Skip to content

Commit aa451ae

Browse files
committed
drm/i915/vblank: convert to struct intel_display
Going forward, struct intel_display shall replace struct drm_i915_private as the main display device data pointer type. Convert intel_vblank.[ch] to struct intel_display. Some stragglers are left behind where needed. Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/40430651a45ddd9e350a1fd7938fe4054492f6ea.1724342644.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent 58cfea6 commit aa451ae

File tree

1 file changed

+50
-47
lines changed

1 file changed

+50
-47
lines changed

drivers/gpu/drm/i915/display/intel_vblank.c

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
*/
6868
u32 i915_get_vblank_counter(struct drm_crtc *crtc)
6969
{
70-
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
70+
struct intel_display *display = to_intel_display(crtc->dev);
7171
struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
7272
const struct drm_display_mode *mode = &vblank->hwmode;
7373
enum pipe pipe = to_intel_crtc(crtc)->pipe;
@@ -103,8 +103,8 @@ u32 i915_get_vblank_counter(struct drm_crtc *crtc)
103103
* we get a low value that's stable across two reads of the high
104104
* register.
105105
*/
106-
frame = intel_de_read64_2x32(dev_priv, PIPEFRAMEPIXEL(dev_priv, pipe),
107-
PIPEFRAME(dev_priv, pipe));
106+
frame = intel_de_read64_2x32(display, PIPEFRAMEPIXEL(display, pipe),
107+
PIPEFRAME(display, pipe));
108108

109109
pixel = frame & PIPE_PIXEL_MASK;
110110
frame = (frame >> PIPE_FRAME_LOW_SHIFT) & 0xffffff;
@@ -119,19 +119,19 @@ u32 i915_get_vblank_counter(struct drm_crtc *crtc)
119119

120120
u32 g4x_get_vblank_counter(struct drm_crtc *crtc)
121121
{
122-
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
122+
struct intel_display *display = to_intel_display(crtc->dev);
123123
struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
124124
enum pipe pipe = to_intel_crtc(crtc)->pipe;
125125

126126
if (!vblank->max_vblank_count)
127127
return 0;
128128

129-
return intel_de_read(dev_priv, PIPE_FRMCOUNT_G4X(dev_priv, pipe));
129+
return intel_de_read(display, PIPE_FRMCOUNT_G4X(display, pipe));
130130
}
131131

132132
static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
133133
{
134-
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
134+
struct intel_display *display = to_intel_display(crtc);
135135
struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
136136
const struct drm_display_mode *mode = &vblank->hwmode;
137137
u32 htotal = mode->crtc_htotal;
@@ -150,16 +150,16 @@ static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
150150
* pipe frame time stamp. The time stamp value
151151
* is sampled at every start of vertical blank.
152152
*/
153-
scan_prev_time = intel_de_read_fw(dev_priv,
153+
scan_prev_time = intel_de_read_fw(display,
154154
PIPE_FRMTMSTMP(crtc->pipe));
155155

156156
/*
157157
* The TIMESTAMP_CTR register has the current
158158
* time stamp value.
159159
*/
160-
scan_curr_time = intel_de_read_fw(dev_priv, IVB_TIMESTAMP_CTR);
160+
scan_curr_time = intel_de_read_fw(display, IVB_TIMESTAMP_CTR);
161161

162-
scan_post_time = intel_de_read_fw(dev_priv,
162+
scan_post_time = intel_de_read_fw(display,
163163
PIPE_FRMTMSTMP(crtc->pipe));
164164
} while (scan_post_time != scan_prev_time);
165165

@@ -192,6 +192,7 @@ static u32 __intel_get_crtc_scanline_from_timestamp(struct intel_crtc *crtc)
192192

193193
static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
194194
{
195+
struct intel_display *display = to_intel_display(crtc_state);
195196
struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
196197

197198
/*
@@ -220,7 +221,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
220221
* However if queried just before the start of vblank we'll get an
221222
* answer that's slightly in the future.
222223
*/
223-
if (DISPLAY_VER(i915) == 2)
224+
if (DISPLAY_VER(display) == 2)
224225
return -1;
225226
else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
226227
return 2;
@@ -234,8 +235,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
234235
*/
235236
static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
236237
{
237-
struct drm_device *dev = crtc->base.dev;
238-
struct drm_i915_private *dev_priv = to_i915(dev);
238+
struct intel_display *display = to_intel_display(crtc);
239239
struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
240240
const struct drm_display_mode *mode = &vblank->hwmode;
241241
enum pipe pipe = crtc->pipe;
@@ -249,7 +249,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
249249

250250
vtotal = intel_mode_vtotal(mode);
251251

252-
position = intel_de_read_fw(dev_priv, PIPEDSL(dev_priv, pipe)) & PIPEDSL_LINE_MASK;
252+
position = intel_de_read_fw(display, PIPEDSL(display, pipe)) & PIPEDSL_LINE_MASK;
253253

254254
/*
255255
* On HSW, the DSL reg (0x70000) appears to return 0 if we
@@ -263,13 +263,13 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
263263
* problem. We may need to extend this to include other platforms,
264264
* but so far testing only shows the problem on HSW.
265265
*/
266-
if (HAS_DDI(dev_priv) && !position) {
266+
if (HAS_DDI(display) && !position) {
267267
int i, temp;
268268

269269
for (i = 0; i < 100; i++) {
270270
udelay(1);
271-
temp = intel_de_read_fw(dev_priv,
272-
PIPEDSL(dev_priv, pipe)) & PIPEDSL_LINE_MASK;
271+
temp = intel_de_read_fw(display,
272+
PIPEDSL(display, pipe)) & PIPEDSL_LINE_MASK;
273273
if (temp != position) {
274274
position = temp;
275275
break;
@@ -304,23 +304,25 @@ int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
304304
* otherwise they may hang.
305305
*/
306306
#ifdef I915
307-
static void intel_vblank_section_enter(struct drm_i915_private *i915)
307+
static void intel_vblank_section_enter(struct intel_display *display)
308308
__acquires(i915->uncore.lock)
309309
{
310+
struct drm_i915_private *i915 = to_i915(display->drm);
310311
spin_lock(&i915->uncore.lock);
311312
}
312313

313-
static void intel_vblank_section_exit(struct drm_i915_private *i915)
314+
static void intel_vblank_section_exit(struct intel_display *display)
314315
__releases(i915->uncore.lock)
315316
{
317+
struct drm_i915_private *i915 = to_i915(display->drm);
316318
spin_unlock(&i915->uncore.lock);
317319
}
318320
#else
319-
static void intel_vblank_section_enter(struct drm_i915_private *i915)
321+
static void intel_vblank_section_enter(struct intel_display *display)
320322
{
321323
}
322324

323-
static void intel_vblank_section_exit(struct drm_i915_private *i915)
325+
static void intel_vblank_section_exit(struct intel_display *display)
324326
{
325327
}
326328
#endif
@@ -331,19 +333,19 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
331333
ktime_t *stime, ktime_t *etime,
332334
const struct drm_display_mode *mode)
333335
{
334-
struct drm_device *dev = _crtc->dev;
335-
struct drm_i915_private *dev_priv = to_i915(dev);
336+
struct intel_display *display = to_intel_display(_crtc->dev);
337+
struct drm_i915_private *dev_priv = to_i915(display->drm);
336338
struct intel_crtc *crtc = to_intel_crtc(_crtc);
337339
enum pipe pipe = crtc->pipe;
338340
int position;
339341
int vbl_start, vbl_end, hsync_start, htotal, vtotal;
340342
unsigned long irqflags;
341-
bool use_scanline_counter = DISPLAY_VER(dev_priv) >= 5 ||
342-
IS_G4X(dev_priv) || DISPLAY_VER(dev_priv) == 2 ||
343+
bool use_scanline_counter = DISPLAY_VER(display) >= 5 ||
344+
IS_G4X(dev_priv) || DISPLAY_VER(display) == 2 ||
343345
crtc->mode_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER;
344346

345-
if (drm_WARN_ON(&dev_priv->drm, !mode->crtc_clock)) {
346-
drm_dbg(&dev_priv->drm,
347+
if (drm_WARN_ON(display->drm, !mode->crtc_clock)) {
348+
drm_dbg(display->drm,
347349
"trying to get scanoutpos for disabled pipe %c\n",
348350
pipe_name(pipe));
349351
return false;
@@ -361,7 +363,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
361363
* preemption disabled, so the following code must not block.
362364
*/
363365
local_irq_save(irqflags);
364-
intel_vblank_section_enter(dev_priv);
366+
intel_vblank_section_enter(display);
365367

366368
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
367369

@@ -393,7 +395,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
393395
* We can split this into vertical and horizontal
394396
* scanout position.
395397
*/
396-
position = (intel_de_read_fw(dev_priv, PIPEFRAMEPIXEL(dev_priv, pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT;
398+
position = (intel_de_read_fw(display, PIPEFRAMEPIXEL(display, pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT;
397399

398400
/* convert to pixel counts */
399401
vbl_start *= htotal;
@@ -429,7 +431,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
429431

430432
/* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
431433

432-
intel_vblank_section_exit(dev_priv);
434+
intel_vblank_section_exit(display);
433435
local_irq_restore(irqflags);
434436

435437
/*
@@ -464,42 +466,42 @@ bool intel_crtc_get_vblank_timestamp(struct drm_crtc *crtc, int *max_error,
464466

465467
int intel_get_crtc_scanline(struct intel_crtc *crtc)
466468
{
467-
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
469+
struct intel_display *display = to_intel_display(crtc);
468470
unsigned long irqflags;
469471
int position;
470472

471473
local_irq_save(irqflags);
472-
intel_vblank_section_enter(dev_priv);
474+
intel_vblank_section_enter(display);
473475

474476
position = __intel_get_crtc_scanline(crtc);
475477

476-
intel_vblank_section_exit(dev_priv);
478+
intel_vblank_section_exit(display);
477479
local_irq_restore(irqflags);
478480

479481
return position;
480482
}
481483

482-
static bool pipe_scanline_is_moving(struct drm_i915_private *dev_priv,
484+
static bool pipe_scanline_is_moving(struct intel_display *display,
483485
enum pipe pipe)
484486
{
485-
i915_reg_t reg = PIPEDSL(dev_priv, pipe);
487+
i915_reg_t reg = PIPEDSL(display, pipe);
486488
u32 line1, line2;
487489

488-
line1 = intel_de_read(dev_priv, reg) & PIPEDSL_LINE_MASK;
490+
line1 = intel_de_read(display, reg) & PIPEDSL_LINE_MASK;
489491
msleep(5);
490-
line2 = intel_de_read(dev_priv, reg) & PIPEDSL_LINE_MASK;
492+
line2 = intel_de_read(display, reg) & PIPEDSL_LINE_MASK;
491493

492494
return line1 != line2;
493495
}
494496

495497
static void wait_for_pipe_scanline_moving(struct intel_crtc *crtc, bool state)
496498
{
497-
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
499+
struct intel_display *display = to_intel_display(crtc);
498500
enum pipe pipe = crtc->pipe;
499501

500502
/* Wait for the display line to settle/start moving */
501-
if (wait_for(pipe_scanline_is_moving(dev_priv, pipe) == state, 100))
502-
drm_err(&dev_priv->drm,
503+
if (wait_for(pipe_scanline_is_moving(display, pipe) == state, 100))
504+
drm_err(display->drm,
503505
"pipe %c scanline %s wait timed out\n",
504506
pipe_name(pipe), str_on_off(state));
505507
}
@@ -517,8 +519,8 @@ void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc)
517519
void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
518520
bool vrr_enable)
519521
{
522+
struct intel_display *display = to_intel_display(crtc_state);
520523
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
521-
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
522524
u8 mode_flags = crtc_state->mode_flags;
523525
struct drm_display_mode adjusted_mode;
524526
int vmax_vblank_start = 0;
@@ -527,7 +529,8 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
527529
drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode);
528530

529531
if (vrr_enable) {
530-
drm_WARN_ON(&i915->drm, (mode_flags & I915_MODE_FLAG_VRR) == 0);
532+
drm_WARN_ON(display->drm,
533+
(mode_flags & I915_MODE_FLAG_VRR) == 0);
531534

532535
adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax;
533536
adjusted_mode.crtc_vblank_end = crtc_state->vrr.vmax;
@@ -549,8 +552,8 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
549552
* __intel_get_crtc_scanline()) with vblank_time_lock?
550553
* Need to audit everything to make sure it's safe.
551554
*/
552-
spin_lock_irqsave(&i915->drm.vblank_time_lock, irqflags);
553-
intel_vblank_section_enter(i915);
555+
spin_lock_irqsave(&display->drm->vblank_time_lock, irqflags);
556+
intel_vblank_section_enter(display);
554557

555558
drm_calc_timestamping_constants(&crtc->base, &adjusted_mode);
556559

@@ -559,8 +562,8 @@ void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
559562
crtc->mode_flags = mode_flags;
560563

561564
crtc->scanline_offset = intel_crtc_scanline_offset(crtc_state);
562-
intel_vblank_section_exit(i915);
563-
spin_unlock_irqrestore(&i915->drm.vblank_time_lock, irqflags);
565+
intel_vblank_section_exit(display);
566+
spin_unlock_irqrestore(&display->drm->vblank_time_lock, irqflags);
564567
}
565568

566569
int intel_mode_vdisplay(const struct drm_display_mode *mode)
@@ -666,7 +669,7 @@ void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
666669
int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
667670
{
668671
struct intel_crtc *crtc = evade->crtc;
669-
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
672+
struct intel_display *display = to_intel_display(crtc);
670673
long timeout = msecs_to_jiffies_timeout(1);
671674
wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base);
672675
DEFINE_WAIT(wait);
@@ -688,7 +691,7 @@ int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
688691
break;
689692

690693
if (!timeout) {
691-
drm_err(&i915->drm,
694+
drm_err(display->drm,
692695
"Potential atomic update failure on pipe %c\n",
693696
pipe_name(crtc->pipe));
694697
break;

0 commit comments

Comments
 (0)