vidioc-dbg-g-register.xml 9.0 KB

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