2021-03-25 23:47:49 +02:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
/*
|
|
|
|
* Copyright © 2020-2021 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INTEL_FB_H__
|
|
|
|
#define __INTEL_FB_H__
|
|
|
|
|
2021-10-20 22:51:28 +03:00
|
|
|
#include <linux/bits.h>
|
2021-03-25 23:47:49 +02:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2021-08-23 15:25:36 +03:00
|
|
|
struct drm_device;
|
|
|
|
struct drm_file;
|
2021-03-25 23:47:49 +02:00
|
|
|
struct drm_framebuffer;
|
2024-09-17 19:13:40 +03:00
|
|
|
struct drm_gem_object;
|
2021-08-23 15:25:36 +03:00
|
|
|
struct drm_mode_fb_cmd2;
|
2025-02-06 20:55:26 +02:00
|
|
|
struct intel_display;
|
2021-03-25 23:48:01 +02:00
|
|
|
struct intel_fb_view;
|
|
|
|
struct intel_framebuffer;
|
2021-10-20 22:51:28 +03:00
|
|
|
struct intel_plane;
|
2021-03-25 23:47:52 +02:00
|
|
|
struct intel_plane_state;
|
2025-02-13 17:02:18 +02:00
|
|
|
struct intel_remapped_info;
|
|
|
|
struct intel_rotation_info;
|
2021-03-25 23:47:52 +02:00
|
|
|
|
2021-10-27 15:51:50 +03:00
|
|
|
#define INTEL_PLANE_CAP_NONE 0
|
|
|
|
#define INTEL_PLANE_CAP_CCS_RC BIT(0)
|
|
|
|
#define INTEL_PLANE_CAP_CCS_RC_CC BIT(1)
|
|
|
|
#define INTEL_PLANE_CAP_CCS_MC BIT(2)
|
|
|
|
#define INTEL_PLANE_CAP_TILING_X BIT(3)
|
|
|
|
#define INTEL_PLANE_CAP_TILING_Y BIT(4)
|
|
|
|
#define INTEL_PLANE_CAP_TILING_Yf BIT(5)
|
2022-01-18 13:55:44 +02:00
|
|
|
#define INTEL_PLANE_CAP_TILING_4 BIT(6)
|
2024-08-26 19:01:15 +02:00
|
|
|
#define INTEL_PLANE_CAP_NEED64K_PHYS BIT(7)
|
2021-10-20 22:51:28 +03:00
|
|
|
|
2022-10-03 14:15:44 +03:00
|
|
|
bool intel_fb_is_tiled_modifier(u64 modifier);
|
2021-10-20 22:51:37 +03:00
|
|
|
bool intel_fb_is_ccs_modifier(u64 modifier);
|
2021-10-20 22:51:38 +03:00
|
|
|
bool intel_fb_is_rc_ccs_cc_modifier(u64 modifier);
|
|
|
|
bool intel_fb_is_mc_ccs_modifier(u64 modifier);
|
2024-08-26 19:01:15 +02:00
|
|
|
bool intel_fb_needs_64k_phys(u64 modifier);
|
2024-10-07 21:28:41 +03:00
|
|
|
bool intel_fb_is_tile4_modifier(u64 modifier);
|
2021-10-20 22:51:37 +03:00
|
|
|
|
2021-10-20 22:51:36 +03:00
|
|
|
bool intel_fb_is_ccs_aux_plane(const struct drm_framebuffer *fb, int color_plane);
|
2021-10-20 22:51:34 +03:00
|
|
|
int intel_fb_rc_ccs_cc_plane(const struct drm_framebuffer *fb);
|
|
|
|
|
2025-02-06 20:55:26 +02:00
|
|
|
u64 *intel_fb_plane_get_modifiers(struct intel_display *display,
|
2021-10-26 19:15:16 +03:00
|
|
|
u8 plane_caps);
|
2021-10-20 22:51:28 +03:00
|
|
|
bool intel_fb_plane_supports_modifier(struct intel_plane *plane, u64 modifier);
|
|
|
|
|
2021-10-20 22:51:29 +03:00
|
|
|
const struct drm_format_info *
|
2025-07-01 12:07:04 +03:00
|
|
|
intel_fb_get_format_info(u32 pixel_format, u64 modifier);
|
2021-10-20 22:51:29 +03:00
|
|
|
|
2021-10-20 22:51:33 +03:00
|
|
|
bool
|
|
|
|
intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info,
|
|
|
|
u64 modifier);
|
|
|
|
|
2021-03-25 23:47:51 +02:00
|
|
|
bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane);
|
|
|
|
|
2021-03-25 23:47:50 +02:00
|
|
|
int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane);
|
|
|
|
int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane);
|
|
|
|
int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane);
|
|
|
|
|
2025-02-06 20:55:26 +02:00
|
|
|
unsigned int intel_tile_size(struct intel_display *display);
|
2021-08-23 15:25:33 +03:00
|
|
|
unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane);
|
2021-03-25 23:47:53 +02:00
|
|
|
unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane);
|
|
|
|
unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane);
|
2021-08-23 15:25:34 +03:00
|
|
|
unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
|
|
|
|
int color_plane, unsigned int height);
|
2021-03-25 23:47:53 +02:00
|
|
|
|
|
|
|
void intel_fb_plane_get_subsampling(int *hsub, int *vsub,
|
|
|
|
const struct drm_framebuffer *fb,
|
|
|
|
int color_plane);
|
|
|
|
|
|
|
|
u32 intel_plane_adjust_aligned_offset(int *x, int *y,
|
2025-02-13 17:02:20 +02:00
|
|
|
const struct intel_plane_state *plane_state,
|
2021-03-25 23:47:53 +02:00
|
|
|
int color_plane,
|
|
|
|
u32 old_offset, u32 new_offset);
|
|
|
|
u32 intel_plane_compute_aligned_offset(int *x, int *y,
|
2025-02-13 17:02:20 +02:00
|
|
|
const struct intel_plane_state *plane_state,
|
2021-03-25 23:47:53 +02:00
|
|
|
int color_plane);
|
|
|
|
|
2021-05-06 19:19:30 +03:00
|
|
|
bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb);
|
2025-02-13 17:02:17 +02:00
|
|
|
bool intel_plane_uses_fence(const struct intel_plane_state *plane_state);
|
2021-05-06 19:19:28 +03:00
|
|
|
bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb);
|
|
|
|
|
2025-02-13 17:02:18 +02:00
|
|
|
unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
|
|
|
|
unsigned int intel_remapped_info_size(const struct intel_remapped_info *rem_info);
|
|
|
|
|
2025-02-06 20:55:26 +02:00
|
|
|
int intel_fill_fb_info(struct intel_display *display, struct intel_framebuffer *fb);
|
2021-03-25 23:48:01 +02:00
|
|
|
void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation,
|
|
|
|
struct intel_fb_view *view);
|
2025-01-22 17:17:53 +02:00
|
|
|
unsigned int intel_fb_view_vtd_guard(const struct drm_framebuffer *fb,
|
|
|
|
const struct intel_fb_view *view,
|
|
|
|
unsigned int rotation);
|
2021-03-25 23:47:53 +02:00
|
|
|
int intel_plane_compute_gtt(struct intel_plane_state *plane_state);
|
|
|
|
|
2025-02-13 17:02:19 +02:00
|
|
|
unsigned int intel_fb_xy_to_linear(int x, int y,
|
2025-02-13 17:02:20 +02:00
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
int color_plane);
|
2025-02-13 17:02:19 +02:00
|
|
|
void intel_add_fb_offsets(int *x, int *y,
|
2025-02-13 17:02:20 +02:00
|
|
|
const struct intel_plane_state *plane_state,
|
|
|
|
int color_plane);
|
2025-02-13 17:02:19 +02:00
|
|
|
|
2021-08-23 15:25:36 +03:00
|
|
|
int intel_framebuffer_init(struct intel_framebuffer *ifb,
|
2024-09-17 19:13:45 +03:00
|
|
|
struct drm_gem_object *obj,
|
2025-07-01 12:07:16 +03:00
|
|
|
const struct drm_format_info *info,
|
2021-08-23 15:25:36 +03:00
|
|
|
struct drm_mode_fb_cmd2 *mode_cmd);
|
|
|
|
struct drm_framebuffer *
|
2024-09-17 19:13:50 +03:00
|
|
|
intel_framebuffer_create(struct drm_gem_object *obj,
|
2025-07-01 12:07:16 +03:00
|
|
|
const struct drm_format_info *info,
|
2024-09-17 19:13:50 +03:00
|
|
|
struct drm_mode_fb_cmd2 *mode_cmd);
|
|
|
|
struct drm_framebuffer *
|
2021-08-23 15:25:36 +03:00
|
|
|
intel_user_framebuffer_create(struct drm_device *dev,
|
|
|
|
struct drm_file *filp,
|
drm: Pass the format info to .fb_create()
Pass along the format information from the top to .fb_create()
so that we can avoid redundant (and somewhat expensive) lookups
in the drivers.
Done with cocci (with some manual fixups):
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
(
- const struct drm_format_info *info = drm_get_format_info(...);
|
- const struct drm_format_info *info;
...
- info = drm_get_format_info(...);
)
<...
- if (!info)
- return ...;
...>
}
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
}
@find@
identifier fb_create_func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *fb_create_func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
@@
identifier find.fb_create_func;
expression dev, file, mode_cmd;
@@
fb_create_func(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create_with_dirty(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file_priv, mode_cmd;
identifier info, fb;
@@
info = drm_get_format_info(...);
...
fb = dev->mode_config.funcs->fb_create(dev, file_priv
+ ,info
,mode_cmd);
@@
identifier dev, file_priv, mode_cmd;
@@
struct drm_mode_config_funcs {
...
struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
struct drm_file *file_priv,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
...
};
v2: Fix kernel docs (Laurent)
Fix commit msg (Geert)
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Maxime Ripard <mripard@kernel.org>
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: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Biju Das <biju.das.jz@bp.renesas.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: Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: "Maíra Canal" <mcanal@igalia.com>
Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>
Cc: Chia-I Wu <olvaffe@gmail.com>
Cc: Zack Rusin <zack.rusin@broadcom.com>
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: virtualization@lists.linux.dev
Cc: spice-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-5-ville.syrjala@linux.intel.com
2025-07-01 12:07:07 +03:00
|
|
|
const struct drm_format_info *info,
|
2021-08-23 15:25:36 +03:00
|
|
|
const struct drm_mode_fb_cmd2 *user_mode_cmd);
|
|
|
|
|
2025-02-06 20:55:26 +02:00
|
|
|
bool intel_fb_modifier_uses_dpt(struct intel_display *display, u64 modifier);
|
2021-12-01 15:57:08 +02:00
|
|
|
bool intel_fb_uses_dpt(const struct drm_framebuffer *fb);
|
|
|
|
|
2023-12-03 13:48:38 +02:00
|
|
|
unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier);
|
|
|
|
|
2024-09-17 19:13:40 +03:00
|
|
|
struct drm_gem_object *intel_fb_bo(const struct drm_framebuffer *fb);
|
|
|
|
|
2021-03-25 23:47:49 +02:00
|
|
|
#endif /* __INTEL_FB_H__ */
|