Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp451200lqh; Thu, 28 Mar 2024 07:01:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNmhCODn8q9EcGt4svKXRAOLKGhNgXup06v+dsQJVBBfounU+WhGw18uWDGrqZC+F9EPWS11HCM3+P3nzb1eKFUqEXUArVk26Er9rHIw== X-Google-Smtp-Source: AGHT+IFBY86PelQjOIsfV4EDS5+J6jCWBi/2PewUSF1QFoeaAnBNzeqo7X03c2EaApFUXr5L5SE+ X-Received: by 2002:a19:6405:0:b0:515:b8d5:c5b7 with SMTP id y5-20020a196405000000b00515b8d5c5b7mr2009441lfb.56.1711634473414; Thu, 28 Mar 2024 07:01:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711634473; cv=pass; d=google.com; s=arc-20160816; b=WHlu/jQ4JuAFpr+wI0WlycryA/HymqypVZFRiCIcq+MKbuv5SEFVCjptztZC7qdjL8 XeoXTH0oWw07xd1CJGfDERQOaLjm9Wtn4DS6V6IZ9l9GdRfnxL2Ml1QUep4jOiiqSpee G1uL7eFvyv6jOQc1pYHdkYkBIvGkcOrdwOe8gV9QdHp6sasHQqpaO6Nqiec6FoVmmXQf PWyLBAWePUAv5ZUMKJNLTe+dgEi1hefmBanSqdwfxJwAFvqxZZDalaOsEpnP9eOx6wDM uLHM0G8nUlq2PgNXfYMbHvoOmcWhaSVZnOTE/q3//0zJHlD0rCHOsV7ov9uRvKL4MJvP sfwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Rz5QvpI2lpXssGj6sRuibNRq6OgYlLpNJiY6mkPruYQ=; fh=URr6yXP2w9vp68pwO+yb8jq0tB2Cey7jSL5blboKTPg=; b=kM9YsBe1Hx48b+IhH35q/W/Ux/D/IRpNcPO7jNxxrZbV+fyBN1lKj+mxm8Gcp1R/ml zUn+ZI9g0qqK9dTYsjfWNSVtyXoPbfVegaS6anEnGkHq38RQjnskA+24VpDl700NE31h WzlMEdosvMz/TUomsGp6CQkDHgnRHnkdDEaK8BVTuCAhaIZ3F0qFkjMbJ3VSJlFyhoin YpAPwvVG/5x8G0a3NPY7xRvW3763ZE4hMAMCrptePGhjTKAF5x96PSY4vF8+34KAs49L ovI+//6BWmtuubW5X6GXnsprEXm1G65UvFEOx2IMiKDl7PVc9Kq6Va5nMmkNln1bgLj4 8PPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=rjNbN4Uv; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-123010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id es15-20020a056402380f00b0056b9ba80cbesi838150edb.582.2024.03.28.07.01.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=rjNbN4Uv; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-123010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EEDAD1F240B5 for ; Thu, 28 Mar 2024 14:01:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ED068060B; Thu, 28 Mar 2024 14:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="rjNbN4Uv" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1527F847C for ; Thu, 28 Mar 2024 14:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634465; cv=none; b=llHhji/uLs3LKgTMvJx6/SXGGXw+9Itr4Wtwasx+5dHx8p5Z41ejW+uLUP65CxncdIpYjYD6DFihZPc3PFJnG8UBSU7W7iLXSG9se/Uy0xC4TcaozlU7EejL5MFdBwI8dOlsDYsgBf/lp3eGY2Hz9s0oTIHlnev79WZ0SiJACZo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634465; c=relaxed/simple; bh=4eyuktlj3zT+S0v4lDjOGGPXuz5uyxEP9zOsIuqV3IU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UJ4l9YXLHvfBr6NiIdIkvmx5eFgAUkLsTM4l01xapxg+3AnAOce8duiWtejgWCdmjrqfIMp5Q+vO2OTQ7a1O22X20AtTBFz3Cj8B6NRHm60Hi89BCGI7GJ05q9IUEKVr1PG3UDoLcUMDCG0JCfpuZItYL+QdArCg8wLHNZX5aU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=rjNbN4Uv; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1711634460; bh=4eyuktlj3zT+S0v4lDjOGGPXuz5uyxEP9zOsIuqV3IU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rjNbN4UvU30FBUsy6OLV1q02Y4AR8Sd4StjrsgDfdkbqqEeuT/4bchJz0gddXxLao qKtA/XmCUKifgYKiVHgGLHKCqlaIiX81cnL9d1hCslPv62yrh5KswPVYe94B3qxeZN ptrzmGrPZUF/W4c3IKTwgObjRVhD+bKmngET2b0gu6S92jOwx9hQ4KBVYfYC9P1nl5 MW/CxvJHniM/6ia9vRcE7LKvVV4VHJQ7TPVkxmp8A2kgUIa0ehfPPfEtlrZ7uu+L0e b4CAXXEGnvZ8RNug8Wq5VxToeyMOBlFxyV3tPA0ekP1c3+Wq1NgIFWkK2fseN3Kus0 WldEfaMgvh19A== Received: from eldfell (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pq) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 1D3A73780629; Thu, 28 Mar 2024 14:00:59 +0000 (UTC) Date: Thu, 28 Mar 2024 16:00:57 +0200 From: Pekka Paalanen To: Louis Chauvet Cc: Rodrigo Siqueira , Melissa Wen , =?UTF-8?B?TWHDrXJh?= Canal , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , arthurgrillo@riseup.net, Jonathan Corbet , dri-devel@lists.freedesktop.org, 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 Subject: Re: [PATCH v5 16/16] drm/vkms: Add support for DRM_FORMAT_R* Message-ID: <20240328160057.124b32c4.pekka.paalanen@collabora.com> In-Reply-To: <20240313-yuv-v5-16-e610cbd03f52@bootlin.com> References: <20240313-yuv-v5-0-e610cbd03f52@bootlin.com> <20240313-yuv-v5-16-e610cbd03f52@bootlin.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/P3OiAf8YwdepAoHMsEV.zAB"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Sig_/P3OiAf8YwdepAoHMsEV.zAB Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 13 Mar 2024 18:45:10 +0100 Louis Chauvet wrote: > This add the support for: > - R1/R2/R4/R8 >=20 > R1 format was tested with [1] and [2]. >=20 > [1]: https://lore.kernel.org/r/20240313-new_rotation-v2-0-6230fd5cae59@bo= otlin.com > [2]: https://lore.kernel.org/igt-dev/20240306-b4-kms_tests-v1-0-8fe451efd= 2ac@bootlin.com/ >=20 > Signed-off-by: Louis Chauvet > --- > drivers/gpu/drm/vkms/vkms_formats.c | 100 ++++++++++++++++++++++++++++++= ++++++ > drivers/gpu/drm/vkms/vkms_plane.c | 6 ++- > 2 files changed, 105 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/v= kms_formats.c > index 863fc91d6d48..cbb2ec09564a 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -201,6 +201,11 @@ static struct pixel_argb_u16 argb_u16_from_RGB565(co= nst u16 *pixel) > return out_pixel; > } > =20 > +static struct pixel_argb_u16 argb_u16_from_gray8(u8 gray) > +{ > + return argb_u16_from_u8888(255, gray, gray, gray); > +} > + > VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb,= u8 cr, > struct conversion_matrix *matrix) > { > @@ -269,6 +274,89 @@ static void black_to_argb_u16(const struct vkms_plan= e_state *plane, int x_start, > } > } > =20 > +static void Rx_read_line(const struct vkms_plane_state *plane, int x_sta= rt, > + int y_start, enum pixel_read_direction direction, int count, > + struct pixel_argb_u16 out_pixel[], u8 bit_per_pixel, u8 lum_per_leve= l) > +{ > + struct pixel_argb_u16 *end =3D out_pixel + count; > + u8 *src_pixels; > + int rem_x, rem_y; > + > + packed_pixels_addr(plane->frame_info, x_start, y_start, 0, &src_pixels,= &rem_x, &rem_y); Maybe assert that rem_y =3D 0? Or block_h =3D 1. > + int bit_offset =3D (int)rem_x * bit_per_pixel; Why cast rem_x to int when it was defined to be int? > + int step =3D get_step_next_block(plane->frame_info->fb, direction, 0); > + int mask =3D (0x1 << bit_per_pixel) - 1; Since mask will interact with u8, it should be unsigned too. > + > + if (direction =3D=3D READ_LEFT_TO_RIGHT || direction =3D=3D READ_RIGHT_= TO_LEFT) { > + int restart_bit_offset =3D 0; > + int step_bit_offset =3D bit_per_pixel; > + > + if (direction =3D=3D READ_RIGHT_TO_LEFT) { > + restart_bit_offset =3D 8 - bit_per_pixel; > + step_bit_offset =3D -bit_per_pixel; > + } > + > + while (out_pixel < end) { > + u8 val =3D (*src_pixels & (mask << bit_offset)) >> bit_offset; or shorter: (*src_pixels >> bit_offset) & mask However, shouldn't the first pixel be on the high bits? That how I would understand the comments in drm_fourcc.h. Again a reason to avoid a solid color fill in IGT. > + > + *out_pixel =3D argb_u16_from_gray8(val * lum_per_level); > + > + bit_offset +=3D step_bit_offset; > + if (bit_offset < 0 || 8 <=3D bit_offset) { > + bit_offset =3D restart_bit_offset; > + src_pixels +=3D step; > + } > + out_pixel +=3D 1; > + } > + } else if (direction =3D=3D READ_TOP_TO_BOTTOM || direction =3D=3D READ= _BOTTOM_TO_TOP) { > + while (out_pixel < end) { > + u8 val =3D (*src_pixels & (mask << bit_offset)) >> bit_offset; > + *out_pixel =3D argb_u16_from_gray8(val * lum_per_level); > + src_pixels +=3D step; > + out_pixel +=3D 1; > + } > + } > +} > + > +static void R1_read_line(const struct vkms_plane_state *plane, int x_sta= rt, > + int y_start, enum pixel_read_direction direction, int count, > + struct pixel_argb_u16 out_pixel[]) > +{ > + Rx_read_line(plane, x_start, y_start, direction, count, out_pixel, 1, 0= xFF); > +} > + > +static void R2_read_line(const struct vkms_plane_state *plane, int x_sta= rt, > + int y_start, enum pixel_read_direction direction, int count, > + struct pixel_argb_u16 out_pixel[]) > +{ > + Rx_read_line(plane, x_start, y_start, direction, count, out_pixel, 2, 0= x55); > +} > + > +static void R4_read_line(const struct vkms_plane_state *plane, int x_sta= rt, > + int y_start, enum pixel_read_direction direction, int count, > + struct pixel_argb_u16 out_pixel[]) > +{ > + Rx_read_line(plane, x_start, y_start, direction, count, out_pixel, 4, 0= x11); > +} > + > +static void R8_read_line(const struct vkms_plane_state *plane, int x_sta= rt, > + int y_start, enum pixel_read_direction direction, int count, > + struct pixel_argb_u16 out_pixel[]) > +{ > + struct pixel_argb_u16 *end =3D out_pixel + count; > + u8 *src_pixels; > + int rem_x, rem_y; > + int step =3D get_step_next_block(plane->frame_info->fb, direction, 0); > + > + packed_pixels_addr(plane->frame_info, x_start, y_start, 0, &src_pixels,= &rem_x, &rem_y); Assert on block size? > + > + while (out_pixel < end) { > + *out_pixel =3D argb_u16_from_gray8(*src_pixels); > + src_pixels +=3D step; > + out_pixel +=3D 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[]) > @@ -582,6 +670,14 @@ pixel_read_line_t get_pixel_read_line_function(u32 f= ormat) > case DRM_FORMAT_YVU422: > case DRM_FORMAT_YVU444: > return &planar_yuv_read_line; > + case DRM_FORMAT_R1: > + return &R1_read_line; > + case DRM_FORMAT_R2: > + return &R2_read_line; > + case DRM_FORMAT_R4: > + return &R4_read_line; > + case DRM_FORMAT_R8: > + return &R8_read_line; > default: > /* > * This is a bug in vkms_plane_atomic_check. All the supported > @@ -855,6 +951,10 @@ get_conversion_matrix_to_argb_u16(u32 format, enum d= rm_color_encoding encoding, > case DRM_FORMAT_ARGB16161616: > case DRM_FORMAT_XRGB16161616: > case DRM_FORMAT_RGB565: > + case DRM_FORMAT_R1: > + case DRM_FORMAT_R2: > + case DRM_FORMAT_R4: > + case DRM_FORMAT_R8: > /* > * Those formats are supported, but they don't need a conversion matri= x. Return It is strange that you need to list irrelevant formats here. > * a valid pointer to avoid kernel panic in case this matrix is used/c= hecked > diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkm= s_plane.c > index e21cc92cf497..dc9d62acf350 100644 > --- a/drivers/gpu/drm/vkms/vkms_plane.c > +++ b/drivers/gpu/drm/vkms/vkms_plane.c > @@ -29,7 +29,11 @@ static const u32 vkms_formats[] =3D { > DRM_FORMAT_YUV444, > DRM_FORMAT_YVU420, > DRM_FORMAT_YVU422, > - DRM_FORMAT_YVU444 > + DRM_FORMAT_YVU444, > + DRM_FORMAT_R1, > + DRM_FORMAT_R2, > + DRM_FORMAT_R4, > + DRM_FORMAT_R8 > }; > =20 > static struct drm_plane_state * >=20 Thanks, pq --Sig_/P3OiAf8YwdepAoHMsEV.zAB Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAmYFeBkACgkQI1/ltBGq qqeHVhAAoWHtPFfcwQBZAL8Q2nrXxgfDguVWiSRZBMVFBhBnGc2t1v3U+BSBNy6u lENqEU1LrzRR3aN9LCJVKvz6/7Iq/qvSZXjsqwbs9WRNSytcOxWAXlss+7yn1TS0 k0DxI1JhJWGCX2D9LyGVc0EzaWKx/GiPqZfAu2F0Tft16IOSUVZ1CT3//XakQGPS 6mNuyC42XPEWkJVyfXz6tNkLrOS8HIYvLPtsNFzJIv/Z5oDGE72N5ZwWma9UfrEa /3c/szbVru6gYzHn7Yhvm0W/H1zOTMqQFRNuRap4EbjKv4XYd9ZwRexn5r23mGpA TPZegTlUotCoPUD95ZqQ5oCobP0+K+5CyFy6atBjX0tXkEIdYU1cht4XPeZ2GfsX 4Pwcpzv3ptCgOZXdjZrz9OkwSzpNsMzdUEVsnGTSqpoxGemJpqNUslQ951HvQvri SIC4ZBQ3WQI7BpjekupY9z/BXnR8VOkGQXdaX8+bkEBVW3zD60A3WQXrUAl71RRP f1moRzIrRJZYjndttF++GLsBMsTVuUcO6Kce7+n93w8Gzo9tXQzCIRS20uAFJJ0b C8H/+mBgboXBfq3oZINHsv/F3T2ttxdh7E8cVNsiLChAJzuskdO2kSddPI+vZVqG GWTBF6l0KNI6qKzoS0r/RqbEQQapSFMm/tPnSk7JV4EAkScMxG4= =jP0O -----END PGP SIGNATURE----- --Sig_/P3OiAf8YwdepAoHMsEV.zAB--