diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-05-20 03:25:09 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 11:05:08 -0400 |
commit | cc552b620fa3a184ba3d4064223ca1d59325b166 (patch) | |
tree | 8de21b7b635acbc87f71f790af917f3a4c56ee20 | |
parent | e9ceeced6feb6f072d59b87fe5a47c37e2b50d51 (diff) |
[media] V4L: soc-camera: add a new packing for YUV 4:2:0 type formats
12-bit formats, similar to YUV 4:2:0 occupy 3 bytes for each two pixels
and cannot be described by any of the existing SOC_MBUS_PACKING_* macros.
This patch adds a new one SOC_MBUS_PACKING_1_5X8 to describe such
formats and extends soc_mbus_samples_per_pixel() to support it.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/mx3_camera.c | 6 | ||||
-rw-r--r-- | drivers/media/video/soc_mediabus.c | 19 | ||||
-rw-r--r-- | include/media/soc_mediabus.h | 10 |
3 files changed, 28 insertions, 7 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index 8630c0c9e60..3e5435b539b 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c | |||
@@ -756,8 +756,10 @@ static void configure_geometry(struct mx3_camera_dev *mx3_cam, | |||
756 | * the width parameter count the number of samples to | 756 | * the width parameter count the number of samples to |
757 | * capture to complete the whole image width. | 757 | * capture to complete the whole image width. |
758 | */ | 758 | */ |
759 | width *= soc_mbus_samples_per_pixel(fmt); | 759 | unsigned int num, den; |
760 | BUG_ON(width < 0); | 760 | int ret = soc_mbus_samples_per_pixel(fmt, &num, &den); |
761 | BUG_ON(ret < 0); | ||
762 | width = width * num / den; | ||
761 | } | 763 | } |
762 | 764 | ||
763 | /* Setup frame size - this cannot be changed on-the-fly... */ | 765 | /* Setup frame size - this cannot be changed on-the-fly... */ |
diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c index 1b0018a5880..e13c663d6d0 100644 --- a/drivers/media/video/soc_mediabus.c +++ b/drivers/media/video/soc_mediabus.c | |||
@@ -172,16 +172,27 @@ static const struct soc_mbus_lookup mbus_fmt[] = { | |||
172 | }, | 172 | }, |
173 | }; | 173 | }; |
174 | 174 | ||
175 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf) | 175 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, |
176 | unsigned int *numerator, unsigned int *denominator) | ||
176 | { | 177 | { |
177 | switch (mf->packing) { | 178 | switch (mf->packing) { |
178 | case SOC_MBUS_PACKING_NONE: | 179 | case SOC_MBUS_PACKING_NONE: |
179 | case SOC_MBUS_PACKING_EXTEND16: | 180 | case SOC_MBUS_PACKING_EXTEND16: |
180 | return 1; | 181 | *numerator = 1; |
182 | *denominator = 1; | ||
183 | return 0; | ||
181 | case SOC_MBUS_PACKING_2X8_PADHI: | 184 | case SOC_MBUS_PACKING_2X8_PADHI: |
182 | case SOC_MBUS_PACKING_2X8_PADLO: | 185 | case SOC_MBUS_PACKING_2X8_PADLO: |
183 | return 2; | 186 | *numerator = 2; |
187 | *denominator = 1; | ||
188 | return 0; | ||
189 | case SOC_MBUS_PACKING_1_5X8: | ||
190 | *numerator = 3; | ||
191 | *denominator = 2; | ||
192 | return 0; | ||
184 | case SOC_MBUS_PACKING_VARIABLE: | 193 | case SOC_MBUS_PACKING_VARIABLE: |
194 | *numerator = 0; | ||
195 | *denominator = 1; | ||
185 | return 0; | 196 | return 0; |
186 | } | 197 | } |
187 | return -EINVAL; | 198 | return -EINVAL; |
@@ -197,6 +208,8 @@ s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf) | |||
197 | case SOC_MBUS_PACKING_2X8_PADLO: | 208 | case SOC_MBUS_PACKING_2X8_PADLO: |
198 | case SOC_MBUS_PACKING_EXTEND16: | 209 | case SOC_MBUS_PACKING_EXTEND16: |
199 | return width * 2; | 210 | return width * 2; |
211 | case SOC_MBUS_PACKING_1_5X8: | ||
212 | return width * 3 / 2; | ||
200 | case SOC_MBUS_PACKING_VARIABLE: | 213 | case SOC_MBUS_PACKING_VARIABLE: |
201 | return 0; | 214 | return 0; |
202 | } | 215 | } |
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h index 3eed98ed02f..fae432544b4 100644 --- a/include/media/soc_mediabus.h +++ b/include/media/soc_mediabus.h | |||
@@ -16,12 +16,16 @@ | |||
16 | 16 | ||
17 | /** | 17 | /** |
18 | * enum soc_mbus_packing - data packing types on the media-bus | 18 | * enum soc_mbus_packing - data packing types on the media-bus |
19 | * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM | 19 | * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one |
20 | * sample represents one pixel | ||
20 | * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the | 21 | * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the |
21 | * possibly incomplete byte high bits are padding | 22 | * possibly incomplete byte high bits are padding |
22 | * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding | 23 | * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding |
23 | * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended | 24 | * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended |
24 | * to 16 bits | 25 | * to 16 bits |
26 | * @SOC_MBUS_PACKING_VARIABLE: compressed formats with variable packing | ||
27 | * @SOC_MBUS_PACKING_1_5X8: used for packed YUV 4:2:0 formats, where 4 | ||
28 | * pixels occupy 6 bytes in RAM | ||
25 | */ | 29 | */ |
26 | enum soc_mbus_packing { | 30 | enum soc_mbus_packing { |
27 | SOC_MBUS_PACKING_NONE, | 31 | SOC_MBUS_PACKING_NONE, |
@@ -29,6 +33,7 @@ enum soc_mbus_packing { | |||
29 | SOC_MBUS_PACKING_2X8_PADLO, | 33 | SOC_MBUS_PACKING_2X8_PADLO, |
30 | SOC_MBUS_PACKING_EXTEND16, | 34 | SOC_MBUS_PACKING_EXTEND16, |
31 | SOC_MBUS_PACKING_VARIABLE, | 35 | SOC_MBUS_PACKING_VARIABLE, |
36 | SOC_MBUS_PACKING_1_5X8, | ||
32 | }; | 37 | }; |
33 | 38 | ||
34 | /** | 39 | /** |
@@ -75,6 +80,7 @@ const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc( | |||
75 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( | 80 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( |
76 | enum v4l2_mbus_pixelcode code); | 81 | enum v4l2_mbus_pixelcode code); |
77 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); | 82 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); |
78 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf); | 83 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, |
84 | unsigned int *numerator, unsigned int *denominator); | ||
79 | 85 | ||
80 | #endif | 86 | #endif |