1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * Media Bus API header 2 * Media Bus API header 4 * 3 * 5 * Copyright (C) 2009, Guennadi Liakhovetski < 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. 6 */ 9 */ 7 10 8 #ifndef V4L2_MEDIABUS_H 11 #ifndef V4L2_MEDIABUS_H 9 #define V4L2_MEDIABUS_H 12 #define V4L2_MEDIABUS_H 10 13 11 #include <linux/v4l2-mediabus.h> 14 #include <linux/v4l2-mediabus.h> 12 #include <linux/bitops.h> << 13 << 14 /* << 15 * How to use the V4L2_MBUS_* flags: << 16 * Flags are defined for each of the possible << 17 * bus configuration parameter. One and only o << 18 * shall be set by the users of the v4l2_subde << 19 * operation to ensure that no conflicting set << 20 * reporting the media bus configuration. For << 21 * clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH << 22 * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same << 23 * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MB << 24 * << 25 * TODO: replace the existing V4L2_MBUS_* flag << 26 * to avoid conflicting settings. << 27 * << 28 * In example: << 29 * #define V4L2_MBUS_HSYNC_ACTIVE_HIGH << 30 * #define V4L2_MBUS_HSYNC_ACTIVE_LOW << 31 * will be replaced by a field whose value rep << 32 * the signal: << 33 * unsigned int v4l2_mbus_hsync_active : 1 << 34 */ << 35 15 36 /* Parallel flags */ 16 /* Parallel flags */ 37 /* 17 /* 38 * The client runs in master or in slave mode. !! 18 * Can the client run in master or in slave mode. By "Master mode" an operation 39 * mode is meant, when the client (e.g., a cam 19 * mode is meant, when the client (e.g., a camera sensor) is producing 40 * horizontal and vertical synchronisation. In 20 * horizontal and vertical synchronisation. In "Slave mode" the host is 41 * providing these signals to the slave. 21 * providing these signals to the slave. 42 */ 22 */ 43 #define V4L2_MBUS_MASTER !! 23 #define V4L2_MBUS_MASTER (1 << 0) 44 #define V4L2_MBUS_SLAVE !! 24 #define V4L2_MBUS_SLAVE (1 << 1) 45 /* 25 /* 46 * Signal polarity flags 26 * Signal polarity flags 47 * Note: in BT.656 mode HSYNC, FIELD, and VSYN 27 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused 48 * V4L2_MBUS_[HV]SYNC* flags should be also us 28 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying 49 * configuration of hardware that uses [HV]REF 29 * configuration of hardware that uses [HV]REF signals 50 */ 30 */ 51 #define V4L2_MBUS_HSYNC_ACTIVE_HIGH !! 31 #define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2) 52 #define V4L2_MBUS_HSYNC_ACTIVE_LOW !! 32 #define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3) 53 #define V4L2_MBUS_VSYNC_ACTIVE_HIGH !! 33 #define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4) 54 #define V4L2_MBUS_VSYNC_ACTIVE_LOW !! 34 #define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5) 55 #define V4L2_MBUS_PCLK_SAMPLE_RISING !! 35 #define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6) 56 #define V4L2_MBUS_PCLK_SAMPLE_FALLING !! 36 #define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7) 57 #define V4L2_MBUS_PCLK_SAMPLE_DUALEDGE !! 37 #define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8) 58 #define V4L2_MBUS_DATA_ACTIVE_HIGH !! 38 #define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9) 59 #define V4L2_MBUS_DATA_ACTIVE_LOW << 60 /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ 39 /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ 61 #define V4L2_MBUS_FIELD_EVEN_HIGH !! 40 #define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10) 62 /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ 41 /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ 63 #define V4L2_MBUS_FIELD_EVEN_LOW !! 42 #define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11) 64 /* Active state of Sync-on-green (SoG) signal, 43 /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ 65 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH !! 44 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH (1 << 12) 66 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW !! 45 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW (1 << 13) 67 #define V4L2_MBUS_DATA_ENABLE_HIGH << 68 #define V4L2_MBUS_DATA_ENABLE_LOW << 69 46 70 /* Serial flags */ 47 /* Serial flags */ 71 /* Clock non-continuous mode support. */ !! 48 /* How many lanes the client can use */ 72 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK !! 49 #define V4L2_MBUS_CSI2_1_LANE (1 << 0) 73 !! 50 #define V4L2_MBUS_CSI2_2_LANE (1 << 1) 74 #define V4L2_MBUS_CSI2_MAX_DATA_LANES !! 51 #define V4L2_MBUS_CSI2_3_LANE (1 << 2) 75 !! 52 #define V4L2_MBUS_CSI2_4_LANE (1 << 3) 76 /** !! 53 /* On which channels it can send video data */ 77 * struct v4l2_mbus_config_mipi_csi2 - MIPI CS !! 54 #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4) 78 * @flags: media bus (V4L2_MBUS_*) flags !! 55 #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5) 79 * @data_lanes: an array of physical data lane !! 56 #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6) 80 * @clock_lane: physical lane index of the clo !! 57 #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7) 81 * @num_data_lanes: number of data lanes !! 58 /* Does it support only continuous or also non-continuous clock mode */ 82 * @lane_polarities: polarity of the lanes. Th !! 59 #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8) 83 * the physical lanes. !! 60 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9) 84 */ !! 61 85 struct v4l2_mbus_config_mipi_csi2 { !! 62 #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ 86 unsigned int flags; !! 63 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE) 87 unsigned char data_lanes[V4L2_MBUS_CSI !! 64 #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \ 88 unsigned char clock_lane; !! 65 V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3) 89 unsigned char num_data_lanes; << 90 bool lane_polarities[1 + V4L2_MBUS_CSI << 91 }; << 92 << 93 /** << 94 * struct v4l2_mbus_config_parallel - parallel << 95 * @flags: media bus (V4L2_MBUS_*) flags << 96 * @bus_width: bus width in bits << 97 * @data_shift: data shift in bits << 98 */ << 99 struct v4l2_mbus_config_parallel { << 100 unsigned int flags; << 101 unsigned char bus_width; << 102 unsigned char data_shift; << 103 }; << 104 << 105 /** << 106 * struct v4l2_mbus_config_mipi_csi1 - CSI-1/C << 107 * @clock_inv: polarity of clock/strobe signal << 108 * false - not inverted, true - in << 109 * @strobe: false - data/clock, true - data/st << 110 * @lane_polarity: the polarities of the clock << 111 * index (1) << 112 * @data_lane: the number of the data lane << 113 * @clock_lane: the number of the clock lane << 114 */ << 115 struct v4l2_mbus_config_mipi_csi1 { << 116 unsigned char clock_inv:1; << 117 unsigned char strobe:1; << 118 bool lane_polarity[2]; << 119 unsigned char data_lane; << 120 unsigned char clock_lane; << 121 }; << 122 66 123 /** 67 /** 124 * enum v4l2_mbus_type - media bus type 68 * enum v4l2_mbus_type - media bus type 125 * @V4L2_MBUS_UNKNOWN: unknown bus type, no V << 126 * @V4L2_MBUS_PARALLEL: parallel interface wit 69 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync 127 * @V4L2_MBUS_BT656: parallel interface wit 70 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can 128 * also be used for BT.11 71 * also be used for BT.1120 129 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial inte !! 72 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface 130 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera P << 131 * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial int << 132 * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial int << 133 * @V4L2_MBUS_DPI: MIPI VIDEO DPI interfa << 134 * @V4L2_MBUS_INVALID: invalid bus type (keep << 135 */ 73 */ 136 enum v4l2_mbus_type { 74 enum v4l2_mbus_type { 137 V4L2_MBUS_UNKNOWN, << 138 V4L2_MBUS_PARALLEL, 75 V4L2_MBUS_PARALLEL, 139 V4L2_MBUS_BT656, 76 V4L2_MBUS_BT656, 140 V4L2_MBUS_CSI1, !! 77 V4L2_MBUS_CSI2, 141 V4L2_MBUS_CCP2, << 142 V4L2_MBUS_CSI2_DPHY, << 143 V4L2_MBUS_CSI2_CPHY, << 144 V4L2_MBUS_DPI, << 145 V4L2_MBUS_INVALID, << 146 }; 78 }; 147 79 148 /** 80 /** 149 * struct v4l2_mbus_config - media bus configu 81 * struct v4l2_mbus_config - media bus configuration 150 * @type: interface type !! 82 * @type: in: interface type 151 * @bus: bus configuration data structure !! 83 * @flags: in / out: configuration flags, depending on @type 152 * @bus.parallel: embedded &struct v4l2_mbus_c << 153 * Used if the bus is parallel << 154 * @bus.mipi_csi1: embedded &struct v4l2_mbus_ << 155 * Used if the bus is MIPI All << 156 * Interface version 1 (MIPI C << 157 * Mobile Imaging Architecture << 158 * (SMIA CCP2). << 159 * @bus.mipi_csi2: embedded &struct v4l2_mbus_ << 160 * Used if the bus is MIPI All << 161 * Interface version 2 (MIPI C << 162 */ 84 */ 163 struct v4l2_mbus_config { 85 struct v4l2_mbus_config { 164 enum v4l2_mbus_type type; 86 enum v4l2_mbus_type type; 165 union { !! 87 unsigned int flags; 166 struct v4l2_mbus_config_parall << 167 struct v4l2_mbus_config_mipi_c << 168 struct v4l2_mbus_config_mipi_c << 169 } bus; << 170 }; 88 }; 171 89 172 /** !! 90 static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, 173 * v4l2_fill_pix_format - Ancillary routine th !! 91 const struct v4l2_mbus_framefmt *mbus_fmt) 174 * v4l2_pix_format fields from a &struct << 175 * << 176 * @pix_fmt: pointer to &struct v4l2_pix_fo << 177 * @mbus_fmt: pointer to &struct v4l2_mbus_f << 178 */ << 179 static inline void << 180 v4l2_fill_pix_format(struct v4l2_pix_format *p << 181 const struct v4l2_mbus_fr << 182 { 92 { 183 pix_fmt->width = mbus_fmt->width; 93 pix_fmt->width = mbus_fmt->width; 184 pix_fmt->height = mbus_fmt->height; 94 pix_fmt->height = mbus_fmt->height; 185 pix_fmt->field = mbus_fmt->field; 95 pix_fmt->field = mbus_fmt->field; 186 pix_fmt->colorspace = mbus_fmt->colors 96 pix_fmt->colorspace = mbus_fmt->colorspace; 187 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_e 97 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc; 188 pix_fmt->quantization = mbus_fmt->quan 98 pix_fmt->quantization = mbus_fmt->quantization; 189 pix_fmt->xfer_func = mbus_fmt->xfer_fu 99 pix_fmt->xfer_func = mbus_fmt->xfer_func; 190 } 100 } 191 101 192 /** << 193 * v4l2_fill_mbus_format - Ancillary routine t << 194 * v4l2_mbus_framefmt from a &struct v4l2 << 195 * data format code. << 196 * << 197 * @mbus_fmt: pointer to &struct v4l2_mbus_f << 198 * @pix_fmt: pointer to &struct v4l2_pix_fo << 199 * @code: data format code (from &enum v << 200 */ << 201 static inline void v4l2_fill_mbus_format(struc 102 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, 202 const !! 103 const struct v4l2_pix_format *pix_fmt, 203 u32 code) 104 u32 code) 204 { 105 { 205 mbus_fmt->width = pix_fmt->width; 106 mbus_fmt->width = pix_fmt->width; 206 mbus_fmt->height = pix_fmt->height; 107 mbus_fmt->height = pix_fmt->height; 207 mbus_fmt->field = pix_fmt->field; 108 mbus_fmt->field = pix_fmt->field; 208 mbus_fmt->colorspace = pix_fmt->colors 109 mbus_fmt->colorspace = pix_fmt->colorspace; 209 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_e 110 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc; 210 mbus_fmt->quantization = pix_fmt->quan 111 mbus_fmt->quantization = pix_fmt->quantization; 211 mbus_fmt->xfer_func = pix_fmt->xfer_fu 112 mbus_fmt->xfer_func = pix_fmt->xfer_func; 212 mbus_fmt->code = code; 113 mbus_fmt->code = code; 213 } << 214 << 215 /** << 216 * v4l2_fill_pix_format_mplane - Ancillary rou << 217 * v4l2_pix_format_mplane fields from a m << 218 * << 219 * @pix_mp_fmt: pointer to &struct v4l2_pix_fo << 220 * @mbus_fmt: pointer to &struct v4l2_mbus_f << 221 */ << 222 static inline void << 223 v4l2_fill_pix_format_mplane(struct v4l2_pix_fo << 224 const struct v4l2_ << 225 { << 226 pix_mp_fmt->width = mbus_fmt->width; << 227 pix_mp_fmt->height = mbus_fmt->height; << 228 pix_mp_fmt->field = mbus_fmt->field; << 229 pix_mp_fmt->colorspace = mbus_fmt->col << 230 pix_mp_fmt->ycbcr_enc = mbus_fmt->ycbc << 231 pix_mp_fmt->quantization = mbus_fmt->q << 232 pix_mp_fmt->xfer_func = mbus_fmt->xfer << 233 } << 234 << 235 /** << 236 * v4l2_fill_mbus_format_mplane - Ancillary ro << 237 * v4l2_mbus_framefmt from a &struct v4l2 << 238 * << 239 * @mbus_fmt: pointer to &struct v4l2_mbus_f << 240 * @pix_mp_fmt: pointer to &struct v4l2_pix_fo << 241 */ << 242 static inline void << 243 v4l2_fill_mbus_format_mplane(struct v4l2_mbus_ << 244 const struct v4l2 << 245 { << 246 mbus_fmt->width = pix_mp_fmt->width; << 247 mbus_fmt->height = pix_mp_fmt->height; << 248 mbus_fmt->field = pix_mp_fmt->field; << 249 mbus_fmt->colorspace = pix_mp_fmt->col << 250 mbus_fmt->ycbcr_enc = pix_mp_fmt->ycbc << 251 mbus_fmt->quantization = pix_mp_fmt->q << 252 mbus_fmt->xfer_func = pix_mp_fmt->xfer << 253 } 114 } 254 115 255 #endif 116 #endif 256 117
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.