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