Commit | Line | Data |
---|---|---|
5377d91f MH |
1 | .. -*- coding: utf-8; mode: rst -*- |
2 | ||
af4a4d0d | 3 | .. _VIDIOC_DBG_G_REGISTER: |
5377d91f MH |
4 | |
5 | ************************************************** | |
6 | ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER | |
7 | ************************************************** | |
8 | ||
15e7d615 | 9 | Name |
586027ce | 10 | ==== |
5377d91f | 11 | |
586027ce | 12 | VIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers |
5377d91f | 13 | |
15e7d615 MCC |
14 | |
15 | Synopsis | |
5377d91f MH |
16 | ======== |
17 | ||
41d80465 MCC |
18 | .. c:function:: int ioctl( int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp ) |
19 | :name: VIDIOC_DBG_G_REGISTER | |
5377d91f | 20 | |
41d80465 MCC |
21 | .. c:function:: int ioctl( int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp ) |
22 | :name: VIDIOC_DBG_S_REGISTER | |
5377d91f | 23 | |
586027ce | 24 | |
15e7d615 | 25 | Arguments |
5377d91f MH |
26 | ========= |
27 | ||
28 | ``fd`` | |
29 | File descriptor returned by :ref:`open() <func-open>`. | |
30 | ||
5377d91f MH |
31 | ``argp`` |
32 | ||
33 | ||
15e7d615 | 34 | Description |
5377d91f MH |
35 | =========== |
36 | ||
706f8a99 | 37 | .. note:: |
5377d91f | 38 | |
7347081e | 39 | This is an :ref:`experimental` interface and may |
5377d91f MH |
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 | |
e8be7e97 | 52 | :c:type:`v4l2_dbg_register` except for ``size`` and |
5377d91f MH |
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 | |
7347081e | 68 | :ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl. |
5377d91f MH |
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 | |
7347081e | 75 | :ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely |
5377d91f MH |
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 | ||
5bd4bb78 MCC |
88 | .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| |
89 | ||
e8be7e97 | 90 | .. c:type:: v4l2_dbg_match |
fa92b04d | 91 | |
5377d91f MH |
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 | ||
0579e6e3 | 114 | - |
5377d91f MH |
115 | - __u32 |
116 | ||
117 | - ``addr`` | |
118 | ||
119 | - Match a chip by this number, interpreted according to the ``type`` | |
0579e6e3 | 120 | field. |
5377d91f MH |
121 | |
122 | - .. row 4 | |
123 | ||
0579e6e3 | 124 | - |
5377d91f MH |
125 | - char |
126 | ||
8968da9b | 127 | - ``name[32]`` |
5377d91f MH |
128 | |
129 | - Match a chip by this name, interpreted according to the ``type`` | |
0579e6e3 | 130 | field. Currently unused. |
5377d91f MH |
131 | |
132 | ||
133 | ||
e8be7e97 | 134 | .. c:type:: v4l2_dbg_register |
5377d91f MH |
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 | ||
56683d7d | 147 | - How to match the chip, see :c:type:`v4l2_dbg_match`. |
5377d91f MH |
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 | ||
5bd4bb78 MCC |
175 | .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| |
176 | ||
fa92b04d MCC |
177 | .. _chip-match-types: |
178 | ||
5377d91f MH |
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 | |
0579e6e3 | 192 | match sub-devices. |
5377d91f MH |
193 | |
194 | - .. row 2 | |
195 | ||
196 | - ``V4L2_CHIP_MATCH_SUBDEV`` | |
197 | ||
198 | - 4 | |
199 | ||
200 | - Match the nth sub-device. | |
201 | ||
202 | ||
15e7d615 | 203 | Return Value |
5377d91f MH |
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. |