diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-07-03 06:33:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-12 10:11:04 -0400 |
commit | 77430f0396aff1f00ccdda378a661cbfebd5b854 (patch) | |
tree | 94f46ef6f18b6a23d8063d7f88bc56baf33721e6 | |
parent | a4d020e97d8e65d57061677c15c89e99609d0b37 (diff) |
[media] omap_vout: use control framework
Replace the old control code with the control framework.
This is one of the few remaining drivers that was not using this
framework.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/platform/omap/omap_vout.c | 109 | ||||
-rw-r--r-- | drivers/media/platform/omap/omap_voutdef.h | 5 |
2 files changed, 29 insertions, 85 deletions
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c index 70c28d19ea04..4afc999c0780 100644 --- a/drivers/media/platform/omap/omap_vout.c +++ b/drivers/media/platform/omap/omap_vout.c | |||
@@ -1318,71 +1318,16 @@ s_crop_err: | |||
1318 | return ret; | 1318 | return ret; |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | static int vidioc_queryctrl(struct file *file, void *fh, | 1321 | static int omap_vout_s_ctrl(struct v4l2_ctrl *ctrl) |
1322 | struct v4l2_queryctrl *ctrl) | ||
1323 | { | 1322 | { |
1323 | struct omap_vout_device *vout = | ||
1324 | container_of(ctrl->handler, struct omap_vout_device, ctrl_handler); | ||
1324 | int ret = 0; | 1325 | int ret = 0; |
1325 | 1326 | ||
1326 | switch (ctrl->id) { | 1327 | switch (ctrl->id) { |
1327 | case V4L2_CID_ROTATE: | 1328 | case V4L2_CID_ROTATE: { |
1328 | ret = v4l2_ctrl_query_fill(ctrl, 0, 270, 90, 0); | ||
1329 | break; | ||
1330 | case V4L2_CID_BG_COLOR: | ||
1331 | ret = v4l2_ctrl_query_fill(ctrl, 0, 0xFFFFFF, 1, 0); | ||
1332 | break; | ||
1333 | case V4L2_CID_VFLIP: | ||
1334 | ret = v4l2_ctrl_query_fill(ctrl, 0, 1, 1, 0); | ||
1335 | break; | ||
1336 | default: | ||
1337 | ctrl->name[0] = '\0'; | ||
1338 | ret = -EINVAL; | ||
1339 | } | ||
1340 | return ret; | ||
1341 | } | ||
1342 | |||
1343 | static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *ctrl) | ||
1344 | { | ||
1345 | int ret = 0; | ||
1346 | struct omap_vout_device *vout = fh; | ||
1347 | |||
1348 | switch (ctrl->id) { | ||
1349 | case V4L2_CID_ROTATE: | ||
1350 | ctrl->value = vout->control[0].value; | ||
1351 | break; | ||
1352 | case V4L2_CID_BG_COLOR: | ||
1353 | { | ||
1354 | struct omap_overlay_manager_info info; | ||
1355 | struct omap_overlay *ovl; | ||
1356 | |||
1357 | ovl = vout->vid_info.overlays[0]; | ||
1358 | if (!ovl->manager || !ovl->manager->get_manager_info) { | ||
1359 | ret = -EINVAL; | ||
1360 | break; | ||
1361 | } | ||
1362 | |||
1363 | ovl->manager->get_manager_info(ovl->manager, &info); | ||
1364 | ctrl->value = info.default_color; | ||
1365 | break; | ||
1366 | } | ||
1367 | case V4L2_CID_VFLIP: | ||
1368 | ctrl->value = vout->control[2].value; | ||
1369 | break; | ||
1370 | default: | ||
1371 | ret = -EINVAL; | ||
1372 | } | ||
1373 | return ret; | ||
1374 | } | ||
1375 | |||
1376 | static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a) | ||
1377 | { | ||
1378 | int ret = 0; | ||
1379 | struct omap_vout_device *vout = fh; | ||
1380 | |||
1381 | switch (a->id) { | ||
1382 | case V4L2_CID_ROTATE: | ||
1383 | { | ||
1384 | struct omapvideo_info *ovid; | 1329 | struct omapvideo_info *ovid; |
1385 | int rotation = a->value; | 1330 | int rotation = ctrl->val; |
1386 | 1331 | ||
1387 | ovid = &vout->vid_info; | 1332 | ovid = &vout->vid_info; |
1388 | 1333 | ||
@@ -1405,15 +1350,13 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a) | |||
1405 | ret = -EINVAL; | 1350 | ret = -EINVAL; |
1406 | break; | 1351 | break; |
1407 | } | 1352 | } |
1408 | |||
1409 | vout->control[0].value = rotation; | ||
1410 | mutex_unlock(&vout->lock); | 1353 | mutex_unlock(&vout->lock); |
1411 | break; | 1354 | break; |
1412 | } | 1355 | } |
1413 | case V4L2_CID_BG_COLOR: | 1356 | case V4L2_CID_BG_COLOR: |
1414 | { | 1357 | { |
1415 | struct omap_overlay *ovl; | 1358 | struct omap_overlay *ovl; |
1416 | unsigned int color = a->value; | 1359 | unsigned int color = ctrl->val; |
1417 | struct omap_overlay_manager_info info; | 1360 | struct omap_overlay_manager_info info; |
1418 | 1361 | ||
1419 | ovl = vout->vid_info.overlays[0]; | 1362 | ovl = vout->vid_info.overlays[0]; |
@@ -1432,15 +1375,13 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a) | |||
1432 | ret = -EINVAL; | 1375 | ret = -EINVAL; |
1433 | break; | 1376 | break; |
1434 | } | 1377 | } |
1435 | |||
1436 | vout->control[1].value = color; | ||
1437 | mutex_unlock(&vout->lock); | 1378 | mutex_unlock(&vout->lock); |
1438 | break; | 1379 | break; |
1439 | } | 1380 | } |
1440 | case V4L2_CID_VFLIP: | 1381 | case V4L2_CID_VFLIP: |
1441 | { | 1382 | { |
1442 | struct omapvideo_info *ovid; | 1383 | struct omapvideo_info *ovid; |
1443 | unsigned int mirror = a->value; | 1384 | unsigned int mirror = ctrl->val; |
1444 | 1385 | ||
1445 | ovid = &vout->vid_info; | 1386 | ovid = &vout->vid_info; |
1446 | 1387 | ||
@@ -1457,16 +1398,19 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a) | |||
1457 | break; | 1398 | break; |
1458 | } | 1399 | } |
1459 | vout->mirror = mirror; | 1400 | vout->mirror = mirror; |
1460 | vout->control[2].value = mirror; | ||
1461 | mutex_unlock(&vout->lock); | 1401 | mutex_unlock(&vout->lock); |
1462 | break; | 1402 | break; |
1463 | } | 1403 | } |
1464 | default: | 1404 | default: |
1465 | ret = -EINVAL; | 1405 | return -EINVAL; |
1466 | } | 1406 | } |
1467 | return ret; | 1407 | return ret; |
1468 | } | 1408 | } |
1469 | 1409 | ||
1410 | static const struct v4l2_ctrl_ops omap_vout_ctrl_ops = { | ||
1411 | .s_ctrl = omap_vout_s_ctrl, | ||
1412 | }; | ||
1413 | |||
1470 | static int vidioc_reqbufs(struct file *file, void *fh, | 1414 | static int vidioc_reqbufs(struct file *file, void *fh, |
1471 | struct v4l2_requestbuffers *req) | 1415 | struct v4l2_requestbuffers *req) |
1472 | { | 1416 | { |
@@ -1831,11 +1775,8 @@ static const struct v4l2_ioctl_ops vout_ioctl_ops = { | |||
1831 | .vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, | 1775 | .vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, |
1832 | .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, | 1776 | .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out, |
1833 | .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, | 1777 | .vidioc_s_fmt_vid_out = vidioc_s_fmt_vid_out, |
1834 | .vidioc_queryctrl = vidioc_queryctrl, | ||
1835 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1836 | .vidioc_s_fbuf = vidioc_s_fbuf, | 1778 | .vidioc_s_fbuf = vidioc_s_fbuf, |
1837 | .vidioc_g_fbuf = vidioc_g_fbuf, | 1779 | .vidioc_g_fbuf = vidioc_g_fbuf, |
1838 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1839 | .vidioc_try_fmt_vid_out_overlay = vidioc_try_fmt_vid_overlay, | 1780 | .vidioc_try_fmt_vid_out_overlay = vidioc_try_fmt_vid_overlay, |
1840 | .vidioc_s_fmt_vid_out_overlay = vidioc_s_fmt_vid_overlay, | 1781 | .vidioc_s_fmt_vid_out_overlay = vidioc_s_fmt_vid_overlay, |
1841 | .vidioc_g_fmt_vid_out_overlay = vidioc_g_fmt_vid_overlay, | 1782 | .vidioc_g_fmt_vid_out_overlay = vidioc_g_fmt_vid_overlay, |
@@ -1865,9 +1806,9 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout) | |||
1865 | { | 1806 | { |
1866 | struct video_device *vfd; | 1807 | struct video_device *vfd; |
1867 | struct v4l2_pix_format *pix; | 1808 | struct v4l2_pix_format *pix; |
1868 | struct v4l2_control *control; | ||
1869 | struct omap_overlay *ovl = vout->vid_info.overlays[0]; | 1809 | struct omap_overlay *ovl = vout->vid_info.overlays[0]; |
1870 | struct omap_dss_device *display = ovl->get_device(ovl); | 1810 | struct omap_dss_device *display = ovl->get_device(ovl); |
1811 | struct v4l2_ctrl_handler *hdl; | ||
1871 | 1812 | ||
1872 | /* set the default pix */ | 1813 | /* set the default pix */ |
1873 | pix = &vout->pix; | 1814 | pix = &vout->pix; |
@@ -1896,29 +1837,32 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout) | |||
1896 | 1837 | ||
1897 | omap_vout_new_format(pix, &vout->fbuf, &vout->crop, &vout->win); | 1838 | omap_vout_new_format(pix, &vout->fbuf, &vout->crop, &vout->win); |
1898 | 1839 | ||
1899 | /*Initialize the control variables for | 1840 | hdl = &vout->ctrl_handler; |
1900 | rotation, flipping and background color. */ | 1841 | v4l2_ctrl_handler_init(hdl, 3); |
1901 | control = vout->control; | 1842 | v4l2_ctrl_new_std(hdl, &omap_vout_ctrl_ops, |
1902 | control[0].id = V4L2_CID_ROTATE; | 1843 | V4L2_CID_ROTATE, 0, 270, 90, 0); |
1903 | control[0].value = 0; | 1844 | v4l2_ctrl_new_std(hdl, &omap_vout_ctrl_ops, |
1845 | V4L2_CID_BG_COLOR, 0, 0xffffff, 1, 0); | ||
1846 | v4l2_ctrl_new_std(hdl, &omap_vout_ctrl_ops, | ||
1847 | V4L2_CID_VFLIP, 0, 1, 1, 0); | ||
1848 | if (hdl->error) | ||
1849 | return hdl->error; | ||
1850 | |||
1904 | vout->rotation = 0; | 1851 | vout->rotation = 0; |
1905 | vout->mirror = false; | 1852 | vout->mirror = false; |
1906 | vout->control[2].id = V4L2_CID_HFLIP; | ||
1907 | vout->control[2].value = 0; | ||
1908 | if (vout->vid_info.rotation_type == VOUT_ROT_VRFB) | 1853 | if (vout->vid_info.rotation_type == VOUT_ROT_VRFB) |
1909 | vout->vrfb_bpp = 2; | 1854 | vout->vrfb_bpp = 2; |
1910 | 1855 | ||
1911 | control[1].id = V4L2_CID_BG_COLOR; | ||
1912 | control[1].value = 0; | ||
1913 | |||
1914 | /* initialize the video_device struct */ | 1856 | /* initialize the video_device struct */ |
1915 | vfd = vout->vfd = video_device_alloc(); | 1857 | vfd = vout->vfd = video_device_alloc(); |
1916 | 1858 | ||
1917 | if (!vfd) { | 1859 | if (!vfd) { |
1918 | printk(KERN_ERR VOUT_NAME ": could not allocate" | 1860 | printk(KERN_ERR VOUT_NAME ": could not allocate" |
1919 | " video device struct\n"); | 1861 | " video device struct\n"); |
1862 | v4l2_ctrl_handler_free(hdl); | ||
1920 | return -ENOMEM; | 1863 | return -ENOMEM; |
1921 | } | 1864 | } |
1865 | vfd->ctrl_handler = hdl; | ||
1922 | vfd->release = video_device_release; | 1866 | vfd->release = video_device_release; |
1923 | vfd->ioctl_ops = &vout_ioctl_ops; | 1867 | vfd->ioctl_ops = &vout_ioctl_ops; |
1924 | 1868 | ||
@@ -2092,6 +2036,7 @@ static void omap_vout_cleanup_device(struct omap_vout_device *vout) | |||
2092 | video_unregister_device(vfd); | 2036 | video_unregister_device(vfd); |
2093 | } | 2037 | } |
2094 | } | 2038 | } |
2039 | v4l2_ctrl_handler_free(&vout->ctrl_handler); | ||
2095 | if (ovid->rotation_type == VOUT_ROT_VRFB) { | 2040 | if (ovid->rotation_type == VOUT_ROT_VRFB) { |
2096 | omap_vout_release_vrfb(vout); | 2041 | omap_vout_release_vrfb(vout); |
2097 | /* Free the VRFB buffer if allocated | 2042 | /* Free the VRFB buffer if allocated |
diff --git a/drivers/media/platform/omap/omap_voutdef.h b/drivers/media/platform/omap/omap_voutdef.h index 9ccfe1f475a4..49de1475e473 100644 --- a/drivers/media/platform/omap/omap_voutdef.h +++ b/drivers/media/platform/omap/omap_voutdef.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #ifndef OMAP_VOUTDEF_H | 11 | #ifndef OMAP_VOUTDEF_H |
12 | #define OMAP_VOUTDEF_H | 12 | #define OMAP_VOUTDEF_H |
13 | 13 | ||
14 | #include <media/v4l2-ctrls.h> | ||
14 | #include <video/omapdss.h> | 15 | #include <video/omapdss.h> |
15 | #include <video/omapvrfb.h> | 16 | #include <video/omapvrfb.h> |
16 | 17 | ||
@@ -116,6 +117,7 @@ struct omap_vout_device { | |||
116 | struct omapvideo_info vid_info; | 117 | struct omapvideo_info vid_info; |
117 | struct video_device *vfd; | 118 | struct video_device *vfd; |
118 | struct omap2video_device *vid_dev; | 119 | struct omap2video_device *vid_dev; |
120 | struct v4l2_ctrl_handler ctrl_handler; | ||
119 | int vid; | 121 | int vid; |
120 | int opened; | 122 | int opened; |
121 | 123 | ||
@@ -149,12 +151,9 @@ struct omap_vout_device { | |||
149 | /* Lock to protect the shared data structures in ioctl */ | 151 | /* Lock to protect the shared data structures in ioctl */ |
150 | struct mutex lock; | 152 | struct mutex lock; |
151 | 153 | ||
152 | /* V4L2 control structure for different control id */ | ||
153 | struct v4l2_control control[MAX_CID]; | ||
154 | enum dss_rotation rotation; | 154 | enum dss_rotation rotation; |
155 | bool mirror; | 155 | bool mirror; |
156 | int flicker_filter; | 156 | int flicker_filter; |
157 | /* V4L2 control structure for different control id */ | ||
158 | 157 | ||
159 | int bpp; /* bytes per pixel */ | 158 | int bpp; /* bytes per pixel */ |
160 | int vrfb_bpp; /* bytes per pixel with respect to VRFB */ | 159 | int vrfb_bpp; /* bytes per pixel with respect to VRFB */ |