blob: 8e6559838ae32f844ec9f33626787d9b86b19316 [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
14/*
15 * These pixel codes uniquely identify data formats on the media bus. Mostly
16 * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
17 * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
18 * data format is fixed. Additionally, "2X8" means that one pixel is transferred
19 * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
20 * transferred over the bus: "LE" means that the least significant bits are
21 * transferred first, "BE" means that the most significant bits are transferred
22 * first, and "PADHI" and "PADLO" define which bits - low or high, in the
23 * incomplete high byte, are filled with padding bits.
24 */
25enum v4l2_mbus_pixelcode {
26 V4L2_MBUS_FMT_FIXED = 1,
Guennadi Liakhovetskiace6e972010-07-22 16:52:51 -030027 V4L2_MBUS_FMT_YUYV8_2X8,
28 V4L2_MBUS_FMT_YVYU8_2X8,
29 V4L2_MBUS_FMT_UYVY8_2X8,
30 V4L2_MBUS_FMT_VYUY8_2X8,
Hans Verkuil0edc4af2010-08-07 06:27:16 -030031 V4L2_MBUS_FMT_YVYU10_2X10,
32 V4L2_MBUS_FMT_YUYV10_2X10,
33 V4L2_MBUS_FMT_YVYU10_1X20,
34 V4L2_MBUS_FMT_YUYV10_1X20,
Hans Verkuild7709fff2010-08-06 16:25:04 -030035 V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE,
36 V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE,
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030037 V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
38 V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
39 V4L2_MBUS_FMT_RGB565_2X8_LE,
40 V4L2_MBUS_FMT_RGB565_2X8_BE,
Sascha Hauer0915d552010-08-03 07:57:47 -030041 V4L2_MBUS_FMT_BGR565_2X8_LE,
42 V4L2_MBUS_FMT_BGR565_2X8_BE,
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030043 V4L2_MBUS_FMT_SBGGR8_1X8,
44 V4L2_MBUS_FMT_SBGGR10_1X10,
45 V4L2_MBUS_FMT_GREY8_1X8,
46 V4L2_MBUS_FMT_Y10_1X10,
47 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
48 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE,
49 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
50 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
Hans Verkuil260bb382010-05-08 19:02:11 -030051 V4L2_MBUS_FMT_SGRBG8_1X8,
Guennadi Liakhovetskic6b65ab2010-07-26 10:41:55 -030052 V4L2_MBUS_FMT_SBGGR12_1X12,
53 V4L2_MBUS_FMT_YUYV8_1_5X8,
54 V4L2_MBUS_FMT_YVYU8_1_5X8,
55 V4L2_MBUS_FMT_UYVY8_1_5X8,
56 V4L2_MBUS_FMT_VYUY8_1_5X8,
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030057};
58
59/**
60 * struct v4l2_mbus_framefmt - frame format on the media bus
61 * @width: frame width
62 * @height: frame height
63 * @code: data format code
64 * @field: used interlacing type
65 * @colorspace: colorspace of the data
66 */
67struct v4l2_mbus_framefmt {
68 __u32 width;
69 __u32 height;
70 enum v4l2_mbus_pixelcode code;
71 enum v4l2_field field;
72 enum v4l2_colorspace colorspace;
73};
74
Hans Verkuil3a21cee2010-05-08 17:08:58 -030075static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
76 const struct v4l2_mbus_framefmt *mbus_fmt)
77{
78 pix_fmt->width = mbus_fmt->width;
79 pix_fmt->height = mbus_fmt->height;
80 pix_fmt->field = mbus_fmt->field;
81 pix_fmt->colorspace = mbus_fmt->colorspace;
82}
83
84static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
85 const struct v4l2_pix_format *pix_fmt,
86 enum v4l2_mbus_pixelcode code)
87{
88 mbus_fmt->width = pix_fmt->width;
89 mbus_fmt->height = pix_fmt->height;
90 mbus_fmt->field = pix_fmt->field;
91 mbus_fmt->colorspace = pix_fmt->colorspace;
92 mbus_fmt->code = code;
93}
94
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030095#endif