[i-g-t,8/9] lib/igt_fb: Add a helper to retreive the plane bpp for a given format

Submitted by Paul Kocialkowski on Dec. 6, 2018, 2:11 p.m.

Details

Message ID 20181206141132.23349-9-paul.kocialkowski@bootlin.com
State New
Series "Chamelium VC4 plane testing, with T-tiled mode"
Headers show

Commit Message

Paul Kocialkowski Dec. 6, 2018, 2:11 p.m.
The format bpp for a given plane is stored in the static format_desc
structure and is not accessible to tests, which is inconvenient to
get the minimum stride for a format when testing various strides.

Add a simple helper to expose the information.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_fb.c | 16 ++++++++++++++++
 lib/igt_fb.h |  1 +
 2 files changed, 17 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 1548bf4e..b02f7f22 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2416,3 +2416,19 @@  bool igt_format_is_yuv(uint32_t drm_format)
 		return false;
 	}
 }
+
+/**
+ * igt_format_plane_bpp:
+ * @drm_format: drm fourcc
+ * @plane: format plane index
+ *
+ * This functions returns the number of bits per pixel for the given @plane
+ * index of the @drm_format.
+ */
+int igt_format_plane_bpp(uint32_t drm_format, int plane)
+{
+	const struct format_desc_struct *format =
+		lookup_drm_format(drm_format);
+
+	return format->plane_bpp[plane];
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index cb21fdbc..a39c4d2f 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -175,6 +175,7 @@  uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
 const char *igt_format_str(uint32_t drm_format);
 bool igt_fb_supported_format(uint32_t drm_format);
 bool igt_format_is_yuv(uint32_t drm_format);
+int igt_format_plane_bpp(uint32_t drm_format, int plane);
 
 #endif /* __IGT_FB_H__ */
 

Comments

Lyude Paul Dec. 6, 2018, 10:58 p.m.
Reviewed-by: Lyude Paul <lyude@redhat.com>

On Thu, 2018-12-06 at 15:11 +0100, Paul Kocialkowski wrote:
> The format bpp for a given plane is stored in the static format_desc
> structure and is not accessible to tests, which is inconvenient to
> get the minimum stride for a format when testing various strides.
> 
> Add a simple helper to expose the information.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  lib/igt_fb.c | 16 ++++++++++++++++
>  lib/igt_fb.h |  1 +
>  2 files changed, 17 insertions(+)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 1548bf4e..b02f7f22 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -2416,3 +2416,19 @@ bool igt_format_is_yuv(uint32_t drm_format)
>  		return false;
>  	}
>  }
> +
> +/**
> + * igt_format_plane_bpp:
> + * @drm_format: drm fourcc
> + * @plane: format plane index
> + *
> + * This functions returns the number of bits per pixel for the given @plane
> + * index of the @drm_format.
> + */
> +int igt_format_plane_bpp(uint32_t drm_format, int plane)
> +{
> +	const struct format_desc_struct *format =
> +		lookup_drm_format(drm_format);
> +
> +	return format->plane_bpp[plane];
> +}
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index cb21fdbc..a39c4d2f 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -175,6 +175,7 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
>  const char *igt_format_str(uint32_t drm_format);
>  bool igt_fb_supported_format(uint32_t drm_format);
>  bool igt_format_is_yuv(uint32_t drm_format);
> +int igt_format_plane_bpp(uint32_t drm_format, int plane);
>  
>  #endif /* __IGT_FB_H__ */
>