Commit 7adc4a34 authored by Jordan Crouse's avatar Jordan Crouse Committed by Rob Clark

drm/msm/dpu: Clean up dpu_media_info.h static inline functions

Do some cleanup in the static inline functions defined in
dpu_media_info.h by cleaning up gotos and unneeded local
variables.

v3: Added spaces between operators per Seal Paul and Sam Ravnborg
Reviewed-by: default avatarSean Paul <sean@poorly.run>
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 3804a982
...@@ -822,36 +822,30 @@ enum color_fmts { ...@@ -822,36 +822,30 @@ enum color_fmts {
*/ */
static unsigned int VENUS_Y_STRIDE(int color_fmt, int width) static unsigned int VENUS_Y_STRIDE(int color_fmt, int width)
{ {
unsigned int alignment, stride = 0; unsigned int stride = 0;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV21: case COLOR_FMT_NV21:
case COLOR_FMT_NV12: case COLOR_FMT_NV12:
case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_MVTB:
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
alignment = 128; stride = MSM_MEDIA_ALIGN(width, 128);
stride = MSM_MEDIA_ALIGN(width, alignment);
break; break;
case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_NV12_BPP10_UBWC:
alignment = 256;
stride = MSM_MEDIA_ALIGN(width, 192); stride = MSM_MEDIA_ALIGN(width, 192);
stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256);
break; break;
case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010_UBWC:
alignment = 256; stride = MSM_MEDIA_ALIGN(width * 2, 256);
stride = MSM_MEDIA_ALIGN(width * 2, alignment);
break; break;
case COLOR_FMT_P010: case COLOR_FMT_P010:
alignment = 128; stride = MSM_MEDIA_ALIGN(width * 2, 128);
stride = MSM_MEDIA_ALIGN(width*2, alignment);
break;
default:
break; break;
} }
invalid_input:
return stride; return stride;
} }
...@@ -864,36 +858,30 @@ static unsigned int VENUS_Y_STRIDE(int color_fmt, int width) ...@@ -864,36 +858,30 @@ static unsigned int VENUS_Y_STRIDE(int color_fmt, int width)
*/ */
static unsigned int VENUS_UV_STRIDE(int color_fmt, int width) static unsigned int VENUS_UV_STRIDE(int color_fmt, int width)
{ {
unsigned int alignment, stride = 0; unsigned int stride = 0;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV21: case COLOR_FMT_NV21:
case COLOR_FMT_NV12: case COLOR_FMT_NV12:
case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_MVTB:
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
alignment = 128; stride = MSM_MEDIA_ALIGN(width, 128);
stride = MSM_MEDIA_ALIGN(width, alignment);
break; break;
case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_NV12_BPP10_UBWC:
alignment = 256;
stride = MSM_MEDIA_ALIGN(width, 192); stride = MSM_MEDIA_ALIGN(width, 192);
stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256);
break; break;
case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010_UBWC:
alignment = 256; stride = MSM_MEDIA_ALIGN(width * 2, 256);
stride = MSM_MEDIA_ALIGN(width * 2, alignment);
break; break;
case COLOR_FMT_P010: case COLOR_FMT_P010:
alignment = 128; stride = MSM_MEDIA_ALIGN(width * 2, 128);
stride = MSM_MEDIA_ALIGN(width*2, alignment);
break;
default:
break; break;
} }
invalid_input:
return stride; return stride;
} }
...@@ -906,10 +894,10 @@ static unsigned int VENUS_UV_STRIDE(int color_fmt, int width) ...@@ -906,10 +894,10 @@ static unsigned int VENUS_UV_STRIDE(int color_fmt, int width)
*/ */
static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
{ {
unsigned int alignment, sclines = 0; unsigned int sclines = 0;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV21: case COLOR_FMT_NV21:
...@@ -917,17 +905,14 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) ...@@ -917,17 +905,14 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
case COLOR_FMT_NV12_MVTB: case COLOR_FMT_NV12_MVTB:
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
case COLOR_FMT_P010: case COLOR_FMT_P010:
alignment = 32; sclines = MSM_MEDIA_ALIGN(height, 32);
break; break;
case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_NV12_BPP10_UBWC:
case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010_UBWC:
alignment = 16; sclines = MSM_MEDIA_ALIGN(height, 16);
break; break;
default:
return 0;
} }
sclines = MSM_MEDIA_ALIGN(height, alignment);
invalid_input:
return sclines; return sclines;
} }
...@@ -940,10 +925,10 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) ...@@ -940,10 +925,10 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
*/ */
static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
{ {
unsigned int alignment, sclines = 0; unsigned int sclines = 0;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV21: case COLOR_FMT_NV21:
...@@ -952,18 +937,13 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) ...@@ -952,18 +937,13 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
case COLOR_FMT_NV12_BPP10_UBWC: case COLOR_FMT_NV12_BPP10_UBWC:
case COLOR_FMT_P010_UBWC: case COLOR_FMT_P010_UBWC:
case COLOR_FMT_P010: case COLOR_FMT_P010:
alignment = 16; sclines = MSM_MEDIA_ALIGN((height + 1) >> 1, 16);
break; break;
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
alignment = 32; sclines = MSM_MEDIA_ALIGN((height + 1) >> 1, 32);
break; break;
default:
goto invalid_input;
} }
sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment);
invalid_input:
return sclines; return sclines;
} }
...@@ -976,10 +956,10 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) ...@@ -976,10 +956,10 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
*/ */
static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
{ {
int y_tile_width = 0, y_meta_stride = 0; int y_tile_width = 0, y_meta_stride;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
...@@ -990,14 +970,11 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) ...@@ -990,14 +970,11 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
y_tile_width = 48; y_tile_width = 48;
break; break;
default: default:
goto invalid_input; return 0;
} }
y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width); y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64); return MSM_MEDIA_ALIGN(y_meta_stride, 64);
invalid_input:
return y_meta_stride;
} }
/* /*
...@@ -1009,10 +986,10 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) ...@@ -1009,10 +986,10 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
*/ */
static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
{ {
int y_tile_height = 0, y_meta_scanlines = 0; int y_tile_height = 0, y_meta_scanlines;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
...@@ -1023,14 +1000,11 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) ...@@ -1023,14 +1000,11 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
y_tile_height = 4; y_tile_height = 4;
break; break;
default: default:
goto invalid_input; return 0;
} }
y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height); y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16); return MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
invalid_input:
return y_meta_scanlines;
} }
/* /*
...@@ -1042,10 +1016,10 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) ...@@ -1042,10 +1016,10 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
*/ */
static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
{ {
int uv_tile_width = 0, uv_meta_stride = 0; int uv_tile_width = 0, uv_meta_stride;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
...@@ -1056,14 +1030,11 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) ...@@ -1056,14 +1030,11 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
uv_tile_width = 24; uv_tile_width = 24;
break; break;
default: default:
goto invalid_input; return 0;
} }
uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width); uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width);
uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64); return MSM_MEDIA_ALIGN(uv_meta_stride, 64);
invalid_input:
return uv_meta_stride;
} }
/* /*
...@@ -1075,10 +1046,10 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) ...@@ -1075,10 +1046,10 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
*/ */
static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height)
{ {
int uv_tile_height = 0, uv_meta_scanlines = 0; int uv_tile_height = 0, uv_meta_scanlines;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_NV12_UBWC: case COLOR_FMT_NV12_UBWC:
...@@ -1089,22 +1060,19 @@ static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) ...@@ -1089,22 +1060,19 @@ static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height)
uv_tile_height = 4; uv_tile_height = 4;
break; break;
default: default:
goto invalid_input; return 0;
} }
uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height); uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height);
uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); return MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
invalid_input:
return uv_meta_scanlines;
} }
static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width)
{ {
unsigned int alignment = 0, stride = 0, bpp = 4; unsigned int alignment = 0, bpp = 4;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_RGBA8888: case COLOR_FMT_RGBA8888:
...@@ -1119,21 +1087,18 @@ static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) ...@@ -1119,21 +1087,18 @@ static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width)
alignment = 256; alignment = 256;
break; break;
default: default:
goto invalid_input; return 0;
} }
stride = MSM_MEDIA_ALIGN(width * bpp, alignment); return MSM_MEDIA_ALIGN(width * bpp, alignment);
invalid_input:
return stride;
} }
static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
{ {
unsigned int alignment = 0, scanlines = 0; unsigned int alignment = 0;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_RGBA8888: case COLOR_FMT_RGBA8888:
...@@ -1145,61 +1110,46 @@ static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) ...@@ -1145,61 +1110,46 @@ static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
alignment = 16; alignment = 16;
break; break;
default: default:
goto invalid_input; return 0;
} }
scanlines = MSM_MEDIA_ALIGN(height, alignment); return MSM_MEDIA_ALIGN(height, alignment);
invalid_input:
return scanlines;
} }
static unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width) static unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width)
{ {
int rgb_tile_width = 0, rgb_meta_stride = 0; int rgb_meta_stride;
if (!width) if (!width)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_RGBA8888_UBWC: case COLOR_FMT_RGBA8888_UBWC:
case COLOR_FMT_RGBA1010102_UBWC: case COLOR_FMT_RGBA1010102_UBWC:
case COLOR_FMT_RGB565_UBWC: case COLOR_FMT_RGB565_UBWC:
rgb_tile_width = 16; rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, 16);
break; return MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
default:
goto invalid_input;
} }
rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width); return 0;
rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
invalid_input:
return rgb_meta_stride;
} }
static unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height) static unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height)
{ {
int rgb_tile_height = 0, rgb_meta_scanlines = 0; int rgb_meta_scanlines;
if (!height) if (!height)
goto invalid_input; return 0;
switch (color_fmt) { switch (color_fmt) {
case COLOR_FMT_RGBA8888_UBWC: case COLOR_FMT_RGBA8888_UBWC:
case COLOR_FMT_RGBA1010102_UBWC: case COLOR_FMT_RGBA1010102_UBWC:
case COLOR_FMT_RGB565_UBWC: case COLOR_FMT_RGB565_UBWC:
rgb_tile_height = 4; rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, 4);
break; return MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
default:
goto invalid_input;
} }
rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height); return 0;
rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
invalid_input:
return rgb_meta_scanlines;
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment