2 * Copyright © 2006-2007 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Eric Anholt <eric@anholt.net>
27 #include <linux/i2c.h>
29 #include "intel_drv.h"
33 #include "drm_crtc_helper.h"
35 bool intel_pipe_has_type (struct drm_crtc *crtc, int type);
58 #define INTEL_P2_NUM 2
61 intel_range_t dot, vco, n, m, m1, m2, p, p1;
65 #define I8XX_DOT_MIN 25000
66 #define I8XX_DOT_MAX 350000
67 #define I8XX_VCO_MIN 930000
68 #define I8XX_VCO_MAX 1400000
72 #define I8XX_M_MAX 140
73 #define I8XX_M1_MIN 18
74 #define I8XX_M1_MAX 26
76 #define I8XX_M2_MAX 16
78 #define I8XX_P_MAX 128
80 #define I8XX_P1_MAX 33
81 #define I8XX_P1_LVDS_MIN 1
82 #define I8XX_P1_LVDS_MAX 6
83 #define I8XX_P2_SLOW 4
84 #define I8XX_P2_FAST 2
85 #define I8XX_P2_LVDS_SLOW 14
86 #define I8XX_P2_LVDS_FAST 14 /* No fast option */
87 #define I8XX_P2_SLOW_LIMIT 165000
89 #define I9XX_DOT_MIN 20000
90 #define I9XX_DOT_MAX 400000
91 #define I9XX_VCO_MIN 1400000
92 #define I9XX_VCO_MAX 2800000
96 #define I9XX_M_MAX 120
97 #define I9XX_M1_MIN 10
98 #define I9XX_M1_MAX 20
100 #define I9XX_M2_MAX 9
101 #define I9XX_P_SDVO_DAC_MIN 5
102 #define I9XX_P_SDVO_DAC_MAX 80
103 #define I9XX_P_LVDS_MIN 7
104 #define I9XX_P_LVDS_MAX 98
105 #define I9XX_P1_MIN 1
106 #define I9XX_P1_MAX 8
107 #define I9XX_P2_SDVO_DAC_SLOW 10
108 #define I9XX_P2_SDVO_DAC_FAST 5
109 #define I9XX_P2_SDVO_DAC_SLOW_LIMIT 200000
110 #define I9XX_P2_LVDS_SLOW 14
111 #define I9XX_P2_LVDS_FAST 7
112 #define I9XX_P2_LVDS_SLOW_LIMIT 112000
114 #define INTEL_LIMIT_I8XX_DVO_DAC 0
115 #define INTEL_LIMIT_I8XX_LVDS 1
116 #define INTEL_LIMIT_I9XX_SDVO_DAC 2
117 #define INTEL_LIMIT_I9XX_LVDS 3
119 static const intel_limit_t intel_limits[] = {
120 { /* INTEL_LIMIT_I8XX_DVO_DAC */
121 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX },
122 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX },
123 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX },
124 .m = { .min = I8XX_M_MIN, .max = I8XX_M_MAX },
125 .m1 = { .min = I8XX_M1_MIN, .max = I8XX_M1_MAX },
126 .m2 = { .min = I8XX_M2_MIN, .max = I8XX_M2_MAX },
127 .p = { .min = I8XX_P_MIN, .max = I8XX_P_MAX },
128 .p1 = { .min = I8XX_P1_MIN, .max = I8XX_P1_MAX },
129 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT,
130 .p2_slow = I8XX_P2_SLOW, .p2_fast = I8XX_P2_FAST },
132 { /* INTEL_LIMIT_I8XX_LVDS */
133 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX },
134 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX },
135 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX },
136 .m = { .min = I8XX_M_MIN, .max = I8XX_M_MAX },
137 .m1 = { .min = I8XX_M1_MIN, .max = I8XX_M1_MAX },
138 .m2 = { .min = I8XX_M2_MIN, .max = I8XX_M2_MAX },
139 .p = { .min = I8XX_P_MIN, .max = I8XX_P_MAX },
140 .p1 = { .min = I8XX_P1_LVDS_MIN, .max = I8XX_P1_LVDS_MAX },
141 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT,
142 .p2_slow = I8XX_P2_LVDS_SLOW, .p2_fast = I8XX_P2_LVDS_FAST },
144 { /* INTEL_LIMIT_I9XX_SDVO_DAC */
145 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX },
146 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX },
147 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX },
148 .m = { .min = I9XX_M_MIN, .max = I9XX_M_MAX },
149 .m1 = { .min = I9XX_M1_MIN, .max = I9XX_M1_MAX },
150 .m2 = { .min = I9XX_M2_MIN, .max = I9XX_M2_MAX },
151 .p = { .min = I9XX_P_SDVO_DAC_MIN, .max = I9XX_P_SDVO_DAC_MAX },
152 .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX },
153 .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT,
154 .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST },
156 { /* INTEL_LIMIT_I9XX_LVDS */
157 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX },
158 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX },
159 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX },
160 .m = { .min = I9XX_M_MIN, .max = I9XX_M_MAX },
161 .m1 = { .min = I9XX_M1_MIN, .max = I9XX_M1_MAX },
162 .m2 = { .min = I9XX_M2_MIN, .max = I9XX_M2_MAX },
163 .p = { .min = I9XX_P_LVDS_MIN, .max = I9XX_P_LVDS_MAX },
164 .p1 = { .min = I9XX_P1_MIN, .max = I9XX_P1_MAX },
165 /* The single-channel range is 25-112Mhz, and dual-channel
166 * is 80-224Mhz. Prefer single channel as much as possible.
168 .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT,
169 .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_FAST },
173 static const intel_limit_t *intel_limit(struct drm_crtc *crtc)
175 struct drm_device *dev = crtc->dev;
176 const intel_limit_t *limit;
179 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
180 limit = &intel_limits[INTEL_LIMIT_I9XX_LVDS];
182 limit = &intel_limits[INTEL_LIMIT_I9XX_SDVO_DAC];
184 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
185 limit = &intel_limits[INTEL_LIMIT_I8XX_LVDS];
187 limit = &intel_limits[INTEL_LIMIT_I8XX_DVO_DAC];
192 /** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
194 static void i8xx_clock(int refclk, intel_clock_t *clock)
196 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
197 clock->p = clock->p1 * clock->p2;
198 clock->vco = refclk * clock->m / (clock->n + 2);
199 clock->dot = clock->vco / clock->p;
202 /** Derive the pixel clock for the given refclk and divisors for 9xx chips. */
204 static void i9xx_clock(int refclk, intel_clock_t *clock)
206 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
207 clock->p = clock->p1 * clock->p2;
208 clock->vco = refclk * clock->m / (clock->n + 2);
209 clock->dot = clock->vco / clock->p;
212 static void intel_clock(struct drm_device *dev, int refclk,
213 intel_clock_t *clock)
216 return i9xx_clock (refclk, clock);
218 return i8xx_clock (refclk, clock);
222 * Returns whether any output on the specified pipe is of the specified type
224 bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
226 struct drm_device *dev = crtc->dev;
227 struct drm_mode_config *mode_config = &dev->mode_config;
228 struct drm_output *l_entry;
230 list_for_each_entry(l_entry, &mode_config->output_list, head) {
231 if (l_entry->crtc == crtc) {
232 struct intel_output *intel_output = l_entry->driver_private;
233 if (intel_output->type == type)
240 #define INTELPllInvalid(s) { /* ErrorF (s) */; return false; }
242 * Returns whether the given set of divisors are valid for a given refclk with
246 static bool intel_PLL_is_valid(struct drm_crtc *crtc, intel_clock_t *clock)
248 const intel_limit_t *limit = intel_limit (crtc);
250 if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1)
251 INTELPllInvalid ("p1 out of range\n");
252 if (clock->p < limit->p.min || limit->p.max < clock->p)
253 INTELPllInvalid ("p out of range\n");
254 if (clock->m2 < limit->m2.min || limit->m2.max < clock->m2)
255 INTELPllInvalid ("m2 out of range\n");
256 if (clock->m1 < limit->m1.min || limit->m1.max < clock->m1)
257 INTELPllInvalid ("m1 out of range\n");
258 if (clock->m1 <= clock->m2)
259 INTELPllInvalid ("m1 <= m2\n");
260 if (clock->m < limit->m.min || limit->m.max < clock->m)
261 INTELPllInvalid ("m out of range\n");
262 if (clock->n < limit->n.min || limit->n.max < clock->n)
263 INTELPllInvalid ("n out of range\n");
264 if (clock->vco < limit->vco.min || limit->vco.max < clock->vco)
265 INTELPllInvalid ("vco out of range\n");
266 /* XXX: We may need to be checking "Dot clock" depending on the multiplier,
267 * output, etc., rather than just a single range.
269 if (clock->dot < limit->dot.min || limit->dot.max < clock->dot)
270 INTELPllInvalid ("dot out of range\n");
276 * Returns a set of divisors for the desired target clock with the given
277 * refclk, or FALSE. The returned values represent the clock equation:
278 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
280 static bool intel_find_best_PLL(struct drm_crtc *crtc, int target,
281 int refclk, intel_clock_t *best_clock)
283 struct drm_device *dev = crtc->dev;
284 struct drm_i915_private *dev_priv = dev->dev_private;
286 const intel_limit_t *limit = intel_limit(crtc);
289 if (IS_I9XX(dev) && intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
290 (I915_READ(LVDS) & LVDS_PORT_EN) != 0) {
292 * For LVDS, if the panel is on, just rely on its current
293 * settings for dual-channel. We haven't figured out how to
294 * reliably set up different single/dual channel state, if we
297 if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) ==
299 clock.p2 = limit->p2.p2_fast;
301 clock.p2 = limit->p2.p2_slow;
303 if (target < limit->p2.dot_limit)
304 clock.p2 = limit->p2.p2_slow;
306 clock.p2 = limit->p2.p2_fast;
309 memset (best_clock, 0, sizeof (*best_clock));
311 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; clock.m1++) {
312 for (clock.m2 = limit->m2.min; clock.m2 < clock.m1 &&
313 clock.m2 <= limit->m2.max; clock.m2++) {
314 for (clock.n = limit->n.min; clock.n <= limit->n.max;
316 for (clock.p1 = limit->p1.min;
317 clock.p1 <= limit->p1.max; clock.p1++) {
320 intel_clock(dev, refclk, &clock);
322 if (!intel_PLL_is_valid(crtc, &clock))
325 this_err = abs(clock.dot - target);
326 if (this_err < err) {
335 return (err != target);
339 intel_set_vblank(struct drm_device *dev)
341 struct drm_i915_private *dev_priv = dev->dev_private;
342 struct drm_crtc *crtc;
343 struct intel_crtc *intel_crtc;
346 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
347 intel_crtc = crtc->driver_private;
350 vbl_pipe |= (1<<intel_crtc->pipe);
353 dev_priv->vblank_pipe = vbl_pipe;
354 i915_enable_interrupt(dev);
357 intel_wait_for_vblank(struct drm_device *dev)
359 /* Wait for 20ms, i.e. one cycle at 50hz. */
364 intel_pipe_set_base(struct drm_crtc *crtc, int x, int y)
366 struct drm_device *dev = crtc->dev;
367 struct drm_i915_private *dev_priv = dev->dev_private;
368 struct drm_i915_master_private *master_priv;
369 struct intel_crtc *intel_crtc = crtc->driver_private;
370 int pipe = intel_crtc->pipe;
371 unsigned long Start, Offset;
372 int dspbase = (pipe == 0 ? DSPAADDR : DSPBADDR);
373 int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF);
374 int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE;
375 int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
380 DRM_DEBUG("No FB bound\n");
384 Start = crtc->fb->bo->offset;
385 Offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
387 I915_WRITE(dspstride, crtc->fb->pitch);
389 dspcntr = I915_READ(dspcntr_reg);
390 switch (crtc->fb->bits_per_pixel) {
392 dspcntr |= DISPPLANE_8BPP;
395 if (crtc->fb->depth == 15)
396 dspcntr |= DISPPLANE_15_16BPP;
398 dspcntr |= DISPPLANE_16BPP;
402 dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
405 DRM_ERROR("Unknown color depth\n");
408 I915_WRITE(dspcntr_reg, dspcntr);
410 DRM_DEBUG("Writing base %08lX %08lX %d %d\n", Start, Offset, x, y);
412 I915_WRITE(dspbase, Offset);
414 I915_WRITE(dspsurf, Start);
417 I915_WRITE(dspbase, Start + Offset);
422 if (!dev->primary->master)
425 master_priv = dev->primary->master->driver_priv;
426 if (!master_priv->sarea_priv)
431 master_priv->sarea_priv->planeA_x = x;
432 master_priv->sarea_priv->planeA_y = y;
435 master_priv->sarea_priv->planeB_x = x;
436 master_priv->sarea_priv->planeB_y = y;
439 DRM_ERROR("Can't update pipe %d in SAREA\n", pipe);
447 * Sets the power management mode of the pipe and plane.
449 * This code should probably grow support for turning the cursor off and back
450 * on appropriately at the same time as we're turning the pipe off/on.
452 static void intel_crtc_dpms(struct drm_crtc *crtc, int mode)
454 struct drm_device *dev = crtc->dev;
455 struct drm_i915_master_private *master_priv;
456 struct drm_i915_private *dev_priv = dev->dev_private;
457 struct intel_crtc *intel_crtc = crtc->driver_private;
458 int pipe = intel_crtc->pipe;
459 int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
460 int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
461 int dspbase_reg = (pipe == 0) ? DSPAADDR : DSPBADDR;
462 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
466 /* XXX: When our outputs are all unaware of DPMS modes other than off
467 * and on, we should map those modes to DPMSModeOff in the CRTC.
471 case DPMSModeStandby:
472 case DPMSModeSuspend:
473 /* Enable the DPLL */
474 temp = I915_READ(dpll_reg);
475 if ((temp & DPLL_VCO_ENABLE) == 0) {
476 I915_WRITE(dpll_reg, temp);
478 /* Wait for the clocks to stabilize. */
480 I915_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
482 /* Wait for the clocks to stabilize. */
484 I915_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
486 /* Wait for the clocks to stabilize. */
490 /* Enable the pipe */
491 temp = I915_READ(pipeconf_reg);
492 if ((temp & PIPEACONF_ENABLE) == 0)
493 I915_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE);
495 /* Enable the plane */
496 temp = I915_READ(dspcntr_reg);
497 if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
498 I915_WRITE(dspcntr_reg, temp | DISPLAY_PLANE_ENABLE);
499 /* Flush the plane changes */
500 I915_WRITE(dspbase_reg, I915_READ(dspbase_reg));
503 intel_crtc_load_lut(crtc);
505 /* Give the overlay scaler a chance to enable if it's on this pipe */
506 //intel_crtc_dpms_video(crtc, TRUE); TODO
509 /* Give the overlay scaler a chance to disable if it's on this pipe */
510 //intel_crtc_dpms_video(crtc, FALSE); TODO
512 /* Disable the VGA plane that we never use */
513 I915_WRITE(VGACNTRL, VGA_DISP_DISABLE);
515 /* Disable display plane */
516 temp = I915_READ(dspcntr_reg);
517 if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
518 I915_WRITE(dspcntr_reg, temp & ~DISPLAY_PLANE_ENABLE);
519 /* Flush the plane changes */
520 I915_WRITE(dspbase_reg, I915_READ(dspbase_reg));
521 I915_READ(dspbase_reg);
525 /* Wait for vblank for the disable to take effect */
526 intel_wait_for_vblank(dev);
529 /* Next, disable display pipes */
530 temp = I915_READ(pipeconf_reg);
531 if ((temp & PIPEACONF_ENABLE) != 0) {
532 I915_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE);
533 I915_READ(pipeconf_reg);
536 /* Wait for vblank for the disable to take effect. */
537 intel_wait_for_vblank(dev);
539 temp = I915_READ(dpll_reg);
540 if ((temp & DPLL_VCO_ENABLE) != 0) {
541 I915_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE);
545 /* Wait for the clocks to turn off. */
550 if (!dev->primary->master)
553 master_priv = dev->primary->master->driver_priv;
554 if (!master_priv->sarea_priv)
557 enabled = crtc->enabled && mode != DPMSModeOff;
561 master_priv->sarea_priv->planeA_w = enabled ? crtc->mode.hdisplay : 0;
562 master_priv->sarea_priv->planeA_h = enabled ? crtc->mode.vdisplay : 0;
565 master_priv->sarea_priv->planeB_w = enabled ? crtc->mode.hdisplay : 0;
566 master_priv->sarea_priv->planeB_h = enabled ? crtc->mode.vdisplay : 0;
569 DRM_ERROR("Can't update pipe %d in SAREA\n", pipe);
573 intel_crtc->dpms_mode = mode;
576 static void intel_crtc_prepare (struct drm_crtc *crtc)
578 crtc->funcs->dpms(crtc, DPMSModeOff);
581 static void intel_crtc_commit (struct drm_crtc *crtc)
583 crtc->funcs->dpms(crtc, DPMSModeOn);
586 void intel_output_prepare (struct drm_output *output)
588 /* lvds has its own version of prepare see intel_lvds_prepare */
589 output->funcs->dpms(output, DPMSModeOff);
592 void intel_output_commit (struct drm_output *output)
594 /* lvds has its own version of commit see intel_lvds_commit */
595 output->funcs->dpms(output, DPMSModeOn);
598 static bool intel_crtc_mode_fixup(struct drm_crtc *crtc,
599 struct drm_display_mode *mode,
600 struct drm_display_mode *adjusted_mode)
606 /** Returns the core display clock speed for i830 - i945 */
607 static int intel_get_core_clock_speed(struct drm_device *dev)
610 /* Core clock values taken from the published datasheets.
611 * The 830 may go up to 166 Mhz, which we should check.
615 else if (IS_I915G(dev))
617 else if (IS_I945GM(dev) || IS_845G(dev))
619 else if (IS_I915GM(dev)) {
622 pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
624 if (gcfgc & GC_LOW_FREQUENCY_ENABLE)
627 switch (gcfgc & GC_DISPLAY_CLOCK_MASK) {
628 case GC_DISPLAY_CLOCK_333_MHZ:
631 case GC_DISPLAY_CLOCK_190_200_MHZ:
635 } else if (IS_I865G(dev))
637 else if (IS_I855(dev)) {
639 PCITAG bridge = pciTag(0, 0, 0); /* This is always the host bridge */
640 u16 hpllcc = pciReadWord(bridge, HPLLCC);
644 /* Assume that the hardware is in the high speed state. This
645 * should be the default.
647 switch (hpllcc & GC_CLOCK_CONTROL_MASK) {
648 case GC_CLOCK_133_200:
649 case GC_CLOCK_100_200:
651 case GC_CLOCK_166_250:
653 case GC_CLOCK_100_133:
656 } else /* 852, 830 */
659 return 0; /* Silence gcc warning */
664 * Return the pipe currently connected to the panel fitter,
665 * or -1 if the panel fitter is not present or not in use
667 static int intel_panel_fitter_pipe (struct drm_device *dev)
669 struct drm_i915_private *dev_priv = dev->dev_private;
672 /* i830 doesn't have a panel fitter */
676 pfit_control = I915_READ(PFIT_CONTROL);
678 /* See if the panel fitter is in use */
679 if ((pfit_control & PFIT_ENABLE) == 0)
682 /* 965 can place panel fitter on either pipe */
684 return (pfit_control >> 29) & 0x3;
686 /* older chips can only use pipe 1 */
690 static void intel_crtc_mode_set(struct drm_crtc *crtc,
691 struct drm_display_mode *mode,
692 struct drm_display_mode *adjusted_mode,
695 struct drm_device *dev = crtc->dev;
696 struct drm_i915_private *dev_priv = dev->dev_private;
697 struct intel_crtc *intel_crtc = crtc->driver_private;
698 int pipe = intel_crtc->pipe;
699 int fp_reg = (pipe == 0) ? FPA0 : FPB0;
700 int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
701 int dpll_md_reg = (intel_crtc->pipe == 0) ? DPLL_A_MD : DPLL_B_MD;
702 int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
703 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
704 int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B;
705 int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B;
706 int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B;
707 int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B;
708 int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B;
709 int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B;
710 int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE;
711 int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS;
712 int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC;
715 u32 dpll = 0, fp = 0, dspcntr, pipeconf;
716 bool ok, is_sdvo = false, is_dvo = false;
717 bool is_crt = false, is_lvds = false, is_tv = false;
718 struct drm_mode_config *mode_config = &dev->mode_config;
719 struct drm_output *output;
721 list_for_each_entry(output, &mode_config->output_list, head) {
722 struct intel_output *intel_output = output->driver_private;
724 if (output->crtc != crtc)
727 switch (intel_output->type) {
728 case INTEL_OUTPUT_LVDS:
731 case INTEL_OUTPUT_SDVO:
734 case INTEL_OUTPUT_DVO:
737 case INTEL_OUTPUT_TVOUT:
740 case INTEL_OUTPUT_ANALOG:
752 ok = intel_find_best_PLL(crtc, adjusted_mode->clock, refclk, &clock);
754 DRM_ERROR("Couldn't find PLL settings for mode!\n");
758 fp = clock.n << 16 | clock.m1 << 8 | clock.m2;
760 dpll = DPLL_VGA_MODE_DIS;
763 dpll |= DPLLB_MODE_LVDS;
765 dpll |= DPLLB_MODE_DAC_SERIAL;
767 dpll |= DPLL_DVO_HIGH_SPEED;
768 if (IS_I945G(dev) || IS_I945GM(dev)) {
769 int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
770 dpll |= (sdvo_pixel_multiply - 1) << SDVO_MULTIPLIER_SHIFT_HIRES;
774 /* compute bitmask from p1 value */
775 dpll |= (1 << (clock.p1 - 1)) << 16;
778 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
781 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_7;
784 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_10;
787 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
791 dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT);
794 dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
797 dpll |= PLL_P1_DIVIDE_BY_TWO;
799 dpll |= (clock.p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT;
801 dpll |= PLL_P2_DIVIDE_BY_4;
806 /* XXX: just matching BIOS for now */
807 /* dpll |= PLL_REF_INPUT_TVCLKINBC; */
812 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
815 dpll |= PLL_REF_INPUT_DREFCLK;
818 pipeconf = I915_READ(pipeconf_reg);
820 /* Set up the display plane register */
821 dspcntr = DISPPLANE_GAMMA_ENABLE;
824 dspcntr |= DISPPLANE_SEL_PIPE_A;
826 dspcntr |= DISPPLANE_SEL_PIPE_B;
828 if (pipe == 0 && !IS_I965G(dev)) {
829 /* Enable pixel doubling when the dot clock is > 90% of the (display)
832 * XXX: No double-wide on 915GM pipe B. Is that the only reason for the
835 if (mode->clock > intel_get_core_clock_speed(dev) * 9 / 10)
836 pipeconf |= PIPEACONF_DOUBLE_WIDE;
838 pipeconf &= ~PIPEACONF_DOUBLE_WIDE;
841 dspcntr |= DISPLAY_PLANE_ENABLE;
842 pipeconf |= PIPEACONF_ENABLE;
843 dpll |= DPLL_VCO_ENABLE;
846 /* Disable the panel fitter if it was on our pipe */
847 if (intel_panel_fitter_pipe(dev) == pipe)
848 I915_WRITE(PFIT_CONTROL, 0);
850 DRM_DEBUG("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
851 drm_mode_debug_printmodeline(mode);
854 if (!xf86ModesEqual(mode, adjusted_mode)) {
855 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
856 "Adjusted mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
857 xf86PrintModeline(pScrn->scrnIndex, mode);
859 i830PrintPll("chosen", &clock);
862 if (dpll & DPLL_VCO_ENABLE) {
863 I915_WRITE(fp_reg, fp);
864 I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE);
869 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
870 * This is an exception to the general rule that mode_set doesn't turn
874 u32 lvds = I915_READ(LVDS);
876 lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP | LVDS_PIPEB_SELECT;
877 /* Set the B0-B3 data pairs corresponding to whether we're going to
878 * set the DPLLs for dual-channel mode or not.
881 lvds |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
883 lvds &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
885 /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
886 * appropriately here, but we need to look more thoroughly into how
887 * panels behave in the two modes.
890 I915_WRITE(LVDS, lvds);
894 I915_WRITE(fp_reg, fp);
895 I915_WRITE(dpll_reg, dpll);
897 /* Wait for the clocks to stabilize. */
901 int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
902 I915_WRITE(dpll_md_reg, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) |
903 ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT));
905 /* write it again -- the BIOS does, after all */
906 I915_WRITE(dpll_reg, dpll);
909 /* Wait for the clocks to stabilize. */
912 I915_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) |
913 ((adjusted_mode->crtc_htotal - 1) << 16));
914 I915_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) |
915 ((adjusted_mode->crtc_hblank_end - 1) << 16));
916 I915_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) |
917 ((adjusted_mode->crtc_hsync_end - 1) << 16));
918 I915_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) |
919 ((adjusted_mode->crtc_vtotal - 1) << 16));
920 I915_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) |
921 ((adjusted_mode->crtc_vblank_end - 1) << 16));
922 I915_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) |
923 ((adjusted_mode->crtc_vsync_end - 1) << 16));
924 /* pipesrc and dspsize control the size that is scaled from, which should
925 * always be the user's requested size.
927 I915_WRITE(dspsize_reg, ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1));
928 I915_WRITE(dsppos_reg, 0);
929 I915_WRITE(pipesrc_reg, ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
930 I915_WRITE(pipeconf_reg, pipeconf);
931 I915_READ(pipeconf_reg);
933 intel_wait_for_vblank(dev);
935 I915_WRITE(dspcntr_reg, dspcntr);
937 /* Flush the plane changes */
938 intel_pipe_set_base(crtc, x, y);
940 intel_set_vblank(dev);
942 intel_wait_for_vblank(dev);
945 /** Loads the palette/gamma unit for the CRTC with the prepared values */
946 void intel_crtc_load_lut(struct drm_crtc *crtc)
948 struct drm_device *dev = crtc->dev;
949 struct drm_i915_private *dev_priv = dev->dev_private;
950 struct intel_crtc *intel_crtc = crtc->driver_private;
951 int palreg = (intel_crtc->pipe == 0) ? PALETTE_A : PALETTE_B;
954 /* The clocks have to be on to load the palette. */
958 for (i = 0; i < 256; i++) {
959 I915_WRITE(palreg + 4 * i,
960 (intel_crtc->lut_r[i] << 16) |
961 (intel_crtc->lut_g[i] << 8) |
962 intel_crtc->lut_b[i]);
966 static int intel_crtc_cursor_set(struct drm_crtc *crtc,
967 struct drm_buffer_object *bo,
968 uint32_t width, uint32_t height)
970 struct drm_device *dev = crtc->dev;
971 struct drm_i915_private *dev_priv = dev->dev_private;
972 struct intel_crtc *intel_crtc = crtc->driver_private;
973 int pipe = intel_crtc->pipe;
974 uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
975 uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
981 /* if we want to turn of the cursor ignore width and height */
983 DRM_DEBUG("cursor off\n");
984 /* turn of the cursor */
986 temp |= CURSOR_MODE_DISABLE;
988 I915_WRITE(control, temp);
993 /* Currently we only support 64x64 cursors */
994 if (width != 64 || height != 64) {
995 DRM_ERROR("we currently only support 64x64 cursors\n");
999 if ((bo->mem.flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_VRAM) {
1000 DRM_ERROR("buffer needs to be in VRAM\n");
1004 if (bo->mem.size < width * height * 4) {
1005 DRM_ERROR("buffer is to small\n");
1009 if (dev_priv->cursor_needs_physical)
1010 addr = dev_priv->stolen_base + bo->offset;
1014 intel_crtc->cursor_addr = addr;
1016 /* set the pipe for the cursor */
1017 temp |= (pipe << 28);
1018 temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
1020 I915_WRITE(control, temp);
1021 I915_WRITE(base, addr);
1026 static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
1028 struct drm_device *dev = crtc->dev;
1029 struct drm_i915_private *dev_priv = dev->dev_private;
1030 struct intel_crtc *intel_crtc = crtc->driver_private;
1031 int pipe = intel_crtc->pipe;
1036 temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT);
1040 temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT);
1044 temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
1045 temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
1047 adder = intel_crtc->cursor_addr;
1048 I915_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
1049 I915_WRITE((pipe == 0) ? CURABASE : CURBBASE, adder);
1054 /** Sets the color ramps on behalf of RandR */
1055 static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
1056 u16 blue, int regno)
1058 struct intel_crtc *intel_crtc = crtc->driver_private;
1060 intel_crtc->lut_r[regno] = red >> 8;
1061 intel_crtc->lut_g[regno] = green >> 8;
1062 intel_crtc->lut_b[regno] = blue >> 8;
1066 * Get a pipe with a simple mode set on it for doing load-based monitor
1069 * It will be up to the load-detect code to adjust the pipe as appropriate for
1070 * its requirements. The pipe will be connected to no other outputs.
1072 * Currently this code will only succeed if there is a pipe with no outputs
1073 * configured for it. In the future, it could choose to temporarily disable
1074 * some outputs to free up a pipe for its use.
1076 * \return crtc, or NULL if no pipes are available.
1079 /* VESA 640x480x72Hz mode to set on the pipe */
1080 static struct drm_display_mode load_detect_mode = {
1081 DRM_MODE("640x480", DRM_MODE_TYPE_DEFAULT, 31500, 640, 664,
1082 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC),
1085 struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
1086 struct drm_display_mode *mode,
1089 struct drm_device *dev = output->dev;
1090 struct intel_output *intel_output = output->driver_private;
1091 struct intel_crtc *intel_crtc;
1092 struct drm_crtc *possible_crtc;
1093 struct drm_crtc *supported_crtc =NULL;
1094 struct drm_crtc *crtc = NULL;
1095 struct drm_output_helper_funcs *output_funcs;
1099 * Algorithm gets a little messy:
1100 * - if the output already has an assigned crtc, use it (but make
1101 * sure it's on first)
1102 * - try to find the first unused crtc that can drive this output,
1103 * and use that if we find one
1104 * - if there are no unused crtcs available, try to use the first
1105 * one we found that supports the output
1108 /* See if we already have a CRTC for this output */
1110 crtc = output->crtc;
1111 /* Make sure the crtc and output are running */
1112 intel_crtc = crtc->driver_private;
1113 *dpms_mode = intel_crtc->dpms_mode;
1114 if (intel_crtc->dpms_mode != DPMSModeOn) {
1115 crtc->funcs->dpms(crtc, DPMSModeOn);
1116 output->funcs->dpms(output, DPMSModeOn);
1121 /* Find an unused one (if possible) */
1122 list_for_each_entry(possible_crtc, &dev->mode_config.crtc_list, head) {
1124 if (!(output->possible_crtcs & (1 << i)))
1126 if (!possible_crtc->enabled) {
1127 crtc = possible_crtc;
1130 if (!supported_crtc)
1131 supported_crtc = possible_crtc;
1135 * If we didn't find an unused CRTC, use the first available one
1136 * that can drive this output.
1139 crtc = supported_crtc;
1144 output->crtc = crtc;
1145 intel_output->load_detect_temp = TRUE;
1147 intel_crtc = crtc->driver_private;
1148 *dpms_mode = intel_crtc->dpms_mode;
1150 if (!crtc->enabled) {
1152 mode = &load_detect_mode;
1153 drm_crtc_helper_set_mode(crtc, mode, 0, 0);
1155 if (intel_crtc->dpms_mode != DPMSModeOn)
1156 crtc->funcs->dpms(crtc, DPMSModeOn);
1158 output_funcs = output->helper_private;
1159 /* Add this output to the crtc */
1160 output_funcs->mode_set(output, &crtc->mode, &crtc->mode);
1161 output_funcs->commit(output);
1163 /* let the output get through one full cycle before testing */
1164 intel_wait_for_vblank(dev);
1169 void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode)
1171 struct drm_device *dev = output->dev;
1172 struct intel_output *intel_output = output->driver_private;
1173 struct drm_crtc *crtc = output->crtc;
1175 if (intel_output->load_detect_temp) {
1176 output->crtc = NULL;
1177 intel_output->load_detect_temp = FALSE;
1178 crtc->enabled = drm_crtc_in_use(crtc);
1179 drm_disable_unused_functions(dev);
1182 /* Switch crtc and output back off if necessary */
1183 if (crtc->enabled && dpms_mode != DPMSModeOn) {
1184 if (output->crtc == crtc)
1185 output->funcs->dpms(output, dpms_mode);
1186 crtc->funcs->dpms(crtc, dpms_mode);
1190 /* Returns the clock of the currently programmed mode of the given pipe. */
1191 static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
1193 struct drm_i915_private *dev_priv = dev->dev_private;
1194 struct intel_crtc *intel_crtc = crtc->driver_private;
1195 int pipe = intel_crtc->pipe;
1196 u32 dpll = I915_READ((pipe == 0) ? DPLL_A : DPLL_B);
1198 intel_clock_t clock;
1200 if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
1201 fp = I915_READ((pipe == 0) ? FPA0 : FPB0);
1203 fp = I915_READ((pipe == 0) ? FPA1 : FPB1);
1205 clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
1206 clock.m2 = (fp & FP_M2_DIV_MASK) >> FP_M2_DIV_SHIFT;
1207 clock.n = (fp & FP_N_DIV_MASK) >> FP_N_DIV_SHIFT;
1209 clock.p1 = ffs((dpll & DPLL_FPA01_P1_POST_DIV_MASK) >>
1210 DPLL_FPA01_P1_POST_DIV_SHIFT);
1212 switch (dpll & DPLL_MODE_MASK) {
1213 case DPLLB_MODE_DAC_SERIAL:
1214 clock.p2 = dpll & DPLL_DAC_SERIAL_P2_CLOCK_DIV_5 ?
1217 case DPLLB_MODE_LVDS:
1218 clock.p2 = dpll & DPLLB_LVDS_P2_CLOCK_DIV_7 ?
1222 DRM_DEBUG("Unknown DPLL mode %08x in programmed "
1223 "mode\n", (int)(dpll & DPLL_MODE_MASK));
1227 /* XXX: Handle the 100Mhz refclk */
1228 i9xx_clock(96000, &clock);
1230 bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN);
1233 clock.p1 = ffs((dpll & DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >>
1234 DPLL_FPA01_P1_POST_DIV_SHIFT);
1237 if ((dpll & PLL_REF_INPUT_MASK) ==
1238 PLLB_REF_INPUT_SPREADSPECTRUMIN) {
1239 /* XXX: might not be 66MHz */
1240 i8xx_clock(66000, &clock);
1242 i8xx_clock(48000, &clock);
1244 if (dpll & PLL_P1_DIVIDE_BY_TWO)
1247 clock.p1 = ((dpll & DPLL_FPA01_P1_POST_DIV_MASK_I830) >>
1248 DPLL_FPA01_P1_POST_DIV_SHIFT) + 2;
1250 if (dpll & PLL_P2_DIVIDE_BY_4)
1255 i8xx_clock(48000, &clock);
1259 /* XXX: It would be nice to validate the clocks, but we can't reuse
1260 * i830PllIsValid() because it relies on the xf86_config output
1261 * configuration being accurate, which it isn't necessarily.
1267 /** Returns the currently programmed mode of the given pipe. */
1268 struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
1269 struct drm_crtc *crtc)
1271 struct drm_i915_private *dev_priv = dev->dev_private;
1272 struct intel_crtc *intel_crtc = crtc->driver_private;
1273 int pipe = intel_crtc->pipe;
1274 struct drm_display_mode *mode;
1275 int htot = I915_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B);
1276 int hsync = I915_READ((pipe == 0) ? HSYNC_A : HSYNC_B);
1277 int vtot = I915_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B);
1278 int vsync = I915_READ((pipe == 0) ? VSYNC_A : VSYNC_B);
1280 mode = kzalloc(sizeof(*mode), GFP_KERNEL);
1284 mode->clock = intel_crtc_clock_get(dev, crtc);
1285 mode->hdisplay = (htot & 0xffff) + 1;
1286 mode->htotal = ((htot & 0xffff0000) >> 16) + 1;
1287 mode->hsync_start = (hsync & 0xffff) + 1;
1288 mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1;
1289 mode->vdisplay = (vtot & 0xffff) + 1;
1290 mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1;
1291 mode->vsync_start = (vsync & 0xffff) + 1;
1292 mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1;
1294 drm_mode_set_name(mode);
1295 drm_mode_set_crtcinfo(mode, 0);
1300 static const struct drm_crtc_helper_funcs intel_helper_funcs = {
1301 .mode_fixup = intel_crtc_mode_fixup,
1302 .mode_set = intel_crtc_mode_set,
1303 .mode_set_base = intel_pipe_set_base,
1304 .prepare = intel_crtc_prepare,
1305 .commit = intel_crtc_commit,
1308 static const struct drm_crtc_funcs intel_crtc_funcs = {
1309 .dpms = intel_crtc_dpms,
1310 .cursor_set = intel_crtc_cursor_set,
1311 .cursor_move = intel_crtc_cursor_move,
1312 .gamma_set = intel_crtc_gamma_set,
1313 .set_config = drm_crtc_helper_set_config,
1317 void intel_crtc_init(struct drm_device *dev, int pipe)
1319 struct drm_crtc *crtc;
1320 struct intel_crtc *intel_crtc;
1323 crtc = drm_crtc_create(dev, &intel_crtc_funcs);
1327 intel_crtc = kzalloc(sizeof(struct intel_crtc), GFP_KERNEL);
1328 if (intel_crtc == NULL) {
1333 intel_crtc->pipe = pipe;
1334 for (i = 0; i < 256; i++) {
1335 intel_crtc->lut_r[i] = i;
1336 intel_crtc->lut_g[i] = i;
1337 intel_crtc->lut_b[i] = i;
1340 intel_crtc->cursor_addr = 0;
1341 intel_crtc->dpms_mode = DPMSModeOff;
1342 drm_crtc_helper_add(crtc, &intel_helper_funcs);
1344 crtc->driver_private = intel_crtc;
1347 struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
1349 struct drm_crtc *crtc = NULL;
1351 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1352 struct intel_crtc *intel_crtc = crtc->driver_private;
1353 if (intel_crtc->pipe == pipe)
1359 int intel_output_clones(struct drm_device *dev, int type_mask)
1362 struct drm_output *output;
1365 list_for_each_entry(output, &dev->mode_config.output_list, head) {
1366 struct intel_output *intel_output = output->driver_private;
1367 if (type_mask & (1 << intel_output->type))
1368 index_mask |= (1 << entry);
1375 static void intel_setup_outputs(struct drm_device *dev)
1377 struct drm_output *output;
1379 intel_crt_init(dev);
1381 /* Set up integrated LVDS */
1382 if (IS_MOBILE(dev) && !IS_I830(dev))
1383 intel_lvds_init(dev);
1386 intel_sdvo_init(dev, SDVOB);
1387 intel_sdvo_init(dev, SDVOC);
1389 intel_dvo_init(dev);
1391 if (IS_I9XX(dev) && !IS_I915G(dev))
1394 list_for_each_entry(output, &dev->mode_config.output_list, head) {
1395 struct intel_output *intel_output = output->driver_private;
1396 int crtc_mask = 0, clone_mask = 0;
1399 switch(intel_output->type) {
1400 case INTEL_OUTPUT_DVO:
1401 case INTEL_OUTPUT_SDVO:
1402 crtc_mask = ((1 << 0)|
1404 clone_mask = ((1 << INTEL_OUTPUT_ANALOG) |
1405 (1 << INTEL_OUTPUT_DVO) |
1406 (1 << INTEL_OUTPUT_SDVO));
1408 case INTEL_OUTPUT_ANALOG:
1409 crtc_mask = ((1 << 0)|
1411 clone_mask = ((1 << INTEL_OUTPUT_ANALOG) |
1412 (1 << INTEL_OUTPUT_DVO) |
1413 (1 << INTEL_OUTPUT_SDVO));
1415 case INTEL_OUTPUT_LVDS:
1416 crtc_mask = (1 << 1);
1417 clone_mask = (1 << INTEL_OUTPUT_LVDS);
1419 case INTEL_OUTPUT_TVOUT:
1420 crtc_mask = ((1 << 0) |
1422 clone_mask = (1 << INTEL_OUTPUT_TVOUT);
1425 output->possible_crtcs = crtc_mask;
1426 output->possible_clones = intel_output_clones(dev, clone_mask);
1430 static const struct drm_mode_config_funcs intel_mode_funcs = {
1434 void intel_modeset_init(struct drm_device *dev)
1439 drm_mode_config_init(dev);
1441 dev->mode_config.min_width = 0;
1442 dev->mode_config.min_height = 0;
1444 dev->mode_config.funcs = (void *)&intel_mode_funcs;
1446 if (IS_I965G(dev)) {
1447 dev->mode_config.max_width = 8192;
1448 dev->mode_config.max_height = 8192;
1450 dev->mode_config.max_width = 2048;
1451 dev->mode_config.max_height = 2048;
1454 /* set memory base */
1456 dev->mode_config.fb_base = pci_resource_start(dev->pdev, 2);
1458 dev->mode_config.fb_base = pci_resource_start(dev->pdev, 0);
1460 if (IS_MOBILE(dev) || IS_I9XX(dev))
1464 DRM_DEBUG("%d display pipe%s available.\n",
1465 num_pipe, num_pipe > 1 ? "s" : "");
1467 for (i = 0; i < num_pipe; i++) {
1468 intel_crtc_init(dev, i);
1471 intel_setup_outputs(dev);
1473 //drm_initial_config(dev, false);
1476 void intel_modeset_cleanup(struct drm_device *dev)
1478 drm_mode_config_cleanup(dev);