Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp41429lqi; Wed, 6 Mar 2024 09:30:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWI0Zf7hg3QKN0kvuje+SLHg2Zm01wM0VX1a0JBRqnLdW2avh+/xB05fdrHFMDtMOOmY+ZDrhZXepvnHYh0IGo0H1AX8xPKHgnxhHRlYg== X-Google-Smtp-Source: AGHT+IETzfVAsZF3PonneWYQ0STZZ1lJOsSOu+ddBKlWpMY1AaFjAdm5iU05H9We1P5F8viR5Gls X-Received: by 2002:a17:902:e944:b0:1db:b8dc:a016 with SMTP id b4-20020a170902e94400b001dbb8dca016mr989793pll.7.1709746214593; Wed, 06 Mar 2024 09:30:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709746214; cv=pass; d=google.com; s=arc-20160816; b=oj8PoQJyDWb3C9ghAtxYaUcmIZoAiUDlEOxUw4IVEsmhDZPnwXOtr+Ob1YHmWCN81Q NChH6z9Z10epazS7eb5/GqfpG3l85GOB9bPu+TSiLnUWJ7McCmsplvf0Rscw7LBrC83Z Eq0lQx5vWAEaVtrV1xQmYX9uE7hwZaqoLf2xPxpiaqi6DeDfQonZrz5ac91zgFFxSHFE JTDKPI1loPA3APTotUjcJhtRn6yhn4IDUgtKkCDKdbza5wYLNnZYFnsMALIee7DP+BWO qhTXK9YPhXuqvev7o88OPWmvRB1be5vzq3rcloOWDjAn9AApLg639m0Ya4qmSnnfSr2E CbKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=sXLhJ0O6OO6mf1nCrL/ZtBeWa84FHx+qoQdFINeOTeU=; fh=C/kWxPHJgHTzeuEGDmfV930f+FZwSY5KYV25VaH+M5U=; b=V2yMFA2c7AhKBASj1HAbAi8rzJzl5gYEWHb6Crok5m3kGrKULURtwFA5sOD8ZWeKXV MNprnUB9elan0vhMrYedn1RsHEVmZh/fpNzByIUGr9Jc5ntpMnX9ALhqtgHR82yqcdWY Z4JzuIuSrJeBZ91gf0tt4L/BM9PubGODSEzrHoRMQjcLdFc3a15AI11QIVPSagy3OnSi fskLnYrh3wFGoZuCvXr+wQe6+wDR7LyaVSyXoGCyQKt8xotJGcNsZ5l7Qaz5Xk0bhjFE //0B1ETziOvQNE9L9Sia7vLj2uNjxlIrvPOcFTbiaG0yH922Qu8lNP1O74+qWvpLF/a3 XGDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GZH1+1J6; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-94334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94334-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j6-20020a170903024600b001db5b403700si12468648plh.324.2024.03.06.09.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 09:30:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GZH1+1J6; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-94334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94334-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 446C2282922 for ; Wed, 6 Mar 2024 17:30:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E70213BAEC; Wed, 6 Mar 2024 17:30:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GZH1+1J6" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 C2E5E13172D for ; Wed, 6 Mar 2024 17:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709746201; cv=none; b=e1X6DUoYhMZ4f41v+4+WW+yQvKulciQLt0i8Sp0ZNp+cLgtYtHaFquX8mK4ROeE9qC/LgGLUXjxJdU3wcZURlVsCGa4aNvV6tm9L2Kuh18RWZ5w+eXXxhHmHsjibjWeDlRDKYQOjnRQop9dq87pvt1yzAR4X649JR6edfghNFNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709746201; c=relaxed/simple; bh=Zw3ohwfcAaNEE1/o0Q4UrG7MAf91Gs1+OTJphW8DMYs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ne4QL95pnaIkDUd+kYSDE+Yaj3VVpcwn5+cQZKnoEL3bzuv7mp1P6TI0bvLUeKh8fkpIoFdmaxPU5qg4pISVfKHYs++uoMxCh9cZVtqRFWkJBOoypTTAuGCLJ7uRXUFYAiisQqqIwsSvrBBxSN2VP8CVDTiMn7g7sm+3wRuDJvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GZH1+1J6; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id BDD46C0005; Wed, 6 Mar 2024 17:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709746196; 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: in-reply-to:in-reply-to:references:references; bh=sXLhJ0O6OO6mf1nCrL/ZtBeWa84FHx+qoQdFINeOTeU=; b=GZH1+1J6RkqrwG+vvNkjS/qywjS7wLBfuXk31cPPc6Qn8vwL8lZJZw7W6B9aYb1xhaJTjQ IikGU9mtyxPoD4BZFamhiWRd7JrY1F0Bea7GzXahlL07zoFYjYVdpzmRLTzU3IFv02ekZp BXxV0rHDqglXSBJD24WlGE2xYq4a9GGlnSN0D2X+2Nly86bcSa9LnmHE+1IECN94MxHOL2 +SpHQopB5QazFeoGORV/v8Qu121jaaQjKiT0qBzcmBsGcmw7zdTKkj6YCK1CT/45LOY4Fg C87OQ3ftMWS8sLjABXhWBM/49MmwqH8rNx0kNEnCGzBq5NsXKysX+4cKrj/0oA== Date: Wed, 6 Mar 2024 18:29:53 +0100 From: Louis Chauvet To: Pekka Paalanen Cc: Rodrigo Siqueira , Melissa Wen , =?iso-8859-1?Q?Ma=EDra?= 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 Subject: Re: [PATCH v2 3/9] drm/vkms: write/update the documentation for pixel conversion and pixel write functions Message-ID: Mail-Followup-To: Pekka Paalanen , Rodrigo Siqueira , Melissa Wen , =?iso-8859-1?Q?Ma=EDra?= 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 References: <20240223-yuv-v2-0-aa6be2827bb7@bootlin.com> <20240223-yuv-v2-3-aa6be2827bb7@bootlin.com> <20240226133700.3fef91d9.pekka.paalanen@collabora.com> <20240229104833.2a404d6b.pekka.paalanen@collabora.com> <20240305115007.0d0d49ef.pekka.paalanen@collabora.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240305115007.0d0d49ef.pekka.paalanen@collabora.com> X-GND-Sasl: louis.chauvet@bootlin.com [...] > > > > > > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > > > > > > @@ -9,6 +9,17 @@ > > > > > > > > > > > > #include "vkms_formats.h" > > > > > > > > > > > > +/** > > > > > > + * packed_pixels_offset() - Get the offset of the block containing the pixel at coordinates x/y > > > > > > + * in the first plane > > > > > > + * > > > > > > + * @frame_info: Buffer metadata > > > > > > + * @x: The x coordinate of the wanted pixel in the buffer > > > > > > + * @y: The y coordinate of the wanted pixel in the buffer > > > > > > + * > > > > > > + * The caller must be aware that this offset is not always a pointer to a pixel. If individual > > > > > > + * pixel values are needed, they have to be extracted from the resulting block. > > > > > > > > > > Just wondering how the caller will be able to extract the right pixel > > > > > from the block without re-using the knowledge already used in this > > > > > function. I'd also expect the function to round down x,y to be > > > > > divisible by block dimensions, but that's not visible in this email. > > > > > Then the caller needs the remainder from the round-down, too? > > > > > > > > You are right, the current implementation is only working when block_h == > > > > block_w == 1. I think I wrote the documentation for PATCHv2 5/9, but when > > > > backporting this comment for PATCHv2 3/9 I forgot to update it. > > > > The new comment will be: > > > > > > > > * pixels_offset() - Get the offset of a given pixel data at coordinate > > > > * x/y in the first plane > > > > [...] > > > > * The caller must ensure that the framebuffer associated with this > > > > * request uses a pixel format where block_h == block_w == 1. > > > > * If this requirement is not fulfilled, the resulting offset can be > > > > * completly wrong. > > > > > > Hi Louis, > > > > Hi Pekka, > > > > > if there is no plan for how non-1x1 blocks would work yet, then I think > > > the above wording is fine. In my mind, the below wording would > > > encourage callers to seek out and try arbitrary tricks to make things > > > work for non-1x1 without rewriting the function to actually work. > > > > > > I believe something would need to change in the function signature to > > > make it properly usable for non-1x1 blocks, but I too cannot suggest > > > anything off-hand. > > > > I already made the change to support non-1x1 blocks in Patchv2 5/9 > > (I will extract this modification in "drm/vkms: Update pixels accessor to > > support packed and multi-plane formats"), this function is now able > > to extract the pointer to the start of a block. But as stated in the > > comment, the caller must manually extract the correct pixel values (if the > > format is 2x2, the pointer will point to the first byte of this block, the > > caller must do some computation to access the bottom-right value). > > Patchv2 5/9 is not enough. > > "Manually extract the correct pixels" is the thing I have a problem > with here. The caller should not need to re-do any semantic > calculations this function already did. Most likely this function > should return the remainders from the x,y coordinate division, so that > the caller can extract the right pixels from the block, or something > else equivalent. > > That same semantic division should not be done in two different places. > It is too easy for someone later to come and change one site while > missing the other. I did not notice this, and I agree, thanks for this feedback. For the v5 I will change it and update the function signature to: static void packed_pixels_offset(const struct vkms_frame_info *frame_info, int x, int y, size_t plane_index, size_t *offset, size_t *rem_x, size_t *rem_y) where rem_x and rem_y are those reminder. > I have a hard time finding in "[PATCH v2 6/9] drm/vkms: Add YUV > support" how you actually handle blocks bigger than 1x1. I see > get_subsampling() which returns format->{hsub,vsub}, and I see > get_subsampling_offset() which combined with remainder-division gates U > and V plane pixel pointer increments. > > However, I do not see you ever using > drm_format_info_block_{width,height}() anywhere else. That makes me > think you have no code to actually handle non-1x1 block formats, which > means that you cannot get the function signature of > packed_pixels_offset() right in this series either. It would be better > to not even pretend the function works for non-1x1 blocks until you > have code handling at least one such format. > > All of the YUV formats that patch 6 adds support for use 1x1 blocks all > all their planes. Yes, none of the supported format have block_h != block_w != 1, so there is no need to drm_format_info_block*() helpers. I wrote the code for DRM_FORMAT_R*. They are packed, with block_w != 1. I will add this patch in the next revision. I also wrote the IGT test for DRM_FORMAT_R1 [1]. Everything will be in the v5 (I will send it when you have the time to review the v4). For information, I also have a series ready for adding more RGB variants (I introduced a macro to make it easier and avoid copy/pasting the same loop). I don't send them yet, because I realy want this series merged first. I also have the work for the writeback "line-by-line" algorithm ready (I just need to rebase it, but it will be fast). [1]: https://lore.kernel.org/igt-dev/20240306-b4-kms_tests-v1-0-8fe451efd2ac@bootlin.com Kind regards, Louis Chauvet [...] -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com