All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: dri-devel@lists.freedesktop.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH libdrm v2 10/10] modetest: Add SMPTE pattern support for C4 format
Date: Fri,  8 Jul 2022 20:21:40 +0200	[thread overview]
Message-ID: <03a793cccc36106067efaed6793c0c2900b1fb61.1657302034.git.geert@linux-m68k.org> (raw)
In-Reply-To: <cover.1657302034.git.geert@linux-m68k.org>

Add support for drawing the SMPTE pattern in buffers using a
color-indexed frame buffer formats with two, four, or sixteen colors.

Note that this still uses 256 as the CLUT size, as
DRM_IOCTL_MODE_SETGAMMA enforces that the size matches against the
(fixed) gamma size, while the CLUT size depends on the format.

Move clearing the color LUT entries from util_smpte_index_gamma() to its
caller, as only the caller knows how many entries there really are
(currently DRM always assumes 256 entries).

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
v2:
  - Split off changes to tests/modetest/modetest.c,
  - Add C1 and C2 support.

The linuxdoc comments say userspace can query the gamma size:

 * drm_mode_gamma_set_ioctl - set the gamma table
 *
 * Set the gamma table of a CRTC to the one passed in by the user. Userspace can
 * inquire the required gamma table size through drm_mode_gamma_get_ioctl.

 * drm_mode_gamma_get_ioctl - get the gamma table
 *
 * Copy the current gamma table into the storage provided. This also provides
 * the gamma table size the driver expects, which can be used to size the
 * allocated storage.

but the code doesn't seem to support that in an easy way (like setting
red/green/blue to NULL on input, retrieving gamma_size on output), only
by providing big enough buffers for red/green/blue, and looping over
gamma_size until -EINVAL is no longer returned.
---
 tests/modetest/modetest.c | 9 ++++++---
 tests/util/pattern.c      | 1 -
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 11a39ada80579293..1d87046f0fdfaf24 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1129,13 +1129,16 @@ static bool add_property_optional(struct device *dev, uint32_t obj_id,
 static void set_gamma(struct device *dev, unsigned crtc_id, unsigned fourcc)
 {
 	unsigned blob_id = 0;
+	const struct util_format_info *info;
 	/* TODO: support 1024-sized LUTs, when the use-case arises */
 	struct drm_color_lut gamma_lut[256];
 	int i, ret;
 
-	if (fourcc == DRM_FORMAT_C8) {
-		/* TODO: Add C8 support for more patterns */
-		util_smpte_index_gamma(256, gamma_lut);
+	info = util_format_info_find(fourcc);
+	if (info->ncolors) {
+		memset(gamma_lut, 0, sizeof(gamma_lut));
+		/* TODO: Add index support for more patterns */
+		util_smpte_index_gamma(info->ncolors, gamma_lut);
 		drmModeCreatePropertyBlob(dev->fd, gamma_lut, sizeof(gamma_lut), &blob_id);
 	} else {
 		for (i = 0; i < 256; i++) {
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index a5c4e31ad856709e..631114563fa011c2 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -990,7 +990,6 @@ void util_smpte_index_gamma(unsigned size, struct drm_color_lut *lut)
 		printf("Error: gamma too small: %u < 2\n", size);
 		return;
 	}
-	memset(lut, 0, size * sizeof(struct drm_color_lut));
 
 #define FILL_COLOR(idx, r, g, b) \
 	lut[idx].red = (r) * 0x101; \
-- 
2.25.1


  parent reply	other threads:[~2022-07-08 18:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08 18:21 [PATCH libdrm v2 00/10] Add support for low-color frame buffer formats Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 01/10] util: Improve SMPTE color LUT accuracy Geert Uytterhoeven
2022-07-10 10:31   ` Sam Ravnborg
2022-07-10 11:04     ` Geert Uytterhoeven
2022-07-10 11:55       ` Sam Ravnborg
2022-07-12  9:05         ` Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 02/10] util: Factor out and optimize C8 SMPTE color LUT Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH/RFC libdrm v2 03/10] drm_fourcc: Add DRM_FORMAT_C[124] Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 04/10] util: Add support for DRM_FORMAT_C[124] Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 05/10] util: Store number of colors for indexed formats Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 06/10] util: Add SMPTE pattern support for C4 format Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 07/10] util: Add SMPTE pattern support for C1 format Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 08/10] util: Add SMPTE pattern support for C2 format Geert Uytterhoeven
2022-07-08 18:21 ` [PATCH libdrm v2 09/10] modetest: Add support for DRM_FORMAT_C[124] Geert Uytterhoeven
2022-07-08 18:21 ` Geert Uytterhoeven [this message]
2022-07-10 10:40 ` [PATCH libdrm v2 00/10] Add support for low-color frame buffer formats Sam Ravnborg
2022-07-10 12:15   ` Geert Uytterhoeven

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=03a793cccc36106067efaed6793c0c2900b1fb61.1657302034.git.geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=dri-devel@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.