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 <ankit.k.nautiyal@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patch.msgid.link/20251219060302.2365123-4-ankit.k.nautiyal@intel.com
This commit is contained in:
Ankit Nautiyal 2025-12-19 11:32:56 +05:30
parent f3255cf449
commit d6a3a67856
5 changed files with 49 additions and 0 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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__ */

View File

@ -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 {

View File

@ -66,6 +66,7 @@
#include "display/vlv_dsi_pll_regs.h"
#include "gt/intel_gt_regs.h"
#include <linux/vmalloc.h>
#include "display_helpers.h"
/* XXX FIXME i915 has changed PP_XXX definition */
#define PCH_PP_STATUS _MMIO(0xc7200)