1
2
3
4
5
6
7
8
9
10
11#ifndef V4L2_MEDIABUS_H
12#define V4L2_MEDIABUS_H
13
14#include <linux/v4l2-mediabus.h>
15#include <linux/bitops.h>
16
17
18
19
20
21
22
23
24#define V4L2_MBUS_MASTER BIT(0)
25#define V4L2_MBUS_SLAVE BIT(1)
26
27
28
29
30
31
32#define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2)
33#define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3)
34#define V4L2_MBUS_VSYNC_ACTIVE_HIGH BIT(4)
35#define V4L2_MBUS_VSYNC_ACTIVE_LOW BIT(5)
36#define V4L2_MBUS_PCLK_SAMPLE_RISING BIT(6)
37#define V4L2_MBUS_PCLK_SAMPLE_FALLING BIT(7)
38#define V4L2_MBUS_DATA_ACTIVE_HIGH BIT(8)
39#define V4L2_MBUS_DATA_ACTIVE_LOW BIT(9)
40
41#define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10)
42
43#define V4L2_MBUS_FIELD_EVEN_LOW BIT(11)
44
45#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12)
46#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13)
47#define V4L2_MBUS_DATA_ENABLE_HIGH BIT(14)
48#define V4L2_MBUS_DATA_ENABLE_LOW BIT(15)
49
50
51
52#define V4L2_MBUS_CSI2_1_LANE BIT(0)
53#define V4L2_MBUS_CSI2_2_LANE BIT(1)
54#define V4L2_MBUS_CSI2_3_LANE BIT(2)
55#define V4L2_MBUS_CSI2_4_LANE BIT(3)
56
57#define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4)
58#define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5)
59#define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6)
60#define V4L2_MBUS_CSI2_CHANNEL_3 BIT(7)
61
62#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8)
63#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9)
64
65#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | \
66 V4L2_MBUS_CSI2_2_LANE | \
67 V4L2_MBUS_CSI2_3_LANE | \
68 V4L2_MBUS_CSI2_4_LANE)
69#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | \
70 V4L2_MBUS_CSI2_CHANNEL_1 | \
71 V4L2_MBUS_CSI2_CHANNEL_2 | \
72 V4L2_MBUS_CSI2_CHANNEL_3)
73
74
75
76
77
78
79
80
81
82
83
84
85enum v4l2_mbus_type {
86 V4L2_MBUS_UNKNOWN,
87 V4L2_MBUS_PARALLEL,
88 V4L2_MBUS_BT656,
89 V4L2_MBUS_CSI1,
90 V4L2_MBUS_CCP2,
91 V4L2_MBUS_CSI2_DPHY,
92 V4L2_MBUS_CSI2_CPHY,
93};
94
95
96
97
98
99
100struct v4l2_mbus_config {
101 enum v4l2_mbus_type type;
102 unsigned int flags;
103};
104
105
106
107
108
109
110
111
112static inline void
113v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
114 const struct v4l2_mbus_framefmt *mbus_fmt)
115{
116 pix_fmt->width = mbus_fmt->width;
117 pix_fmt->height = mbus_fmt->height;
118 pix_fmt->field = mbus_fmt->field;
119 pix_fmt->colorspace = mbus_fmt->colorspace;
120 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
121 pix_fmt->quantization = mbus_fmt->quantization;
122 pix_fmt->xfer_func = mbus_fmt->xfer_func;
123}
124
125
126
127
128
129
130
131
132
133
134static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
135 const struct v4l2_pix_format *pix_fmt,
136 u32 code)
137{
138 mbus_fmt->width = pix_fmt->width;
139 mbus_fmt->height = pix_fmt->height;
140 mbus_fmt->field = pix_fmt->field;
141 mbus_fmt->colorspace = pix_fmt->colorspace;
142 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
143 mbus_fmt->quantization = pix_fmt->quantization;
144 mbus_fmt->xfer_func = pix_fmt->xfer_func;
145 mbus_fmt->code = code;
146}
147
148
149
150
151
152
153
154
155static inline void
156v4l2_fill_pix_format_mplane(struct v4l2_pix_format_mplane *pix_mp_fmt,
157 const struct v4l2_mbus_framefmt *mbus_fmt)
158{
159 pix_mp_fmt->width = mbus_fmt->width;
160 pix_mp_fmt->height = mbus_fmt->height;
161 pix_mp_fmt->field = mbus_fmt->field;
162 pix_mp_fmt->colorspace = mbus_fmt->colorspace;
163 pix_mp_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
164 pix_mp_fmt->quantization = mbus_fmt->quantization;
165 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func;
166}
167
168
169
170
171
172
173
174
175static inline void
176v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt,
177 const struct v4l2_pix_format_mplane *pix_mp_fmt)
178{
179 mbus_fmt->width = pix_mp_fmt->width;
180 mbus_fmt->height = pix_mp_fmt->height;
181 mbus_fmt->field = pix_mp_fmt->field;
182 mbus_fmt->colorspace = pix_mp_fmt->colorspace;
183 mbus_fmt->ycbcr_enc = pix_mp_fmt->ycbcr_enc;
184 mbus_fmt->quantization = pix_mp_fmt->quantization;
185 mbus_fmt->xfer_func = pix_mp_fmt->xfer_func;
186}
187
188#endif
189