aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-01-29 08:07:13 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-25 11:47:55 -0400
commit9cfd65e80959836fed78704e8a127d4e10448d56 (patch)
treebdae4d269740557a868dd2a7c2a89394c8af69f8
parentc4fa146ce53cc5741016fdfadfce84f5c0bcf999 (diff)
[media] v4l: Add support for DV timings ioctls on subdev nodes
Validate the pad field in the core code whenever specified. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml27
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml30
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c27
-rw-r--r--include/uapi/linux/v4l2-subdev.h7
4 files changed, 78 insertions, 13 deletions
diff --git a/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml b/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
index cd7720d404ea..28a8c1e1c705 100644
--- a/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-dv-timings-cap.xml
@@ -1,11 +1,12 @@
1<refentry id="vidioc-dv-timings-cap"> 1<refentry id="vidioc-dv-timings-cap">
2 <refmeta> 2 <refmeta>
3 <refentrytitle>ioctl VIDIOC_DV_TIMINGS_CAP</refentrytitle> 3 <refentrytitle>ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP</refentrytitle>
4 &manvol; 4 &manvol;
5 </refmeta> 5 </refmeta>
6 6
7 <refnamediv> 7 <refnamediv>
8 <refname>VIDIOC_DV_TIMINGS_CAP</refname> 8 <refname>VIDIOC_DV_TIMINGS_CAP</refname>
9 <refname>VIDIOC_SUBDEV_DV_TIMINGS_CAP</refname>
9 <refpurpose>The capabilities of the Digital Video receiver/transmitter</refpurpose> 10 <refpurpose>The capabilities of the Digital Video receiver/transmitter</refpurpose>
10 </refnamediv> 11 </refnamediv>
11 12
@@ -33,7 +34,7 @@
33 <varlistentry> 34 <varlistentry>
34 <term><parameter>request</parameter></term> 35 <term><parameter>request</parameter></term>
35 <listitem> 36 <listitem>
36 <para>VIDIOC_DV_TIMINGS_CAP</para> 37 <para>VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP</para>
37 </listitem> 38 </listitem>
38 </varlistentry> 39 </varlistentry>
39 <varlistentry> 40 <varlistentry>
@@ -54,10 +55,19 @@
54 interface and may change in the future.</para> 55 interface and may change in the future.</para>
55 </note> 56 </note>
56 57
57 <para>To query the capabilities of the DV receiver/transmitter applications can call 58 <para>To query the capabilities of the DV receiver/transmitter applications
58this ioctl and the driver will fill in the structure. Note that drivers may return 59can call the <constant>VIDIOC_DV_TIMINGS_CAP</constant> ioctl on a video node
60and the driver will fill in the structure. Note that drivers may return
59different values after switching the video input or output.</para> 61different values after switching the video input or output.</para>
60 62
63 <para>When implemented by the driver DV capabilities of subdevices can be
64queried by calling the <constant>VIDIOC_SUBDEV_DV_TIMINGS_CAP</constant> ioctl
65directly on a subdevice node. The capabilities are specific to inputs (for DV
66receivers) or outputs (for DV transmitters), applications must specify the
67desired pad number in the &v4l2-dv-timings-cap; <structfield>pad</structfield>
68field. Attempts to query capabilities on a pad that doesn't support them will
69return an &EINVAL;.</para>
70
61 <table pgwide="1" frame="none" id="v4l2-bt-timings-cap"> 71 <table pgwide="1" frame="none" id="v4l2-bt-timings-cap">
62 <title>struct <structname>v4l2_bt_timings_cap</structname></title> 72 <title>struct <structname>v4l2_bt_timings_cap</structname></title>
63 <tgroup cols="3"> 73 <tgroup cols="3">
@@ -127,7 +137,14 @@ different values after switching the video input or output.</para>
127 </row> 137 </row>
128 <row> 138 <row>
129 <entry>__u32</entry> 139 <entry>__u32</entry>
130 <entry><structfield>reserved</structfield>[3]</entry> 140 <entry><structfield>pad</structfield></entry>
141 <entry>Pad number as reported by the media controller API. This field
142 is only used when operating on a subdevice node. When operating on a
143 video node applications must set this field to zero.</entry>
144 </row>
145 <row>
146 <entry>__u32</entry>
147 <entry><structfield>reserved</structfield>[2]</entry>
131 <entry>Reserved for future extensions. Drivers must set the array to zero.</entry> 148 <entry>Reserved for future extensions. Drivers must set the array to zero.</entry>
132 </row> 149 </row>
133 <row> 150 <row>
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
index b3e17c1dfaf5..b9fdfeacdbcb 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-dv-timings.xml
@@ -1,11 +1,12 @@
1<refentry id="vidioc-enum-dv-timings"> 1<refentry id="vidioc-enum-dv-timings">
2 <refmeta> 2 <refmeta>
3 <refentrytitle>ioctl VIDIOC_ENUM_DV_TIMINGS</refentrytitle> 3 <refentrytitle>ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS</refentrytitle>
4 &manvol; 4 &manvol;
5 </refmeta> 5 </refmeta>
6 6
7 <refnamediv> 7 <refnamediv>
8 <refname>VIDIOC_ENUM_DV_TIMINGS</refname> 8 <refname>VIDIOC_ENUM_DV_TIMINGS</refname>
9 <refname>VIDIOC_SUBDEV_ENUM_DV_TIMINGS</refname>
9 <refpurpose>Enumerate supported Digital Video timings</refpurpose> 10 <refpurpose>Enumerate supported Digital Video timings</refpurpose>
10 </refnamediv> 11 </refnamediv>
11 12
@@ -33,7 +34,7 @@
33 <varlistentry> 34 <varlistentry>
34 <term><parameter>request</parameter></term> 35 <term><parameter>request</parameter></term>
35 <listitem> 36 <listitem>
36 <para>VIDIOC_ENUM_DV_TIMINGS</para> 37 <para>VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS</para>
37 </listitem> 38 </listitem>
38 </varlistentry> 39 </varlistentry>
39 <varlistentry> 40 <varlistentry>
@@ -61,14 +62,21 @@ standards or even custom timings that are not in this list.</para>
61 62
62 <para>To query the available timings, applications initialize the 63 <para>To query the available timings, applications initialize the
63<structfield>index</structfield> field and zero the reserved array of &v4l2-enum-dv-timings; 64<structfield>index</structfield> field and zero the reserved array of &v4l2-enum-dv-timings;
64and call the <constant>VIDIOC_ENUM_DV_TIMINGS</constant> ioctl with a pointer to this 65and call the <constant>VIDIOC_ENUM_DV_TIMINGS</constant> ioctl on a video node with a
65structure. Drivers fill the rest of the structure or return an 66pointer to this structure. Drivers fill the rest of the structure or return an
66&EINVAL; when the index is out of bounds. To enumerate all supported DV timings, 67&EINVAL; when the index is out of bounds. To enumerate all supported DV timings,
67applications shall begin at index zero, incrementing by one until the 68applications shall begin at index zero, incrementing by one until the
68driver returns <errorcode>EINVAL</errorcode>. Note that drivers may enumerate a 69driver returns <errorcode>EINVAL</errorcode>. Note that drivers may enumerate a
69different set of DV timings after switching the video input or 70different set of DV timings after switching the video input or
70output.</para> 71output.</para>
71 72
73 <para>When implemented by the driver DV timings of subdevices can be queried
74by calling the <constant>VIDIOC_SUBDEV_ENUM_DV_TIMINGS</constant> ioctl directly
75on a subdevice node. The DV timings are specific to inputs (for DV receivers) or
76outputs (for DV transmitters), applications must specify the desired pad number
77in the &v4l2-enum-dv-timings; <structfield>pad</structfield> field. Attempts to
78enumerate timings on a pad that doesn't support them will return an &EINVAL;.</para>
79
72 <table pgwide="1" frame="none" id="v4l2-enum-dv-timings"> 80 <table pgwide="1" frame="none" id="v4l2-enum-dv-timings">
73 <title>struct <structname>v4l2_enum_dv_timings</structname></title> 81 <title>struct <structname>v4l2_enum_dv_timings</structname></title>
74 <tgroup cols="3"> 82 <tgroup cols="3">
@@ -82,8 +90,16 @@ application.</entry>
82 </row> 90 </row>
83 <row> 91 <row>
84 <entry>__u32</entry> 92 <entry>__u32</entry>
85 <entry><structfield>reserved</structfield>[3]</entry> 93 <entry><structfield>pad</structfield></entry>
86 <entry>Reserved for future extensions. Drivers must set the array to zero.</entry> 94 <entry>Pad number as reported by the media controller API. This field
95 is only used when operating on a subdevice node. When operating on a
96 video node applications must set this field to zero.</entry>
97 </row>
98 <row>
99 <entry>__u32</entry>
100 <entry><structfield>reserved</structfield>[2]</entry>
101 <entry>Reserved for future extensions. Drivers and applications must
102 set the array to zero.</entry>
87 </row> 103 </row>
88 <row> 104 <row>
89 <entry>&v4l2-dv-timings;</entry> 105 <entry>&v4l2-dv-timings;</entry>
@@ -103,7 +119,7 @@ application.</entry>
103 <term><errorcode>EINVAL</errorcode></term> 119 <term><errorcode>EINVAL</errorcode></term>
104 <listitem> 120 <listitem>
105 <para>The &v4l2-enum-dv-timings; <structfield>index</structfield> 121 <para>The &v4l2-enum-dv-timings; <structfield>index</structfield>
106is out of bounds.</para> 122is out of bounds or the <structfield>pad</structfield> number is invalid.</para>
107 </listitem> 123 </listitem>
108 </varlistentry> 124 </varlistentry>
109 <varlistentry> 125 <varlistentry>
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 0ed4c5be1b32..db126dbc19c9 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -366,6 +366,33 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
366 366
367 case VIDIOC_S_EDID: 367 case VIDIOC_S_EDID:
368 return v4l2_subdev_call(sd, pad, set_edid, arg); 368 return v4l2_subdev_call(sd, pad, set_edid, arg);
369
370 case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
371 struct v4l2_dv_timings_cap *cap = arg;
372
373 if (cap->pad >= sd->entity.num_pads)
374 return -EINVAL;
375
376 return v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
377 }
378
379 case VIDIOC_SUBDEV_ENUM_DV_TIMINGS: {
380 struct v4l2_enum_dv_timings *dvt = arg;
381
382 if (dvt->pad >= sd->entity.num_pads)
383 return -EINVAL;
384
385 return v4l2_subdev_call(sd, pad, enum_dv_timings, dvt);
386 }
387
388 case VIDIOC_SUBDEV_QUERY_DV_TIMINGS:
389 return v4l2_subdev_call(sd, video, query_dv_timings, arg);
390
391 case VIDIOC_SUBDEV_G_DV_TIMINGS:
392 return v4l2_subdev_call(sd, video, g_dv_timings, arg);
393
394 case VIDIOC_SUBDEV_S_DV_TIMINGS:
395 return v4l2_subdev_call(sd, video, s_dv_timings, arg);
369#endif 396#endif
370 default: 397 default:
371 return v4l2_subdev_call(sd, core, ioctl, cmd, arg); 398 return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index db28964a697c..a619cdd300ac 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -162,8 +162,13 @@ struct v4l2_subdev_selection {
162#define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop) 162#define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop)
163#define VIDIOC_SUBDEV_G_SELECTION _IOWR('V', 61, struct v4l2_subdev_selection) 163#define VIDIOC_SUBDEV_G_SELECTION _IOWR('V', 61, struct v4l2_subdev_selection)
164#define VIDIOC_SUBDEV_S_SELECTION _IOWR('V', 62, struct v4l2_subdev_selection) 164#define VIDIOC_SUBDEV_S_SELECTION _IOWR('V', 62, struct v4l2_subdev_selection)
165/* These two G/S_EDID ioctls are identical to the ioctls in videodev2.h */ 165/* The following ioctls are identical to the ioctls in videodev2.h */
166#define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_edid) 166#define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_edid)
167#define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_edid) 167#define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_edid)
168#define VIDIOC_SUBDEV_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
169#define VIDIOC_SUBDEV_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
170#define VIDIOC_SUBDEV_ENUM_DV_TIMINGS _IOWR('V', 98, struct v4l2_enum_dv_timings)
171#define VIDIOC_SUBDEV_QUERY_DV_TIMINGS _IOR('V', 99, struct v4l2_dv_timings)
172#define VIDIOC_SUBDEV_DV_TIMINGS_CAP _IOWR('V', 100, struct v4l2_dv_timings_cap)
168 173
169#endif 174#endif