Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1193369rbb; Mon, 26 Feb 2024 01:27:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWAmCfKo58tPk3nJXaYZfjX4CC/ALUZsRVtEzQXX27TGmbdFth6IVgrxHeyVBGaDNfAthwmHooKtzwflkhhQImy0XyCXQ8OKAh0wX/Orw== X-Google-Smtp-Source: AGHT+IEDZ9PNuRmpJ+vxQM4zyCUq4wT8s/uYot/oBHKYbnl8Qg78EcDwh9SV9MR9zn6jQS6mwvyz X-Received: by 2002:a05:6402:7c5:b0:564:5604:d0e1 with SMTP id u5-20020a05640207c500b005645604d0e1mr4375977edy.38.1708939671701; Mon, 26 Feb 2024 01:27:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939671; cv=pass; d=google.com; s=arc-20160816; b=DhzGxtJ3a9kDrDcZpG8JJA/14smuHb8mNmDae4jVOCEa4op3fABA8H+41m4ayVzia/ 2P73WjuUzD3QbEZCoCKlG9bP6S8C9tYp2GeSv59Nu0fZCvLZ2RwEi/JgIc+9joOBJVl6 LoswcpsOmzBhJoHHpUmh4VSe3EQ03Sr89+FuOmf78+A0BkD/2dduvTzrvAcH+Pvwbnxv 8ZdXGLLW/+95htb66FpxzsF0ojZBjshYhl5Gu1m4WF62uPtFXYM2/nwpmYRbRTWqMlJG uvCs/35IHoHPpWJX3tjI+Iw3qiuy7KWpcFUav1xk+9MzVXJsHtOV9061A5LEYBpjMsOD 1LoQ== ARC-Message-Signature: i=2; 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=U5UinReH6vUXNxBJ97EG+ZqktERoBQAcu/k8mtlmiaY=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=Rh9UHPC6+kQx9xGBmjZwRK9LVx3Zha7zHe9ICwTjM6BXcbFBT8gLgVv8E+qvHDlr3T 50s4FgQjUwxE29l/VruE3oyWPYiiZoNtosTf6WGnMpBDiRtzuWo/nBAOEdku+ZMoMcll 0SO0Rwo8LpTbsS9Odpjs8hzSO83T02N+EjnKrLfjOA7NRUhssoESk6r8ji3yG5KV7+Y3 +0CiMA2cVnULLE2Hd7YgE3/TaCydhqHI1jdWx3B9MYTJQspaSKEwbrGwROKH2t8pWE5P VUZTCA59P8UUnhcHE/3X96qrL6VvKeqTUIk3lFq9yLqjVfsJFVMtM/IRoskxYMhDrgeb 5eow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XrP9z8jx; 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-80956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80956-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 w16-20020a50fa90000000b005617dbded52si1820073edr.497.2024.02.26.01.27.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:27:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80956-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=XrP9z8jx; 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-80956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80956-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 451071F22748 for ; Mon, 26 Feb 2024 09:27:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 105815DF12; Mon, 26 Feb 2024 08:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XrP9z8jx" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 632A75D464 for ; Mon, 26 Feb 2024 08:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; cv=none; b=YYBOoQtVR7e6n9qoyEqvU4JoOkRwMARnOtB7rlfMlIfxldsJpGqaKUEWIBXXFUyKjwMsnJc6MRwwdKbjvG/qK00cPmcnk+yQpDDmY+44pC5BczmdaM9y4TI05AwEpQtkMsoSe+y//nhmgv95twjKQQxmNgh2Ty8/yst+2SZptNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; c=relaxed/simple; bh=+DsmO8SGjkaXdS5jYLEBNm7wDQTKeBuOh6cIQzNvHU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ay1N+EiVJIE3gM4/NyHuWy875Mo61+6ISEf0W2CqlwefBkFFRL+UYMjXlygD/J6rY1ec9qa7easKqjAz6jsLvPcN92D1qvF80mcESntNJn3b3fpVmtSab6OlDa0klhKwT6MHQve74Lu1YFnkO6Yee2YS23bvev05gSYPIKFZGu0= 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=XrP9z8jx; arc=none smtp.client-ip=217.70.183.196 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 983CEE0005; Mon, 26 Feb 2024 08:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937268; 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=U5UinReH6vUXNxBJ97EG+ZqktERoBQAcu/k8mtlmiaY=; b=XrP9z8jxMI5xCnX8l+KmyX/OJHsT/QmOU1KSAK+/DiaCAEyrVNuShux4U9dRUB54aVXAP7 l+qtq7YRMZgS8LUJE+fwPiKyLRahcb33HpqHFvVFTcjuCtYikwmrYQWThab2/VWNhvBDdf 7oqUxYO03+mnag3bgcCnQDfGbSsRu9hzfvY8AWVbAureTm8PuQRb2bQEeJZJUDgmykTNk3 J1EpKhc9k08onD+9a4CC/aH6zhrtY/EayYnDXwL0MKR9PRAzE+aeJPIQrcet7l119OMd13 DAW8v0ZM0+gsuby5I1kw602HA1YcXpqATY5I/zvR04Wxv3nwtr1RnbJNPP/xCQ== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:33 +0100 Subject: [PATCH v3 3/9] drm/vkms: write/update the documentation for pixel conversion and pixel write functions 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: <20240226-yuv-v3-3-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , arthurgrillo@riseup.net, Jonathan Corbet , pekka.paalanen@haloniitty.fi Cc: 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6432; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+DsmO8SGjkaXdS5jYLEBNm7wDQTKeBuOh6cIQzNvHU8=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAtv6lG5Spu+Fvdk7/o9Z0JtjYZu9Zbw5ykTQz0 4KgnyCmJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLQAKCRAgrS7GWxAs4lHMEA CTqOSIvqzWg5SOoLw9sntXeUH/2RgSp5S7nC3yjRZwTmKFiYwQuFeBqvHeF3s8Ox7W/wA8g2SIdyD8 LsciJq5x4mM2X7R6cbBw2z+C1SUlvBkmlNsNSsGTJiUGtcr1kc67uOa9MUdgUmA5VhaM+ArJpn6rGm cp5NYVDbNwGly5AmjhCdc5Xk/eGWs5SEp5GzA/6e4xcfc+/rRuj2kUZxnjhI+iRJp75UGWOaMBJvr3 Yj1HyvriKQEYXrhVur/OnfTg33SnQa1JsQYzJ0ZFvGLznh0y9tcOm2rZSgm2hrCIiBchWxMLZGlosh fOZLNevfHm/+Mt3BjqYgCE3gR5dyFK+eAwCdt5kAlsXIbez4HYg+FkAFRF6gkBGhwvZBoElT6wTgIO K/KojwFD80ueszTcsrjO6NiqRnXkEYmggk34KiSMnKoJOBy3FBVCPUEgA3fnNIcLb8xCebFSkT+Gaz Lr6p7Hor6TaFf/NnVfNLbU42PZ8qh3u3C98xHjczi3zS8o8irXPPem3MBJ3jAcCxryYVMocWd9KWut IS4ieNPzs8xqCohPwI1DsWfrgMLP+dB8zyUoRltaVNfk6ck/epwBPD6dIwRq+C0kxhPLR/dsrDa/mx uOLb1eK2orxzDdvG9EBOTIEYSD0sg6PLo/KwCo+kIGIclzva83HZtfekC9Gw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com Add some documentation on pixel conversion functions. Update of outdated comments for pixel_write functions. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 4 +++ drivers/gpu/drm/vkms/vkms_drv.h | 13 ++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 58 ++++++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index c6d9b4a65809..5b341222d239 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -189,6 +189,10 @@ static void blend(struct vkms_writeback_job *wb, size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; + /* + * The planes are composed line-by-line. It is a necessary complexity to avoid poor + * blending performance. + */ for (size_t y = 0; y < crtc_y_limit; y++) { fill_background(&background_color, output_buffer); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index b4b357447292..18086423a3a7 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -25,6 +25,17 @@ #define VKMS_LUT_SIZE 256 +/** + * struct vkms_frame_info - structure to store the state of a frame + * + * @fb: backing drm framebuffer + * @src: source rectangle of this frame in the source framebuffer + * @dst: destination rectangle in the crtc buffer + * @map: see drm_shadow_plane_state@data + * @rotation: rotation applied to the source. + * + * @src and @dst should have the same size modulo the rotation. + */ struct vkms_frame_info { struct drm_framebuffer *fb; struct drm_rect src, dst; @@ -52,6 +63,8 @@ struct vkms_writeback_job { * vkms_plane_state - Driver specific plane state * @base: base plane state * @frame_info: data required for composing computation + * @pixel_read: function to read a pixel in this plane. The creator of a vkms_plane_state must + * ensure that this pointer is valid */ struct vkms_plane_state { struct drm_shadow_plane_state base; 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. + */ 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]); } -/* - * packed_pixels_addr - Get the pointer to pixel of a given pair of coordinates +/** + * packed_pixels_addr() - Get the pointer to the block containing the pixel at the given + * coordinates * * @frame_info: Buffer metadata - * @x: The x(width) coordinate of the 2D buffer - * @y: The y(Heigth) coordinate of the 2D buffer + * @x: The x(width) coordinate inside the plane + * @y: The y(height) coordinate inside the plane * * Takes the information stored in the frame_info, a pair of coordinates, and * returns the address of the first color channel. @@ -53,6 +65,13 @@ static int get_x_position(const struct vkms_frame_info *frame_info, int limit, i return x; } +/* + * The following functions take pixel data from the buffer and convert them to the format + * ARGB16161616 in out_pixel. + * + * They are used in the `vkms_compose_row` function to handle multiple formats. + */ + static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { /* @@ -145,12 +164,11 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state } /* - * The following functions take an line of argb_u16 pixels from the - * src_buffer, convert them to a specific format, and store them in the - * destination. + * The following functions take one argb_u16 pixel and convert it to a specific format. The + * result is stored in @dst_pixels. * - * They are used in the `compose_active_planes` to convert and store a line - * from the src_buffer to the writeback buffer. + * They are used in the `vkms_writeback_row` to convert and store a pixel from the src_buffer to + * the writeback buffer. */ static void argb_u16_to_ARGB8888(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { @@ -216,6 +234,14 @@ static void argb_u16_to_RGB565(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) *pixels = cpu_to_le16(r << 11 | g << 5 | b); } +/** + * Generic loop for all supported writeback format. It is executed just after the blending to + * write a line in the writeback buffer. + * + * @wb: Job where to insert the final image + * @src_buffer: Line to write + * @y: Row to write in the writeback buffer + */ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y) { @@ -229,6 +255,13 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, wb->pixel_write(dst_pixels, &in_pixels[x]); } +/** + * 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 + */ void *get_pixel_conversion_function(u32 format) { switch (format) { @@ -247,6 +280,13 @@ void *get_pixel_conversion_function(u32 format) } } +/** + * Retrieve the correct write_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_writeback_job. + * + * @format: 4cc of the format + */ void *get_pixel_write_function(u32 format) { switch (format) { -- 2.43.0