Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 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 | |
Laurent Pinchart | 2ef2d5a | 2010-03-15 19:33:31 -0300 | [diff] [blame] | 14 | #include <linux/v4l2-mediabus.h> |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 15 | |
Guennadi Liakhovetski | 91c7953 | 2011-07-01 14:31:17 -0300 | [diff] [blame] | 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 | /* Which signal polarities it supports */ |
| 26 | /* Note: in BT.656 mode HSYNC and VSYNC are unused */ |
| 27 | #define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2) |
| 28 | #define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3) |
| 29 | #define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4) |
| 30 | #define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5) |
| 31 | #define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6) |
| 32 | #define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7) |
| 33 | #define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8) |
| 34 | #define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9) |
| 35 | |
| 36 | /* Serial flags */ |
| 37 | /* How many lanes the client can use */ |
| 38 | #define V4L2_MBUS_CSI2_1_LANE (1 << 0) |
| 39 | #define V4L2_MBUS_CSI2_2_LANE (1 << 1) |
| 40 | #define V4L2_MBUS_CSI2_3_LANE (1 << 2) |
| 41 | #define V4L2_MBUS_CSI2_4_LANE (1 << 3) |
| 42 | /* On which channels it can send video data */ |
| 43 | #define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4) |
| 44 | #define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5) |
| 45 | #define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6) |
| 46 | #define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7) |
| 47 | /* Does it support only continuous or also non-continuous clock mode */ |
| 48 | #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8) |
| 49 | #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9) |
| 50 | |
| 51 | #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ |
| 52 | V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE) |
| 53 | #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \ |
| 54 | V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3) |
| 55 | |
| 56 | /** |
| 57 | * v4l2_mbus_type - media bus type |
| 58 | * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync |
| 59 | * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can |
| 60 | * also be used for BT.1120 |
| 61 | * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface |
| 62 | */ |
| 63 | enum v4l2_mbus_type { |
| 64 | V4L2_MBUS_PARALLEL, |
| 65 | V4L2_MBUS_BT656, |
| 66 | V4L2_MBUS_CSI2, |
| 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * v4l2_mbus_config - media bus configuration |
| 71 | * @type: in: interface type |
| 72 | * @flags: in / out: configuration flags, depending on @type |
| 73 | */ |
| 74 | struct v4l2_mbus_config { |
| 75 | enum v4l2_mbus_type type; |
| 76 | unsigned int flags; |
| 77 | }; |
| 78 | |
Hans Verkuil | 3a21cee | 2010-05-08 17:08:58 -0300 | [diff] [blame] | 79 | static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, |
| 80 | const struct v4l2_mbus_framefmt *mbus_fmt) |
| 81 | { |
| 82 | pix_fmt->width = mbus_fmt->width; |
| 83 | pix_fmt->height = mbus_fmt->height; |
| 84 | pix_fmt->field = mbus_fmt->field; |
| 85 | pix_fmt->colorspace = mbus_fmt->colorspace; |
| 86 | } |
| 87 | |
| 88 | static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, |
| 89 | const struct v4l2_pix_format *pix_fmt, |
| 90 | enum v4l2_mbus_pixelcode code) |
| 91 | { |
| 92 | mbus_fmt->width = pix_fmt->width; |
| 93 | mbus_fmt->height = pix_fmt->height; |
| 94 | mbus_fmt->field = pix_fmt->field; |
| 95 | mbus_fmt->colorspace = pix_fmt->colorspace; |
| 96 | mbus_fmt->code = code; |
| 97 | } |
| 98 | |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 99 | #endif |