[igt-dev] [PATCH i-g-t 2/8] lib/igt_fb: Pass format to igt_calc_fb_size

Mika Kahola mika.kahola at intel.com
Thu Jan 25 11:51:31 UTC 2018


On Tue, 2018-01-23 at 13:56 +0100, Maarten Lankhorst wrote:
> bpp is only sufficient to calculate dimensions for packed formats, in
> case of planar formats we need to pass the drm format fourcc, which
> will give us better information.
> 
> This is required for supporting planar framebuffers.
> 

Reviewed-by: Mika Kahola <mika.kahola at intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> ---
>  lib/igt_fb.c                     | 10 ++++++----
>  lib/igt_fb.h                     |  2 +-
>  tests/kms_frontbuffer_tracking.c |  4 +---
>  3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 39a83bae178a..da07d1a9e21f 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -147,7 +147,7 @@ void igt_get_fb_tile_size(int fd, uint64_t
> tiling, int fb_bpp,
>   * @fd: the DRM file descriptor
>   * @width: width of the framebuffer in pixels
>   * @height: height of the framebuffer in pixels
> - * @bpp: bytes per pixel of the framebuffer
> + * @format: drm fourcc pixel format code
>   * @tiling: tiling layout of the framebuffer (as framebuffer
> modifier)
>   * @size_ret: returned size for the framebuffer
>   * @stride_ret: returned stride for the framebuffer
> @@ -155,10 +155,11 @@ void igt_get_fb_tile_size(int fd, uint64_t
> tiling, int fb_bpp,
>   * This function returns valid stride and size values for a
> framebuffer with the
>   * specified parameters.
>   */
> -void igt_calc_fb_size(int fd, int width, int height, int bpp,
> uint64_t tiling,
> +void igt_calc_fb_size(int fd, int width, int height, uint32_t
> format, uint64_t tiling,
>  		      unsigned *size_ret, unsigned *stride_ret)
>  {
>  	unsigned int tile_width, tile_height, stride, size;
> +	int bpp = igt_drm_format_to_bpp(format);
>  	int byte_width = width * (bpp / 8);
>  
>  	igt_get_fb_tile_size(fd, tiling, bpp, &tile_width,
> &tile_height);
> @@ -249,13 +250,12 @@ static int create_bo_for_fb(int fd, int width,
> int height, uint32_t format,
>  			    unsigned *size_ret, unsigned
> *stride_ret,
>  			    bool *is_dumb)
>  {
> -	int bpp = igt_drm_format_to_bpp(format);
>  	int bo;
>  
>  	if (tiling || size || stride) {
>  		unsigned calculated_size, calculated_stride;
>  
> -		igt_calc_fb_size(fd, width, height, bpp, tiling,
> +		igt_calc_fb_size(fd, width, height, format, tiling,
>  				 &calculated_size,
> &calculated_stride);
>  		if (stride == 0)
>  			stride = calculated_stride;
> @@ -290,6 +290,8 @@ static int create_bo_for_fb(int fd, int width,
> int height, uint32_t format,
>  			return -EINVAL;
>  		}
>  	} else {
> +		int bpp = igt_drm_format_to_bpp(format);
> +
>  		if (is_dumb)
>  			*is_dumb = true;
>  
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 3004f0656029..152798e9896b 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -90,7 +90,7 @@ enum igt_text_align {
>  
>  void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
>  			  unsigned *width_ret, unsigned
> *height_ret);
> -void igt_calc_fb_size(int fd, int width, int height, int bpp,
> uint64_t tiling,
> +void igt_calc_fb_size(int fd, int width, int height, uint32_t
> format, uint64_t tiling,
>  		      unsigned *size_ret, unsigned *stride_ret);
>  unsigned int
>  igt_create_fb_with_bo_size(int fd, int width, int height,
> diff --git a/tests/kms_frontbuffer_tracking.c
> b/tests/kms_frontbuffer_tracking.c
> index 1601cab45b9a..ea5297538c34 100644
> --- a/tests/kms_frontbuffer_tracking.c
> +++ b/tests/kms_frontbuffer_tracking.c
> @@ -541,7 +541,6 @@ static void create_fb(enum pixel_format pformat,
> int width, int height,
>  {
>  	uint32_t format;
>  	unsigned int size, stride;
> -	int bpp;
>  	uint64_t tiling_for_size;
>  
>  	switch (pformat) {
> @@ -576,13 +575,12 @@ static void create_fb(enum pixel_format
> pformat, int width, int height,
>  	 * the same size regardless of tiling since we want to
> properly exercise
>  	 * the Kernel's specific tiling-checking code paths without
> accidentally
>  	 * hitting size-checking ones first. */
> -	bpp = igt_drm_format_to_bpp(format);
>  	if (plane == PLANE_CUR)
>  		tiling_for_size = LOCAL_DRM_FORMAT_MOD_NONE;
>  	else
>  		tiling_for_size = opt.tiling;
>  
> -	igt_calc_fb_size(drm.fd, width, height, bpp,
> tiling_for_size, &size,
> +	igt_calc_fb_size(drm.fd, width, height, format,
> tiling_for_size, &size,
>  			 &stride);
>  
>  	igt_create_fb_with_bo_size(drm.fd, width, height, format,
> tiling, fb,
-- 
Mika Kahola - Intel OTC



More information about the igt-dev mailing list