vidioc-dbg-g-register.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <refentry id="vidioc-dbg-g-register">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_DBG_G_REGISTER</refname>
  8. <refname>VIDIOC_DBG_S_REGISTER</refname>
  9. <refpurpose>Read or write hardware registers</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_dbg_register *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. <funcsynopsis>
  21. <funcprototype>
  22. <funcdef>int <function>ioctl</function></funcdef>
  23. <paramdef>int <parameter>fd</parameter></paramdef>
  24. <paramdef>int <parameter>request</parameter></paramdef>
  25. <paramdef>const struct v4l2_dbg_register
  26. *<parameter>argp</parameter></paramdef>
  27. </funcprototype>
  28. </funcsynopsis>
  29. </refsynopsisdiv>
  30. <refsect1>
  31. <title>Arguments</title>
  32. <variablelist>
  33. <varlistentry>
  34. <term><parameter>fd</parameter></term>
  35. <listitem>
  36. <para>&fd;</para>
  37. </listitem>
  38. </varlistentry>
  39. <varlistentry>
  40. <term><parameter>request</parameter></term>
  41. <listitem>
  42. <para>VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER</para>
  43. </listitem>
  44. </varlistentry>
  45. <varlistentry>
  46. <term><parameter>argp</parameter></term>
  47. <listitem>
  48. <para></para>
  49. </listitem>
  50. </varlistentry>
  51. </variablelist>
  52. </refsect1>
  53. <refsect1>
  54. <title>Description</title>
  55. <note>
  56. <title>Experimental</title>
  57. <para>This is an <link linkend="experimental">experimental</link>
  58. interface and may change in the future.</para>
  59. </note>
  60. <para>For driver debugging purposes these ioctls allow test
  61. applications to access hardware registers directly. Regular
  62. applications must not use them.</para>
  63. <para>Since writing or even reading registers can jeopardize the
  64. system security, its stability and damage the hardware, both ioctls
  65. require superuser privileges. Additionally the Linux kernel must be
  66. compiled with the <constant>CONFIG_VIDEO_ADV_DEBUG</constant> option
  67. to enable these ioctls.</para>
  68. <para>To write a register applications must initialize all fields
  69. of a &v4l2-dbg-register; except for <structfield>size</structfield> and call
  70. <constant>VIDIOC_DBG_S_REGISTER</constant> with a pointer to this
  71. structure. The <structfield>match.type</structfield> and
  72. <structfield>match.addr</structfield> or <structfield>match.name</structfield>
  73. fields select a chip on the TV
  74. card, the <structfield>reg</structfield> field specifies a register
  75. number and the <structfield>val</structfield> field the value to be
  76. written into the register.</para>
  77. <para>To read a register applications must initialize the
  78. <structfield>match.type</structfield>,
  79. <structfield>match.addr</structfield> or <structfield>match.name</structfield> and
  80. <structfield>reg</structfield> fields, and call
  81. <constant>VIDIOC_DBG_G_REGISTER</constant> with a pointer to this
  82. structure. On success the driver stores the register value in the
  83. <structfield>val</structfield> field and the size (in bytes) of the
  84. value in <structfield>size</structfield>.</para>
  85. <para>When <structfield>match.type</structfield> is
  86. <constant>V4L2_CHIP_MATCH_BRIDGE</constant>,
  87. <structfield>match.addr</structfield> selects the nth non-sub-device chip
  88. on the TV card. The number zero always selects the host chip, &eg; the
  89. chip connected to the PCI or USB bus. You can find out which chips are
  90. present with the &VIDIOC-DBG-G-CHIP-INFO; ioctl.</para>
  91. <para>When <structfield>match.type</structfield> is
  92. <constant>V4L2_CHIP_MATCH_SUBDEV</constant>,
  93. <structfield>match.addr</structfield> selects the nth sub-device.</para>
  94. <note>
  95. <title>Success not guaranteed</title>
  96. <para>Due to a flaw in the Linux &i2c; bus driver these ioctls may
  97. return successfully without actually reading or writing a register. To
  98. catch the most likely failure we recommend a &VIDIOC-DBG-G-CHIP-INFO;
  99. call confirming the presence of the selected &i2c; chip.</para>
  100. </note>
  101. <para>These ioctls are optional, not all drivers may support them.
  102. However when a driver supports these ioctls it must also support
  103. &VIDIOC-DBG-G-CHIP-INFO;. Conversely it may support
  104. <constant>VIDIOC_DBG_G_CHIP_INFO</constant> but not these ioctls.</para>
  105. <para><constant>VIDIOC_DBG_G_REGISTER</constant> and
  106. <constant>VIDIOC_DBG_S_REGISTER</constant> were introduced in Linux
  107. 2.6.21, but their API was changed to the one described here in kernel 2.6.29.</para>
  108. <para>We recommended the <application>v4l2-dbg</application>
  109. utility over calling these ioctls directly. It is available from the
  110. LinuxTV v4l-dvb repository; see <ulink
  111. url="http://linuxtv.org/repo/">http://linuxtv.org/repo/</ulink> for
  112. access instructions.</para>
  113. <!-- Note for convenience vidioc-dbg-g-chip-info.sgml
  114. contains a duplicate of this table. -->
  115. <table pgwide="1" frame="none" id="v4l2-dbg-match">
  116. <title>struct <structname>v4l2_dbg_match</structname></title>
  117. <tgroup cols="4">
  118. &cs-ustr;
  119. <tbody valign="top">
  120. <row>
  121. <entry>__u32</entry>
  122. <entry><structfield>type</structfield></entry>
  123. <entry>See <xref linkend="chip-match-types" /> for a list of
  124. possible types.</entry>
  125. </row>
  126. <row>
  127. <entry>union</entry>
  128. <entry>(anonymous)</entry>
  129. </row>
  130. <row>
  131. <entry></entry>
  132. <entry>__u32</entry>
  133. <entry><structfield>addr</structfield></entry>
  134. <entry>Match a chip by this number, interpreted according
  135. to the <structfield>type</structfield> field.</entry>
  136. </row>
  137. <row>
  138. <entry></entry>
  139. <entry>char</entry>
  140. <entry><structfield>name[32]</structfield></entry>
  141. <entry>Match a chip by this name, interpreted according
  142. to the <structfield>type</structfield> field. Currently unused.</entry>
  143. </row>
  144. </tbody>
  145. </tgroup>
  146. </table>
  147. <table pgwide="1" frame="none" id="v4l2-dbg-register">
  148. <title>struct <structname>v4l2_dbg_register</structname></title>
  149. <tgroup cols="4">
  150. <colspec colname="c1" />
  151. <colspec colname="c2" />
  152. <colspec colname="c4" />
  153. <tbody valign="top">
  154. <row>
  155. <entry>struct v4l2_dbg_match</entry>
  156. <entry><structfield>match</structfield></entry>
  157. <entry>How to match the chip, see <xref linkend="v4l2-dbg-match" />.</entry>
  158. </row>
  159. <row>
  160. <entry>__u32</entry>
  161. <entry><structfield>size</structfield></entry>
  162. <entry>The register size in bytes.</entry>
  163. </row>
  164. <row>
  165. <entry>__u64</entry>
  166. <entry><structfield>reg</structfield></entry>
  167. <entry>A register number.</entry>
  168. </row>
  169. <row>
  170. <entry>__u64</entry>
  171. <entry><structfield>val</structfield></entry>
  172. <entry>The value read from, or to be written into the
  173. register.</entry>
  174. </row>
  175. </tbody>
  176. </tgroup>
  177. </table>
  178. <!-- Note for convenience vidioc-dbg-g-chip-info.sgml
  179. contains a duplicate of this table. -->
  180. <table pgwide="1" frame="none" id="chip-match-types">
  181. <title>Chip Match Types</title>
  182. <tgroup cols="3">
  183. &cs-def;
  184. <tbody valign="top">
  185. <row>
  186. <entry><constant>V4L2_CHIP_MATCH_BRIDGE</constant></entry>
  187. <entry>0</entry>
  188. <entry>Match the nth chip on the card, zero for the
  189. bridge chip. Does not match sub-devices.</entry>
  190. </row>
  191. <row>
  192. <entry><constant>V4L2_CHIP_MATCH_SUBDEV</constant></entry>
  193. <entry>4</entry>
  194. <entry>Match the nth sub-device.</entry>
  195. </row>
  196. </tbody>
  197. </tgroup>
  198. </table>
  199. </refsect1>
  200. <refsect1>
  201. &return-value;
  202. <variablelist>
  203. <varlistentry>
  204. <term><errorcode>EPERM</errorcode></term>
  205. <listitem>
  206. <para>Insufficient permissions. Root privileges are required
  207. to execute these ioctls.</para>
  208. </listitem>
  209. </varlistentry>
  210. </variablelist>
  211. </refsect1>
  212. </refentry>