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