diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2013-01-29 05:58:48 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-08 11:42:16 -0500 |
commit | 593403c59b2c1977cf22313d4bb7e912b35ee797 (patch) | |
tree | c102277504ee042e19989b07ea8e53816aaad5cf | |
parent | 492959c77f66c2238298115f4fabf1bb9ca997eb (diff) |
[media] mcam-core: implement the control framework
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>
-rw-r--r-- | drivers/media/platform/marvell-ccic/mcam-core.c | 54 | ||||
-rw-r--r-- | drivers/media/platform/marvell-ccic/mcam-core.h | 2 |
2 files changed, 11 insertions, 45 deletions
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 7012913f34a2..92a33f081852 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/videodev2.h> | 22 | #include <linux/videodev2.h> |
23 | #include <media/v4l2-device.h> | 23 | #include <media/v4l2-device.h> |
24 | #include <media/v4l2-ioctl.h> | 24 | #include <media/v4l2-ioctl.h> |
25 | #include <media/v4l2-ctrls.h> | ||
25 | #include <media/v4l2-chip-ident.h> | 26 | #include <media/v4l2-chip-ident.h> |
26 | #include <media/ov7670.h> | 27 | #include <media/ov7670.h> |
27 | #include <media/videobuf2-vmalloc.h> | 28 | #include <media/videobuf2-vmalloc.h> |
@@ -1225,47 +1226,6 @@ static int mcam_vidioc_dqbuf(struct file *filp, void *priv, | |||
1225 | return ret; | 1226 | return ret; |
1226 | } | 1227 | } |
1227 | 1228 | ||
1228 | |||
1229 | |||
1230 | static int mcam_vidioc_queryctrl(struct file *filp, void *priv, | ||
1231 | struct v4l2_queryctrl *qc) | ||
1232 | { | ||
1233 | struct mcam_camera *cam = priv; | ||
1234 | int ret; | ||
1235 | |||
1236 | mutex_lock(&cam->s_mutex); | ||
1237 | ret = sensor_call(cam, core, queryctrl, qc); | ||
1238 | mutex_unlock(&cam->s_mutex); | ||
1239 | return ret; | ||
1240 | } | ||
1241 | |||
1242 | |||
1243 | static int mcam_vidioc_g_ctrl(struct file *filp, void *priv, | ||
1244 | struct v4l2_control *ctrl) | ||
1245 | { | ||
1246 | struct mcam_camera *cam = priv; | ||
1247 | int ret; | ||
1248 | |||
1249 | mutex_lock(&cam->s_mutex); | ||
1250 | ret = sensor_call(cam, core, g_ctrl, ctrl); | ||
1251 | mutex_unlock(&cam->s_mutex); | ||
1252 | return ret; | ||
1253 | } | ||
1254 | |||
1255 | |||
1256 | static int mcam_vidioc_s_ctrl(struct file *filp, void *priv, | ||
1257 | struct v4l2_control *ctrl) | ||
1258 | { | ||
1259 | struct mcam_camera *cam = priv; | ||
1260 | int ret; | ||
1261 | |||
1262 | mutex_lock(&cam->s_mutex); | ||
1263 | ret = sensor_call(cam, core, s_ctrl, ctrl); | ||
1264 | mutex_unlock(&cam->s_mutex); | ||
1265 | return ret; | ||
1266 | } | ||
1267 | |||
1268 | |||
1269 | static int mcam_vidioc_querycap(struct file *file, void *priv, | 1229 | static int mcam_vidioc_querycap(struct file *file, void *priv, |
1270 | struct v4l2_capability *cap) | 1230 | struct v4l2_capability *cap) |
1271 | { | 1231 | { |
@@ -1513,9 +1473,6 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = { | |||
1513 | .vidioc_dqbuf = mcam_vidioc_dqbuf, | 1473 | .vidioc_dqbuf = mcam_vidioc_dqbuf, |
1514 | .vidioc_streamon = mcam_vidioc_streamon, | 1474 | .vidioc_streamon = mcam_vidioc_streamon, |
1515 | .vidioc_streamoff = mcam_vidioc_streamoff, | 1475 | .vidioc_streamoff = mcam_vidioc_streamoff, |
1516 | .vidioc_queryctrl = mcam_vidioc_queryctrl, | ||
1517 | .vidioc_g_ctrl = mcam_vidioc_g_ctrl, | ||
1518 | .vidioc_s_ctrl = mcam_vidioc_s_ctrl, | ||
1519 | .vidioc_g_parm = mcam_vidioc_g_parm, | 1476 | .vidioc_g_parm = mcam_vidioc_g_parm, |
1520 | .vidioc_s_parm = mcam_vidioc_s_parm, | 1477 | .vidioc_s_parm = mcam_vidioc_s_parm, |
1521 | .vidioc_enum_framesizes = mcam_vidioc_enum_framesizes, | 1478 | .vidioc_enum_framesizes = mcam_vidioc_enum_framesizes, |
@@ -1782,14 +1739,19 @@ int mccic_register(struct mcam_camera *cam) | |||
1782 | /* | 1739 | /* |
1783 | * Get the v4l2 setup done. | 1740 | * Get the v4l2 setup done. |
1784 | */ | 1741 | */ |
1742 | ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10); | ||
1743 | if (ret) | ||
1744 | goto out_unregister; | ||
1745 | cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler; | ||
1746 | |||
1785 | mutex_lock(&cam->s_mutex); | 1747 | mutex_lock(&cam->s_mutex); |
1786 | cam->vdev = mcam_v4l_template; | 1748 | cam->vdev = mcam_v4l_template; |
1787 | cam->vdev.debug = 0; | 1749 | cam->vdev.debug = 0; |
1788 | cam->vdev.v4l2_dev = &cam->v4l2_dev; | 1750 | cam->vdev.v4l2_dev = &cam->v4l2_dev; |
1751 | video_set_drvdata(&cam->vdev, cam); | ||
1789 | ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1); | 1752 | ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1); |
1790 | if (ret) | 1753 | if (ret) |
1791 | goto out; | 1754 | goto out; |
1792 | video_set_drvdata(&cam->vdev, cam); | ||
1793 | 1755 | ||
1794 | /* | 1756 | /* |
1795 | * If so requested, try to get our DMA buffers now. | 1757 | * If so requested, try to get our DMA buffers now. |
@@ -1801,6 +1763,7 @@ int mccic_register(struct mcam_camera *cam) | |||
1801 | } | 1763 | } |
1802 | 1764 | ||
1803 | out: | 1765 | out: |
1766 | v4l2_ctrl_handler_free(&cam->ctrl_handler); | ||
1804 | mutex_unlock(&cam->s_mutex); | 1767 | mutex_unlock(&cam->s_mutex); |
1805 | return ret; | 1768 | return ret; |
1806 | out_unregister: | 1769 | out_unregister: |
@@ -1825,6 +1788,7 @@ void mccic_shutdown(struct mcam_camera *cam) | |||
1825 | if (cam->buffer_mode == B_vmalloc) | 1788 | if (cam->buffer_mode == B_vmalloc) |
1826 | mcam_free_dma_bufs(cam); | 1789 | mcam_free_dma_bufs(cam); |
1827 | video_unregister_device(&cam->vdev); | 1790 | video_unregister_device(&cam->vdev); |
1791 | v4l2_ctrl_handler_free(&cam->ctrl_handler); | ||
1828 | v4l2_device_unregister(&cam->v4l2_dev); | 1792 | v4l2_device_unregister(&cam->v4l2_dev); |
1829 | } | 1793 | } |
1830 | 1794 | ||
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index 6c53ac9681da..01dec9e5fc2b 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | #include <media/v4l2-common.h> | 10 | #include <media/v4l2-common.h> |
11 | #include <media/v4l2-ctrls.h> | ||
11 | #include <media/v4l2-dev.h> | 12 | #include <media/v4l2-dev.h> |
12 | #include <media/videobuf2-core.h> | 13 | #include <media/videobuf2-core.h> |
13 | 14 | ||
@@ -112,6 +113,7 @@ struct mcam_camera { | |||
112 | * should not be touched by the platform code. | 113 | * should not be touched by the platform code. |
113 | */ | 114 | */ |
114 | struct v4l2_device v4l2_dev; | 115 | struct v4l2_device v4l2_dev; |
116 | struct v4l2_ctrl_handler ctrl_handler; | ||
115 | enum mcam_state state; | 117 | enum mcam_state state; |
116 | unsigned long flags; /* Buffer status, mainly (dev_lock) */ | 118 | unsigned long flags; /* Buffer status, mainly (dev_lock) */ |
117 | int users; /* How many open FDs */ | 119 | int users; /* How many open FDs */ |