From nobody Fri Dec 26 03:24:41 2025 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) (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 A8AE24D59D; Wed, 10 Jan 2024 17:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riseup.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riseup.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b="KYezJL8p" Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx1.riseup.net (Postfix) with ESMTPS id 4T9FYC5GngzDqwQ; Wed, 10 Jan 2024 17:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1704908672; bh=WibHmCZfubrdUIl1IxqVcLZcKWoO43ZgT2tYTKfxTxU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KYezJL8pD+myZse/2G2+P20ErYIm5GjxxS3o67ww77z0snqcT1rgrRHGHmz0qvJGJ 9G0JlTcNCfQmb4UH6Dd5vY4EKBeX1UjJCImTYRXXw1pOYp3v2XyZp0HB87fZDkwULE RLfNcAY6Eoppo1sLhfjaQ7drUU6Qo31Tysm+YFLk= X-Riseup-User-ID: 9FA7D4907E67B96F8A70C063943DBC32D31F05A2CDF76D5EE0C16085438934EC Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4T9FY71yY4zJp2K; Wed, 10 Jan 2024 17:44:26 +0000 (UTC) From: Arthur Grillo Date: Wed, 10 Jan 2024 14:44:04 -0300 Subject: [PATCH v2 4/7] drm/vkms: Add chroma subsampling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240110-vkms-yuv-v2-4-952fcaa5a193@riseup.net> References: <20240110-vkms-yuv-v2-0-952fcaa5a193@riseup.net> In-Reply-To: <20240110-vkms-yuv-v2-0-952fcaa5a193@riseup.net> To: Daniel Vetter , David Airlie , Haneen Mohammed , Harry Wentland , Jonathan Corbet , Maarten Lankhorst , Maxime Ripard , =?utf-8?q?Ma=C3=ADra_Canal?= , Melissa Wen , Rodrigo Siqueira , Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arthur Grillo Add support to chroma subsampling. This should be noop, as all supported formats do not have chroma subsampling. Signed-off-by: Arthur Grillo --- drivers/gpu/drm/vkms/vkms_formats.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkm= s_formats.c index 0156372aa1ef..098ed16f2104 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -26,12 +26,15 @@ static size_t pixel_offset(const struct vkms_frame_info= *frame_info, int x, int * @index: The index of the plane on the 2D buffer * * Takes the information stored in the frame_info, a pair of coordinates, = and - * returns the address of the first color channel on the desired index. + * returns the address of the first color channel on the desired index. The + * format's specific subsample is applied. */ static void *packed_pixels_addr(const struct vkms_frame_info *frame_info, int x, int y, size_t index) { - size_t offset =3D pixel_offset(frame_info, x, y, index); + int vsub =3D index =3D=3D 0 ? 1 : frame_info->fb->format->vsub; + int hsub =3D index =3D=3D 0 ? 1 : frame_info->fb->format->hsub; + size_t offset =3D pixel_offset(frame_info, x / hsub, y / vsub, index); =20 return (u8 *)frame_info->map[0].vaddr + offset; } @@ -146,18 +149,23 @@ void vkms_compose_row(struct line_buffer *stage_buffe= r, struct vkms_plane_state for (size_t x =3D 0; x < limit; x++) { int x_pos =3D get_x_position(frame_info, limit, x); =20 + bool shoud_inc =3D !((x + 1) % frame_format->num_planes); + if (drm_rotation_90_or_270(frame_info->rotation)) { for (size_t i =3D 0; i < frame_format->num_planes; i++) { src_pixels[i] =3D get_packed_src_addr(frame_info, x + frame_info->rotated.y1, i); - src_pixels[i] +=3D frame_format->cpp[i] * y; + if (!i || shoud_inc) + src_pixels[i] +=3D frame_format->cpp[i] * y; } } =20 plane->pixel_read(src_pixels, &out_pixels[x_pos], encoding, range); =20 - for (size_t i =3D 0; i < frame_format->num_planes; i++) - src_pixels[i] +=3D frame_format->cpp[i]; + for (size_t i =3D 0; i < frame_format->num_planes; i++) { + if (!i || shoud_inc) + src_pixels[i] +=3D frame_format->cpp[i]; + } } } =20 --=20 2.43.0