xref: /linux/Documentation/userspace-api/media/v4l/vidioc-dbg-g-register.rst (revision 54f38fcae536ea202ce7d6a359521492fba30c1f)
1*54f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this
2*54f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License,
3*54f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software
4*54f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts
5*54f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at
6*54f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst.
7*54f38fcaSMauro Carvalho Chehab..
8*54f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9*54f38fcaSMauro Carvalho Chehab
10*54f38fcaSMauro Carvalho Chehab.. _VIDIOC_DBG_G_REGISTER:
11*54f38fcaSMauro Carvalho Chehab
12*54f38fcaSMauro Carvalho Chehab**************************************************
13*54f38fcaSMauro Carvalho Chehabioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
14*54f38fcaSMauro Carvalho Chehab**************************************************
15*54f38fcaSMauro Carvalho Chehab
16*54f38fcaSMauro Carvalho ChehabName
17*54f38fcaSMauro Carvalho Chehab====
18*54f38fcaSMauro Carvalho Chehab
19*54f38fcaSMauro Carvalho ChehabVIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
20*54f38fcaSMauro Carvalho Chehab
21*54f38fcaSMauro Carvalho Chehab
22*54f38fcaSMauro Carvalho ChehabSynopsis
23*54f38fcaSMauro Carvalho Chehab========
24*54f38fcaSMauro Carvalho Chehab
25*54f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp )
26*54f38fcaSMauro Carvalho Chehab    :name: VIDIOC_DBG_G_REGISTER
27*54f38fcaSMauro Carvalho Chehab
28*54f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp )
29*54f38fcaSMauro Carvalho Chehab    :name: VIDIOC_DBG_S_REGISTER
30*54f38fcaSMauro Carvalho Chehab
31*54f38fcaSMauro Carvalho Chehab
32*54f38fcaSMauro Carvalho ChehabArguments
33*54f38fcaSMauro Carvalho Chehab=========
34*54f38fcaSMauro Carvalho Chehab
35*54f38fcaSMauro Carvalho Chehab``fd``
36*54f38fcaSMauro Carvalho Chehab    File descriptor returned by :ref:`open() <func-open>`.
37*54f38fcaSMauro Carvalho Chehab
38*54f38fcaSMauro Carvalho Chehab``argp``
39*54f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`v4l2_dbg_register`.
40*54f38fcaSMauro Carvalho Chehab
41*54f38fcaSMauro Carvalho Chehab
42*54f38fcaSMauro Carvalho ChehabDescription
43*54f38fcaSMauro Carvalho Chehab===========
44*54f38fcaSMauro Carvalho Chehab
45*54f38fcaSMauro Carvalho Chehab.. note::
46*54f38fcaSMauro Carvalho Chehab
47*54f38fcaSMauro Carvalho Chehab    This is an :ref:`experimental` interface and may
48*54f38fcaSMauro Carvalho Chehab    change in the future.
49*54f38fcaSMauro Carvalho Chehab
50*54f38fcaSMauro Carvalho ChehabFor driver debugging purposes these ioctls allow test applications to
51*54f38fcaSMauro Carvalho Chehabaccess hardware registers directly. Regular applications must not use
52*54f38fcaSMauro Carvalho Chehabthem.
53*54f38fcaSMauro Carvalho Chehab
54*54f38fcaSMauro Carvalho ChehabSince writing or even reading registers can jeopardize the system
55*54f38fcaSMauro Carvalho Chehabsecurity, its stability and damage the hardware, both ioctls require
56*54f38fcaSMauro Carvalho Chehabsuperuser privileges. Additionally the Linux kernel must be compiled
57*54f38fcaSMauro Carvalho Chehabwith the ``CONFIG_VIDEO_ADV_DEBUG`` option to enable these ioctls.
58*54f38fcaSMauro Carvalho Chehab
59*54f38fcaSMauro Carvalho ChehabTo write a register applications must initialize all fields of a struct
60*54f38fcaSMauro Carvalho Chehab:c:type:`v4l2_dbg_register` except for ``size`` and
61*54f38fcaSMauro Carvalho Chehabcall ``VIDIOC_DBG_S_REGISTER`` with a pointer to this structure. The
62*54f38fcaSMauro Carvalho Chehab``match.type`` and ``match.addr`` or ``match.name`` fields select a chip
63*54f38fcaSMauro Carvalho Chehabon the TV card, the ``reg`` field specifies a register number and the
64*54f38fcaSMauro Carvalho Chehab``val`` field the value to be written into the register.
65*54f38fcaSMauro Carvalho Chehab
66*54f38fcaSMauro Carvalho ChehabTo read a register applications must initialize the ``match.type``,
67*54f38fcaSMauro Carvalho Chehab``match.addr`` or ``match.name`` and ``reg`` fields, and call
68*54f38fcaSMauro Carvalho Chehab``VIDIOC_DBG_G_REGISTER`` with a pointer to this structure. On success
69*54f38fcaSMauro Carvalho Chehabthe driver stores the register value in the ``val`` field and the size
70*54f38fcaSMauro Carvalho Chehab(in bytes) of the value in ``size``.
71*54f38fcaSMauro Carvalho Chehab
72*54f38fcaSMauro Carvalho ChehabWhen ``match.type`` is ``V4L2_CHIP_MATCH_BRIDGE``, ``match.addr``
73*54f38fcaSMauro Carvalho Chehabselects the nth non-sub-device chip on the TV card. The number zero
74*54f38fcaSMauro Carvalho Chehabalways selects the host chip, e. g. the chip connected to the PCI or USB
75*54f38fcaSMauro Carvalho Chehabbus. You can find out which chips are present with the
76*54f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_DBG_G_CHIP_INFO` ioctl.
77*54f38fcaSMauro Carvalho Chehab
78*54f38fcaSMauro Carvalho ChehabWhen ``match.type`` is ``V4L2_CHIP_MATCH_SUBDEV``, ``match.addr``
79*54f38fcaSMauro Carvalho Chehabselects the nth sub-device.
80*54f38fcaSMauro Carvalho Chehab
81*54f38fcaSMauro Carvalho ChehabThese ioctls are optional, not all drivers may support them. However
82*54f38fcaSMauro Carvalho Chehabwhen a driver supports these ioctls it must also support
83*54f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_DBG_G_CHIP_INFO`. Conversely
84*54f38fcaSMauro Carvalho Chehabit may support ``VIDIOC_DBG_G_CHIP_INFO`` but not these ioctls.
85*54f38fcaSMauro Carvalho Chehab
86*54f38fcaSMauro Carvalho Chehab``VIDIOC_DBG_G_REGISTER`` and ``VIDIOC_DBG_S_REGISTER`` were introduced
87*54f38fcaSMauro Carvalho Chehabin Linux 2.6.21, but their API was changed to the one described here in
88*54f38fcaSMauro Carvalho Chehabkernel 2.6.29.
89*54f38fcaSMauro Carvalho Chehab
90*54f38fcaSMauro Carvalho ChehabWe recommended the v4l2-dbg utility over calling these ioctls directly.
91*54f38fcaSMauro Carvalho ChehabIt is available from the LinuxTV v4l-dvb repository; see
92*54f38fcaSMauro Carvalho Chehab`https://linuxtv.org/repo/ <https://linuxtv.org/repo/>`__ for access
93*54f38fcaSMauro Carvalho Chehabinstructions.
94*54f38fcaSMauro Carvalho Chehab
95*54f38fcaSMauro Carvalho Chehab
96*54f38fcaSMauro Carvalho Chehab.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
97*54f38fcaSMauro Carvalho Chehab
98*54f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_match
99*54f38fcaSMauro Carvalho Chehab
100*54f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_match
101*54f38fcaSMauro Carvalho Chehab    :header-rows:  0
102*54f38fcaSMauro Carvalho Chehab    :stub-columns: 0
103*54f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
104*54f38fcaSMauro Carvalho Chehab
105*54f38fcaSMauro Carvalho Chehab    * - __u32
106*54f38fcaSMauro Carvalho Chehab      - ``type``
107*54f38fcaSMauro Carvalho Chehab      - See :ref:`chip-match-types` for a list of possible types.
108*54f38fcaSMauro Carvalho Chehab    * - union {
109*54f38fcaSMauro Carvalho Chehab      - (anonymous)
110*54f38fcaSMauro Carvalho Chehab    * - __u32
111*54f38fcaSMauro Carvalho Chehab      - ``addr``
112*54f38fcaSMauro Carvalho Chehab      - Match a chip by this number, interpreted according to the ``type``
113*54f38fcaSMauro Carvalho Chehab	field.
114*54f38fcaSMauro Carvalho Chehab    * - char
115*54f38fcaSMauro Carvalho Chehab      - ``name[32]``
116*54f38fcaSMauro Carvalho Chehab      - Match a chip by this name, interpreted according to the ``type``
117*54f38fcaSMauro Carvalho Chehab	field. Currently unused.
118*54f38fcaSMauro Carvalho Chehab    * - }
119*54f38fcaSMauro Carvalho Chehab      -
120*54f38fcaSMauro Carvalho Chehab
121*54f38fcaSMauro Carvalho Chehab
122*54f38fcaSMauro Carvalho Chehab
123*54f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_dbg_register
124*54f38fcaSMauro Carvalho Chehab
125*54f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_dbg_register
126*54f38fcaSMauro Carvalho Chehab    :header-rows:  0
127*54f38fcaSMauro Carvalho Chehab    :stub-columns: 0
128*54f38fcaSMauro Carvalho Chehab
129*54f38fcaSMauro Carvalho Chehab    * - struct v4l2_dbg_match
130*54f38fcaSMauro Carvalho Chehab      - ``match``
131*54f38fcaSMauro Carvalho Chehab      - How to match the chip, see :c:type:`v4l2_dbg_match`.
132*54f38fcaSMauro Carvalho Chehab    * - __u32
133*54f38fcaSMauro Carvalho Chehab      - ``size``
134*54f38fcaSMauro Carvalho Chehab      - The register size in bytes.
135*54f38fcaSMauro Carvalho Chehab    * - __u64
136*54f38fcaSMauro Carvalho Chehab      - ``reg``
137*54f38fcaSMauro Carvalho Chehab      - A register number.
138*54f38fcaSMauro Carvalho Chehab    * - __u64
139*54f38fcaSMauro Carvalho Chehab      - ``val``
140*54f38fcaSMauro Carvalho Chehab      - The value read from, or to be written into the register.
141*54f38fcaSMauro Carvalho Chehab
142*54f38fcaSMauro Carvalho Chehab
143*54f38fcaSMauro Carvalho Chehab
144*54f38fcaSMauro Carvalho Chehab.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
145*54f38fcaSMauro Carvalho Chehab
146*54f38fcaSMauro Carvalho Chehab.. _chip-match-types:
147*54f38fcaSMauro Carvalho Chehab
148*54f38fcaSMauro Carvalho Chehab.. flat-table:: Chip Match Types
149*54f38fcaSMauro Carvalho Chehab    :header-rows:  0
150*54f38fcaSMauro Carvalho Chehab    :stub-columns: 0
151*54f38fcaSMauro Carvalho Chehab    :widths:       3 1 4
152*54f38fcaSMauro Carvalho Chehab
153*54f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_BRIDGE``
154*54f38fcaSMauro Carvalho Chehab      - 0
155*54f38fcaSMauro Carvalho Chehab      - Match the nth chip on the card, zero for the bridge chip. Does not
156*54f38fcaSMauro Carvalho Chehab	match sub-devices.
157*54f38fcaSMauro Carvalho Chehab    * - ``V4L2_CHIP_MATCH_SUBDEV``
158*54f38fcaSMauro Carvalho Chehab      - 4
159*54f38fcaSMauro Carvalho Chehab      - Match the nth sub-device.
160*54f38fcaSMauro Carvalho Chehab
161*54f38fcaSMauro Carvalho Chehab
162*54f38fcaSMauro Carvalho ChehabReturn Value
163*54f38fcaSMauro Carvalho Chehab============
164*54f38fcaSMauro Carvalho Chehab
165*54f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
166*54f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
167*54f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
168*54f38fcaSMauro Carvalho Chehab
169*54f38fcaSMauro Carvalho ChehabEPERM
170*54f38fcaSMauro Carvalho Chehab    Insufficient permissions. Root privileges are required to execute
171*54f38fcaSMauro Carvalho Chehab    these ioctls.
172