diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-12-11 09:41:28 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-16 06:27:27 -0500 |
commit | 9a74251d8bee7a25fee89a0be3ccea73e01c1a05 (patch) | |
tree | 5bffc0457e8fb4e39ac98e7d41423a1512aae498 /drivers/media | |
parent | faa582610d87edf3ae1d07710a8f7e11c105686c (diff) |
V4L/DVB (13658): v4l: add a media-bus API for configuring v4l2 subdev pixel and frame formats
Video subdevices, like cameras, decoders, connect to video bridges over
specialised busses. Data is being transferred over these busses in various
formats, which only loosely correspond to fourcc codes, describing how video
data is stored in RAM. This is not a one-to-one correspondence, therefore we
cannot use fourcc codes to configure subdevice output data formats. This patch
adds codes for several such on-the-bus formats and an API, similar to the
familiar .s_fmt(), .g_fmt(), .try_fmt(), .enum_fmt() API for configuring those
codes. After all users of the old API in struct v4l2_subdev_video_ops are
converted, it will be removed. Also add helper routines to support generic
pass-through mode for the soc-camera framework.
create mode 100644 drivers/media/video/soc_mediabus.c
create mode 100644 include/media/soc_mediabus.h
create mode 100644 include/media/v4l2-mediabus.h
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/video/soc_mediabus.c | 157 |
2 files changed, 158 insertions, 1 deletions
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 7a2dcc34111c..e7bc8daae064 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -149,7 +149,7 @@ obj-$(CONFIG_VIDEO_VIVI) += vivi.o | |||
149 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ | 149 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ |
150 | 150 | ||
151 | obj-$(CONFIG_VIDEO_OMAP2) += omap2cam.o | 151 | obj-$(CONFIG_VIDEO_OMAP2) += omap2cam.o |
152 | obj-$(CONFIG_SOC_CAMERA) += soc_camera.o | 152 | obj-$(CONFIG_SOC_CAMERA) += soc_camera.o soc_mediabus.o |
153 | obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o | 153 | obj-$(CONFIG_SOC_CAMERA_PLATFORM) += soc_camera_platform.o |
154 | # soc-camera host drivers have to be linked after camera drivers | 154 | # soc-camera host drivers have to be linked after camera drivers |
155 | obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o | 155 | obj-$(CONFIG_VIDEO_MX1) += mx1_camera.o |
diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c new file mode 100644 index 000000000000..f8d5c87dc2aa --- /dev/null +++ b/drivers/media/video/soc_mediabus.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * soc-camera media bus helper routines | ||
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 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include <media/v4l2-device.h> | ||
15 | #include <media/v4l2-mediabus.h> | ||
16 | #include <media/soc_mediabus.h> | ||
17 | |||
18 | #define MBUS_IDX(f) (V4L2_MBUS_FMT_ ## f - V4L2_MBUS_FMT_FIXED - 1) | ||
19 | |||
20 | static const struct soc_mbus_pixelfmt mbus_fmt[] = { | ||
21 | [MBUS_IDX(YUYV8_2X8_LE)] = { | ||
22 | .fourcc = V4L2_PIX_FMT_YUYV, | ||
23 | .name = "YUYV", | ||
24 | .bits_per_sample = 8, | ||
25 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
26 | .order = SOC_MBUS_ORDER_LE, | ||
27 | }, [MBUS_IDX(YVYU8_2X8_LE)] = { | ||
28 | .fourcc = V4L2_PIX_FMT_YVYU, | ||
29 | .name = "YVYU", | ||
30 | .bits_per_sample = 8, | ||
31 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
32 | .order = SOC_MBUS_ORDER_LE, | ||
33 | }, [MBUS_IDX(YUYV8_2X8_BE)] = { | ||
34 | .fourcc = V4L2_PIX_FMT_UYVY, | ||
35 | .name = "UYVY", | ||
36 | .bits_per_sample = 8, | ||
37 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
38 | .order = SOC_MBUS_ORDER_LE, | ||
39 | }, [MBUS_IDX(YVYU8_2X8_BE)] = { | ||
40 | .fourcc = V4L2_PIX_FMT_VYUY, | ||
41 | .name = "VYUY", | ||
42 | .bits_per_sample = 8, | ||
43 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
44 | .order = SOC_MBUS_ORDER_LE, | ||
45 | }, [MBUS_IDX(RGB555_2X8_PADHI_LE)] = { | ||
46 | .fourcc = V4L2_PIX_FMT_RGB555, | ||
47 | .name = "RGB555", | ||
48 | .bits_per_sample = 8, | ||
49 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
50 | .order = SOC_MBUS_ORDER_LE, | ||
51 | }, [MBUS_IDX(RGB555_2X8_PADHI_BE)] = { | ||
52 | .fourcc = V4L2_PIX_FMT_RGB555X, | ||
53 | .name = "RGB555X", | ||
54 | .bits_per_sample = 8, | ||
55 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
56 | .order = SOC_MBUS_ORDER_LE, | ||
57 | }, [MBUS_IDX(RGB565_2X8_LE)] = { | ||
58 | .fourcc = V4L2_PIX_FMT_RGB565, | ||
59 | .name = "RGB565", | ||
60 | .bits_per_sample = 8, | ||
61 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
62 | .order = SOC_MBUS_ORDER_LE, | ||
63 | }, [MBUS_IDX(RGB565_2X8_BE)] = { | ||
64 | .fourcc = V4L2_PIX_FMT_RGB565X, | ||
65 | .name = "RGB565X", | ||
66 | .bits_per_sample = 8, | ||
67 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
68 | .order = SOC_MBUS_ORDER_LE, | ||
69 | }, [MBUS_IDX(SBGGR8_1X8)] = { | ||
70 | .fourcc = V4L2_PIX_FMT_SBGGR8, | ||
71 | .name = "Bayer 8 BGGR", | ||
72 | .bits_per_sample = 8, | ||
73 | .packing = SOC_MBUS_PACKING_NONE, | ||
74 | .order = SOC_MBUS_ORDER_LE, | ||
75 | }, [MBUS_IDX(SBGGR10_1X10)] = { | ||
76 | .fourcc = V4L2_PIX_FMT_SBGGR10, | ||
77 | .name = "Bayer 10 BGGR", | ||
78 | .bits_per_sample = 10, | ||
79 | .packing = SOC_MBUS_PACKING_EXTEND16, | ||
80 | .order = SOC_MBUS_ORDER_LE, | ||
81 | }, [MBUS_IDX(GREY8_1X8)] = { | ||
82 | .fourcc = V4L2_PIX_FMT_GREY, | ||
83 | .name = "Grey", | ||
84 | .bits_per_sample = 8, | ||
85 | .packing = SOC_MBUS_PACKING_NONE, | ||
86 | .order = SOC_MBUS_ORDER_LE, | ||
87 | }, [MBUS_IDX(Y10_1X10)] = { | ||
88 | .fourcc = V4L2_PIX_FMT_Y10, | ||
89 | .name = "Grey 10bit", | ||
90 | .bits_per_sample = 10, | ||
91 | .packing = SOC_MBUS_PACKING_EXTEND16, | ||
92 | .order = SOC_MBUS_ORDER_LE, | ||
93 | }, [MBUS_IDX(SBGGR10_2X8_PADHI_LE)] = { | ||
94 | .fourcc = V4L2_PIX_FMT_SBGGR10, | ||
95 | .name = "Bayer 10 BGGR", | ||
96 | .bits_per_sample = 8, | ||
97 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
98 | .order = SOC_MBUS_ORDER_LE, | ||
99 | }, [MBUS_IDX(SBGGR10_2X8_PADLO_LE)] = { | ||
100 | .fourcc = V4L2_PIX_FMT_SBGGR10, | ||
101 | .name = "Bayer 10 BGGR", | ||
102 | .bits_per_sample = 8, | ||
103 | .packing = SOC_MBUS_PACKING_2X8_PADLO, | ||
104 | .order = SOC_MBUS_ORDER_LE, | ||
105 | }, [MBUS_IDX(SBGGR10_2X8_PADHI_BE)] = { | ||
106 | .fourcc = V4L2_PIX_FMT_SBGGR10, | ||
107 | .name = "Bayer 10 BGGR", | ||
108 | .bits_per_sample = 8, | ||
109 | .packing = SOC_MBUS_PACKING_2X8_PADHI, | ||
110 | .order = SOC_MBUS_ORDER_BE, | ||
111 | }, [MBUS_IDX(SBGGR10_2X8_PADLO_BE)] = { | ||
112 | .fourcc = V4L2_PIX_FMT_SBGGR10, | ||
113 | .name = "Bayer 10 BGGR", | ||
114 | .bits_per_sample = 8, | ||
115 | .packing = SOC_MBUS_PACKING_2X8_PADLO, | ||
116 | .order = SOC_MBUS_ORDER_BE, | ||
117 | }, | ||
118 | }; | ||
119 | |||
120 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf) | ||
121 | { | ||
122 | switch (mf->packing) { | ||
123 | case SOC_MBUS_PACKING_NONE: | ||
124 | return width * mf->bits_per_sample / 8; | ||
125 | case SOC_MBUS_PACKING_2X8_PADHI: | ||
126 | case SOC_MBUS_PACKING_2X8_PADLO: | ||
127 | case SOC_MBUS_PACKING_EXTEND16: | ||
128 | return width * 2; | ||
129 | } | ||
130 | return -EINVAL; | ||
131 | } | ||
132 | EXPORT_SYMBOL(soc_mbus_bytes_per_line); | ||
133 | |||
134 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( | ||
135 | enum v4l2_mbus_pixelcode code) | ||
136 | { | ||
137 | if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED) > ARRAY_SIZE(mbus_fmt)) | ||
138 | return NULL; | ||
139 | return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1; | ||
140 | } | ||
141 | EXPORT_SYMBOL(soc_mbus_get_fmtdesc); | ||
142 | |||
143 | static int __init soc_mbus_init(void) | ||
144 | { | ||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static void __exit soc_mbus_exit(void) | ||
149 | { | ||
150 | } | ||
151 | |||
152 | module_init(soc_mbus_init); | ||
153 | module_exit(soc_mbus_exit); | ||
154 | |||
155 | MODULE_DESCRIPTION("soc-camera media bus interface"); | ||
156 | MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); | ||
157 | MODULE_LICENSE("GPL v2"); | ||