2 * Copyright © 2006-2010 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
31 #include <linux/kernel.h>
32 #include <linux/pwm.h>
34 #include <drm/drm_edid.h>
37 #include "intel_backlight.h"
38 #include "intel_connector.h"
40 #include "intel_display_types.h"
41 #include "intel_drrs.h"
42 #include "intel_lvds_regs.h"
43 #include "intel_panel.h"
44 #include "intel_quirks.h"
45 #include "intel_vrr.h"
47 bool intel_panel_use_ssc(struct drm_i915_private *i915)
49 if (i915->params.panel_use_ssc >= 0)
50 return i915->params.panel_use_ssc != 0;
51 return i915->display.vbt.lvds_use_ssc &&
52 !intel_has_quirk(i915, QUIRK_LVDS_SSC_DISABLE);
55 const struct drm_display_mode *
56 intel_panel_preferred_fixed_mode(struct intel_connector *connector)
58 return list_first_entry_or_null(&connector->panel.fixed_modes,
59 struct drm_display_mode, head);
62 static bool is_in_vrr_range(struct intel_connector *connector, int vrefresh)
64 const struct drm_display_info *info = &connector->base.display_info;
66 return intel_vrr_is_capable(connector) &&
67 vrefresh >= info->monitor_range.min_vfreq &&
68 vrefresh <= info->monitor_range.max_vfreq;
71 static bool is_best_fixed_mode(struct intel_connector *connector,
72 int vrefresh, int fixed_mode_vrefresh,
73 const struct drm_display_mode *best_mode)
75 /* we want to always return something */
80 * With VRR always pick a mode with equal/higher than requested
81 * vrefresh, which we can then reduce to match the requested
82 * vrefresh by extending the vblank length.
84 if (is_in_vrr_range(connector, vrefresh) &&
85 is_in_vrr_range(connector, fixed_mode_vrefresh) &&
86 fixed_mode_vrefresh < vrefresh)
89 /* pick the fixed_mode that is closest in terms of vrefresh */
90 return abs(fixed_mode_vrefresh - vrefresh) <
91 abs(drm_mode_vrefresh(best_mode) - vrefresh);
94 const struct drm_display_mode *
95 intel_panel_fixed_mode(struct intel_connector *connector,
96 const struct drm_display_mode *mode)
98 const struct drm_display_mode *fixed_mode, *best_mode = NULL;
99 int vrefresh = drm_mode_vrefresh(mode);
101 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) {
102 int fixed_mode_vrefresh = drm_mode_vrefresh(fixed_mode);
104 if (is_best_fixed_mode(connector, vrefresh,
105 fixed_mode_vrefresh, best_mode))
106 best_mode = fixed_mode;
112 static bool is_alt_drrs_mode(const struct drm_display_mode *mode,
113 const struct drm_display_mode *preferred_mode)
115 return drm_mode_match(mode, preferred_mode,
116 DRM_MODE_MATCH_TIMINGS |
117 DRM_MODE_MATCH_FLAGS |
118 DRM_MODE_MATCH_3D_FLAGS) &&
119 mode->clock != preferred_mode->clock;
122 static bool is_alt_fixed_mode(const struct drm_display_mode *mode,
123 const struct drm_display_mode *preferred_mode)
125 u32 sync_flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC |
126 DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC;
128 return (mode->flags & ~sync_flags) == (preferred_mode->flags & ~sync_flags) &&
129 mode->hdisplay == preferred_mode->hdisplay &&
130 mode->vdisplay == preferred_mode->vdisplay;
133 const struct drm_display_mode *
134 intel_panel_downclock_mode(struct intel_connector *connector,
135 const struct drm_display_mode *adjusted_mode)
137 const struct drm_display_mode *fixed_mode, *best_mode = NULL;
138 int min_vrefresh = connector->panel.vbt.seamless_drrs_min_refresh_rate;
139 int max_vrefresh = drm_mode_vrefresh(adjusted_mode);
141 /* pick the fixed_mode with the lowest refresh rate */
142 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) {
143 int vrefresh = drm_mode_vrefresh(fixed_mode);
145 if (is_alt_drrs_mode(fixed_mode, adjusted_mode) &&
146 vrefresh >= min_vrefresh && vrefresh < max_vrefresh) {
147 max_vrefresh = vrefresh;
148 best_mode = fixed_mode;
155 const struct drm_display_mode *
156 intel_panel_highest_mode(struct intel_connector *connector,
157 const struct drm_display_mode *adjusted_mode)
159 const struct drm_display_mode *fixed_mode, *best_mode = adjusted_mode;
161 /* pick the fixed_mode that has the highest clock */
162 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) {
163 if (fixed_mode->clock > best_mode->clock)
164 best_mode = fixed_mode;
170 int intel_panel_get_modes(struct intel_connector *connector)
172 const struct drm_display_mode *fixed_mode;
175 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) {
176 struct drm_display_mode *mode;
178 mode = drm_mode_duplicate(connector->base.dev, fixed_mode);
180 drm_mode_probed_add(&connector->base, mode);
188 static bool has_drrs_modes(struct intel_connector *connector)
190 const struct drm_display_mode *mode1;
192 list_for_each_entry(mode1, &connector->panel.fixed_modes, head) {
193 const struct drm_display_mode *mode2 = mode1;
195 list_for_each_entry_continue(mode2, &connector->panel.fixed_modes, head) {
196 if (is_alt_drrs_mode(mode1, mode2))
204 enum drrs_type intel_panel_drrs_type(struct intel_connector *connector)
206 return connector->panel.vbt.drrs_type;
209 int intel_panel_compute_config(struct intel_connector *connector,
210 struct drm_display_mode *adjusted_mode)
212 const struct drm_display_mode *fixed_mode =
213 intel_panel_fixed_mode(connector, adjusted_mode);
214 int vrefresh, fixed_mode_vrefresh;
220 vrefresh = drm_mode_vrefresh(adjusted_mode);
221 fixed_mode_vrefresh = drm_mode_vrefresh(fixed_mode);
224 * Assume that we shouldn't muck about with the
225 * timings if they don't land in the VRR range.
227 is_vrr = is_in_vrr_range(connector, vrefresh) &&
228 is_in_vrr_range(connector, fixed_mode_vrefresh);
232 * We don't want to lie too much to the user about the refresh
233 * rate they're going to get. But we have to allow a bit of latitude
234 * for Xorg since it likes to automagically cook up modes with slightly
237 if (abs(vrefresh - fixed_mode_vrefresh) > 1) {
238 drm_dbg_kms(connector->base.dev,
239 "[CONNECTOR:%d:%s] Requested mode vrefresh (%d Hz) does not match fixed mode vrefresh (%d Hz)\n",
240 connector->base.base.id, connector->base.name,
241 vrefresh, fixed_mode_vrefresh);
247 drm_mode_copy(adjusted_mode, fixed_mode);
249 if (is_vrr && fixed_mode_vrefresh != vrefresh)
250 adjusted_mode->vtotal =
251 DIV_ROUND_CLOSEST(adjusted_mode->clock * 1000,
252 adjusted_mode->htotal * vrefresh);
254 drm_mode_set_crtcinfo(adjusted_mode, 0);
259 static void intel_panel_add_edid_alt_fixed_modes(struct intel_connector *connector)
261 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
262 const struct drm_display_mode *preferred_mode =
263 intel_panel_preferred_fixed_mode(connector);
264 struct drm_display_mode *mode, *next;
266 list_for_each_entry_safe(mode, next, &connector->base.probed_modes, head) {
267 if (!is_alt_fixed_mode(mode, preferred_mode))
270 drm_dbg_kms(&dev_priv->drm,
271 "[CONNECTOR:%d:%s] using alternate EDID fixed mode: " DRM_MODE_FMT "\n",
272 connector->base.base.id, connector->base.name,
275 list_move_tail(&mode->head, &connector->panel.fixed_modes);
279 static void intel_panel_add_edid_preferred_mode(struct intel_connector *connector)
281 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
282 struct drm_display_mode *scan, *fixed_mode = NULL;
284 if (list_empty(&connector->base.probed_modes))
287 /* make sure the preferred mode is first */
288 list_for_each_entry(scan, &connector->base.probed_modes, head) {
289 if (scan->type & DRM_MODE_TYPE_PREFERRED) {
296 fixed_mode = list_first_entry(&connector->base.probed_modes,
297 typeof(*fixed_mode), head);
299 drm_dbg_kms(&dev_priv->drm,
300 "[CONNECTOR:%d:%s] using %s EDID fixed mode: " DRM_MODE_FMT "\n",
301 connector->base.base.id, connector->base.name,
302 fixed_mode->type & DRM_MODE_TYPE_PREFERRED ? "preferred" : "first",
303 DRM_MODE_ARG(fixed_mode));
305 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
307 list_move_tail(&fixed_mode->head, &connector->panel.fixed_modes);
310 static void intel_panel_destroy_probed_modes(struct intel_connector *connector)
312 struct drm_i915_private *i915 = to_i915(connector->base.dev);
313 struct drm_display_mode *mode, *next;
315 list_for_each_entry_safe(mode, next, &connector->base.probed_modes, head) {
316 drm_dbg_kms(&i915->drm,
317 "[CONNECTOR:%d:%s] not using EDID mode: " DRM_MODE_FMT "\n",
318 connector->base.base.id, connector->base.name,
320 list_del(&mode->head);
321 drm_mode_destroy(&i915->drm, mode);
325 void intel_panel_add_edid_fixed_modes(struct intel_connector *connector,
326 bool use_alt_fixed_modes)
328 intel_panel_add_edid_preferred_mode(connector);
329 if (intel_panel_preferred_fixed_mode(connector) && use_alt_fixed_modes)
330 intel_panel_add_edid_alt_fixed_modes(connector);
331 intel_panel_destroy_probed_modes(connector);
334 static void intel_panel_add_fixed_mode(struct intel_connector *connector,
335 struct drm_display_mode *fixed_mode,
338 struct drm_i915_private *i915 = to_i915(connector->base.dev);
339 struct drm_display_info *info = &connector->base.display_info;
344 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
346 info->width_mm = fixed_mode->width_mm;
347 info->height_mm = fixed_mode->height_mm;
349 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] using %s fixed mode: " DRM_MODE_FMT "\n",
350 connector->base.base.id, connector->base.name, type,
351 DRM_MODE_ARG(fixed_mode));
353 list_add_tail(&fixed_mode->head, &connector->panel.fixed_modes);
356 void intel_panel_add_vbt_lfp_fixed_mode(struct intel_connector *connector)
358 struct drm_i915_private *i915 = to_i915(connector->base.dev);
359 const struct drm_display_mode *mode;
361 mode = connector->panel.vbt.lfp_lvds_vbt_mode;
365 intel_panel_add_fixed_mode(connector,
366 drm_mode_duplicate(&i915->drm, mode),
370 void intel_panel_add_vbt_sdvo_fixed_mode(struct intel_connector *connector)
372 struct drm_i915_private *i915 = to_i915(connector->base.dev);
373 const struct drm_display_mode *mode;
375 mode = connector->panel.vbt.sdvo_lvds_vbt_mode;
379 intel_panel_add_fixed_mode(connector,
380 drm_mode_duplicate(&i915->drm, mode),
384 void intel_panel_add_encoder_fixed_mode(struct intel_connector *connector,
385 struct intel_encoder *encoder)
387 intel_panel_add_fixed_mode(connector,
388 intel_encoder_current_mode(encoder),
392 /* adjusted_mode has been preset to be the panel's fixed mode */
393 static int pch_panel_fitting(struct intel_crtc_state *crtc_state,
394 const struct drm_connector_state *conn_state)
396 const struct drm_display_mode *adjusted_mode =
397 &crtc_state->hw.adjusted_mode;
398 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
399 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
400 int x, y, width, height;
402 /* Native modes don't need fitting */
403 if (adjusted_mode->crtc_hdisplay == pipe_src_w &&
404 adjusted_mode->crtc_vdisplay == pipe_src_h &&
405 crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420)
408 switch (conn_state->scaling_mode) {
409 case DRM_MODE_SCALE_CENTER:
412 x = (adjusted_mode->crtc_hdisplay - width + 1)/2;
413 y = (adjusted_mode->crtc_vdisplay - height + 1)/2;
416 case DRM_MODE_SCALE_ASPECT:
417 /* Scale but preserve the aspect ratio */
419 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
420 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
421 if (scaled_width > scaled_height) { /* pillar */
422 width = scaled_height / pipe_src_h;
425 x = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
427 height = adjusted_mode->crtc_vdisplay;
428 } else if (scaled_width < scaled_height) { /* letter */
429 height = scaled_width / pipe_src_w;
432 y = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
434 width = adjusted_mode->crtc_hdisplay;
437 width = adjusted_mode->crtc_hdisplay;
438 height = adjusted_mode->crtc_vdisplay;
443 case DRM_MODE_SCALE_NONE:
444 WARN_ON(adjusted_mode->crtc_hdisplay != pipe_src_w);
445 WARN_ON(adjusted_mode->crtc_vdisplay != pipe_src_h);
447 case DRM_MODE_SCALE_FULLSCREEN:
449 width = adjusted_mode->crtc_hdisplay;
450 height = adjusted_mode->crtc_vdisplay;
454 MISSING_CASE(conn_state->scaling_mode);
458 drm_rect_init(&crtc_state->pch_pfit.dst,
459 x, y, width, height);
460 crtc_state->pch_pfit.enabled = true;
466 centre_horizontally(struct drm_display_mode *adjusted_mode,
469 u32 border, sync_pos, blank_width, sync_width;
471 /* keep the hsync and hblank widths constant */
472 sync_width = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start;
473 blank_width = adjusted_mode->crtc_hblank_end - adjusted_mode->crtc_hblank_start;
474 sync_pos = (blank_width - sync_width + 1) / 2;
476 border = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
477 border += border & 1; /* make the border even */
479 adjusted_mode->crtc_hdisplay = width;
480 adjusted_mode->crtc_hblank_start = width + border;
481 adjusted_mode->crtc_hblank_end = adjusted_mode->crtc_hblank_start + blank_width;
483 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hblank_start + sync_pos;
484 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + sync_width;
488 centre_vertically(struct drm_display_mode *adjusted_mode,
491 u32 border, sync_pos, blank_width, sync_width;
493 /* keep the vsync and vblank widths constant */
494 sync_width = adjusted_mode->crtc_vsync_end - adjusted_mode->crtc_vsync_start;
495 blank_width = adjusted_mode->crtc_vblank_end - adjusted_mode->crtc_vblank_start;
496 sync_pos = (blank_width - sync_width + 1) / 2;
498 border = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
500 adjusted_mode->crtc_vdisplay = height;
501 adjusted_mode->crtc_vblank_start = height + border;
502 adjusted_mode->crtc_vblank_end = adjusted_mode->crtc_vblank_start + blank_width;
504 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vblank_start + sync_pos;
505 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + sync_width;
508 static u32 panel_fitter_scaling(u32 source, u32 target)
511 * Floating point operation is not supported. So the FACTOR
512 * is defined, which can avoid the floating point computation
513 * when calculating the panel ratio.
516 #define FACTOR (1 << ACCURACY)
517 u32 ratio = source * FACTOR / target;
518 return (FACTOR * ratio + FACTOR/2) / FACTOR;
521 static void i965_scale_aspect(struct intel_crtc_state *crtc_state,
524 const struct drm_display_mode *adjusted_mode =
525 &crtc_state->hw.adjusted_mode;
526 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
527 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
528 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
529 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
531 /* 965+ is easy, it does everything in hw */
532 if (scaled_width > scaled_height)
533 *pfit_control |= PFIT_ENABLE |
535 else if (scaled_width < scaled_height)
536 *pfit_control |= PFIT_ENABLE |
538 else if (adjusted_mode->crtc_hdisplay != pipe_src_w)
539 *pfit_control |= PFIT_ENABLE | PFIT_SCALING_AUTO;
542 static void i9xx_scale_aspect(struct intel_crtc_state *crtc_state,
543 u32 *pfit_control, u32 *pfit_pgm_ratios,
546 struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
547 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
548 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
549 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h;
550 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay;
554 * For earlier chips we have to calculate the scaling
555 * ratio by hand and program it into the
556 * PFIT_PGM_RATIO register
558 if (scaled_width > scaled_height) { /* pillar */
559 centre_horizontally(adjusted_mode,
560 scaled_height / pipe_src_h);
562 *border = LVDS_BORDER_ENABLE;
563 if (pipe_src_h != adjusted_mode->crtc_vdisplay) {
564 bits = panel_fitter_scaling(pipe_src_h,
565 adjusted_mode->crtc_vdisplay);
567 *pfit_pgm_ratios |= (PFIT_HORIZ_SCALE(bits) |
568 PFIT_VERT_SCALE(bits));
569 *pfit_control |= (PFIT_ENABLE |
570 PFIT_VERT_INTERP_BILINEAR |
571 PFIT_HORIZ_INTERP_BILINEAR);
573 } else if (scaled_width < scaled_height) { /* letter */
574 centre_vertically(adjusted_mode,
575 scaled_width / pipe_src_w);
577 *border = LVDS_BORDER_ENABLE;
578 if (pipe_src_w != adjusted_mode->crtc_hdisplay) {
579 bits = panel_fitter_scaling(pipe_src_w,
580 adjusted_mode->crtc_hdisplay);
582 *pfit_pgm_ratios |= (PFIT_HORIZ_SCALE(bits) |
583 PFIT_VERT_SCALE(bits));
584 *pfit_control |= (PFIT_ENABLE |
585 PFIT_VERT_INTERP_BILINEAR |
586 PFIT_HORIZ_INTERP_BILINEAR);
589 /* Aspects match, Let hw scale both directions */
590 *pfit_control |= (PFIT_ENABLE |
591 PFIT_VERT_AUTO_SCALE |
592 PFIT_HORIZ_AUTO_SCALE |
593 PFIT_VERT_INTERP_BILINEAR |
594 PFIT_HORIZ_INTERP_BILINEAR);
598 static int gmch_panel_fitting(struct intel_crtc_state *crtc_state,
599 const struct drm_connector_state *conn_state)
601 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
602 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
603 u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
604 struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
605 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src);
606 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src);
608 /* Native modes don't need fitting */
609 if (adjusted_mode->crtc_hdisplay == pipe_src_w &&
610 adjusted_mode->crtc_vdisplay == pipe_src_h)
613 switch (conn_state->scaling_mode) {
614 case DRM_MODE_SCALE_CENTER:
616 * For centered modes, we have to calculate border widths &
617 * heights and modify the values programmed into the CRTC.
619 centre_horizontally(adjusted_mode, pipe_src_w);
620 centre_vertically(adjusted_mode, pipe_src_h);
621 border = LVDS_BORDER_ENABLE;
623 case DRM_MODE_SCALE_ASPECT:
624 /* Scale but preserve the aspect ratio */
625 if (DISPLAY_VER(dev_priv) >= 4)
626 i965_scale_aspect(crtc_state, &pfit_control);
628 i9xx_scale_aspect(crtc_state, &pfit_control,
629 &pfit_pgm_ratios, &border);
631 case DRM_MODE_SCALE_FULLSCREEN:
633 * Full scaling, even if it changes the aspect ratio.
634 * Fortunately this is all done for us in hw.
636 if (pipe_src_h != adjusted_mode->crtc_vdisplay ||
637 pipe_src_w != adjusted_mode->crtc_hdisplay) {
638 pfit_control |= PFIT_ENABLE;
639 if (DISPLAY_VER(dev_priv) >= 4)
640 pfit_control |= PFIT_SCALING_AUTO;
642 pfit_control |= (PFIT_VERT_AUTO_SCALE |
643 PFIT_VERT_INTERP_BILINEAR |
644 PFIT_HORIZ_AUTO_SCALE |
645 PFIT_HORIZ_INTERP_BILINEAR);
649 MISSING_CASE(conn_state->scaling_mode);
653 /* 965+ wants fuzzy fitting */
654 /* FIXME: handle multiple panels by failing gracefully */
655 if (DISPLAY_VER(dev_priv) >= 4)
656 pfit_control |= PFIT_PIPE(crtc->pipe) | PFIT_FILTER_FUZZY;
659 if ((pfit_control & PFIT_ENABLE) == 0) {
664 /* Make sure pre-965 set dither correctly for 18bpp panels. */
665 if (DISPLAY_VER(dev_priv) < 4 && crtc_state->pipe_bpp == 18)
666 pfit_control |= PFIT_PANEL_8TO6_DITHER_ENABLE;
668 crtc_state->gmch_pfit.control = pfit_control;
669 crtc_state->gmch_pfit.pgm_ratios = pfit_pgm_ratios;
670 crtc_state->gmch_pfit.lvds_border_bits = border;
675 int intel_panel_fitting(struct intel_crtc_state *crtc_state,
676 const struct drm_connector_state *conn_state)
678 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
679 struct drm_i915_private *i915 = to_i915(crtc->base.dev);
682 return gmch_panel_fitting(crtc_state, conn_state);
684 return pch_panel_fitting(crtc_state, conn_state);
687 enum drm_connector_status
688 intel_panel_detect(struct drm_connector *connector, bool force)
690 struct drm_i915_private *i915 = to_i915(connector->dev);
692 if (!INTEL_DISPLAY_ENABLED(i915))
693 return connector_status_disconnected;
695 return connector_status_connected;
699 intel_panel_mode_valid(struct intel_connector *connector,
700 const struct drm_display_mode *mode)
702 const struct drm_display_mode *fixed_mode =
703 intel_panel_fixed_mode(connector, mode);
708 if (mode->hdisplay != fixed_mode->hdisplay)
711 if (mode->vdisplay != fixed_mode->vdisplay)
714 if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(fixed_mode))
720 void intel_panel_init_alloc(struct intel_connector *connector)
722 struct intel_panel *panel = &connector->panel;
724 connector->panel.vbt.panel_type = -1;
725 connector->panel.vbt.backlight.controller = -1;
726 INIT_LIST_HEAD(&panel->fixed_modes);
729 int intel_panel_init(struct intel_connector *connector,
730 const struct drm_edid *fixed_edid)
732 struct intel_panel *panel = &connector->panel;
734 panel->fixed_edid = fixed_edid;
736 intel_backlight_init_funcs(panel);
738 if (!has_drrs_modes(connector))
739 connector->panel.vbt.drrs_type = DRRS_TYPE_NONE;
741 drm_dbg_kms(connector->base.dev,
742 "[CONNECTOR:%d:%s] DRRS type: %s\n",
743 connector->base.base.id, connector->base.name,
744 intel_drrs_type_str(intel_panel_drrs_type(connector)));
749 void intel_panel_fini(struct intel_connector *connector)
751 struct intel_panel *panel = &connector->panel;
752 struct drm_display_mode *fixed_mode, *next;
754 if (!IS_ERR_OR_NULL(panel->fixed_edid))
755 drm_edid_free(panel->fixed_edid);
757 intel_backlight_destroy(panel);
759 intel_bios_fini_panel(panel);
761 list_for_each_entry_safe(fixed_mode, next, &panel->fixed_modes, head) {
762 list_del(&fixed_mode->head);
763 drm_mode_destroy(connector->base.dev, fixed_mode);