vidioc-dbg-g-register.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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_I2C_DRIVER</constant>,
  93. <structfield>match.name</structfield> contains the I2C driver name.
  94. For instance
  95. <constant>"saa7127"</constant> will match any chip
  96. supported by the saa7127 driver, regardless of its &i2c; bus address.
  97. When multiple chips supported by the same driver are present, the
  98. effect of these ioctls is undefined. Again with the
  99. &VIDIOC-DBG-G-CHIP-INFO; ioctl you can find out which &i2c; chips are
  100. present.</para>
  101. <para>When <structfield>match.type</structfield> is
  102. <constant>V4L2_CHIP_MATCH_I2C_ADDR</constant>,
  103. <structfield>match.addr</structfield> selects a chip by its 7 bit &i2c;
  104. bus address.</para>
  105. <para>When <structfield>match.type</structfield> is
  106. <constant>V4L2_CHIP_MATCH_AC97</constant>,
  107. <structfield>match.addr</structfield> selects the nth AC97 chip
  108. on the TV card.</para>
  109. <para>When <structfield>match.type</structfield> is
  110. <constant>V4L2_CHIP_MATCH_SUBDEV</constant>,
  111. <structfield>match.addr</structfield> selects the nth sub-device.</para>
  112. <note>
  113. <title>Success not guaranteed</title>
  114. <para>Due to a flaw in the Linux &i2c; bus driver these ioctls may
  115. return successfully without actually reading or writing a register. To
  116. catch the most likely failure we recommend a &VIDIOC-DBG-G-CHIP-INFO;
  117. call confirming the presence of the selected &i2c; chip.</para>
  118. </note>
  119. <para>These ioctls are optional, not all drivers may support them.
  120. However when a driver supports these ioctls it must also support
  121. &VIDIOC-DBG-G-CHIP-INFO;. Conversely it may support
  122. <constant>VIDIOC_DBG_G_CHIP_INFO</constant> but not these ioctls.</para>
  123. <para><constant>VIDIOC_DBG_G_REGISTER</constant> and
  124. <constant>VIDIOC_DBG_S_REGISTER</constant> were introduced in Linux
  125. 2.6.21, but their API was changed to the one described here in kernel 2.6.29.</para>
  126. <para>We recommended the <application>v4l2-dbg</application>
  127. utility over calling these ioctls directly. It is available from the
  128. LinuxTV v4l-dvb repository; see <ulink
  129. url="http://linuxtv.org/repo/">http://linuxtv.org/repo/</ulink> for
  130. access instructions.</para>
  131. <!-- Note for convenience vidioc-dbg-g-chip-info.sgml
  132. contains a duplicate of this table. -->
  133. <table pgwide="1" frame="none" id="v4l2-dbg-match">
  134. <title>struct <structname>v4l2_dbg_match</structname></title>
  135. <tgroup cols="4">
  136. &cs-ustr;
  137. <tbody valign="top">
  138. <row>
  139. <entry>__u32</entry>
  140. <entry><structfield>type</structfield></entry>
  141. <entry>See <xref linkend="ident-chip-match-types" /> for a list of
  142. possible types.</entry>
  143. </row>
  144. <row>
  145. <entry>union</entry>
  146. <entry>(anonymous)</entry>
  147. </row>
  148. <row>
  149. <entry></entry>
  150. <entry>__u32</entry>
  151. <entry><structfield>addr</structfield></entry>
  152. <entry>Match a chip by this number, interpreted according
  153. to the <structfield>type</structfield> field.</entry>
  154. </row>
  155. <row>
  156. <entry></entry>
  157. <entry>char</entry>
  158. <entry><structfield>name[32]</structfield></entry>
  159. <entry>Match a chip by this name, interpreted according
  160. to the <structfield>type</structfield> field.</entry>
  161. </row>
  162. </tbody>
  163. </tgroup>
  164. </table>
  165. <table pgwide="1" frame="none" id="v4l2-dbg-register">
  166. <title>struct <structname>v4l2_dbg_register</structname></title>
  167. <tgroup cols="4">
  168. <colspec colname="c1" />
  169. <colspec colname="c2" />
  170. <colspec colname="c4" />
  171. <tbody valign="top">
  172. <row>
  173. <entry>struct v4l2_dbg_match</entry>
  174. <entry><structfield>match</structfield></entry>
  175. <entry>How to match the chip, see <xref linkend="v4l2-dbg-match" />.</entry>
  176. </row>
  177. <row>
  178. <entry>__u32</entry>
  179. <entry><structfield>size</structfield></entry>
  180. <entry>The register size in bytes.</entry>
  181. </row>
  182. <row>
  183. <entry>__u64</entry>
  184. <entry><structfield>reg</structfield></entry>
  185. <entry>A register number.</entry>
  186. </row>
  187. <row>
  188. <entry>__u64</entry>
  189. <entry><structfield>val</structfield></entry>
  190. <entry>The value read from, or to be written into the
  191. register.</entry>
  192. </row>
  193. </tbody>
  194. </tgroup>
  195. </table>
  196. <!-- Note for convenience vidioc-dbg-g-chip-info.sgml
  197. contains a duplicate of this table. -->
  198. <table pgwide="1" frame="none" id="chip-match-types">
  199. <title>Chip Match Types</title>
  200. <tgroup cols="3">
  201. &cs-def;
  202. <tbody valign="top">
  203. <row>
  204. <entry><constant>V4L2_CHIP_MATCH_BRIDGE</constant></entry>
  205. <entry>0</entry>
  206. <entry>Match the nth chip on the card, zero for the
  207. bridge chip. Does not match sub-devices.</entry>
  208. </row>
  209. <row>
  210. <entry><constant>V4L2_CHIP_MATCH_I2C_DRIVER</constant></entry>
  211. <entry>1</entry>
  212. <entry>Match an &i2c; chip by its driver name.</entry>
  213. </row>
  214. <row>
  215. <entry><constant>V4L2_CHIP_MATCH_I2C_ADDR</constant></entry>
  216. <entry>2</entry>
  217. <entry>Match a chip by its 7 bit &i2c; bus address.</entry>
  218. </row>
  219. <row>
  220. <entry><constant>V4L2_CHIP_MATCH_AC97</constant></entry>
  221. <entry>3</entry>
  222. <entry>Match the nth anciliary AC97 chip.</entry>
  223. </row>
  224. <row>
  225. <entry><constant>V4L2_CHIP_MATCH_SUBDEV</constant></entry>
  226. <entry>4</entry>
  227. <entry>Match the nth sub-device.</entry>
  228. </row>
  229. </tbody>
  230. </tgroup>
  231. </table>
  232. </refsect1>
  233. <refsect1>
  234. &return-value;
  235. <variablelist>
  236. <varlistentry>
  237. <term><errorcode>EPERM</errorcode></term>
  238. <listitem>
  239. <para>Insufficient permissions. Root privileges are required
  240. to execute these ioctls.</para>
  241. </listitem>
  242. </varlistentry>
  243. </variablelist>
  244. </refsect1>
  245. </refentry>