.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Media Bus API header |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #ifndef V4L2_MEDIABUS_H |
---|
.. | .. |
---|
14 | 11 | #include <linux/v4l2-mediabus.h> |
---|
15 | 12 | #include <linux/bitops.h> |
---|
16 | 13 | |
---|
| 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 | + */ |
---|
17 | 38 | |
---|
18 | 39 | /* Parallel flags */ |
---|
19 | 40 | /* |
---|
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 |
---|
21 | 42 | * mode is meant, when the client (e.g., a camera sensor) is producing |
---|
22 | 43 | * horizontal and vertical synchronisation. In "Slave mode" the host is |
---|
23 | 44 | * providing these signals to the slave. |
---|
.. | .. |
---|
49 | 70 | #define V4L2_MBUS_DATA_ENABLE_LOW BIT(15) |
---|
50 | 71 | |
---|
51 | 72 | /* Serial flags */ |
---|
52 | | -/* How many lanes the client can use */ |
---|
| 73 | +/* CSI-2 D-PHY number of data lanes. */ |
---|
53 | 74 | #define V4L2_MBUS_CSI2_1_LANE BIT(0) |
---|
54 | 75 | #define V4L2_MBUS_CSI2_2_LANE BIT(1) |
---|
55 | 76 | #define V4L2_MBUS_CSI2_3_LANE BIT(2) |
---|
56 | 77 | #define V4L2_MBUS_CSI2_4_LANE BIT(3) |
---|
57 | | -/* On which channels it can send video data */ |
---|
| 78 | +/* CSI-2 Virtual Channel identifiers. */ |
---|
58 | 79 | #define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4) |
---|
59 | 80 | #define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5) |
---|
60 | 81 | #define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6) |
---|
61 | 82 | #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. */ |
---|
63 | 84 | #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8) |
---|
64 | 85 | #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9) |
---|
65 | 86 | |
---|
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) |
---|
70 | 95 | |
---|
71 | 96 | /** |
---|
72 | 97 | * enum v4l2_mbus_type - media bus type |
---|
| 98 | + * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration |
---|
73 | 99 | * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync |
---|
74 | 100 | * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can |
---|
75 | 101 | * also be used for BT.1120 |
---|
76 | 102 | * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface |
---|
77 | 103 | * @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) |
---|
79 | 107 | */ |
---|
80 | 108 | enum v4l2_mbus_type { |
---|
| 109 | + V4L2_MBUS_UNKNOWN, |
---|
81 | 110 | V4L2_MBUS_PARALLEL, |
---|
82 | 111 | V4L2_MBUS_BT656, |
---|
83 | 112 | V4L2_MBUS_CSI1, |
---|
84 | 113 | V4L2_MBUS_CCP2, |
---|
85 | | - V4L2_MBUS_CSI2, |
---|
| 114 | + V4L2_MBUS_CSI2_DPHY, |
---|
| 115 | + V4L2_MBUS_CSI2_CPHY, |
---|
| 116 | + V4L2_MBUS_INVALID, |
---|
86 | 117 | }; |
---|
87 | 118 | |
---|
88 | 119 | /** |
---|
.. | .. |
---|
102 | 133 | * @pix_fmt: pointer to &struct v4l2_pix_format to be filled |
---|
103 | 134 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model |
---|
104 | 135 | */ |
---|
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) |
---|
107 | 139 | { |
---|
108 | 140 | pix_fmt->width = mbus_fmt->width; |
---|
109 | 141 | pix_fmt->height = mbus_fmt->height; |
---|
.. | .. |
---|
124 | 156 | * @code: data format code (from &enum v4l2_mbus_pixelcode) |
---|
125 | 157 | */ |
---|
126 | 158 | 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, |
---|
128 | 160 | u32 code) |
---|
129 | 161 | { |
---|
130 | 162 | mbus_fmt->width = pix_fmt->width; |
---|
.. | .. |
---|
144 | 176 | * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled |
---|
145 | 177 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model |
---|
146 | 178 | */ |
---|
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) |
---|
150 | 182 | { |
---|
151 | 183 | pix_mp_fmt->width = mbus_fmt->width; |
---|
152 | 184 | pix_mp_fmt->height = mbus_fmt->height; |
---|
.. | .. |
---|
164 | 196 | * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled |
---|
165 | 197 | * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model |
---|
166 | 198 | */ |
---|
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) |
---|
170 | 202 | { |
---|
171 | 203 | mbus_fmt->width = pix_mp_fmt->width; |
---|
172 | 204 | mbus_fmt->height = pix_mp_fmt->height; |
---|