aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/v4l2-compat-ioctl32.c6
-rw-r--r--drivers/media/video/v4l2-ioctl.c147
-rw-r--r--include/linux/videodev2.h116
-rw-r--r--include/media/v4l2-ioctl.h15
-rw-r--r--include/media/v4l2-subdev.h21
5 files changed, 303 insertions, 2 deletions
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index 997975d5e024..c4150bd26337 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -1077,6 +1077,12 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1077 case VIDIOC_DBG_G_REGISTER: 1077 case VIDIOC_DBG_G_REGISTER:
1078 case VIDIOC_DBG_G_CHIP_IDENT: 1078 case VIDIOC_DBG_G_CHIP_IDENT:
1079 case VIDIOC_S_HW_FREQ_SEEK: 1079 case VIDIOC_S_HW_FREQ_SEEK:
1080 case VIDIOC_ENUM_DV_PRESETS:
1081 case VIDIOC_S_DV_PRESET:
1082 case VIDIOC_G_DV_PRESET:
1083 case VIDIOC_QUERY_DV_PRESET:
1084 case VIDIOC_S_DV_TIMINGS:
1085 case VIDIOC_G_DV_TIMINGS:
1080 ret = do_video_ioctl(file, cmd, arg); 1086 ret = do_video_ioctl(file, cmd, arg);
1081 break; 1087 break;
1082 1088
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 30cc3347ae52..4b11257c3184 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -284,6 +284,12 @@ static const char *v4l2_ioctls[] = {
284 [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT", 284 [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT",
285 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK", 285 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
286#endif 286#endif
287 [_IOC_NR(VIDIOC_ENUM_DV_PRESETS)] = "VIDIOC_ENUM_DV_PRESETS",
288 [_IOC_NR(VIDIOC_S_DV_PRESET)] = "VIDIOC_S_DV_PRESET",
289 [_IOC_NR(VIDIOC_G_DV_PRESET)] = "VIDIOC_G_DV_PRESET",
290 [_IOC_NR(VIDIOC_QUERY_DV_PRESET)] = "VIDIOC_QUERY_DV_PRESET",
291 [_IOC_NR(VIDIOC_S_DV_TIMINGS)] = "VIDIOC_S_DV_TIMINGS",
292 [_IOC_NR(VIDIOC_G_DV_TIMINGS)] = "VIDIOC_G_DV_TIMINGS",
287}; 293};
288#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 294#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
289 295
@@ -1135,6 +1141,19 @@ static long __video_do_ioctl(struct file *file,
1135 { 1141 {
1136 struct v4l2_input *p = arg; 1142 struct v4l2_input *p = arg;
1137 1143
1144 /*
1145 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
1146 * CAP_STD here based on ioctl handler provided by the
1147 * driver. If the driver doesn't support these
1148 * for a specific input, it must override these flags.
1149 */
1150 if (ops->vidioc_s_std)
1151 p->capabilities |= V4L2_IN_CAP_STD;
1152 if (ops->vidioc_s_dv_preset)
1153 p->capabilities |= V4L2_IN_CAP_PRESETS;
1154 if (ops->vidioc_s_dv_timings)
1155 p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS;
1156
1138 if (!ops->vidioc_enum_input) 1157 if (!ops->vidioc_enum_input)
1139 break; 1158 break;
1140 1159
@@ -1179,6 +1198,19 @@ static long __video_do_ioctl(struct file *file,
1179 if (!ops->vidioc_enum_output) 1198 if (!ops->vidioc_enum_output)
1180 break; 1199 break;
1181 1200
1201 /*
1202 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
1203 * CAP_STD here based on ioctl handler provided by the
1204 * driver. If the driver doesn't support these
1205 * for a specific output, it must override these flags.
1206 */
1207 if (ops->vidioc_s_std)
1208 p->capabilities |= V4L2_OUT_CAP_STD;
1209 if (ops->vidioc_s_dv_preset)
1210 p->capabilities |= V4L2_OUT_CAP_PRESETS;
1211 if (ops->vidioc_s_dv_timings)
1212 p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS;
1213
1182 ret = ops->vidioc_enum_output(file, fh, p); 1214 ret = ops->vidioc_enum_output(file, fh, p);
1183 if (!ret) 1215 if (!ret)
1184 dbgarg(cmd, "index=%d, name=%s, type=%d, " 1216 dbgarg(cmd, "index=%d, name=%s, type=%d, "
@@ -1794,6 +1826,121 @@ static long __video_do_ioctl(struct file *file,
1794 } 1826 }
1795 break; 1827 break;
1796 } 1828 }
1829 case VIDIOC_ENUM_DV_PRESETS:
1830 {
1831 struct v4l2_dv_enum_preset *p = arg;
1832
1833 if (!ops->vidioc_enum_dv_presets)
1834 break;
1835
1836 ret = ops->vidioc_enum_dv_presets(file, fh, p);
1837 if (!ret)
1838 dbgarg(cmd,
1839 "index=%d, preset=%d, name=%s, width=%d,"
1840 " height=%d ",
1841 p->index, p->preset, p->name, p->width,
1842 p->height);
1843 break;
1844 }
1845 case VIDIOC_S_DV_PRESET:
1846 {
1847 struct v4l2_dv_preset *p = arg;
1848
1849 if (!ops->vidioc_s_dv_preset)
1850 break;
1851
1852 dbgarg(cmd, "preset=%d\n", p->preset);
1853 ret = ops->vidioc_s_dv_preset(file, fh, p);
1854 break;
1855 }
1856 case VIDIOC_G_DV_PRESET:
1857 {
1858 struct v4l2_dv_preset *p = arg;
1859
1860 if (!ops->vidioc_g_dv_preset)
1861 break;
1862
1863 ret = ops->vidioc_g_dv_preset(file, fh, p);
1864 if (!ret)
1865 dbgarg(cmd, "preset=%d\n", p->preset);
1866 break;
1867 }
1868 case VIDIOC_QUERY_DV_PRESET:
1869 {
1870 struct v4l2_dv_preset *p = arg;
1871
1872 if (!ops->vidioc_query_dv_preset)
1873 break;
1874
1875 ret = ops->vidioc_query_dv_preset(file, fh, p);
1876 if (!ret)
1877 dbgarg(cmd, "preset=%d\n", p->preset);
1878 break;
1879 }
1880 case VIDIOC_S_DV_TIMINGS:
1881 {
1882 struct v4l2_dv_timings *p = arg;
1883
1884 if (!ops->vidioc_s_dv_timings)
1885 break;
1886
1887 switch (p->type) {
1888 case V4L2_DV_BT_656_1120:
1889 dbgarg2("bt-656/1120:interlaced=%d, pixelclock=%lld,"
1890 " width=%d, height=%d, polarities=%x,"
1891 " hfrontporch=%d, hsync=%d, hbackporch=%d,"
1892 " vfrontporch=%d, vsync=%d, vbackporch=%d,"
1893 " il_vfrontporch=%d, il_vsync=%d,"
1894 " il_vbackporch=%d\n",
1895 p->bt.interlaced, p->bt.pixelclock,
1896 p->bt.width, p->bt.height, p->bt.polarities,
1897 p->bt.hfrontporch, p->bt.hsync,
1898 p->bt.hbackporch, p->bt.vfrontporch,
1899 p->bt.vsync, p->bt.vbackporch,
1900 p->bt.il_vfrontporch, p->bt.il_vsync,
1901 p->bt.il_vbackporch);
1902 ret = ops->vidioc_s_dv_timings(file, fh, p);
1903 break;
1904 default:
1905 dbgarg2("Unknown type %d!\n", p->type);
1906 break;
1907 }
1908 break;
1909 }
1910 case VIDIOC_G_DV_TIMINGS:
1911 {
1912 struct v4l2_dv_timings *p = arg;
1913
1914 if (!ops->vidioc_g_dv_timings)
1915 break;
1916
1917 ret = ops->vidioc_g_dv_timings(file, fh, p);
1918 if (!ret) {
1919 switch (p->type) {
1920 case V4L2_DV_BT_656_1120:
1921 dbgarg2("bt-656/1120:interlaced=%d,"
1922 " pixelclock=%lld,"
1923 " width=%d, height=%d, polarities=%x,"
1924 " hfrontporch=%d, hsync=%d,"
1925 " hbackporch=%d, vfrontporch=%d,"
1926 " vsync=%d, vbackporch=%d,"
1927 " il_vfrontporch=%d, il_vsync=%d,"
1928 " il_vbackporch=%d\n",
1929 p->bt.interlaced, p->bt.pixelclock,
1930 p->bt.width, p->bt.height,
1931 p->bt.polarities, p->bt.hfrontporch,
1932 p->bt.hsync, p->bt.hbackporch,
1933 p->bt.vfrontporch, p->bt.vsync,
1934 p->bt.vbackporch, p->bt.il_vfrontporch,
1935 p->bt.il_vsync, p->bt.il_vbackporch);
1936 break;
1937 default:
1938 dbgarg2("Unknown type %d!\n", p->type);
1939 break;
1940 }
1941 }
1942 break;
1943 }
1797 1944
1798 default: 1945 default:
1799 { 1946 {
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 32b92298fd79..59047ebf452e 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -732,6 +732,99 @@ struct v4l2_standard {
732}; 732};
733 733
734/* 734/*
735 * V I D E O T I M I N G S D V P R E S E T
736 */
737struct v4l2_dv_preset {
738 __u32 preset;
739 __u32 reserved[4];
740};
741
742/*
743 * D V P R E S E T S E N U M E R A T I O N
744 */
745struct v4l2_dv_enum_preset {
746 __u32 index;
747 __u32 preset;
748 __u8 name[32]; /* Name of the preset timing */
749 __u32 width;
750 __u32 height;
751 __u32 reserved[4];
752};
753
754/*
755 * D V P R E S E T V A L U E S
756 */
757#define V4L2_DV_INVALID 0
758#define V4L2_DV_480P59_94 1 /* BT.1362 */
759#define V4L2_DV_576P50 2 /* BT.1362 */
760#define V4L2_DV_720P24 3 /* SMPTE 296M */
761#define V4L2_DV_720P25 4 /* SMPTE 296M */
762#define V4L2_DV_720P30 5 /* SMPTE 296M */
763#define V4L2_DV_720P50 6 /* SMPTE 296M */
764#define V4L2_DV_720P59_94 7 /* SMPTE 274M */
765#define V4L2_DV_720P60 8 /* SMPTE 274M/296M */
766#define V4L2_DV_1080I29_97 9 /* BT.1120/ SMPTE 274M */
767#define V4L2_DV_1080I30 10 /* BT.1120/ SMPTE 274M */
768#define V4L2_DV_1080I25 11 /* BT.1120 */
769#define V4L2_DV_1080I50 12 /* SMPTE 296M */
770#define V4L2_DV_1080I60 13 /* SMPTE 296M */
771#define V4L2_DV_1080P24 14 /* SMPTE 296M */
772#define V4L2_DV_1080P25 15 /* SMPTE 296M */
773#define V4L2_DV_1080P30 16 /* SMPTE 296M */
774#define V4L2_DV_1080P50 17 /* BT.1120 */
775#define V4L2_DV_1080P60 18 /* BT.1120 */
776
777/*
778 * D V B T T I M I N G S
779 */
780
781/* BT.656/BT.1120 timing data */
782struct v4l2_bt_timings {
783 __u32 width; /* width in pixels */
784 __u32 height; /* height in lines */
785 __u32 interlaced; /* Interlaced or progressive */
786 __u32 polarities; /* Positive or negative polarity */
787 __u64 pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
788 __u32 hfrontporch; /* Horizpontal front porch in pixels */
789 __u32 hsync; /* Horizontal Sync length in pixels */
790 __u32 hbackporch; /* Horizontal back porch in pixels */
791 __u32 vfrontporch; /* Vertical front porch in pixels */
792 __u32 vsync; /* Vertical Sync length in lines */
793 __u32 vbackporch; /* Vertical back porch in lines */
794 __u32 il_vfrontporch; /* Vertical front porch for bottom field of
795 * interlaced field formats
796 */
797 __u32 il_vsync; /* Vertical sync length for bottom field of
798 * interlaced field formats
799 */
800 __u32 il_vbackporch; /* Vertical back porch for bottom field of
801 * interlaced field formats
802 */
803 __u32 reserved[16];
804} __attribute__ ((packed));
805
806/* Interlaced or progressive format */
807#define V4L2_DV_PROGRESSIVE 0
808#define V4L2_DV_INTERLACED 1
809
810/* Polarities. If bit is not set, it is assumed to be negative polarity */
811#define V4L2_DV_VSYNC_POS_POL 0x00000001
812#define V4L2_DV_HSYNC_POS_POL 0x00000002
813
814
815/* DV timings */
816struct v4l2_dv_timings {
817 __u32 type;
818 union {
819 struct v4l2_bt_timings bt;
820 __u32 reserved[32];
821 };
822} __attribute__ ((packed));
823
824/* Values for the type field */
825#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */
826
827/*
735 * V I D E O I N P U T S 828 * V I D E O I N P U T S
736 */ 829 */
737struct v4l2_input { 830struct v4l2_input {
@@ -742,7 +835,8 @@ struct v4l2_input {
742 __u32 tuner; /* Associated tuner */ 835 __u32 tuner; /* Associated tuner */
743 v4l2_std_id std; 836 v4l2_std_id std;
744 __u32 status; 837 __u32 status;
745 __u32 reserved[4]; 838 __u32 capabilities;
839 __u32 reserved[3];
746}; 840};
747 841
748/* Values for the 'type' field */ 842/* Values for the 'type' field */
@@ -773,6 +867,11 @@ struct v4l2_input {
773#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */ 867#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
774#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */ 868#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
775 869
870/* capabilities flags */
871#define V4L2_IN_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
872#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
873#define V4L2_IN_CAP_STD 0x00000004 /* Supports S_STD */
874
776/* 875/*
777 * V I D E O O U T P U T S 876 * V I D E O O U T P U T S
778 */ 877 */
@@ -783,13 +882,19 @@ struct v4l2_output {
783 __u32 audioset; /* Associated audios (bitfield) */ 882 __u32 audioset; /* Associated audios (bitfield) */
784 __u32 modulator; /* Associated modulator */ 883 __u32 modulator; /* Associated modulator */
785 v4l2_std_id std; 884 v4l2_std_id std;
786 __u32 reserved[4]; 885 __u32 capabilities;
886 __u32 reserved[3];
787}; 887};
788/* Values for the 'type' field */ 888/* Values for the 'type' field */
789#define V4L2_OUTPUT_TYPE_MODULATOR 1 889#define V4L2_OUTPUT_TYPE_MODULATOR 1
790#define V4L2_OUTPUT_TYPE_ANALOG 2 890#define V4L2_OUTPUT_TYPE_ANALOG 2
791#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3 891#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
792 892
893/* capabilities flags */
894#define V4L2_OUT_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
895#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
896#define V4L2_OUT_CAP_STD 0x00000004 /* Supports S_STD */
897
793/* 898/*
794 * C O N T R O L S 899 * C O N T R O L S
795 */ 900 */
@@ -1624,6 +1729,13 @@ struct v4l2_dbg_chip_ident {
1624#endif 1729#endif
1625 1730
1626#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) 1731#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1732#define VIDIOC_ENUM_DV_PRESETS _IOWR('V', 83, struct v4l2_dv_enum_preset)
1733#define VIDIOC_S_DV_PRESET _IOWR('V', 84, struct v4l2_dv_preset)
1734#define VIDIOC_G_DV_PRESET _IOWR('V', 85, struct v4l2_dv_preset)
1735#define VIDIOC_QUERY_DV_PRESET _IOR('V', 86, struct v4l2_dv_preset)
1736#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
1737#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
1738
1627/* Reminder: when adding new ioctls please add support for them to 1739/* Reminder: when adding new ioctls please add support for them to
1628 drivers/media/video/v4l2-compat-ioctl32.c as well! */ 1740 drivers/media/video/v4l2-compat-ioctl32.c as well! */
1629 1741
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 7a4529defa88..e8ba0f2efbae 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -239,6 +239,21 @@ struct v4l2_ioctl_ops {
239 int (*vidioc_enum_frameintervals) (struct file *file, void *fh, 239 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
240 struct v4l2_frmivalenum *fival); 240 struct v4l2_frmivalenum *fival);
241 241
242 /* DV Timings IOCTLs */
243 int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
244 struct v4l2_dv_enum_preset *preset);
245
246 int (*vidioc_s_dv_preset) (struct file *file, void *fh,
247 struct v4l2_dv_preset *preset);
248 int (*vidioc_g_dv_preset) (struct file *file, void *fh,
249 struct v4l2_dv_preset *preset);
250 int (*vidioc_query_dv_preset) (struct file *file, void *fh,
251 struct v4l2_dv_preset *qpreset);
252 int (*vidioc_s_dv_timings) (struct file *file, void *fh,
253 struct v4l2_dv_timings *timings);
254 int (*vidioc_g_dv_timings) (struct file *file, void *fh,
255 struct v4l2_dv_timings *timings);
256
242 /* For other private ioctls */ 257 /* For other private ioctls */
243 long (*vidioc_default) (struct file *file, void *fh, 258 long (*vidioc_default) (struct file *file, void *fh,
244 int cmd, void *arg); 259 int cmd, void *arg);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 00bf17608453..7a3408f9d0f2 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -217,6 +217,19 @@ struct v4l2_subdev_audio_ops {
217 217
218 s_routing: see s_routing in audio_ops, except this version is for video 218 s_routing: see s_routing in audio_ops, except this version is for video
219 devices. 219 devices.
220
221 s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to
222 s_std()
223
224 query_dv_preset: query dv preset in the sub device. This is similar to
225 querystd()
226
227 s_dv_timings(): Set custom dv timings in the sub device. This is used
228 when sub device is capable of setting detailed timing information
229 in the hardware to generate/detect the video signal.
230
231 g_dv_timings(): Get custom dv timings in the sub device.
232
220 */ 233 */
221struct v4l2_subdev_video_ops { 234struct v4l2_subdev_video_ops {
222 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); 235 int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
@@ -240,6 +253,14 @@ struct v4l2_subdev_video_ops {
240 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 253 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
241 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); 254 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
242 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); 255 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
256 int (*s_dv_preset)(struct v4l2_subdev *sd,
257 struct v4l2_dv_preset *preset);
258 int (*query_dv_preset)(struct v4l2_subdev *sd,
259 struct v4l2_dv_preset *preset);
260 int (*s_dv_timings)(struct v4l2_subdev *sd,
261 struct v4l2_dv_timings *timings);
262 int (*g_dv_timings)(struct v4l2_subdev *sd,
263 struct v4l2_dv_timings *timings);
243}; 264};
244 265
245/* 266/*