Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 241974
b: refs/heads/master
c: 0522921
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Drake authored and Mauro Carvalho Chehab committed Mar 21, 2011
1 parent eefe7c2 commit 50579be
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 498e677cfd78b098342640f382293782bfa0bd63
refs/heads/master: 0522921c0f89f274a99d5084ca0a6fd370749cc8
64 changes: 64 additions & 0 deletions trunk/drivers/media/video/via-camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,62 @@ static const struct v4l2_ioctl_ops viacam_ioctl_ops = {
/*
* Power management.
*/
#ifdef CONFIG_PM

static int viacam_suspend(void *priv)
{
struct via_camera *cam = priv;
enum viacam_opstate state = cam->opstate;

if (cam->opstate != S_IDLE) {
viacam_stop_engine(cam);
cam->opstate = state; /* So resume restarts */
}

return 0;
}

static int viacam_resume(void *priv)
{
struct via_camera *cam = priv;
int ret = 0;

/*
* Get back to a reasonable operating state.
*/
via_write_reg_mask(VIASR, 0x78, 0, 0x80);
via_write_reg_mask(VIASR, 0x1e, 0xc0, 0xc0);
viacam_int_disable(cam);
set_bit(CF_CONFIG_NEEDED, &cam->flags);
/*
* Make sure the sensor's power state is correct
*/
if (cam->users > 0)
via_sensor_power_up(cam);
else
via_sensor_power_down(cam);
/*
* If it was operating, try to restart it.
*/
if (cam->opstate != S_IDLE) {
mutex_lock(&cam->lock);
ret = viacam_configure_sensor(cam);
if (!ret)
ret = viacam_config_controller(cam);
mutex_unlock(&cam->lock);
if (!ret)
viacam_start_engine(cam);
}

return ret;
}

static struct viafb_pm_hooks viacam_pm_hooks = {
.suspend = viacam_suspend,
.resume = viacam_resume
};

#endif /* CONFIG_PM */

/*
* Setup stuff.
Expand Down Expand Up @@ -1369,6 +1425,14 @@ static __devinit int viacam_probe(struct platform_device *pdev)
goto out_irq;
video_set_drvdata(&cam->vdev, cam);

#ifdef CONFIG_PM
/*
* Hook into PM events
*/
viacam_pm_hooks.private = cam;
viafb_pm_register(&viacam_pm_hooks);
#endif

/* Power the sensor down until somebody opens the device */
via_sensor_power_down(cam);
return 0;
Expand Down

0 comments on commit 50579be

Please sign in to comment.