mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
drm: Pass pixel_format+modifier directly to drm_get_format_info()
Decouple drm_get_format_info() from struct drm_mode_fb_cmd2 and just
pass the pixel format+modifier combo in by hand.
We may want to use drm_get_format_info() outside of the normal
addfb paths where we won't have a struct drm_mode_fb_cmd2, and
creating a temporary one just for this seems silly.
Done with cocci:
@@
identifier dev, mode_cmd;
@@
struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
- const struct drm_mode_fb_cmd2 *mode_cmd
+ u32 pixel_format, u64 modifier
)
{
<...
(
- mode_cmd->pixel_format
+ pixel_format
|
- mode_cmd->modifier[0]
+ modifier
)
...>
}
@@
identifier dev, mode_cmd;
@@
struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
- const struct drm_mode_fb_cmd2 *mode_cmd
+ u32 pixel_format, u64 modifier
);
@@
expression dev, mode_cmd;
@@
- drm_get_format_info(dev, mode_cmd)
+ drm_get_format_info(dev, mode_cmd->pixel_format, mode_cmd->modifier[0])
v2: Fix kernel docs (Laurent)
Drop drm_mode_fb_cmd2 forward declaration (Thomas)
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Sean Paul <sean@poorly.run>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Andy Yan <andy.yan@rock-chips.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-3-ville.syrjala@linux.intel.com
This commit is contained in:
parent
0389e4256e
commit
0e7d5874fb
17 changed files with 48 additions and 26 deletions
|
|
@ -325,7 +325,8 @@ malidp_verify_afbc_framebuffer_size(struct drm_device *dev,
|
|||
return false;
|
||||
}
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
|
||||
n_superblocks = (mode_cmd->width / afbc_superblock_width) *
|
||||
(mode_cmd->height / afbc_superblock_height);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,9 @@ struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
|
|||
struct drm_framebuffer *armada_fb_create(struct drm_device *dev,
|
||||
struct drm_file *dfile, const struct drm_mode_fb_cmd2 *mode)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev, mode);
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
mode->pixel_format,
|
||||
mode->modifier[0]);
|
||||
struct armada_gem_object *obj;
|
||||
struct armada_framebuffer *dfb;
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -417,7 +417,8 @@ EXPORT_SYMBOL(drm_format_info);
|
|||
/**
|
||||
* drm_get_format_info - query information for a given framebuffer configuration
|
||||
* @dev: DRM device
|
||||
* @mode_cmd: metadata from the userspace fb creation request
|
||||
* @pixel_format: pixel format (DRM_FORMAT_*)
|
||||
* @modifier: modifier
|
||||
*
|
||||
* Returns:
|
||||
* The instance of struct drm_format_info that describes the pixel format, or
|
||||
|
|
@ -425,16 +426,16 @@ EXPORT_SYMBOL(drm_format_info);
|
|||
*/
|
||||
const struct drm_format_info *
|
||||
drm_get_format_info(struct drm_device *dev,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||
u32 pixel_format, u64 modifier)
|
||||
{
|
||||
const struct drm_format_info *info = NULL;
|
||||
|
||||
if (dev->mode_config.funcs->get_format_info)
|
||||
info = dev->mode_config.funcs->get_format_info(mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
info = dev->mode_config.funcs->get_format_info(pixel_format,
|
||||
modifier);
|
||||
|
||||
if (!info)
|
||||
info = drm_format_info(mode_cmd->pixel_format);
|
||||
info = drm_format_info(pixel_format);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ static int framebuffer_check(struct drm_device *dev,
|
|||
}
|
||||
|
||||
/* now let the driver pick its own format info */
|
||||
info = drm_get_format_info(dev, r);
|
||||
info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
|
||||
|
||||
for (i = 0; i < info->num_planes; i++) {
|
||||
unsigned int width = drm_format_info_plane_width(info, r->width, i);
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev,
|
|||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
if (!info) {
|
||||
drm_dbg_kms(dev, "Failed to get FB format info\n");
|
||||
return -EINVAL;
|
||||
|
|
@ -502,7 +503,8 @@ static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev,
|
|||
{
|
||||
const struct drm_format_info *info;
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
|
||||
switch (info->format) {
|
||||
case DRM_FORMAT_YUV420_8BIT:
|
||||
|
|
@ -600,7 +602,8 @@ int drm_gem_fb_afbc_init(struct drm_device *dev,
|
|||
int ret;
|
||||
|
||||
objs = afbc_fb->base.obj;
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
if (!info)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
|
|||
int i;
|
||||
|
||||
fb->dev = dev;
|
||||
fb->format = drm_get_format_info(dev, mode_cmd);
|
||||
fb->format = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
fb->width = mode_cmd->width;
|
||||
fb->height = mode_cmd->height;
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ static struct drm_framebuffer *
|
|||
exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev, mode_cmd);
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
|
||||
struct drm_framebuffer *fb;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ static int psb_framebuffer_init(struct drm_device *dev,
|
|||
* Reject unknown formats, YUV formats, and formats with more than
|
||||
* 4 bytes per pixel.
|
||||
*/
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
if (!info || !info->depth || info->cpp[0] > 4)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
|
|||
struct drm_file *file,
|
||||
const struct drm_mode_fb_cmd2 *cmd)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev, cmd);
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
cmd->pixel_format,
|
||||
cmd->modifier[0]);
|
||||
|
||||
if (info->num_planes != 1)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
|
|||
struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
mode_cmd);
|
||||
mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
struct drm_gem_object *bos[4] = {0};
|
||||
struct drm_framebuffer *fb;
|
||||
int ret, i, n = info->num_planes;
|
||||
|
|
@ -173,7 +174,8 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
|
|||
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
mode_cmd);
|
||||
mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
struct msm_drm_private *priv = dev->dev_private;
|
||||
struct msm_kms *kms = priv->kms;
|
||||
struct msm_framebuffer *msm_fb = NULL;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ mxsfb_fb_create(struct drm_device *dev, struct drm_file *file_priv,
|
|||
{
|
||||
const struct drm_format_info *info;
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
if (!info)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,8 @@ nouveau_framebuffer_new(struct drm_device *dev,
|
|||
kind = nvbo->kind;
|
||||
}
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
|
||||
for (i = 0; i < info->num_planes; i++) {
|
||||
height = drm_format_info_plane_height(info,
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
|
|||
struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(dev,
|
||||
mode_cmd);
|
||||
mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
unsigned int num_planes = info->num_planes;
|
||||
struct drm_gem_object *bos[4];
|
||||
struct drm_framebuffer *fb;
|
||||
|
|
@ -378,7 +379,8 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
|
|||
dev, mode_cmd, mode_cmd->width, mode_cmd->height,
|
||||
(char *)&mode_cmd->pixel_format);
|
||||
|
||||
format = drm_get_format_info(dev, mode_cmd);
|
||||
format = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(formats); i++) {
|
||||
if (formats[i] == mode_cmd->pixel_format)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ static int radeon_fbdev_create_pinned_object(struct drm_fb_helper *fb_helper,
|
|||
int height = mode_cmd->height;
|
||||
u32 cpp;
|
||||
|
||||
info = drm_get_format_info(rdev_to_drm(rdev), mode_cmd);
|
||||
info = drm_get_format_info(rdev_to_drm(rdev), mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
cpp = info->cpp[0];
|
||||
|
||||
/* need to align pitch with crtc limits */
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file *file,
|
|||
const struct drm_format_info *info;
|
||||
int ret;
|
||||
|
||||
info = drm_get_format_info(dev, mode_cmd);
|
||||
info = drm_get_format_info(dev, mode_cmd->pixel_format,
|
||||
mode_cmd->modifier[0]);
|
||||
if (!info)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,9 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
|
|||
struct drm_file *file,
|
||||
const struct drm_mode_fb_cmd2 *cmd)
|
||||
{
|
||||
const struct drm_format_info *info = drm_get_format_info(drm, cmd);
|
||||
const struct drm_format_info *info = drm_get_format_info(drm,
|
||||
cmd->pixel_format,
|
||||
cmd->modifier[0]);
|
||||
struct tegra_bo *planes[4];
|
||||
struct drm_gem_object *gem;
|
||||
struct drm_framebuffer *fb;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
#endif
|
||||
|
||||
struct drm_device;
|
||||
struct drm_mode_fb_cmd2;
|
||||
|
||||
/**
|
||||
* struct drm_format_info - information about a DRM format
|
||||
|
|
@ -309,7 +308,7 @@ const struct drm_format_info *__drm_format_info(u32 format);
|
|||
const struct drm_format_info *drm_format_info(u32 format);
|
||||
const struct drm_format_info *
|
||||
drm_get_format_info(struct drm_device *dev,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd);
|
||||
u32 pixel_format, u64 modifier);
|
||||
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
|
||||
uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
|
||||
uint32_t bpp, uint32_t depth);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue