xref: /linux/Documentation/userspace-api/media/v4l/vidioc-dbg-g-register.rst (revision 059b1c5b15579b09c3787c3a3f843574233ab976)
1*059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
254f38fcaSMauro Carvalho Chehab
354f38fcaSMauro Carvalho Chehab.. _VIDIOC_DBG_G_REGISTER:
454f38fcaSMauro Carvalho Chehab
554f38fcaSMauro Carvalho Chehab**************************************************
654f38fcaSMauro Carvalho Chehabioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
754f38fcaSMauro Carvalho Chehab**************************************************
854f38fcaSMauro Carvalho Chehab
954f38fcaSMauro Carvalho ChehabName
1054f38fcaSMauro Carvalho Chehab====
1154f38fcaSMauro Carvalho Chehab
1254f38fcaSMauro Carvalho ChehabVIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
1354f38fcaSMauro Carvalho Chehab
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
1854f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp )
1954f38fcaSMauro Carvalho Chehab    :name: VIDIOC_DBG_G_REGISTER
2054f38fcaSMauro Carvalho Chehab
2154f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp )
2254f38fcaSMauro Carvalho Chehab    :name: VIDIOC_DBG_S_REGISTER
2354f38fcaSMauro Carvalho Chehab
2454f38fcaSMauro Carvalho Chehab
2554f38fcaSMauro Carvalho ChehabArguments
2654f38fcaSMauro Carvalho Chehab=========
2754f38fcaSMauro Carvalho Chehab
2854f38fcaSMauro Carvalho Chehab``fd``
2954f38fcaSMauro Carvalho Chehab    File descriptor returned by :ref:`open() <func-open>`.
3054f38fcaSMauro Carvalho Chehab
3154f38fcaSMauro Carvalho Chehab``argp``
3254f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`v4l2_dbg_register`.
3354f38fcaSMauro Carvalho Chehab
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
8854f38fcaSMauro Carvalho Chehab
8954f38fcaSMauro Carvalho Chehab.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
9054f38fcaSMauro Carvalho Chehab
9154f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_match
9254f38fcaSMauro Carvalho Chehab
9354f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_match
9454f38fcaSMauro Carvalho Chehab    :header-rows:  0
9554f38fcaSMauro Carvalho Chehab    :stub-columns: 0
9654f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
9754f38fcaSMauro Carvalho Chehab
9854f38fcaSMauro Carvalho Chehab    * - __u32
9954f38fcaSMauro Carvalho Chehab      - ``type``
10054f38fcaSMauro Carvalho Chehab      - See :ref:`chip-match-types` for a list of possible types.
10154f38fcaSMauro Carvalho Chehab    * - union {
10254f38fcaSMauro Carvalho Chehab      - (anonymous)
10354f38fcaSMauro Carvalho Chehab    * - __u32
10454f38fcaSMauro Carvalho Chehab      - ``addr``
10554f38fcaSMauro Carvalho Chehab      - Match a chip by this number, interpreted according to the ``type``
10654f38fcaSMauro Carvalho Chehab	field.
10754f38fcaSMauro Carvalho Chehab    * - char
10854f38fcaSMauro Carvalho Chehab      - ``name[32]``
10954f38fcaSMauro Carvalho Chehab      - Match a chip by this name, interpreted according to the ``type``
11054f38fcaSMauro Carvalho Chehab	field. Currently unused.
11154f38fcaSMauro Carvalho Chehab    * - }
11254f38fcaSMauro Carvalho Chehab      -
11354f38fcaSMauro Carvalho Chehab
11454f38fcaSMauro Carvalho Chehab
11554f38fcaSMauro Carvalho Chehab
11654f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_register
11754f38fcaSMauro Carvalho Chehab
11854f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_register
11954f38fcaSMauro Carvalho Chehab    :header-rows:  0
12054f38fcaSMauro Carvalho Chehab    :stub-columns: 0
12154f38fcaSMauro Carvalho Chehab
12254f38fcaSMauro Carvalho Chehab    * - struct v4l2_dbg_match
12354f38fcaSMauro Carvalho Chehab      - ``match``
12454f38fcaSMauro Carvalho Chehab      - How to match the chip, see :c:type:`v4l2_dbg_match`.
12554f38fcaSMauro Carvalho Chehab    * - __u32
12654f38fcaSMauro Carvalho Chehab      - ``size``
12754f38fcaSMauro Carvalho Chehab      - The register size in bytes.
12854f38fcaSMauro Carvalho Chehab    * - __u64
12954f38fcaSMauro Carvalho Chehab      - ``reg``
13054f38fcaSMauro Carvalho Chehab      - A register number.
13154f38fcaSMauro Carvalho Chehab    * - __u64
13254f38fcaSMauro Carvalho Chehab      - ``val``
13354f38fcaSMauro Carvalho Chehab      - The value read from, or to be written into the register.
13454f38fcaSMauro Carvalho Chehab
13554f38fcaSMauro Carvalho Chehab
13654f38fcaSMauro Carvalho Chehab
13754f38fcaSMauro Carvalho Chehab.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
13854f38fcaSMauro Carvalho Chehab
13954f38fcaSMauro Carvalho Chehab.. _chip-match-types:
14054f38fcaSMauro Carvalho Chehab
14154f38fcaSMauro Carvalho Chehab.. flat-table:: Chip Match Types
14254f38fcaSMauro Carvalho Chehab    :header-rows:  0
14354f38fcaSMauro Carvalho Chehab    :stub-columns: 0
14454f38fcaSMauro Carvalho Chehab    :widths:       3 1 4
14554f38fcaSMauro Carvalho Chehab
14654f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_BRIDGE``
14754f38fcaSMauro Carvalho Chehab      - 0
14854f38fcaSMauro Carvalho Chehab      - Match the nth chip on the card, zero for the bridge chip. Does not
14954f38fcaSMauro Carvalho Chehab	match sub-devices.
15054f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_SUBDEV``
15154f38fcaSMauro Carvalho Chehab      - 4
15254f38fcaSMauro Carvalho Chehab      - Match the nth sub-device.
15354f38fcaSMauro Carvalho Chehab
15454f38fcaSMauro Carvalho Chehab
15554f38fcaSMauro Carvalho ChehabReturn Value
15654f38fcaSMauro Carvalho Chehab============
15754f38fcaSMauro Carvalho Chehab
15854f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
15954f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
16054f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
16154f38fcaSMauro Carvalho Chehab
16254f38fcaSMauro Carvalho ChehabEPERM
16354f38fcaSMauro Carvalho Chehab    Insufficient permissions. Root privileges are required to execute
16454f38fcaSMauro Carvalho Chehab    these ioctls.
165