Re: [Freedreno] [PATCH 11/11] drm/msm/dpu: Clean up dpu_media_info.h static inline functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 05, 2018 at 04:31:03PM -0700, Jordan Crouse wrote:
> Do some cleanup in the static inline functions defined in
> dpu_media_info.h by cleaning up gotos and unneeded local
> variables.
> 
> Signed-off-by: Jordan Crouse <jcrouse@xxxxxxxxxxxxxx>
> ---
>  .../gpu/drm/msm/disp/dpu1/msm_media_info.h    | 164 ++++++------------
>  1 file changed, 57 insertions(+), 107 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h b/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h
> index 75470ee5b18f..8b8309f25c1a 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h
> +++ b/drivers/gpu/drm/msm/disp/dpu1/msm_media_info.h
> @@ -822,36 +822,30 @@ enum color_fmts {
>   */
>  static unsigned int VENUS_Y_STRIDE(int color_fmt, int width)
>  {
> -	unsigned int alignment, stride = 0;
> +	unsigned int stride = 0;
>  
>  	if (!width)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV21:
>  	case COLOR_FMT_NV12:
>  	case COLOR_FMT_NV12_MVTB:
>  	case COLOR_FMT_NV12_UBWC:
> -		alignment = 128;
> -		stride = MSM_MEDIA_ALIGN(width, alignment);
> +		stride = MSM_MEDIA_ALIGN(width, 128);
>  		break;
>  	case COLOR_FMT_NV12_BPP10_UBWC:
> -		alignment = 256;
>  		stride = MSM_MEDIA_ALIGN(width, 192);
> -		stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
> +		stride = MSM_MEDIA_ALIGN(stride * 4/3, 256);

nit: Can you please surround the binary operators with spaces? This applies
everywhere in the patch.

With that,

Reviewed-by: Sean Paul <sean@xxxxxxxxxx>


>  		break;
>  	case COLOR_FMT_P010_UBWC:
> -		alignment = 256;
> -		stride = MSM_MEDIA_ALIGN(width * 2, alignment);
> +		stride = MSM_MEDIA_ALIGN(width * 2, 256);
>  		break;
>  	case COLOR_FMT_P010:
> -		alignment = 128;
> -		stride = MSM_MEDIA_ALIGN(width*2, alignment);
> -		break;
> -	default:
> +		stride = MSM_MEDIA_ALIGN(width * 2, 128);
>  		break;
>  	}
> -invalid_input:
> +
>  	return stride;
>  }
>  
> @@ -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)
>  {
> -	unsigned int alignment, stride = 0;
> +	unsigned int stride = 0;
>  
>  	if (!width)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV21:
>  	case COLOR_FMT_NV12:
>  	case COLOR_FMT_NV12_MVTB:
>  	case COLOR_FMT_NV12_UBWC:
> -		alignment = 128;
> -		stride = MSM_MEDIA_ALIGN(width, alignment);
> +		stride = MSM_MEDIA_ALIGN(width, 128);
>  		break;
>  	case COLOR_FMT_NV12_BPP10_UBWC:
> -		alignment = 256;
>  		stride = MSM_MEDIA_ALIGN(width, 192);
> -		stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment);
> +		stride = MSM_MEDIA_ALIGN(stride * 4/3, 256);
>  		break;
>  	case COLOR_FMT_P010_UBWC:
> -		alignment = 256;
> -		stride = MSM_MEDIA_ALIGN(width * 2, alignment);
> +		stride = MSM_MEDIA_ALIGN(width * 2, 256);
>  		break;
>  	case COLOR_FMT_P010:
> -		alignment = 128;
> -		stride = MSM_MEDIA_ALIGN(width*2, alignment);
> -		break;
> -	default:
> +		stride = MSM_MEDIA_ALIGN(width*2, 128);
>  		break;
>  	}
> -invalid_input:
> +
>  	return stride;
>  }
>  
> @@ -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)
>  {
> -	unsigned int alignment, sclines = 0;
> +	unsigned int sclines = 0;
>  
>  	if (!height)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV21:
> @@ -917,17 +905,14 @@ static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height)
>  	case COLOR_FMT_NV12_MVTB:
>  	case COLOR_FMT_NV12_UBWC:
>  	case COLOR_FMT_P010:
> -		alignment = 32;
> +		sclines = MSM_MEDIA_ALIGN(height, 32);
>  		break;
>  	case COLOR_FMT_NV12_BPP10_UBWC:
>  	case COLOR_FMT_P010_UBWC:
> -		alignment = 16;
> +		sclines = MSM_MEDIA_ALIGN(height, 16);
>  		break;
> -	default:
> -		return 0;
>  	}
> -	sclines = MSM_MEDIA_ALIGN(height, alignment);
> -invalid_input:
> +
>  	return sclines;
>  }
>  
> @@ -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)
>  {
> -	unsigned int alignment, sclines = 0;
> +	unsigned int sclines = 0;
>  
>  	if (!height)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV21:
> @@ -952,18 +937,13 @@ static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height)
>  	case COLOR_FMT_NV12_BPP10_UBWC:
>  	case COLOR_FMT_P010_UBWC:
>  	case COLOR_FMT_P010:
> -		alignment = 16;
> +		sclines = MSM_MEDIA_ALIGN((height+1)>>1, 16);
>  		break;
>  	case COLOR_FMT_NV12_UBWC:
> -		alignment = 32;
> +		sclines = MSM_MEDIA_ALIGN((height+1)>>1, 32);
>  		break;
> -	default:
> -		goto invalid_input;
>  	}
>  
> -	sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment);
> -
> -invalid_input:
>  	return sclines;
>  }
>  
> @@ -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)
>  {
> -	int y_tile_width = 0, y_meta_stride = 0;
> +	int y_tile_width = 0, y_meta_stride;
>  
>  	if (!width)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV12_UBWC:
> @@ -990,14 +970,11 @@ static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width)
>  		y_tile_width = 48;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
>  	y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width);
> -	y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64);
> -
> -invalid_input:
> -	return y_meta_stride;
> +	return MSM_MEDIA_ALIGN(y_meta_stride, 64);
>  }
>  
>  /*
> @@ -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)
>  {
> -	int y_tile_height = 0, y_meta_scanlines = 0;
> +	int y_tile_height = 0, y_meta_scanlines;
>  
>  	if (!height)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV12_UBWC:
> @@ -1023,14 +1000,11 @@ static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height)
>  		y_tile_height = 4;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
>  	y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height);
> -	y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
> -
> -invalid_input:
> -	return y_meta_scanlines;
> +	return MSM_MEDIA_ALIGN(y_meta_scanlines, 16);
>  }
>  
>  /*
> @@ -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)
>  {
> -	int uv_tile_width = 0, uv_meta_stride = 0;
> +	int uv_tile_width = 0, uv_meta_stride;
>  
>  	if (!width)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV12_UBWC:
> @@ -1056,14 +1030,11 @@ static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width)
>  		uv_tile_width = 24;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
>  	uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width);
> -	uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64);
> -
> -invalid_input:
> -	return uv_meta_stride;
> +	return MSM_MEDIA_ALIGN(uv_meta_stride, 64);
>  }
>  
>  /*
> @@ -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)
>  {
> -	int uv_tile_height = 0, uv_meta_scanlines = 0;
> +	int uv_tile_height = 0, uv_meta_scanlines;
>  
>  	if (!height)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_NV12_UBWC:
> @@ -1089,22 +1060,19 @@ static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height)
>  		uv_tile_height = 4;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
>  	uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height);
> -	uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
> -
> -invalid_input:
> -	return uv_meta_scanlines;
> +	return MSM_MEDIA_ALIGN(uv_meta_scanlines, 16);
>  }
>  
>  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)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_RGBA8888:
> @@ -1119,21 +1087,18 @@ static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width)
>  		alignment = 256;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
> -	stride = MSM_MEDIA_ALIGN(width * bpp, alignment);
> -
> -invalid_input:
> -	return stride;
> +	return MSM_MEDIA_ALIGN(width * bpp, alignment);
>  }
>  
>  static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
>  {
> -	unsigned int alignment = 0, scanlines = 0;
> +	unsigned int alignment = 0;
>  
>  	if (!height)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_RGBA8888:
> @@ -1145,61 +1110,46 @@ static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height)
>  		alignment = 16;
>  		break;
>  	default:
> -		goto invalid_input;
> +		return 0;
>  	}
>  
> -	scanlines = MSM_MEDIA_ALIGN(height, alignment);
> -
> -invalid_input:
> -	return scanlines;
> +	return MSM_MEDIA_ALIGN(height, alignment);
>  }
>  
>  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)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_RGBA8888_UBWC:
>  	case COLOR_FMT_RGBA1010102_UBWC:
>  	case COLOR_FMT_RGB565_UBWC:
> -		rgb_tile_width = 16;
> -		break;
> -	default:
> -		goto invalid_input;
> +		rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, 16);
> +		return MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
>  	}
>  
> -	rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width);
> -	rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64);
> -
> -invalid_input:
> -	return rgb_meta_stride;
> +	return 0;
>  }
>  
>  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)
> -		goto invalid_input;
> +		return 0;
>  
>  	switch (color_fmt) {
>  	case COLOR_FMT_RGBA8888_UBWC:
>  	case COLOR_FMT_RGBA1010102_UBWC:
>  	case COLOR_FMT_RGB565_UBWC:
> -		rgb_tile_height = 4;
> -		break;
> -	default:
> -		goto invalid_input;
> +		rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, 4);
> +		return MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
>  	}
>  
> -	rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height);
> -	rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16);
> -
> -invalid_input:
> -	return rgb_meta_scanlines;
> +	return 0;
>  }
>  
>  #endif
> -- 
> 2.18.0
> 
> _______________________________________________
> Freedreno mailing list
> Freedreno@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/freedreno

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux