4 * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
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.
11 #ifndef V4L2_MEDIABUS_H
12 #define V4L2_MEDIABUS_H
14 #include <linux/v4l2-mediabus.h>
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.
23 #define V4L2_MBUS_MASTER (1 << 0)
24 #define V4L2_MBUS_SLAVE (1 << 1)
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
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)
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)
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)
68 * 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_CSI2: MIPI CSI-2 serial interface
81 * v4l2_mbus_config - media bus configuration
82 * @type: in: interface type
83 * @flags: in / out: configuration flags, depending on @type
85 struct v4l2_mbus_config
{
86 enum v4l2_mbus_type type
;
90 static inline void v4l2_fill_pix_format(struct v4l2_pix_format
*pix_fmt
,
91 const struct v4l2_mbus_framefmt
*mbus_fmt
)
93 pix_fmt
->width
= mbus_fmt
->width
;
94 pix_fmt
->height
= mbus_fmt
->height
;
95 pix_fmt
->field
= mbus_fmt
->field
;
96 pix_fmt
->colorspace
= mbus_fmt
->colorspace
;
97 pix_fmt
->ycbcr_enc
= mbus_fmt
->ycbcr_enc
;
98 pix_fmt
->quantization
= mbus_fmt
->quantization
;
101 static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt
*mbus_fmt
,
102 const struct v4l2_pix_format
*pix_fmt
,
105 mbus_fmt
->width
= pix_fmt
->width
;
106 mbus_fmt
->height
= pix_fmt
->height
;
107 mbus_fmt
->field
= pix_fmt
->field
;
108 mbus_fmt
->colorspace
= pix_fmt
->colorspace
;
109 mbus_fmt
->ycbcr_enc
= pix_fmt
->ycbcr_enc
;
110 mbus_fmt
->quantization
= pix_fmt
->quantization
;
111 mbus_fmt
->code
= code
;