diff mbox

[PATCH/RFC,1/1] v4l: Add support for binary controls

Message ID 1269856386-29557-2-git-send-email-k.debski@samsung.com (mailing list archive)
State RFC
Headers show

Commit Message

Kamil Debski March 29, 2010, 9:53 a.m. UTC
None
diff mbox

Patch

diff --git a/Documentation/DocBook/v4l/compat.xml b/Documentation/DocBook/v4l/compat.xml
index b9dbdf9..83b8b64 100644
--- a/Documentation/DocBook/v4l/compat.xml
+++ b/Documentation/DocBook/v4l/compat.xml
@@ -2333,6 +2333,15 @@  more information.</para>
       </orderedlist>
     </section>
    </section>
+    <section>
+      <title>V4L2 in Linux 2.6.35</title>
+      <orderedlist>
+	<listitem>
+	  <para>Added support for binary data controls via new type <constant>V4L2_CTRL_TYPE_BINARY</constant>.</para>
+	</listitem>
+      </orderedlist>
+    </section>
+   </section>
 
    <section id="other">
      <title>Relation of V4L2 to other Linux multimedia APIs</title>
diff --git a/Documentation/DocBook/v4l/videodev2.h.xml b/Documentation/DocBook/v4l/videodev2.h.xml
index 0683259..c552134 100644
--- a/Documentation/DocBook/v4l/videodev2.h.xml
+++ b/Documentation/DocBook/v4l/videodev2.h.xml
@@ -169,6 +169,7 @@  enum <link linkend="v4l2-ctrl-type">v4l2_ctrl_type</link> {
         V4L2_CTRL_TYPE_INTEGER64     = 5,
         V4L2_CTRL_TYPE_CTRL_CLASS    = 6,
         V4L2_CTRL_TYPE_STRING        = 7,
+        V4L2_CTRL_TYPE_BINARY        = 8,
 };
 
 enum <link linkend="v4l2-tuner-type">v4l2_tuner_type</link> {
@@ -913,6 +914,7 @@  struct <link linkend="v4l2-ext-control">v4l2_ext_control</link> {
                 __s32 value;
                 __s64 value64;
                 char *string;
+		unsigned char *blob;
         };
 } __attribute__ ((packed));
 
diff --git a/Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml
index 3aa7f8f..ab4f1c9 100644
--- a/Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml
@@ -170,6 +170,12 @@  applications must set the array to zero.</entry>
 	    <entry><structfield>string</structfield></entry>
 	    <entry>A pointer to a string.</entry>
 	  </row>
+	  <row>
+	    <entry></entry>
+	    <entry>unsigned char *</entry>
+	    <entry><structfield>blob</structfield></entry>
+	    <entry>A pointer to a blob.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
diff --git a/Documentation/DocBook/v4l/vidioc-queryctrl.xml b/Documentation/DocBook/v4l/vidioc-queryctrl.xml
index 4876ff1..d1cd5ee 100644
--- a/Documentation/DocBook/v4l/vidioc-queryctrl.xml
+++ b/Documentation/DocBook/v4l/vidioc-queryctrl.xml
@@ -142,9 +142,10 @@  bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
 lowest valid index (always 0) for <constant>V4L2_CTRL_TYPE_MENU</constant> controls.
 For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the minimum value
 gives the minimum length of the string. This length <emphasis>does not include the terminating
-zero</emphasis>. It may not be valid for any other type of control, including
-<constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
-signed value.</entry>
+zero</emphasis>. For <constant>V4L2_CTRL_TYPE_BINARY</constant> controls this value
+gives the minimum length of the binary data. It may not be valid for any other type of
+ control, including <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that
+ this is a signed value.</entry>
 	  </row>
 	  <row>
 	    <entry>__s32</entry>
@@ -155,7 +156,8 @@  highest valid index for <constant>V4L2_CTRL_TYPE_MENU</constant>
 controls.
 For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the maximum value
 gives the maximum length of the string. This length <emphasis>does not include the terminating
-zero</emphasis>. It may not be valid for any other type of control, including
+zero</emphasis>. For <constant>V4L2_CTRL_TYPE_BINARY</constant> controls this value
+gives the maximum length of the binary data. It may not be valid for any other type of control, including
 <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
 signed value.</entry>
 	  </row>
@@ -166,8 +168,8 @@  signed value.</entry>
 <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls. For
 <constant>V4L2_CTRL_TYPE_STRING</constant> controls this field refers to
 the string length that has to be a multiple of this step size.
-It may not be valid for any other type of control, including
-<constant>V4L2_CTRL_TYPE_INTEGER64</constant>
+For <constant>V4L2_CTRL_TYPE_BINARY</constant> controls the size of the binary data has to be a multiple of this step size. It may not be valid for any other type of
+control, including <constant>V4L2_CTRL_TYPE_INTEGER64</constant>
 controls.</para><para>Generally drivers should not scale hardware
 control values. It may be necessary for example when the
 <structfield>name</structfield> or <structfield>id</structfield> imply
@@ -319,6 +321,15 @@  Which character encoding is used will depend on the string control itself and
 should be part of the control documentation.</entry>
 	  </row>
 	  <row>
+	    <entry><constant>V4L2_CTRL_TYPE_BINARY</constant></entry>
+	    <entry>&ge; 0</entry>
+	    <entry>&ge; 1</entry>
+	    <entry>&ge; 0</entry>
+	    <entry>The minimum and maximum of the binary data length. The step size
+means that the length must be (minimum + N * step) characters long for
+N &ge; 0. </entry>
+	  </row>
+	  <row>
 	    <entry><constant>V4L2_CTRL_TYPE_CTRL_CLASS</constant></entry>
 	    <entry>n/a</entry>
 	    <entry>n/a</entry>
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 36b5cb8..cbd770e 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -158,6 +158,8 @@  int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
 		return -EBUSY;
 	if (qctrl->type == V4L2_CTRL_TYPE_STRING)
 		return 0;
+	if (qctrl->type == V4L2_CTRL_TYPE_BINARY)
+		return 0;
 	if (qctrl->type == V4L2_CTRL_TYPE_BUTTON ||
 	    qctrl->type == V4L2_CTRL_TYPE_INTEGER64 ||
 	    qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 3793d16..5a62c9a 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -168,6 +168,7 @@  enum v4l2_ctrl_type {
 	V4L2_CTRL_TYPE_INTEGER64     = 5,
 	V4L2_CTRL_TYPE_CTRL_CLASS    = 6,
 	V4L2_CTRL_TYPE_STRING        = 7,
+	V4L2_CTRL_TYPE_BINARY        = 8,
 };
 
 enum v4l2_tuner_type {
@@ -918,6 +919,7 @@  struct v4l2_ext_control {
 		__s32 value;
 		__s64 value64;
 		char *string;
+		unsigned char *blob;
 	};
 } __attribute__ ((packed));