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