Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1140878rdd; Wed, 10 Jan 2024 09:46:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIR1cjufRe8GpqJlae7tGw3fyybyMsWbvje/ys7i33Ev848l3kaTkYRYrhufwJ120AyWDa X-Received: by 2002:a17:90a:b383:b0:28c:a56d:d161 with SMTP id e3-20020a17090ab38300b0028ca56dd161mr640633pjr.1.1704908776740; Wed, 10 Jan 2024 09:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704908776; cv=none; d=google.com; s=arc-20160816; b=nnI2YE+Fq5nUAu2zbwWmipQIkeXkvmRM3925mU/EneqHY10k/shCI3BsW6pjRbI5ea yFqJSHO0McqWq+m4unt+ObYFRbD/FEGaLCL5poEhtUkC6+7wxYeoILF7+ODjTn+AzWb1 oyDSe5AEBX1YgkCXqbO2es7SyyDNTtYBjxU5c9ZcczGn+mXT4rZaUEsK3KquLyECZLyO qZTHlPCgWUyad7t6xDqRLLC86imyqQGCf86eLpXqeJ7inBxHTppXMT3tQdKZVAFwewgk qDH5GO0EFiQXknXh2NBeu5ijhVvSc2rj2iCUujn7rc1kVxWdpP06DDcYuy7lF/xcH6gE 6ISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=D2GxrWxYK+vHWWb/Hul87p478FUboHJGpz683/EezV0=; fh=e2pLjgUlBXjelzqkDvkFjOkj11JaHJ4/Nmp/XhAV6n0=; b=pAPdoT7wonYRV4jNRbTh3p2pBHtSVHRuIGegj8BDx5LikZ+pwG5kdg4skr2C6HUwQY rZP0Y4HL40Fm7gOSyZT7kqAPh4xtXR5s0coIKqI7ACqgdROmbN1yvFhow7yXI+Fl6PhZ vwMaSXQbd1eRjzRJtrzHFzyHKJFQ67fUD7n2GkeVkoDhK1CS9oSUO8fXrrv2k93G/ulO l5U7hgbG8OYKr9rESte//CyCF9EqnYBtZ8HlmszX69QJ3Fc+J+ZIk+5M21qR+s9qaUD9 Pzl43hUnsKIAjeVfNHPIcXmPkPdpex5nCYMupDiS9lr1s7ObR2iSb4b84tn+ZxXDCEjR Mdtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=KYezJL8p; spf=pass (google.com: domain of linux-kernel+bounces-22551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22551-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q2-20020a17090a68c200b0028d50f84500si1856455pjj.74.2024.01.10.09.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 09:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=KYezJL8p; spf=pass (google.com: domain of linux-kernel+bounces-22551-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22551-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4B5C4B21856 for ; Wed, 10 Jan 2024 17:45:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B09144E1A2; Wed, 10 Jan 2024 17:44:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b="KYezJL8p" 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 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: 7bit 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/vkms_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 = pixel_offset(frame_info, x, y, index); + int vsub = index == 0 ? 1 : frame_info->fb->format->vsub; + int hsub = index == 0 ? 1 : frame_info->fb->format->hsub; + size_t offset = pixel_offset(frame_info, x / hsub, y / vsub, index); return (u8 *)frame_info->map[0].vaddr + offset; } @@ -146,18 +149,23 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state for (size_t x = 0; x < limit; x++) { int x_pos = get_x_position(frame_info, limit, x); + bool shoud_inc = !((x + 1) % frame_format->num_planes); + if (drm_rotation_90_or_270(frame_info->rotation)) { for (size_t i = 0; i < frame_format->num_planes; i++) { src_pixels[i] = get_packed_src_addr(frame_info, x + frame_info->rotated.y1, i); - src_pixels[i] += frame_format->cpp[i] * y; + if (!i || shoud_inc) + src_pixels[i] += frame_format->cpp[i] * y; } } plane->pixel_read(src_pixels, &out_pixels[x_pos], encoding, range); - for (size_t i = 0; i < frame_format->num_planes; i++) - src_pixels[i] += frame_format->cpp[i]; + for (size_t i = 0; i < frame_format->num_planes; i++) { + if (!i || shoud_inc) + src_pixels[i] += frame_format->cpp[i]; + } } } -- 2.43.0