aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Randgaard <mats.randgaard@cisco.com>2010-12-16 10:17:43 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-19 08:28:16 -0500
commit40c8bcea6bc594c50abf3d3867bd49c8c039eb21 (patch)
tree8472b31720934b42520d19dc16ec4fe2bc247737
parentaa4444063505983c5971bc8fb832385dfba16b41 (diff)
[media] vpif_cap/disp: Add support for DV presets
- Added functions to set/get/query/enum DV presets for vpif_caputre and vpif_display. - The format specification table is extended with all the DV formats supported by TVP7002. Signed-off-by: Mats Randgaard <mats.randgaard@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Manjunath Hadli <manjunath.hadli@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/davinci/vpif.c127
-rw-r--r--drivers/media/video/davinci/vpif.h1
-rw-r--r--drivers/media/video/davinci/vpif_capture.c124
-rw-r--r--drivers/media/video/davinci/vpif_capture.h1
-rw-r--r--drivers/media/video/davinci/vpif_display.c105
-rw-r--r--drivers/media/video/davinci/vpif_display.h1
6 files changed, 350 insertions, 9 deletions
diff --git a/drivers/media/video/davinci/vpif.c b/drivers/media/video/davinci/vpif.c
index 54cc0dadd755..9f3bfc1eb240 100644
--- a/drivers/media/video/davinci/vpif.c
+++ b/drivers/media/video/davinci/vpif.c
@@ -46,6 +46,133 @@ void __iomem *vpif_base;
46 * The table must include all presets from supported subdevices. 46 * The table must include all presets from supported subdevices.
47 */ 47 */
48const struct vpif_channel_config_params ch_params[] = { 48const struct vpif_channel_config_params ch_params[] = {
49 /* HDTV formats */
50 {
51 .name = "480p59_94",
52 .width = 720,
53 .height = 480,
54 .frm_fmt = 1,
55 .ycmux_mode = 0,
56 .eav2sav = 138-8,
57 .sav2eav = 720,
58 .l1 = 1,
59 .l3 = 43,
60 .l5 = 523,
61 .vsize = 525,
62 .capture_format = 0,
63 .vbi_supported = 0,
64 .hd_sd = 1,
65 .dv_preset = V4L2_DV_480P59_94,
66 },
67 {
68 .name = "576p50",
69 .width = 720,
70 .height = 576,
71 .frm_fmt = 1,
72 .ycmux_mode = 0,
73 .eav2sav = 144-8,
74 .sav2eav = 720,
75 .l1 = 1,
76 .l3 = 45,
77 .l5 = 621,
78 .vsize = 625,
79 .capture_format = 0,
80 .vbi_supported = 0,
81 .hd_sd = 1,
82 .dv_preset = V4L2_DV_576P50,
83 },
84 {
85 .name = "720p50",
86 .width = 1280,
87 .height = 720,
88 .frm_fmt = 1,
89 .ycmux_mode = 0,
90 .eav2sav = 700-8,
91 .sav2eav = 1280,
92 .l1 = 1,
93 .l3 = 26,
94 .l5 = 746,
95 .vsize = 750,
96 .capture_format = 0,
97 .vbi_supported = 0,
98 .hd_sd = 1,
99 .dv_preset = V4L2_DV_720P50,
100 },
101 {
102 .name = "720p60",
103 .width = 1280,
104 .height = 720,
105 .frm_fmt = 1,
106 .ycmux_mode = 0,
107 .eav2sav = 370 - 8,
108 .sav2eav = 1280,
109 .l1 = 1,
110 .l3 = 26,
111 .l5 = 746,
112 .vsize = 750,
113 .capture_format = 0,
114 .vbi_supported = 0,
115 .hd_sd = 1,
116 .dv_preset = V4L2_DV_720P60,
117 },
118 {
119 .name = "1080I50",
120 .width = 1920,
121 .height = 1080,
122 .frm_fmt = 0,
123 .ycmux_mode = 0,
124 .eav2sav = 720 - 8,
125 .sav2eav = 1920,
126 .l1 = 1,
127 .l3 = 21,
128 .l5 = 561,
129 .l7 = 563,
130 .l9 = 584,
131 .l11 = 1124,
132 .vsize = 1125,
133 .capture_format = 0,
134 .vbi_supported = 0,
135 .hd_sd = 1,
136 .dv_preset = V4L2_DV_1080I50,
137 },
138 {
139 .name = "1080I60",
140 .width = 1920,
141 .height = 1080,
142 .frm_fmt = 0,
143 .ycmux_mode = 0,
144 .eav2sav = 280 - 8,
145 .sav2eav = 1920,
146 .l1 = 1,
147 .l3 = 21,
148 .l5 = 561,
149 .l7 = 563,
150 .l9 = 584,
151 .l11 = 1124,
152 .vsize = 1125,
153 .capture_format = 0,
154 .vbi_supported = 0,
155 .hd_sd = 1,
156 .dv_preset = V4L2_DV_1080I60,
157 },
158 {
159 .name = "1080p60",
160 .width = 1920,
161 .height = 1080,
162 .frm_fmt = 1,
163 .ycmux_mode = 0,
164 .eav2sav = 280 - 8,
165 .sav2eav = 1920,
166 .l1 = 1,
167 .l3 = 42,
168 .l5 = 1122,
169 .vsize = 1125,
170 .capture_format = 0,
171 .vbi_supported = 0,
172 .hd_sd = 1,
173 .dv_preset = V4L2_DV_1080P60,
174 },
175
49 /* SDTV formats */ 176 /* SDTV formats */
50 { 177 {
51 .name = "NTSC_M", 178 .name = "NTSC_M",
diff --git a/drivers/media/video/davinci/vpif.h b/drivers/media/video/davinci/vpif.h
index d14e36e5c90d..b6695bee3c59 100644
--- a/drivers/media/video/davinci/vpif.h
+++ b/drivers/media/video/davinci/vpif.h
@@ -591,6 +591,7 @@ struct vpif_channel_config_params {
591 * supports capturing vbi or not */ 591 * supports capturing vbi or not */
592 u8 hd_sd; 592 u8 hd_sd;
593 v4l2_std_id stdid; 593 v4l2_std_id stdid;
594 u32 dv_preset; /* HDTV format */
594}; 595};
595 596
596extern const unsigned int vpif_ch_params_count; 597extern const unsigned int vpif_ch_params_count;
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 0a7ebb0e151a..42f1cd60780b 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -432,9 +432,18 @@ static int vpif_update_std_info(struct channel_obj *ch)
432 432
433 for (index = 0; index < vpif_ch_params_count; index++) { 433 for (index = 0; index < vpif_ch_params_count; index++) {
434 config = &ch_params[index]; 434 config = &ch_params[index];
435 if (config->stdid & vid_ch->stdid) { 435 if (config->hd_sd == 0) {
436 memcpy(std_info, config, sizeof(*config)); 436 vpif_dbg(2, debug, "SD format\n");
437 break; 437 if (config->stdid & vid_ch->stdid) {
438 memcpy(std_info, config, sizeof(*config));
439 break;
440 }
441 } else {
442 vpif_dbg(2, debug, "HD format\n");
443 if (config->dv_preset == vid_ch->dv_preset) {
444 memcpy(std_info, config, sizeof(*config));
445 break;
446 }
438 } 447 }
439 } 448 }
440 449
@@ -1442,6 +1451,7 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1442 return -ERESTARTSYS; 1451 return -ERESTARTSYS;
1443 1452
1444 ch->video.stdid = *std_id; 1453 ch->video.stdid = *std_id;
1454 ch->video.dv_preset = V4L2_DV_INVALID;
1445 1455
1446 /* Get the information about the standard */ 1456 /* Get the information about the standard */
1447 if (vpif_update_std_info(ch)) { 1457 if (vpif_update_std_info(ch)) {
@@ -1794,6 +1804,110 @@ static int vpif_cropcap(struct file *file, void *priv,
1794 return 0; 1804 return 0;
1795} 1805}
1796 1806
1807/**
1808 * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler
1809 * @file: file ptr
1810 * @priv: file handle
1811 * @preset: input preset
1812 */
1813static int vpif_enum_dv_presets(struct file *file, void *priv,
1814 struct v4l2_dv_enum_preset *preset)
1815{
1816 struct vpif_fh *fh = priv;
1817 struct channel_obj *ch = fh->channel;
1818
1819 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1820 video, enum_dv_presets, preset);
1821}
1822
1823/**
1824 * vpif_query_dv_presets() - QUERY_DV_PRESET handler
1825 * @file: file ptr
1826 * @priv: file handle
1827 * @preset: input preset
1828 */
1829static int vpif_query_dv_preset(struct file *file, void *priv,
1830 struct v4l2_dv_preset *preset)
1831{
1832 struct vpif_fh *fh = priv;
1833 struct channel_obj *ch = fh->channel;
1834
1835 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1836 video, query_dv_preset, preset);
1837}
1838/**
1839 * vpif_s_dv_presets() - S_DV_PRESETS handler
1840 * @file: file ptr
1841 * @priv: file handle
1842 * @preset: input preset
1843 */
1844static int vpif_s_dv_preset(struct file *file, void *priv,
1845 struct v4l2_dv_preset *preset)
1846{
1847 struct vpif_fh *fh = priv;
1848 struct channel_obj *ch = fh->channel;
1849 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1850 int ret = 0;
1851
1852 if (common->started) {
1853 vpif_dbg(1, debug, "streaming in progress\n");
1854 return -EBUSY;
1855 }
1856
1857 if ((VPIF_CHANNEL0_VIDEO == ch->channel_id) ||
1858 (VPIF_CHANNEL1_VIDEO == ch->channel_id)) {
1859 if (!fh->initialized) {
1860 vpif_dbg(1, debug, "Channel Busy\n");
1861 return -EBUSY;
1862 }
1863 }
1864
1865 ret = v4l2_prio_check(&ch->prio, fh->prio);
1866 if (ret)
1867 return ret;
1868
1869 fh->initialized = 1;
1870
1871 /* Call encoder subdevice function to set the standard */
1872 if (mutex_lock_interruptible(&common->lock))
1873 return -ERESTARTSYS;
1874
1875 ch->video.dv_preset = preset->preset;
1876 ch->video.stdid = V4L2_STD_UNKNOWN;
1877
1878 /* Get the information about the standard */
1879 if (vpif_update_std_info(ch)) {
1880 vpif_dbg(1, debug, "Error getting the standard info\n");
1881 ret = -EINVAL;
1882 } else {
1883 /* Configure the default format information */
1884 vpif_config_format(ch);
1885
1886 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1887 video, s_dv_preset, preset);
1888 }
1889
1890 mutex_unlock(&common->lock);
1891
1892 return ret;
1893}
1894/**
1895 * vpif_g_dv_presets() - G_DV_PRESETS handler
1896 * @file: file ptr
1897 * @priv: file handle
1898 * @preset: input preset
1899 */
1900static int vpif_g_dv_preset(struct file *file, void *priv,
1901 struct v4l2_dv_preset *preset)
1902{
1903 struct vpif_fh *fh = priv;
1904 struct channel_obj *ch = fh->channel;
1905
1906 preset->preset = ch->video.dv_preset;
1907
1908 return 0;
1909}
1910
1797/* 1911/*
1798 * vpif_g_chip_ident() - Identify the chip 1912 * vpif_g_chip_ident() - Identify the chip
1799 * @file: file ptr 1913 * @file: file ptr
@@ -1892,6 +2006,10 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1892 .vidioc_streamon = vpif_streamon, 2006 .vidioc_streamon = vpif_streamon,
1893 .vidioc_streamoff = vpif_streamoff, 2007 .vidioc_streamoff = vpif_streamoff,
1894 .vidioc_cropcap = vpif_cropcap, 2008 .vidioc_cropcap = vpif_cropcap,
2009 .vidioc_enum_dv_presets = vpif_enum_dv_presets,
2010 .vidioc_s_dv_preset = vpif_s_dv_preset,
2011 .vidioc_g_dv_preset = vpif_g_dv_preset,
2012 .vidioc_query_dv_preset = vpif_query_dv_preset,
1895 .vidioc_g_chip_ident = vpif_g_chip_ident, 2013 .vidioc_g_chip_ident = vpif_g_chip_ident,
1896#ifdef CONFIG_VIDEO_ADV_DEBUG 2014#ifdef CONFIG_VIDEO_ADV_DEBUG
1897 .vidioc_g_register = vpif_dbg_g_register, 2015 .vidioc_g_register = vpif_dbg_g_register,
diff --git a/drivers/media/video/davinci/vpif_capture.h b/drivers/media/video/davinci/vpif_capture.h
index 4e12ec8cac6f..3452a8aec020 100644
--- a/drivers/media/video/davinci/vpif_capture.h
+++ b/drivers/media/video/davinci/vpif_capture.h
@@ -59,6 +59,7 @@ struct video_obj {
59 enum v4l2_field buf_field; 59 enum v4l2_field buf_field;
60 /* Currently selected or default standard */ 60 /* Currently selected or default standard */
61 v4l2_std_id stdid; 61 v4l2_std_id stdid;
62 u32 dv_preset;
62 /* This is to track the last input that is passed to application */ 63 /* This is to track the last input that is passed to application */
63 u32 input_idx; 64 u32 input_idx;
64}; 65};
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index 9de0062eca59..759c5e855ac8 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -373,15 +373,23 @@ static int vpif_get_std_info(struct channel_obj *ch)
373 373
374 int index; 374 int index;
375 375
376 std_info->stdid = vid_ch->stdid; 376 if (!vid_ch->stdid && !vid_ch->dv_preset)
377 if (!std_info->stdid) 377 return -EINVAL;
378 return -1;
379 378
380 for (index = 0; index < vpif_ch_params_count; index++) { 379 for (index = 0; index < vpif_ch_params_count; index++) {
381 config = &ch_params[index]; 380 config = &ch_params[index];
382 if (config->stdid & std_info->stdid) { 381 if (config->hd_sd == 0) {
383 memcpy(std_info, config, sizeof(*config)); 382 vpif_dbg(2, debug, "SD format\n");
384 break; 383 if (config->stdid & vid_ch->stdid) {
384 memcpy(std_info, config, sizeof(*config));
385 break;
386 }
387 } else {
388 vpif_dbg(2, debug, "HD format\n");
389 if (config->dv_preset == vid_ch->dv_preset) {
390 memcpy(std_info, config, sizeof(*config));
391 break;
392 }
385 } 393 }
386 } 394 }
387 395
@@ -1305,6 +1313,88 @@ static int vpif_s_priority(struct file *file, void *priv, enum v4l2_priority p)
1305 return v4l2_prio_change(&ch->prio, &fh->prio, p); 1313 return v4l2_prio_change(&ch->prio, &fh->prio, p);
1306} 1314}
1307 1315
1316/**
1317 * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler
1318 * @file: file ptr
1319 * @priv: file handle
1320 * @preset: input preset
1321 */
1322static int vpif_enum_dv_presets(struct file *file, void *priv,
1323 struct v4l2_dv_enum_preset *preset)
1324{
1325 struct vpif_fh *fh = priv;
1326 struct channel_obj *ch = fh->channel;
1327 struct video_obj *vid_ch = &ch->video;
1328
1329 return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id],
1330 video, enum_dv_presets, preset);
1331}
1332
1333/**
1334 * vpif_s_dv_presets() - S_DV_PRESETS handler
1335 * @file: file ptr
1336 * @priv: file handle
1337 * @preset: input preset
1338 */
1339static int vpif_s_dv_preset(struct file *file, void *priv,
1340 struct v4l2_dv_preset *preset)
1341{
1342 struct vpif_fh *fh = priv;
1343 struct channel_obj *ch = fh->channel;
1344 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1345 struct video_obj *vid_ch = &ch->video;
1346 int ret = 0;
1347
1348 if (common->started) {
1349 vpif_dbg(1, debug, "streaming in progress\n");
1350 return -EBUSY;
1351 }
1352
1353 ret = v4l2_prio_check(&ch->prio, fh->prio);
1354 if (ret != 0)
1355 return ret;
1356
1357 fh->initialized = 1;
1358
1359 /* Call encoder subdevice function to set the standard */
1360 if (mutex_lock_interruptible(&common->lock))
1361 return -ERESTARTSYS;
1362
1363 ch->video.dv_preset = preset->preset;
1364 ch->video.stdid = V4L2_STD_UNKNOWN;
1365
1366 /* Get the information about the standard */
1367 if (vpif_get_std_info(ch)) {
1368 ret = -EINVAL;
1369 vpif_dbg(1, debug, "Error getting the standard info\n");
1370 } else {
1371 /* Configure the default format information */
1372 vpif_config_format(ch);
1373
1374 ret = v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id],
1375 video, s_dv_preset, preset);
1376 }
1377
1378 mutex_unlock(&common->lock);
1379
1380 return ret;
1381}
1382/**
1383 * vpif_g_dv_presets() - G_DV_PRESETS handler
1384 * @file: file ptr
1385 * @priv: file handle
1386 * @preset: input preset
1387 */
1388static int vpif_g_dv_preset(struct file *file, void *priv,
1389 struct v4l2_dv_preset *preset)
1390{
1391 struct vpif_fh *fh = priv;
1392 struct channel_obj *ch = fh->channel;
1393
1394 preset->preset = ch->video.dv_preset;
1395
1396 return 0;
1397}
1308 1398
1309/* 1399/*
1310 * vpif_g_chip_ident() - Identify the chip 1400 * vpif_g_chip_ident() - Identify the chip
@@ -1405,6 +1495,9 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1405 .vidioc_s_output = vpif_s_output, 1495 .vidioc_s_output = vpif_s_output,
1406 .vidioc_g_output = vpif_g_output, 1496 .vidioc_g_output = vpif_g_output,
1407 .vidioc_cropcap = vpif_cropcap, 1497 .vidioc_cropcap = vpif_cropcap,
1498 .vidioc_enum_dv_presets = vpif_enum_dv_presets,
1499 .vidioc_s_dv_preset = vpif_s_dv_preset,
1500 .vidioc_g_dv_preset = vpif_g_dv_preset,
1408 .vidioc_g_chip_ident = vpif_g_chip_ident, 1501 .vidioc_g_chip_ident = vpif_g_chip_ident,
1409#ifdef CONFIG_VIDEO_ADV_DEBUG 1502#ifdef CONFIG_VIDEO_ADV_DEBUG
1410 .vidioc_g_register = vpif_dbg_g_register, 1503 .vidioc_g_register = vpif_dbg_g_register,
diff --git a/drivers/media/video/davinci/vpif_display.h b/drivers/media/video/davinci/vpif_display.h
index a2a7cd166bbf..3d56b3e356a2 100644
--- a/drivers/media/video/davinci/vpif_display.h
+++ b/drivers/media/video/davinci/vpif_display.h
@@ -67,6 +67,7 @@ struct video_obj {
67 * most recent displayed frame only */ 67 * most recent displayed frame only */
68 v4l2_std_id stdid; /* Currently selected or default 68 v4l2_std_id stdid; /* Currently selected or default
69 * standard */ 69 * standard */
70 u32 dv_preset;
70 u32 output_id; /* Current output id */ 71 u32 output_id; /* Current output id */
71}; 72};
72 73