Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1912147lqg; Mon, 4 Mar 2024 07:28:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgAu1U8K8DcrPEUsRBUoW8ITXDnD8omx35alYx0+jUt61HHGOG5P/ZeCvIDvK3Irj0K4QY1R1g3m+zf0uRxbq317yhAUGl9KtRfYiEAw== X-Google-Smtp-Source: AGHT+IGkPmgUkpA8y6cQaxtd337ifUot54LvyHW7kxLa0vqpbk88oYWyGEmKVhrZ/yEfLdKIFY67 X-Received: by 2002:a05:6402:5c3:b0:564:3b2e:2a2e with SMTP id n3-20020a05640205c300b005643b2e2a2emr6029286edx.9.1709566126489; Mon, 04 Mar 2024 07:28:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566126; cv=pass; d=google.com; s=arc-20160816; b=pnowy2uvOOW9FRnBsBA/EDLUzcIjHLQuRLofLHpAqHj1ILbzphCvFG+AmJuxssmZ1t nRZXRMRmJ1wWcdM1mJ5eIirk78DW2hDQENJN3gJSuaJJMWbNyP7dMewqNI0Ozvc974Ul L+yLUOf6utSy5EQsnJmpr+WHsrw80260+d3CFkn6uM9TfNTAy3uDnVfnS5frSACaBefR HKdHMUDasLEF0ald3FX6nMmq4q2L29F2NCmhDZdQeb0SJrSnPDjj5UxQR6HNwhSJmHR8 zYIdZ+hTN//QZTC55hczdGmWoZ4gwHH/GH8F+Jil29yT4F/3P0CP5ajnLVWvUDtkZ/VP Pj+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding: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=T4Zv8m/UXPDGpZewLmyg0pl/W4ahyJ8xUUUXXUY66xc=; fh=C/kWxPHJgHTzeuEGDmfV930f+FZwSY5KYV25VaH+M5U=; b=la9vm2l6UqlX4gmvscTdwyIhFX7wGocU21gKteEn6SgAAP/d4LKCqG0Z7YFZrCPcQb XyEK4cYJbKyEC8gbXv0i03ZAi8CYLCuVpdpBjhEOlcJrSNeFLL1FJIjLCe0klVEQuL9U G+gFYK/aJQRUhqWvsDSLP7DKchMqT1krzV7cKnDlWSdMQhceUr/q9rCbALiD7rLDUXU1 /5Pl9wFb9Vm13qaXRQozFMTHyhjHyrAklXkjB6Oeylj55yALhMX55hja1VxNBYir0va+ BG6Z/6hZOb5i4sXWrKGVgKfdXntescRGzlR5yc32yV6ZM8XYg7MFfCUYbBExipAHKtZR avXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="E/lDvTTl"; 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-90815-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y18-20020a056402441200b00563fcbed2a2si4174115eda.180.2024.03.04.07.28.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:28:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90815-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="E/lDvTTl"; 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-90815-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90815-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 12FFE1F258B0 for ; Mon, 4 Mar 2024 15:28:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF7ED47A6A; Mon, 4 Mar 2024 15:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="E/lDvTTl" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 788A814ABC for ; Mon, 4 Mar 2024 15:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566117; cv=none; b=uGx7rchsiqgc4apLku870WuyoKsHs8zjJ2EYOlDGHx01h3ochNZfVg+qOKaNP+BXiXh+0xSmBFVi3a+PJLzMl7uUKfMcyUIddwfVpBV5tcA/e8yomuyrWjDDL8foGuABk9Whr6Jw+ypSjnkKGvBxUqJhJ358h4fC6vEKHz560VY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566117; c=relaxed/simple; bh=JqPLe8KPWvpiqlSrIgQN5CjA/uLkeh0Hokz47hMRiiU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TtSoewfPdErkm6VOrwLzI+fMT7qVikdUB6Oxd9CfHgeKLJmpknCU3tsyErLaOxRgeK4ZBj0xjVhjSNBRNhTMzd7p39Xn2R3SL5k5B+p6f7so9aYvfVXfbHP4LYqkkZ/16kzOisvnubyp93kzYZr1YZxU1o/IoVTU2oyABbmU6us= 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=E/lDvTTl; arc=none smtp.client-ip=217.70.183.201 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 2EC981BF204; Mon, 4 Mar 2024 15:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566113; 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=T4Zv8m/UXPDGpZewLmyg0pl/W4ahyJ8xUUUXXUY66xc=; b=E/lDvTTl8F84vRyAi+hKvmn0JWisQyYP1UEdCQd8fmO5ZjfWdtsuTORqExmXL6CuAOdsMp c56yDlg9yPH2s9fjLX0tz+vskbRBb0YDxKZszPXSuQCaAahyj7F6HC8laaThNCxF7iISjZ f2zqQba8qhfnTAkTwIzCM2X+PN0kf585lLXnoifMQQprJI2xPQgAzG2J3kStq7bVMMB2tk Wd7+fpOxIXImnLYR5tNlniuE+On92t538kBDTwrmgZ86QgYLx5mab3C0nlNnCTEilpDPgH VytIyaCLrwV7hZ/hrqG5vFNUV3edyPiUvuaTHDyJNpPjdZj3bZlH6ffFdn0rag== Date: Mon, 4 Mar 2024 16:28:30 +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> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240229104833.2a404d6b.pekka.paalanen@collabora.com> X-GND-Sasl: louis.chauvet@bootlin.com Le 29/02/24 - 10:48, Pekka Paalanen a ?crit : > On Tue, 27 Feb 2024 16:02:10 +0100 > Louis Chauvet wrote: > > > [...] > > > > > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > > > > index 172830a3936a..cb7a49b7c8e7 100644 > > > > --- a/drivers/gpu/drm/vkms/vkms_formats.c > > > > +++ 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). > > > > And yes, even after PATCHv2 5/9 it is not clear what is the offset. Is > > this better to replace the last sentence? (I will do the same update for > > the last sentence of packed_pixels_addr) > > > > [...] > > * The returned offset correspond to the offset of the block containing the pixel at coordinates > > * x/y. > > * The caller must use this offset with care, as for formats with block_h != 1 or block_w != 1 > > * the requested pixel value may have to be extracted from the block, even if they are > > * individually adressable. > > > > > > + */ > > > > static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int y) > > > > { > > > > struct drm_framebuffer *fb = frame_info->fb; > > > > @@ -17,12 +28,13 @@ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int > > > > + (x * fb->format->cpp[0]); > > > > } > > > > > > > > [...] > > > > > > +/** > > > > + * Retrieve the correct read_pixel function for a specific format. > > > > + * The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the > > > > + * pointer is valid before using it in a vkms_plane_state. > > > > + * > > > > + * @format: 4cc of the format > > > > > > Since there are many different 4cc style pixel format definition tables > > > in existence with conflicting definitions, it would not hurt to be more > > > specific that this is about DRM_FORMAT_* or drm_fourcc.h. > > > > Is this better? > > > > @format: DRM_FORMAT_* value for which to obtain a conversion function (see [drm_fourcc.h]) > > Much better! > > > Thanks, > pq [...] Kind regards, Louis Chauvet -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com