1 From 480b9effa08541b5df369dd6516013282cf28bd8 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Sun, 6 Oct 2013 17:24:04 +0200
4 Subject: [PATCH] Add kernel headers for compatibility with old toolchains
6 The media controller mechanism is relatively new in the Linux kernel,
7 and therefore all toolchains don't yet have the necessary
8 headers. This patch makes sure that media-ctl provides such headers,
9 as was already the case with v4l2-common.h, v4l2-subdev.h and
12 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
15 src/linux/media.h | 132 ++++++++++++++++++++++++++++++++++++++++++++++
16 src/linux/v4l2-mediabus.h | 119 +++++++++++++++++++++++++++++++++++++++++
17 3 files changed, 252 insertions(+), 5 deletions(-)
18 create mode 100644 src/linux/media.h
19 create mode 100644 src/linux/v4l2-mediabus.h
21 diff --git a/configure.ac b/configure.ac
22 index a749794..56eb71f 100644
25 @@ -51,11 +51,7 @@ AC_ARG_WITH(kernel-headers,
26 CPPFLAGS="$CPPFLAGS -I$KERNEL_HEADERS_DIR/include"
28 # Checks for header files.
29 -AC_CHECK_HEADERS([linux/media.h \
31 - linux/v4l2-mediabus.h \
32 - linux/v4l2-subdev.h \
34 +AC_CHECK_HEADERS([linux/types.h],
36 [echo "ERROR: Kernel header file not found or not usable!"; exit 1])
38 diff --git a/src/linux/media.h b/src/linux/media.h
40 index 0000000..410e7cc
42 +++ b/src/linux/media.h
45 + * Multimedia device API
47 + * Copyright (C) 2010 Nokia Corporation
49 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
50 + * Sakari Ailus <sakari.ailus@iki.fi>
52 + * This program is free software; you can redistribute it and/or modify
53 + * it under the terms of the GNU General Public License version 2 as
54 + * published by the Free Software Foundation.
56 + * This program is distributed in the hope that it will be useful,
57 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
58 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59 + * GNU General Public License for more details.
61 + * You should have received a copy of the GNU General Public License
62 + * along with this program; if not, write to the Free Software
63 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
66 +#ifndef __LINUX_MEDIA_H
67 +#define __LINUX_MEDIA_H
69 +#include <linux/ioctl.h>
70 +#include <linux/types.h>
71 +#include <linux/version.h>
73 +#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
75 +struct media_device_info {
80 + __u32 media_version;
82 + __u32 driver_version;
86 +#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
88 +#define MEDIA_ENT_TYPE_SHIFT 16
89 +#define MEDIA_ENT_TYPE_MASK 0x00ff0000
90 +#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
92 +#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT)
93 +#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1)
94 +#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
95 +#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
96 +#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
98 +#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT)
99 +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
100 +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
101 +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
103 +#define MEDIA_ENT_FL_DEFAULT (1 << 0)
105 +struct media_entity_desc {
118 + /* Node specifications */
134 + /* Sub-device specifications */
135 + /* Nothing needed yet */
140 +#define MEDIA_PAD_FL_SINK (1 << 0)
141 +#define MEDIA_PAD_FL_SOURCE (1 << 1)
143 +struct media_pad_desc {
144 + __u32 entity; /* entity ID */
145 + __u16 index; /* pad index */
146 + __u32 flags; /* pad flags */
150 +#define MEDIA_LNK_FL_ENABLED (1 << 0)
151 +#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
152 +#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
154 +struct media_link_desc {
155 + struct media_pad_desc source;
156 + struct media_pad_desc sink;
161 +struct media_links_enum {
163 + /* Should have enough room for pads elements */
164 + struct media_pad_desc *pads;
165 + /* Should have enough room for links elements */
166 + struct media_link_desc *links;
170 +#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
171 +#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
172 +#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
173 +#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
175 +#endif /* __LINUX_MEDIA_H */
176 diff --git a/src/linux/v4l2-mediabus.h b/src/linux/v4l2-mediabus.h
178 index 0000000..7d64e0e
180 +++ b/src/linux/v4l2-mediabus.h
183 + * Media Bus API header
185 + * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
187 + * This program is free software; you can redistribute it and/or modify
188 + * it under the terms of the GNU General Public License version 2 as
189 + * published by the Free Software Foundation.
192 +#ifndef __LINUX_V4L2_MEDIABUS_H
193 +#define __LINUX_V4L2_MEDIABUS_H
195 +#include <linux/types.h>
196 +#include <linux/videodev2.h>
199 + * These pixel codes uniquely identify data formats on the media bus. Mostly
200 + * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
201 + * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
202 + * data format is fixed. Additionally, "2X8" means that one pixel is transferred
203 + * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
204 + * transferred over the bus: "LE" means that the least significant bits are
205 + * transferred first, "BE" means that the most significant bits are transferred
206 + * first, and "PADHI" and "PADLO" define which bits - low or high, in the
207 + * incomplete high byte, are filled with padding bits.
209 + * The pixel codes are grouped by type, bus_width, bits per component, samples
210 + * per pixel and order of subsamples. Numerical values are sorted using generic
211 + * numerical sort order (8 thus comes before 10).
213 + * As their value can't change when a new pixel code is inserted in the
214 + * enumeration, the pixel codes are explicitly given a numerical value. The next
215 + * free values for each category are listed below, update them when inserting
218 +enum v4l2_mbus_pixelcode {
219 + V4L2_MBUS_FMT_FIXED = 0x0001,
221 + /* RGB - next is 0x1009 */
222 + V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
223 + V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
224 + V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
225 + V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
226 + V4L2_MBUS_FMT_BGR565_2X8_BE = 0x1005,
227 + V4L2_MBUS_FMT_BGR565_2X8_LE = 0x1006,
228 + V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
229 + V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
231 + /* YUV (including grey) - next is 0x2014 */
232 + V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
233 + V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
234 + V4L2_MBUS_FMT_VYUY8_1_5X8 = 0x2003,
235 + V4L2_MBUS_FMT_YUYV8_1_5X8 = 0x2004,
236 + V4L2_MBUS_FMT_YVYU8_1_5X8 = 0x2005,
237 + V4L2_MBUS_FMT_UYVY8_2X8 = 0x2006,
238 + V4L2_MBUS_FMT_VYUY8_2X8 = 0x2007,
239 + V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
240 + V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
241 + V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
242 + V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
243 + V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
244 + V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
245 + V4L2_MBUS_FMT_UYVY8_1X16 = 0x200f,
246 + V4L2_MBUS_FMT_VYUY8_1X16 = 0x2010,
247 + V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
248 + V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
249 + V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
250 + V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
252 + /* Bayer - next is 0x3015 */
253 + V4L2_MBUS_FMT_SBGGR8_1X8 = 0x3001,
254 + V4L2_MBUS_FMT_SGBRG8_1X8 = 0x3013,
255 + V4L2_MBUS_FMT_SGRBG8_1X8 = 0x3002,
256 + V4L2_MBUS_FMT_SRGGB8_1X8 = 0x3014,
257 + V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8 = 0x300b,
258 + V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8 = 0x300c,
259 + V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8 = 0x3009,
260 + V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8 = 0x300d,
261 + V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE = 0x3003,
262 + V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE = 0x3004,
263 + V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE = 0x3005,
264 + V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE = 0x3006,
265 + V4L2_MBUS_FMT_SBGGR10_1X10 = 0x3007,
266 + V4L2_MBUS_FMT_SGBRG10_1X10 = 0x300e,
267 + V4L2_MBUS_FMT_SGRBG10_1X10 = 0x300a,
268 + V4L2_MBUS_FMT_SRGGB10_1X10 = 0x300f,
269 + V4L2_MBUS_FMT_SBGGR12_1X12 = 0x3008,
270 + V4L2_MBUS_FMT_SGBRG12_1X12 = 0x3010,
271 + V4L2_MBUS_FMT_SGRBG12_1X12 = 0x3011,
272 + V4L2_MBUS_FMT_SRGGB12_1X12 = 0x3012,
274 + /* JPEG compressed formats - next is 0x4002 */
275 + V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
277 + /* Vendor specific formats - next is 0x5002 */
279 + /* S5C73M3 sensor specific interleaved UYVY and JPEG */
280 + V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8 = 0x5001,
284 + * struct v4l2_mbus_framefmt - frame format on the media bus
285 + * @width: frame width
286 + * @height: frame height
287 + * @code: data format code (from enum v4l2_mbus_pixelcode)
288 + * @field: used interlacing type (from enum v4l2_field)
289 + * @colorspace: colorspace of the data (from enum v4l2_colorspace)
291 +struct v4l2_mbus_framefmt {