From patchwork Wed Aug 14 08:19:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763046 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 24DF6C531DC for ; Wed, 14 Aug 2024 08:19:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49BEA10E080; Wed, 14 Aug 2024 08:19:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="PKRFQmdQ"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2508310E05C for ; Wed, 14 Aug 2024 08:19:48 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A23DDC0009; Wed, 14 Aug 2024 08:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623586; 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=bu6viIhSnWEgk66jXAPqJNV5YI/xtHGtsXjAa8vmFoY=; b=PKRFQmdQqPk5Sa8ROniRn1YIFSYcSpDb0BUM71GUHjXjTlau2MS6Eru9r7MW4Ca0fZnEoC 7C2/bZO59SjkTPXIol30Lzfz3+2BFpIY2G2afNZ4UG/R1bPV0CqJPOdQduSjQZpJVQnum4 BES7KTmVC2cyR8c62V/RemxbKhjHVGeXRnUxUEx67dD52cydJWqEdksDy6czON2O3i5plc WyyUpSgsJJrF/l5gicoJ0+GCquZnX50if3pzVvsJir36a7ZZ0+swSaS7UixaUlQ9fi+8P9 5GO5vKRZTlaJWqthmcPr0FXp0cjneTazykaQqgyOD8eDR18zn7GJw1rUvJeKfw== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:34 +0200 Subject: [PATCH v2 1/8] drm/vkms: Create helpers macro to avoid code duplication in format callbacks MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-1-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7762; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=61wrT+opDbJNU/QfX9tV7dco/mpoqSN98WVUgQF83xs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGiewd7aiG/MsG8j8TbEvGKXALbY0rBr8W0C0 PK6KpqqXHSJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxongAKCRAgrS7GWxAs 4jI0D/9M8Ia0bPO1onu5fapA0CKsoSdQZCLNbZoEqSMTtHVAKPabrNPKtv1r3TxKdVsOpA8TWqj +LdBIDe+R1eJMMwM0s+VeGcv/1owgdVPFe8BfFFWoGLNoC9rtfMnEXi+Msv/n9wqXKPKwKdehF/ SjxePici57dWhvqEONYugJc11go20GVvn031cTykKUsfHk7t2Nnr+qMfruKiHCirAPuQx/bcMSq YZc8SHBkAP+8/6Z+wRQPCgNcNf7m3BeXfi3gpmZS07ZBvAEImUvJoDVhK9upgbPup/Ym5EZ3WaB KI5Jr4oHUbGD3b1imCoh3Yt6vqrfoaY1CVEK3dJQpSMrwjYzL/vvSVYcDqTIJ9IoFZhjq1RNOtb nKVXymkGVhgN8GCz5JtYisfeIzXX0xB/WGRAehwi9k+oNr2VW4aCzmelWvlU5grEXt+TML57wgv CEpuSH0X617AKCjYE2tamRVBvp1S4EfFrlqmASOv4cj0m/2+c07wm7SH6QIA7+2k6f293zinxE5 xtPl4X4eAJWZ5n8416W3fo3dqeEdvN/HktqH2F1UA1pB2w926H5dRHVQzne6Ks5mDvm7KyU1i/N Mzuv3JM4W4exTnDgxvL3rqWBKOD4Zom1TSxMD582PxFL/xhXNn9F6aP42ljl8CtARfGxT+M4gyU DxSGxZenJ4kjqcg== 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 3065086a7ea4..a03e07874b9f 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -290,6 +290,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. * @@ -376,118 +428,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 Wed Aug 14 08:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763047 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 04F04C52D7F for ; Wed, 14 Aug 2024 08:19:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FE4C10E410; Wed, 14 Aug 2024 08:19:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Bfp13Y4g"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 349AC10E410 for ; Wed, 14 Aug 2024 08:19:49 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C25F8C000A; Wed, 14 Aug 2024 08:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623587; 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=FBWf54lXumZ+hhRHe3Mk0Bk6xMn84yJ+slIW6jLvcVE=; b=Bfp13Y4gmWOZpIY/pOiBq/9ZYw9xik1bz1wnQJuZwN7IAmxUYSFxZ8wx2P7RGmUhi2g+Wo MLfMDTSGHHToc4jwE5Rf3YaQcc7I3JL3dhEv0sqH8TcSP0nedOVpJCQjh18/Q8gkTmZg8P z9I1ktq+KKWvr+gNF/AX7Hw++0FzHpyh8JqaK+UYNt0enG8GNbKHXKu+bdZo9QAchqaXyj DFSxu1wccj4wFLIBVQLOtrlxsFg1w3A8qp7OKhWCRxx4oNWuxJnWY/uBlzdFxTgMyt3xvq sEvvLcHybuccOHwRMrnhti8yg6LpTgzOhxTKL/H6tZOEo+qzFua16qRLLxUm1g== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:35 +0200 Subject: [PATCH v2 2/8] drm/vkms: Add support for ARGB8888 formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-2-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2595; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=tHOYCwndCrcrYZ2J3sSlvyKyS5INO3/s+AeO+x2ugxQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGiezmnsdW2O+kYA7nkoemaW2L5qDmqBOQaD3 9cNCzDVnf2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxongAKCRAgrS7GWxAs 4juuD/9TswEtuzCen3eUtDa9j5+pr0ZezfmHrtvWczfey3mHOkL/VnZi1gZ1mMNeCVllgwwgCOk JsjsVII2v5fjC2HfV6/7n1Y86hrq23cMf0muzGYmh83mipaE64T/VIffTMmZldxy41p6ObE9i0K iDGt44QopKdncR63CElehTtbqmfoEUCDkFv3ko468B8OeDV40df7oKBitirD1FQgBSbFWOzmQmN pPMvFYF6lK8lsBJ5Mjt2NY7SetHq+1vsf9HeihlMFHkkYZvLzgqCvlAAT9Bd01DkbhQJA1tH+U+ qfhuTZDglyZKDyTRcB00Mv5z2Wi9svjZh7q8Zv2U+QRTgJ2+FjU3R65QjGgCbRlBPtpTQW8ogv9 lnuivB7JicKJqRZyin3KrXSx+/70tUN+poFQX9Ff5KvbKuJyyjko7ga+tRTcV8g0UJqHmZAl1Hs ch/gfLoGc4Nre0RAFBhWIqT8kq1yw8BkJxfkedfYt0WeEJLMEEaEyKu6u1KGD17AlQecSc9xaO/ kDCycqGYSvNxBeU83/lxbIMM+XRQNPRcdSRzyA2a8M2iccWzOnnO7oykVRyCVjk+mYHYSWU6ihK iRScHNhdGQ1zfuVH7dBuImR1SFJx8Emj9KleAEGQnrFv2AZ+vIEtGZRcYGGaQ927fNJ5eM2YXDx Kdq+ujnLy3LH5FQ== 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 a03e07874b9f..894c83c31f97 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -430,8 +430,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]); @@ -635,8 +641,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 Wed Aug 14 08:19:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763048 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 7833CC3DA4A for ; Wed, 14 Aug 2024 08:19:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8992010E418; Wed, 14 Aug 2024 08:19:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="aMPF8Iqd"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A2C010E410 for ; Wed, 14 Aug 2024 08:19:50 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id DFF6FC0004; Wed, 14 Aug 2024 08:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623589; 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=1bQW4w2sqK2bHnvmD4jLbo5BQQSO4DNCwJ4IoRox5zE=; b=aMPF8IqdYCWqFKcc4+pX5obOXr3ZmBA/OAxDA4LQWdOVwvQpTxP8K1tkZOQZwByxneueZp QkZdlxe536LyzIOLThMwmAUnNsNYn7BKqiw0a4+6ZJKELHg4KS5zg9b0RMDqN0xFthcC9c ScYOujjq42byXzL0Rs/HDKd4C131sw+bjtUHbLcoG10Ceq6++iIZUIacBsKceWCc4UsmUc 2oGqR/zuIX7yZmP3dnhCqeAehABX6A2ZVO7/8Ev3wjha4NQXfUwmyYpw+y4ISUnPjF0q1T 17VuXmhQ6mydWvumhQPd6kiI7SQTJNmsJTFTPzglr/f2qkrjZ5xj/0uzHUoYjQ== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:36 +0200 Subject: [PATCH v2 3/8] drm/vkms: Add support for ARGB16161616 formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-3-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2312; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=U8nQOSe6mzeM/r34Hu9pqa7sb6HD4D0ZQFRXh+EiNmY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGieA3Ipv89pfkoRjeeZqCGXtL9ep99nU5qiU MIx8L8Xws2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxongAKCRAgrS7GWxAs 4oOTD/4trJka3DwIkcfr0vmGkAt32XYzAGxEM/bqz+X2ADeW30QnAOdBr8M4LPSfqPTDIQZXOul BWx/6RK0TbGaMrWl6mDfXWu/ZI1tXXrWD5dq+Jh1Rl1sBc0WrscKTXgQ+pO/I6HUcdyDE8X3dbx aHLLv4Was0F3MRHRrNDX+NIQn/EVfoN7Q5A4vKB9PToQ5rJMEXBex7Jxjupi2WXwSrMIrrPxkBx HL22SfK6AW9aVjvH8tk4Ou1LPov5DpvQWCIUD8RLzrStUGu2NRHW6yhvR6y69BMvBmXyMQu7ZT+ eGAq5AsFHiJHDSLgtj9o+XfSanec2UOGEfeO+pVumXOXpLNbfVBRRORVNAtIK5Ro9aUSXSsziPB 4SfGyMPGX+tb/n5wkRDl5BMlBZmoJKUMvpM0dSdlx5e9jA9YxsT774rbcq/nZ82DlUAjcpS0/Hl rdtRg9l15JW4EH2KamrOnsuNznVa7I7RHmpsLzzBeknHtIsqP5MZ34CGNCkurkh5b18sIZMwPf9 2SbxCvQlXmPZQx3ZN3xZ2i+RWAq1RFVgH5/0Bh4xLOIXq9Vo1Ypldc0IM/tcmucvOWvQIg3iBMp Tb+6J6OFC2dk7g2Yoyj0ptdPP+yf7VxyYxbwMIP+1wmamjSqHJ4vpb6TfqSD7g/Nl4p0nIcV1ES VrdqIza5hs5YbQA== 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 894c83c31f97..691fd8275f14 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -439,9 +439,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) @@ -657,8 +658,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 Wed Aug 14 08:19:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763049 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 58080C531DC for ; Wed, 14 Aug 2024 08:19:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2383810E420; Wed, 14 Aug 2024 08:19:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Sd0rbp/z"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7345810E410 for ; Wed, 14 Aug 2024 08:19:51 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2BCA4C000C; Wed, 14 Aug 2024 08:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623590; 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=zFpORCPNREBN6z592weC6FbCQDcy1ab/TlfzvnZajH8=; b=Sd0rbp/zVU3E5sdAO1ovMShFfeeQ/f76tcf2hly1/2sRQZOzuCyPTyNqIP09RHmjWMus0+ WGT+PqQmdEL4a5PljmvRgHwb3aNbGbFyZ40ccxZM0V4OkI8CcOzXVy8wPDEPYNS3X2puzD KJvopmH5m7Zrb/nv3d3mOq2dNUX65zFNTPdIV1HhOk83hbaHIYmYzIlBVtM/RgOYh4JnJY pkN621pXFqQRuC6SUcdTcDICPqqPRY2ltqj6h7mSsTl4FL6Uh0rHXFJrQhmmBGnfeVdbSQ y/Bph0YI1Fa5KmcizmYE6scUbXLRzpTF7zve9oQCt7NRvHTJZnUr8Gzf7Cu//A== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:37 +0200 Subject: [PATCH v2 4/8] drm/vkms: Add support for RGB565 formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-4-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2973; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=RBF+mOuEEb0DdX+OD7VGfrmSjVRcmOGK9r7zIRQVJGs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGie0Uv+IgeM70/olFWS+q/JLIewBCr8JhF7F fA1uWNJiu6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxongAKCRAgrS7GWxAs 4tfSD/9x3h1HuQWRGpzyh61DU+16EAsEYhot+E9HJIKo+J427Hy8DHd7wiE4zBwNiljVIouKJad 4ak6RGZVl7+jHb/ZpelosF1Jn3gqUoPKT1yIBE+o8q0jcbgjlhuV/NJ43GVqxONWKdpFKeW77NB sF+mRK6hgoA+40yBup59ZrC1IXIjmIs8WG3e5+OfxTrLnSr4BJCh7Ur4Sy8IwC86L0neqD1rTDA 284RN80ewGRMqv33FsCNenCNcyIBKLC/aPMkwI/2bdq51ul2vGhO1YZEC5UTQWBTIFnQyAM5TQJ u749opsVYoyy5hvrHmxuaw55rbpo9+RthzpniVm+FFr80pNvpZ1vHdpsHjpo4kIETFcX+oXpqmd OK22adqMKJUJdrVD9AaIqvd04wPUgq8mAP4/ysjXL+xBCh7n2F+kcQ0312zPlwXNn4McYY0kRWy ox5H96k1s0KGxeHjRg1jGe1XnnKzri2V1PlyRm7oqVoQdtlCNNvDB2ZfBi2z5N0N9UM75oMXyr4 h8UGAtrFSNPXPREMQVGQdCsmMrj5iX5AInDovU69xaSSybIE8JRVpcSpNJsYg8FscBG87blzNsz pb4zTTjgHj/Peqb0mXCczAAVYMIWL5e52/LBtJ094WITOqwLsVjyj3fy8+ftHl24SKEgkIuBFB2 EIOdZjVM0JNS9Ag== 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 691fd8275f14..76cefd301b4a 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -247,7 +247,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); } @@ -257,6 +257,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) { @@ -445,6 +465,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) @@ -666,6 +687,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 Wed Aug 14 08:19:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763053 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 B02B9C531DC for ; Wed, 14 Aug 2024 08:19:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A66110E424; Wed, 14 Aug 2024 08:19:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="d8pyUrR6"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id A431910E41F for ; Wed, 14 Aug 2024 08:19:52 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 573E2C0005; Wed, 14 Aug 2024 08:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623591; 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=jwwNkXRY6lmEOrw+igTtyBvP0kqQ2nuCn+F4aNEGdA0=; b=d8pyUrR6PvMudhd//6Tee3KDrZG3EWCRfU/fxIlCsU7dPz1Ac7MgI3a4NreTU+OTdENhXe e1O4HREcqIodD1CeGIAwVJ7eGw5qR2MqiVDZ/EJ9l1ghc5j0wpkVUbqHu0jlb2f6WhX3y1 wEjvsC59RHDU/9WnJs98Io+NuBOJBuNOwxV/ZOtHuEtqO5UyJCqhD0ObuftTVgoQsYlZH4 HFFRveqU0VERF1qKic2K8NZkCJkUUcvZC7v2Qmijgp6pDzH9fPy709OMwc9fMt1d12NolZ TxL8Np1skak2jOTiAAz71xybdyexLAGAfHL2FACvk2VTQRMkVL02Fh4IKu4z5A== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:38 +0200 Subject: [PATCH v2 5/8] drm/vkms: Add support for RGB888 formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-5-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1933; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=7ArWQ6zmluvsBt86X5iI6qfLzvj8UuOSAivLRhVa7ME=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGifl9B5RmcfASNaIaQhRARs3R1E5LCSYIVw3 PkLczYF4TOJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxonwAKCRAgrS7GWxAs 4o1oD/9rd4sBtqP8VEkWITf/LVIPQw8iSTTL0cEaUm5yoJEq/CF5p7cZXpiry11y1CqQdX653jt ht53CLOnESvWSm5K00NuteMEtqQkCxyu/Zr6GXlxBwf01xVIJ/jI7bSL3jkyN5sBQ2DyEgfc/On AwvUwGyOHFeElBeVfYj1jTj1tYBXFvnvpxMXuT7GOa1x351S4BzDQg2wYyXqC0KpHGUmRU4uAIb mfW69IvEnBtYAXDE5nYTupaYe1JxaopO7ENqhZhS7vQuQW8A1eyuGC1x3+qEw/ZNe5dEEBc/jVz W9bZ8AxtDxao5q4hjrHxtD76/sLtEmHHAy+vZ/W9XRiTcgK668XFzTEV5iSoMldPI+WMNjnlH3O 0I3lf7HzH6XQS2n+OTNnJANqwUBuGvJ33tYIKY3aVL3TzViwblayzIypa8wRGNOxMoWpMWw3EPB rs6pZ+5kzYcRvrm8UrB1U1RSPmcrQlZen3M/4VvvNI/7+fSBlZVsd5Kc3/4RXoV+ipAI1tfS14B Jrc/Zht6xfNUD70y20DwjgIN5bSEkYuTlhXWKRIIq6ZG3ytmyeUbPsQsZOONq/UEt0+WYjiPI3h c5Nm9fWlRV37EHMd9K4HyOWvmxUcO42OIlFC8jIxigsuxBu9Fw7X1YyI3ETXr5RbGO2HSzowDw8 45GiXmDBcA8fOfA== 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 76cefd301b4a..b7c378552340 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -459,6 +459,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]) @@ -677,6 +680,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 Wed Aug 14 08:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763050 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 5144AC52D7F for ; Wed, 14 Aug 2024 08:19:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A44710E422; Wed, 14 Aug 2024 08:19:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="L9iGdTF3"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED98B10E422 for ; Wed, 14 Aug 2024 08:19:53 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 84ED9C000B; Wed, 14 Aug 2024 08:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623592; 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=op2K3KJoi4MhR/F0QxDi5rBLi6a6hU0wv7s1ktIoY50=; b=L9iGdTF34KOZdzBG1/ai19BeeUaiivpb9TfcXhXksIt4+HndamrKZX4LR/BzRljldYCByP 1qK1L5fy5n0zpOK/yOJmSLv2xUkgcxo5hLGDQYafmAXAtxH8asXbggIdlrbhRDDPzbRbGO 5hBcLu4hkBRWIvECnb8PiftwVzBbuLWZoY/Tz7mBTmEBYBXO7THpXqS3r/7tCvTk+gaCm9 /7LQI5DSNNMk9xV+1n4a75vatvPy2iHZhKlVb9omPXZClQUcLjvV57PwcpdcezWleY2Hek jTPy0v6xz5T52HfCu8KazzgxXzV0sqPRemsamZ+bnNvgxUduiLtWY0ZO+jDm+g== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:39 +0200 Subject: [PATCH v2 6/8] drm/vkms: Change YUV helpers to support u16 inputs for conversion MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-6-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4712; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ha2LReeTda/VFQ8tThojZzBeyjNxSlOLJhSv50oIqfY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGifkl3EcsSGMWWw0rL0DS9JEhtBFSZQVitS9 aNihFUnPw6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxonwAKCRAgrS7GWxAs 4mtDEACBrb3u6N4EDMd2GHsp9+dp9EUu6PBQiuxKyvc3NS6LDtXIcrA2W9S6YjAj1XsqZBXmhMV 55/lZnRYFs3SBXKZLkuMKqE0th4uDj8xp1goZPNsrBnYnS2Qm4NeqnmQGOcZfdYCX+GxxDYij6L IcCHLjdJwOKCTwhqIMz88NQS306FmlyQzU+n8XFa9Zgw4pAYY8LSfv6q5xj7Qr/F70dHIoaIwVv glOVF8OdoJ59UJqqIuV+N1tJA2GXohYHTeeHoRFU6Upoo7cp9DuooUSvIl3JSqxSLcwIab9AxIa VhftYaxyGRVXaaNA3+o4tnckY9v/RsER6xfGyzWPV0TOtEE/gviLTcPctgFQ9G0eAhLjDHN9Rpo vKGUtTo3ZWqGo7Pfwe1aBX5e6OyF0BDPco4wtKhk9sJdD+/MEjkGIJYnYcnXKC093+zXHou0LaI FGy7C++n4ePGbijz1skKktjxS5x14OO7pN8SA/AMmwqXHLb663xNKPsb5dD0d7QKFDKC/PRlNpT g7seJbb9KGTJoWFad7M0Z9yLueQoPhPJWK1UMvPtyYt3ddqvEp016Kc8RwDlKqkKENGj+EGgSpi 3YuYEu3fQKcp92ILfXQP0wJRZWLeumJxU5OFXDEkoKabmaiLfO0etm4KknzsG8fX8/wEARIuLF0 By3BoeRf3V6HL0Q== 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 b7c378552340..71aae2397c5f 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -277,16 +277,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) + @@ -308,7 +309,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 @@ -503,8 +504,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) @@ -548,8 +549,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 Wed Aug 14 08:19:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763051 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 20B67C3DA4A for ; Wed, 14 Aug 2024 08:19:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 468A910E41F; Wed, 14 Aug 2024 08:19:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="fIQCuJVY"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0583110E422 for ; Wed, 14 Aug 2024 08:19:54 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id AD01CC000F; Wed, 14 Aug 2024 08:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623593; 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=+XLqR/82ccZGaCcoGlm+qk8KiKsKQqQDLhoRWrH/3Qw=; b=fIQCuJVYWFiym+vsfPj9/bh1x3x0I6iIQY2PaYQDdM0HkCGOXcPXj8juqukgl6X5aXKfgS reqeIvbrYRK0IML+I5qCr2TxSqRSPNAZ3uwvV+BqewlEUxCgavcPxTSLY9Du8/LkwboydO baRYASH3yyqKv0vHuqsoPmXu52oAkBVHkCYkoK+5sEwxHpluAAUjjZzCiC1znqNNWfm72G eURm1xmd/Qj6tSid0yzrm/Nkh7yosmKmZyDGI9ZmaIXx8B7Iv9JBdLweZ/F7T118prsPt7 qSA54erw94R1RU5slvREJ7yG/28le1RXiLkz6EE5qXexcydN0O0j//NoFTaQHw== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:40 +0200 Subject: [PATCH v2 7/8] drm/vkms: Create helper macro for YUV formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-7-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5213; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=OgrIZaRglaW9lLIYFQvj2Tj4ljYg7ePzSg0Mkmo6f9o=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGifM8NYxhUiKoSs23U/LpjvqGyqrDYoxHbj3 hJ7zOsBCgmJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxonwAKCRAgrS7GWxAs 4jf2EADIi8Dvo8G79mSzjEY5OGDg9gA4G5cjEl0QCIIoZLsaTjw2XYGIip37qcWZlk0+A2P9hw4 MA2+XAYPU1lKCSBA0iRiP6XXbiyq5tGUxsBsTSB/kc1biK6KwkqBCkBx52m0GuFOjzMxXvUB9kK Urzj1UYGAD3JJISTJo4h4ffS7IQQxnNCQFg0avDlKw37olEvhGAXy03WI1K5tDz+797UEwqsMOb 50oq3sRL7sggppy/lmgvF8Ywzi1jQnyRCgVPqA1rjffJQYKX9eKIxCzj2vijE5+nfLNo7MtemW3 Xceq/rnX/g5pP3Zu/v9AdQhT6xO5N4CHweS8As3CLfaGaQvvyYfqeaVqQtW+gy47RiGXeiKwYUV +afsyYzBId05zdreqlrkxOlHmeFKSGWFBD+i3NA1OnXu+dsdjrfhTqx38aODQVSH2/+FJy/KkFY LpEiWT2tLbUHOdsAaVcG45LpVJdD+IAF2ENylbSU5uN+W/L7Jb0piruF3wtCsx/GjxkaFPdFDdk 1UOhf1OxmelZdYJzNTmggFhfsuJeUIOrjpBn0g3Hb+BttgxWLXZVEqk74VvYNNlmlxhMFnWJQ40 +y53JkJQetkD1vYUnbPVpht1mXO9Rm1UInJuX/J37M13hHlqQc3F7Fzz584p936XT6fbpC/SkWo 3a9rPa9ufHETwDg== 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 71aae2397c5f..129672a555ce 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -484,35 +484,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 @@ -704,7 +725,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 Wed Aug 14 08:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13763052 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 015FFC531DD for ; Wed, 14 Aug 2024 08:19:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D183410E423; Wed, 14 Aug 2024 08:19:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="pRLqf4j+"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D66010E41F for ; Wed, 14 Aug 2024 08:19:56 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id DE332C0008; Wed, 14 Aug 2024 08:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1723623594; 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=/zuFuAELsFfeHuKjmDwBJ7LuklizkVl2A5HyoJYo+hw=; b=pRLqf4j+Dr7oPP8PJPbGgRpdPi9JT732Y4anVTfA+HB27lympxMn5FS5J8BUzI7lORFLAY 9TA1/LWSuzPZdIdWz2QZ8mVYKSlrKEwimIUqG0pkCvUf1flFR7zX9jh/4nwk1GBmNPZKw0 1zUCmNFL6n/aODl2nkUBgikDsLOsZhN7sg7UhKyE2x29yeGwg1qPNX/p3x5Un/RyCO3Wtg 4pOaUA9DwaHh3oAKNzFd/ZxAOgG4ZpwWfgknYncbGQI1IZyLFtkTA+MzB0qrDVvE0c0reK L5jmin5QNWmWzwVvSmeb6F5Rmyy5b3kapbObVpF8izspiLjDT49/0PpnT83E8Q== From: Louis Chauvet Date: Wed, 14 Aug 2024 10:19:41 +0200 Subject: [PATCH v2 8/8] drm/vkms: Add P01* formats MIME-Version: 1.0 Message-Id: <20240814-b4-new-color-formats-v2-8-8b3499cfe90e@bootlin.com> References: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> In-Reply-To: <20240814-b4-new-color-formats-v2-0-8b3499cfe90e@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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 , 20240809-yuv-v10-0-1a7c764166f7@bootlin.com X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1885; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=TMTnR4P98mlZAZ+WK5vWeKSerKkdvqWXG9xVfF8Pg2U=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmvGif7IJe69h1cW5j6EMURpnNlQxaewd5nu+J3 uhS/QjHeuuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZrxonwAKCRAgrS7GWxAs 4kJiD/oDGFmw1++hs7b8As2dRYG7+HSel6E/jMXOEPE6q0uNmun3A0rOrvPDf6S8YrchrSsUtaX pdani5UYLpURqTbm41kZZ5umPMk7FE7VWLdQkzz/pzhhTm8MweupC62ydiRYAuqxtoAlCrIDYHh W0oVvsZNvtMTHqA1iKBd4JMBycYGvV1niicBasB0JQlQzWZTVBY4a5a8R6isnqvjaTDCR94DxDZ 77AnbALvSUHJqoAaLxdDRaL+J3zA5KcDQ3Pi26baiM4RBo1QxLpqSXj05O6Gq54+U4yNxlbd94E geayKBzFRa0ZBkFqjPHpOsX4Dg4uYJJ3TgHLydJJtTwnX/50qWyzIjmgQOFE0p+99N1Evxg+1Ba LDXFfCfiz9iz67fUHJl0/7rU/FMbIc5ERcbwzYhLvn1tH73FwHGsqaeW23xtzKuGQr03zE7hZhE U0meepjVM54uMn2angftJYbQrRx1ycK1Zd5zD7RXRXuRbrSNysV1GIPFl6686OUf4s8FCt3W/Rb z8AVdy8D+bHfHElFCW/SqEcbTU7Yze0m1IXSN4x8mO6Yc6YxhrH7QcnYeIUSixhmuJVst/iS9hp 4lyvp+f7cvk44VbmF889L5R9EfQFP/1hnlH37BsnZeBhGczFwHEue5Fiy5t0HjJgsFgdwaeK6RO uLfoyDE7X3csQ6w== 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 129672a555ce..d1abfb1c3e3c 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -533,7 +533,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 @@ -726,6 +727,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,