diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2013-01-29 06:06:35 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-08 11:42:57 -0500 |
commit | dbf8f4e5839869d1ead50b661a2cbab3b7225002 (patch) | |
tree | 0bc598c088269e5c005a803a941182f596e082b5 /drivers/media | |
parent | 593403c59b2c1977cf22313d4bb7e912b35ee797 (diff) |
[media] via-camera: implement the control framework
And added a missing kfree to clean up the via_camera struct.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/via-camera.c | 60 |
1 files changed, 14 insertions, 46 deletions
diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c index 63e8c3461239..b051c4a28554 100644 --- a/drivers/media/platform/via-camera.c +++ b/drivers/media/platform/via-camera.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <media/v4l2-device.h> | 18 | #include <media/v4l2-device.h> |
19 | #include <media/v4l2-ioctl.h> | 19 | #include <media/v4l2-ioctl.h> |
20 | #include <media/v4l2-chip-ident.h> | 20 | #include <media/v4l2-chip-ident.h> |
21 | #include <media/v4l2-ctrls.h> | ||
21 | #include <media/ov7670.h> | 22 | #include <media/ov7670.h> |
22 | #include <media/videobuf-dma-sg.h> | 23 | #include <media/videobuf-dma-sg.h> |
23 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
@@ -63,6 +64,7 @@ enum viacam_opstate { S_IDLE = 0, S_RUNNING = 1 }; | |||
63 | 64 | ||
64 | struct via_camera { | 65 | struct via_camera { |
65 | struct v4l2_device v4l2_dev; | 66 | struct v4l2_device v4l2_dev; |
67 | struct v4l2_ctrl_handler ctrl_handler; | ||
66 | struct video_device vdev; | 68 | struct video_device vdev; |
67 | struct v4l2_subdev *sensor; | 69 | struct v4l2_subdev *sensor; |
68 | struct platform_device *platdev; | 70 | struct platform_device *platdev; |
@@ -818,47 +820,6 @@ static int viacam_g_chip_ident(struct file *file, void *priv, | |||
818 | } | 820 | } |
819 | 821 | ||
820 | /* | 822 | /* |
821 | * Control ops are passed through to the sensor. | ||
822 | */ | ||
823 | static int viacam_queryctrl(struct file *filp, void *priv, | ||
824 | struct v4l2_queryctrl *qc) | ||
825 | { | ||
826 | struct via_camera *cam = priv; | ||
827 | int ret; | ||
828 | |||
829 | mutex_lock(&cam->lock); | ||
830 | ret = sensor_call(cam, core, queryctrl, qc); | ||
831 | mutex_unlock(&cam->lock); | ||
832 | return ret; | ||
833 | } | ||
834 | |||
835 | |||
836 | static int viacam_g_ctrl(struct file *filp, void *priv, | ||
837 | struct v4l2_control *ctrl) | ||
838 | { | ||
839 | struct via_camera *cam = priv; | ||
840 | int ret; | ||
841 | |||
842 | mutex_lock(&cam->lock); | ||
843 | ret = sensor_call(cam, core, g_ctrl, ctrl); | ||
844 | mutex_unlock(&cam->lock); | ||
845 | return ret; | ||
846 | } | ||
847 | |||
848 | |||
849 | static int viacam_s_ctrl(struct file *filp, void *priv, | ||
850 | struct v4l2_control *ctrl) | ||
851 | { | ||
852 | struct via_camera *cam = priv; | ||
853 | int ret; | ||
854 | |||
855 | mutex_lock(&cam->lock); | ||
856 | ret = sensor_call(cam, core, s_ctrl, ctrl); | ||
857 | mutex_unlock(&cam->lock); | ||
858 | return ret; | ||
859 | } | ||
860 | |||
861 | /* | ||
862 | * Only one input. | 823 | * Only one input. |
863 | */ | 824 | */ |
864 | static int viacam_enum_input(struct file *filp, void *priv, | 825 | static int viacam_enum_input(struct file *filp, void *priv, |
@@ -1214,9 +1175,6 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv, | |||
1214 | 1175 | ||
1215 | static const struct v4l2_ioctl_ops viacam_ioctl_ops = { | 1176 | static const struct v4l2_ioctl_ops viacam_ioctl_ops = { |
1216 | .vidioc_g_chip_ident = viacam_g_chip_ident, | 1177 | .vidioc_g_chip_ident = viacam_g_chip_ident, |
1217 | .vidioc_queryctrl = viacam_queryctrl, | ||
1218 | .vidioc_g_ctrl = viacam_g_ctrl, | ||
1219 | .vidioc_s_ctrl = viacam_s_ctrl, | ||
1220 | .vidioc_enum_input = viacam_enum_input, | 1178 | .vidioc_enum_input = viacam_enum_input, |
1221 | .vidioc_g_input = viacam_g_input, | 1179 | .vidioc_g_input = viacam_g_input, |
1222 | .vidioc_s_input = viacam_s_input, | 1180 | .vidioc_s_input = viacam_s_input, |
@@ -1418,8 +1376,12 @@ static int viacam_probe(struct platform_device *pdev) | |||
1418 | ret = v4l2_device_register(&pdev->dev, &cam->v4l2_dev); | 1376 | ret = v4l2_device_register(&pdev->dev, &cam->v4l2_dev); |
1419 | if (ret) { | 1377 | if (ret) { |
1420 | dev_err(&pdev->dev, "Unable to register v4l2 device\n"); | 1378 | dev_err(&pdev->dev, "Unable to register v4l2 device\n"); |
1421 | return ret; | 1379 | goto out_free; |
1422 | } | 1380 | } |
1381 | ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10); | ||
1382 | if (ret) | ||
1383 | goto out_unregister; | ||
1384 | cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler; | ||
1423 | /* | 1385 | /* |
1424 | * Convince the system that we can do DMA. | 1386 | * Convince the system that we can do DMA. |
1425 | */ | 1387 | */ |
@@ -1436,7 +1398,7 @@ static int viacam_probe(struct platform_device *pdev) | |||
1436 | */ | 1398 | */ |
1437 | ret = via_sensor_power_setup(cam); | 1399 | ret = via_sensor_power_setup(cam); |
1438 | if (ret) | 1400 | if (ret) |
1439 | goto out_unregister; | 1401 | goto out_ctrl_hdl_free; |
1440 | via_sensor_power_up(cam); | 1402 | via_sensor_power_up(cam); |
1441 | 1403 | ||
1442 | /* | 1404 | /* |
@@ -1485,8 +1447,12 @@ out_irq: | |||
1485 | free_irq(viadev->pdev->irq, cam); | 1447 | free_irq(viadev->pdev->irq, cam); |
1486 | out_power_down: | 1448 | out_power_down: |
1487 | via_sensor_power_release(cam); | 1449 | via_sensor_power_release(cam); |
1450 | out_ctrl_hdl_free: | ||
1451 | v4l2_ctrl_handler_free(&cam->ctrl_handler); | ||
1488 | out_unregister: | 1452 | out_unregister: |
1489 | v4l2_device_unregister(&cam->v4l2_dev); | 1453 | v4l2_device_unregister(&cam->v4l2_dev); |
1454 | out_free: | ||
1455 | kfree(cam); | ||
1490 | return ret; | 1456 | return ret; |
1491 | } | 1457 | } |
1492 | 1458 | ||
@@ -1499,6 +1465,8 @@ static int viacam_remove(struct platform_device *pdev) | |||
1499 | v4l2_device_unregister(&cam->v4l2_dev); | 1465 | v4l2_device_unregister(&cam->v4l2_dev); |
1500 | free_irq(viadev->pdev->irq, cam); | 1466 | free_irq(viadev->pdev->irq, cam); |
1501 | via_sensor_power_release(cam); | 1467 | via_sensor_power_release(cam); |
1468 | v4l2_ctrl_handler_free(&cam->ctrl_handler); | ||
1469 | kfree(cam); | ||
1502 | via_cam_info = NULL; | 1470 | via_cam_info = NULL; |
1503 | return 0; | 1471 | return 0; |
1504 | } | 1472 | } |