18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _VIDIOC_DBG_G_REGISTER: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci************************************************** 78c2ecf20Sopenharmony_ciioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER 88c2ecf20Sopenharmony_ci************************************************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciVIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_DBG_G_REGISTER 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp)`` 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_DBG_S_REGISTER 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp)`` 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciArguments 278c2ecf20Sopenharmony_ci========= 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci``fd`` 308c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci``argp`` 338c2ecf20Sopenharmony_ci Pointer to struct :c:type:`v4l2_dbg_register`. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciDescription 368c2ecf20Sopenharmony_ci=========== 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci.. note:: 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci This is an :ref:`experimental` interface and may 418c2ecf20Sopenharmony_ci change in the future. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciFor driver debugging purposes these ioctls allow test applications to 448c2ecf20Sopenharmony_ciaccess hardware registers directly. Regular applications must not use 458c2ecf20Sopenharmony_cithem. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciSince writing or even reading registers can jeopardize the system 488c2ecf20Sopenharmony_cisecurity, its stability and damage the hardware, both ioctls require 498c2ecf20Sopenharmony_cisuperuser privileges. Additionally the Linux kernel must be compiled 508c2ecf20Sopenharmony_ciwith the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciTo write a register applications must initialize all fields of a struct 538c2ecf20Sopenharmony_ci:c:type:`v4l2_dbg_register` except for ``size`` and 548c2ecf20Sopenharmony_cicall ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The 558c2ecf20Sopenharmony_ci``match.type`` and ``match.addr`` or ``match.name`` fields select a chip 568c2ecf20Sopenharmony_cion the TV card, the ``reg`` field specifies a register number and the 578c2ecf20Sopenharmony_ci``val`` field the value to be written into the register. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciTo read a register applications must initialize the ``match.type``, 608c2ecf20Sopenharmony_ci``match.addr`` or ``match.name`` and ``reg`` fields, and call 618c2ecf20Sopenharmony_ci``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success 628c2ecf20Sopenharmony_cithe driver stores the register value in the ``val`` field and the size 638c2ecf20Sopenharmony_ci(in bytes) of the value in ``size``. 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciWhen ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr`` 668c2ecf20Sopenharmony_ciselects the nth non-sub-device chip on the TV card. The number zero 678c2ecf20Sopenharmony_cialways selects the host chip, e. g. the chip connected to the PCI or USB 688c2ecf20Sopenharmony_cibus. You can find out which chips are present with the 698c2ecf20Sopenharmony_ci:ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl. 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciWhen ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr`` 728c2ecf20Sopenharmony_ciselects the nth sub-device. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciThese ioctls are optional, not all drivers may support them. However 758c2ecf20Sopenharmony_ciwhen a driver supports these ioctls it must also support 768c2ecf20Sopenharmony_ci:ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely 778c2ecf20Sopenharmony_ciit may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls. 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced 808c2ecf20Sopenharmony_ciin Linux 2.6.21, but their API was changed to the one described here in 818c2ecf20Sopenharmony_cikernel 2.6.29. 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciWe recommended the v4l2-dbg utility over calling these ioctls directly. 848c2ecf20Sopenharmony_ciIt is available from the LinuxTV v4l-dvb repository; see 858c2ecf20Sopenharmony_ci`https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access 868c2ecf20Sopenharmony_ciinstructions. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci.. c:type:: v4l2_dbg_match 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_dbg_match 938c2ecf20Sopenharmony_ci :header-rows: 0 948c2ecf20Sopenharmony_ci :stub-columns: 0 958c2ecf20Sopenharmony_ci :widths: 1 1 2 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci * - __u32 988c2ecf20Sopenharmony_ci - ``type`` 998c2ecf20Sopenharmony_ci - See :ref:`chip-match-types` for a list of possible types. 1008c2ecf20Sopenharmony_ci * - union { 1018c2ecf20Sopenharmony_ci - (anonymous) 1028c2ecf20Sopenharmony_ci * - __u32 1038c2ecf20Sopenharmony_ci - ``addr`` 1048c2ecf20Sopenharmony_ci - Match a chip by this number, interpreted according to the ``type`` 1058c2ecf20Sopenharmony_ci field. 1068c2ecf20Sopenharmony_ci * - char 1078c2ecf20Sopenharmony_ci - ``name[32]`` 1088c2ecf20Sopenharmony_ci - Match a chip by this name, interpreted according to the ``type`` 1098c2ecf20Sopenharmony_ci field. Currently unused. 1108c2ecf20Sopenharmony_ci * - } 1118c2ecf20Sopenharmony_ci - 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci.. c:type:: v4l2_dbg_register 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_dbg_register 1178c2ecf20Sopenharmony_ci :header-rows: 0 1188c2ecf20Sopenharmony_ci :stub-columns: 0 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci * - struct v4l2_dbg_match 1218c2ecf20Sopenharmony_ci - ``match`` 1228c2ecf20Sopenharmony_ci - How to match the chip, see :c:type:`v4l2_dbg_match`. 1238c2ecf20Sopenharmony_ci * - __u32 1248c2ecf20Sopenharmony_ci - ``size`` 1258c2ecf20Sopenharmony_ci - The register size in bytes. 1268c2ecf20Sopenharmony_ci * - __u64 1278c2ecf20Sopenharmony_ci - ``reg`` 1288c2ecf20Sopenharmony_ci - A register number. 1298c2ecf20Sopenharmony_ci * - __u64 1308c2ecf20Sopenharmony_ci - ``val`` 1318c2ecf20Sopenharmony_ci - The value read from, or to be written into the register. 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci.. _chip-match-types: 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci.. flat-table:: Chip Match Types 1398c2ecf20Sopenharmony_ci :header-rows: 0 1408c2ecf20Sopenharmony_ci :stub-columns: 0 1418c2ecf20Sopenharmony_ci :widths: 3 1 4 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci * - ``V4L2_CHIP_MATCH_BRIDGE`` 1448c2ecf20Sopenharmony_ci - 0 1458c2ecf20Sopenharmony_ci - Match the nth chip on the card, zero for the bridge chip. Does not 1468c2ecf20Sopenharmony_ci match sub-devices. 1478c2ecf20Sopenharmony_ci * - ``V4L2_CHIP_MATCH_SUBDEV`` 1488c2ecf20Sopenharmony_ci - 4 1498c2ecf20Sopenharmony_ci - Match the nth sub-device. 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciReturn Value 1528c2ecf20Sopenharmony_ci============ 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 1558c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 1568c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ciEPERM 1598c2ecf20Sopenharmony_ci Insufficient permissions. Root privileges are required to execute 1608c2ecf20Sopenharmony_ci these ioctls. 161