Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Abhinav Kumar <abhinavk@codeaurora.org>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com, swboyd@chromium.org,
	khsieh@codeaurora.org, nganji@codeaurora.org,
	seanpaul@chromium.org, tanmay@codeaurora.org,
	aravindh@codeaurora.org
Subject: [igt-dev] [PATCH i-g-t v2 3/5] lib/igt_fb: move the CTS fill framebuffer to igt_fb lib
Date: Tue, 15 Sep 2020 12:56:12 -0700	[thread overview]
Message-ID: <20200915195614.7618-4-abhinavk@codeaurora.org> (raw)
In-Reply-To: <20200915195614.7618-1-abhinavk@codeaurora.org>

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.

changes in v2: none

Signed-off-by: Abhinav Kumar <abhinavk@codeaurora.org>
Reviewed-by: Petri Latvala <petri.latvala@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 5e3706e9..d19b9c8b 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 debfb5ad..b36db965 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);
 
 int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc);
 
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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-09-15 19:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 19:56 [igt-dev] [PATCH i-g-t v2 0/5] Add support for video pattern DP CTS for MSM chipsets Abhinav Kumar
2020-09-15 19:56 ` [igt-dev] [PATCH i-g-t v2 2/5] lib/igt_kms: move some of the useful dump functions to igt_kms Abhinav Kumar
2020-09-16  8:14   ` Petri Latvala
2020-09-16  8:38     ` Petri Latvala
2020-09-15 19:56 ` Abhinav Kumar [this message]
2020-09-15 19:56 ` [igt-dev] [PATCH i-g-t v2 4/5] tools: move terminal utility functions to a separate file Abhinav Kumar
2020-09-15 19:56 ` [igt-dev] [PATCH i-g-t v2 5/5] tools: add support for msm_dp_compliance to IGT Abhinav Kumar
2020-09-15 20:46 ` [igt-dev] ✓ Fi.CI.BAT: success for Add support for video pattern DP CTS for MSM chipsets (rev2) Patchwork
2020-09-16  1:00 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200915195614.7618-4-abhinavk@codeaurora.org \
    --to=abhinavk@codeaurora.org \
    --cc=aravindh@codeaurora.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=khsieh@codeaurora.org \
    --cc=nganji@codeaurora.org \
    --cc=petri.latvala@intel.com \
    --cc=seanpaul@chromium.org \
    --cc=swboyd@chromium.org \
    --cc=tanmay@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox