1 .. -*- coding: utf-8; mode: rst -*-
3 .. _VIDIOC_DBG_G_REGISTER:
5 **************************************************
6 ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
7 **************************************************
12 VIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
18 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_dbg_register *argp )
20 .. cpp:function:: int ioctl( int fd, int request, const struct v4l2_dbg_register *argp )
27 File descriptor returned by :ref:`open() <func-open>`.
30 VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
40 This is an :ref:`experimental` interface and may
43 For driver debugging purposes these ioctls allow test applications to
44 access hardware registers directly. Regular applications must not use
47 Since writing or even reading registers can jeopardize the system
48 security, its stability and damage the hardware, both ioctls require
49 superuser privileges. Additionally the Linux kernel must be compiled
50 with the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls.
52 To write a register applications must initialize all fields of a struct
53 :ref:`v4l2_dbg_register <v4l2-dbg-register>` except for ``size`` and
54 call ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The
55 ``match.type`` and ``match.addr`` or ``match.name`` fields select a chip
56 on the TV card, the ``reg`` field specifies a register number and the
57 ``val`` field the value to be written into the register.
59 To read a register applications must initialize the ``match.type``,
60 ``match.addr`` or ``match.name`` and ``reg`` fields, and call
61 ``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success
62 the driver stores the register value in the ``val`` field and the size
63 (in bytes) of the value in ``size``.
65 When ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr``
66 selects the nth non-sub-device chip on the TV card. The number zero
67 always selects the host chip, e. g. the chip connected to the PCI or USB
68 bus. You can find out which chips are present with the
69 :ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl.
71 When ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
72 selects the nth sub-device.
74 These ioctls are optional, not all drivers may support them. However
75 when a driver supports these ioctls it must also support
76 :ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely
77 it may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
79 ``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced
80 in Linux 2.6.21, but their API was changed to the one described here in
83 We recommended the v4l2-dbg utility over calling these ioctls directly.
84 It is available from the LinuxTV v4l-dvb repository; see
85 `https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access
89 .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
93 .. flat-table:: struct v4l2_dbg_match
105 - See :ref:`chip-match-types` for a list of possible types.
120 - Match a chip by this number, interpreted according to the ``type``
130 - Match a chip by this name, interpreted according to the ``type``
131 field. Currently unused.
135 .. _v4l2-dbg-register:
137 .. flat-table:: struct v4l2_dbg_register
144 - struct v4l2_dbg_match
148 - How to match the chip, see :ref:`v4l2-dbg-match`.
156 - The register size in bytes.
172 - The value read from, or to be written into the register.
176 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
178 .. _chip-match-types:
180 .. flat-table:: Chip Match Types
188 - ``V4L2_CHIP_MATCH_BRIDGE``
192 - Match the nth chip on the card, zero for the bridge chip. Does not
197 - ``V4L2_CHIP_MATCH_SUBDEV``
201 - Match the nth sub-device.
207 On success 0 is returned, on error -1 and the ``errno`` variable is set
208 appropriately. The generic error codes are described at the
209 :ref:`Generic Error Codes <gen-errors>` chapter.
212 Insufficient permissions. Root privileges are required to execute