aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArchit Taneja <archit@ti.com>2012-07-20 08:56:30 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2012-09-26 07:58:32 -0400
commitd629f03f748c46277c421ed5b892f0b39fd1fe47 (patch)
tree6d128f6192e0a581f675cb94d4a0ad746aedf26e
parent794bc4eefa10fbc80e6ad29de1bc42424efde608 (diff)
OMAP_VOUT: Remove manager->device references
With the introduction of output entities, managers will now connect to outputs. Use the helper op for overlays named get_device. This will abstract away the information on how to get the omap_dss_device pointer from an overlay. Using the helper function will reduce the number of pointer dereferences a user of OMAPDSS needs to do and reduce risk of a NULL dereference. Cc: Vaibhav Hiremath <hvaibhav@ti.com> Signed-off-by: Archit Taneja <archit@ti.com>
-rw-r--r--drivers/media/video/omap/omap_vout.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
index 88cf9d952631..f721fd2155f7 100644
--- a/drivers/media/video/omap/omap_vout.c
+++ b/drivers/media/video/omap/omap_vout.c
@@ -454,11 +454,15 @@ static int omapvid_init(struct omap_vout_device *vout, u32 addr)
454 454
455 win = &vout->win; 455 win = &vout->win;
456 for (i = 0; i < ovid->num_overlays; i++) { 456 for (i = 0; i < ovid->num_overlays; i++) {
457 struct omap_dss_device *dssdev;
458
457 ovl = ovid->overlays[i]; 459 ovl = ovid->overlays[i];
458 if (!ovl->manager || !ovl->manager->device) 460 dssdev = ovl->get_device(ovl);
461
462 if (!dssdev)
459 return -EINVAL; 463 return -EINVAL;
460 464
461 timing = &ovl->manager->device->panel.timings; 465 timing = &dssdev->panel.timings;
462 466
463 outw = win->w.width; 467 outw = win->w.width;
464 outh = win->w.height; 468 outh = win->w.height;
@@ -515,8 +519,11 @@ static int omapvid_apply_changes(struct omap_vout_device *vout)
515 struct omapvideo_info *ovid = &vout->vid_info; 519 struct omapvideo_info *ovid = &vout->vid_info;
516 520
517 for (i = 0; i < ovid->num_overlays; i++) { 521 for (i = 0; i < ovid->num_overlays; i++) {
522 struct omap_dss_device *dssdev;
523
518 ovl = ovid->overlays[i]; 524 ovl = ovid->overlays[i];
519 if (!ovl->manager || !ovl->manager->device) 525 dssdev = ovl->get_device(ovl);
526 if (!dssdev)
520 return -EINVAL; 527 return -EINVAL;
521 ovl->manager->apply(ovl->manager); 528 ovl->manager->apply(ovl->manager);
522 } 529 }
@@ -579,12 +586,14 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
579 586
580 ovid = &vout->vid_info; 587 ovid = &vout->vid_info;
581 ovl = ovid->overlays[0]; 588 ovl = ovid->overlays[0];
582 /* get the display device attached to the overlay */
583 if (!ovl->manager || !ovl->manager->device)
584 return;
585 589
586 mgr_id = ovl->manager->id; 590 mgr_id = ovl->manager->id;
587 cur_display = ovl->manager->device; 591
592 /* get the display device attached to the overlay */
593 cur_display = ovl->get_device(ovl);
594
595 if (!cur_display)
596 return;
588 597
589 spin_lock(&vout->vbq_lock); 598 spin_lock(&vout->vbq_lock);
590 do_gettimeofday(&timevalue); 599 do_gettimeofday(&timevalue);
@@ -948,7 +957,9 @@ static int omap_vout_release(struct file *file)
948 /* Disable all the overlay managers connected with this interface */ 957 /* Disable all the overlay managers connected with this interface */
949 for (i = 0; i < ovid->num_overlays; i++) { 958 for (i = 0; i < ovid->num_overlays; i++) {
950 struct omap_overlay *ovl = ovid->overlays[i]; 959 struct omap_overlay *ovl = ovid->overlays[i];
951 if (ovl->manager && ovl->manager->device) 960 struct omap_dss_device *dssdev = ovl->get_device(ovl);
961
962 if (dssdev)
952 ovl->disable(ovl); 963 ovl->disable(ovl);
953 } 964 }
954 /* Turn off the pipeline */ 965 /* Turn off the pipeline */
@@ -1081,14 +1092,17 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *fh,
1081 struct omapvideo_info *ovid; 1092 struct omapvideo_info *ovid;
1082 struct omap_video_timings *timing; 1093 struct omap_video_timings *timing;
1083 struct omap_vout_device *vout = fh; 1094 struct omap_vout_device *vout = fh;
1095 struct omap_dss_device *dssdev;
1084 1096
1085 ovid = &vout->vid_info; 1097 ovid = &vout->vid_info;
1086 ovl = ovid->overlays[0]; 1098 ovl = ovid->overlays[0];
1099 /* get the display device attached to the overlay */
1100 dssdev = ovl->get_device(ovl);
1087 1101
1088 if (!ovl->manager || !ovl->manager->device) 1102 if (!dssdev)
1089 return -EINVAL; 1103 return -EINVAL;
1090 /* get the display device attached to the overlay */ 1104
1091 timing = &ovl->manager->device->panel.timings; 1105 timing = &dssdev->panel.timings;
1092 1106
1093 vout->fbuf.fmt.height = timing->y_res; 1107 vout->fbuf.fmt.height = timing->y_res;
1094 vout->fbuf.fmt.width = timing->x_res; 1108 vout->fbuf.fmt.width = timing->x_res;
@@ -1105,6 +1119,7 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
1105 struct omapvideo_info *ovid; 1119 struct omapvideo_info *ovid;
1106 struct omap_video_timings *timing; 1120 struct omap_video_timings *timing;
1107 struct omap_vout_device *vout = fh; 1121 struct omap_vout_device *vout = fh;
1122 struct omap_dss_device *dssdev;
1108 1123
1109 if (vout->streaming) 1124 if (vout->streaming)
1110 return -EBUSY; 1125 return -EBUSY;
@@ -1113,13 +1128,14 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
1113 1128
1114 ovid = &vout->vid_info; 1129 ovid = &vout->vid_info;
1115 ovl = ovid->overlays[0]; 1130 ovl = ovid->overlays[0];
1131 dssdev = ovl->get_device(ovl);
1116 1132
1117 /* get the display device attached to the overlay */ 1133 /* get the display device attached to the overlay */
1118 if (!ovl->manager || !ovl->manager->device) { 1134 if (!dssdev) {
1119 ret = -EINVAL; 1135 ret = -EINVAL;
1120 goto s_fmt_vid_out_exit; 1136 goto s_fmt_vid_out_exit;
1121 } 1137 }
1122 timing = &ovl->manager->device->panel.timings; 1138 timing = &dssdev->panel.timings;
1123 1139
1124 /* We dont support RGB24-packed mode if vrfb rotation 1140 /* We dont support RGB24-packed mode if vrfb rotation
1125 * is enabled*/ 1141 * is enabled*/
@@ -1298,6 +1314,7 @@ static int vidioc_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
1298 struct omapvideo_info *ovid; 1314 struct omapvideo_info *ovid;
1299 struct omap_overlay *ovl; 1315 struct omap_overlay *ovl;
1300 struct omap_video_timings *timing; 1316 struct omap_video_timings *timing;
1317 struct omap_dss_device *dssdev;
1301 1318
1302 if (vout->streaming) 1319 if (vout->streaming)
1303 return -EBUSY; 1320 return -EBUSY;
@@ -1305,13 +1322,15 @@ static int vidioc_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
1305 mutex_lock(&vout->lock); 1322 mutex_lock(&vout->lock);
1306 ovid = &vout->vid_info; 1323 ovid = &vout->vid_info;
1307 ovl = ovid->overlays[0]; 1324 ovl = ovid->overlays[0];
1325 /* get the display device attached to the overlay */
1326 dssdev = ovl->get_device(ovl);
1308 1327
1309 if (!ovl->manager || !ovl->manager->device) { 1328 if (!dssdev) {
1310 ret = -EINVAL; 1329 ret = -EINVAL;
1311 goto s_crop_err; 1330 goto s_crop_err;
1312 } 1331 }
1313 /* get the display device attached to the overlay */ 1332
1314 timing = &ovl->manager->device->panel.timings; 1333 timing = &dssdev->panel.timings;
1315 1334
1316 if (is_rotation_90_or_270(vout)) { 1335 if (is_rotation_90_or_270(vout)) {
1317 vout->fbuf.fmt.height = timing->x_res; 1336 vout->fbuf.fmt.height = timing->x_res;
@@ -1667,7 +1686,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
1667 for (j = 0; j < ovid->num_overlays; j++) { 1686 for (j = 0; j < ovid->num_overlays; j++) {
1668 struct omap_overlay *ovl = ovid->overlays[j]; 1687 struct omap_overlay *ovl = ovid->overlays[j];
1669 1688
1670 if (ovl->manager && ovl->manager->device) { 1689 if (ovl->get_device(ovl)) {
1671 struct omap_overlay_info info; 1690 struct omap_overlay_info info;
1672 ovl->get_overlay_info(ovl, &info); 1691 ovl->get_overlay_info(ovl, &info);
1673 info.paddr = addr; 1692 info.paddr = addr;
@@ -1690,8 +1709,9 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
1690 1709
1691 for (j = 0; j < ovid->num_overlays; j++) { 1710 for (j = 0; j < ovid->num_overlays; j++) {
1692 struct omap_overlay *ovl = ovid->overlays[j]; 1711 struct omap_overlay *ovl = ovid->overlays[j];
1712 struct omap_dss_device *dssdev = ovl->get_device(ovl);
1693 1713
1694 if (ovl->manager && ovl->manager->device) { 1714 if (dssdev) {
1695 ret = ovl->enable(ovl); 1715 ret = ovl->enable(ovl);
1696 if (ret) 1716 if (ret)
1697 goto streamon_err1; 1717 goto streamon_err1;
@@ -1726,8 +1746,9 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
1726 1746
1727 for (j = 0; j < ovid->num_overlays; j++) { 1747 for (j = 0; j < ovid->num_overlays; j++) {
1728 struct omap_overlay *ovl = ovid->overlays[j]; 1748 struct omap_overlay *ovl = ovid->overlays[j];
1749 struct omap_dss_device *dssdev = ovl->get_device(ovl);
1729 1750
1730 if (ovl->manager && ovl->manager->device) 1751 if (dssdev)
1731 ovl->disable(ovl); 1752 ovl->disable(ovl);
1732 } 1753 }
1733 1754
@@ -1890,8 +1911,8 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
1890 struct video_device *vfd; 1911 struct video_device *vfd;
1891 struct v4l2_pix_format *pix; 1912 struct v4l2_pix_format *pix;
1892 struct v4l2_control *control; 1913 struct v4l2_control *control;
1893 struct omap_dss_device *display = 1914 struct omap_overlay *ovl = vout->vid_info.overlays[0];
1894 vout->vid_info.overlays[0]->manager->device; 1915 struct omap_dss_device *display = ovl->get_device(ovl);
1895 1916
1896 /* set the default pix */ 1917 /* set the default pix */
1897 pix = &vout->pix; 1918 pix = &vout->pix;
@@ -2205,8 +2226,10 @@ static int __init omap_vout_probe(struct platform_device *pdev)
2205 */ 2226 */
2206 for (i = 1; i < vid_dev->num_overlays; i++) { 2227 for (i = 1; i < vid_dev->num_overlays; i++) {
2207 ovl = omap_dss_get_overlay(i); 2228 ovl = omap_dss_get_overlay(i);
2208 if (ovl->manager && ovl->manager->device) { 2229 dssdev = ovl->get_device(ovl);
2209 def_display = ovl->manager->device; 2230
2231 if (dssdev) {
2232 def_display = dssdev;
2210 } else { 2233 } else {
2211 dev_warn(&pdev->dev, "cannot find display\n"); 2234 dev_warn(&pdev->dev, "cannot find display\n");
2212 def_display = NULL; 2235 def_display = NULL;
@@ -2253,8 +2276,10 @@ probe_err1:
2253 for (i = 1; i < vid_dev->num_overlays; i++) { 2276 for (i = 1; i < vid_dev->num_overlays; i++) {
2254 def_display = NULL; 2277 def_display = NULL;
2255 ovl = omap_dss_get_overlay(i); 2278 ovl = omap_dss_get_overlay(i);
2256 if (ovl->manager && ovl->manager->device) 2279 dssdev = ovl->get_device(ovl);
2257 def_display = ovl->manager->device; 2280
2281 if (dssdev)
2282 def_display = dssdev;
2258 2283
2259 if (def_display && def_display->driver) 2284 if (def_display && def_display->driver)
2260 def_display->driver->disable(def_display); 2285 def_display->driver->disable(def_display);