Skip to content

Commit 6930afd

Browse files
slongerbeampH5
authored andcommitted
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>
1 parent e7268c6 commit 6930afd

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎drivers/gpu/ipu-v3/ipu-common.c‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,36 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
126126
}
127127
EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
128128

129+
int 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+
}
157+
EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
158+
129159
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
130160
bool hflip, bool vflip)
131161
{

‎include/video/imx-ipu-v3.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ int ipu_smfc_set_watermark(struct ipu_smfc *smfc, u32 set_level, u32 clr_level);
333333
enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
334334
enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
335335
enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
336+
int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
336337
bool ipu_pixelformat_is_planar(u32 pixelformat);
337338
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
338339
bool hflip, bool vflip);

0 commit comments

Comments
 (0)