]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/media/v4l2-mediabus.h
jbd2: Fix possible overflow in jbd2_log_space_left()
[mirror_ubuntu-bionic-kernel.git] / include / media / v4l2-mediabus.h
CommitLineData
9a74251d
GL
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
2ef2d5a3 14#include <linux/v4l2-mediabus.h>
9a74251d 15
91c79530
GL
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)
3c6938f8
SN
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 */
91c79530
GL
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)
3c6938f8
SN
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)
d1d70aa6
LP
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)
91c79530
GL
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/**
98d00bd7 68 * enum v4l2_mbus_type - media bus type
91c79530
GL
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
97bbdf02
SA
72 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface
73 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
91c79530
GL
74 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
75 */
76enum v4l2_mbus_type {
77 V4L2_MBUS_PARALLEL,
78 V4L2_MBUS_BT656,
97bbdf02
SA
79 V4L2_MBUS_CSI1,
80 V4L2_MBUS_CCP2,
91c79530
GL
81 V4L2_MBUS_CSI2,
82};
83
84/**
98d00bd7 85 * struct v4l2_mbus_config - media bus configuration
91c79530
GL
86 * @type: in: interface type
87 * @flags: in / out: configuration flags, depending on @type
88 */
89struct v4l2_mbus_config {
90 enum v4l2_mbus_type type;
91 unsigned int flags;
92};
93
3a21ceed
HV
94static 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;
11ff030c
HV
101 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
102 pix_fmt->quantization = mbus_fmt->quantization;
74fdcb2e 103 pix_fmt->xfer_func = mbus_fmt->xfer_func;
3a21ceed
HV
104}
105
106static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
107 const struct v4l2_pix_format *pix_fmt,
32b32ce8 108 u32 code)
3a21ceed
HV
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;
11ff030c
HV
114 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
115 mbus_fmt->quantization = pix_fmt->quantization;
74fdcb2e 116 mbus_fmt->xfer_func = pix_fmt->xfer_func;
3a21ceed
HV
117 mbus_fmt->code = code;
118}
119
f1923010
TT
120static 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
133static 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
9a74251d 146#endif