Commit | Line | Data |
---|---|---|
9a74251d GL |
1 | /* |
2 | * Media Bus API header | |
3 | * | |
4 | * 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. | |
9 | */ | |
10 | ||
11 | #ifndef V4L2_MEDIABUS_H | |
12 | #define V4L2_MEDIABUS_H | |
13 | ||
2ef2d5a3 | 14 | #include <linux/v4l2-mediabus.h> |
2120961f MCC |
15 | #include <linux/bitops.h> |
16 | ||
91c79530 GL |
17 | /* Parallel flags */ |
18 | /* | |
19 | * Can the client run in master or in slave mode. By "Master mode" an operation | |
20 | * mode is meant, when the client (e.g., a camera sensor) is producing | |
21 | * horizontal and vertical synchronisation. In "Slave mode" the host is | |
22 | * providing these signals to the slave. | |
23 | */ | |
2120961f MCC |
24 | #define V4L2_MBUS_MASTER BIT(0) |
25 | #define V4L2_MBUS_SLAVE BIT(1) | |
3c6938f8 SN |
26 | /* |
27 | * Signal polarity flags | |
28 | * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused | |
29 | * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying | |
30 | * configuration of hardware that uses [HV]REF signals | |
31 | */ | |
2120961f MCC |
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) | |
3c6938f8 | 40 | /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ |
2120961f | 41 | #define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10) |
3c6938f8 | 42 | /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ |
2120961f | 43 | #define V4L2_MBUS_FIELD_EVEN_LOW BIT(11) |
d1d70aa6 | 44 | /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ |
2120961f MCC |
45 | #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12) |
46 | #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13) | |
9b04fcc1 JM |
47 | #define V4L2_MBUS_DATA_ENABLE_HIGH BIT(14) |
48 | #define V4L2_MBUS_DATA_ENABLE_LOW BIT(15) | |
91c79530 GL |
49 | |
50 | /* Serial flags */ | |
51 | /* How many lanes the client can use */ | |
2120961f MCC |
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) | |
91c79530 | 56 | /* On which channels it can send video data */ |
2120961f MCC |
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) | |
91c79530 | 61 | /* Does it support only continuous or also non-continuous clock mode */ |
2120961f MCC |
62 | #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8) |
63 | #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9) | |
91c79530 | 64 | |
6087b215 MCC |
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) | |
91c79530 GL |
73 | |
74 | /** | |
98d00bd7 | 75 | * enum v4l2_mbus_type - media bus type |
2835b5b1 | 76 | * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration |
91c79530 GL |
77 | * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync |
78 | * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can | |
79 | * also be used for BT.1120 | |
97bbdf02 SA |
80 | * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface |
81 | * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) | |
2d95e7ed SA |
82 | * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY |
83 | * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY | |
91c79530 GL |
84 | */ |
85 | enum v4l2_mbus_type { | |
2835b5b1 | 86 | V4L2_MBUS_UNKNOWN, |
91c79530 GL |
87 | V4L2_MBUS_PARALLEL, |
88 | V4L2_MBUS_BT656, | |
97bbdf02 SA |
89 | V4L2_MBUS_CSI1, |
90 | V4L2_MBUS_CCP2, | |
2d95e7ed SA |
91 | V4L2_MBUS_CSI2_DPHY, |
92 | V4L2_MBUS_CSI2_CPHY, | |
91c79530 GL |
93 | }; |
94 | ||
95 | /** | |
98d00bd7 | 96 | * struct v4l2_mbus_config - media bus configuration |
91c79530 GL |
97 | * @type: in: interface type |
98 | * @flags: in / out: configuration flags, depending on @type | |
99 | */ | |
100 | struct v4l2_mbus_config { | |
101 | enum v4l2_mbus_type type; | |
102 | unsigned int flags; | |
103 | }; | |
104 | ||
4839c58f MCC |
105 | /** |
106 | * v4l2_fill_pix_format - Ancillary routine that fills a &struct | |
107 | * v4l2_pix_format fields from a &struct v4l2_mbus_framefmt. | |
108 | * | |
109 | * @pix_fmt: pointer to &struct v4l2_pix_format to be filled | |
110 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model | |
111 | */ | |
6087b215 MCC |
112 | static inline void |
113 | v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, | |
114 | const struct v4l2_mbus_framefmt *mbus_fmt) | |
3a21ceed HV |
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; | |
11ff030c HV |
120 | pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc; |
121 | pix_fmt->quantization = mbus_fmt->quantization; | |
74fdcb2e | 122 | pix_fmt->xfer_func = mbus_fmt->xfer_func; |
3a21ceed HV |
123 | } |
124 | ||
4839c58f MCC |
125 | /** |
126 | * v4l2_fill_pix_format - Ancillary routine that fills a &struct | |
127 | * v4l2_mbus_framefmt from a &struct v4l2_pix_format and a | |
128 | * data format code. | |
129 | * | |
130 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled | |
131 | * @pix_fmt: pointer to &struct v4l2_pix_format to be used as model | |
132 | * @code: data format code (from &enum v4l2_mbus_pixelcode) | |
133 | */ | |
3a21ceed | 134 | static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, |
6087b215 | 135 | const struct v4l2_pix_format *pix_fmt, |
32b32ce8 | 136 | u32 code) |
3a21ceed HV |
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; | |
11ff030c HV |
142 | mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc; |
143 | mbus_fmt->quantization = pix_fmt->quantization; | |
74fdcb2e | 144 | mbus_fmt->xfer_func = pix_fmt->xfer_func; |
3a21ceed HV |
145 | mbus_fmt->code = code; |
146 | } | |
147 | ||
4839c58f MCC |
148 | /** |
149 | * v4l2_fill_pix_format - Ancillary routine that fills a &struct | |
150 | * v4l2_pix_format_mplane fields from a media bus structure. | |
151 | * | |
152 | * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled | |
153 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model | |
154 | */ | |
6087b215 MCC |
155 | static inline void |
156 | v4l2_fill_pix_format_mplane(struct v4l2_pix_format_mplane *pix_mp_fmt, | |
157 | const struct v4l2_mbus_framefmt *mbus_fmt) | |
f1923010 TT |
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 | ||
4839c58f MCC |
168 | /** |
169 | * v4l2_fill_pix_format - Ancillary routine that fills a &struct | |
170 | * v4l2_mbus_framefmt from a &struct v4l2_pix_format_mplane. | |
171 | * | |
172 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled | |
173 | * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model | |
174 | */ | |
6087b215 MCC |
175 | static inline void |
176 | v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt, | |
177 | const struct v4l2_pix_format_mplane *pix_mp_fmt) | |
f1923010 TT |
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 | ||
9a74251d | 188 | #endif |