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