Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp329686rdb; Thu, 1 Feb 2024 09:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLzGok38UNX7Xvo/vLGnH5rg5Wl9/+WE91uv2la+1TqsEIARC6Fp1QvCt/A1TKpu6ML16V X-Received: by 2002:a05:6a21:3812:b0:19c:8698:88a9 with SMTP id yi18-20020a056a21381200b0019c869888a9mr5190164pzb.14.1706808967214; Thu, 01 Feb 2024 09:36:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706808967; cv=pass; d=google.com; s=arc-20160816; b=fH2Wra8kxVsso90dJaXv8LFJMSaKn8lb9lkWGZNf7SwWVTV3VzpOxokc5ZxqDWsoKV 2RSz7c2+WK7UIOwT0J3tUE4o6AAuV0H1ygKusvaYM+ueLJbSpJhwFuoTaTyB/C3jJBSG iAf5V+x3dz+8Pnfvb/ZnxvSK/hTmgLwHcimxy7IA+T2vEq6+ieuNXNmICQlmhC/FVp7N 6OCpRSmq69DBYMN2M2mCKJfiiDNCO3mY8BfG2PaZfY9VIZpWNmSmkUl4v8E8DYr/WwjG HvJ25HAMG3wDdDtiA35yS39Ixd8BrvYm6oz7Wlf1nLB3ggwzZp9REa1E0dO2onSPnihE 5yzA== 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=y+aqzxTPAUjOzIodHPzxeC6qMPaNLGnJXnuBentQENE=; fh=68B0QWGnIt96K5wsFX8sXyUruTCZLv+lAiefgzH5pOw=; b=Lx6mqBTDz7Tx5uJAMaszH109hCorEeTEioHPLLiXj4LiVzsV2ozllP2WFNnGw4d25m J5hJ444GRaYiojhMho669PzkiSzmr+9//D2+KD4CXJlkSI7CTKVcbzV+TmZj16dYQWGd 0QnK4m4VZ9eD8De3zOalpLpo5DZMdiFiSzRH99Yiz/6dExv1COJJbnmoGhTv+30Ng8rT LraC0hyw45kY4CvxV11DM8L5SlXF8+nsewsPHatLGgJix7jToQJK7h9epBrZ4A+KopKe O3T/Bp2XbLxQTpRzI5opRkdyqdS3vrq/OEWW7zdltGoWlOkh8yixLMBcGuQ1lVU9gd46 S6+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o4NwI2W7; 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-48595-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=1; AJvYcCU0Iwuyw33HP0KmwumdHTZ5BgqKkWmgKP8nUN89CMMBbbdYjr9/C38ybEKkMQjs5Up07BvpRRYLAUvgnUmtP1XbLvLOcKQdtcO6rbjOag== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q24-20020a635058000000b005cf64c8f74asi70702pgl.30.2024.02.01.09.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 09:36:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48595-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o4NwI2W7; 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-48595-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48595-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 36B1928EC6A for ; Thu, 1 Feb 2024 17:32:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 121E95C033; Thu, 1 Feb 2024 17:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="o4NwI2W7" Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 9C11484025 for ; Thu, 1 Feb 2024 17:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706808742; cv=none; b=bq83zL5b5rSToNpLsOHmjOyNnfcURpuHd07jQR4HralU9Ig0q4pdHR7mNgk/ER7QhK59K1uRsAsT4PaAkkjgfmc78nT8i80NBoe3Z5+GZQAsWnrGqcl1sytrBTau+/xK2KW6I+dQGUn2GDQW7TednlGTg+O/g4xBfHHBEvYDf2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706808742; c=relaxed/simple; bh=sy6XOjKiwgGLJghXuUCDDipZtMBjZVoiNnbEzSMpZZE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sf3l+3Pb0XUUexuBui55KHhVzxqh3AW/KuzyU4OK+2zAd6YHfP5ovjd7YcanPDiQ1nLGV/7lpuzuNTS7+oc2voF7ZhAhj5agjyXQQcdEkF+MLvd4UIzkJ8B3JMFUlCAe8ug4+oj6sb7F84lKzNP9tW+heLe3GtyhPPg3n4jk+3c= 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=o4NwI2W7; arc=none smtp.client-ip=217.70.183.197 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 1E23B1C000E; Thu, 1 Feb 2024 17:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706808732; 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=y+aqzxTPAUjOzIodHPzxeC6qMPaNLGnJXnuBentQENE=; b=o4NwI2W71cP/524XS5XZd+wR6dynrd7bQz1YYFr85lIod0g7wnCEVb5vMnkvfFa4swnFa6 Vga1gARfj5bJ4msfrmpsnust9S++UbhaLijPItbdzjUqSpZtYTV35ugOmwnlntXZ+9lfam uJftslgpJgj5g70KbaSDZfl4zGTDb5UP4ZWqeiSikA3jiebmiiYid8XZKd9QXevyUeoIVh fDmCB5CoGVdj+DFAUoIg4NVT0tnzc/n4iZ0Cz/xZCT9/jQ0UOrpkF+h7J+jAlBG8Pr+FkM CTYn91NG3ddpR1Y0LytRlrgqt5mb3zN/BNOlE23tdqRBEeojZORxMfxNUlKV8w== From: Louis Chauvet Date: Thu, 01 Feb 2024 18:31:31 +0100 Subject: [PATCH 1/2] drm/vkms: Create a type to check a function pointer validity 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: <20240201-yuv-v1-1-3ca376f27632@bootlin.com> References: <20240201-yuv-v1-0-3ca376f27632@bootlin.com> In-Reply-To: <20240201-yuv-v1-0-3ca376f27632@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 , marcheu@google.com, seanpaul@google.com, nicolejadeyee@google.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Louis Chauvet , thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3051; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=sy6XOjKiwgGLJghXuUCDDipZtMBjZVoiNnbEzSMpZZE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBlu9WZSdSr1fJmjjmgoEgdMXRsHSkHazV7I02+1oIU rS216fCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZbvVmQAKCRAgrS7GWxAs4lx2D/ 9gzX3KmylHrfqn4EdZ5irvLsNj7XKSNitiwqJLoic7NSfewZYK0ZTimaTYAqOJWUGC+1W7wWv8Y/Ah ujjMwiIwHX4ee+EmgvT5nFbtlNxwUbS/6YoGHh5z+JoAdCzZA3paPGkfLcRexE4W0KQFP23tsWD18F rb2Tlkqn5gHrT9PLwSV0VTiWfAi4KUv8fnc7CAyv/6BLnP5pRYHfOLo4TcTL/AztLn3hu4z27VytY3 Jd7Glyf8Y7Pc4fU0arCO8WrcI0+KaLp7NsEBM9bXJKYYUOncvYxiCBwUT5bibv9fZVU3t/0BLrDRRa VWQUXmKd48TfrZD0F/vNEnvOllKijrIg6usH81Qcm2hgBvNbIfIHokg9IoMKJH14fwlOJfLdtrfNOS ICe8GWq8r1njHfduxaUaTFBAnCFRcybcq/5qQdz3l2mNU6LJipXQKUvl46AHT26eHjVIGk33y+vQJN 0B7uU6HXys4vdlLpj8TsVHtlV8v7nPiG5N39l2NEjlWZ3nv1HAV6dWXA1SjJGMDUqQKftYSYaZMMGW qrCqrJ+E4SAR7w8If6pZXTaINxjhRvL+N+ZAPDIqwMH/OTxpJne5tJmwV3Jz/M6OyQ8kfw3k9k3Q56 b7qTPQxXPPYvKBVUcO2rvl3An1HvyBXGzH+NZHQPifz2RqVzzSZv9aItU2pQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com Add the pixel_read_t type to check function prototype in structures and functions. It avoids casting to (void *) and at the same occasion allows the compiler to check the type properly. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 17 +++++++++++++++-- drivers/gpu/drm/vkms/vkms_formats.c | 4 ++-- drivers/gpu/drm/vkms/vkms_formats.h | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 51349a0c32d8..cb20bab26cae 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -48,6 +48,20 @@ struct vkms_writeback_job { void (*pixel_write)(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel); }; +/** + * typedef pixel_read_t - These functions are used to read the pixels in the source frame, convert + * them to argb16 and write them to out_pixel. + * It assumes that src_pixels point to a valid pixel (not a block, or a block of 1x1 pixel) + * + * @src_pixels: Source pointer to a pixel + * @out_pixel: Pointer where to write the pixel value + * @encoding: Color encoding to use (mainly used for YUV formats) + * @range: Color range to use (mainly used for YUV formats) + */ +typedef void (*pixel_read_t)(u8 **src_pixels, int y, + struct pixel_argb_u16 *out_pixel, enum drm_color_encoding enconding, + enum drm_color_range range); + /** * vkms_plane_state - Driver specific plane state * @base: base plane state @@ -56,8 +70,7 @@ struct vkms_writeback_job { struct vkms_plane_state { struct drm_shadow_plane_state base; struct vkms_frame_info *frame_info; - void (*pixel_read)(u8 **src_buffer, struct pixel_argb_u16 *out_pixel, - enum drm_color_encoding enconding, enum drm_color_range range); + pixel_read_t pixel_read; }; struct vkms_plane { diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index e06bbd7c0a67..c6376db58d38 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -390,7 +390,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, wb->pixel_write(dst_pixels, &in_pixels[x]); } -void *get_pixel_conversion_function(u32 format) +pixel_read_t get_pixel_conversion_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: @@ -420,7 +420,7 @@ void *get_pixel_conversion_function(u32 format) case DRM_FORMAT_YVU444: return &planar_yvu_to_argb_u16; default: - return NULL; + return (pixel_read_t)NULL; } } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 0cf835292cec..04e31e126ab1 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -5,7 +5,7 @@ #include "vkms_drv.h" -void *get_pixel_conversion_function(u32 format); +pixel_read_t get_pixel_conversion_function(u32 format); void *get_pixel_write_function(u32 format); -- 2.43.0