From patchwork Fri Nov 22 16:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BBE1E69173 for ; Fri, 22 Nov 2024 16:19:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20ECD10EBF1; Fri, 22 Nov 2024 16:19:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Y0rcMQRZ"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B80910EBF1 for ; Fri, 22 Nov 2024 16:19:08 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4ABF760002; Fri, 22 Nov 2024 16:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oKPlLz9ZC/4CRqq8g5QxpCOYxnAFDUMpkF+GuYmvk1M=; b=Y0rcMQRZ87KOYYj7QFPuC805fGXo7mDiUEK08eJhLub5cGgQwQ6g3qogT4Y7IIXzDgwwIa bAZqaFAin2TjsKpJDLIDQs5bqMAhT+5pgKv9cXXKs9R1DCLlDdd6ooV09TD3sc98qi3gNy tXHnPTyAYhmbdBtLFESRoMjC/qVOshaZZLtcb4nhfzC9PvMSJXodqlfXKDXDTRbpxHxVwe MD7K/19DVQxStdKIDMzjHjaPY/Yy9IyIax6T1A6++r5ojIoPlhipQu5my7CYh5s3pLYZn9 X0VAsTWwHuzq+PeEk0E/QvoFBYVJ74zUifxfk9GXFgcqNz5p296jk6DHbGXCaw== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:01 +0100 Subject: [PATCH v3 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-1-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7839; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=DCSX226vwuqHCnEOZmjENkcyjWmhEEVjaWFvKST7rQA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK722R/bG0K6WvwaRwCUYT/w1exnxyDqkxYoS KZAhjrNluKJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9gAKCRAgrS7GWxAs 4hvlD/0eRnqUgUxXeZE0S4l61LADGbz8ze6ecWrwWuBggsKiV95RyiCUzadelagBjKTsTPk0p0r 49ha4Q2txnEXIk1ttBm9RYanew1LPukbkMXfrLVWHPDrc0/w9UmoGV1HJKrmxtitgg4RMpeiT4S vurgOEWtjaSqVYeVwbuAOeCd7a8JVML+ZJQEaHYKpJLtWBB64S9VoMKvJDAmgHYoQHncWRvKmun 88wS6WzEKIkZx/zq5bOXx9hBy4+Y7LXqeE+igIorKtcIXoo+4pY/YR2a7B60AIyNThyhjF+Z32p XmwCyD1nxPUYGU3hJF2e6sURHELneUFgJQkcsMhrZmLd4a/NNTqkTq8snBNPDrf0tIMEmJ/l/5j azIBbTgPmGJcjKCRBLa0fhZPY3jla3Ji2ufPse+LjOr1Cy6G3QfnDnhbDRfOiQZTlQOQamIb5er zmxdHjRFR/EgrpU1pjGBWdglIxkhx93d7hgrsBkzNnlfRnzkHUR1zg5ePk/stIz5mfr0bJd8RuZ Xr4cVykeSnwc4KyyfDRHLoRd98YdJTTblkxHt8f3cSAHNqnMcAJzcjIvMI+lPR8UMOAa1t2By8x Dy+xIsbdxsD/Ko+eGJtBptDbzH4aOwvmVI18GxM930yu96DCOypsaCaLtCJW6c3zLvplk3qV24I 78tWYdMN7NyPPdw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The callback functions for line conversion are almost identical for some format. The generic READ_LINE macro generate all the required boilerplate to process a line. Two overrides of this macro have been added to avoid duplication of the same arguments every time. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 164 +++++++++++++----------------------- 1 file changed, 58 insertions(+), 106 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 2edf1ceccd37ad3a2f9f6d2dcf2044c98d9e10f0..9c4aaca7853102b86dcfd8e39a8f70392d019aed 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -292,6 +292,58 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, } EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); +/** + * READ_LINE() - Generic generator for a read_line function which can be used for format with one + * plane and a block_h == block_w == 1. + * + * @function_name: Function name to generate + * @pixel_name: Temporary pixel name used in the @__VA_ARGS__ parameters + * @pixel_type: Used to specify the type you want to cast the pixel pointer + * @callback: Callback to call for each pixels. This fonction should take @__VA_ARGS__ as parameter + * and return a pixel_argb_u16 + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_name to access current + * pixel. + */ +#define READ_LINE(function_name, pixel_name, pixel_type, callback, ...) \ +static void function_name(const struct vkms_plane_state *plane, int x_start, \ + int y_start, enum pixel_read_direction direction, int count, \ + struct pixel_argb_u16 out_pixel[]) \ +{ \ + struct pixel_argb_u16 *end = out_pixel + count; \ + int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ + u8 *src_pixels; \ + \ + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); \ + \ + while (out_pixel < end) { \ + pixel_type *(pixel_name) = (pixel_type *)src_pixels; \ + *out_pixel = (callback)(__VA_ARGS__); \ + out_pixel += 1; \ + src_pixels += step; \ + } \ +} + +/** + * READ_LINE_ARGB8888() - Generic generator for ARGB8888 formats. + * The pixel type used is u8, so pixel_name[0]..pixel_name[n] are the n components of the pixel. + * + * @function_name: Function name to generate + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters + * @a, @r, @g, @b: value of each channel + */ +#define READ_LINE_ARGB8888(function_name, pixel_name, a, r, g, b) \ + READ_LINE(function_name, pixel_name, u8, argb_u16_from_u8888, a, r, g, b) +/** + * READ_LINE_le16161616() - Generic generator for ARGB16161616 formats. + * The pixel type used is u16, so pixel_name[0]..pixel_name[n] are the n components of the pixel. + * + * @function_name: Function name to generate + * @pixel_name: temporary pixel to use in @a, @r, @g and @b parameters + * @a, @r, @g, @b: value of each channel + */ +#define READ_LINE_le16161616(function_name, pixel_name, a, r, g, b) \ + READ_LINE(function_name, pixel_name, __le16, argb_u16_from_le16161616, a, r, g, b) + /* * The following functions are read_line function for each pixel format supported by VKMS. * @@ -378,118 +430,18 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start, Rx_read_line(plane, x_start, y_start, direction, count, out_pixel); } -static void R8_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); +READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0]) - while (out_pixel < end) { - *out_pixel = argb_u16_from_gray8(*src_pixels); - src_pixels += step; - out_pixel += 1; - } -} - -static void ARGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, - enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); +READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) - while (out_pixel < end) { - u8 *px = (u8 *)src_pixels; - *out_pixel = argb_u16_from_u8888(px[3], px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} +READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) -static void XRGB8888_read_line(const struct vkms_plane_state *plane, int x_start, int y_start, - enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); +READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); +READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) - while (out_pixel < end) { - u8 *px = (u8 *)src_pixels; - *out_pixel = argb_u16_from_u8888(255, px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void ARGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - u16 *px = (u16 *)src_pixels; - *out_pixel = argb_u16_from_u16161616(px[3], px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void XRGB16161616_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - __le16 *px = (__le16 *)src_pixels; - *out_pixel = argb_u16_from_le16161616(cpu_to_le16(0xFFFF), px[2], px[1], px[0]); - out_pixel += 1; - src_pixels += step; - } -} - -static void RGB565_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - struct pixel_argb_u16 *end = out_pixel + count; - u8 *src_pixels; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - while (out_pixel < end) { - __le16 *px = (__le16 *)src_pixels; - - *out_pixel = argb_u16_from_RGB565(px); - out_pixel += 1; - src_pixels += step; - } -} /* * This callback can be used for YUV formats where U and V values are From patchwork Fri Nov 22 16:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1324DE6916C for ; Fri, 22 Nov 2024 16:19:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A87010EBF9; Fri, 22 Nov 2024 16:19:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="hsAQYWuq"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FB8610EBF1 for ; Fri, 22 Nov 2024 16:19:09 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4BFBC60008; Fri, 22 Nov 2024 16:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQHb2AQUZTKgO+ldjVa5ay9EUsJ/fVjYqsXQJEb7ICc=; b=hsAQYWuqHweJB/UIdhIRgSi3XInhJ58XaXUlMMAZous8mzhTAGJR8x+iUiam/eBFKDeOy0 /cwkAD9RiCgvnG8etq0+6uPl7asr9Zb5/RoN/KkwizEKhSZ48AlPayujkSbwWLUp2DtDo1 I6YYFcyH7AEex5i4JuY5/LGZGUkr21XXWwmys5nZERlJxSQcNGskrrsQre6tDTUAIGGEUM A50g3zNYhVMx3Dk1kXxwoTnqNUHkB+ofVXaWqz7B8x1+SKs8/kACI4CE/btz3Ka5+sX5uj FnvvfacrPSmuLZioSX1Bb2C8STlkuVeDujWpoi5HaYaHVgit2b5n2WprI1DJXQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:02 +0100 Subject: [PATCH v3 2/8] drm/vkms: Add support for ARGB8888 formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-2-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=gJNge0fDzpH4LyPjnilSlTnJcUnJayCSzW4JiJCQxPk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK72t+Iob3mJaTm9piaeXpkzVIGGytAhcjk9r rIJEe80Jm2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9gAKCRAgrS7GWxAs 4olkEADXifTgmeQG7EMSKAmVn56M2Qz0MXBMHnFznerbrMXQxGgoX+rZqmgoQ20SsS0hVC+mSZD ge2Bj5lViU3uMAOn6E2H+NgNCf5+7TNYqcSdCzMF0XvCfENfqhhbgsg63+/8r5DLxCmbXEpMORk wACi8sZmS1wynFRIyNHDY0OcuHmS6YRUjxwj23IpspJi60yD4UdggAz0hITUyJOI0uMz8moXFGJ NyHJUCdmmT4KUJk3nBPyAbwhQyA8U64W8T+eWaVWRd3OSRoT3rahcfJ7KpG7VtJ/NzwWQCKbVgs hmGvNw7rdOakgDRXpg9gpHcctoCSwdS3OcFosNHNw1sNd4fGf/WFAgk7tVt/zE5u5pm5lCRfEm0 Vx7/da+mjNZKq6MCdnTMUHEIIf9ZVvTUfGQ0WmHLa+tLKrIlstPtScV5GIkIFBEzslA+Dt0rLg0 Bo5/vsX1eryP9M3YAkutbHNCTeB2UDzZbR9RNz+u6f2bC/zNd5uvYFsAP1L70LTL0CbVJDTkxYp zDXScrlH0ZWn0qKJCXO8dXH0GBOFukjfI+3DLAT9PYhByzHX9S0rvS6nWqsLz6X/ZpgsEDRvrnK 1a45EAocZal83YvzwIumDGmUrscjQpsWEMDbP+Aon4pRxeo7f8bjNkf/kWl0NgJBsHxbIOhrXof jvv5TsUCXv21Mlw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The formats XRGB8888 and ARGB8888 were already supported. Add the support for: - XBGR8888 - RGBX8888 - BGRX8888 - ABGR8888 - RGBA8888 - BGRA8888 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 18 ++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 9c4aaca7853102b86dcfd8e39a8f70392d019aed..520298fc74a1e24cded8d192efbaa84041e6339d 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -432,8 +432,14 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start, READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0]) +READ_LINE_ARGB8888(XBGR8888_read_line, px, 0xFF, px[0], px[1], px[2]) +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1]) +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3]) READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) @@ -636,8 +642,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) switch (format) { case DRM_FORMAT_ARGB8888: return &ARGB8888_read_line; + case DRM_FORMAT_ABGR8888: + return &ABGR8888_read_line; + case DRM_FORMAT_BGRA8888: + return &BGRA8888_read_line; + case DRM_FORMAT_RGBA8888: + return &RGBA8888_read_line; case DRM_FORMAT_XRGB8888: return &XRGB8888_read_line; + case DRM_FORMAT_XBGR8888: + return &XBGR8888_read_line; + case DRM_FORMAT_RGBX8888: + return &RGBX8888_read_line; + case DRM_FORMAT_BGRX8888: + return &BGRX8888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_XRGB16161616: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 81941914af87fcefb180dc393f2ec311f1a1d3fa..b7f498944c506631f9eb237bf56000bae4f86a1c 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -14,7 +14,13 @@ static const u32 vkms_formats[] = { DRM_FORMAT_ARGB8888, + DRM_FORMAT_ABGR8888, + DRM_FORMAT_BGRA8888, + DRM_FORMAT_RGBA8888, DRM_FORMAT_XRGB8888, + DRM_FORMAT_XBGR8888, + DRM_FORMAT_RGBX8888, + DRM_FORMAT_BGRX8888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_ARGB16161616, DRM_FORMAT_RGB565, From patchwork Fri Nov 22 16:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0157E69173 for ; Fri, 22 Nov 2024 16:19:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B4FC10EBFF; Fri, 22 Nov 2024 16:19:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="FunLCrRV"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75F7110EBF8 for ; Fri, 22 Nov 2024 16:19:10 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 539686000B; Fri, 22 Nov 2024 16:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MkFP2awiNhVE1SbicVB5Ya1gxVAKEjnrfHxgO70L7sM=; b=FunLCrRVY2b3jvn54EHv3FHXebghYZG0RKEaBYmIYapDUx+SoDzsULp9BC/Dc78bleWBZt kadeaBAkaPyb6853Qr68l+A25H/f9pKX4o5gdnIt+Nf1x+ut1tWL6de+UICSifcuRdS2DN g39Ue14fOgW0xMd6ZQbR6glqPuE1vYOGzhl8nvNDC6XzC5fRtrVSte5/Cvc+X92q6yFncI gUOYXvZz4uTC06jHYkO0cwv8VqNyr2ewhhr4JaVQX92gA46X0+AVPOvS2VkUG0WmMNzSP4 C5+2LhUQcDFf4lbshx44aNln4Y8ltgc6AIZmxBp0YSqnlGJPVrfmxhkFR2vn2g== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:03 +0100 Subject: [PATCH v3 3/8] drm/vkms: Add support for ARGB16161616 formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-3-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2200; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=P5nW6CStss6XBXJFB4mg63UIwOzvzkPZvmY9VNXeEMU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK72SKwWS6t/hvcDxOfnDTmQbN0sxqCu3Ra1M pHMChROovuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9gAKCRAgrS7GWxAs 4oeIEACBGWAC1xr5fq6T0d2MtpKpPqxqOU4jlC0Xg5p+CdQqzx38roaFuO9cXVegMwpgRuYWzsv heOp6IpNLjF8KZcUAzb2uhHYV/tdJcHOoWLxQK9fQjuTU5XDfbwWqbU/A3SZrrII18dYzShZudq +7T7BhuuE2J9Ns1MYpNyQTdq4PTeFthY5J/j4yjO32zYncl0AI6zE1y6j37LiB4amd63+PyMCh7 G0LeIuNW1goUrgXJUaXKUtUPQeOgRexkGU12tSWy0hlA2vs4pq0RAYmyEAvqzlL/eth1FMQLKG/ e9Lb3jbUyZcDfqzuQfJK3KyX+o94/PoUAxK87ZWFY4rmIeTWISl1CVbrgl7O5wWLfJEpvZSwg+2 n1B9HrH2tSf9XFIHxuL5Qjy38APME/HuYhAAqBQ3qfYQc9RFeepNJaZEFk7+qyrQlVGvgR0Yir2 w+nKPyzmKn6FIDM+nXQ2HCHILJq1T0qKZaMwNK0UvhDpjl5E12hmyMdZ3gshG+4VWicZTsIm7d0 HppAIsJxdoOmxhOy4BrhlSPgkWcSHqwahz2xz3lvZD8IJwgLkWEka6HznFdBZaGywfObNIIVLkI HVVnF/4a4tCp66yHJuAcq8uLJ+DviglGRyhNrL25GptuZQD4auEKwO8Mru4vEDL9BFmNR6f2XjK 60OLQOsnZX8wdDw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The formats XRGB16161616 and ARGB16161616 were already supported. Add the support for: - ABGR16161616 - XBGR16161616 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 520298fc74a1e24cded8d192efbaa84041e6339d..1f12607c9009643c5749611a5001ece2b775e099 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -442,7 +442,9 @@ READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) +READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) @@ -658,8 +660,12 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &BGRX8888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; + case DRM_FORMAT_ABGR16161616: + return &ABGR16161616_read_line; case DRM_FORMAT_XRGB16161616: return &XRGB16161616_read_line; + case DRM_FORMAT_XBGR16161616: + return &XBGR16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; case DRM_FORMAT_NV12: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index b7f498944c506631f9eb237bf56000bae4f86a1c..505847ec850855ee5c047985b0811416ff94e51f 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -22,7 +22,9 @@ static const u32 vkms_formats[] = { DRM_FORMAT_RGBX8888, DRM_FORMAT_BGRX8888, DRM_FORMAT_XRGB16161616, + DRM_FORMAT_XBGR16161616, DRM_FORMAT_ARGB16161616, + DRM_FORMAT_ABGR16161616, DRM_FORMAT_RGB565, DRM_FORMAT_NV12, DRM_FORMAT_NV16, From patchwork Fri Nov 22 16:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFD99E69174 for ; Fri, 22 Nov 2024 16:19:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 124D810EBF8; Fri, 22 Nov 2024 16:19:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="N+tHvqXE"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D45A10EBF8 for ; Fri, 22 Nov 2024 16:19:11 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5367D6000C; Fri, 22 Nov 2024 16:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292350; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wIvwz0pMdTQMLcy9cYC3AU7RkUEZgto8FvismTkIrSs=; b=N+tHvqXEcPO2gO44inl2Xg/nQfAKdUUuVfCV+1VOGbRWAyNvZbjg/E0V/JpBf73eP6CIV/ NFaVooEZ/gJlBZWSzTa4Djd3wGwJjmRan5J4MBsj8v0YUSAacML88U5uZYzGOaHn4M41Eu MY6rZeRNJfNJqYkJHyRuqMZSYWRVGYxSZ13C1oJAzqX7jnyoal4W4qsoRM7Mm85xoD0VvJ Y/hhtFHER//UWDpOYxUIvQGWWsI0dPbNYuRPie93PX6paKKP6USyTudZN2Xb+uKNLm6kJv wN9nJhWrTdkjZvWgXuaEE5l3szl0BdnPx0SwIqaezWsNQS3RZGh06HgZC40HrQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:04 +0100 Subject: [PATCH v3 4/8] drm/vkms: Add support for RGB565 formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-4-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2785; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=dbQqGdgqZ8VAgEmYe7A7eY51kRR6HJWf8pH66nmoElg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK72EuhD3HojzcS++/C2YbSlXeLXoG/xKpIBV XS+qw8okLCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9gAKCRAgrS7GWxAs 4lG8D/40yM3aDRWaUpIrbrAqJM0w1MFLA45iwaBfyU9VX1eskpGbUal7x/rThqEEqJ6Wm+GiMKu sJUgpZhrH/fIl91y46tcpRt2spt0E9C4VpSh7QjEMuSuyM+pHPialeNb9z8994ZYuHiClzjIaU3 o6tscy0CDIeNrX12suphMMKfOzyWrDUPDWyV+X++O4eW9IFW+4aIrI8RyAuWqgmPl9XLQd/eQG3 tsupLT23EAHJLEJLtLHjlGV3vDbOlrTwNQSbIEm2+DlJyOztDk21W0bMxfhstQWYp2YSB0gkCy4 QUGcJQmT/Sazir6JJEQgDT4iTx2QpviRbYwrHbBe9inu+MMzlyI8qRkcZLxl4sgm9w5HvfHIkyC 6HtuoGmEcgys5XWA+pUQrJPwfJSfrL8O3hNuyUo+q7TB8Hr3NZtroNaVP5JmNCzeGCl1yJu2En4 8S0XI5lDoUCr4BYt0eSrGLT8UxJEc1Xi2QB3S1dtG+FXE5YLBXVu+JdKYGaulzri4om0eWu4Hjd BJdasn66JG2TkThqDKdeafj34zOh+WOdfFMwo201swMqZmB6sefntianFNxO+minq3XPFfqrNAb 6lr1GGjQovnk/JAToLF4TRqQylHhlavdNjjlS2yalxfz+WK0WngA1CCsCMyiecRnZqULZdhwQsj JbjxVvANrcQ6QGA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The format RGB565 was already supported. Add the support for: - BGR565 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_plane.c | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 1f12607c9009643c5749611a5001ece2b775e099..7af6c5c048d5c482f47e4bd7954b765bc2d13b9d 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -259,6 +259,26 @@ static struct pixel_argb_u16 argb_u16_from_grayu16(u16 gray) return argb_u16_from_u16161616(0xFFFF, gray, gray, gray); } +static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) +{ + struct pixel_argb_u16 out_pixel; + + s64 fp_rb_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(31)); + s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63)); + + u16 rgb_565 = le16_to_cpu(*pixel); + s64 fp_b = drm_int2fixp((rgb_565 >> 11) & 0x1f); + s64 fp_g = drm_int2fixp((rgb_565 >> 5) & 0x3f); + s64 fp_r = drm_int2fixp(rgb_565 & 0x1f); + + out_pixel.a = (u16)0xffff; + out_pixel.b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); + out_pixel.g = drm_fixp2int_round(drm_fixp_mul(fp_g, fp_g_ratio)); + out_pixel.r = drm_fixp2int_round(drm_fixp_mul(fp_r, fp_rb_ratio)); + + return out_pixel; +} + VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, const struct conversion_matrix *matrix) { @@ -447,6 +467,7 @@ READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[ READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2]) READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) +READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px) READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) @@ -668,6 +689,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &XBGR16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; + case DRM_FORMAT_BGR565: + return &BGR565_read_line; case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: case DRM_FORMAT_NV24: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 505847ec850855ee5c047985b0811416ff94e51f..d3783a8f84c203dcf772ccf84dc32a6ddd4fc573 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -26,6 +26,7 @@ static const u32 vkms_formats[] = { DRM_FORMAT_ARGB16161616, DRM_FORMAT_ABGR16161616, DRM_FORMAT_RGB565, + DRM_FORMAT_BGR565, DRM_FORMAT_NV12, DRM_FORMAT_NV16, DRM_FORMAT_NV24, From patchwork Fri Nov 22 16:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3839E6916C for ; Fri, 22 Nov 2024 16:19:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27FD110EBFD; Fri, 22 Nov 2024 16:19:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="TSDSVm13"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94BDE10EBF9 for ; Fri, 22 Nov 2024 16:19:12 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6F90360009; Fri, 22 Nov 2024 16:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hxHofKZoem7NTwx2e51YaIJsnuWipPm4SrZGnIVNA8c=; b=TSDSVm134r4O/GcPCqhjTraNZ/Hv9z/h5WYY8Y3O4XYz+dPPB0+0sjyt4QYSCISl35KkSH zXctHq3wg3n7+5b+mwHuLMrDZ9ydlJfExO9rzqURrvqiTmzRKF3vDMWsDRvs13m+tMlfC/ bOp90pEA9DFJOn93aPGeOhp+OCYt0OdsrmdGKF/rfcm8PD7fbErA2sVkKOFa/mtLjrdjaM YN4MSdlESjkE1jkqOa8cj2p39gisLjNw4XOtGCacHPzwQ8yIwK/BU673+zFj1ssD88LOJv itygsMCVZczfmDvw/CqrVwF6M/tj3tqOSDmt+AQKJKQ45Ik5ySsDFr9kHOH+aw== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:05 +0100 Subject: [PATCH v3 5/8] drm/vkms: Add support for RGB888 formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-5-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2066; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=0QgKkVDHdfn4g/sZ9Ryhe8fOiTwNEjOz77ipz3qqPqQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK73nQd8g2Uaa6WRCrf0T8UsTYQ3snrQRhVwG lWwD0HmrUaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9wAKCRAgrS7GWxAs 4mbGEACOcewvrgjp33AeKzYqCsW4WeHqG2cr1ZCK8dCS5HvTlN6eN9+4axKkyKXF5yyIuZYn5Ue OSSzsRypXv4/+8nr1N38LHcw2hZ6t0rMK6prmRvJKgAjlDNtPKUjpCRVK2jpnh+uOMl/uxwADoS jGsvLfw221rYo/xufcI5Vpnwych3M5kHmkXeEhqwgROOuQDS1EFNJuV01H7HS/9k2WC+OSPaTKh c3OppPVXVu3WTIskaEkB9DrA7QDvbq5j5ItM+CNXDJKGrkcSH0Is0zpRz0nyckhSg0xMt0fYzlw wmHkB+yulsGoaqwX6RKCXRXlz8SaBG4N0zonlfhmH6s3ry7FoOujakwZaYsdrGkXsUE6UY8VSB+ dmCa+tQQqaGX4Stiib5pXwOJuvyMCVCUvar1/ALd/prfA9OO/rLAQxEU9orufGTLqMTSB9vskM0 LrxWeEVabtR8ynnlzyNV30diZpCKOyr1QJ8Lb8RhzRR4XUx9+Sw1N9WB9UmvipV+cHUSgkFo//i KvVtUXxZ7dmO6MDhVUBEYNpCpaD3TA7TuKN042MufXZYy3MAoj6aitgY+B6RuAoQv1WMbeBqKfR tvHAPqW6ry3BfFRVlCjSuf0/z0F9mcl6poWeLwIdR25Ku0dlPEbHcQCLwJlq5jXF+AiFATxDBqc wNEcn8WrGbRpbzA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the support for: - RGB888 - BGR888 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 7 +++++++ drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 7af6c5c048d5c482f47e4bd7954b765bc2d13b9d..f73d3de33807644a7f7294a4dc8b9de2bec6e427 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -461,6 +461,9 @@ READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1]) READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3]) +READ_LINE_ARGB8888(RGB888_read_line, px, 0xFF, px[2], px[1], px[0]) +READ_LINE_ARGB8888(BGR888_read_line, px, 0xFF, px[0], px[1], px[2]) + READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0]) @@ -679,6 +682,10 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &RGBX8888_read_line; case DRM_FORMAT_BGRX8888: return &BGRX8888_read_line; + case DRM_FORMAT_RGB888: + return RGB888_read_line; + case DRM_FORMAT_BGR888: + return BGR888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_ABGR16161616: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index d3783a8f84c203dcf772ccf84dc32a6ddd4fc573..e82b60fcda4bc2f2337e9c1e65515548ee06c9ed 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -21,6 +21,8 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XBGR8888, DRM_FORMAT_RGBX8888, DRM_FORMAT_BGRX8888, + DRM_FORMAT_RGB888, + DRM_FORMAT_BGR888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_XBGR16161616, DRM_FORMAT_ARGB16161616, From patchwork Fri Nov 22 16:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 261E4E6916C for ; Fri, 22 Nov 2024 16:19:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DA4E10EBFC; Fri, 22 Nov 2024 16:19:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="LNSyMyrN"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id B0B4C10EBFB for ; Fri, 22 Nov 2024 16:19:13 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 78D9B60002; Fri, 22 Nov 2024 16:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cw1lm/kzwxajdmu7r2dcdO3tCjaL56NGjbITviJPxno=; b=LNSyMyrNOQOQ/zNP8CZrk9diIYI+GObKO7ndk1ruGTgW9/IT5LNMsNJ3aJMogiRU7vs6d7 EAj8aNqdswC2T/M3DUpLlpQiA6L4vOMiNfy3JQz0Ryyfz3e6nLATZhXWCzQmGollV1BEPI /rsKtXxP2JEmK26AcykVmZdg7y9O83i6RxRrBqQkNO9TnxJX2P94LTUy3psYObTOMH32u9 1WVplKy0oLqUhL6syZ9Hh33PeftbV3Tl1+HYFaM5eLcASBhfHkJLqWE8MB6OnLFKbUvzoo ysNC96jIEUL65F7YRY4sG8wtbfTngWem2FUExvXaoFqeQcMt/W9+m4P8CfmHQA== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:06 +0100 Subject: [PATCH v3 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-6-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5299; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=BUrScrD21+8OVFDE9O4vUOYPacl4PSRaT4P7htnDffU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK73WMmLSZdj6tvlxFVmCvVjNVLuUTIeAGiMF Jz7i9EYw+6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9wAKCRAgrS7GWxAs 4veoEACodwITQS3HZ4XnZlRC6hHFK8nvgpu5rzCswZMvQVekUhbzEB4fRIU1OvLATkWV2Y57X31 BD1c3Bzto5R1maNK6m5TtxoYIz43B96tD4UYGJTJofhplznVpisi7yKaaJP5nTGbcA7clrO2/DC tUmBjfD17UmMjfg2KxqRSNH1fP/vJk0aqoRvu4zElyQMt9q3zKKdgeePCFZkHeD92HfwOb0tWjW i4hYruh++2Y65gZAJcdBOS7SEFdOpCOpZhfuEvfcnWCsVxtpYtvtypxYoPNLPx+XRZeLC/3cmZ4 mR7Jvs7y8DtGfueRcUuOV6aj4KWegx2iyq+iPVNkDQRUKTvxe9ZEZBJ8PHA/ShNXtFkEeBmWY6L GClzqVPnSIywWKG2U5eaUNgSd4XAjjgc7S94jOlYiRn5ZbdCzIhCI3FciNMA/I/DEVwqgJlp80N lA8jUWcxmHwrzUfgl2UiVXBBCAREZX1BRqRxn6GC8KasrDW01eIs+aoQjLVvj0ABK92/VUpGNSm nGwZQbyM1cSlrWe3TuyRtPLGhUL6mamuMmBqpxf7NRriT1eZrDcUoMiZ/+izgUjo6rolW2PjILt hRt9EFP+iLWwqbP7YhxrP7uQQpePnMFn86mBCnml4wCUDRWW5PEg5matIZnR2IhfRWG7z/tS8wG rTtk9PgCSwK5+pg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some YUV format uses 16 bit values, so change the helper function for conversion to support those new formats. Add support for the YUV format P010 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/tests/vkms_format_test.c | 3 ++- drivers/gpu/drm/vkms/vkms_formats.c | 26 ++++++++++++++------------ drivers/gpu/drm/vkms/vkms_formats.h | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c index 4f565ecb591c34b08d9df577860488702200a384..1d9a6515ce44f56fc3032f9aad2d11591bb71a68 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c @@ -226,7 +226,8 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test) get_conversion_matrix_to_argb_u16 (DRM_FORMAT_NV12, param->encoding, param->range, &matrix); - argb = argb_u16_from_yuv888(color->yuv.y, color->yuv.u, color->yuv.v, &matrix); + argb = argb_u16_from_yuv161616(&matrix, color->yuv.y * 257, color->yuv.u * 257, + color->yuv.v * 257); KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.a, color->argb.a), 257, "On the A channel of the color %s expected 0x%04x, got 0x%04x", diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index f73d3de33807644a7f7294a4dc8b9de2bec6e427..668c3a88a1f3e7d4e3c492a428bc487291392da2 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -279,16 +279,17 @@ static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel) return out_pixel; } -VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, - const struct conversion_matrix *matrix) +VISIBLE_IF_KUNIT +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, + u16 y, u16 channel_1, u16 channel_2) { u16 r, g, b; s64 fp_y, fp_channel_1, fp_channel_2; s64 fp_r, fp_g, fp_b; - fp_y = drm_int2fixp(((int)y - matrix->y_offset) * 257); - fp_channel_1 = drm_int2fixp(((int)channel_1 - 128) * 257); - fp_channel_2 = drm_int2fixp(((int)channel_2 - 128) * 257); + fp_y = drm_int2fixp((int)y - matrix->y_offset * 257); + fp_channel_1 = drm_int2fixp((int)channel_1 - 128 * 257); + fp_channel_2 = drm_int2fixp((int)channel_2 - 128 * 257); fp_r = drm_fixp_mul(matrix->matrix[0][0], fp_y) + drm_fixp_mul(matrix->matrix[0][1], fp_channel_1) + @@ -310,7 +311,7 @@ VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, return argb_u16_from_u16161616(0xffff, r, g, b); } -EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv161616); /** * READ_LINE() - Generic generator for a read_line function which can be used for format with one @@ -505,8 +506,8 @@ static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv888(y_plane[0], uv_plane[0], uv_plane[1], - conversion_matrix); + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, + uv_plane[0] * 257, uv_plane[1] * 257); out_pixel += 1; y_plane += step_y; if ((i + subsampling_offset + 1) % subsampling == 0) @@ -550,8 +551,9 @@ static void planar_yuv_read_line(const struct vkms_plane_state *plane, int x_sta const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv888(*y_plane, *channel_1_plane, *channel_2_plane, - conversion_matrix); + *out_pixel = argb_u16_from_yuv161616(conversion_matrix, + *y_plane * 257, *channel_1_plane * 257, + *channel_2_plane * 257); out_pixel += 1; y_plane += step_y; if ((i + subsampling_offset + 1) % subsampling == 0) { @@ -683,9 +685,9 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_BGRX8888: return &BGRX8888_read_line; case DRM_FORMAT_RGB888: - return RGB888_read_line; + return &RGB888_read_line; case DRM_FORMAT_BGR888: - return BGR888_read_line; + return &BGR888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_ABGR16161616: diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index b4fe62ab9c65d465925d29911f26612193a80799..eeb208cdd6b1be9676b4706e0e3cbb2ad7efe067 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -14,8 +14,8 @@ void get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encod struct conversion_matrix *matrix); #if IS_ENABLED(CONFIG_KUNIT) -struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2, - const struct conversion_matrix *matrix); +struct pixel_argb_u16 argb_u16_from_yuv161616(const struct conversion_matrix *matrix, + u16 y, u16 channel_1, u16 channel_2); #endif #endif /* _VKMS_FORMATS_H_ */ From patchwork Fri Nov 22 16:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04AF4E69174 for ; Fri, 22 Nov 2024 16:19:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F404010EBF7; Fri, 22 Nov 2024 16:19:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="BNGv9Nb+"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9C7310EBFB for ; Fri, 22 Nov 2024 16:19:14 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 976A960004; Fri, 22 Nov 2024 16:19:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zExytEYkGHJ18P/wL/RkrQGgwqv47QAp/V3OFve+Zi0=; b=BNGv9Nb+UG0l8ClI3kvrdQDLuDaDjEmlKxSP00HFdakhEpm6a+B3ZSMdWyMdO/5ou6+Kgx vwZ9g8pIoLdfqFHmDK9DCdqjSRnV1Fpxi7TOl2KJNJHHE3xZ7dR3Eth/txA9ynyM4OZD/3 Ko1X2gZ6CHj61j2z1PmeuaBasEBtn24qQdwhEE0l8WA1K2/bj10LvQT5uIgYKOTCP5J4Yx XbwKKCoh/uTfXnj+GBic2FfkC/zSW6Onm+Q654ECVuoPl4kgLf4Eu9sfLpiEYIUuyfjqAS TA3hSbmDulFrhwLmTJWoPpSqMzz1HyuVKXr9fRqFblZ8Gc3y0sZUiv+zX2wfRw== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:07 +0100 Subject: [PATCH v3 7/8] drm/vkms: Create helper macro for YUV formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-7-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5269; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=cRhyJpqK4UQEB6lUCB9BGi7XqZMxLwWjbRwzbxs0rs8=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK73e/e3tmAzQU/S2Xd+BCU/ID64NUFP7Gjn0 Zu2YC/YxRGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu9wAKCRAgrS7GWxAs 4kiDEADFFuwryVQO7OFUq2znwPv7XNIB9QbgFLQANGPjLf8UghYQTp/o1gYTpbunQ7ShneCFoEt aFAl5sxXN6zvjH/L2SSgEW1sRcvpHJYFqyLjR44n8l6kg6dx68lMUV5gO+Pqnu3LZX1maqONmgI +DCuQO4AgPYek5KLmGGX9ZgNVecDYxJjY3ehkfG6p5Bdzl5jxz7zirord4BGZ/R9LAGg1SGQMAM 1sH9eehenDgYl35O0u0Vuco0IDWfZUnuNyGsJZjpB29cuDL5ivhyhJVPoviApaV+32VV2DtGLl2 i4H+kxJz5WCWflTIm0GwvD9QcTYRgt1/9UX+YbSKaVxyY1x6HhPU/7CproracRKgLxS8gN+Nnpj kuzOvsOsks34AyGWIDuLTR6VsDEfCtyUVW9LZEAWNFRLh/OCRYLgh0Tyjgd624KH/sDH4NMTkdc CmXfcMlJGIFEWh4nFXktMUSfb4An6aL8xK1AhXurWUblqvetPcCJYC+epfafxVqAH3waJovh11l W/2Qoy2Bc21pBtggNrD7en9COw3KYhXZBO+1GW779xKczM6Hb/CQnEeVH3yulUYuilIZqHfiwuK CnMqcIVtcW98FlprW9Mwym08cy6YoYw42D6BivL4yoS46l2Pi33ZUqRmBGLCC65E3k0EXRoTUzi H0L3RR29Rl7AmPA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The callback functions for line conversion are almost identical for semi-planar formats. The generic READ_LINE_YUV_SEMIPLANAR macro generate all the required boilerplate to process a line from a semi-planar format. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 75 ++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 668c3a88a1f3e7d4e3c492a428bc487291392da2..d2ce5848eb3fb667a882d1efd7c8af5baec97bf4 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -486,35 +486,56 @@ READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) * - Convert YUV and YVU with the same function (a column swap is needed when setting up * plane->conversion_matrix) */ -static void semi_planar_yuv_read_line(const struct vkms_plane_state *plane, int x_start, - int y_start, enum pixel_read_direction direction, int count, - struct pixel_argb_u16 out_pixel[]) -{ - u8 *y_plane; - u8 *uv_plane; - - packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, - &y_plane); - packed_pixels_addr_1x1(plane->frame_info, - x_start / plane->frame_info->fb->format->hsub, - y_start / plane->frame_info->fb->format->vsub, 1, - &uv_plane); - int step_y = get_block_step_bytes(plane->frame_info->fb, direction, 0); - int step_uv = get_block_step_bytes(plane->frame_info->fb, direction, 1); - int subsampling = get_subsampling(plane->frame_info->fb->format, direction); - int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); - const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; - for (int i = 0; i < count; i++) { - *out_pixel = argb_u16_from_yuv161616(conversion_matrix, y_plane[0] * 257, - uv_plane[0] * 257, uv_plane[1] * 257); - out_pixel += 1; - y_plane += step_y; - if ((i + subsampling_offset + 1) % subsampling == 0) - uv_plane += step_uv; - } +/** + * READ_LINE_YUV_SEMIPLANAR() - Generic generator for a read_line function which can be used for yuv + * formats with two planes and block_w == block_h == 1. + * + * @function_name: Function name to generate + * @pixel_1_name: temporary pixel name for the first plane used in the @__VA_ARGS__ parameters + * @pixel_2_name: temporary pixel name for the second plane used in the @__VA_ARGS__ parameters + * @pixel_1_type: Used to specify the type you want to cast the pixel pointer on the plane 1 + * @pixel_2_type: Used to specify the type you want to cast the pixel pointer on the plane 2 + * @callback: Callback to call for each pixels. This function should take + * (struct conversion_matrix*, @__VA_ARGS__) as parameter and return a pixel_argb_u16 + * @__VA_ARGS__: Argument to pass inside the callback. You can use @pixel_1_name and @pixel_2_name + * to access current pixel values + */ +#define READ_LINE_YUV_SEMIPLANAR(function_name, pixel_1_name, pixel_2_name, pixel_1_type, \ + pixel_2_type, callback, ...) \ +static void function_name(const struct vkms_plane_state *plane, int x_start, \ + int y_start, enum pixel_read_direction direction, int count, \ + struct pixel_argb_u16 out_pixel[]) \ +{ \ + u8 *plane_1; \ + u8 *plane_2; \ + \ + packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, \ + &plane_1); \ + packed_pixels_addr_1x1(plane->frame_info, \ + x_start / plane->frame_info->fb->format->hsub, \ + y_start / plane->frame_info->fb->format->vsub, 1, \ + &plane_2); \ + int step_1 = get_block_step_bytes(plane->frame_info->fb, direction, 0); \ + int step_2 = get_block_step_bytes(plane->frame_info->fb, direction, 1); \ + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); \ + int subsampling_offset = get_subsampling_offset(direction, x_start, y_start); \ + const struct conversion_matrix *conversion_matrix = &plane->conversion_matrix; \ + \ + for (int i = 0; i < count; i++) { \ + pixel_1_type *(pixel_1_name) = (pixel_1_type *)plane_1; \ + pixel_2_type *(pixel_2_name) = (pixel_2_type *)plane_2; \ + *out_pixel = (callback)(conversion_matrix, __VA_ARGS__); \ + out_pixel += 1; \ + plane_1 += step_1; \ + if ((i + subsampling_offset + 1) % subsampling == 0) \ + plane_2 += step_2; \ + } \ } +READ_LINE_YUV_SEMIPLANAR(YUV888_semiplanar_read_line, y, uv, u8, u8, argb_u16_from_yuv161616, + y[0] * 257, uv[0] * 257, uv[1] * 257) + /* * This callback can be used for YUV format where each color component is * stored in a different plane (often called planar formats). It will @@ -706,7 +727,7 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_NV21: case DRM_FORMAT_NV61: case DRM_FORMAT_NV42: - return &semi_planar_yuv_read_line; + return &YUV888_semiplanar_read_line; case DRM_FORMAT_YUV420: case DRM_FORMAT_YUV422: case DRM_FORMAT_YUV444: From patchwork Fri Nov 22 16:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13883357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78D08E69173 for ; Fri, 22 Nov 2024 16:19:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F19EA10EBFB; Fri, 22 Nov 2024 16:19:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="PtHoLXWJ"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id DCF9410EBF7 for ; Fri, 22 Nov 2024 16:19:15 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id AD73A60005; Fri, 22 Nov 2024 16:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E53FflVZUbLnlF8wplWhxBERpMv4taFo3hTXjKtrZCU=; b=PtHoLXWJH0/6BA86CIHExNewbrAdsOGcPzSbF1IfrKNuZX4BJQTPeCS25v9OAc7Il5tZAm MCnKEcaqT4J40LrSHTKYrymGmOy5IRMnPI1IGWWvdeknfdMveIl8yQ89Bc0zol7FQaYHSy g84X3Ioa7SwFOTEwMPilTovRuPrRr/CzcFIuL2o50/X32xNg50mJa0Dhl351ugCCIBCEk7 py4Ql/CtlEq1hGVa5Ii70aYhZtTzVhtVdux74DXVwSUYh2pSzhQqkpAUHsVgi1kERhLPyh WPstHDoe7S1ttQfkogGgO2rPoYreUfCk1hz1zPGsytIiUPSxiMaulKgftI9Tnw== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:19:08 +0100 Subject: [PATCH v3 8/8] drm/vkms: Add P01* formats MIME-Version: 1.0 Message-Id: <20241122-b4-new-color-formats-v3-8-23f7776197c9@bootlin.com> References: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> In-Reply-To: <20241122-b4-new-color-formats-v3-0-23f7776197c9@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1997; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=DCYx66irwTSpBabckwUwZmGruKQUcBMtLxM8Do3N2IQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQK74GL6Vhqnot+DzZiz2Gb2MKlgyveVzGXgPM +Jhf+j7xvuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0Cu+AAKCRAgrS7GWxAs 4mv9D/oDnKG8lR+N8flppo33NvpPhyMa8bD3jAMRvLb/FL2nu73pMXwIDsKcS92Q224p4AQiU6h RvEoCNeWOqp7mzon+d2i8S+mXEDZDq0tzEd+D4y5kvCLbvAhZNNfo8rcnW6mKON2r9se7u2yoL0 sRvSV/xp723fSehYpiFLgisALxslaWswFvwvL16hlm0PnhowbsKPndzpuP+Ve6wgtddr8FI2R8j g/ClZPpE1CuKnfbxbqXBtbiWfvfkMnLWHcUudW22WPkceneYsfTd48U+cUbmN34Fu/QW6BQNDg3 aFCDSSSbthn37VyK6ye+1E+1nb/uctHW734k7Xs54CWCwTXKBa2pk7QEunxOIet3b3GDf8bayCf pATVk/YipLYCz2yh/CIbIblgNVqhDA985ML/Gh/RnIaLgQ070U3m1wqHv633wCIsR+vDrqR7rY0 JD3UsP/got/3HbmiIEadODNALWqy/Y6TNUhl+tPavfOa+0WL2K3ePW0/EW+cGUpkdu4Zja7P3ci xp26Py4YCP8f6t8kUNtltqwGxfLjVehXLgxCXiyp7VDXc8+uFlPi+fj6Uj9PSW4IkrBl+SO1qRL 7/f9RZKHCrXhHXjSCCxwe0qoTBY8KC32hdmYewnkcUo/gnNtYnWnMRyj5AAxByHI2o4Lljui+vF siTK1ZIx+hEr0XA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The formats NV 12/16/24/21/61/42 were already supported. Add support for: - P010 - P012 - P016 Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_formats.c | 7 ++++++- drivers/gpu/drm/vkms/vkms_plane.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index d2ce5848eb3fb667a882d1efd7c8af5baec97bf4..c895126e9136bff7820ac7dfc1a3b6418c9ca2b1 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -535,7 +535,8 @@ static void function_name(const struct vkms_plane_state *plane, int x_start, \ READ_LINE_YUV_SEMIPLANAR(YUV888_semiplanar_read_line, y, uv, u8, u8, argb_u16_from_yuv161616, y[0] * 257, uv[0] * 257, uv[1] * 257) - +READ_LINE_YUV_SEMIPLANAR(YUV161616_semiplanar_read_line, y, uv, u16, u16, argb_u16_from_yuv161616, + y[0], uv[0], uv[1]) /* * This callback can be used for YUV format where each color component is * stored in a different plane (often called planar formats). It will @@ -728,6 +729,10 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) case DRM_FORMAT_NV61: case DRM_FORMAT_NV42: return &YUV888_semiplanar_read_line; + case DRM_FORMAT_P010: + case DRM_FORMAT_P012: + case DRM_FORMAT_P016: + return &YUV161616_semiplanar_read_line; case DRM_FORMAT_YUV420: case DRM_FORMAT_YUV422: case DRM_FORMAT_YUV444: diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e82b60fcda4bc2f2337e9c1e65515548ee06c9ed..4ab0fab4dd09f4be14308afb2f52bc6465f6396d 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -41,6 +41,9 @@ static const u32 vkms_formats[] = { DRM_FORMAT_YVU420, DRM_FORMAT_YVU422, DRM_FORMAT_YVU444, + DRM_FORMAT_P010, + DRM_FORMAT_P012, + DRM_FORMAT_P016, DRM_FORMAT_R1, DRM_FORMAT_R2, DRM_FORMAT_R4,