[media] docs-rst: Convert V4L2 uAPI to use C function references
[cascardo/linux.git] / Documentation / media / uapi / v4l / vidioc-dbg-g-register.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _VIDIOC_DBG_G_REGISTER:
4
5 **************************************************
6 ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
7 **************************************************
8
9 Name
10 ====
11
12 VIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
13
14
15 Synopsis
16 ========
17
18 .. c:function:: int ioctl( int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp )
19     :name: VIDIOC_DBG_G_REGISTER
20
21 .. c:function:: int ioctl( int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp )
22     :name: VIDIOC_DBG_S_REGISTER
23
24
25 Arguments
26 =========
27
28 ``fd``
29     File descriptor returned by :ref:`open() <func-open>`.
30
31 ``argp``
32
33
34 Description
35 ===========
36
37 .. note::
38
39     This is an :ref:`experimental` interface and may
40     change in the future.
41
42 For driver debugging purposes these ioctls allow test applications to
43 access hardware registers directly. Regular applications must not use
44 them.
45
46 Since writing or even reading registers can jeopardize the system
47 security, its stability and damage the hardware, both ioctls require
48 superuser privileges. Additionally the Linux kernel must be compiled
49 with the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls.
50
51 To write a register applications must initialize all fields of a struct
52 :ref:`v4l2_dbg_register <v4l2-dbg-register>` except for ``size`` and
53 call ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The
54 ``match.type`` and ``match.addr`` or ``match.name`` fields select a chip
55 on the TV card, the ``reg`` field specifies a register number and the
56 ``val`` field the value to be written into the register.
57
58 To read a register applications must initialize the ``match.type``,
59 ``match.addr`` or ``match.name`` and ``reg`` fields, and call
60 ``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success
61 the driver stores the register value in the ``val`` field and the size
62 (in bytes) of the value in ``size``.
63
64 When ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr``
65 selects the nth non-sub-device chip on the TV card. The number zero
66 always selects the host chip, e. g. the chip connected to the PCI or USB
67 bus. You can find out which chips are present with the
68 :ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl.
69
70 When ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
71 selects the nth sub-device.
72
73 These ioctls are optional, not all drivers may support them. However
74 when a driver supports these ioctls it must also support
75 :ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely
76 it may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
77
78 ``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced
79 in Linux 2.6.21, but their API was changed to the one described here in
80 kernel 2.6.29.
81
82 We recommended the v4l2-dbg utility over calling these ioctls directly.
83 It is available from the LinuxTV v4l-dvb repository; see
84 `https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access
85 instructions.
86
87
88 .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
89
90 .. _v4l2-dbg-match:
91
92 .. flat-table:: struct v4l2_dbg_match
93     :header-rows:  0
94     :stub-columns: 0
95     :widths:       1 1 1 2
96
97
98     -  .. row 1
99
100        -  __u32
101
102        -  ``type``
103
104        -  See :ref:`chip-match-types` for a list of possible types.
105
106     -  .. row 2
107
108        -  union
109
110        -  (anonymous)
111
112     -  .. row 3
113
114        -
115        -  __u32
116
117        -  ``addr``
118
119        -  Match a chip by this number, interpreted according to the ``type``
120           field.
121
122     -  .. row 4
123
124        -
125        -  char
126
127        -  ``name[32]``
128
129        -  Match a chip by this name, interpreted according to the ``type``
130           field. Currently unused.
131
132
133
134 .. _v4l2-dbg-register:
135
136 .. flat-table:: struct v4l2_dbg_register
137     :header-rows:  0
138     :stub-columns: 0
139
140
141     -  .. row 1
142
143        -  struct v4l2_dbg_match
144
145        -  ``match``
146
147        -  How to match the chip, see :ref:`v4l2-dbg-match`.
148
149     -  .. row 2
150
151        -  __u32
152
153        -  ``size``
154
155        -  The register size in bytes.
156
157     -  .. row 3
158
159        -  __u64
160
161        -  ``reg``
162
163        -  A register number.
164
165     -  .. row 4
166
167        -  __u64
168
169        -  ``val``
170
171        -  The value read from, or to be written into the register.
172
173
174
175 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
176
177 .. _chip-match-types:
178
179 .. flat-table:: Chip Match Types
180     :header-rows:  0
181     :stub-columns: 0
182     :widths:       3 1 4
183
184
185     -  .. row 1
186
187        -  ``V4L2_CHIP_MATCH_BRIDGE``
188
189        -  0
190
191        -  Match the nth chip on the card, zero for the bridge chip. Does not
192           match sub-devices.
193
194     -  .. row 2
195
196        -  ``V4L2_CHIP_MATCH_SUBDEV``
197
198        -  4
199
200        -  Match the nth sub-device.
201
202
203 Return Value
204 ============
205
206 On success 0 is returned, on error -1 and the ``errno`` variable is set
207 appropriately. The generic error codes are described at the
208 :ref:`Generic Error Codes <gen-errors>` chapter.
209
210 EPERM
211     Insufficient permissions. Root privileges are required to execute
212     these ioctls.