]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] V4L: soc_mediabus: add a method to obtain the number of samples per pixel
authorAlberto Panizzo <maramaopercheseimorto@gmail.com>
Wed, 12 Jan 2011 11:16:19 +0000 (08:16 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 21 Mar 2011 23:32:13 +0000 (20:32 -0300)
Add a function to calculate the number of samples on the media-bus,
required to retrieve one pixel of a certain format.

Signed-off-by: Alberto Panizzo <maramaopercheseimorto@gmail.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/soc_mediabus.c
include/media/soc_mediabus.h

index 91391214c682d46f52bae13eb53a3c7f37f2f347..73b4138709e40ebb521986d639c5b4fdd132f3ab 100644 (file)
@@ -132,6 +132,20 @@ static const struct soc_mbus_pixelfmt mbus_fmt[] = {
        },
 };
 
+int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf)
+{
+       switch (mf->packing) {
+       case SOC_MBUS_PACKING_NONE:
+       case SOC_MBUS_PACKING_EXTEND16:
+               return 1;
+       case SOC_MBUS_PACKING_2X8_PADHI:
+       case SOC_MBUS_PACKING_2X8_PADLO:
+               return 2;
+       }
+       return -EINVAL;
+}
+EXPORT_SYMBOL(soc_mbus_samples_per_pixel);
+
 s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf)
 {
        switch (mf->packing) {
index 037cd7be001e75f5751f6db848d39fa9142c7b2f..f5522b3f175a821c754c7d4c336e50fa682ecd03 100644 (file)
@@ -61,5 +61,6 @@ struct soc_mbus_pixelfmt {
 const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
        enum v4l2_mbus_pixelcode code);
 s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
+int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf);
 
 #endif