Message ID | 1402178205-22697-22-git-send-email-steve_longerbeam@mentor.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam: > Add simple conversion from pixelformat to total bits-per-pixel. [...] > +/* > + * Standard bpp from pixel format. > + */ > +int ipu_bits_per_pixel(u32 pixelformat) > +{ > + switch (pixelformat) { > + case V4L2_PIX_FMT_YUV420: > + case V4L2_PIX_FMT_YVU420: > + return 12; > + case V4L2_PIX_FMT_RGB565: > + case V4L2_PIX_FMT_YUYV: > + case V4L2_PIX_FMT_UYVY: > + return 16; > + case V4L2_PIX_FMT_BGR24: > + case V4L2_PIX_FMT_RGB24: > + return 24; > + case V4L2_PIX_FMT_BGR32: > + case V4L2_PIX_FMT_RGB32: > + return 32; > + default: > + break; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(ipu_bits_per_pixel); This isn't really IPU specific. Should we have a v4l2-wide helper for this? Also, it seems that this is only ever used to calculate the bytesperline, so why not return bytes per pixel directly? regards Philipp -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index de66d02..8a03ad2 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -606,6 +606,33 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) } EXPORT_SYMBOL_GPL(ipu_stride_to_bytes); +/* + * Standard bpp from pixel format. + */ +int ipu_bits_per_pixel(u32 pixelformat) +{ + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + return 12; + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + return 16; + case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_RGB24: + return 24; + case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_RGB32: + return 32; + default: + break; + } + + return 0; +} +EXPORT_SYMBOL_GPL(ipu_bits_per_pixel); + int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip) { diff --git a/include/linux/platform_data/imx-ipu-v3.h b/include/linux/platform_data/imx-ipu-v3.h index 75a6a5d..49e69a9 100644 --- a/include/linux/platform_data/imx-ipu-v3.h +++ b/include/linux/platform_data/imx-ipu-v3.h @@ -510,6 +510,7 @@ enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code); int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat); +int ipu_bits_per_pixel(u32 pixelformat); bool ipu_pixelformat_is_planar(u32 pixelformat); int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip);
Add simple conversion from pixelformat to total bits-per-pixel. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 27 +++++++++++++++++++++++++++ include/linux/platform_data/imx-ipu-v3.h | 1 + 2 files changed, 28 insertions(+)