mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-24 08:16:10 +00:00
tests/igt_fb: rename igt_get_all_formats to igt_get_all_cairo_formats
I recently had this discussion with Daniel where I didn't want to use igt_drm_format_to_bpp() because it uses the format_desc array, and igt_fb currently assumes that all the format_desc formats have a matching valid Cairo format, so I wouldn't be able to easily add formats such as ARGB2101010. The function that has the assumption mentioned above is igt_get_all_formats: its current users call igt_get_all_formats, and then call cairo-dependent functions, such as igt_get_cairo_ctx on the returned formats. In order to document the current behavior and prevent any problems in case we start adding new formats without matching Cairo versions to format_desc, rename igt_get_all_formats to igt_get_all_cairo_formats and make it explicitly check for CAIRO_FORMAT_INVALID. Requested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:
parent
55229f173e
commit
7ca55f433c
20
lib/igt_fb.c
20
lib/igt_fb.c
@ -1141,28 +1141,34 @@ const char *igt_format_str(uint32_t drm_format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* igt_get_all_formats:
|
* igt_get_all_cairo_formats:
|
||||||
* @formats: pointer to pointer to store the allocated formats array
|
* @formats: pointer to pointer to store the allocated formats array
|
||||||
* @format_count: pointer to integer to store the size of the allocated array
|
* @format_count: pointer to integer to store the size of the allocated array
|
||||||
*
|
*
|
||||||
* This functions returns an array of all the drm fourcc codes supported by this
|
* This functions returns an array of all the drm fourcc codes supported by
|
||||||
* library.
|
* cairo and this library.
|
||||||
*/
|
*/
|
||||||
void igt_get_all_formats(const uint32_t **formats, int *format_count)
|
void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count)
|
||||||
{
|
{
|
||||||
static uint32_t *drm_formats;
|
static uint32_t *drm_formats;
|
||||||
|
static int n_formats;
|
||||||
|
|
||||||
if (!drm_formats) {
|
if (!drm_formats) {
|
||||||
struct format_desc_struct *f;
|
struct format_desc_struct *f;
|
||||||
uint32_t *format;
|
uint32_t *format;
|
||||||
|
|
||||||
drm_formats = calloc(ARRAY_SIZE(format_desc),
|
n_formats = 0;
|
||||||
sizeof(*drm_formats));
|
for_each_format(f)
|
||||||
|
if (f->cairo_id != CAIRO_FORMAT_INVALID)
|
||||||
|
n_formats++;
|
||||||
|
|
||||||
|
drm_formats = calloc(n_formats, sizeof(*drm_formats));
|
||||||
format = &drm_formats[0];
|
format = &drm_formats[0];
|
||||||
for_each_format(f)
|
for_each_format(f)
|
||||||
|
if (f->cairo_id != CAIRO_FORMAT_INVALID)
|
||||||
*format++ = f->drm_id;
|
*format++ = f->drm_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
*formats = drm_formats;
|
*formats = drm_formats;
|
||||||
*format_count = ARRAY_SIZE(format_desc);
|
*format_count = n_formats;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
|
|||||||
uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
|
uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
|
||||||
uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
|
uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
|
||||||
const char *igt_format_str(uint32_t drm_format);
|
const char *igt_format_str(uint32_t drm_format);
|
||||||
void igt_get_all_formats(const uint32_t **formats, int *format_count);
|
void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count);
|
||||||
|
|
||||||
#endif /* __IGT_FB_H__ */
|
#endif /* __IGT_FB_H__ */
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ static uint32_t plane_get_igt_format(struct kms_atomic_plane_state *plane)
|
|||||||
plane_kms = drmModeGetPlane(plane->state->desc->fd, plane->obj);
|
plane_kms = drmModeGetPlane(plane->state->desc->fd, plane->obj);
|
||||||
igt_assert(plane_kms);
|
igt_assert(plane_kms);
|
||||||
|
|
||||||
igt_get_all_formats(&igt_formats, &num_igt_formats);
|
igt_get_all_cairo_formats(&igt_formats, &num_igt_formats);
|
||||||
for (i = 0; i < num_igt_formats; i++) {
|
for (i = 0; i < num_igt_formats; i++) {
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ static void test_connector(const char *test_name,
|
|||||||
int format_count;
|
int format_count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
igt_get_all_formats(&formats, &format_count);
|
igt_get_all_cairo_formats(&formats, &format_count);
|
||||||
for (i = 0; i < format_count; i++) {
|
for (i = 0; i < format_count; i++) {
|
||||||
if (intel_gen(intel_get_drm_devid(drm_fd)) < 4
|
if (intel_gen(intel_get_drm_devid(drm_fd)) < 4
|
||||||
&& formats[i] == DRM_FORMAT_XRGB2101010) {
|
&& formats[i] == DRM_FORMAT_XRGB2101010) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user