From: Louis Chauvet <louis.chauvet@bootlin.com>
To: "Rodrigo Siqueira" <rodrigosiqueiramelo@gmail.com>,
"Melissa Wen" <melissa.srw@gmail.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Haneen Mohammed" <hamohammed.sa@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
marcheu@google.com, seanpaul@google.com,
nicolejadeyee@google.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Louis Chauvet <louis.chauvet@bootlin.com>,
thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com
Subject: [PATCH 1/2] drm/vkms: Create a type to check a function pointer validity
Date: Thu, 01 Feb 2024 18:31:31 +0100 [thread overview]
Message-ID: <20240201-yuv-v1-1-3ca376f27632@bootlin.com> (raw)
In-Reply-To: <20240201-yuv-v1-0-3ca376f27632@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 <louis.chauvet@bootlin.com>
---
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
next prev parent reply other threads:[~2024-02-01 17:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 17:31 [PATCH 0/2] Better support for complex pixel formats Louis Chauvet
2024-02-01 17:31 ` Louis Chauvet [this message]
2024-02-02 20:59 ` [PATCH 1/2] drm/vkms: Create a type to check a function pointer validity Arthur Grillo
2024-02-01 17:31 ` [PATCH 2/2] drm/vkms: Use a simpler composition function Louis Chauvet
2024-02-02 8:55 ` Pekka Paalanen
2024-02-02 9:26 ` Miquel Raynal
2024-02-02 9:47 ` Maíra Canal
2024-02-02 9:53 ` Maxime Ripard
2024-02-02 12:13 ` Miquel Raynal
2024-02-02 15:49 ` Pekka Paalanen
2024-02-02 16:07 ` Miquel Raynal
2024-02-02 19:45 ` Pekka Paalanen
2024-02-06 17:57 ` Arthur Grillo
2024-02-07 8:44 ` Pekka Paalanen
2024-02-07 16:03 ` Louis Chauvet
2024-02-07 20:21 ` Arthur Grillo
2024-02-02 20:02 ` Arthur Grillo
2024-02-05 10:12 ` Pekka Paalanen
2024-02-05 10:19 ` Pekka Paalanen
2024-02-07 15:49 ` Louis Chauvet
2024-02-08 9:39 ` Pekka Paalanen
2024-02-15 17:43 ` Arthur Grillo
2024-02-02 10:24 ` Pekka Paalanen
2024-02-01 22:07 ` [PATCH 0/2] Better support for complex pixel formats Maira Canal
2024-02-02 8:15 ` Louis Chauvet
2024-02-02 9:40 ` Maíra Canal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201-yuv-v1-1-3ca376f27632@bootlin.com \
--to=louis.chauvet@bootlin.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=marcheu@google.com \
--cc=melissa.srw@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=nicolejadeyee@google.com \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=seanpaul@google.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®