[igt-dev] [PATCH i-g-t 3/5] lib/igt_fb: move the CTS fill framebuffer to igt_fb lib
Petri Latvala
petri.latvala at intel.com
Tue Sep 15 07:37:53 UTC 2020
On Thu, Sep 03, 2020 at 05:54:37PM -0700, Abhinav Kumar wrote:
> The function to fill the framebuffer with the CTS pattern
> is generic. Move it to the igt_fb layer so that it can be used by
> other modules.
>
> Signed-off-by: Abhinav Kumar <abhinavk at codeaurora.org>
Reviewed-by: Petri Latvala <petri.latvala at intel.com>
> ---
> lib/igt_fb.c | 65 ++++++++++++++++++++++++++++++++++
> lib/igt_fb.h | 3 ++
> tools/intel_dp_compliance.c | 70 ++++++-------------------------------
> 3 files changed, 78 insertions(+), 60 deletions(-)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 3864b7a1..d6f0b9ed 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -1,4 +1,5 @@
> /*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.
> * Copyright © 2013,2014 Intel Corporation
> *
> * Permission is hereby granted, free of charge, to any person obtaining a
> @@ -1280,6 +1281,70 @@ void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
> cairo_fill(cr);
> }
>
> +/**
> + * igt_fill_cts_framebuffer:
> + * @pixmap: handle to the mapped buffer
> + * @video_width: required width for the CTS pattern
> + * @video_height: required height for the CTS pattern
> + * @bitdepth: required bitdepth for the CTS pattern
> + * @alpha: required alpha for the CTS pattern
> + * This functions draws the CTS test pattern for a given width, height.
> + */
> +int igt_fill_cts_framebuffer(uint32_t *pixmap, uint32_t video_width,
> + uint32_t video_height, uint32_t bitdepth, int alpha)
> +{
> + uint32_t tile_height, tile_width;
> + uint32_t *red_ptr, *green_ptr, *blue_ptr;
> + uint32_t *white_ptr, *src_ptr, *dst_ptr;
> + int x, y;
> + int32_t pixel_val;
> +
> + tile_height = 64;
> + tile_width = 1 << bitdepth;
> +
> + red_ptr = pixmap;
> + green_ptr = red_ptr + (video_width * tile_height);
> + blue_ptr = green_ptr + (video_width * tile_height);
> + white_ptr = blue_ptr + (video_width * tile_height);
> + x = 0;
> +
> + /* Fill the frame buffer with video pattern from CTS 3.1.5 */
> + while (x < video_width) {
> + for (pixel_val = 0; pixel_val < 256;
> + pixel_val = pixel_val + (256 / tile_width)) {
> + red_ptr[x] = alpha << 24 | pixel_val << 16;
> + green_ptr[x] = alpha << 24 | pixel_val << 8;
> + blue_ptr[x] = alpha << 24 | pixel_val << 0;
> + white_ptr[x] = alpha << 24 | red_ptr[x] | green_ptr[x] |
> + blue_ptr[x];
> + if (++x >= video_width)
> + break;
> + }
> + }
> + for (y = 0; y < video_height; y++) {
> + if (y == 0 || y == 64 || y == 128 || y == 192)
> + continue;
> + switch ((y / tile_height) % 4) {
> + case 0:
> + src_ptr = red_ptr;
> + break;
> + case 1:
> + src_ptr = green_ptr;
> + break;
> + case 2:
> + src_ptr = blue_ptr;
> + break;
> + case 3:
> + src_ptr = white_ptr;
> + break;
> + }
> + dst_ptr = pixmap + (y * video_width);
> + memcpy(dst_ptr, src_ptr, (video_width * 4));
> + }
> +
> + return 0;
> +}
> +
> /**
> * igt_paint_color_alpha:
> * @cr: cairo drawing context
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 5ec906b7..a1f94503 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -1,4 +1,5 @@
> /*
> + * Copyright (c) 2020, The Linux Foundation. All rights reserved.
> * Copyright © 2013,2014 Intel Corporation
> *
> * Permission is hereby granted, free of charge, to any person obtaining a
> @@ -206,6 +207,8 @@ bool igt_format_is_fp16(uint32_t drm_format);
> int igt_format_plane_bpp(uint32_t drm_format, int plane);
> void igt_format_array_fill(uint32_t **formats_array, unsigned int *count,
> bool allow_yuv);
> +int igt_fill_cts_framebuffer(uint32_t *pixmap, uint32_t video_width,
> + uint32_t video_height, uint32_t bitdepth, int alpha);
>
> #endif /* __IGT_FB_H__ */
>
> diff --git a/tools/intel_dp_compliance.c b/tools/intel_dp_compliance.c
> index fc512711..c8c5c841 100644
> --- a/tools/intel_dp_compliance.c
> +++ b/tools/intel_dp_compliance.c
> @@ -448,70 +448,12 @@ static int setup_video_pattern_framebuffer(struct connector *dp_conn)
>
> }
>
> -static int fill_framebuffer(struct connector *dp_conn)
> -{
> - uint32_t tile_height, tile_width, video_width, video_height;
> - uint32_t *red_ptr, *green_ptr, *blue_ptr, *white_ptr, *src_ptr, *dst_ptr;
> - int x, y;
> - int32_t pixel_val;
> - uint8_t alpha;
> -
> - video_width = dp_conn->test_pattern.hdisplay;
> - video_height = dp_conn->test_pattern.vdisplay;
> -
> - tile_height = 64;
> - tile_width = 1 << (dp_conn->test_pattern.bitdepth);
> -
> - red_ptr = dp_conn->test_pattern.pixmap;
> - green_ptr = red_ptr + (video_width * tile_height);
> - blue_ptr = green_ptr + (video_width * tile_height);
> - white_ptr = blue_ptr + (video_width * tile_height);
> - x = 0;
> -
> - /* Fill the frame buffer with video pattern from CTS 3.1.5 */
> - while (x < video_width) {
> - for (pixel_val = 0; pixel_val < 256;
> - pixel_val = pixel_val + (256 / tile_width)) {
> - alpha = gen == 10 ? 0xff : 0;
> - red_ptr[x] = alpha << 24 | pixel_val << 16;
> - green_ptr[x] = alpha << 24 | pixel_val << 8;
> - blue_ptr[x] = alpha << 24 | pixel_val << 0;
> - white_ptr[x] = alpha << 24 | red_ptr[x] | green_ptr[x] |
> - blue_ptr[x];
> - if (++x >= video_width)
> - break;
> - }
> - }
> - for (y = 0; y < video_height; y++) {
> - if (y == 0 || y == 64 || y == 128 || y == 192)
> - continue;
> - switch ((y / tile_height) % 4) {
> - case 0:
> - src_ptr = red_ptr;
> - break;
> - case 1:
> - src_ptr = green_ptr;
> - break;
> - case 2:
> - src_ptr = blue_ptr;
> - break;
> - case 3:
> - src_ptr = white_ptr;
> - break;
> - }
> - dst_ptr = dp_conn->test_pattern.pixmap + (y * video_width);
> - memcpy(dst_ptr, src_ptr, (video_width * 4));
> - }
> - munmap(dp_conn->test_pattern.pixmap,
> - dp_conn->test_pattern.size);
> - return 0;
> -}
> -
> static int set_test_mode(struct connector *dp_conn)
> {
> int ret = 0;
> int i;
> bool found_std = false, found_fs = false;
> + uint32_t alpha;
> drmModeConnector *c = dp_conn->connector;
>
> /* Ignore any disconnected devices */
> @@ -584,6 +526,7 @@ static int set_test_mode(struct connector *dp_conn)
> dp_conn->test_pattern.hdisplay = hdisplay;
> dp_conn->test_pattern.vdisplay = vdisplay;
> dp_conn->test_pattern.bitdepth = bitdepth;
> + alpha = gen == 10 ? 0xff : 0;
>
> ret = setup_video_pattern_framebuffer(dp_conn);
> if (ret) {
> @@ -592,12 +535,19 @@ static int set_test_mode(struct connector *dp_conn)
> return ret;
> }
>
> - ret = fill_framebuffer(dp_conn);
> + ret = igt_fill_cts_framebuffer(dp_conn->test_pattern.pixmap,
> + dp_conn->test_pattern.hdisplay,
> + dp_conn->test_pattern.vdisplay,
> + dp_conn->test_pattern.bitdepth,
> + alpha);
> if (ret) {
> igt_warn("Filling framebuffer for connector %u failed (%d)\n",
> c->connector_id, ret);
> return ret;
> }
> + /* unmapping the buffer previously mapped during setup */
> + munmap(dp_conn->test_pattern.pixmap,
> + dp_conn->test_pattern.size);
> }
>
> return ret;
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
More information about the igt-dev
mailing list