hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/include/media/v4l2-mediabus.h
....@@ -1,11 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Media Bus API header
34 *
45 * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #ifndef V4L2_MEDIABUS_H
....@@ -14,10 +11,34 @@
1411 #include <linux/v4l2-mediabus.h>
1512 #include <linux/bitops.h>
1613
14
+/*
15
+ * How to use the V4L2_MBUS_* flags:
16
+ * Flags are defined for each of the possible states and values of a media
17
+ * bus configuration parameter. One and only one bit of each group of flags
18
+ * shall be set by the users of the v4l2_subdev_pad_ops.get_mbus_config and
19
+ * v4l2_subdev_pad_ops.set_mbus_config operations to ensure that no
20
+ * conflicting settings are specified when reporting and setting the media bus
21
+ * configuration with the two operations respectively. For example, it is
22
+ * invalid to set or clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the
23
+ * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same time. Instead either flag
24
+ * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be
25
+ * set. The same is true for the V4L2_MBUS_CSI2_1/2/3/4_LANE flags group: only
26
+ * one of these four bits shall be set.
27
+ *
28
+ * TODO: replace the existing V4L2_MBUS_* flags with structures of fields
29
+ * to avoid conflicting settings.
30
+ *
31
+ * In example:
32
+ * #define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2)
33
+ * #define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3)
34
+ * will be replaced by a field whose value reports the intended active state of
35
+ * the signal:
36
+ * unsigned int v4l2_mbus_hsync_active : 1;
37
+ */
1738
1839 /* Parallel flags */
1940 /*
20
- * Can the client run in master or in slave mode. By "Master mode" an operation
41
+ * The client runs in master or in slave mode. By "Master mode" an operation
2142 * mode is meant, when the client (e.g., a camera sensor) is producing
2243 * horizontal and vertical synchronisation. In "Slave mode" the host is
2344 * providing these signals to the slave.
....@@ -49,40 +70,50 @@
4970 #define V4L2_MBUS_DATA_ENABLE_LOW BIT(15)
5071
5172 /* Serial flags */
52
-/* How many lanes the client can use */
73
+/* CSI-2 D-PHY number of data lanes. */
5374 #define V4L2_MBUS_CSI2_1_LANE BIT(0)
5475 #define V4L2_MBUS_CSI2_2_LANE BIT(1)
5576 #define V4L2_MBUS_CSI2_3_LANE BIT(2)
5677 #define V4L2_MBUS_CSI2_4_LANE BIT(3)
57
-/* On which channels it can send video data */
78
+/* CSI-2 Virtual Channel identifiers. */
5879 #define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4)
5980 #define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5)
6081 #define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6)
6182 #define V4L2_MBUS_CSI2_CHANNEL_3 BIT(7)
62
-/* Does it support only continuous or also non-continuous clock mode */
83
+/* Clock non-continuous mode support. */
6384 #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8)
6485 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9)
6586
66
-#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
67
- V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
68
-#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
69
- V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
87
+#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | \
88
+ V4L2_MBUS_CSI2_2_LANE | \
89
+ V4L2_MBUS_CSI2_3_LANE | \
90
+ V4L2_MBUS_CSI2_4_LANE)
91
+#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | \
92
+ V4L2_MBUS_CSI2_CHANNEL_1 | \
93
+ V4L2_MBUS_CSI2_CHANNEL_2 | \
94
+ V4L2_MBUS_CSI2_CHANNEL_3)
7095
7196 /**
7297 * enum v4l2_mbus_type - media bus type
98
+ * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration
7399 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
74100 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
75101 * also be used for BT.1120
76102 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface
77103 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
78
- * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
104
+ * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY
105
+ * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY
106
+ * @V4L2_MBUS_INVALID: invalid bus type (keep as last)
79107 */
80108 enum v4l2_mbus_type {
109
+ V4L2_MBUS_UNKNOWN,
81110 V4L2_MBUS_PARALLEL,
82111 V4L2_MBUS_BT656,
83112 V4L2_MBUS_CSI1,
84113 V4L2_MBUS_CCP2,
85
- V4L2_MBUS_CSI2,
114
+ V4L2_MBUS_CSI2_DPHY,
115
+ V4L2_MBUS_CSI2_CPHY,
116
+ V4L2_MBUS_INVALID,
86117 };
87118
88119 /**
....@@ -102,8 +133,9 @@
102133 * @pix_fmt: pointer to &struct v4l2_pix_format to be filled
103134 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model
104135 */
105
-static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
106
- const struct v4l2_mbus_framefmt *mbus_fmt)
136
+static inline void
137
+v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
138
+ const struct v4l2_mbus_framefmt *mbus_fmt)
107139 {
108140 pix_fmt->width = mbus_fmt->width;
109141 pix_fmt->height = mbus_fmt->height;
....@@ -124,7 +156,7 @@
124156 * @code: data format code (from &enum v4l2_mbus_pixelcode)
125157 */
126158 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
127
- const struct v4l2_pix_format *pix_fmt,
159
+ const struct v4l2_pix_format *pix_fmt,
128160 u32 code)
129161 {
130162 mbus_fmt->width = pix_fmt->width;
....@@ -144,9 +176,9 @@
144176 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled
145177 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model
146178 */
147
-static inline void v4l2_fill_pix_format_mplane(
148
- struct v4l2_pix_format_mplane *pix_mp_fmt,
149
- const struct v4l2_mbus_framefmt *mbus_fmt)
179
+static inline void
180
+v4l2_fill_pix_format_mplane(struct v4l2_pix_format_mplane *pix_mp_fmt,
181
+ const struct v4l2_mbus_framefmt *mbus_fmt)
150182 {
151183 pix_mp_fmt->width = mbus_fmt->width;
152184 pix_mp_fmt->height = mbus_fmt->height;
....@@ -164,9 +196,9 @@
164196 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled
165197 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model
166198 */
167
-static inline void v4l2_fill_mbus_format_mplane(
168
- struct v4l2_mbus_framefmt *mbus_fmt,
169
- const struct v4l2_pix_format_mplane *pix_mp_fmt)
199
+static inline void
200
+v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt,
201
+ const struct v4l2_pix_format_mplane *pix_mp_fmt)
170202 {
171203 mbus_fmt->width = pix_mp_fmt->width;
172204 mbus_fmt->height = pix_mp_fmt->height;