1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _VIDIOC_DBG_G_REGISTER:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab**************************************************
754f38fcaSMauro Carvalho Chehabioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
854f38fcaSMauro Carvalho Chehab**************************************************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabVIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
18407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_DBG_G_REGISTER
1954f38fcaSMauro Carvalho Chehab
20407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp)``
2154f38fcaSMauro Carvalho Chehab
22407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_DBG_S_REGISTER
23407e84cdSMauro Carvalho Chehab
24407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp)``
2554f38fcaSMauro Carvalho Chehab
2654f38fcaSMauro Carvalho ChehabArguments
2754f38fcaSMauro Carvalho Chehab=========
2854f38fcaSMauro Carvalho Chehab
2954f38fcaSMauro Carvalho Chehab``fd``
30407e84cdSMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
3154f38fcaSMauro Carvalho Chehab
3254f38fcaSMauro Carvalho Chehab``argp``
3354f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`v4l2_dbg_register`.
3454f38fcaSMauro Carvalho Chehab
3554f38fcaSMauro Carvalho ChehabDescription
3654f38fcaSMauro Carvalho Chehab===========
3754f38fcaSMauro Carvalho Chehab
3854f38fcaSMauro Carvalho Chehab.. note::
3954f38fcaSMauro Carvalho Chehab
4054f38fcaSMauro Carvalho Chehab    This is an :ref:`experimental` interface and may
4154f38fcaSMauro Carvalho Chehab    change in the future.
4254f38fcaSMauro Carvalho Chehab
4354f38fcaSMauro Carvalho ChehabFor driver debugging purposes these ioctls allow test applications to
4454f38fcaSMauro Carvalho Chehabaccess hardware registers directly. Regular applications must not use
4554f38fcaSMauro Carvalho Chehabthem.
4654f38fcaSMauro Carvalho Chehab
4754f38fcaSMauro Carvalho ChehabSince writing or even reading registers can jeopardize the system
4854f38fcaSMauro Carvalho Chehabsecurity, its stability and damage the hardware, both ioctls require
4954f38fcaSMauro Carvalho Chehabsuperuser privileges. Additionally the Linux kernel must be compiled
5054f38fcaSMauro Carvalho Chehabwith the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls.
5154f38fcaSMauro Carvalho Chehab
5254f38fcaSMauro Carvalho ChehabTo write a register applications must initialize all fields of a struct
5354f38fcaSMauro Carvalho Chehab:c:type:`v4l2_dbg_register` except for ``size`` and
5454f38fcaSMauro Carvalho Chehabcall ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The
5554f38fcaSMauro Carvalho Chehab``match.type`` and ``match.addr`` or ``match.name`` fields select a chip
5654f38fcaSMauro Carvalho Chehabon the TV card, the ``reg`` field specifies a register number and the
5754f38fcaSMauro Carvalho Chehab``val`` field the value to be written into the register.
5854f38fcaSMauro Carvalho Chehab
5954f38fcaSMauro Carvalho ChehabTo read a register applications must initialize the ``match.type``,
6054f38fcaSMauro Carvalho Chehab``match.addr`` or ``match.name`` and ``reg`` fields, and call
6154f38fcaSMauro Carvalho Chehab``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success
6254f38fcaSMauro Carvalho Chehabthe driver stores the register value in the ``val`` field and the size
6354f38fcaSMauro Carvalho Chehab(in bytes) of the value in ``size``.
6454f38fcaSMauro Carvalho Chehab
6554f38fcaSMauro Carvalho ChehabWhen ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr``
6654f38fcaSMauro Carvalho Chehabselects the nth non-sub-device chip on the TV card. The number zero
6754f38fcaSMauro Carvalho Chehabalways selects the host chip, e. g. the chip connected to the PCI or USB
6854f38fcaSMauro Carvalho Chehabbus. You can find out which chips are present with the
6954f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl.
7054f38fcaSMauro Carvalho Chehab
7154f38fcaSMauro Carvalho ChehabWhen ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
7254f38fcaSMauro Carvalho Chehabselects the nth sub-device.
7354f38fcaSMauro Carvalho Chehab
7454f38fcaSMauro Carvalho ChehabThese ioctls are optional, not all drivers may support them. However
7554f38fcaSMauro Carvalho Chehabwhen a driver supports these ioctls it must also support
7654f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely
7754f38fcaSMauro Carvalho Chehabit may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
7854f38fcaSMauro Carvalho Chehab
7954f38fcaSMauro Carvalho Chehab``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced
8054f38fcaSMauro Carvalho Chehabin Linux 2.6.21, but their API was changed to the one described here in
8154f38fcaSMauro Carvalho Chehabkernel 2.6.29.
8254f38fcaSMauro Carvalho Chehab
8354f38fcaSMauro Carvalho ChehabWe recommended the v4l2-dbg utility over calling these ioctls directly.
8454f38fcaSMauro Carvalho ChehabIt is available from the LinuxTV v4l-dvb repository; see
8554f38fcaSMauro Carvalho Chehab`https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access
8654f38fcaSMauro Carvalho Chehabinstructions.
8754f38fcaSMauro Carvalho Chehab
88*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{6.6cm}|
8954f38fcaSMauro Carvalho Chehab
9054f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_match
9154f38fcaSMauro Carvalho Chehab
9254f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_match
9354f38fcaSMauro Carvalho Chehab    :header-rows:  0
9454f38fcaSMauro Carvalho Chehab    :stub-columns: 0
9554f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
9654f38fcaSMauro Carvalho Chehab
9754f38fcaSMauro Carvalho Chehab    * - __u32
9854f38fcaSMauro Carvalho Chehab      - ``type``
9954f38fcaSMauro Carvalho Chehab      - See :ref:`chip-match-types` for a list of possible types.
10054f38fcaSMauro Carvalho Chehab    * - union {
10154f38fcaSMauro Carvalho Chehab      - (anonymous)
10254f38fcaSMauro Carvalho Chehab    * - __u32
10354f38fcaSMauro Carvalho Chehab      - ``addr``
10454f38fcaSMauro Carvalho Chehab      - Match a chip by this number, interpreted according to the ``type``
10554f38fcaSMauro Carvalho Chehab	field.
10654f38fcaSMauro Carvalho Chehab    * - char
10754f38fcaSMauro Carvalho Chehab      - ``name[32]``
10854f38fcaSMauro Carvalho Chehab      - Match a chip by this name, interpreted according to the ``type``
10954f38fcaSMauro Carvalho Chehab	field. Currently unused.
11054f38fcaSMauro Carvalho Chehab    * - }
11154f38fcaSMauro Carvalho Chehab      -
11254f38fcaSMauro Carvalho Chehab
11354f38fcaSMauro Carvalho Chehab
11454f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_register
11554f38fcaSMauro Carvalho Chehab
11654f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_register
11754f38fcaSMauro Carvalho Chehab    :header-rows:  0
11854f38fcaSMauro Carvalho Chehab    :stub-columns: 0
11954f38fcaSMauro Carvalho Chehab
12054f38fcaSMauro Carvalho Chehab    * - struct v4l2_dbg_match
12154f38fcaSMauro Carvalho Chehab      - ``match``
12254f38fcaSMauro Carvalho Chehab      - How to match the chip, see :c:type:`v4l2_dbg_match`.
12354f38fcaSMauro Carvalho Chehab    * - __u32
12454f38fcaSMauro Carvalho Chehab      - ``size``
12554f38fcaSMauro Carvalho Chehab      - The register size in bytes.
12654f38fcaSMauro Carvalho Chehab    * - __u64
12754f38fcaSMauro Carvalho Chehab      - ``reg``
12854f38fcaSMauro Carvalho Chehab      - A register number.
12954f38fcaSMauro Carvalho Chehab    * - __u64
13054f38fcaSMauro Carvalho Chehab      - ``val``
13154f38fcaSMauro Carvalho Chehab      - The value read from, or to be written into the register.
13254f38fcaSMauro Carvalho Chehab
13354f38fcaSMauro Carvalho Chehab
134*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
13554f38fcaSMauro Carvalho Chehab
13654f38fcaSMauro Carvalho Chehab.. _chip-match-types:
13754f38fcaSMauro Carvalho Chehab
13854f38fcaSMauro Carvalho Chehab.. flat-table:: Chip Match Types
13954f38fcaSMauro Carvalho Chehab    :header-rows:  0
14054f38fcaSMauro Carvalho Chehab    :stub-columns: 0
14154f38fcaSMauro Carvalho Chehab    :widths:       3 1 4
14254f38fcaSMauro Carvalho Chehab
14354f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_BRIDGE``
14454f38fcaSMauro Carvalho Chehab      - 0
14554f38fcaSMauro Carvalho Chehab      - Match the nth chip on the card, zero for the bridge chip. Does not
14654f38fcaSMauro Carvalho Chehab	match sub-devices.
14754f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_SUBDEV``
14854f38fcaSMauro Carvalho Chehab      - 4
14954f38fcaSMauro Carvalho Chehab      - Match the nth sub-device.
15054f38fcaSMauro Carvalho Chehab
15154f38fcaSMauro Carvalho ChehabReturn Value
15254f38fcaSMauro Carvalho Chehab============
15354f38fcaSMauro Carvalho Chehab
15454f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
15554f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
15654f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
15754f38fcaSMauro Carvalho Chehab
15854f38fcaSMauro Carvalho ChehabEPERM
15954f38fcaSMauro Carvalho Chehab    Insufficient permissions. Root privileges are required to execute
16054f38fcaSMauro Carvalho Chehab    these ioctls.
161