aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/ipu-v3
diff options
context:
space:
mode:
authorSteve Longerbeam <slongerbeam@gmail.com>2014-06-25 21:05:43 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2014-09-02 08:55:50 -0400
commit6930afdccfd2b3e6669c305d97958d81cf0d072e (patch)
treebfff374703164662e7f4dab97270691f7420e984 /drivers/gpu/ipu-v3
parente7268c699bbe578e6dcf02e9f7f5a267837bc18f (diff)
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.c30
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 985a7508af3a..e542d5e8a9e1 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)
126} 126}
127EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace); 127EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
128 128
129int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
130{
131 switch (pixelformat) {
132 case V4L2_PIX_FMT_YUV420:
133 case V4L2_PIX_FMT_YVU420:
134 /*
135 * for the planar YUV formats, the stride passed to
136 * cpmem must be the stride in bytes of the Y plane.
137 * And all the planar YUV formats have an 8-bit
138 * Y component.
139 */
140 return (8 * pixel_stride) >> 3;
141 case V4L2_PIX_FMT_RGB565:
142 case V4L2_PIX_FMT_YUYV:
143 case V4L2_PIX_FMT_UYVY:
144 return (16 * pixel_stride) >> 3;
145 case V4L2_PIX_FMT_BGR24:
146 case V4L2_PIX_FMT_RGB24:
147 return (24 * pixel_stride) >> 3;
148 case V4L2_PIX_FMT_BGR32:
149 case V4L2_PIX_FMT_RGB32:
150 return (32 * pixel_stride) >> 3;
151 default:
152 break;
153 }
154
155 return -EINVAL;
156}
157EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
158
129int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, 159int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
130 bool hflip, bool vflip) 160 bool hflip, bool vflip)
131{ 161{