]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/media/v4l2-mediabus.h
regulator: Fix return value of _set_load() stub
[mirror_ubuntu-bionic-kernel.git] / include / media / v4l2-mediabus.h
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
14 #include <linux/v4l2-mediabus.h>
15
16 /* Parallel flags */
17 /*
18 * Can the client run in master or in slave mode. By "Master mode" an operation
19 * mode is meant, when the client (e.g., a camera sensor) is producing
20 * horizontal and vertical synchronisation. In "Slave mode" the host is
21 * providing these signals to the slave.
22 */
23 #define V4L2_MBUS_MASTER (1 << 0)
24 #define V4L2_MBUS_SLAVE (1 << 1)
25 /*
26 * Signal polarity flags
27 * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused
28 * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying
29 * configuration of hardware that uses [HV]REF signals
30 */
31 #define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2)
32 #define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3)
33 #define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4)
34 #define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5)
35 #define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6)
36 #define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7)
37 #define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8)
38 #define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9)
39 /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */
40 #define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10)
41 /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */
42 #define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11)
43 /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */
44 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH (1 << 12)
45 #define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW (1 << 13)
46
47 /* Serial flags */
48 /* How many lanes the client can use */
49 #define V4L2_MBUS_CSI2_1_LANE (1 << 0)
50 #define V4L2_MBUS_CSI2_2_LANE (1 << 1)
51 #define V4L2_MBUS_CSI2_3_LANE (1 << 2)
52 #define V4L2_MBUS_CSI2_4_LANE (1 << 3)
53 /* On which channels it can send video data */
54 #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4)
55 #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5)
56 #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6)
57 #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7)
58 /* Does it support only continuous or also non-continuous clock mode */
59 #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8)
60 #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9)
61
62 #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \
63 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
64 #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
65 V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
66
67 /**
68 * enum v4l2_mbus_type - media bus type
69 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
70 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
71 * also be used for BT.1120
72 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface
73 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
74 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
75 */
76 enum v4l2_mbus_type {
77 V4L2_MBUS_PARALLEL,
78 V4L2_MBUS_BT656,
79 V4L2_MBUS_CSI1,
80 V4L2_MBUS_CCP2,
81 V4L2_MBUS_CSI2,
82 };
83
84 /**
85 * struct v4l2_mbus_config - media bus configuration
86 * @type: in: interface type
87 * @flags: in / out: configuration flags, depending on @type
88 */
89 struct v4l2_mbus_config {
90 enum v4l2_mbus_type type;
91 unsigned int flags;
92 };
93
94 static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
95 const struct v4l2_mbus_framefmt *mbus_fmt)
96 {
97 pix_fmt->width = mbus_fmt->width;
98 pix_fmt->height = mbus_fmt->height;
99 pix_fmt->field = mbus_fmt->field;
100 pix_fmt->colorspace = mbus_fmt->colorspace;
101 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
102 pix_fmt->quantization = mbus_fmt->quantization;
103 pix_fmt->xfer_func = mbus_fmt->xfer_func;
104 }
105
106 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
107 const struct v4l2_pix_format *pix_fmt,
108 u32 code)
109 {
110 mbus_fmt->width = pix_fmt->width;
111 mbus_fmt->height = pix_fmt->height;
112 mbus_fmt->field = pix_fmt->field;
113 mbus_fmt->colorspace = pix_fmt->colorspace;
114 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
115 mbus_fmt->quantization = pix_fmt->quantization;
116 mbus_fmt->xfer_func = pix_fmt->xfer_func;
117 mbus_fmt->code = code;
118 }
119
120 static inline void v4l2_fill_pix_format_mplane(
121 struct v4l2_pix_format_mplane *pix_mp_fmt,
122 const struct v4l2_mbus_framefmt *mbus_fmt)
123 {
124 pix_mp_fmt->width = mbus_fmt->width;
125 pix_mp_fmt->height = mbus_fmt->height;
126 pix_mp_fmt->field = mbus_fmt->field;
127 pix_mp_fmt->colorspace = mbus_fmt->colorspace;
128 pix_mp_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
129 pix_mp_fmt->quantization = mbus_fmt->quantization;
130 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func;
131 }
132
133 static inline void v4l2_fill_mbus_format_mplane(
134 struct v4l2_mbus_framefmt *mbus_fmt,
135 const struct v4l2_pix_format_mplane *pix_mp_fmt)
136 {
137 mbus_fmt->width = pix_mp_fmt->width;
138 mbus_fmt->height = pix_mp_fmt->height;
139 mbus_fmt->field = pix_mp_fmt->field;
140 mbus_fmt->colorspace = pix_mp_fmt->colorspace;
141 mbus_fmt->ycbcr_enc = pix_mp_fmt->ycbcr_enc;
142 mbus_fmt->quantization = pix_mp_fmt->quantization;
143 mbus_fmt->xfer_func = pix_mp_fmt->xfer_func;
144 }
145
146 #endif