162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_DBG_G_REGISTER:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**************************************************
762306a36Sopenharmony_ciioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
862306a36Sopenharmony_ci**************************************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_DBG_G_REGISTER
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_DBG_S_REGISTER
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciArguments
2762306a36Sopenharmony_ci=========
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci``fd``
3062306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``argp``
3362306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_dbg_register`.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDescription
3662306a36Sopenharmony_ci===========
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci.. note::
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci    This is an :ref:`experimental` interface and may
4162306a36Sopenharmony_ci    change in the future.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciFor driver debugging purposes these ioctls allow test applications to
4462306a36Sopenharmony_ciaccess hardware registers directly. Regular applications must not use
4562306a36Sopenharmony_cithem.
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciSince writing or even reading registers can jeopardize the system
4862306a36Sopenharmony_cisecurity, its stability and damage the hardware, both ioctls require
4962306a36Sopenharmony_cisuperuser privileges. Additionally the Linux kernel must be compiled
5062306a36Sopenharmony_ciwith the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls.
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciTo write a register applications must initialize all fields of a struct
5362306a36Sopenharmony_ci:c:type:`v4l2_dbg_register` except for ``size`` and
5462306a36Sopenharmony_cicall ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The
5562306a36Sopenharmony_ci``match.type`` and ``match.addr`` or ``match.name`` fields select a chip
5662306a36Sopenharmony_cion the TV card, the ``reg`` field specifies a register number and the
5762306a36Sopenharmony_ci``val`` field the value to be written into the register.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciTo read a register applications must initialize the ``match.type``,
6062306a36Sopenharmony_ci``match.addr`` or ``match.name`` and ``reg`` fields, and call
6162306a36Sopenharmony_ci``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success
6262306a36Sopenharmony_cithe driver stores the register value in the ``val`` field and the size
6362306a36Sopenharmony_ci(in bytes) of the value in ``size``.
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciWhen ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr``
6662306a36Sopenharmony_ciselects the nth non-sub-device chip on the TV card. The number zero
6762306a36Sopenharmony_cialways selects the host chip, e. g. the chip connected to the PCI or USB
6862306a36Sopenharmony_cibus. You can find out which chips are present with the
6962306a36Sopenharmony_ci:ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciWhen ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
7262306a36Sopenharmony_ciselects the nth sub-device.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciThese ioctls are optional, not all drivers may support them. However
7562306a36Sopenharmony_ciwhen a driver supports these ioctls it must also support
7662306a36Sopenharmony_ci:ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely
7762306a36Sopenharmony_ciit may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced
8062306a36Sopenharmony_ciin Linux 2.6.21, but their API was changed to the one described here in
8162306a36Sopenharmony_cikernel 2.6.29.
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciWe recommended the v4l2-dbg utility over calling these ioctls directly.
8462306a36Sopenharmony_ciIt is available from the LinuxTV v4l-dvb repository; see
8562306a36Sopenharmony_ci`https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access
8662306a36Sopenharmony_ciinstructions.
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{6.6cm}|
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci.. c:type:: v4l2_dbg_match
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci.. flat-table:: struct v4l2_dbg_match
9362306a36Sopenharmony_ci    :header-rows:  0
9462306a36Sopenharmony_ci    :stub-columns: 0
9562306a36Sopenharmony_ci    :widths:       1 1 2
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci    * - __u32
9862306a36Sopenharmony_ci      - ``type``
9962306a36Sopenharmony_ci      - See :ref:`chip-match-types` for a list of possible types.
10062306a36Sopenharmony_ci    * - union {
10162306a36Sopenharmony_ci      - (anonymous)
10262306a36Sopenharmony_ci    * - __u32
10362306a36Sopenharmony_ci      - ``addr``
10462306a36Sopenharmony_ci      - Match a chip by this number, interpreted according to the ``type``
10562306a36Sopenharmony_ci	field.
10662306a36Sopenharmony_ci    * - char
10762306a36Sopenharmony_ci      - ``name[32]``
10862306a36Sopenharmony_ci      - Match a chip by this name, interpreted according to the ``type``
10962306a36Sopenharmony_ci	field. Currently unused.
11062306a36Sopenharmony_ci    * - }
11162306a36Sopenharmony_ci      -
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci.. c:type:: v4l2_dbg_register
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci.. flat-table:: struct v4l2_dbg_register
11762306a36Sopenharmony_ci    :header-rows:  0
11862306a36Sopenharmony_ci    :stub-columns: 0
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci    * - struct v4l2_dbg_match
12162306a36Sopenharmony_ci      - ``match``
12262306a36Sopenharmony_ci      - How to match the chip, see :c:type:`v4l2_dbg_match`.
12362306a36Sopenharmony_ci    * - __u32
12462306a36Sopenharmony_ci      - ``size``
12562306a36Sopenharmony_ci      - The register size in bytes.
12662306a36Sopenharmony_ci    * - __u64
12762306a36Sopenharmony_ci      - ``reg``
12862306a36Sopenharmony_ci      - A register number.
12962306a36Sopenharmony_ci    * - __u64
13062306a36Sopenharmony_ci      - ``val``
13162306a36Sopenharmony_ci      - The value read from, or to be written into the register.
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci.. _chip-match-types:
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci.. flat-table:: Chip Match Types
13962306a36Sopenharmony_ci    :header-rows:  0
14062306a36Sopenharmony_ci    :stub-columns: 0
14162306a36Sopenharmony_ci    :widths:       3 1 4
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci    * - ``V4L2_CHIP_MATCH_BRIDGE``
14462306a36Sopenharmony_ci      - 0
14562306a36Sopenharmony_ci      - Match the nth chip on the card, zero for the bridge chip. Does not
14662306a36Sopenharmony_ci	match sub-devices.
14762306a36Sopenharmony_ci    * - ``V4L2_CHIP_MATCH_SUBDEV``
14862306a36Sopenharmony_ci      - 4
14962306a36Sopenharmony_ci      - Match the nth sub-device.
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciReturn Value
15262306a36Sopenharmony_ci============
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
15562306a36Sopenharmony_ciappropriately. The generic error codes are described at the
15662306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ciEPERM
15962306a36Sopenharmony_ci    Insufficient permissions. Root privileges are required to execute
16062306a36Sopenharmony_ci    these ioctls.
161