![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Media Bus API header 0004 * 0005 * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de> 0006 */ 0007 0008 #ifndef V4L2_MEDIABUS_H 0009 #define V4L2_MEDIABUS_H 0010 0011 #include <linux/v4l2-mediabus.h> 0012 #include <linux/bitops.h> 0013 0014 /* 0015 * How to use the V4L2_MBUS_* flags: 0016 * Flags are defined for each of the possible states and values of a media 0017 * bus configuration parameter. One and only one bit of each group of flags 0018 * shall be set by the users of the v4l2_subdev_pad_ops.get_mbus_config 0019 * operation to ensure that no conflicting settings are specified when 0020 * reporting the media bus configuration. For example, it is invalid to set or 0021 * clear both the V4L2_MBUS_HSYNC_ACTIVE_HIGH and the 0022 * V4L2_MBUS_HSYNC_ACTIVE_LOW flag at the same time. Instead either flag 0023 * V4L2_MBUS_HSYNC_ACTIVE_HIGH or flag V4L2_MBUS_HSYNC_ACTIVE_LOW shall be set. 0024 * 0025 * TODO: replace the existing V4L2_MBUS_* flags with structures of fields 0026 * to avoid conflicting settings. 0027 * 0028 * In example: 0029 * #define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2) 0030 * #define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3) 0031 * will be replaced by a field whose value reports the intended active state of 0032 * the signal: 0033 * unsigned int v4l2_mbus_hsync_active : 1; 0034 */ 0035 0036 /* Parallel flags */ 0037 /* 0038 * The client runs in master or in slave mode. By "Master mode" an operation 0039 * mode is meant, when the client (e.g., a camera sensor) is producing 0040 * horizontal and vertical synchronisation. In "Slave mode" the host is 0041 * providing these signals to the slave. 0042 */ 0043 #define V4L2_MBUS_MASTER BIT(0) 0044 #define V4L2_MBUS_SLAVE BIT(1) 0045 /* 0046 * Signal polarity flags 0047 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused 0048 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying 0049 * configuration of hardware that uses [HV]REF signals 0050 */ 0051 #define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2) 0052 #define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3) 0053 #define V4L2_MBUS_VSYNC_ACTIVE_HIGH BIT(4) 0054 #define V4L2_MBUS_VSYNC_ACTIVE_LOW BIT(5) 0055 #define V4L2_MBUS_PCLK_SAMPLE_RISING BIT(6) 0056 #define V4L2_MBUS_PCLK_SAMPLE_FALLING BIT(7) 0057 #define V4L2_MBUS_DATA_ACTIVE_HIGH BIT(8) 0058 #define V4L2_MBUS_DATA_ACTIVE_LOW BIT(9) 0059 /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ 0060 #define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10) 0061 /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ 0062 #define V4L2_MBUS_FIELD_EVEN_LOW BIT(11) 0063 /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ 0064 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12) 0065 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13) 0066 #define V4L2_MBUS_DATA_ENABLE_HIGH BIT(14) 0067 #define V4L2_MBUS_DATA_ENABLE_LOW BIT(15) 0068 0069 /* Serial flags */ 0070 /* Clock non-continuous mode support. */ 0071 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(0) 0072 0073 #define V4L2_MBUS_CSI2_MAX_DATA_LANES 8 0074 0075 /** 0076 * struct v4l2_mbus_config_mipi_csi2 - MIPI CSI-2 data bus configuration 0077 * @flags: media bus (V4L2_MBUS_*) flags 0078 * @data_lanes: an array of physical data lane indexes 0079 * @clock_lane: physical lane index of the clock lane 0080 * @num_data_lanes: number of data lanes 0081 * @lane_polarities: polarity of the lanes. The order is the same of 0082 * the physical lanes. 0083 */ 0084 struct v4l2_mbus_config_mipi_csi2 { 0085 unsigned int flags; 0086 unsigned char data_lanes[V4L2_MBUS_CSI2_MAX_DATA_LANES]; 0087 unsigned char clock_lane; 0088 unsigned char num_data_lanes; 0089 bool lane_polarities[1 + V4L2_MBUS_CSI2_MAX_DATA_LANES]; 0090 }; 0091 0092 /** 0093 * struct v4l2_mbus_config_parallel - parallel data bus configuration 0094 * @flags: media bus (V4L2_MBUS_*) flags 0095 * @bus_width: bus width in bits 0096 * @data_shift: data shift in bits 0097 */ 0098 struct v4l2_mbus_config_parallel { 0099 unsigned int flags; 0100 unsigned char bus_width; 0101 unsigned char data_shift; 0102 }; 0103 0104 /** 0105 * struct v4l2_mbus_config_mipi_csi1 - CSI-1/CCP2 data bus configuration 0106 * @clock_inv: polarity of clock/strobe signal 0107 * false - not inverted, true - inverted 0108 * @strobe: false - data/clock, true - data/strobe 0109 * @lane_polarity: the polarities of the clock (index 0) and data lanes 0110 * index (1) 0111 * @data_lane: the number of the data lane 0112 * @clock_lane: the number of the clock lane 0113 */ 0114 struct v4l2_mbus_config_mipi_csi1 { 0115 unsigned char clock_inv:1; 0116 unsigned char strobe:1; 0117 bool lane_polarity[2]; 0118 unsigned char data_lane; 0119 unsigned char clock_lane; 0120 }; 0121 0122 /** 0123 * enum v4l2_mbus_type - media bus type 0124 * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration 0125 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync 0126 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can 0127 * also be used for BT.1120 0128 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface 0129 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) 0130 * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY 0131 * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY 0132 * @V4L2_MBUS_DPI: MIPI VIDEO DPI interface 0133 * @V4L2_MBUS_INVALID: invalid bus type (keep as last) 0134 */ 0135 enum v4l2_mbus_type { 0136 V4L2_MBUS_UNKNOWN, 0137 V4L2_MBUS_PARALLEL, 0138 V4L2_MBUS_BT656, 0139 V4L2_MBUS_CSI1, 0140 V4L2_MBUS_CCP2, 0141 V4L2_MBUS_CSI2_DPHY, 0142 V4L2_MBUS_CSI2_CPHY, 0143 V4L2_MBUS_DPI, 0144 V4L2_MBUS_INVALID, 0145 }; 0146 0147 /** 0148 * struct v4l2_mbus_config - media bus configuration 0149 * @type: interface type 0150 * @bus: bus configuration data structure 0151 * @bus.parallel: embedded &struct v4l2_mbus_config_parallel. 0152 * Used if the bus is parallel or BT.656. 0153 * @bus.mipi_csi1: embedded &struct v4l2_mbus_config_mipi_csi1. 0154 * Used if the bus is MIPI Alliance's Camera Serial 0155 * Interface version 1 (MIPI CSI1) or Standard 0156 * Mobile Imaging Architecture's Compact Camera Port 2 0157 * (SMIA CCP2). 0158 * @bus.mipi_csi2: embedded &struct v4l2_mbus_config_mipi_csi2. 0159 * Used if the bus is MIPI Alliance's Camera Serial 0160 * Interface version 2 (MIPI CSI2). 0161 */ 0162 struct v4l2_mbus_config { 0163 enum v4l2_mbus_type type; 0164 union { 0165 struct v4l2_mbus_config_parallel parallel; 0166 struct v4l2_mbus_config_mipi_csi1 mipi_csi1; 0167 struct v4l2_mbus_config_mipi_csi2 mipi_csi2; 0168 } bus; 0169 }; 0170 0171 /** 0172 * v4l2_fill_pix_format - Ancillary routine that fills a &struct 0173 * v4l2_pix_format fields from a &struct v4l2_mbus_framefmt. 0174 * 0175 * @pix_fmt: pointer to &struct v4l2_pix_format to be filled 0176 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model 0177 */ 0178 static inline void 0179 v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, 0180 const struct v4l2_mbus_framefmt *mbus_fmt) 0181 { 0182 pix_fmt->width = mbus_fmt->width; 0183 pix_fmt->height = mbus_fmt->height; 0184 pix_fmt->field = mbus_fmt->field; 0185 pix_fmt->colorspace = mbus_fmt->colorspace; 0186 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc; 0187 pix_fmt->quantization = mbus_fmt->quantization; 0188 pix_fmt->xfer_func = mbus_fmt->xfer_func; 0189 } 0190 0191 /** 0192 * v4l2_fill_mbus_format - Ancillary routine that fills a &struct 0193 * v4l2_mbus_framefmt from a &struct v4l2_pix_format and a 0194 * data format code. 0195 * 0196 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled 0197 * @pix_fmt: pointer to &struct v4l2_pix_format to be used as model 0198 * @code: data format code (from &enum v4l2_mbus_pixelcode) 0199 */ 0200 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, 0201 const struct v4l2_pix_format *pix_fmt, 0202 u32 code) 0203 { 0204 mbus_fmt->width = pix_fmt->width; 0205 mbus_fmt->height = pix_fmt->height; 0206 mbus_fmt->field = pix_fmt->field; 0207 mbus_fmt->colorspace = pix_fmt->colorspace; 0208 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc; 0209 mbus_fmt->quantization = pix_fmt->quantization; 0210 mbus_fmt->xfer_func = pix_fmt->xfer_func; 0211 mbus_fmt->code = code; 0212 } 0213 0214 /** 0215 * v4l2_fill_pix_format_mplane - Ancillary routine that fills a &struct 0216 * v4l2_pix_format_mplane fields from a media bus structure. 0217 * 0218 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled 0219 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model 0220 */ 0221 static inline void 0222 v4l2_fill_pix_format_mplane(struct v4l2_pix_format_mplane *pix_mp_fmt, 0223 const struct v4l2_mbus_framefmt *mbus_fmt) 0224 { 0225 pix_mp_fmt->width = mbus_fmt->width; 0226 pix_mp_fmt->height = mbus_fmt->height; 0227 pix_mp_fmt->field = mbus_fmt->field; 0228 pix_mp_fmt->colorspace = mbus_fmt->colorspace; 0229 pix_mp_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc; 0230 pix_mp_fmt->quantization = mbus_fmt->quantization; 0231 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func; 0232 } 0233 0234 /** 0235 * v4l2_fill_mbus_format_mplane - Ancillary routine that fills a &struct 0236 * v4l2_mbus_framefmt from a &struct v4l2_pix_format_mplane. 0237 * 0238 * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled 0239 * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model 0240 */ 0241 static inline void 0242 v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt, 0243 const struct v4l2_pix_format_mplane *pix_mp_fmt) 0244 { 0245 mbus_fmt->width = pix_mp_fmt->width; 0246 mbus_fmt->height = pix_mp_fmt->height; 0247 mbus_fmt->field = pix_mp_fmt->field; 0248 mbus_fmt->colorspace = pix_mp_fmt->colorspace; 0249 mbus_fmt->ycbcr_enc = pix_mp_fmt->ycbcr_enc; 0250 mbus_fmt->quantization = pix_mp_fmt->quantization; 0251 mbus_fmt->xfer_func = pix_mp_fmt->xfer_func; 0252 } 0253 0254 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |