From: Ankit Nautiyal Date: Fri, 19 Dec 2025 06:02:56 +0000 (+0530) Subject: drm/i915/gvt: Add header to use display offset functions in macros X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6a3a678569431ed816ac490bf489541bc87b424;p=thirdparty%2Fkernel%2Flinux.git drm/i915/gvt: Add header to use display offset functions in macros Introduce gvt/display_helpers.h to make DISPLAY_MMIO_BASE and INTEL_DISPLAY_DEVICE_*_OFFSET macros call exported display functions. This lets GVT keep using existing register macros (e.g., TRANSCONF(display, pipe)) while ensuring offset calculations happen through functions instead of accessing display internals. Ideally, we would remove the display headers that define these macros, but some macros in GVT still depend on them and have not yet been ported. Keeping those headers leads to build conflicts, so as a stopgap, we use temporary ifdef/undef blocks to override the macros with API-backed versions. These will be removed once all dependent macros are ported and the conflicting headers can be safely dropped. Note: TRANSCONF() expects a pipe index but some GVT callers pass a transcoder, causing -Werror=enum-conversion. Fix: cast to enum pipe in the GVT-side macro override. This works for all cases as TRANSCODER_{A,B,C,D} all have 1:1 mapping to PIPE_{A,B,C,D} except for TRANSCODER_EDP which is used in one place. In any case, the cast preserves the previous behaviour. v2: - Remove prefix `gvt/` while including the header file. (Jani) - Explain the rationale behind temporary ifdef/undefs and plan to drop them. (Jani). v3: - Meld the patch to cast argument to enum pipe for the pipe-offset macro. (Jani) - Add a FIXME to highlight the cast. (Jani) Signed-off-by: Ankit Nautiyal Reviewed-by: Jani Nikula Link: https://patch.msgid.link/20251219060302.2365123-4-ankit.k.nautiyal@intel.com --- diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c index df04e4ead8ea1..fbc8a5e285768 100644 --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c @@ -58,6 +58,7 @@ #include "gem/i915_gem_context.h" #include "gem/i915_gem_pm.h" #include "gt/intel_context.h" +#include "display_helpers.h" #define INVALID_OP (~0U) diff --git a/drivers/gpu/drm/i915/gvt/display.c b/drivers/gpu/drm/i915/gvt/display.c index 06517d1f07a29..9d6b22b2e4d01 100644 --- a/drivers/gpu/drm/i915/gvt/display.c +++ b/drivers/gpu/drm/i915/gvt/display.c @@ -46,6 +46,7 @@ #include "display/intel_cursor_regs.h" #include "display/intel_display.h" #include "display/intel_display_core.h" +#include "display_helpers.h" #include "display/intel_dpio_phy.h" #include "display/intel_sprite_regs.h" diff --git a/drivers/gpu/drm/i915/gvt/display_helpers.h b/drivers/gpu/drm/i915/gvt/display_helpers.h new file mode 100644 index 0000000000000..cbe383f677d58 --- /dev/null +++ b/drivers/gpu/drm/i915/gvt/display_helpers.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright © 2025 Intel Corporation + */ + +#ifndef __DISPLAY_HELPERS_H__ +#define __DISPLAY_HELPERS_H__ + +#include "display/intel_gvt_api.h" + +#ifdef DISPLAY_MMIO_BASE +#undef DISPLAY_MMIO_BASE +#endif +#define DISPLAY_MMIO_BASE(display) \ + intel_display_device_mmio_base((display)) + +#ifdef INTEL_DISPLAY_DEVICE_PIPE_OFFSET +#undef INTEL_DISPLAY_DEVICE_PIPE_OFFSET +#endif +/* + * #FIXME: + * TRANSCONF() uses pipe-based addressing via _MMIO_PIPE2(). + * Some GVT call sites pass enum transcoder instead of enum pipe. + * Cast the argument to enum pipe for now since TRANSCODER_A..D map + * 1:1 to PIPE_A..D. + * TRANSCODER_EDP is an exception, the cast preserves the existing + * behaviour but this needs to be handled later either by using the + * correct pipe or by switching TRANSCONF() to use _MMIO_TRANS2(). + */ +#define INTEL_DISPLAY_DEVICE_PIPE_OFFSET(display, idx) \ + intel_display_device_pipe_offset((display), (enum pipe)(idx)) + +#ifdef INTEL_DISPLAY_DEVICE_TRANS_OFFSET +#undef INTEL_DISPLAY_DEVICE_TRANS_OFFSET +#endif +#define INTEL_DISPLAY_DEVICE_TRANS_OFFSET(display, trans) \ + intel_display_device_trans_offset((display), (trans)) + +#ifdef INTEL_DISPLAY_DEVICE_CURSOR_OFFSET +#undef INTEL_DISPLAY_DEVICE_CURSOR_OFFSET +#endif +#define INTEL_DISPLAY_DEVICE_CURSOR_OFFSET(display, pipe) \ + intel_display_device_cursor_offset((display), (pipe)) + +#endif /* __DISPLAY_HELPERS_H__ */ diff --git a/drivers/gpu/drm/i915/gvt/fb_decoder.c b/drivers/gpu/drm/i915/gvt/fb_decoder.c index a8079cfa8e1d3..c402f3b5a0abf 100644 --- a/drivers/gpu/drm/i915/gvt/fb_decoder.c +++ b/drivers/gpu/drm/i915/gvt/fb_decoder.c @@ -46,6 +46,7 @@ #include "display/intel_display_core.h" #include "display/intel_sprite_regs.h" #include "display/skl_universal_plane_regs.h" +#include "display_helpers.h" #define PRIMARY_FORMAT_NUM 16 struct pixel_format { diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c index 36ea12ade849c..9ada97d01b6c8 100644 --- a/drivers/gpu/drm/i915/gvt/handlers.c +++ b/drivers/gpu/drm/i915/gvt/handlers.c @@ -66,6 +66,7 @@ #include "display/vlv_dsi_pll_regs.h" #include "gt/intel_gt_regs.h" #include +#include "display_helpers.h" /* XXX FIXME i915 has changed PP_XXX definition */ #define PCH_PP_STATUS _MMIO(0xc7200)