1 /* 2 * Copyright © 2006-2010 Intel Corporation 3 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> 4 * 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: 11 * 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 14 * Software. 15 * 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. 23 * 24 * Authors: 25 * Eric Anholt <eric@anholt.net> 26 * Dave Airlie <airlied@linux.ie> 27 * Jesse Barnes <jesse.barnes@intel.com> 28 * Chris Wilson <chris@chris-wilson.co.uk> 29 */ 30 31 #include <linux/kernel.h> 32 #include <linux/pwm.h> 33 34 #include "intel_backlight.h" 35 #include "intel_connector.h" 36 #include "intel_de.h" 37 #include "intel_display_types.h" 38 #include "intel_drrs.h" 39 #include "intel_panel.h" 40 41 bool intel_panel_use_ssc(struct drm_i915_private *i915) 42 { 43 if (i915->params.panel_use_ssc >= 0) 44 return i915->params.panel_use_ssc != 0; 45 return i915->vbt.lvds_use_ssc 46 && !(i915->quirks & QUIRK_LVDS_SSC_DISABLE); 47 } 48 49 const struct drm_display_mode * 50 intel_panel_preferred_fixed_mode(struct intel_connector *connector) 51 { 52 return list_first_entry_or_null(&connector->panel.fixed_modes, 53 struct drm_display_mode, head); 54 } 55 56 const struct drm_display_mode * 57 intel_panel_fixed_mode(struct intel_connector *connector, 58 const struct drm_display_mode *mode) 59 { 60 const struct drm_display_mode *fixed_mode, *best_mode = NULL; 61 int vrefresh = drm_mode_vrefresh(mode); 62 63 /* pick the fixed_mode that is closest in terms of vrefresh */ 64 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) { 65 if (!best_mode || 66 abs(drm_mode_vrefresh(fixed_mode) - vrefresh) < 67 abs(drm_mode_vrefresh(best_mode) - vrefresh)) 68 best_mode = fixed_mode; 69 } 70 71 return best_mode; 72 } 73 74 const struct drm_display_mode * 75 intel_panel_downclock_mode(struct intel_connector *connector, 76 const struct drm_display_mode *adjusted_mode) 77 { 78 const struct drm_display_mode *fixed_mode, *best_mode = NULL; 79 int vrefresh = drm_mode_vrefresh(adjusted_mode); 80 81 /* pick the fixed_mode with the lowest refresh rate */ 82 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) { 83 if (drm_mode_vrefresh(fixed_mode) < vrefresh) { 84 vrefresh = drm_mode_vrefresh(fixed_mode); 85 best_mode = fixed_mode; 86 } 87 } 88 89 return best_mode; 90 } 91 92 int intel_panel_get_modes(struct intel_connector *connector) 93 { 94 const struct drm_display_mode *fixed_mode; 95 int num_modes = 0; 96 97 list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head) { 98 struct drm_display_mode *mode; 99 100 mode = drm_mode_duplicate(connector->base.dev, fixed_mode); 101 if (mode) { 102 drm_mode_probed_add(&connector->base, mode); 103 num_modes++; 104 } 105 } 106 107 return num_modes; 108 } 109 110 enum drrs_type intel_panel_drrs_type(struct intel_connector *connector) 111 { 112 struct drm_i915_private *i915 = to_i915(connector->base.dev); 113 114 if (list_empty(&connector->panel.fixed_modes) || 115 list_is_singular(&connector->panel.fixed_modes)) 116 return DRRS_TYPE_NONE; 117 118 return i915->vbt.drrs_type; 119 } 120 121 int intel_panel_compute_config(struct intel_connector *connector, 122 struct drm_display_mode *adjusted_mode) 123 { 124 const struct drm_display_mode *fixed_mode = 125 intel_panel_fixed_mode(connector, adjusted_mode); 126 127 if (!fixed_mode) 128 return 0; 129 130 /* 131 * We don't want to lie too much to the user about the refresh 132 * rate they're going to get. But we have to allow a bit of latitude 133 * for Xorg since it likes to automagically cook up modes with slightly 134 * off refresh rates. 135 */ 136 if (abs(drm_mode_vrefresh(adjusted_mode) - drm_mode_vrefresh(fixed_mode)) > 1) { 137 drm_dbg_kms(connector->base.dev, 138 "[CONNECTOR:%d:%s] Requested mode vrefresh (%d Hz) does not match fixed mode vrefresh (%d Hz)\n", 139 connector->base.base.id, connector->base.name, 140 drm_mode_vrefresh(adjusted_mode), drm_mode_vrefresh(fixed_mode)); 141 142 return -EINVAL; 143 } 144 145 drm_mode_copy(adjusted_mode, fixed_mode); 146 147 drm_mode_set_crtcinfo(adjusted_mode, 0); 148 149 return 0; 150 } 151 152 static bool is_alt_fixed_mode(const struct drm_display_mode *mode, 153 const struct drm_display_mode *preferred_mode) 154 { 155 return drm_mode_match(mode, preferred_mode, 156 DRM_MODE_MATCH_TIMINGS | 157 DRM_MODE_MATCH_FLAGS | 158 DRM_MODE_MATCH_3D_FLAGS) && 159 mode->clock != preferred_mode->clock; 160 } 161 162 static void intel_panel_add_edid_alt_fixed_modes(struct intel_connector *connector) 163 { 164 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 165 const struct drm_display_mode *preferred_mode = 166 intel_panel_preferred_fixed_mode(connector); 167 struct drm_display_mode *mode, *next; 168 169 list_for_each_entry_safe(mode, next, &connector->base.probed_modes, head) { 170 if (!is_alt_fixed_mode(mode, preferred_mode)) 171 continue; 172 173 drm_dbg_kms(&dev_priv->drm, 174 "[CONNECTOR:%d:%s] using alternate EDID fixed mode: " DRM_MODE_FMT "\n", 175 connector->base.base.id, connector->base.name, 176 DRM_MODE_ARG(mode)); 177 178 list_move_tail(&mode->head, &connector->panel.fixed_modes); 179 } 180 } 181 182 static void intel_panel_add_edid_preferred_mode(struct intel_connector *connector) 183 { 184 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 185 struct drm_display_mode *scan, *fixed_mode = NULL; 186 187 if (list_empty(&connector->base.probed_modes)) 188 return; 189 190 /* make sure the preferred mode is first */ 191 list_for_each_entry(scan, &connector->base.probed_modes, head) { 192 if (scan->type & DRM_MODE_TYPE_PREFERRED) { 193 fixed_mode = scan; 194 break; 195 } 196 } 197 198 if (!fixed_mode) 199 fixed_mode = list_first_entry(&connector->base.probed_modes, 200 typeof(*fixed_mode), head); 201 202 drm_dbg_kms(&dev_priv->drm, 203 "[CONNECTOR:%d:%s] using %s EDID fixed mode: " DRM_MODE_FMT "\n", 204 connector->base.base.id, connector->base.name, 205 fixed_mode->type & DRM_MODE_TYPE_PREFERRED ? "preferred" : "first", 206 DRM_MODE_ARG(fixed_mode)); 207 208 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED; 209 210 list_move_tail(&fixed_mode->head, &connector->panel.fixed_modes); 211 } 212 213 static void intel_panel_destroy_probed_modes(struct intel_connector *connector) 214 { 215 struct drm_i915_private *i915 = to_i915(connector->base.dev); 216 struct drm_display_mode *mode, *next; 217 218 list_for_each_entry_safe(mode, next, &connector->base.probed_modes, head) { 219 list_del(&mode->head); 220 drm_mode_destroy(&i915->drm, mode); 221 } 222 } 223 224 void intel_panel_add_edid_fixed_modes(struct intel_connector *connector, bool has_drrs) 225 { 226 intel_panel_add_edid_preferred_mode(connector); 227 if (intel_panel_preferred_fixed_mode(connector) && has_drrs) 228 intel_panel_add_edid_alt_fixed_modes(connector); 229 intel_panel_destroy_probed_modes(connector); 230 } 231 232 static void intel_panel_add_fixed_mode(struct intel_connector *connector, 233 struct drm_display_mode *fixed_mode, 234 const char *type) 235 { 236 struct drm_i915_private *i915 = to_i915(connector->base.dev); 237 struct drm_display_info *info = &connector->base.display_info; 238 239 if (!fixed_mode) 240 return; 241 242 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 243 244 info->width_mm = fixed_mode->width_mm; 245 info->height_mm = fixed_mode->height_mm; 246 247 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] using %s fixed mode: " DRM_MODE_FMT "\n", 248 connector->base.base.id, connector->base.name, type, 249 DRM_MODE_ARG(fixed_mode)); 250 251 list_add_tail(&fixed_mode->head, &connector->panel.fixed_modes); 252 } 253 254 void intel_panel_add_vbt_lfp_fixed_mode(struct intel_connector *connector) 255 { 256 struct drm_i915_private *i915 = to_i915(connector->base.dev); 257 const struct drm_display_mode *mode; 258 259 mode = i915->vbt.lfp_lvds_vbt_mode; 260 if (!mode) 261 return; 262 263 intel_panel_add_fixed_mode(connector, 264 drm_mode_duplicate(&i915->drm, mode), 265 "VBT LFP"); 266 } 267 268 void intel_panel_add_vbt_sdvo_fixed_mode(struct intel_connector *connector) 269 { 270 struct drm_i915_private *i915 = to_i915(connector->base.dev); 271 const struct drm_display_mode *mode; 272 273 mode = i915->vbt.sdvo_lvds_vbt_mode; 274 if (!mode) 275 return; 276 277 intel_panel_add_fixed_mode(connector, 278 drm_mode_duplicate(&i915->drm, mode), 279 "VBT SDVO"); 280 } 281 282 void intel_panel_add_encoder_fixed_mode(struct intel_connector *connector, 283 struct intel_encoder *encoder) 284 { 285 intel_panel_add_fixed_mode(connector, 286 intel_encoder_current_mode(encoder), 287 "current (BIOS)"); 288 } 289 290 /* adjusted_mode has been preset to be the panel's fixed mode */ 291 static int pch_panel_fitting(struct intel_crtc_state *crtc_state, 292 const struct drm_connector_state *conn_state) 293 { 294 const struct drm_display_mode *adjusted_mode = 295 &crtc_state->hw.adjusted_mode; 296 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src); 297 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src); 298 int x, y, width, height; 299 300 /* Native modes don't need fitting */ 301 if (adjusted_mode->crtc_hdisplay == pipe_src_w && 302 adjusted_mode->crtc_vdisplay == pipe_src_h && 303 crtc_state->output_format != INTEL_OUTPUT_FORMAT_YCBCR420) 304 return 0; 305 306 switch (conn_state->scaling_mode) { 307 case DRM_MODE_SCALE_CENTER: 308 width = pipe_src_w; 309 height = pipe_src_h; 310 x = (adjusted_mode->crtc_hdisplay - width + 1)/2; 311 y = (adjusted_mode->crtc_vdisplay - height + 1)/2; 312 break; 313 314 case DRM_MODE_SCALE_ASPECT: 315 /* Scale but preserve the aspect ratio */ 316 { 317 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h; 318 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay; 319 if (scaled_width > scaled_height) { /* pillar */ 320 width = scaled_height / pipe_src_h; 321 if (width & 1) 322 width++; 323 x = (adjusted_mode->crtc_hdisplay - width + 1) / 2; 324 y = 0; 325 height = adjusted_mode->crtc_vdisplay; 326 } else if (scaled_width < scaled_height) { /* letter */ 327 height = scaled_width / pipe_src_w; 328 if (height & 1) 329 height++; 330 y = (adjusted_mode->crtc_vdisplay - height + 1) / 2; 331 x = 0; 332 width = adjusted_mode->crtc_hdisplay; 333 } else { 334 x = y = 0; 335 width = adjusted_mode->crtc_hdisplay; 336 height = adjusted_mode->crtc_vdisplay; 337 } 338 } 339 break; 340 341 case DRM_MODE_SCALE_NONE: 342 WARN_ON(adjusted_mode->crtc_hdisplay != pipe_src_w); 343 WARN_ON(adjusted_mode->crtc_vdisplay != pipe_src_h); 344 fallthrough; 345 case DRM_MODE_SCALE_FULLSCREEN: 346 x = y = 0; 347 width = adjusted_mode->crtc_hdisplay; 348 height = adjusted_mode->crtc_vdisplay; 349 break; 350 351 default: 352 MISSING_CASE(conn_state->scaling_mode); 353 return -EINVAL; 354 } 355 356 drm_rect_init(&crtc_state->pch_pfit.dst, 357 x, y, width, height); 358 crtc_state->pch_pfit.enabled = true; 359 360 return 0; 361 } 362 363 static void 364 centre_horizontally(struct drm_display_mode *adjusted_mode, 365 int width) 366 { 367 u32 border, sync_pos, blank_width, sync_width; 368 369 /* keep the hsync and hblank widths constant */ 370 sync_width = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start; 371 blank_width = adjusted_mode->crtc_hblank_end - adjusted_mode->crtc_hblank_start; 372 sync_pos = (blank_width - sync_width + 1) / 2; 373 374 border = (adjusted_mode->crtc_hdisplay - width + 1) / 2; 375 border += border & 1; /* make the border even */ 376 377 adjusted_mode->crtc_hdisplay = width; 378 adjusted_mode->crtc_hblank_start = width + border; 379 adjusted_mode->crtc_hblank_end = adjusted_mode->crtc_hblank_start + blank_width; 380 381 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hblank_start + sync_pos; 382 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + sync_width; 383 } 384 385 static void 386 centre_vertically(struct drm_display_mode *adjusted_mode, 387 int height) 388 { 389 u32 border, sync_pos, blank_width, sync_width; 390 391 /* keep the vsync and vblank widths constant */ 392 sync_width = adjusted_mode->crtc_vsync_end - adjusted_mode->crtc_vsync_start; 393 blank_width = adjusted_mode->crtc_vblank_end - adjusted_mode->crtc_vblank_start; 394 sync_pos = (blank_width - sync_width + 1) / 2; 395 396 border = (adjusted_mode->crtc_vdisplay - height + 1) / 2; 397 398 adjusted_mode->crtc_vdisplay = height; 399 adjusted_mode->crtc_vblank_start = height + border; 400 adjusted_mode->crtc_vblank_end = adjusted_mode->crtc_vblank_start + blank_width; 401 402 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vblank_start + sync_pos; 403 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + sync_width; 404 } 405 406 static u32 panel_fitter_scaling(u32 source, u32 target) 407 { 408 /* 409 * Floating point operation is not supported. So the FACTOR 410 * is defined, which can avoid the floating point computation 411 * when calculating the panel ratio. 412 */ 413 #define ACCURACY 12 414 #define FACTOR (1 << ACCURACY) 415 u32 ratio = source * FACTOR / target; 416 return (FACTOR * ratio + FACTOR/2) / FACTOR; 417 } 418 419 static void i965_scale_aspect(struct intel_crtc_state *crtc_state, 420 u32 *pfit_control) 421 { 422 const struct drm_display_mode *adjusted_mode = 423 &crtc_state->hw.adjusted_mode; 424 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src); 425 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src); 426 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h; 427 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay; 428 429 /* 965+ is easy, it does everything in hw */ 430 if (scaled_width > scaled_height) 431 *pfit_control |= PFIT_ENABLE | 432 PFIT_SCALING_PILLAR; 433 else if (scaled_width < scaled_height) 434 *pfit_control |= PFIT_ENABLE | 435 PFIT_SCALING_LETTER; 436 else if (adjusted_mode->crtc_hdisplay != pipe_src_w) 437 *pfit_control |= PFIT_ENABLE | PFIT_SCALING_AUTO; 438 } 439 440 static void i9xx_scale_aspect(struct intel_crtc_state *crtc_state, 441 u32 *pfit_control, u32 *pfit_pgm_ratios, 442 u32 *border) 443 { 444 struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; 445 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src); 446 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src); 447 u32 scaled_width = adjusted_mode->crtc_hdisplay * pipe_src_h; 448 u32 scaled_height = pipe_src_w * adjusted_mode->crtc_vdisplay; 449 u32 bits; 450 451 /* 452 * For earlier chips we have to calculate the scaling 453 * ratio by hand and program it into the 454 * PFIT_PGM_RATIO register 455 */ 456 if (scaled_width > scaled_height) { /* pillar */ 457 centre_horizontally(adjusted_mode, 458 scaled_height / pipe_src_h); 459 460 *border = LVDS_BORDER_ENABLE; 461 if (pipe_src_h != adjusted_mode->crtc_vdisplay) { 462 bits = panel_fitter_scaling(pipe_src_h, 463 adjusted_mode->crtc_vdisplay); 464 465 *pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | 466 bits << PFIT_VERT_SCALE_SHIFT); 467 *pfit_control |= (PFIT_ENABLE | 468 VERT_INTERP_BILINEAR | 469 HORIZ_INTERP_BILINEAR); 470 } 471 } else if (scaled_width < scaled_height) { /* letter */ 472 centre_vertically(adjusted_mode, 473 scaled_width / pipe_src_w); 474 475 *border = LVDS_BORDER_ENABLE; 476 if (pipe_src_w != adjusted_mode->crtc_hdisplay) { 477 bits = panel_fitter_scaling(pipe_src_w, 478 adjusted_mode->crtc_hdisplay); 479 480 *pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | 481 bits << PFIT_VERT_SCALE_SHIFT); 482 *pfit_control |= (PFIT_ENABLE | 483 VERT_INTERP_BILINEAR | 484 HORIZ_INTERP_BILINEAR); 485 } 486 } else { 487 /* Aspects match, Let hw scale both directions */ 488 *pfit_control |= (PFIT_ENABLE | 489 VERT_AUTO_SCALE | HORIZ_AUTO_SCALE | 490 VERT_INTERP_BILINEAR | 491 HORIZ_INTERP_BILINEAR); 492 } 493 } 494 495 static int gmch_panel_fitting(struct intel_crtc_state *crtc_state, 496 const struct drm_connector_state *conn_state) 497 { 498 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 499 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 500 u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; 501 struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; 502 int pipe_src_w = drm_rect_width(&crtc_state->pipe_src); 503 int pipe_src_h = drm_rect_height(&crtc_state->pipe_src); 504 505 /* Native modes don't need fitting */ 506 if (adjusted_mode->crtc_hdisplay == pipe_src_w && 507 adjusted_mode->crtc_vdisplay == pipe_src_h) 508 goto out; 509 510 switch (conn_state->scaling_mode) { 511 case DRM_MODE_SCALE_CENTER: 512 /* 513 * For centered modes, we have to calculate border widths & 514 * heights and modify the values programmed into the CRTC. 515 */ 516 centre_horizontally(adjusted_mode, pipe_src_w); 517 centre_vertically(adjusted_mode, pipe_src_h); 518 border = LVDS_BORDER_ENABLE; 519 break; 520 case DRM_MODE_SCALE_ASPECT: 521 /* Scale but preserve the aspect ratio */ 522 if (DISPLAY_VER(dev_priv) >= 4) 523 i965_scale_aspect(crtc_state, &pfit_control); 524 else 525 i9xx_scale_aspect(crtc_state, &pfit_control, 526 &pfit_pgm_ratios, &border); 527 break; 528 case DRM_MODE_SCALE_FULLSCREEN: 529 /* 530 * Full scaling, even if it changes the aspect ratio. 531 * Fortunately this is all done for us in hw. 532 */ 533 if (pipe_src_h != adjusted_mode->crtc_vdisplay || 534 pipe_src_w != adjusted_mode->crtc_hdisplay) { 535 pfit_control |= PFIT_ENABLE; 536 if (DISPLAY_VER(dev_priv) >= 4) 537 pfit_control |= PFIT_SCALING_AUTO; 538 else 539 pfit_control |= (VERT_AUTO_SCALE | 540 VERT_INTERP_BILINEAR | 541 HORIZ_AUTO_SCALE | 542 HORIZ_INTERP_BILINEAR); 543 } 544 break; 545 default: 546 MISSING_CASE(conn_state->scaling_mode); 547 return -EINVAL; 548 } 549 550 /* 965+ wants fuzzy fitting */ 551 /* FIXME: handle multiple panels by failing gracefully */ 552 if (DISPLAY_VER(dev_priv) >= 4) 553 pfit_control |= PFIT_PIPE(crtc->pipe) | PFIT_FILTER_FUZZY; 554 555 out: 556 if ((pfit_control & PFIT_ENABLE) == 0) { 557 pfit_control = 0; 558 pfit_pgm_ratios = 0; 559 } 560 561 /* Make sure pre-965 set dither correctly for 18bpp panels. */ 562 if (DISPLAY_VER(dev_priv) < 4 && crtc_state->pipe_bpp == 18) 563 pfit_control |= PANEL_8TO6_DITHER_ENABLE; 564 565 crtc_state->gmch_pfit.control = pfit_control; 566 crtc_state->gmch_pfit.pgm_ratios = pfit_pgm_ratios; 567 crtc_state->gmch_pfit.lvds_border_bits = border; 568 569 return 0; 570 } 571 572 int intel_panel_fitting(struct intel_crtc_state *crtc_state, 573 const struct drm_connector_state *conn_state) 574 { 575 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 576 struct drm_i915_private *i915 = to_i915(crtc->base.dev); 577 578 if (HAS_GMCH(i915)) 579 return gmch_panel_fitting(crtc_state, conn_state); 580 else 581 return pch_panel_fitting(crtc_state, conn_state); 582 } 583 584 enum drm_connector_status 585 intel_panel_detect(struct drm_connector *connector, bool force) 586 { 587 struct drm_i915_private *i915 = to_i915(connector->dev); 588 589 if (!INTEL_DISPLAY_ENABLED(i915)) 590 return connector_status_disconnected; 591 592 return connector_status_connected; 593 } 594 595 enum drm_mode_status 596 intel_panel_mode_valid(struct intel_connector *connector, 597 const struct drm_display_mode *mode) 598 { 599 const struct drm_display_mode *fixed_mode = 600 intel_panel_fixed_mode(connector, mode); 601 602 if (!fixed_mode) 603 return MODE_OK; 604 605 if (mode->hdisplay != fixed_mode->hdisplay) 606 return MODE_PANEL; 607 608 if (mode->vdisplay != fixed_mode->vdisplay) 609 return MODE_PANEL; 610 611 if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(fixed_mode)) 612 return MODE_PANEL; 613 614 return MODE_OK; 615 } 616 617 int intel_panel_init(struct intel_connector *connector) 618 { 619 struct intel_panel *panel = &connector->panel; 620 621 intel_backlight_init_funcs(panel); 622 623 drm_dbg_kms(connector->base.dev, 624 "[CONNECTOR:%d:%s] DRRS type: %s\n", 625 connector->base.base.id, connector->base.name, 626 intel_drrs_type_str(intel_panel_drrs_type(connector))); 627 628 return 0; 629 } 630 631 void intel_panel_fini(struct intel_connector *connector) 632 { 633 struct intel_panel *panel = &connector->panel; 634 struct drm_display_mode *fixed_mode, *next; 635 636 intel_backlight_destroy(panel); 637 638 list_for_each_entry_safe(fixed_mode, next, &panel->fixed_modes, head) { 639 list_del(&fixed_mode->head); 640 drm_mode_destroy(connector->base.dev, fixed_mode); 641 } 642 } 643