diff options
author | Steve Longerbeam <slongerbeam@gmail.com> | 2014-06-25 18:05:43 -0700 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2014-09-02 14:55:50 +0200 |
commit | 6930afdccfd2b3e6669c305d97958d81cf0d072e (patch) | |
tree | bfff374703164662e7f4dab97270691f7420e984 /drivers/gpu/ipu-v3 | |
parent | e7268c699bbe578e6dcf02e9f7f5a267837bc18f (diff) | |
download | op-kernel-dev-6930afdccfd2b3e6669c305d97958d81cf0d072e.zip op-kernel-dev-6930afdccfd2b3e6669c305d97958d81cf0d072e.tar.gz |
gpu: ipu-v3: Add ipu_stride_to_bytes()
Adds ipu_stride_to_bytes(), which converts a pixel stride to bytes,
suitable for passing to cpmem.
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/ipu-v3')
-rw-r--r-- | drivers/gpu/ipu-v3/ipu-common.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 985a750..e542d5e 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -126,6 +126,36 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code) } EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace); +int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) +{ + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + /* + * for the planar YUV formats, the stride passed to + * cpmem must be the stride in bytes of the Y plane. + * And all the planar YUV formats have an 8-bit + * Y component. + */ + return (8 * pixel_stride) >> 3; + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + return (16 * pixel_stride) >> 3; + case V4L2_PIX_FMT_BGR24: + case V4L2_PIX_FMT_RGB24: + return (24 * pixel_stride) >> 3; + case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_RGB32: + return (32 * pixel_stride) >> 3; + default: + break; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(ipu_stride_to_bytes); + int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, bool hflip, bool vflip) { |