From patchwork Mon Oct 7 16:46: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: 13825047 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 14061CFB44E for ; Mon, 7 Oct 2024 16:46:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9876510E20E; Mon, 7 Oct 2024 16:46:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="jpu+anjT"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FC1F10E20E for ; Mon, 7 Oct 2024 16:46:24 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id DE60040005; Mon, 7 Oct 2024 16:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319583; 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=rS9nUQWZiV3e0foKLhEBRgWJnsWmMc+J3tidmd0VNVc=; b=jpu+anjTB0lNSBgpA2bgJcHfap7Z2uHKyDNbD4py18AQw5JZNTvM01q/OKpav6skySIjmf PnjiUmI2hO5YseQXHzFk7h96WUoPw88BJwsLvcUDsfOY8U36VLx3dJcDqm9UX225gtCKUB MUanKa1ms3E5bqt1p5i7M0KOZF829Ec+QkMszHxAA7DVuvseLLEQjSfnYZtgt7GKe3lHhE bV9EcGKIBfmVhRcrmUmgHjtB+VFiAKyhGolg61NvLOGdVBm5CSro/p/JUvbJD50Xvho+GX K+civ1sOwvoeqZUBXJDMduxDWNQYVYG+2zu/63hCX9DRIOLDuYxsCds2oJO2rg== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:06 +0200 Subject: [PATCH RESEND v2 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-1-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=7762; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=9mGB556rofW06HSalIfd4eO0p9rQZ2+EOUY99ZbyD8Y=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBarxLpfmhIzLwhk4o9TlgXf2JGbylgRdixC 8jcc5r183KJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQWgAKCRAgrS7GWxAs 4lVGEACU37A2MEWTRnvC5j+mqrD6zirqJTkOuKOuy0Foq9R2Idr2L3KYIkH14KaUouxe8PgCmxp oYh0PQ8v1uFIvV+JscDGkc004yiKdZGrZRz+0KlkOBCwpZA0abNva93JDgZf2RE5DxOpcV0RDT/ eTjRBnbli4QyjpKxo1nZKnUJsVLko5rK5pCHVN4NNnc9Kpo9hey8RbG0gfj/bxFZX23TOAPQjZc qbpF6W3R9SiFq810PJ24ttcG2WaSeLHhDfFBMiN1VcdFbB+3Mq8Z4H7r0zwBHnkvTM0674PQAUq 1uehLR69r7Tii4BAjU6LXTzMsonn8KlyxkcU1q7zqpW5ONngaa7M/FyFUr23hQwLQK6O5+9jCto lFQ3tKExvawPSIFPIXvrIFnuMNN87nM3/NkCylSRE+DKzmWj+aCtZ5HMX/GBsLg3aDFrJBvyWPI vr9Mh95autUIuRg5ZBwQBxrQUNfr6jFV7rxkht5PNsnumFkLVtWcvMfS8z2ci7LPxg/G0Er/tQ8 844rDpdDW8+0U6oL/P/p3spB6fIHg8iN2I7fqc5yGbxhpWnvQCuvwrJpmjNMXQQ086HIX7l/X+G kxjKf2GHMDyGunpgWBT3Km+S1n9qTN3ZJMvu5UR9bXeUQhXOIVbJcIlM2YbsYlPWwDRdVp29iXt boogOoEfVB39YgA== 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 | 163 +++++++++++++----------------------- 1 file changed, 58 insertions(+), 105 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index f9841b8000c4..8f1bcca38148 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_ARGB16161616() - Generic generator for ARGB16161616 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_16161616(function_name, pixel_name, a, r, g, b) \ + READ_LINE(function_name, pixel_name, u16, argb_u16_from_u16161616, a, r, g, b) + /* * The following functions are read_line function for each pixel format supported by VKMS. * @@ -378,118 +430,19 @@ 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); - - 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); - - 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; - } -} - -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); - - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); - - 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); +READ_LINE_ARGB8888(XRGB8888_read_line, px, 255, px[2], px[1], px[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; - } -} +READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0]) -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); +READ_LINE_16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]); +READ_LINE_16161616(XRGB16161616_read_line, px, 0xFFFF, px[2], px[1], px[0]); - int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); +READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) - while (out_pixel < end) { - __le16 *px = (__le16 *)src_pixels; +READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px) - *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 Mon Oct 7 16:46: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: 13825048 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 E3827CFB44D for ; Mon, 7 Oct 2024 16:46:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C88E10E3DC; Mon, 7 Oct 2024 16:46:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Z+HA0GgJ"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1394110E20E for ; Mon, 7 Oct 2024 16:46:25 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C7DF540007; Mon, 7 Oct 2024 16:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319584; 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=xsoIMQdz4wDrKoGlEaJ6v8bPFcpjT0jVjkTFUPasYok=; b=Z+HA0GgJi9aukoEaEoIHq15lDIlZ2Ir7f3wP7TttCQ7jLb1A3q22dWdHyIms8YOwus8vrw DyXtxxeU2TniX3o9X81kXyYmlGu3LVIScyJLakrug19Pw4lz1kPCOhVTd445nu7DWIG4uf TcjyJNBiJBEeyTy3snB32Q/Zpg8NiA68d1Wkp68jRrrpwEtwuqg4XUVbK0hauLuto6pEMc eAUDb4CApYf/7jcQ0UzHtgde17RiggUJlpLElEUIPrX4+vifN9zoBpAIWO6ptv2I1bCyNE x9SNudPBwaID2jDRp2rX3d1MnB3pYCWCWzw9oMbKO+a37mor22B7DdrFIuxZ9g== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:07 +0200 Subject: [PATCH RESEND v2 2/8] drm/vkms: Add support for ARGB8888 formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-2-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2595; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=gdPmVx5gF0p9G7Is+ZemThuXnezaEwBJJ2Nq9GqmioI=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBbGctjHAB+1xzKIPMJi6GLs3ax8ph26aT9Z C0y/kEZ9TKJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQWwAKCRAgrS7GWxAs 4hw5D/9xwAmNKH9SjFGaYfaRf5MlYlKnW89W23FxkC+pRJzv+/oOasp0GJQPzUuN9p3pwtvgGjU ld+KiO0HcadOvDdViq9ef4j5RPZIUy+/dpu/9RmsBki+ICVBhCoQ9yLtB4TLekJgzWGludJlPiN 6+Dt1S3TqJuhtpPlBL+gqtE06cbom+Oehn6uXrAsJB/meO4zlS9mRGy2XnMPY7ZZGWA1EoMtPGk CQTYN8lqYRgR6scwf2tQokGpboDr4NPUD+v8ZKs+/IDS9r6Cmv5sXx/F6pjsyaEfyRjP7bscusb umLBxDjb78JJQaBrUCVZ/+cezlrPJ6C20z2Nl1qWFGPU/cdIXCyuOY5NOAgboBmEL1cl/863oKx Si5ziIGegSs8F7HCWEHEPsVcc9HX9GEv93pe9IrCe2pIl27IB6e8lLsTqoJCEeTDFOlnGRk7U0o e980P1Q9Qrt6bzikRAcgurUTft2LCpmaQ+SV3URZ1uwBVK9kIYAy6dtH2nUjDF4NxmFD6M2+ipi zC3F+txRtDwV94lDFlT8wHPfkZHxWh6qVHQVgyjhTPnce1zr9LRkmHRu2EIYCWNppnMKvhon04w qBIrdNZI8u5d8Xo3ZwnhApjPsxjp8IzNOFzL0evAr8XedMpJxBaSaUzCAAQ7GwGYI4caIxl7hAQ N3uwZVBLSBlylsg== 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 8f1bcca38148..b5a38f70c62b 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, 255, px[2], px[1], px[0]) +READ_LINE_ARGB8888(XBGR8888_read_line, px, 255, px[0], px[1], px[2]) +READ_LINE_ARGB8888(RGBX8888_read_line, px, 255, px[3], px[2], px[1]) +READ_LINE_ARGB8888(BGRX8888_read_line, px, 255, 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_16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]); @@ -637,8 +643,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 67f891e7ac58..941a6e92a040 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 Mon Oct 7 16:46: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: 13825049 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 56380CFB44E for ; Mon, 7 Oct 2024 16:46:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AD7810E3E0; Mon, 7 Oct 2024 16:46:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="MgSmnZ4d"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id C940910E221 for ; Mon, 7 Oct 2024 16:46:26 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B14E340006; Mon, 7 Oct 2024 16:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319585; 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=iqs1bnGU69W3MzIr9W+ombCvohHuBY06BkZDRKmcIuo=; b=MgSmnZ4dhd+3pzxjaFYMBittt8SY7IeyV6HGo/Z4rvlskd6jAX0GofFfokPWfV0wHd5i6U IspZWuSw4ooRQNATZKUO0wl+Pdc5HXX6f7aVEyr3WgG64zDF+ytIvTHG9EKrMGBYtRns/S 8lfLW8uU1rd/SVm4IkOWXXWoX33ayZqNLGPPJl/KV24jMtiXE8y8wF+Yd7OrA3QWWDJFkQ ZgHq+5vkXu/M3SVUpLrk/nwprvUOMHTthHT0PvTceQG1FCQjFb3WecNWA+ShXy6cSLjA0X OcgvbQzUz8l8lGBV+skXIw/2A2DItfdXE848QtNsOHbebS7+Teer+PpKLldcfw== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:08 +0200 Subject: [PATCH RESEND v2 3/8] drm/vkms: Add support for ARGB16161616 formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-3-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2312; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=zdHnGJBg2gP3BAEgoKBrBRx3cyjqQ8zdv+fP4kauhLY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBbKbyLLXf+LJn9L+NsDKkiEJ2LQyk0JoXT3 8vwKaregTaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQWwAKCRAgrS7GWxAs 4jF+EACQR7XDx5gzKvA2WfRDMQmql0nS0hZWCMaVPI2vRhQYXUgTf0tW6SBxR1gpqLVtkgstHRy k7FQffSHVR732mP5iyhoUXsGfigCq7lf3eHzl5abbCDUEXw8ftcZ0I2MbjMlgRgPZG96CAIx8QU depnF1ZODQgnROhm6HNCfKbmH1zkO8PB7b3tsMoGBo3sBQiVaiFUqoKSljzY9d+w/hhe0DQrU2p NXzrFtATjkWK+gsHo0ZQTv6316gpvs+n/6usZUF93njsp+GG3DLb93HZcegHLWVCDukzSjAcJ/G zPg8pFI0NeH9QOHS16TWyFVFaWA/g/sg1RewShxqahjjIin2+/OY8YeVJsRt11Wgh0Jeyh/dK/G IFcWAK8PGGV/L956J9p/ewbpR7NbI3s1b9vlBsrRXfxp1sLfkItpq/VTw+JVJ1TxvwK74hq3Bbp L510CODtMbTL7D3k/A8NgsABcl4TOHuWPGPVJdh3hzByfZ8uqsQzpM0Di5f+UU9WCl+aRtj/a4s JgXYvqUBFVHdN4GAQxXFgnq7JcEol4uzsFBdeOqPdpNIwzVtWllFXaN1R7BwhpGZ6CjeurCB7t9 fi4rK1gdMQsnd/Lw0xu6o1DtX4/oNel/NhR0vU3OUE9wHOZw3mjyzflAoEYQvX7IYdVAURg9W36 HM4kUYP9zCcKHVw== 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 | 11 ++++++++--- drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index b5a38f70c62b..c03a481f5005 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -441,9 +441,10 @@ 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_16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]); -READ_LINE_16161616(XRGB16161616_read_line, px, 0xFFFF, px[2], px[1], px[0]); +READ_LINE_16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) +READ_LINE_16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) +READ_LINE_16161616(XRGB16161616_read_line, px, 0xFFFF, px[2], px[1], px[0]) +READ_LINE_16161616(XBGR16161616_read_line, px, 0xFFFF, px[0], px[1], px[2]) READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px) @@ -659,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 941a6e92a040..1e971c7760d9 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 Mon Oct 7 16:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13825051 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 75278CFB44C for ; Mon, 7 Oct 2024 16:46:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2957010E3E1; Mon, 7 Oct 2024 16:46:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="inzug6K7"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1A8610E221 for ; Mon, 7 Oct 2024 16:46:27 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9E91540008; Mon, 7 Oct 2024 16:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319586; 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=TshjFsEcmwoQXvk8So0jN9vV1qz5TvwoCPRDKomZ+Ac=; b=inzug6K7nln/+wo6fmTC/tG6iHM6RjDLpIZfqQNfmE26fJZRbEUXveZtkR4w49P9G87BzA 6EoTHQMy42LFZpgbCSpxNzG7jMICDvGyVEbcMBBQaQkxdN6AqfvICpC+4Dr45DxImqO2pq aUQQ6mqeiBLtVp7cJLZ3ZgOk9bpN/LqNtElQELmMldZVycCi2e8DLv3yWvwtO/FO7138nr SXHUHaS5OH6CSWX7ysAEe022LMZpZvgP0BllZEllqlx2BqwrDqPm8PtsPK2GPO5HFk/9ag BQ/+JonMYMrFtOykl3ef8CfB/wqvBM1V7hdzP3bZaEfSij8uS0r6bLpaB5zfsw== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:09 +0200 Subject: [PATCH RESEND v2 4/8] drm/vkms: Add support for RGB565 formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-4-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2973; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=tjCECeaRUNgLtjoCubWJYzz5yqt33aSKr7lRkrSGE3Q=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBbJr4y73v18yqNBvJ5HKR+bm1UF3UwLE4Xg 6zAJDQYza+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQWwAKCRAgrS7GWxAs 4iBgD/9U6mvHY83R1kx5F5efuprOX+EwzYe3Y9i+m2OVxlpZFUON4AN4eiAAMoGe0zkI6bVE+Od tV/gbvXAIe/9zsyqYhwnmicpTKdlt+dlnC13jpSzl6yzYIFWpze7+4umQEduUhIGraKF6QvlCww J6GT4sOGGxYBzX8VOa48HfT4XxNBwg95oKszp9vkR2Pbr0GjDdlrvaUUmsNQ8LZ5klh93pPBuGb +LK7DxboP0C/BJgO3WI9d+j+a+eXLoK/MBvMRtRUZP4tao4P+bdjKJR32BGLkgR4o8+eXdJsyZs kFDkfkftTmIw5l6wsRC8WRwJ78nGVnadQfyqGRaKCPDYSYrrGPYs3s34no8VJlDWZ3fY5O95tAl lbL/CRh6m4K/4d1t/vWOpq7t7ArlaHdy/6iVRFSIfUebeJlZuf/PKSgxB57p+jAvz9SfpJlehRs 6BYW3/faQ4/6+KEUMvFzwUpJcMhhMByzeqVNkcWwUNguPsRVQnF05BveCA0XjmDvRc5+37/bzRg NkzYzpKaKL0X7C6KUEWHkgd0gEkb5CT+K3SvJ33AKAyrFetklPfXxUbD6ivwGAYGmUxgWBXnLOL kKrv5ubcQ5kF9XCw2u+k0Z4SmfvKh3k+HBVOqa2BYw57bBRD2rQTO7CaSwNEKQuhPL7zpMiwnGD e6JZOhQv4t7Kj4g== 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 | 25 ++++++++++++++++++++++++- drivers/gpu/drm/vkms/vkms_plane.c | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index c03a481f5005..e34bea5da752 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -249,7 +249,7 @@ static struct pixel_argb_u16 argb_u16_from_RGB565(const __le16 *pixel) return out_pixel; } -static struct pixel_argb_u16 argb_u16_from_gray8(u16 gray) +static struct pixel_argb_u16 argb_u16_from_gray8(u8 gray) { return argb_u16_from_u8888(255, gray, gray, gray); } @@ -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_16161616(XRGB16161616_read_line, px, 0xFFFF, px[2], px[1], px[0]) READ_LINE_16161616(XBGR16161616_read_line, px, 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 1e971c7760d9..a243a706459f 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 Mon Oct 7 16:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13825050 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 779E4CFB450 for ; Mon, 7 Oct 2024 16:46:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F6A310E3E2; Mon, 7 Oct 2024 16:46:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="ERjIjuH5"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id E848610E3DD for ; Mon, 7 Oct 2024 16:46:28 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A29A24000A; Mon, 7 Oct 2024 16:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319587; 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=NUZtJbmneGZ+YDYKXPZlJ4H5daa7MYGpaeYcet1yA+4=; b=ERjIjuH5kcpOrHg1MTdA66XBy+TseV6GZ6uvCl2j3JBeJo6OJ+zywCV8P4Uosmj55MExsu 4IDy0v0oKnmeQMNTnfzzFxdW6isLctvguOCXcysEwTpqhyLOaqSnp+IpHyw7JcVTciDuBv s5lxP8+H/TlCuG11Kx/MSmNPBrvBicaAGGHecyJTKDr1Zl1a54/IYeXg67VNq7MTrae8cf OpWRP50nYAQtrTNhw1YsIw6UXYJsDA/zyZJeBOJA8K5e1QLWYp4VylAISOUqf8WDRMhdLX Mf00eHnWMW8NU0AMrdjyehlOAV0O1Xxvvj6ykV46ITsicqWVB8hAf4qzg/cA6w== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:10 +0200 Subject: [PATCH RESEND v2 5/8] drm/vkms: Add support for RGB888 formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-5-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1933; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ejUk7GS/wHj27mDvtIilIsC3ld6QfwwuT6b3J+l/QQU=; b=kA0DAAgBIK0uxlsQLOIByyZiAGcEEFygqa2gVvD5i+nmBNcpxWN/U03jKrNmhXVHpTSf19r72 okCMwQAAQgAHRYhBE+PuD++eDwxDFBZBCCtLsZbECziBQJnBBBcAAoJECCtLsZbECziChcQAL7w 8HuxKW9q2+67I8twrwe1h6QjV3qnWmcFrUK0CASynJmlxBwJz5b8SoazK0CYMySXYmIFrq/njHz k2QlZc7gmIoaS//6z2qHrD7eGFD++3Ycc2wikRxOpeWRI21lrXMPkUnotL+u/EvHi6YJa7aHFWC wHWR1cpbRmtwjtQcE7GAbGwi5qzY0w1Ho9nHh6srt80LFZ7J7vWovJn7LdnxnJ/sq3Eq06DitbI lAiLhzJPNyUy5Hz69F6xWSGtAtdmvIgN5JSE7at+97me/pDTYTT3DeeaK3MVhJSqp7fwhAzzTuE 9RANWHUKVkhtEaHmkeUYC4Yk7V7NJ56NcGSXa1ipMXNyqs3BhY2EEt0OybiNFsnexI06J0d5jt3 PqgKvS1xmsYMr80v0qYeuV4lNAS5oQqrK0L0MlGeEbrngdG/LD6pxRCFK83fGD+MR6LA0RiCJ0R SxzIdoRJQqZ+SgTmx/NC2if6e89vj7SZ0tFUuhO75yk2cGwhqWWnHJbhkgGT5AFnmsgV5L2ow2U SI1LArOfS4RxRh4p6nxx13E+Zmk0VIqakho1oqBFmI3tFsk8sjn0p88UbqJxjgvOVOaB6n/EeAr kGyZWiousOy2E4TLNmy4DJczrP3CYySnmfH8B1Qn85AF70AoyAdnAFTTvpdyBEZzBFxaysOx/fP 5L0Gt 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 e34bea5da752..2376ea8661ac 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, 255, px[2], px[1], px[0]) +READ_LINE_ARGB8888(BGR888_read_line, px, 255, px[0], px[1], px[2]) + READ_LINE_16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0]) READ_LINE_16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2]) READ_LINE_16161616(XRGB16161616_read_line, px, 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 a243a706459f..0fa589abc53a 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 Mon Oct 7 16:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13825052 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 58CDDCFB44E for ; Mon, 7 Oct 2024 16:46:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2249710E3DE; Mon, 7 Oct 2024 16:46:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="gq/68D/T"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id B048B10E3DD for ; Mon, 7 Oct 2024 16:46:29 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id AACBE4000B; Mon, 7 Oct 2024 16:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319588; 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=gxNnUl0/K3ZNU7G+bCMDMwqFMAtqMIbVXdpL0QRUP+4=; b=gq/68D/TU34/bPcQepZTB+p0jQ+ImXx+XX9RP7aJnjOuzLzPkJc+sHpoSM3TRyeX0jqBEQ aS+q62JkH+fxE8zC/Gtfhb7bL2D2gm5839fYTh8k1ZuPVJi0Tjq8na+W9k9dDdMpztewjs fvbJTQeUVeVxF5uAEOlG1pIt83VxBRldPNwkhIBjo0B4pYAXbuB4K62unWnFNyrYWaiVBi 5X/hKbYU4lYxlXAlSiw+m//PHMFJY7BjnMsgs30wZp0vIZ7fYTb9zgZwjAQ2zhQU04HKdo uas2fKqMXujI5vSQeoIY6RKZJuY0M9cJ26z0wLbejlRVG9DqiE4ZC5+rlOVlzA== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:11 +0200 Subject: [PATCH RESEND v2 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-6-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4712; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ZeyGQ9NKZuaIVfDwqPXIBSpa015LI97ViIOjeVCzOqw=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBczYh4vY/qRK7y2bBKipT+L4mvGcq6VuROg kj9PRs97vOJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQXAAKCRAgrS7GWxAs 4kKxEACmLrduErsaBL9VLAo0CLffOrNb4cHT2OXmuDSacrLCNoTXN7of/5mQZ2qW3igmCzmU+Wz KFg+PRAia60UeDYfrOITEp/2p1Dtz+eb4rsc+WLf+htEFuMHzssxqnxRrSo08c9/thKClqCiAbx WeV2fQW9CE+skUuSRsY8QWDphixj8ufmHdcbM31SncpzmpKHB1vRpUXOq4xBX4nU3K71ubxiPt1 fxjgnE6nCccvK6XXjFaQNmMLdM6KHCev7chGSzEGMJWiocR2PDWQGf2sI+lwke64Z2AS3qnb/mv tgU3GsC6V6pFXgtXt7uVHouN2Z8X6PM4BM+plVg/JWRz2iL801TkGobJH5xlzNfo4nh60yHdseQ mZp0rScOo6AAF0Z5l4e91RPxu+/2sfKFMBXTl5eZKTU1w4O+ZbYKhnoWKsdZijegtXnQl+qXmyU ZcXafcie0o7SmFSiYQc/bTmI8oah+cA1vTJQ5qCF6IjhYtg5Ba0QFwIrP04hHRBdQs/R7SWotE8 etIetjvwICA6AWxdG2F7KCehQ64tSLgtXTGtFFabcqauOJNVuvTTYMh0gOc4wBsx+Br8iHZPf4K dMQyWM/03G7jqBVQRVqoK8y8GGY2gboPRNeuAvRA47nXozO7b8j+6Tnb6VDPS7XZTBjuOy5Mm0v 5u66bBI0ySPqoJA== 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 | 22 ++++++++++++---------- drivers/gpu/drm/vkms/vkms_formats.h | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c index 351409897ca3..e3a77954e6dc 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c @@ -188,7 +188,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 2376ea8661ac..95ff15051fb7 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) { diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index b4fe62ab9c65..eeb208cdd6b1 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 Mon Oct 7 16:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13825053 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 BB005CFB44F for ; Mon, 7 Oct 2024 16:46:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CD5210E221; Mon, 7 Oct 2024 16:46:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="W3j0pvXu"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id A75E210E3DD for ; Mon, 7 Oct 2024 16:46:30 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 911724000D; Mon, 7 Oct 2024 16:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319589; 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=SBFkqUw6qRPpemUWIy6XE7WDsmixV5/4fP6ZTYrwH4g=; b=W3j0pvXu1hIVHrJLz6tHa60A4Jy9fzQvVlZglMXt0ZR/Ge/SJKcSdUyf2TaowwxtHweDvO 9vCC2XawoeiAAfXHO6IMJsAUGo2vgCowJtQnLEQKFg35R5yiQyNyQo4EWnaCyWdYOGiqSq W/NDN8OoDdmpBa2TUdti2BnjLNhdFMOEHtJLAspVIWzYIG6KEuUEm+5zuoi4ez2mf8JgdA L+vfq+elhgWzY5u4kMXJy/UpSOWcXrYhdglrpwf8PSNxf8IRxsKpOYTxsWkIP4tBEgL6j1 WI0M0P1dQGvF9W4K6WZmKi4wLQaFDth0/jgNS5nBfx+tC60ZkrR3onjHrq3jPw== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:12 +0200 Subject: [PATCH RESEND v2 7/8] drm/vkms: Create helper macro for YUV formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-7-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5213; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=iDCATnOisVW9AbADbs15OqvAQPMoCXX9E/U8YNafD+k=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBc+tcYiQrFaWKfFBUucGoc4yU/6SBk/Quqv BZiRL5YWIqJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQXAAKCRAgrS7GWxAs 4t25EADPB0Jok1ppASoCiZ129LoRHGkE3skBtw83KaivTvnFqnqhOPSFrm/97iP25vLmxQ64WBL wBkz+8FPfiaurDIrG4dkRn4dgaoRoY15VJyHR2gtBDiRzwlUid1ZqrHpryakd1KAi7T3vjGJq0M 7sn/I+RoiDzP0/fYbymYvygQEOkCokFQMXT0WHkKcI0X84WuOMDKVY7helgATUcMF2UP2y6pLcN Bw6QOPpu6SBIG7LAn/cMo25e6NWY4i8lHn70qA1Q3H9staHP2S8Q46GNpTkJhlYo5Mp/29QBb3v qo+G50dS+IN+WkDbZofFSnkICo56qeXrNQJRScjOuDwlWk8hd5m58o+Ff0m8vhDjDRoAuk1e1Ya XP8wQq93g+fwht6exFMs0gwJgEVb+nE3qg/IqzMpT4zTZoAKVV5zQqR2lX5cwMPhjywOTWM2xUS MDtBR7BBneuIBwHn2yW0nSimdkNXzZiBdMb9SB+y84MJgVbK9cOfMUCsN5UbR5ZIZC1NXiiJU8X 3//TIxJkMQS5LO9xLL8IaTUj6iTs7rQM8GKB8pKmg4BT6kGSa9ZPnJ0R54hLNhfH8m6WmjjUQTa qJ01F2p6OUpd92vcCPOjxNtBV5zQoXHcl8IfqWSap4CtOv/V0DtaCs7sTS/c8tVYipcAW5U2ClX v37HZ1t04jFtW4Q== 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 95ff15051fb7..1cc52320475d 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 Mon Oct 7 16:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13825054 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 2DA47CFB44C for ; Mon, 7 Oct 2024 16:46:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB9C110E3E3; Mon, 7 Oct 2024 16:46:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="VQ43bJmw"; dkim-atps=neutral Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id A856010E3DD for ; Mon, 7 Oct 2024 16:46:31 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 80DA04000E; Mon, 7 Oct 2024 16:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728319590; 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=xUqVo+rsIarUdQ9nThu6rtZixqT2ecV/BMOIPH+GeZk=; b=VQ43bJmw9T0aDcfHRC638iVpqfF9uGkwF1M0ImSukWgJvlAi25kbsoRV+//0eqwO4RonjN gUD41nqGtZCBCIzxzhX1OLg8HlPfjurY8+C+/aAIT8wtQe7xhI3rIrHK8eWpDKXE+ZhVt7 CZF47EorieU6Qc5Jik2AqffI4DjHMAohQrybnXlJgxvOcBzz5fbPGwW5x8jAMYoD8zfPes vXRHiAKaIbZxgLzpgsbNqIqHp/asTX5URqzwXzC2k4Lx/lUiOEvqqrw6Dcjy/kz6V7bjfM meVCxpOar1xcFZM3lX59nPBDmm6dsAaGxH+DnfEDScSOnPMPuifzA3CCNXetUQ== From: Louis Chauvet Date: Mon, 07 Oct 2024 18:46:13 +0200 Subject: [PATCH RESEND v2 8/8] drm/vkms: Add P01* formats MIME-Version: 1.0 Message-Id: <20241007-b4-new-color-formats-v2-8-d47da50d4674@bootlin.com> References: <20241007-b4-new-color-formats-v2-0-d47da50d4674@bootlin.com> In-Reply-To: <20241007-b4-new-color-formats-v2-0-d47da50d4674@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 , 20241007-yuv-v12-0-01c1ada6fec8@bootlin.com X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1885; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=y8C70ewoTgGfHL96TQe4gJLZQgBlDJaqpUWN8xMc2SM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnBBBdO3f55XEK9pnuYa/9GHdQXPRaM2/n6xGoY w5U4c8bFGWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZwQQXQAKCRAgrS7GWxAs 4kmjD/4t1rVvULWoAs9Df8w8312noBCoUn3740HZi9Db+/+PZcT7UcwaGQZgoHtV5Ti2z20Q98w xcGrlUDYrkQA6eB6+pK0DlhPtHpKq2ufLkZc4CGr2689us1KzjK8dcTy1BGdZo2EsUv4OQ+at0s lgz1KhAhcZ7al0sYIdG/JUR/rLt/S5DmWFlrkilTk+XyC1UKQIGLlutrcMYm9xAzdLA3DXUCNBd 7GfNJ97UFjL11NjxQ67Y46bTqkiLj8dwqp5TlPlmBmoWh4J3UVIllHVPYj6qC5JiNQr5QEz62cl W7mbeVGSpZg6vEPmR97nGvMXsFYIZ1UQsSnh7n2wH+14PjSSJdv0MDcSm1oc8/hJeiykKRV9E4V QVLNLHNX2nkX2EOPuE26N7A36cTi9gtcNAra/8OyXCxyLrPeMAj7giw3Rf885Lf0yisRpPxw665 4qnVkFEo/WeXojKUwhFrvgbXzjjmelHOnfmLccEUwRqjQT+KmXC+ilk3jg8i0/o+RIUtuvExLkA MqPWZbtWo5m8wQXQN28urIVmG7SVRnBFuq16/oPVIZJrewDTDzcsGhejYkGnVbMsc0D2XgRL0gX E0ehXiIi7VpoI9fLM0ahFWXlEk7BK5txA11KuGFGaVom6jo3nKZ2ITJvkQKmMgiMbOs+nRpsB5H +et8tHpH1AoJfag== 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 1cc52320475d..d77718d8e01d 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 0fa589abc53a..03716616f819 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,