1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2023 Intel Corporation 4 */ 5 6 #ifndef __INTEL_DISPLAY_DEVICE_H__ 7 #define __INTEL_DISPLAY_DEVICE_H__ 8 9 #include <linux/bitops.h> 10 #include <linux/types.h> 11 12 #include "intel_display_limits.h" 13 14 struct drm_printer; 15 struct intel_display; 16 struct pci_dev; 17 18 /* 19 * Display platforms and subplatforms. Keep platforms in display version based 20 * order, chronological order within a version, and subplatforms next to the 21 * platform. 22 */ 23 #define INTEL_DISPLAY_PLATFORMS(func) \ 24 /* Platform group aliases */ \ 25 func(g4x) /* g45 and gm45 */ \ 26 func(mobile) /* mobile platforms */ \ 27 func(dgfx) /* discrete graphics */ \ 28 /* Display ver 2 */ \ 29 func(i830) \ 30 func(i845g) \ 31 func(i85x) \ 32 func(i865g) \ 33 /* Display ver 3 */ \ 34 func(i915g) \ 35 func(i915gm) \ 36 func(i945g) \ 37 func(i945gm) \ 38 func(g33) \ 39 func(pineview) \ 40 /* Display ver 4 */ \ 41 func(i965g) \ 42 func(i965gm) \ 43 func(g45) \ 44 func(gm45) \ 45 /* Display ver 5 */ \ 46 func(ironlake) \ 47 /* Display ver 6 */ \ 48 func(sandybridge) \ 49 /* Display ver 7 */ \ 50 func(ivybridge) \ 51 func(valleyview) \ 52 func(haswell) \ 53 func(haswell_ult) \ 54 func(haswell_ulx) \ 55 /* Display ver 8 */ \ 56 func(broadwell) \ 57 func(broadwell_ult) \ 58 func(broadwell_ulx) \ 59 func(cherryview) \ 60 /* Display ver 9 */ \ 61 func(skylake) \ 62 func(skylake_ult) \ 63 func(skylake_ulx) \ 64 func(broxton) \ 65 func(kabylake) \ 66 func(kabylake_ult) \ 67 func(kabylake_ulx) \ 68 func(geminilake) \ 69 func(coffeelake) \ 70 func(coffeelake_ult) \ 71 func(coffeelake_ulx) \ 72 func(cometlake) \ 73 func(cometlake_ult) \ 74 func(cometlake_ulx) \ 75 /* Display ver 11 */ \ 76 func(icelake) \ 77 func(icelake_port_f) \ 78 func(jasperlake) \ 79 func(elkhartlake) \ 80 /* Display ver 12 */ \ 81 func(tigerlake) \ 82 func(tigerlake_uy) \ 83 func(rocketlake) \ 84 func(dg1) \ 85 func(alderlake_s) \ 86 func(alderlake_s_raptorlake_s) \ 87 /* Display ver 13 */ \ 88 func(alderlake_p) \ 89 func(alderlake_p_alderlake_n) \ 90 func(alderlake_p_raptorlake_p) \ 91 func(alderlake_p_raptorlake_u) \ 92 func(dg2) \ 93 func(dg2_g10) \ 94 func(dg2_g11) \ 95 func(dg2_g12) \ 96 /* Display ver 14 (based on GMD ID) */ \ 97 func(meteorlake) \ 98 func(meteorlake_u) \ 99 /* Display ver 20 (based on GMD ID) */ \ 100 func(lunarlake) \ 101 /* Display ver 14.1 (based on GMD ID) */ \ 102 func(battlemage) \ 103 /* Display ver 30 (based on GMD ID) */ \ 104 func(pantherlake) \ 105 func(pantherlake_wildcatlake) 106 107 108 #define __MEMBER(name) unsigned long name:1; 109 #define __COUNT(x) 1 + 110 111 #define __NUM_PLATFORMS (INTEL_DISPLAY_PLATFORMS(__COUNT) 0) 112 113 struct intel_display_platforms { 114 union { 115 struct { 116 INTEL_DISPLAY_PLATFORMS(__MEMBER); 117 }; 118 DECLARE_BITMAP(bitmap, __NUM_PLATFORMS); 119 }; 120 }; 121 122 #undef __MEMBER 123 #undef __COUNT 124 #undef __NUM_PLATFORMS 125 126 #define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \ 127 /* Keep in alphabetical order */ \ 128 func(cursor_needs_physical); \ 129 func(has_cdclk_crawl); \ 130 func(has_cdclk_squash); \ 131 func(has_ddi); \ 132 func(has_dp_mst); \ 133 func(has_dsb); \ 134 func(has_fpga_dbg); \ 135 func(has_gmch); \ 136 func(has_hotplug); \ 137 func(has_hti); \ 138 func(has_ipc); \ 139 func(has_overlay); \ 140 func(has_psr); \ 141 func(has_psr_hw_tracking); \ 142 func(overlay_needs_physical); \ 143 func(supports_tv); 144 145 #define HAS_4TILE(__display) ((__display)->platform.dg2 || DISPLAY_VER(__display) >= 14) 146 #define HAS_ASYNC_FLIPS(__display) (DISPLAY_VER(__display) >= 5) 147 #define HAS_AS_SDP(__display) (DISPLAY_VER(__display) >= 13) 148 #define HAS_BIGJOINER(__display) (DISPLAY_VER(__display) >= 11 && HAS_DSC(__display)) 149 #define HAS_CDCLK_CRAWL(__display) (DISPLAY_INFO(__display)->has_cdclk_crawl) 150 #define HAS_CDCLK_SQUASH(__display) (DISPLAY_INFO(__display)->has_cdclk_squash) 151 #define HAS_CMRR(__display) (DISPLAY_VER(__display) >= 20) 152 #define HAS_CMTG(__display) (!(__display)->platform.dg2 && DISPLAY_VER(__display) >= 13) 153 #define HAS_CUR_FBC(__display) (!HAS_GMCH(__display) && IS_DISPLAY_VER(__display, 7, 13)) 154 #define HAS_D12_PLANE_MINIMIZATION(__display) ((__display)->platform.rocketlake || (__display)->platform.alderlake_s) 155 #define HAS_DBUF_OVERLAP_DETECTION(__display) (DISPLAY_RUNTIME_INFO(__display)->has_dbuf_overlap_detection) 156 #define HAS_DDI(__display) (DISPLAY_INFO(__display)->has_ddi) 157 #define HAS_DISPLAY(__display) (DISPLAY_RUNTIME_INFO(__display)->pipe_mask != 0) 158 #define HAS_DMC(__display) (DISPLAY_RUNTIME_INFO(__display)->has_dmc) 159 #define HAS_DMC_WAKELOCK(__display) (DISPLAY_VER(__display) >= 20) 160 #define HAS_DOUBLE_BUFFERED_M_N(__display) (DISPLAY_VER(__display) >= 9 || (__display)->platform.broadwell) 161 #define HAS_DOUBLE_BUFFERED_LUT(__display) (DISPLAY_VER(__display) >= 30) 162 #define HAS_DOUBLE_WIDE(__display) (DISPLAY_VER(__display) < 4) 163 #define HAS_DP20(__display) ((__display)->platform.dg2 || DISPLAY_VER(__display) >= 14) 164 #define HAS_DPT(__display) (DISPLAY_VER(__display) >= 13) 165 #define HAS_DP_MST(__display) (DISPLAY_INFO(__display)->has_dp_mst) 166 #define HAS_DSB(__display) (DISPLAY_INFO(__display)->has_dsb) 167 #define HAS_DSC(__display) (DISPLAY_RUNTIME_INFO(__display)->has_dsc) 168 #define HAS_DSC_3ENGINES(__display) (DISPLAY_VERx100(__display) == 1401 && HAS_DSC(__display)) 169 #define HAS_DSC_MST(__display) (DISPLAY_VER(__display) >= 12 && HAS_DSC(__display)) 170 #define HAS_FBC(__display) (DISPLAY_RUNTIME_INFO(__display)->fbc_mask != 0) 171 #define HAS_FBC_DIRTY_RECT(__display) (DISPLAY_VER(__display) >= 30) 172 #define HAS_FPGA_DBG_UNCLAIMED(__display) (DISPLAY_INFO(__display)->has_fpga_dbg) 173 #define HAS_FW_BLC(__display) (DISPLAY_VER(__display) >= 3) 174 #define HAS_GMBUS_BURST_READ(__display) (DISPLAY_VER(__display) >= 10 || (__display)->platform.kabylake) 175 #define HAS_GMBUS_IRQ(__display) (DISPLAY_VER(__display) >= 4) 176 #define HAS_GMCH(__display) (DISPLAY_INFO(__display)->has_gmch) 177 #define HAS_FDI(__display) (IS_DISPLAY_VER((__display), 5, 8) && !HAS_GMCH(__display)) 178 #define HAS_HOTPLUG(__display) (DISPLAY_INFO(__display)->has_hotplug) 179 #define HAS_HW_SAGV_WM(__display) (DISPLAY_VER(__display) >= 13 && !(__display)->platform.dgfx) 180 #define HAS_IPC(__display) (DISPLAY_INFO(__display)->has_ipc) 181 #define HAS_IPS(__display) ((__display)->platform.haswell_ult || (__display)->platform.broadwell) 182 #define HAS_LRR(__display) (DISPLAY_VER(__display) >= 12) 183 #define HAS_LSPCON(__display) (IS_DISPLAY_VER(__display, 9, 10)) 184 #define HAS_MBUS_JOINING(__display) ((__display)->platform.alderlake_p || DISPLAY_VER(__display) >= 14) 185 #define HAS_MSO(__display) (DISPLAY_VER(__display) >= 12) 186 #define HAS_OVERLAY(__display) (DISPLAY_INFO(__display)->has_overlay) 187 #define HAS_PIPEDMC(__display) (DISPLAY_VER(__display) >= 12) 188 #define HAS_PSR(__display) (DISPLAY_INFO(__display)->has_psr) 189 #define HAS_PSR_HW_TRACKING(__display) (DISPLAY_INFO(__display)->has_psr_hw_tracking) 190 #define HAS_PSR2_SEL_FETCH(__display) (DISPLAY_VER(__display) >= 12) 191 #define HAS_SAGV(__display) (DISPLAY_VER(__display) >= 9 && \ 192 !(__display)->platform.broxton && !(__display)->platform.geminilake) 193 #define HAS_TRANSCODER(__display, trans) ((DISPLAY_RUNTIME_INFO(__display)->cpu_transcoder_mask & \ 194 BIT(trans)) != 0) 195 #define HAS_UNCOMPRESSED_JOINER(__display) (DISPLAY_VER(__display) >= 13) 196 #define HAS_ULTRAJOINER(__display) (((__display)->platform.dgfx && \ 197 DISPLAY_VER(__display) == 14) && HAS_DSC(__display)) 198 #define HAS_VRR(__display) (DISPLAY_VER(__display) >= 11) 199 #define INTEL_NUM_PIPES(__display) (hweight8(DISPLAY_RUNTIME_INFO(__display)->pipe_mask)) 200 #define OVERLAY_NEEDS_PHYSICAL(__display) (DISPLAY_INFO(__display)->overlay_needs_physical) 201 #define SUPPORTS_TV(__display) (DISPLAY_INFO(__display)->supports_tv) 202 203 /* Check that device has a display IP version within the specific range. */ 204 #define IS_DISPLAY_VERx100(__display, from, until) ( \ 205 BUILD_BUG_ON_ZERO((from) < 200) + \ 206 (DISPLAY_VERx100(__display) >= (from) && \ 207 DISPLAY_VERx100(__display) <= (until))) 208 209 /* 210 * Check if a device has a specific IP version as well as a stepping within the 211 * specified range [from, until). The lower bound is inclusive, the upper 212 * bound is exclusive. The most common use-case of this macro is for checking 213 * bounds for workarounds, which usually have a stepping ("from") at which the 214 * hardware issue is first present and another stepping ("until") at which a 215 * hardware fix is present and the software workaround is no longer necessary. 216 * E.g., 217 * 218 * IS_DISPLAY_VERx100_STEP(display, 1400, STEP_A0, STEP_B2) 219 * IS_DISPLAY_VERx100_STEP(display, 1400, STEP_C0, STEP_FOREVER) 220 * 221 * "STEP_FOREVER" can be passed as "until" for workarounds that have no upper 222 * stepping bound for the specified IP version. 223 */ 224 #define IS_DISPLAY_VERx100_STEP(__display, ipver, from, until) \ 225 (IS_DISPLAY_VERx100((__display), (ipver), (ipver)) && \ 226 IS_DISPLAY_STEP((__display), (from), (until))) 227 228 #define DISPLAY_INFO(__display) ((__display)->info.__device_info) 229 #define DISPLAY_RUNTIME_INFO(__display) (&(__display)->info.__runtime_info) 230 231 #define DISPLAY_VER(__display) (DISPLAY_RUNTIME_INFO(__display)->ip.ver) 232 #define DISPLAY_VERx100(__display) (DISPLAY_RUNTIME_INFO(__display)->ip.ver * 100 + \ 233 DISPLAY_RUNTIME_INFO(__display)->ip.rel) 234 #define IS_DISPLAY_VER(__display, from, until) \ 235 (DISPLAY_VER(__display) >= (from) && DISPLAY_VER(__display) <= (until)) 236 237 #define INTEL_DISPLAY_STEP(__display) (DISPLAY_RUNTIME_INFO(__display)->step) 238 239 #define IS_DISPLAY_STEP(__display, since, until) \ 240 (drm_WARN_ON((__display)->drm, INTEL_DISPLAY_STEP(__display) == STEP_NONE), \ 241 INTEL_DISPLAY_STEP(__display) >= (since) && INTEL_DISPLAY_STEP(__display) < (until)) 242 243 #define ARLS_HOST_BRIDGE_PCI_ID1 0x7D1C 244 #define ARLS_HOST_BRIDGE_PCI_ID2 0x7D2D 245 #define ARLS_HOST_BRIDGE_PCI_ID3 0x7D2E 246 #define ARLS_HOST_BRIDGE_PCI_ID4 0x7D2F 247 248 #define IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(id) \ 249 (((id) == ARLS_HOST_BRIDGE_PCI_ID1) || \ 250 ((id) == ARLS_HOST_BRIDGE_PCI_ID2) || \ 251 ((id) == ARLS_HOST_BRIDGE_PCI_ID3) || \ 252 ((id) == ARLS_HOST_BRIDGE_PCI_ID4)) 253 254 struct intel_display_runtime_info { 255 struct intel_display_ip_ver { 256 u16 ver; 257 u16 rel; 258 u16 step; /* hardware */ 259 } ip; 260 int step; /* symbolic */ 261 262 u32 rawclk_freq; 263 264 u8 pipe_mask; 265 u8 cpu_transcoder_mask; 266 u16 port_mask; 267 268 u8 num_sprites[I915_MAX_PIPES]; 269 u8 num_scalers[I915_MAX_PIPES]; 270 271 u8 fbc_mask; 272 273 bool has_hdcp; 274 bool has_dmc; 275 bool has_dsc; 276 bool edp_typec_support; 277 bool has_dbuf_overlap_detection; 278 }; 279 280 struct intel_display_device_info { 281 /* Initial runtime info. */ 282 const struct intel_display_runtime_info __runtime_defaults; 283 284 u8 abox_mask; 285 286 struct { 287 u16 size; /* in blocks */ 288 u8 slice_mask; 289 } dbuf; 290 291 #define DEFINE_FLAG(name) u8 name:1 292 DEV_INFO_DISPLAY_FOR_EACH_FLAG(DEFINE_FLAG); 293 #undef DEFINE_FLAG 294 295 /* Global register offset for the display engine */ 296 u32 mmio_offset; 297 298 /* Register offsets for the various display pipes and transcoders */ 299 u32 pipe_offsets[I915_MAX_TRANSCODERS]; 300 u32 trans_offsets[I915_MAX_TRANSCODERS]; 301 u32 cursor_offsets[I915_MAX_PIPES]; 302 303 struct { 304 u32 degamma_lut_size; 305 u32 gamma_lut_size; 306 u32 degamma_lut_tests; 307 u32 gamma_lut_tests; 308 } color; 309 }; 310 311 bool intel_display_device_present(struct intel_display *display); 312 bool intel_display_device_enabled(struct intel_display *display); 313 struct intel_display *intel_display_device_probe(struct pci_dev *pdev); 314 void intel_display_device_remove(struct intel_display *display); 315 void intel_display_device_info_runtime_init(struct intel_display *display); 316 317 void intel_display_device_info_print(const struct intel_display_device_info *info, 318 const struct intel_display_runtime_info *runtime, 319 struct drm_printer *p); 320 321 #endif 322