[igt-dev] [PATCH i-g-t] lib/igt_fb: Add cairo conversion to igt_fb_convert_with_stride, v2.
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Fri Apr 5 12:53:40 UTC 2019
Took a while to see what is happening, git made this patch look really
weird. Anyway, look ok to me.
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
On 3.4.2019 12.50, Maarten Lankhorst wrote:
> fb_convert() cannot convert to the HDR formats, so we need a fallback.
> When cairo is available on source and target format, create a surface
> for source and target. This way we can convert framebuffers directly
> when no direct conversion using fb_convert() is available.
>
> This is required to make the kms_chamelium.*-cmp-planes-random tests
> pass.
>
> Changes since v1:
> - Return fb_id in the cairo case.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> ---
> lib/igt_fb.c | 90 ++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 56 insertions(+), 34 deletions(-)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 6adf422228e8..a79b3f832c51 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -2976,53 +2976,75 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
> void *dst_ptr, *src_ptr;
> uint64_t base_modifier;
> int fb_id;
> + const struct format_desc_struct *src_format = lookup_drm_format(src->drm_format);
> + const struct format_desc_struct *dst_format = lookup_drm_format(dst_fourcc);
>
> if (is_vc4_device(src->fd))
> base_modifier = fourcc_mod_broadcom_mod(dst_modifier);
> else
> base_modifier = dst_modifier;
>
> - fb_id = igt_create_fb_with_bo_size(src->fd, src->width, src->height,
> - dst_fourcc,
> - LOCAL_DRM_FORMAT_MOD_NONE, &linear,
> - 0, dst_stride);
> - igt_assert(fb_id > 0);
> + if (src_format->cairo_id == CAIRO_FORMAT_INVALID ||
> + dst_format->cairo_id == CAIRO_FORMAT_INVALID) {
> + fb_id = igt_create_fb_with_bo_size(src->fd, src->width, src->height,
> + dst_fourcc,
> + LOCAL_DRM_FORMAT_MOD_NONE, &linear,
> + 0, dst_stride);
> + igt_assert(fb_id > 0);
>
> - src_ptr = igt_fb_map_buffer(src->fd, src);
> - igt_assert(src_ptr);
> + src_ptr = igt_fb_map_buffer(src->fd, src);
> + igt_assert(src_ptr);
>
> - dst_ptr = igt_fb_map_buffer(linear.fd, &linear);
> - igt_assert(dst_ptr);
> + dst_ptr = igt_fb_map_buffer(linear.fd, &linear);
> + igt_assert(dst_ptr);
>
> - cvt.dst.ptr = dst_ptr;
> - cvt.dst.fb = &linear;
> - cvt.src.ptr = src_ptr;
> - cvt.src.fb = src;
> - fb_convert(&cvt);
> + cvt.dst.ptr = dst_ptr;
> + cvt.dst.fb = &linear;
> + cvt.src.ptr = src_ptr;
> + cvt.src.fb = src;
> + fb_convert(&cvt);
>
> - igt_fb_unmap_buffer(dst, dst_ptr);
> - igt_fb_unmap_buffer(src, src_ptr);
> + igt_fb_unmap_buffer(dst, dst_ptr);
> + igt_fb_unmap_buffer(src, src_ptr);
>
> - switch (base_modifier) {
> - case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
> - fb_id = igt_vc4_fb_t_tiled_convert(dst, &linear);
> - break;
> - case DRM_FORMAT_MOD_BROADCOM_SAND32:
> - case DRM_FORMAT_MOD_BROADCOM_SAND64:
> - case DRM_FORMAT_MOD_BROADCOM_SAND128:
> - case DRM_FORMAT_MOD_BROADCOM_SAND256:
> - fb_id = vc4_fb_sand_tiled_convert(dst, &linear, dst_modifier);
> - break;
> - default:
> - igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
> - }
> + switch (base_modifier) {
> + case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
> + fb_id = igt_vc4_fb_t_tiled_convert(dst, &linear);
> + break;
> + case DRM_FORMAT_MOD_BROADCOM_SAND32:
> + case DRM_FORMAT_MOD_BROADCOM_SAND64:
> + case DRM_FORMAT_MOD_BROADCOM_SAND128:
> + case DRM_FORMAT_MOD_BROADCOM_SAND256:
> + fb_id = vc4_fb_sand_tiled_convert(dst, &linear, dst_modifier);
> + break;
> + default:
> + igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
> + }
>
> - igt_assert(fb_id > 0);
> + igt_assert(fb_id > 0);
>
> - if (dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE)
> - *dst = linear;
> - else
> - igt_remove_fb(linear.fd, &linear);
> + if (dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE)
> + *dst = linear;
> + else
> + igt_remove_fb(linear.fd, &linear);
> + } else {
> + /* Use the cairo api to convert */
> + cairo_surface_t *surf = igt_get_cairo_surface(src->fd, src);
> + cairo_t *cr;
> +
> + fb_id = igt_create_fb_with_bo_size(src->fd, src->width,
> + src->height, dst_fourcc,
> + dst_modifier, dst, 0,
> + dst_stride);
> + igt_assert(fb_id > 0);
> +
> + cr = igt_get_cairo_ctx(dst->fd, dst);
> + cairo_set_source_surface(cr, surf, 0, 0);
> + cairo_paint(cr);
> + igt_put_cairo_ctx(dst->fd, dst, cr);
> +
> + cairo_surface_destroy(surf);
> + }
>
> return fb_id;
> }
>
More information about the igt-dev
mailing list