1 .. -*- coding: utf-8; mode: rst -*-
3 .. _vidioc-dbg-g-register:
5 **************************************************
6 ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
7 **************************************************
9 *man VIDIOC_DBG_G_REGISTER(2)*
12 Read or write hardware registers
18 .. c:function:: int ioctl( int fd, int request, struct v4l2_dbg_register *argp )
20 .. c:function:: int ioctl( int fd, int request, const struct v4l2_dbg_register *argp )
26 File descriptor returned by :ref:`open() <func-open>`.
29 VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
39 This is an :ref:`experimental <experimental>` interface and may
42 For driver debugging purposes these ioctls allow test applications to
43 access hardware registers directly. Regular applications must not use
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.
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.
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``.
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 <vidioc-dbg-g-chip-info>` ioctl.
70 When ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
71 selects the nth sub-device.
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 <vidioc-dbg-g-chip-info>`. Conversely
76 it may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
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
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
90 .. flat-table:: struct v4l2_dbg_match
102 - See :ref:`chip-match-types` for a list of possible types.
117 - Match a chip by this number, interpreted according to the ``type``
127 - Match a chip by this name, interpreted according to the ``type``
128 field. Currently unused.
132 .. _v4l2-dbg-register:
134 .. flat-table:: struct v4l2_dbg_register
141 - struct v4l2_dbg_match
145 - How to match the chip, see :ref:`v4l2-dbg-match`.
153 - The register size in bytes.
169 - The value read from, or to be written into the register.
173 .. _chip-match-types:
175 .. flat-table:: Chip Match Types
183 - ``V4L2_CHIP_MATCH_BRIDGE``
187 - Match the nth chip on the card, zero for the bridge chip. Does not
192 - ``V4L2_CHIP_MATCH_SUBDEV``
196 - Match the nth sub-device.
203 On success 0 is returned, on error -1 and the ``errno`` variable is set
204 appropriately. The generic error codes are described at the
205 :ref:`Generic Error Codes <gen-errors>` chapter.
208 Insufficient permissions. Root privileges are required to execute
212 .. ------------------------------------------------------------------------------
213 .. This file was automatically converted from DocBook-XML with the dbxml
214 .. library (https://github.com/return42/sphkerneldoc). The origin XML comes
215 .. from the linux kernel, refer to:
217 .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
218 .. ------------------------------------------------------------------------------