blob: 34cc99e093ef79780fb92f2793a08b044f8713cf [file] [log] [blame]
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -03001/*
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
Laurent Pinchart2ef2d5a2010-03-15 19:33:31 -030014#include <linux/v4l2-mediabus.h>
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030015
Guennadi Liakhovetski91c79532011-07-01 14:31:17 -030016/* 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)
Sylwester Nawrocki3c6938f2011-09-19 12:58:54 -030025/*
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 */
Guennadi Liakhovetski91c79532011-07-01 14:31:17 -030031#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)
Sylwester Nawrocki3c6938f2011-09-19 12:58:54 -030039/* 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)
Lad, Prabhakard1d70aa62013-08-11 02:02:24 -030043/* 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)
Guennadi Liakhovetski91c79532011-07-01 14:31:17 -030046
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/**
Mauro Carvalho Chehab98d00bd2015-08-22 09:04:46 -030068 * enum v4l2_mbus_type - media bus type
Guennadi Liakhovetski91c79532011-07-01 14:31:17 -030069 * @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
73 */
74enum v4l2_mbus_type {
75 V4L2_MBUS_PARALLEL,
76 V4L2_MBUS_BT656,
77 V4L2_MBUS_CSI2,
78};
79
80/**
Mauro Carvalho Chehab98d00bd2015-08-22 09:04:46 -030081 * struct v4l2_mbus_config - media bus configuration
Guennadi Liakhovetski91c79532011-07-01 14:31:17 -030082 * @type: in: interface type
83 * @flags: in / out: configuration flags, depending on @type
84 */
85struct v4l2_mbus_config {
86 enum v4l2_mbus_type type;
87 unsigned int flags;
88};
89
Hans Verkuil3a21cee2010-05-08 17:08:58 -030090static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
91 const struct v4l2_mbus_framefmt *mbus_fmt)
92{
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;
Hans Verkuil11ff0302014-11-17 09:10:33 -030097 pix_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
98 pix_fmt->quantization = mbus_fmt->quantization;
Hans Verkuil74fdcb22015-04-28 08:49:09 -030099 pix_fmt->xfer_func = mbus_fmt->xfer_func;
Hans Verkuil3a21cee2010-05-08 17:08:58 -0300100}
101
102static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
103 const struct v4l2_pix_format *pix_fmt,
Boris BREZILLON32b32ce2014-11-10 14:28:28 -0300104 u32 code)
Hans Verkuil3a21cee2010-05-08 17:08:58 -0300105{
106 mbus_fmt->width = pix_fmt->width;
107 mbus_fmt->height = pix_fmt->height;
108 mbus_fmt->field = pix_fmt->field;
109 mbus_fmt->colorspace = pix_fmt->colorspace;
Hans Verkuil11ff0302014-11-17 09:10:33 -0300110 mbus_fmt->ycbcr_enc = pix_fmt->ycbcr_enc;
111 mbus_fmt->quantization = pix_fmt->quantization;
Hans Verkuil74fdcb22015-04-28 08:49:09 -0300112 mbus_fmt->xfer_func = pix_fmt->xfer_func;
Hans Verkuil3a21cee2010-05-08 17:08:58 -0300113 mbus_fmt->code = code;
114}
115
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -0300116#endif