Subversion Repositories Kolibri OS

Rev

Rev 3746 | Rev 4280 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3746 Rev 4104
Line 39... Line 39...
39
#include "i915_trace.h"
39
#include "i915_trace.h"
40
#include 
40
#include 
41
#include 
41
#include 
42
//#include 
42
//#include 
Line 43... Line -...
43
 
-
 
44
phys_addr_t get_bus_addr(void);
-
 
45
 
-
 
46
 
43
 
47
#define MAX_ERRNO       4095
-
 
48
 
-
 
-
 
44
#define MAX_ERRNO       4095
Line 49... Line 45...
49
 
45
phys_addr_t get_bus_addr(void);
50
 
46
 
51
bool intel_pipe_has_type(struct drm_crtc *crtc, int type);
47
bool intel_pipe_has_type(struct drm_crtc *crtc, int type);
Line 52... Line 48...
52
static void intel_increase_pllclock(struct drm_crtc *crtc);
48
static void intel_increase_pllclock(struct drm_crtc *crtc);
53
static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
49
static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
54
 
-
 
55
typedef struct {
50
 
56
    /* given values */
51
static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
-
 
52
				struct intel_crtc_config *pipe_config);
57
    int n;
53
static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
58
    int m1, m2;
-
 
59
    int p1, p2;
54
				    struct intel_crtc_config *pipe_config);
60
    /* derived values */
-
 
61
    int dot;
55
 
62
    int vco;
-
 
Line 63... Line 56...
63
    int m;
56
static int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
64
    int p;
57
			  int x, int y, struct drm_framebuffer *old_fb);
65
} intel_clock_t;
58
 
Line 66... Line 59...
66
 
59
 
67
typedef struct {
60
typedef struct {
68
    int min, max;
61
    int min, max;
69
} intel_range_t;
62
} intel_range_t;
Line 70... Line -...
70
 
-
 
71
typedef struct {
63
 
72
    int dot_limit;
64
typedef struct {
73
    int p2_slow, p2_fast;
65
    int dot_limit;
74
} intel_p2_t;
66
    int p2_slow, p2_fast;
75
 
-
 
76
#define INTEL_P2_NUM              2
-
 
77
typedef struct intel_limit intel_limit_t;
-
 
78
struct intel_limit {
-
 
79
    intel_range_t   dot, vco, n, m, m1, m2, p, p1;
-
 
80
    intel_p2_t      p2;
-
 
81
	/**
-
 
82
	 * find_pll() - Find the best values for the PLL
-
 
83
	 * @limit: limits for the PLL
-
 
84
	 * @crtc: current CRTC
-
 
85
	 * @target: target frequency in kHz
-
 
86
	 * @refclk: reference clock frequency in kHz
-
 
87
	 * @match_clock: if provided, @best_clock P divider must
-
 
88
	 *               match the P divider from @match_clock
-
 
89
	 *               used for LVDS downclocking
-
 
90
	 * @best_clock: best PLL values found
-
 
91
	 *
-
 
92
	 * Returns true on success, false on failure.
-
 
93
	 */
67
} intel_p2_t;
Line 94... Line 68...
94
	bool (*find_pll)(const intel_limit_t *limit,
68
 
95
			 struct drm_crtc *crtc,
69
typedef struct intel_limit intel_limit_t;
Line 109... Line 83...
109
	WARN_ON(!HAS_PCH_SPLIT(dev));
83
	WARN_ON(!HAS_PCH_SPLIT(dev));
Line 110... Line 84...
110
 
84
 
111
	return I915_READ(PCH_RAWCLK_FREQ) & RAWCLK_FREQ_MASK;
85
	return I915_READ(PCH_RAWCLK_FREQ) & RAWCLK_FREQ_MASK;
Line 112... Line -...
112
}
-
 
113
 
-
 
114
static bool
-
 
115
intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
116
		    int target, int refclk, intel_clock_t *match_clock,
-
 
117
		    intel_clock_t *best_clock);
-
 
118
static bool
-
 
119
intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
120
			int target, int refclk, intel_clock_t *match_clock,
-
 
121
			intel_clock_t *best_clock);
-
 
122
 
-
 
123
static bool
-
 
124
intel_find_pll_g4x_dp(const intel_limit_t *, struct drm_crtc *crtc,
-
 
125
		      int target, int refclk, intel_clock_t *match_clock,
-
 
126
		      intel_clock_t *best_clock);
-
 
127
static bool
-
 
128
intel_find_pll_ironlake_dp(const intel_limit_t *, struct drm_crtc *crtc,
-
 
129
			   int target, int refclk, intel_clock_t *match_clock,
-
 
130
			   intel_clock_t *best_clock);
-
 
131
 
-
 
132
static bool
-
 
133
intel_vlv_find_best_pll(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
134
			int target, int refclk, intel_clock_t *match_clock,
-
 
135
			intel_clock_t *best_clock);
86
}
136
 
87
 
137
static inline u32 /* units of 100MHz */
88
static inline u32 /* units of 100MHz */
138
intel_fdi_link_freq(struct drm_device *dev)
89
intel_fdi_link_freq(struct drm_device *dev)
139
{
90
{
140
	if (IS_GEN5(dev)) {
91
	if (IS_GEN5(dev)) {
141
		struct drm_i915_private *dev_priv = dev->dev_private;
92
		struct drm_i915_private *dev_priv = dev->dev_private;
142
		return (I915_READ(FDI_PLL_BIOS_0) & FDI_PLL_FB_CLOCK_MASK) + 2;
93
		return (I915_READ(FDI_PLL_BIOS_0) & FDI_PLL_FB_CLOCK_MASK) + 2;
143
	} else
94
	} else
Line 144... Line 95...
144
		return 27;
95
		return 27;
145
}
96
}
146
 
97
 
147
static const intel_limit_t intel_limits_i8xx_dvo = {
98
static const intel_limit_t intel_limits_i8xx_dac = {
148
        .dot = { .min = 25000, .max = 350000 },
99
	.dot = { .min = 25000, .max = 350000 },
149
        .vco = { .min = 930000, .max = 1400000 },
100
	.vco = { .min = 930000, .max = 1400000 },
150
        .n = { .min = 3, .max = 16 },
101
	.n = { .min = 3, .max = 16 },
151
        .m = { .min = 96, .max = 140 },
102
	.m = { .min = 96, .max = 140 },
152
        .m1 = { .min = 18, .max = 26 },
103
	.m1 = { .min = 18, .max = 26 },
153
        .m2 = { .min = 6, .max = 16 },
104
	.m2 = { .min = 6, .max = 16 },
154
        .p = { .min = 4, .max = 128 },
105
	.p = { .min = 4, .max = 128 },
-
 
106
	.p1 = { .min = 2, .max = 33 },
-
 
107
	.p2 = { .dot_limit = 165000,
-
 
108
		.p2_slow = 4, .p2_fast = 2 },
-
 
109
};
-
 
110
 
-
 
111
static const intel_limit_t intel_limits_i8xx_dvo = {
-
 
112
        .dot = { .min = 25000, .max = 350000 },
-
 
113
        .vco = { .min = 930000, .max = 1400000 },
-
 
114
        .n = { .min = 3, .max = 16 },
-
 
115
        .m = { .min = 96, .max = 140 },
-
 
116
        .m1 = { .min = 18, .max = 26 },
-
 
117
        .m2 = { .min = 6, .max = 16 },
155
        .p1 = { .min = 2, .max = 33 },
118
        .p = { .min = 4, .max = 128 },
156
	.p2 = { .dot_limit = 165000,
119
        .p1 = { .min = 2, .max = 33 },
Line 157... Line 120...
157
		.p2_slow = 4, .p2_fast = 2 },
120
	.p2 = { .dot_limit = 165000,
158
	.find_pll = intel_find_best_PLL,
121
		.p2_slow = 4, .p2_fast = 4 },
159
};
122
};
Line 167... Line 130...
167
        .m2 = { .min = 6, .max = 16 },
130
        .m2 = { .min = 6, .max = 16 },
168
        .p = { .min = 4, .max = 128 },
131
        .p = { .min = 4, .max = 128 },
169
        .p1 = { .min = 1, .max = 6 },
132
        .p1 = { .min = 1, .max = 6 },
170
	.p2 = { .dot_limit = 165000,
133
	.p2 = { .dot_limit = 165000,
171
		.p2_slow = 14, .p2_fast = 7 },
134
		.p2_slow = 14, .p2_fast = 7 },
172
	.find_pll = intel_find_best_PLL,
-
 
173
};
135
};
Line 174... Line 136...
174
 
136
 
175
static const intel_limit_t intel_limits_i9xx_sdvo = {
137
static const intel_limit_t intel_limits_i9xx_sdvo = {
176
        .dot = { .min = 20000, .max = 400000 },
138
        .dot = { .min = 20000, .max = 400000 },
Line 181... Line 143...
181
	.m2 = { .min = 3, .max = 7 },
143
	.m2 = { .min = 3, .max = 7 },
182
        .p = { .min = 5, .max = 80 },
144
        .p = { .min = 5, .max = 80 },
183
        .p1 = { .min = 1, .max = 8 },
145
        .p1 = { .min = 1, .max = 8 },
184
	.p2 = { .dot_limit = 200000,
146
	.p2 = { .dot_limit = 200000,
185
		.p2_slow = 10, .p2_fast = 5 },
147
		.p2_slow = 10, .p2_fast = 5 },
186
	.find_pll = intel_find_best_PLL,
-
 
187
};
148
};
Line 188... Line 149...
188
 
149
 
189
static const intel_limit_t intel_limits_i9xx_lvds = {
150
static const intel_limit_t intel_limits_i9xx_lvds = {
190
        .dot = { .min = 20000, .max = 400000 },
151
        .dot = { .min = 20000, .max = 400000 },
Line 195... Line 156...
195
	.m2 = { .min = 3, .max = 7 },
156
	.m2 = { .min = 3, .max = 7 },
196
        .p = { .min = 7, .max = 98 },
157
        .p = { .min = 7, .max = 98 },
197
        .p1 = { .min = 1, .max = 8 },
158
        .p1 = { .min = 1, .max = 8 },
198
	.p2 = { .dot_limit = 112000,
159
	.p2 = { .dot_limit = 112000,
199
		.p2_slow = 14, .p2_fast = 7 },
160
		.p2_slow = 14, .p2_fast = 7 },
200
	.find_pll = intel_find_best_PLL,
-
 
201
};
161
};
Line 202... Line 162...
202
 
162
 
203
 
163
 
Line 212... Line 172...
212
	.p1 = { .min = 1, .max = 3},
172
	.p1 = { .min = 1, .max = 3},
213
	.p2 = { .dot_limit = 270000,
173
	.p2 = { .dot_limit = 270000,
214
		.p2_slow = 10,
174
		.p2_slow = 10,
215
		.p2_fast = 10
175
		.p2_fast = 10
216
	},
176
	},
217
	.find_pll = intel_g4x_find_best_PLL,
-
 
218
};
177
};
Line 219... Line 178...
219
 
178
 
220
static const intel_limit_t intel_limits_g4x_hdmi = {
179
static const intel_limit_t intel_limits_g4x_hdmi = {
221
	.dot = { .min = 22000, .max = 400000 },
180
	.dot = { .min = 22000, .max = 400000 },
Line 226... Line 185...
226
	.m2 = { .min = 5, .max = 11 },
185
	.m2 = { .min = 5, .max = 11 },
227
	.p = { .min = 5, .max = 80 },
186
	.p = { .min = 5, .max = 80 },
228
	.p1 = { .min = 1, .max = 8},
187
	.p1 = { .min = 1, .max = 8},
229
	.p2 = { .dot_limit = 165000,
188
	.p2 = { .dot_limit = 165000,
230
		.p2_slow = 10, .p2_fast = 5 },
189
		.p2_slow = 10, .p2_fast = 5 },
231
	.find_pll = intel_g4x_find_best_PLL,
-
 
232
};
190
};
Line 233... Line 191...
233
 
191
 
234
static const intel_limit_t intel_limits_g4x_single_channel_lvds = {
192
static const intel_limit_t intel_limits_g4x_single_channel_lvds = {
235
	.dot = { .min = 20000, .max = 115000 },
193
	.dot = { .min = 20000, .max = 115000 },
Line 241... Line 199...
241
	.p = { .min = 28, .max = 112 },
199
	.p = { .min = 28, .max = 112 },
242
	.p1 = { .min = 2, .max = 8 },
200
	.p1 = { .min = 2, .max = 8 },
243
	.p2 = { .dot_limit = 0,
201
	.p2 = { .dot_limit = 0,
244
		.p2_slow = 14, .p2_fast = 14
202
		.p2_slow = 14, .p2_fast = 14
245
	},
203
	},
246
	.find_pll = intel_g4x_find_best_PLL,
-
 
247
};
204
};
Line 248... Line 205...
248
 
205
 
249
static const intel_limit_t intel_limits_g4x_dual_channel_lvds = {
206
static const intel_limit_t intel_limits_g4x_dual_channel_lvds = {
250
	.dot = { .min = 80000, .max = 224000 },
207
	.dot = { .min = 80000, .max = 224000 },
Line 256... Line 213...
256
	.p = { .min = 14, .max = 42 },
213
	.p = { .min = 14, .max = 42 },
257
	.p1 = { .min = 2, .max = 6 },
214
	.p1 = { .min = 2, .max = 6 },
258
	.p2 = { .dot_limit = 0,
215
	.p2 = { .dot_limit = 0,
259
		.p2_slow = 7, .p2_fast = 7
216
		.p2_slow = 7, .p2_fast = 7
260
	},
217
	},
261
	.find_pll = intel_g4x_find_best_PLL,
-
 
262
};
-
 
263
 
-
 
264
static const intel_limit_t intel_limits_g4x_display_port = {
-
 
265
        .dot = { .min = 161670, .max = 227000 },
-
 
266
        .vco = { .min = 1750000, .max = 3500000},
-
 
267
        .n = { .min = 1, .max = 2 },
-
 
268
        .m = { .min = 97, .max = 108 },
-
 
269
        .m1 = { .min = 0x10, .max = 0x12 },
-
 
270
        .m2 = { .min = 0x05, .max = 0x06 },
-
 
271
        .p = { .min = 10, .max = 20 },
-
 
272
        .p1 = { .min = 1, .max = 2},
-
 
273
        .p2 = { .dot_limit = 0,
-
 
274
		.p2_slow = 10, .p2_fast = 10 },
-
 
275
        .find_pll = intel_find_pll_g4x_dp,
-
 
276
};
218
};
Line 277... Line 219...
277
 
219
 
278
static const intel_limit_t intel_limits_pineview_sdvo = {
220
static const intel_limit_t intel_limits_pineview_sdvo = {
279
        .dot = { .min = 20000, .max = 400000},
221
        .dot = { .min = 20000, .max = 400000},
Line 286... Line 228...
286
        .m2 = { .min = 0, .max = 254 },
228
        .m2 = { .min = 0, .max = 254 },
287
        .p = { .min = 5, .max = 80 },
229
        .p = { .min = 5, .max = 80 },
288
        .p1 = { .min = 1, .max = 8 },
230
        .p1 = { .min = 1, .max = 8 },
289
	.p2 = { .dot_limit = 200000,
231
	.p2 = { .dot_limit = 200000,
290
		.p2_slow = 10, .p2_fast = 5 },
232
		.p2_slow = 10, .p2_fast = 5 },
291
	.find_pll = intel_find_best_PLL,
-
 
292
};
233
};
Line 293... Line 234...
293
 
234
 
294
static const intel_limit_t intel_limits_pineview_lvds = {
235
static const intel_limit_t intel_limits_pineview_lvds = {
295
        .dot = { .min = 20000, .max = 400000 },
236
        .dot = { .min = 20000, .max = 400000 },
Line 300... Line 241...
300
        .m2 = { .min = 0, .max = 254 },
241
        .m2 = { .min = 0, .max = 254 },
301
        .p = { .min = 7, .max = 112 },
242
        .p = { .min = 7, .max = 112 },
302
        .p1 = { .min = 1, .max = 8 },
243
        .p1 = { .min = 1, .max = 8 },
303
	.p2 = { .dot_limit = 112000,
244
	.p2 = { .dot_limit = 112000,
304
		.p2_slow = 14, .p2_fast = 14 },
245
		.p2_slow = 14, .p2_fast = 14 },
305
	.find_pll = intel_find_best_PLL,
-
 
306
};
246
};
Line 307... Line 247...
307
 
247
 
308
/* Ironlake / Sandybridge
248
/* Ironlake / Sandybridge
309
 *
249
 *
Line 319... Line 259...
319
	.m2 = { .min = 5, .max = 9 },
259
	.m2 = { .min = 5, .max = 9 },
320
	.p = { .min = 5, .max = 80 },
260
	.p = { .min = 5, .max = 80 },
321
	.p1 = { .min = 1, .max = 8 },
261
	.p1 = { .min = 1, .max = 8 },
322
	.p2 = { .dot_limit = 225000,
262
	.p2 = { .dot_limit = 225000,
323
		.p2_slow = 10, .p2_fast = 5 },
263
		.p2_slow = 10, .p2_fast = 5 },
324
	.find_pll = intel_g4x_find_best_PLL,
-
 
325
};
264
};
Line 326... Line 265...
326
 
265
 
327
static const intel_limit_t intel_limits_ironlake_single_lvds = {
266
static const intel_limit_t intel_limits_ironlake_single_lvds = {
328
	.dot = { .min = 25000, .max = 350000 },
267
	.dot = { .min = 25000, .max = 350000 },
Line 333... Line 272...
333
	.m2 = { .min = 5, .max = 9 },
272
	.m2 = { .min = 5, .max = 9 },
334
	.p = { .min = 28, .max = 112 },
273
	.p = { .min = 28, .max = 112 },
335
	.p1 = { .min = 2, .max = 8 },
274
	.p1 = { .min = 2, .max = 8 },
336
	.p2 = { .dot_limit = 225000,
275
	.p2 = { .dot_limit = 225000,
337
		.p2_slow = 14, .p2_fast = 14 },
276
		.p2_slow = 14, .p2_fast = 14 },
338
	.find_pll = intel_g4x_find_best_PLL,
-
 
339
};
277
};
Line 340... Line 278...
340
 
278
 
341
static const intel_limit_t intel_limits_ironlake_dual_lvds = {
279
static const intel_limit_t intel_limits_ironlake_dual_lvds = {
342
	.dot = { .min = 25000, .max = 350000 },
280
	.dot = { .min = 25000, .max = 350000 },
Line 347... Line 285...
347
	.m2 = { .min = 5, .max = 9 },
285
	.m2 = { .min = 5, .max = 9 },
348
	.p = { .min = 14, .max = 56 },
286
	.p = { .min = 14, .max = 56 },
349
	.p1 = { .min = 2, .max = 8 },
287
	.p1 = { .min = 2, .max = 8 },
350
	.p2 = { .dot_limit = 225000,
288
	.p2 = { .dot_limit = 225000,
351
		.p2_slow = 7, .p2_fast = 7 },
289
		.p2_slow = 7, .p2_fast = 7 },
352
	.find_pll = intel_g4x_find_best_PLL,
-
 
353
};
290
};
Line 354... Line 291...
354
 
291
 
355
/* LVDS 100mhz refclk limits. */
292
/* LVDS 100mhz refclk limits. */
356
static const intel_limit_t intel_limits_ironlake_single_lvds_100m = {
293
static const intel_limit_t intel_limits_ironlake_single_lvds_100m = {
Line 362... Line 299...
362
	.m2 = { .min = 5, .max = 9 },
299
	.m2 = { .min = 5, .max = 9 },
363
	.p = { .min = 28, .max = 112 },
300
	.p = { .min = 28, .max = 112 },
364
	.p1 = { .min = 2, .max = 8 },
301
	.p1 = { .min = 2, .max = 8 },
365
	.p2 = { .dot_limit = 225000,
302
	.p2 = { .dot_limit = 225000,
366
		.p2_slow = 14, .p2_fast = 14 },
303
		.p2_slow = 14, .p2_fast = 14 },
367
	.find_pll = intel_g4x_find_best_PLL,
-
 
368
};
304
};
Line 369... Line 305...
369
 
305
 
370
static const intel_limit_t intel_limits_ironlake_dual_lvds_100m = {
306
static const intel_limit_t intel_limits_ironlake_dual_lvds_100m = {
371
	.dot = { .min = 25000, .max = 350000 },
307
	.dot = { .min = 25000, .max = 350000 },
Line 376... Line 312...
376
	.m2 = { .min = 5, .max = 9 },
312
	.m2 = { .min = 5, .max = 9 },
377
	.p = { .min = 14, .max = 42 },
313
	.p = { .min = 14, .max = 42 },
378
	.p1 = { .min = 2, .max = 6 },
314
	.p1 = { .min = 2, .max = 6 },
379
	.p2 = { .dot_limit = 225000,
315
	.p2 = { .dot_limit = 225000,
380
		.p2_slow = 7, .p2_fast = 7 },
316
		.p2_slow = 7, .p2_fast = 7 },
381
	.find_pll = intel_g4x_find_best_PLL,
-
 
382
};
-
 
383
 
-
 
384
static const intel_limit_t intel_limits_ironlake_display_port = {
-
 
385
        .dot = { .min = 25000, .max = 350000 },
-
 
386
        .vco = { .min = 1760000, .max = 3510000},
-
 
387
        .n = { .min = 1, .max = 2 },
-
 
388
        .m = { .min = 81, .max = 90 },
-
 
389
        .m1 = { .min = 12, .max = 22 },
-
 
390
        .m2 = { .min = 5, .max = 9 },
-
 
391
        .p = { .min = 10, .max = 20 },
-
 
392
        .p1 = { .min = 1, .max = 2},
-
 
393
        .p2 = { .dot_limit = 0,
-
 
394
		.p2_slow = 10, .p2_fast = 10 },
-
 
395
        .find_pll = intel_find_pll_ironlake_dp,
-
 
396
};
317
};
Line 397... Line 318...
397
 
318
 
398
static const intel_limit_t intel_limits_vlv_dac = {
319
static const intel_limit_t intel_limits_vlv_dac = {
399
	.dot = { .min = 25000, .max = 270000 },
320
	.dot = { .min = 25000, .max = 270000 },
400
	.vco = { .min = 4000000, .max = 6000000 },
321
	.vco = { .min = 4000000, .max = 6000000 },
401
	.n = { .min = 1, .max = 7 },
322
	.n = { .min = 1, .max = 7 },
402
	.m = { .min = 22, .max = 450 }, /* guess */
323
	.m = { .min = 22, .max = 450 }, /* guess */
403
	.m1 = { .min = 2, .max = 3 },
324
	.m1 = { .min = 2, .max = 3 },
404
	.m2 = { .min = 11, .max = 156 },
325
	.m2 = { .min = 11, .max = 156 },
405
	.p = { .min = 10, .max = 30 },
326
	.p = { .min = 10, .max = 30 },
406
	.p1 = { .min = 2, .max = 3 },
327
	.p1 = { .min = 1, .max = 3 },
407
	.p2 = { .dot_limit = 270000,
328
	.p2 = { .dot_limit = 270000,
408
		.p2_slow = 2, .p2_fast = 20 },
-
 
409
	.find_pll = intel_vlv_find_best_pll,
329
		.p2_slow = 2, .p2_fast = 20 },
Line 410... Line 330...
410
};
330
};
411
 
331
 
412
static const intel_limit_t intel_limits_vlv_hdmi = {
332
static const intel_limit_t intel_limits_vlv_hdmi = {
413
	.dot = { .min = 20000, .max = 165000 },
333
	.dot = { .min = 25000, .max = 270000 },
414
	.vco = { .min = 4000000, .max = 5994000},
334
	.vco = { .min = 4000000, .max = 6000000 },
415
	.n = { .min = 1, .max = 7 },
335
	.n = { .min = 1, .max = 7 },
416
	.m = { .min = 60, .max = 300 }, /* guess */
336
	.m = { .min = 60, .max = 300 }, /* guess */
417
	.m1 = { .min = 2, .max = 3 },
337
	.m1 = { .min = 2, .max = 3 },
418
	.m2 = { .min = 11, .max = 156 },
338
	.m2 = { .min = 11, .max = 156 },
419
	.p = { .min = 10, .max = 30 },
339
	.p = { .min = 10, .max = 30 },
420
	.p1 = { .min = 2, .max = 3 },
340
	.p1 = { .min = 2, .max = 3 },
421
	.p2 = { .dot_limit = 270000,
-
 
422
		.p2_slow = 2, .p2_fast = 20 },
341
	.p2 = { .dot_limit = 270000,
Line 423... Line 342...
423
	.find_pll = intel_vlv_find_best_pll,
342
		.p2_slow = 2, .p2_fast = 20 },
424
};
343
};
425
 
344
 
426
static const intel_limit_t intel_limits_vlv_dp = {
345
static const intel_limit_t intel_limits_vlv_dp = {
427
	.dot = { .min = 25000, .max = 270000 },
346
	.dot = { .min = 25000, .max = 270000 },
428
	.vco = { .min = 4000000, .max = 6000000 },
347
	.vco = { .min = 4000000, .max = 6000000 },
429
	.n = { .min = 1, .max = 7 },
348
	.n = { .min = 1, .max = 7 },
430
	.m = { .min = 22, .max = 450 },
349
	.m = { .min = 22, .max = 450 },
431
	.m1 = { .min = 2, .max = 3 },
350
	.m1 = { .min = 2, .max = 3 },
432
	.m2 = { .min = 11, .max = 156 },
351
	.m2 = { .min = 11, .max = 156 },
433
	.p = { .min = 10, .max = 30 },
352
	.p = { .min = 10, .max = 30 },
434
	.p1 = { .min = 2, .max = 3 },
-
 
435
	.p2 = { .dot_limit = 270000,
353
	.p1 = { .min = 1, .max = 3 },
Line 436... Line -...
436
		.p2_slow = 2, .p2_fast = 20 },
-
 
437
	.find_pll = intel_vlv_find_best_pll,
-
 
438
};
-
 
439
 
-
 
440
u32 intel_dpio_read(struct drm_i915_private *dev_priv, int reg)
-
 
441
{
-
 
442
	WARN_ON(!mutex_is_locked(&dev_priv->dpio_lock));
-
 
443
 
-
 
444
	if (wait_for_atomic_us((I915_READ(DPIO_PKT) & DPIO_BUSY) == 0, 100)) {
-
 
445
		DRM_ERROR("DPIO idle wait timed out\n");
-
 
446
		return 0;
-
 
447
	}
-
 
448
 
-
 
449
	I915_WRITE(DPIO_REG, reg);
-
 
450
	I915_WRITE(DPIO_PKT, DPIO_RID | DPIO_OP_READ | DPIO_PORTID |
-
 
451
		   DPIO_BYTE);
-
 
452
	if (wait_for_atomic_us((I915_READ(DPIO_PKT) & DPIO_BUSY) == 0, 100)) {
-
 
453
		DRM_ERROR("DPIO read wait timed out\n");
-
 
454
		return 0;
-
 
455
	}
-
 
456
 
-
 
457
	return I915_READ(DPIO_DATA);
-
 
458
}
-
 
459
 
-
 
460
static void intel_dpio_write(struct drm_i915_private *dev_priv, int reg,
-
 
461
			     u32 val)
-
 
462
{
-
 
463
	WARN_ON(!mutex_is_locked(&dev_priv->dpio_lock));
-
 
464
 
-
 
465
	if (wait_for_atomic_us((I915_READ(DPIO_PKT) & DPIO_BUSY) == 0, 100)) {
-
 
466
		DRM_ERROR("DPIO idle wait timed out\n");
-
 
467
		return;
-
 
468
	}
-
 
469
 
-
 
470
	I915_WRITE(DPIO_DATA, val);
-
 
471
	I915_WRITE(DPIO_REG, reg);
-
 
472
	I915_WRITE(DPIO_PKT, DPIO_RID | DPIO_OP_WRITE | DPIO_PORTID |
-
 
473
		   DPIO_BYTE);
-
 
474
	if (wait_for_atomic_us((I915_READ(DPIO_PKT) & DPIO_BUSY) == 0, 100))
-
 
475
		DRM_ERROR("DPIO write wait timed out\n");
-
 
476
}
-
 
477
 
-
 
478
static void vlv_init_dpio(struct drm_device *dev)
-
 
479
{
-
 
480
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
481
 
-
 
482
	/* Reset the DPIO config */
-
 
483
	I915_WRITE(DPIO_CTL, 0);
-
 
484
	POSTING_READ(DPIO_CTL);
-
 
485
	I915_WRITE(DPIO_CTL, 1);
354
	.p2 = { .dot_limit = 270000,
486
	POSTING_READ(DPIO_CTL);
355
		.p2_slow = 2, .p2_fast = 20 },
487
}
356
};
488
 
357
 
489
static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc,
358
static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc,
Line 502... Line 371...
502
			if (refclk == 100000)
371
			if (refclk == 100000)
503
				limit = &intel_limits_ironlake_single_lvds_100m;
372
				limit = &intel_limits_ironlake_single_lvds_100m;
504
			else
373
			else
505
				limit = &intel_limits_ironlake_single_lvds;
374
				limit = &intel_limits_ironlake_single_lvds;
506
		}
375
		}
507
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT) ||
-
 
508
		   intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))
-
 
509
		limit = &intel_limits_ironlake_display_port;
-
 
510
	else
376
	} else
511
		limit = &intel_limits_ironlake_dac;
377
		limit = &intel_limits_ironlake_dac;
Line 512... Line 378...
512
 
378
 
513
	return limit;
379
	return limit;
Line 526... Line 392...
526
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) ||
392
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) ||
527
		   intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) {
393
		   intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) {
528
		limit = &intel_limits_g4x_hdmi;
394
		limit = &intel_limits_g4x_hdmi;
529
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) {
395
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) {
530
		limit = &intel_limits_g4x_sdvo;
396
		limit = &intel_limits_g4x_sdvo;
531
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
-
 
532
		limit = &intel_limits_g4x_display_port;
-
 
533
	} else /* The option is for other outputs */
397
	} else /* The option is for other outputs */
534
		limit = &intel_limits_i9xx_sdvo;
398
		limit = &intel_limits_i9xx_sdvo;
Line 535... Line 399...
535
 
399
 
536
	return limit;
400
	return limit;
Line 563... Line 427...
563
		else
427
		else
564
			limit = &intel_limits_i9xx_sdvo;
428
			limit = &intel_limits_i9xx_sdvo;
565
	} else {
429
	} else {
566
		if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
430
		if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
567
			limit = &intel_limits_i8xx_lvds;
431
			limit = &intel_limits_i8xx_lvds;
568
		else
432
		else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO))
569
			limit = &intel_limits_i8xx_dvo;
433
			limit = &intel_limits_i8xx_dvo;
-
 
434
		else
-
 
435
			limit = &intel_limits_i8xx_dac;
570
	}
436
	}
571
	return limit;
437
	return limit;
572
}
438
}
Line 573... Line 439...
573
 
439
 
Line 578... Line 444...
578
	clock->p = clock->p1 * clock->p2;
444
	clock->p = clock->p1 * clock->p2;
579
	clock->vco = refclk * clock->m / clock->n;
445
	clock->vco = refclk * clock->m / clock->n;
580
	clock->dot = clock->vco / clock->p;
446
	clock->dot = clock->vco / clock->p;
581
}
447
}
Line 582... Line 448...
582
 
448
 
583
static void intel_clock(struct drm_device *dev, int refclk, intel_clock_t *clock)
449
static uint32_t i9xx_dpll_compute_m(struct dpll *dpll)
584
{
-
 
585
	if (IS_PINEVIEW(dev)) {
450
{
586
		pineview_clock(refclk, clock);
-
 
587
		return;
451
	return 5 * (dpll->m1 + 2) + (dpll->m2 + 2);
-
 
452
}
-
 
453
 
-
 
454
static void i9xx_clock(int refclk, intel_clock_t *clock)
588
	}
455
{
589
	clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
456
	clock->m = i9xx_dpll_compute_m(clock);
590
	clock->p = clock->p1 * clock->p2;
457
	clock->p = clock->p1 * clock->p2;
591
	clock->vco = refclk * clock->m / (clock->n + 2);
458
	clock->vco = refclk * clock->m / (clock->n + 2);
592
	clock->dot = clock->vco / clock->p;
459
	clock->dot = clock->vco / clock->p;
Line 641... Line 508...
641
 
508
 
642
	return true;
509
	return true;
Line 643... Line 510...
643
}
510
}
644
 
511
 
645
static bool
512
static bool
646
intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
513
i9xx_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc,
647
		    int target, int refclk, intel_clock_t *match_clock,
-
 
648
		    intel_clock_t *best_clock)
514
		    int target, int refclk, intel_clock_t *match_clock,
649
 
515
		    intel_clock_t *best_clock)
650
{
516
{
651
	struct drm_device *dev = crtc->dev;
517
	struct drm_device *dev = crtc->dev;
Line 673... Line 539...
673
 
539
 
674
	for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
540
	for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
675
	     clock.m1++) {
541
	     clock.m1++) {
676
		for (clock.m2 = limit->m2.min;
542
		for (clock.m2 = limit->m2.min;
677
		     clock.m2 <= limit->m2.max; clock.m2++) {
-
 
678
			/* m1 is always 0 in Pineview */
543
		     clock.m2 <= limit->m2.max; clock.m2++) {
679
			if (clock.m2 >= clock.m1 && !IS_PINEVIEW(dev))
544
			if (clock.m2 >= clock.m1)
680
				break;
545
				break;
681
			for (clock.n = limit->n.min;
546
			for (clock.n = limit->n.min;
682
			     clock.n <= limit->n.max; clock.n++) {
547
			     clock.n <= limit->n.max; clock.n++) {
683
				for (clock.p1 = limit->p1.min;
548
				for (clock.p1 = limit->p1.min;
684
					clock.p1 <= limit->p1.max; clock.p1++) {
549
					clock.p1 <= limit->p1.max; clock.p1++) {
Line 685... Line 550...
685
					int this_err;
550
					int this_err;
686
 
551
 
687
					intel_clock(dev, refclk, &clock);
552
					i9xx_clock(refclk, &clock);
688
					if (!intel_PLL_is_valid(dev, limit,
553
					if (!intel_PLL_is_valid(dev, limit,
689
								&clock))
554
								&clock))
690
						continue;
555
						continue;
Line 704... Line 569...
704
 
569
 
705
	return (err != target);
570
	return (err != target);
Line 706... Line 571...
706
}
571
}
-
 
572
 
-
 
573
static bool
-
 
574
pnv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
575
		   int target, int refclk, intel_clock_t *match_clock,
-
 
576
		   intel_clock_t *best_clock)
-
 
577
{
-
 
578
	struct drm_device *dev = crtc->dev;
-
 
579
	intel_clock_t clock;
-
 
580
	int err = target;
-
 
581
 
-
 
582
	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
-
 
583
		/*
-
 
584
		 * For LVDS just rely on its current settings for dual-channel.
-
 
585
		 * We haven't figured out how to reliably set up different
-
 
586
		 * single/dual channel state, if we even can.
-
 
587
		 */
-
 
588
		if (intel_is_dual_link_lvds(dev))
-
 
589
			clock.p2 = limit->p2.p2_fast;
-
 
590
		else
-
 
591
			clock.p2 = limit->p2.p2_slow;
-
 
592
	} else {
-
 
593
		if (target < limit->p2.dot_limit)
-
 
594
			clock.p2 = limit->p2.p2_slow;
-
 
595
		else
-
 
596
			clock.p2 = limit->p2.p2_fast;
-
 
597
	}
-
 
598
 
-
 
599
	memset(best_clock, 0, sizeof(*best_clock));
-
 
600
 
-
 
601
	for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
-
 
602
	     clock.m1++) {
-
 
603
		for (clock.m2 = limit->m2.min;
-
 
604
		     clock.m2 <= limit->m2.max; clock.m2++) {
-
 
605
			for (clock.n = limit->n.min;
-
 
606
			     clock.n <= limit->n.max; clock.n++) {
-
 
607
				for (clock.p1 = limit->p1.min;
-
 
608
					clock.p1 <= limit->p1.max; clock.p1++) {
-
 
609
					int this_err;
-
 
610
 
-
 
611
					pineview_clock(refclk, &clock);
-
 
612
					if (!intel_PLL_is_valid(dev, limit,
-
 
613
								&clock))
-
 
614
						continue;
-
 
615
					if (match_clock &&
-
 
616
					    clock.p != match_clock->p)
-
 
617
						continue;
-
 
618
 
-
 
619
					this_err = abs(clock.dot - target);
-
 
620
					if (this_err < err) {
-
 
621
						*best_clock = clock;
-
 
622
						err = this_err;
-
 
623
					}
-
 
624
				}
-
 
625
			}
-
 
626
		}
-
 
627
	}
-
 
628
 
-
 
629
	return (err != target);
-
 
630
}
707
 
631
 
708
static bool
632
static bool
709
intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
633
g4x_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc,
710
			int target, int refclk, intel_clock_t *match_clock,
634
			int target, int refclk, intel_clock_t *match_clock,
711
			intel_clock_t *best_clock)
635
			intel_clock_t *best_clock)
712
{
636
{
Line 717... Line 641...
717
	/* approximately equals target * 0.00585 */
641
	/* approximately equals target * 0.00585 */
718
	int err_most = (target >> 8) + (target >> 9);
642
	int err_most = (target >> 8) + (target >> 9);
719
	found = false;
643
	found = false;
Line 720... Line 644...
720
 
644
 
721
	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
-
 
722
		int lvds_reg;
-
 
723
 
-
 
724
		if (HAS_PCH_SPLIT(dev))
-
 
725
			lvds_reg = PCH_LVDS;
-
 
726
		else
-
 
727
			lvds_reg = LVDS;
645
	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
728
		if (intel_is_dual_link_lvds(dev))
646
		if (intel_is_dual_link_lvds(dev))
729
			clock.p2 = limit->p2.p2_fast;
647
			clock.p2 = limit->p2.p2_fast;
730
		else
648
		else
731
			clock.p2 = limit->p2.p2_slow;
649
			clock.p2 = limit->p2.p2_slow;
Line 747... Line 665...
747
			     clock.m2 >= limit->m2.min; clock.m2--) {
665
			     clock.m2 >= limit->m2.min; clock.m2--) {
748
				for (clock.p1 = limit->p1.max;
666
				for (clock.p1 = limit->p1.max;
749
				     clock.p1 >= limit->p1.min; clock.p1--) {
667
				     clock.p1 >= limit->p1.min; clock.p1--) {
750
					int this_err;
668
					int this_err;
Line 751... Line 669...
751
 
669
 
752
					intel_clock(dev, refclk, &clock);
670
					i9xx_clock(refclk, &clock);
753
					if (!intel_PLL_is_valid(dev, limit,
671
					if (!intel_PLL_is_valid(dev, limit,
754
								&clock))
672
								&clock))
755
						continue;
-
 
756
					if (match_clock &&
-
 
757
					    clock.p != match_clock->p)
-
 
Line 758... Line 673...
758
						continue;
673
						continue;
759
 
674
 
760
					this_err = abs(clock.dot - target);
675
					this_err = abs(clock.dot - target);
761
					if (this_err < err_most) {
676
					if (this_err < err_most) {
Line 770... Line 685...
770
	}
685
	}
771
	return found;
686
	return found;
772
}
687
}
Line 773... Line 688...
773
 
688
 
774
static bool
-
 
775
intel_find_pll_ironlake_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
776
			   int target, int refclk, intel_clock_t *match_clock,
-
 
777
			   intel_clock_t *best_clock)
-
 
778
{
-
 
779
	struct drm_device *dev = crtc->dev;
-
 
780
	intel_clock_t clock;
-
 
781
 
-
 
782
	if (target < 200000) {
-
 
783
		clock.n = 1;
-
 
784
		clock.p1 = 2;
-
 
785
		clock.p2 = 10;
-
 
786
		clock.m1 = 12;
-
 
787
		clock.m2 = 9;
-
 
788
	} else {
-
 
789
		clock.n = 2;
-
 
790
		clock.p1 = 1;
-
 
791
		clock.p2 = 10;
-
 
792
		clock.m1 = 14;
-
 
793
		clock.m2 = 8;
-
 
794
	}
-
 
795
	intel_clock(dev, refclk, &clock);
-
 
796
	memcpy(best_clock, &clock, sizeof(intel_clock_t));
-
 
797
	return true;
-
 
798
}
-
 
799
 
-
 
800
/* DisplayPort has only two frequencies, 162MHz and 270MHz */
-
 
801
static bool
-
 
802
intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
-
 
803
		      int target, int refclk, intel_clock_t *match_clock,
-
 
804
		      intel_clock_t *best_clock)
-
 
805
{
-
 
806
	intel_clock_t clock;
-
 
807
	if (target < 200000) {
-
 
808
		clock.p1 = 2;
-
 
809
		clock.p2 = 10;
-
 
810
		clock.n = 2;
-
 
811
		clock.m1 = 23;
-
 
812
		clock.m2 = 8;
-
 
813
	} else {
-
 
814
		clock.p1 = 1;
-
 
815
		clock.p2 = 10;
-
 
816
		clock.n = 1;
-
 
817
		clock.m1 = 14;
-
 
818
		clock.m2 = 2;
-
 
819
	}
-
 
820
	clock.m = 5 * (clock.m1 + 2) + (clock.m2 + 2);
-
 
821
	clock.p = (clock.p1 * clock.p2);
-
 
822
	clock.dot = 96000 * clock.m / (clock.n + 2) / clock.p;
-
 
823
	clock.vco = 0;
-
 
824
	memcpy(best_clock, &clock, sizeof(intel_clock_t));
-
 
825
	return true;
-
 
826
}
-
 
827
static bool
689
static bool
828
intel_vlv_find_best_pll(const intel_limit_t *limit, struct drm_crtc *crtc,
690
vlv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc,
829
			int target, int refclk, intel_clock_t *match_clock,
691
			int target, int refclk, intel_clock_t *match_clock,
830
			intel_clock_t *best_clock)
692
			intel_clock_t *best_clock)
831
{
693
{
832
	u32 p1, p2, m1, m2, vco, bestn, bestm1, bestm2, bestp1, bestp2;
694
	u32 p1, p2, m1, m2, vco, bestn, bestm1, bestm2, bestp1, bestp2;
833
	u32 m, n, fastclk;
695
	u32 m, n, fastclk;
834
	u32 updrate, minupdate, fracbits, p;
696
	u32 updrate, minupdate, p;
835
	unsigned long bestppm, ppm, absppm;
697
	unsigned long bestppm, ppm, absppm;
Line 836... Line 698...
836
	int dotclk, flag;
698
	int dotclk, flag;
837
 
699
 
838
	flag = 0;
700
	flag = 0;
839
	dotclk = target * 1000;
701
	dotclk = target * 1000;
840
	bestppm = 1000000;
702
	bestppm = 1000000;
841
	ppm = absppm = 0;
703
	ppm = absppm = 0;
842
	fastclk = dotclk / (2*100);
704
	fastclk = dotclk / (2*100);
843
	updrate = 0;
-
 
844
	minupdate = 19200;
705
	updrate = 0;
845
	fracbits = 1;
706
	minupdate = 19200;
Line 846... Line 707...
846
	n = p = p1 = p2 = m = m1 = m2 = vco = bestn = 0;
707
	n = p = p1 = p2 = m = m1 = m2 = vco = bestn = 0;
847
	bestm1 = bestm2 = bestp1 = bestp2 = 0;
708
	bestm1 = bestm2 = bestp1 = bestp2 = 0;
Line 1054... Line 915...
1054
{
915
{
1055
	return enabled ? "on" : "off";
916
	return enabled ? "on" : "off";
1056
}
917
}
Line 1057... Line 918...
1057
 
918
 
1058
/* Only for pre-ILK configs */
919
/* Only for pre-ILK configs */
1059
static void assert_pll(struct drm_i915_private *dev_priv,
920
void assert_pll(struct drm_i915_private *dev_priv,
1060
		       enum pipe pipe, bool state)
921
		       enum pipe pipe, bool state)
1061
{
922
{
1062
	int reg;
923
	int reg;
1063
	u32 val;
924
	u32 val;
Line 1068... Line 929...
1068
	cur_state = !!(val & DPLL_VCO_ENABLE);
929
	cur_state = !!(val & DPLL_VCO_ENABLE);
1069
	WARN(cur_state != state,
930
	WARN(cur_state != state,
1070
	     "PLL state assertion failure (expected %s, current %s)\n",
931
	     "PLL state assertion failure (expected %s, current %s)\n",
1071
	     state_string(state), state_string(cur_state));
932
	     state_string(state), state_string(cur_state));
1072
}
933
}
-
 
934
 
-
 
935
struct intel_shared_dpll *
1073
#define assert_pll_enabled(d, p) assert_pll(d, p, true)
936
intel_crtc_to_shared_dpll(struct intel_crtc *crtc)
-
 
937
{
-
 
938
	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-
 
939
 
-
 
940
	if (crtc->config.shared_dpll < 0)
-
 
941
		return NULL;
-
 
942
 
1074
#define assert_pll_disabled(d, p) assert_pll(d, p, false)
943
	return &dev_priv->shared_dplls[crtc->config.shared_dpll];
-
 
944
}
Line 1075... Line 945...
1075
 
945
 
1076
/* For ILK+ */
946
/* For ILK+ */
1077
static void assert_pch_pll(struct drm_i915_private *dev_priv,
947
void assert_shared_dpll(struct drm_i915_private *dev_priv,
1078
			   struct intel_pch_pll *pll,
-
 
1079
			   struct intel_crtc *crtc,
948
			       struct intel_shared_dpll *pll,
1080
			   bool state)
949
			   bool state)
1081
{
-
 
1082
	u32 val;
950
{
-
 
951
	bool cur_state;
Line 1083... Line 952...
1083
	bool cur_state;
952
	struct intel_dpll_hw_state hw_state;
1084
 
953
 
1085
	if (HAS_PCH_LPT(dev_priv->dev)) {
954
	if (HAS_PCH_LPT(dev_priv->dev)) {
1086
		DRM_DEBUG_DRIVER("LPT detected: skipping PCH PLL test\n");
955
		DRM_DEBUG_DRIVER("LPT detected: skipping PCH PLL test\n");
Line 1087... Line 956...
1087
		return;
956
		return;
1088
	}
957
	}
1089
 
958
 
Line 1090... Line -...
1090
	if (WARN (!pll,
-
 
1091
		  "asserting PCH PLL %s with no PLL\n", state_string(state)))
959
	if (WARN (!pll,
1092
		return;
960
		  "asserting DPLL %s with no DPLL\n", state_string(state)))
1093
 
961
		return;
1094
	val = I915_READ(pll->pll_reg);
962
 
1095
	cur_state = !!(val & DPLL_VCO_ENABLE);
-
 
1096
	WARN(cur_state != state,
-
 
1097
	     "PCH PLL state for reg %x assertion failure (expected %s, current %s), val=%08x\n",
-
 
1098
	     pll->pll_reg, state_string(state), state_string(cur_state), val);
-
 
1099
 
-
 
1100
	/* Make sure the selected PLL is correctly attached to the transcoder */
-
 
1101
	if (crtc && HAS_PCH_CPT(dev_priv->dev)) {
-
 
1102
		u32 pch_dpll;
-
 
1103
 
-
 
1104
		pch_dpll = I915_READ(PCH_DPLL_SEL);
-
 
1105
		cur_state = pll->pll_reg == _PCH_DPLL_B;
-
 
1106
		if (!WARN(((pch_dpll >> (4 * crtc->pipe)) & 1) != cur_state,
-
 
1107
			  "PLL[%d] not attached to this transcoder %d: %08x\n",
-
 
1108
			  cur_state, crtc->pipe, pch_dpll)) {
-
 
1109
			cur_state = !!(val >> (4*crtc->pipe + 3));
-
 
1110
	WARN(cur_state != state,
-
 
1111
			     "PLL[%d] not %s on this transcoder %d: %08x\n",
-
 
1112
			     pll->pll_reg == _PCH_DPLL_B,
-
 
1113
			     state_string(state),
-
 
1114
			     crtc->pipe,
963
	cur_state = pll->get_hw_state(dev_priv, pll, &hw_state);
1115
			     val);
-
 
1116
		}
-
 
Line 1117... Line 964...
1117
	}
964
	WARN(cur_state != state,
1118
}
965
	     "%s assertion failure (expected %s, current %s)\n",
1119
#define assert_pch_pll_enabled(d, p, c) assert_pch_pll(d, p, c, true)
966
	     pll->name, state_string(state), state_string(cur_state));
1120
#define assert_pch_pll_disabled(d, p, c) assert_pch_pll(d, p, c, false)
967
}
Line 1179... Line 1026...
1179
	reg = FDI_TX_CTL(pipe);
1026
	reg = FDI_TX_CTL(pipe);
1180
	val = I915_READ(reg);
1027
	val = I915_READ(reg);
1181
	WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n");
1028
	WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n");
1182
}
1029
}
Line 1183... Line 1030...
1183
 
1030
 
1184
static void assert_fdi_rx_pll_enabled(struct drm_i915_private *dev_priv,
1031
void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
1185
				      enum pipe pipe)
1032
		       enum pipe pipe, bool state)
1186
{
1033
{
1187
	int reg;
1034
	int reg;
-
 
1035
	u32 val;
Line 1188... Line 1036...
1188
	u32 val;
1036
	bool cur_state;
1189
 
1037
 
-
 
1038
	reg = FDI_RX_CTL(pipe);
-
 
1039
	val = I915_READ(reg);
1190
	reg = FDI_RX_CTL(pipe);
1040
	cur_state = !!(val & FDI_RX_PLL_ENABLE);
-
 
1041
	WARN(cur_state != state,
1191
	val = I915_READ(reg);
1042
	     "FDI RX PLL assertion failure (expected %s, current %s)\n",
Line 1192... Line 1043...
1192
	WARN(!(val & FDI_RX_PLL_ENABLE), "FDI RX PLL assertion failure, should be active but is disabled\n");
1043
	     state_string(state), state_string(cur_state));
1193
}
1044
}
1194
 
1045
 
Line 1232... Line 1083...
1232
 
1083
 
1233
	/* if we need the pipe A quirk it must be always on */
1084
	/* if we need the pipe A quirk it must be always on */
1234
	if (pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE)
1085
	if (pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE)
Line 1235... Line 1086...
1235
		state = true;
1086
		state = true;
1236
 
1087
 
1237
	if (!intel_using_power_well(dev_priv->dev) &&
1088
	if (!intel_display_power_enabled(dev_priv->dev,
1238
	    cpu_transcoder != TRANSCODER_EDP) {
1089
				POWER_DOMAIN_TRANSCODER(cpu_transcoder))) {
1239
		cur_state = false;
1090
		cur_state = false;
1240
	} else {
1091
	} else {
1241
	reg = PIPECONF(cpu_transcoder);
1092
	reg = PIPECONF(cpu_transcoder);
Line 1267... Line 1118...
1267
#define assert_plane_disabled(d, p) assert_plane(d, p, false)
1118
#define assert_plane_disabled(d, p) assert_plane(d, p, false)
Line 1268... Line 1119...
1268
 
1119
 
1269
static void assert_planes_disabled(struct drm_i915_private *dev_priv,
1120
static void assert_planes_disabled(struct drm_i915_private *dev_priv,
1270
				   enum pipe pipe)
1121
				   enum pipe pipe)
-
 
1122
{
1271
{
1123
	struct drm_device *dev = dev_priv->dev;
1272
	int reg, i;
1124
	int reg, i;
1273
	u32 val;
1125
	u32 val;
Line 1274... Line 1126...
1274
	int cur_pipe;
1126
	int cur_pipe;
1275
 
1127
 
1276
	/* Planes are fixed to pipes on ILK+ */
1128
	/* Primary planes are fixed to pipes on gen4+ */
1277
	if (HAS_PCH_SPLIT(dev_priv->dev) || IS_VALLEYVIEW(dev_priv->dev)) {
1129
	if (INTEL_INFO(dev)->gen >= 4) {
1278
		reg = DSPCNTR(pipe);
1130
		reg = DSPCNTR(pipe);
1279
		val = I915_READ(reg);
1131
		val = I915_READ(reg);
1280
		WARN((val & DISPLAY_PLANE_ENABLE),
1132
		WARN((val & DISPLAY_PLANE_ENABLE),
1281
		     "plane %c assertion failure, should be disabled but not\n",
1133
		     "plane %c assertion failure, should be disabled but not\n",
1282
		     plane_name(pipe));
1134
		     plane_name(pipe));
Line 1283... Line 1135...
1283
		return;
1135
		return;
1284
	}
1136
	}
1285
 
1137
 
1286
	/* Need to check both planes against the pipe */
1138
	/* Need to check both planes against the pipe */
1287
	for (i = 0; i < 2; i++) {
1139
	for_each_pipe(i) {
1288
		reg = DSPCNTR(i);
1140
		reg = DSPCNTR(i);
1289
		val = I915_READ(reg);
1141
		val = I915_READ(reg);
Line 1296... Line 1148...
1296
}
1148
}
Line 1297... Line 1149...
1297
 
1149
 
1298
static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
1150
static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
1299
				    enum pipe pipe)
1151
				    enum pipe pipe)
-
 
1152
{
1300
{
1153
	struct drm_device *dev = dev_priv->dev;
1301
	int reg, i;
1154
	int reg, i;
Line 1302... Line 1155...
1302
	u32 val;
1155
	u32 val;
1303
 
-
 
1304
	if (!IS_VALLEYVIEW(dev_priv->dev))
-
 
1305
		return;
-
 
1306
 
1156
 
1307
	/* Need to check both planes against the pipe */
1157
	if (IS_VALLEYVIEW(dev)) {
1308
	for (i = 0; i < dev_priv->num_plane; i++) {
1158
	for (i = 0; i < dev_priv->num_plane; i++) {
1309
		reg = SPCNTR(pipe, i);
1159
		reg = SPCNTR(pipe, i);
-
 
1160
		val = I915_READ(reg);
-
 
1161
		WARN((val & SP_ENABLE),
-
 
1162
			     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
-
 
1163
			     sprite_name(pipe, i), pipe_name(pipe));
-
 
1164
		}
-
 
1165
	} else if (INTEL_INFO(dev)->gen >= 7) {
-
 
1166
		reg = SPRCTL(pipe);
1310
		val = I915_READ(reg);
1167
		val = I915_READ(reg);
-
 
1168
		WARN((val & SPRITE_ENABLE),
-
 
1169
		     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
-
 
1170
		     plane_name(pipe), pipe_name(pipe));
-
 
1171
	} else if (INTEL_INFO(dev)->gen >= 5) {
-
 
1172
		reg = DVSCNTR(pipe);
-
 
1173
		val = I915_READ(reg);
1311
		WARN((val & SP_ENABLE),
1174
		WARN((val & DVS_ENABLE),
1312
		     "sprite %d assertion failure, should be off on pipe %c but is still active\n",
1175
		     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
1313
		     pipe * 2 + i, pipe_name(pipe));
1176
		     plane_name(pipe), pipe_name(pipe));
Line 1314... Line 1177...
1314
	}
1177
	}
1315
}
1178
}
Line 1328... Line 1191...
1328
	enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
1191
	enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
1329
			    DREF_SUPERSPREAD_SOURCE_MASK));
1192
			    DREF_SUPERSPREAD_SOURCE_MASK));
1330
	WARN(!enabled, "PCH refclk assertion failure, should be active but is disabled\n");
1193
	WARN(!enabled, "PCH refclk assertion failure, should be active but is disabled\n");
1331
}
1194
}
Line 1332... Line 1195...
1332
 
1195
 
1333
static void assert_transcoder_disabled(struct drm_i915_private *dev_priv,
1196
static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
1334
				       enum pipe pipe)
1197
				       enum pipe pipe)
1335
{
1198
{
1336
	int reg;
1199
	int reg;
1337
	u32 val;
1200
	u32 val;
Line 1338... Line 1201...
1338
	bool enabled;
1201
	bool enabled;
1339
 
1202
 
1340
	reg = TRANSCONF(pipe);
1203
	reg = PCH_TRANSCONF(pipe);
1341
	val = I915_READ(reg);
1204
	val = I915_READ(reg);
1342
	enabled = !!(val & TRANS_ENABLE);
1205
	enabled = !!(val & TRANS_ENABLE);
1343
	WARN(enabled,
1206
	WARN(enabled,
Line 1461... Line 1324...
1461
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMIB);
1324
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMIB);
1462
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMIC);
1325
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMIC);
1463
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID);
1326
	assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID);
1464
}
1327
}
Line 1465... Line -...
1465
 
-
 
1466
/**
-
 
1467
 * intel_enable_pll - enable a PLL
-
 
1468
 * @dev_priv: i915 private structure
-
 
1469
 * @pipe: pipe PLL to enable
-
 
1470
 *
-
 
1471
 * Enable @pipe's PLL so we can start pumping pixels from a plane.  Check to
-
 
1472
 * make sure the PLL reg is writable first though, since the panel write
-
 
1473
 * protect mechanism may be enabled.
-
 
1474
 *
-
 
1475
 * Note!  This is for pre-ILK only.
-
 
1476
 *
-
 
1477
 * Unfortunately needed by dvo_ns2501 since the dvo depends on it running.
-
 
1478
 */
1328
 
1479
static void intel_enable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
1329
static void vlv_enable_pll(struct intel_crtc *crtc)
-
 
1330
{
-
 
1331
	struct drm_device *dev = crtc->base.dev;
1480
{
1332
	struct drm_i915_private *dev_priv = dev->dev_private;
1481
    int reg;
1333
	int reg = DPLL(crtc->pipe);
-
 
1334
	u32 dpll = crtc->config.dpll_hw_state.dpll;
-
 
1335
 
Line 1482... Line 1336...
1482
    u32 val;
1336
	assert_pipe_disabled(dev_priv, crtc->pipe);
1483
 
1337
 
Line 1484... Line 1338...
1484
    /* No really, not for ILK+ */
1338
    /* No really, not for ILK+ */
1485
	BUG_ON(!IS_VALLEYVIEW(dev_priv->dev) && dev_priv->info->gen >= 5);
1339
	BUG_ON(!IS_VALLEYVIEW(dev_priv->dev));
1486
 
1340
 
Line 1487... Line 1341...
1487
    /* PLL is protected by panel, make sure we can write it */
1341
    /* PLL is protected by panel, make sure we can write it */
1488
    if (IS_MOBILE(dev_priv->dev) && !IS_I830(dev_priv->dev))
1342
    if (IS_MOBILE(dev_priv->dev) && !IS_I830(dev_priv->dev))
-
 
1343
		assert_panel_unlocked(dev_priv, crtc->pipe);
-
 
1344
 
-
 
1345
	I915_WRITE(reg, dpll);
-
 
1346
	POSTING_READ(reg);
-
 
1347
	udelay(150);
-
 
1348
 
1489
        assert_panel_unlocked(dev_priv, pipe);
1349
	if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
Line 1490... Line 1350...
1490
 
1350
		DRM_ERROR("DPLL %d failed to lock\n", crtc->pipe);
1491
    reg = DPLL(pipe);
1351
 
1492
    val = I915_READ(reg);
1352
	I915_WRITE(DPLL_MD(crtc->pipe), crtc->config.dpll_hw_state.dpll_md);
1493
    val |= DPLL_VCO_ENABLE;
1353
	POSTING_READ(DPLL_MD(crtc->pipe));
1494
 
1354
 
1495
    /* We do this three times for luck */
1355
	/* We do this three times for luck */
1496
    I915_WRITE(reg, val);
1356
	I915_WRITE(reg, dpll);
-
 
1357
	POSTING_READ(reg);
-
 
1358
	udelay(150); /* wait for warmup */
-
 
1359
	I915_WRITE(reg, dpll);
-
 
1360
	POSTING_READ(reg);
-
 
1361
	udelay(150); /* wait for warmup */
-
 
1362
	I915_WRITE(reg, dpll);
-
 
1363
	POSTING_READ(reg);
-
 
1364
	udelay(150); /* wait for warmup */
-
 
1365
}
-
 
1366
 
-
 
1367
static void i9xx_enable_pll(struct intel_crtc *crtc)
-
 
1368
{
-
 
1369
	struct drm_device *dev = crtc->base.dev;
-
 
1370
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1371
	int reg = DPLL(crtc->pipe);
-
 
1372
	u32 dpll = crtc->config.dpll_hw_state.dpll;
-
 
1373
 
-
 
1374
	assert_pipe_disabled(dev_priv, crtc->pipe);
-
 
1375
 
-
 
1376
	/* No really, not for ILK+ */
-
 
1377
	BUG_ON(dev_priv->info->gen >= 5);
-
 
1378
 
-
 
1379
	/* PLL is protected by panel, make sure we can write it */
-
 
1380
	if (IS_MOBILE(dev) && !IS_I830(dev))
-
 
1381
		assert_panel_unlocked(dev_priv, crtc->pipe);
-
 
1382
 
-
 
1383
	I915_WRITE(reg, dpll);
-
 
1384
 
-
 
1385
	/* Wait for the clocks to stabilize. */
-
 
1386
	POSTING_READ(reg);
-
 
1387
	udelay(150);
-
 
1388
 
-
 
1389
	if (INTEL_INFO(dev)->gen >= 4) {
-
 
1390
		I915_WRITE(DPLL_MD(crtc->pipe),
-
 
1391
			   crtc->config.dpll_hw_state.dpll_md);
-
 
1392
	} else {
1497
    POSTING_READ(reg);
1393
		/* The pixel multiplier can only be updated once the
-
 
1394
		 * DPLL is enabled and the clocks are stable.
-
 
1395
		 *
-
 
1396
		 * So write it again.
-
 
1397
		 */
-
 
1398
		I915_WRITE(reg, dpll);
-
 
1399
	}
-
 
1400
 
-
 
1401
    /* We do this three times for luck */
-
 
1402
	I915_WRITE(reg, dpll);
-
 
1403
    POSTING_READ(reg);
1498
    udelay(150); /* wait for warmup */
1404
    udelay(150); /* wait for warmup */
1499
    I915_WRITE(reg, val);
1405
	I915_WRITE(reg, dpll);
1500
    POSTING_READ(reg);
1406
    POSTING_READ(reg);
Line 1501... Line 1407...
1501
    udelay(150); /* wait for warmup */
1407
    udelay(150); /* wait for warmup */
1502
    I915_WRITE(reg, val);
1408
	I915_WRITE(reg, dpll);
1503
    POSTING_READ(reg);
1409
    POSTING_READ(reg);
1504
    udelay(150); /* wait for warmup */
1410
    udelay(150); /* wait for warmup */
1505
}
1411
}
1506
 
1412
 
1507
/**
1413
/**
1508
 * intel_disable_pll - disable a PLL
1414
 * i9xx_disable_pll - disable a PLL
1509
 * @dev_priv: i915 private structure
1415
 * @dev_priv: i915 private structure
1510
 * @pipe: pipe PLL to disable
1416
 * @pipe: pipe PLL to disable
1511
 *
1417
 *
1512
 * Disable the PLL for @pipe, making sure the pipe is off first.
-
 
1513
 *
-
 
1514
 * Note!  This is for pre-ILK only.
-
 
1515
 */
1418
 * Disable the PLL for @pipe, making sure the pipe is off first.
1516
static void intel_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
1419
 *
1517
{
1420
 * Note!  This is for pre-ILK only.
Line 1518... Line 1421...
1518
	int reg;
1421
 */
1519
	u32 val;
1422
static void i9xx_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
Line 1520... Line -...
1520
 
-
 
1521
	/* Don't disable pipe A or pipe A PLLs if needed */
-
 
1522
	if (pipe == PIPE_A && (dev_priv->quirks & QUIRK_PIPEA_FORCE))
-
 
1523
		return;
1423
{
1524
 
1424
	/* Don't disable pipe A or pipe A PLLs if needed */
1525
	/* Make sure the pipe isn't still relying on us */
-
 
1526
	assert_pipe_disabled(dev_priv, pipe);
-
 
1527
 
-
 
1528
	reg = DPLL(pipe);
-
 
1529
	val = I915_READ(reg);
-
 
1530
	val &= ~DPLL_VCO_ENABLE;
-
 
1531
	I915_WRITE(reg, val);
-
 
1532
	POSTING_READ(reg);
-
 
1533
}
-
 
1534
 
-
 
1535
/* SBI access */
-
 
1536
static void
-
 
1537
intel_sbi_write(struct drm_i915_private *dev_priv, u16 reg, u32 value,
-
 
1538
		enum intel_sbi_destination destination)
-
 
1539
{
-
 
1540
	u32 tmp;
-
 
1541
 
-
 
1542
	WARN_ON(!mutex_is_locked(&dev_priv->dpio_lock));
-
 
1543
 
-
 
1544
	if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_BUSY) == 0,
-
 
1545
				100)) {
-
 
1546
		DRM_ERROR("timeout waiting for SBI to become ready\n");
-
 
1547
		return;
-
 
1548
	}
-
 
1549
 
-
 
1550
	I915_WRITE(SBI_ADDR, (reg << 16));
-
 
1551
	I915_WRITE(SBI_DATA, value);
-
 
1552
 
-
 
1553
	if (destination == SBI_ICLK)
-
 
1554
		tmp = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRWR;
-
 
1555
	else
-
 
1556
		tmp = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IOWR;
1425
	if (pipe == PIPE_A && (dev_priv->quirks & QUIRK_PIPEA_FORCE))
Line 1557... Line -...
1557
	I915_WRITE(SBI_CTL_STAT, SBI_BUSY | tmp);
-
 
1558
 
1426
		return;
1559
	if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_BUSY | SBI_RESPONSE_FAIL)) == 0,
-
 
1560
				100)) {
1427
 
1561
		DRM_ERROR("timeout waiting for SBI to complete write transaction\n");
1428
	/* Make sure the pipe isn't still relying on us */
1562
		return;
-
 
Line 1563... Line -...
1563
	}
-
 
1564
}
-
 
1565
 
-
 
1566
static u32
1429
	assert_pipe_disabled(dev_priv, pipe);
1567
intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg,
-
 
1568
	       enum intel_sbi_destination destination)
-
 
1569
{
1430
 
1570
	u32 value = 0;
-
 
1571
	WARN_ON(!mutex_is_locked(&dev_priv->dpio_lock));
-
 
1572
 
-
 
1573
	if (wait_for((I915_READ(SBI_CTL_STAT) & SBI_BUSY) == 0,
1431
	I915_WRITE(DPLL(pipe), 0);
1574
				100)) {
-
 
1575
		DRM_ERROR("timeout waiting for SBI to become ready\n");
1432
	POSTING_READ(DPLL(pipe));
1576
		return 0;
-
 
1577
	}
-
 
1578
 
-
 
1579
	I915_WRITE(SBI_ADDR, (reg << 16));
-
 
1580
 
-
 
1581
	if (destination == SBI_ICLK)
-
 
Line -... Line 1433...
-
 
1433
}
-
 
1434
 
1582
		value = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRRD;
1435
void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port)
1583
	else
1436
{
Line 1584... Line 1437...
1584
		value = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IORD;
1437
	u32 port_mask;
1585
	I915_WRITE(SBI_CTL_STAT, value | SBI_BUSY);
1438
 
1586
 
1439
	if (!port)
1587
	if (wait_for((I915_READ(SBI_CTL_STAT) & (SBI_BUSY | SBI_RESPONSE_FAIL)) == 0,
1440
		port_mask = DPLL_PORTB_READY_MASK;
1588
				100)) {
1441
	else
1589
		DRM_ERROR("timeout waiting for SBI to complete read transaction\n");
1442
		port_mask = DPLL_PORTC_READY_MASK;
1590
		return 0;
1443
 
1591
	}
1444
	if (wait_for((I915_READ(DPLL(0)) & port_mask) == 0, 1000))
1592
 
1445
		WARN(1, "timed out waiting for port %c ready: 0x%08x\n",
1593
	return I915_READ(SBI_DATA);
1446
		     'B' + port, I915_READ(DPLL(0)));
1594
}
1447
}
1595
 
1448
 
1596
/**
-
 
1597
 * ironlake_enable_pch_pll - enable PCH PLL
-
 
Line 1598... Line 1449...
1598
 * @dev_priv: i915 private structure
1449
/**
1599
 * @pipe: pipe PLL to enable
1450
 * ironlake_enable_shared_dpll - enable PCH PLL
1600
 *
-
 
1601
 * The PCH PLL needs to be enabled before the PCH transcoder, since it
1451
 * @dev_priv: i915 private structure
1602
 * drives the transcoder clock.
1452
 * @pipe: pipe PLL to enable
Line 1603... Line 1453...
1603
 */
1453
 *
1604
static void ironlake_enable_pch_pll(struct intel_crtc *intel_crtc)
1454
 * The PCH PLL needs to be enabled before the PCH transcoder, since it
Line 1605... Line 1455...
1605
{
1455
 * drives the transcoder clock.
1606
	struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private;
1456
 */
1607
	struct intel_pch_pll *pll;
1457
static void ironlake_enable_shared_dpll(struct intel_crtc *crtc)
1608
	int reg;
-
 
1609
	u32 val;
-
 
1610
 
-
 
Line 1611... Line 1458...
1611
	/* PCH PLLs only available on ILK, SNB and IVB */
1458
{
-
 
1459
	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
1612
	BUG_ON(dev_priv->info->gen < 5);
1460
	struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
1613
	pll = intel_crtc->pch_pll;
1461
 
1614
	if (pll == NULL)
1462
	/* PCH PLLs only available on ILK, SNB and IVB */
-
 
1463
	BUG_ON(dev_priv->info->gen < 5);
Line 1615... Line 1464...
1615
		return;
1464
	if (WARN_ON(pll == NULL))
1616
 
-
 
1617
	if (WARN_ON(pll->refcount == 0))
-
 
1618
		return;
-
 
1619
 
-
 
1620
	DRM_DEBUG_KMS("enable PCH PLL %x (active %d, on? %d)for crtc %d\n",
1465
		return;
1621
		      pll->pll_reg, pll->active, pll->on,
-
 
1622
		      intel_crtc->base.base.id);
-
 
1623
 
-
 
1624
	/* PCH refclock must be enabled first */
1466
 
1625
	assert_pch_refclk_enabled(dev_priv);
1467
	if (WARN_ON(pll->refcount == 0))
Line 1626... Line 1468...
1626
 
1468
		return;
1627
	if (pll->active++ && pll->on) {
1469
 
1628
		assert_pch_pll_enabled(dev_priv, pll, NULL);
1470
	DRM_DEBUG_KMS("enable %s (active %d, on? %d)for crtc %d\n",
1629
		return;
1471
		      pll->name, pll->active, pll->on,
1630
	}
-
 
1631
 
-
 
Line 1632... Line 1472...
1632
	DRM_DEBUG_KMS("enabling PCH PLL %x\n", pll->pll_reg);
1472
		      crtc->base.base.id);
1633
 
1473
 
1634
	reg = pll->pll_reg;
1474
	if (pll->active++) {
1635
	val = I915_READ(reg);
1475
		WARN_ON(!pll->on);
Line 1636... Line 1476...
1636
	val |= DPLL_VCO_ENABLE;
1476
		assert_shared_dpll_enabled(dev_priv, pll);
1637
	I915_WRITE(reg, val);
1477
		return;
Line 1638... Line 1478...
1638
	POSTING_READ(reg);
1478
	}
1639
	udelay(200);
1479
	WARN_ON(pll->on);
1640
 
1480
 
Line 1641... Line 1481...
1641
	pll->on = true;
1481
	DRM_DEBUG_KMS("enabling %s\n", pll->name);
1642
}
1482
	pll->enable(dev_priv, pll);
1643
 
1483
	pll->on = true;
1644
static void intel_disable_pch_pll(struct intel_crtc *intel_crtc)
1484
}
Line -... Line 1485...
-
 
1485
 
-
 
1486
static void intel_disable_shared_dpll(struct intel_crtc *crtc)
1645
{
1487
{
1646
	struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private;
-
 
1647
	struct intel_pch_pll *pll = intel_crtc->pch_pll;
1488
	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
1648
	int reg;
-
 
1649
	u32 val;
-
 
1650
 
-
 
1651
	/* PCH only available on ILK+ */
-
 
1652
	BUG_ON(dev_priv->info->gen < 5);
-
 
1653
	if (pll == NULL)
-
 
1654
	       return;
-
 
1655
 
-
 
1656
	if (WARN_ON(pll->refcount == 0))
-
 
1657
		return;
-
 
1658
 
-
 
1659
	DRM_DEBUG_KMS("disable PCH PLL %x (active %d, on? %d) for crtc %d\n",
-
 
1660
		      pll->pll_reg, pll->active, pll->on,
-
 
Line -... Line 1489...
-
 
1489
	struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
-
 
1490
 
1661
		      intel_crtc->base.base.id);
1491
	/* PCH only available on ILK+ */
1662
 
1492
	BUG_ON(dev_priv->info->gen < 5);
Line 1663... Line 1493...
1663
	if (WARN_ON(pll->active == 0)) {
1493
	if (WARN_ON(pll == NULL))
1664
		assert_pch_pll_disabled(dev_priv, pll, NULL);
1494
	       return;
1665
		return;
1495
 
1666
	}
1496
	if (WARN_ON(pll->refcount == 0))
1667
 
1497
		return;
-
 
1498
 
1668
	if (--pll->active) {
1499
	DRM_DEBUG_KMS("disable %s (active %d, on? %d) for crtc %d\n",
Line 1669... Line 1500...
1669
		assert_pch_pll_enabled(dev_priv, pll, NULL);
1500
		      pll->name, pll->active, pll->on,
1670
		return;
1501
		      crtc->base.base.id);
Line 1671... Line 1502...
1671
	}
1502
 
1672
 
1503
	if (WARN_ON(pll->active == 0)) {
1673
	DRM_DEBUG_KMS("disabling PCH PLL %x\n", pll->pll_reg);
-
 
1674
 
1504
		assert_shared_dpll_disabled(dev_priv, pll);
Line 1675... Line 1505...
1675
	/* Make sure transcoder isn't still depending on us */
1505
		return;
1676
	assert_transcoder_disabled(dev_priv, intel_crtc->pipe);
1506
	}
1677
 
1507
 
Line 1711... Line 1541...
1711
		val = I915_READ(reg);
1541
		val = I915_READ(reg);
1712
		val |= TRANS_CHICKEN2_TIMING_OVERRIDE;
1542
		val |= TRANS_CHICKEN2_TIMING_OVERRIDE;
1713
		I915_WRITE(reg, val);
1543
		I915_WRITE(reg, val);
1714
	}
1544
	}
Line 1715... Line 1545...
1715
 
1545
 
1716
	reg = TRANSCONF(pipe);
1546
	reg = PCH_TRANSCONF(pipe);
1717
	val = I915_READ(reg);
1547
	val = I915_READ(reg);
Line 1718... Line 1548...
1718
	pipeconf_val = I915_READ(PIPECONF(pipe));
1548
	pipeconf_val = I915_READ(PIPECONF(pipe));
1719
 
1549
 
Line 1736... Line 1566...
1736
	else
1566
	else
1737
		val |= TRANS_PROGRESSIVE;
1567
		val |= TRANS_PROGRESSIVE;
Line 1738... Line 1568...
1738
 
1568
 
1739
	I915_WRITE(reg, val | TRANS_ENABLE);
1569
	I915_WRITE(reg, val | TRANS_ENABLE);
1740
	if (wait_for(I915_READ(reg) & TRANS_STATE_ENABLE, 100))
1570
	if (wait_for(I915_READ(reg) & TRANS_STATE_ENABLE, 100))
1741
		DRM_ERROR("failed to enable transcoder %d\n", pipe);
1571
		DRM_ERROR("failed to enable transcoder %c\n", pipe_name(pipe));
Line 1742... Line 1572...
1742
}
1572
}
1743
 
1573
 
1744
static void lpt_enable_pch_transcoder(struct drm_i915_private *dev_priv,
1574
static void lpt_enable_pch_transcoder(struct drm_i915_private *dev_priv,
Line 1765... Line 1595...
1765
	    PIPECONF_INTERLACED_ILK)
1595
	    PIPECONF_INTERLACED_ILK)
1766
		val |= TRANS_INTERLACED;
1596
		val |= TRANS_INTERLACED;
1767
	else
1597
	else
1768
		val |= TRANS_PROGRESSIVE;
1598
		val |= TRANS_PROGRESSIVE;
Line 1769... Line 1599...
1769
 
1599
 
1770
	I915_WRITE(TRANSCONF(TRANSCODER_A), val);
1600
	I915_WRITE(LPT_TRANSCONF, val);
1771
	if (wait_for(I915_READ(_TRANSACONF) & TRANS_STATE_ENABLE, 100))
1601
	if (wait_for(I915_READ(LPT_TRANSCONF) & TRANS_STATE_ENABLE, 100))
1772
		DRM_ERROR("Failed to enable PCH transcoder\n");
1602
		DRM_ERROR("Failed to enable PCH transcoder\n");
Line 1773... Line 1603...
1773
}
1603
}
1774
 
1604
 
Line 1783... Line 1613...
1783
	assert_fdi_rx_disabled(dev_priv, pipe);
1613
	assert_fdi_rx_disabled(dev_priv, pipe);
Line 1784... Line 1614...
1784
 
1614
 
1785
	/* Ports must be off as well */
1615
	/* Ports must be off as well */
Line 1786... Line 1616...
1786
	assert_pch_ports_disabled(dev_priv, pipe);
1616
	assert_pch_ports_disabled(dev_priv, pipe);
1787
 
1617
 
1788
	reg = TRANSCONF(pipe);
1618
	reg = PCH_TRANSCONF(pipe);
1789
	val = I915_READ(reg);
1619
	val = I915_READ(reg);
1790
	val &= ~TRANS_ENABLE;
1620
	val &= ~TRANS_ENABLE;
1791
	I915_WRITE(reg, val);
1621
	I915_WRITE(reg, val);
1792
	/* wait for PCH transcoder off, transcoder state */
1622
	/* wait for PCH transcoder off, transcoder state */
Line 1793... Line 1623...
1793
	if (wait_for((I915_READ(reg) & TRANS_STATE_ENABLE) == 0, 50))
1623
	if (wait_for((I915_READ(reg) & TRANS_STATE_ENABLE) == 0, 50))
1794
		DRM_ERROR("failed to disable transcoder %d\n", pipe);
1624
		DRM_ERROR("failed to disable transcoder %c\n", pipe_name(pipe));
1795
 
1625
 
1796
	if (!HAS_PCH_IBX(dev)) {
1626
	if (!HAS_PCH_IBX(dev)) {
Line 1804... Line 1634...
1804
 
1634
 
1805
static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv)
1635
static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv)
1806
{
1636
{
Line 1807... Line 1637...
1807
	u32 val;
1637
	u32 val;
1808
 
1638
 
1809
	val = I915_READ(_TRANSACONF);
1639
	val = I915_READ(LPT_TRANSCONF);
1810
	val &= ~TRANS_ENABLE;
1640
	val &= ~TRANS_ENABLE;
1811
	I915_WRITE(_TRANSACONF, val);
1641
	I915_WRITE(LPT_TRANSCONF, val);
1812
	/* wait for PCH transcoder off, transcoder state */
1642
	/* wait for PCH transcoder off, transcoder state */
Line 1813... Line 1643...
1813
	if (wait_for((I915_READ(_TRANSACONF) & TRANS_STATE_ENABLE) == 0, 50))
1643
	if (wait_for((I915_READ(LPT_TRANSCONF) & TRANS_STATE_ENABLE) == 0, 50))
1814
		DRM_ERROR("Failed to disable PCH transcoder\n");
1644
		DRM_ERROR("Failed to disable PCH transcoder\n");
1815
 
1645
 
Line 1840... Line 1670...
1840
								      pipe);
1670
								      pipe);
1841
	enum pipe pch_transcoder;
1671
	enum pipe pch_transcoder;
1842
	int reg;
1672
	int reg;
1843
	u32 val;
1673
	u32 val;
Line -... Line 1674...
-
 
1674
 
-
 
1675
	assert_planes_disabled(dev_priv, pipe);
-
 
1676
	assert_sprites_disabled(dev_priv, pipe);
1844
 
1677
 
1845
	if (HAS_PCH_LPT(dev_priv->dev))
1678
	if (HAS_PCH_LPT(dev_priv->dev))
1846
		pch_transcoder = TRANSCODER_A;
1679
		pch_transcoder = TRANSCODER_A;
1847
	else
1680
	else
Line 2044... Line 1877...
2044
 
1877
 
2045
	dev_priv->mm.interruptible = true;
1878
	dev_priv->mm.interruptible = true;
Line 2046... Line 1879...
2046
	return 0;
1879
	return 0;
2047
 
1880
 
2048
err_unpin:
1881
err_unpin:
2049
	i915_gem_object_unpin(obj);
1882
	i915_gem_object_unpin_from_display_plane(obj);
2050
err_interruptible:
1883
err_interruptible:
2051
	dev_priv->mm.interruptible = true;
1884
	dev_priv->mm.interruptible = true;
Line 2101... Line 1934...
2101
    switch (plane) {
1934
    switch (plane) {
2102
    case 0:
1935
    case 0:
2103
    case 1:
1936
    case 1:
2104
        break;
1937
        break;
2105
    default:
1938
    default:
2106
        DRM_ERROR("Can't update plane %d in SAREA\n", plane);
1939
		DRM_ERROR("Can't update plane %c in SAREA\n", plane_name(plane));
2107
        return -EINVAL;
1940
        return -EINVAL;
2108
    }
1941
    }
Line 2109... Line 1942...
2109
 
1942
 
2110
    intel_fb = to_intel_framebuffer(fb);
1943
    intel_fb = to_intel_framebuffer(fb);
Line 2150... Line 1983...
2150
            dspcntr |= DISPPLANE_TILED;
1983
            dspcntr |= DISPPLANE_TILED;
2151
        else
1984
        else
2152
            dspcntr &= ~DISPPLANE_TILED;
1985
            dspcntr &= ~DISPPLANE_TILED;
2153
    }
1986
    }
Line -... Line 1987...
-
 
1987
 
-
 
1988
	if (IS_G4X(dev))
-
 
1989
		dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
2154
 
1990
 
Line 2155... Line 1991...
2155
    I915_WRITE(reg, dspcntr);
1991
    I915_WRITE(reg, dspcntr);
Line 2156... Line 1992...
2156
 
1992
 
Line 2164... Line 2000...
2164
		linear_offset -= intel_crtc->dspaddr_offset;
2000
		linear_offset -= intel_crtc->dspaddr_offset;
2165
	} else {
2001
	} else {
2166
		intel_crtc->dspaddr_offset = linear_offset;
2002
		intel_crtc->dspaddr_offset = linear_offset;
2167
	}
2003
	}
Line 2168... Line 2004...
2168
 
2004
 
2169
	DRM_DEBUG_KMS("Writing base %08X %08lX %d %d %d\n",
2005
	DRM_DEBUG_KMS("Writing base %08lX %08lX %d %d %d\n",
-
 
2006
		      i915_gem_obj_ggtt_offset(obj), linear_offset, x, y,
2170
		      obj->gtt_offset, linear_offset, x, y, fb->pitches[0]);
2007
		      fb->pitches[0]);
2171
	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2008
	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2172
    if (INTEL_INFO(dev)->gen >= 4) {
2009
    if (INTEL_INFO(dev)->gen >= 4) {
2173
		I915_MODIFY_DISPBASE(DSPSURF(plane),
2010
		I915_MODIFY_DISPBASE(DSPSURF(plane),
2174
				     obj->gtt_offset + intel_crtc->dspaddr_offset);
2011
				     i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
2175
        I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
2012
        I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
2176
		I915_WRITE(DSPLINOFF(plane), linear_offset);
2013
		I915_WRITE(DSPLINOFF(plane), linear_offset);
2177
    } else
2014
    } else
2178
		I915_WRITE(DSPADDR(plane), obj->gtt_offset + linear_offset);
2015
		I915_WRITE(DSPADDR(plane), i915_gem_obj_ggtt_offset(obj) + linear_offset);
Line 2179... Line 2016...
2179
    POSTING_READ(reg);
2016
    POSTING_READ(reg);
2180
 
2017
 
Line 2198... Line 2035...
2198
    case 0:
2035
    case 0:
2199
    case 1:
2036
    case 1:
2200
	case 2:
2037
	case 2:
2201
        break;
2038
        break;
2202
    default:
2039
    default:
2203
        DRM_ERROR("Can't update plane %d in SAREA\n", plane);
2040
		DRM_ERROR("Can't update plane %c in SAREA\n", plane_name(plane));
2204
        return -EINVAL;
2041
        return -EINVAL;
2205
    }
2042
    }
Line 2206... Line 2043...
2206
 
2043
 
2207
    intel_fb = to_intel_framebuffer(fb);
2044
    intel_fb = to_intel_framebuffer(fb);
Line 2241... Line 2078...
2241
	if (obj->tiling_mode != I915_TILING_NONE)
2078
	if (obj->tiling_mode != I915_TILING_NONE)
2242
		dspcntr |= DISPPLANE_TILED;
2079
		dspcntr |= DISPPLANE_TILED;
2243
	else
2080
	else
2244
        dspcntr &= ~DISPPLANE_TILED;
2081
        dspcntr &= ~DISPPLANE_TILED;
Line 2245... Line 2082...
2245
 
2082
 
-
 
2083
	if (IS_HASWELL(dev))
-
 
2084
		dspcntr &= ~DISPPLANE_TRICKLE_FEED_DISABLE;
2246
    /* must disable */
2085
	else
Line 2247... Line 2086...
2247
    dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
2086
    dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
Line 2248... Line 2087...
2248
 
2087
 
Line 2253... Line 2092...
2253
		intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode,
2092
		intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode,
2254
						   fb->bits_per_pixel / 8,
2093
						   fb->bits_per_pixel / 8,
2255
						   fb->pitches[0]);
2094
						   fb->pitches[0]);
2256
	linear_offset -= intel_crtc->dspaddr_offset;
2095
	linear_offset -= intel_crtc->dspaddr_offset;
Line 2257... Line 2096...
2257
 
2096
 
2258
	DRM_DEBUG_KMS("Writing base %08X %08lX %d %d %d\n",
2097
	DRM_DEBUG_KMS("Writing base %08lX %08lX %d %d %d\n",
-
 
2098
		      i915_gem_obj_ggtt_offset(obj), linear_offset, x, y,
2259
		      obj->gtt_offset, linear_offset, x, y, fb->pitches[0]);
2099
		      fb->pitches[0]);
2260
	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2100
	I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]);
2261
	I915_MODIFY_DISPBASE(DSPSURF(plane),
2101
	I915_MODIFY_DISPBASE(DSPSURF(plane),
2262
			     obj->gtt_offset + intel_crtc->dspaddr_offset);
2102
			     i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
2263
	if (IS_HASWELL(dev)) {
2103
	if (IS_HASWELL(dev)) {
2264
		I915_WRITE(DSPOFFSET(plane), (y << 16) | x);
2104
		I915_WRITE(DSPOFFSET(plane), (y << 16) | x);
2265
	} else {
2105
	} else {
2266
	I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
2106
	I915_WRITE(DSPTILEOFF(plane), (y << 16) | x);
Line 2285... Line 2125...
2285
 
2125
 
2286
	return dev_priv->display.update_plane(crtc, fb, x, y);
2126
	return dev_priv->display.update_plane(crtc, fb, x, y);
Line 2287... Line 2127...
2287
}
2127
}
-
 
2128
 
-
 
2129
#if 0
-
 
2130
void intel_display_handle_reset(struct drm_device *dev)
-
 
2131
{
-
 
2132
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2133
	struct drm_crtc *crtc;
-
 
2134
 
-
 
2135
	/*
-
 
2136
	 * Flips in the rings have been nuked by the reset,
-
 
2137
	 * so complete all pending flips so that user space
-
 
2138
	 * will get its events and not get stuck.
-
 
2139
	 *
-
 
2140
	 * Also update the base address of all primary
-
 
2141
	 * planes to the the last fb to make sure we're
-
 
2142
	 * showing the correct fb after a reset.
-
 
2143
	 *
-
 
2144
	 * Need to make two loops over the crtcs so that we
-
 
2145
	 * don't try to grab a crtc mutex before the
-
 
2146
	 * pending_flip_queue really got woken up.
-
 
2147
	 */
-
 
2148
 
-
 
2149
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
 
2150
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
2151
		enum plane plane = intel_crtc->plane;
-
 
2152
 
-
 
2153
		intel_prepare_page_flip(dev, plane);
-
 
2154
		intel_finish_page_flip_plane(dev, plane);
-
 
2155
	}
-
 
2156
 
-
 
2157
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
 
2158
		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
2159
 
-
 
2160
		mutex_lock(&crtc->mutex);
-
 
2161
		if (intel_crtc->active)
-
 
2162
			dev_priv->display.update_plane(crtc, crtc->fb,
-
 
2163
						       crtc->x, crtc->y);
-
 
2164
		mutex_unlock(&crtc->mutex);
-
 
2165
	}
2288
 
2166
}
2289
#if 0
2167
 
2290
static int
2168
static int
2291
intel_finish_fb(struct drm_framebuffer *old_fb)
2169
intel_finish_fb(struct drm_framebuffer *old_fb)
2292
{
2170
{
Line 2307... Line 2185...
2307
	ret = i915_gem_object_finish_gpu(obj);
2185
	ret = i915_gem_object_finish_gpu(obj);
2308
	dev_priv->mm.interruptible = was_interruptible;
2186
	dev_priv->mm.interruptible = was_interruptible;
Line 2309... Line 2187...
2309
 
2187
 
2310
	return ret;
2188
	return ret;
-
 
2189
}
-
 
2190
 
-
 
2191
static void intel_crtc_update_sarea_pos(struct drm_crtc *crtc, int x, int y)
-
 
2192
{
-
 
2193
	struct drm_device *dev = crtc->dev;
-
 
2194
	struct drm_i915_master_private *master_priv;
-
 
2195
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
2196
 
-
 
2197
	if (!dev->primary->master)
-
 
2198
		return;
-
 
2199
 
-
 
2200
	master_priv = dev->primary->master->driver_priv;
-
 
2201
	if (!master_priv->sarea_priv)
-
 
2202
		return;
-
 
2203
 
-
 
2204
	switch (intel_crtc->pipe) {
-
 
2205
	case 0:
-
 
2206
		master_priv->sarea_priv->pipeA_x = x;
-
 
2207
		master_priv->sarea_priv->pipeA_y = y;
-
 
2208
		break;
-
 
2209
	case 1:
-
 
2210
		master_priv->sarea_priv->pipeB_x = x;
-
 
2211
		master_priv->sarea_priv->pipeB_y = y;
-
 
2212
		break;
-
 
2213
	default:
-
 
2214
		break;
-
 
2215
	}
2311
}
2216
}
Line 2312... Line 2217...
2312
#endif
2217
#endif
2313
 
2218
 
2314
static int
2219
static int
Line 2326... Line 2231...
2326
		DRM_ERROR("No FB bound\n");
2231
		DRM_ERROR("No FB bound\n");
2327
		return 0;
2232
		return 0;
2328
	}
2233
	}
Line 2329... Line 2234...
2329
 
2234
 
2330
	if (intel_crtc->plane > INTEL_INFO(dev)->num_pipes) {
2235
	if (intel_crtc->plane > INTEL_INFO(dev)->num_pipes) {
2331
		DRM_ERROR("no plane for crtc: plane %d, num_pipes %d\n",
2236
		DRM_ERROR("no plane for crtc: plane %c, num_pipes %d\n",
2332
				intel_crtc->plane,
2237
			  plane_name(intel_crtc->plane),
2333
				INTEL_INFO(dev)->num_pipes);
2238
				INTEL_INFO(dev)->num_pipes);
2334
		return -EINVAL;
2239
		return -EINVAL;
Line 2335... Line 2240...
2335
	}
2240
	}
Line 2357... Line 2262...
2357
	crtc->fb = fb;
2262
	crtc->fb = fb;
2358
	crtc->x = x;
2263
	crtc->x = x;
2359
	crtc->y = y;
2264
	crtc->y = y;
Line 2360... Line 2265...
2360
 
2265
 
-
 
2266
	if (old_fb) {
2361
	if (old_fb) {
2267
		if (intel_crtc->active && old_fb != fb)
2362
		intel_wait_for_vblank(dev, intel_crtc->pipe);
2268
		intel_wait_for_vblank(dev, intel_crtc->pipe);
2363
		intel_unpin_fb_obj(to_intel_framebuffer(old_fb)->obj);
2269
		intel_unpin_fb_obj(to_intel_framebuffer(old_fb)->obj);
Line 2364... Line 2270...
2364
	}
2270
	}
-
 
2271
 
2365
 
2272
	intel_update_fbc(dev);
Line 2366... Line 2273...
2366
	intel_update_fbc(dev);
2273
	intel_edp_psr_update(dev);
2367
	mutex_unlock(&dev->struct_mutex);
2274
	mutex_unlock(&dev->struct_mutex);
Line 2408... Line 2315...
2408
	if (IS_IVYBRIDGE(dev))
2315
	if (IS_IVYBRIDGE(dev))
2409
		I915_WRITE(reg, I915_READ(reg) | FDI_FS_ERRC_ENABLE |
2316
		I915_WRITE(reg, I915_READ(reg) | FDI_FS_ERRC_ENABLE |
2410
			   FDI_FE_ERRC_ENABLE);
2317
			   FDI_FE_ERRC_ENABLE);
2411
}
2318
}
Line -... Line 2319...
-
 
2319
 
-
 
2320
static bool pipe_has_enabled_pch(struct intel_crtc *intel_crtc)
-
 
2321
{
-
 
2322
	return intel_crtc->base.enabled && intel_crtc->config.has_pch_encoder;
-
 
2323
}
2412
 
2324
 
2413
static void ivb_modeset_global_resources(struct drm_device *dev)
2325
static void ivb_modeset_global_resources(struct drm_device *dev)
2414
{
2326
{
2415
	struct drm_i915_private *dev_priv = dev->dev_private;
2327
	struct drm_i915_private *dev_priv = dev->dev_private;
2416
	struct intel_crtc *pipe_B_crtc =
2328
	struct intel_crtc *pipe_B_crtc =
2417
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_B]);
2329
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_B]);
2418
	struct intel_crtc *pipe_C_crtc =
2330
	struct intel_crtc *pipe_C_crtc =
2419
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_C]);
2331
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_C]);
Line -... Line 2332...
-
 
2332
	uint32_t temp;
2420
	uint32_t temp;
2333
 
2421
 
2334
	/*
2422
	/* When everything is off disable fdi C so that we could enable fdi B
2335
	 * When everything is off disable fdi C so that we could enable fdi B
-
 
2336
	 * with all lanes. Note that we don't care about enabled pipes without
2423
	 * with all lanes. XXX: This misses the case where a pipe is not using
2337
	 * an enabled pch encoder.
-
 
2338
	 */
2424
	 * any pch resources and so doesn't need any fdi lanes. */
2339
	if (!pipe_has_enabled_pch(pipe_B_crtc) &&
2425
	if (!pipe_B_crtc->base.enabled && !pipe_C_crtc->base.enabled) {
2340
	    !pipe_has_enabled_pch(pipe_C_crtc)) {
Line 2426... Line 2341...
2426
		WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);
2341
		WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);
2427
		WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);
2342
		WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);
Line 2458... Line 2373...
2458
    udelay(150);
2373
    udelay(150);
Line 2459... Line 2374...
2459
 
2374
 
2460
    /* enable CPU FDI TX and PCH FDI RX */
2375
    /* enable CPU FDI TX and PCH FDI RX */
2461
    reg = FDI_TX_CTL(pipe);
2376
    reg = FDI_TX_CTL(pipe);
2462
    temp = I915_READ(reg);
2377
    temp = I915_READ(reg);
2463
    temp &= ~(7 << 19);
2378
	temp &= ~FDI_DP_PORT_WIDTH_MASK;
2464
    temp |= (intel_crtc->fdi_lanes - 1) << 19;
2379
	temp |= FDI_DP_PORT_WIDTH(intel_crtc->config.fdi_lanes);
2465
    temp &= ~FDI_LINK_TRAIN_NONE;
2380
    temp &= ~FDI_LINK_TRAIN_NONE;
2466
    temp |= FDI_LINK_TRAIN_PATTERN_1;
2381
    temp |= FDI_LINK_TRAIN_PATTERN_1;
Line 2467... Line 2382...
2467
    I915_WRITE(reg, temp | FDI_TX_ENABLE);
2382
    I915_WRITE(reg, temp | FDI_TX_ENABLE);
Line 2556... Line 2471...
2556
    udelay(150);
2471
    udelay(150);
Line 2557... Line 2472...
2557
 
2472
 
2558
    /* enable CPU FDI TX and PCH FDI RX */
2473
    /* enable CPU FDI TX and PCH FDI RX */
2559
    reg = FDI_TX_CTL(pipe);
2474
    reg = FDI_TX_CTL(pipe);
2560
    temp = I915_READ(reg);
2475
    temp = I915_READ(reg);
2561
    temp &= ~(7 << 19);
2476
	temp &= ~FDI_DP_PORT_WIDTH_MASK;
2562
    temp |= (intel_crtc->fdi_lanes - 1) << 19;
2477
	temp |= FDI_DP_PORT_WIDTH(intel_crtc->config.fdi_lanes);
2563
    temp &= ~FDI_LINK_TRAIN_NONE;
2478
    temp &= ~FDI_LINK_TRAIN_NONE;
2564
    temp |= FDI_LINK_TRAIN_PATTERN_1;
2479
    temp |= FDI_LINK_TRAIN_PATTERN_1;
2565
    temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2480
    temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2566
    /* SNB-B */
2481
    /* SNB-B */
Line 2672... Line 2587...
2672
{
2587
{
2673
    struct drm_device *dev = crtc->dev;
2588
    struct drm_device *dev = crtc->dev;
2674
    struct drm_i915_private *dev_priv = dev->dev_private;
2589
    struct drm_i915_private *dev_priv = dev->dev_private;
2675
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2590
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2676
    int pipe = intel_crtc->pipe;
2591
    int pipe = intel_crtc->pipe;
2677
    u32 reg, temp, i;
2592
	u32 reg, temp, i, j;
Line 2678... Line 2593...
2678
 
2593
 
2679
    /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit
2594
    /* Train 1: umask FDI RX Interrupt symbol_lock and bit_lock bit
2680
       for train result */
2595
       for train result */
2681
    reg = FDI_RX_IMR(pipe);
2596
    reg = FDI_RX_IMR(pipe);
Line 2688... Line 2603...
2688
    udelay(150);
2603
    udelay(150);
Line 2689... Line 2604...
2689
 
2604
 
2690
	DRM_DEBUG_KMS("FDI_RX_IIR before link train 0x%x\n",
2605
	DRM_DEBUG_KMS("FDI_RX_IIR before link train 0x%x\n",
Line -... Line 2606...
-
 
2606
		      I915_READ(FDI_RX_IIR(pipe)));
-
 
2607
 
2691
		      I915_READ(FDI_RX_IIR(pipe)));
2608
	/* Try each vswing and preemphasis setting twice before moving on */
2692
 
2609
	for (j = 0; j < ARRAY_SIZE(snb_b_fdi_train_param) * 2; j++) {
2693
    /* enable CPU FDI TX and PCH FDI RX */
2610
		/* disable first in case we need to retry */
2694
    reg = FDI_TX_CTL(pipe);
-
 
2695
    temp = I915_READ(reg);
-
 
2696
    temp &= ~(7 << 19);
2611
		reg = FDI_TX_CTL(pipe);
-
 
2612
		temp = I915_READ(reg);
-
 
2613
		temp &= ~(FDI_LINK_TRAIN_AUTO | FDI_LINK_TRAIN_NONE_IVB);
-
 
2614
		temp &= ~FDI_TX_ENABLE;
-
 
2615
		I915_WRITE(reg, temp);
-
 
2616
 
-
 
2617
		reg = FDI_RX_CTL(pipe);
-
 
2618
		temp = I915_READ(reg);
-
 
2619
		temp &= ~FDI_LINK_TRAIN_AUTO;
-
 
2620
		temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT;
-
 
2621
		temp &= ~FDI_RX_ENABLE;
-
 
2622
		I915_WRITE(reg, temp);
-
 
2623
 
-
 
2624
    /* enable CPU FDI TX and PCH FDI RX */
-
 
2625
    reg = FDI_TX_CTL(pipe);
-
 
2626
    temp = I915_READ(reg);
2697
    temp |= (intel_crtc->fdi_lanes - 1) << 19;
2627
	temp &= ~FDI_DP_PORT_WIDTH_MASK;
2698
    temp &= ~(FDI_LINK_TRAIN_AUTO | FDI_LINK_TRAIN_NONE_IVB);
2628
	temp |= FDI_DP_PORT_WIDTH(intel_crtc->config.fdi_lanes);
2699
    temp |= FDI_LINK_TRAIN_PATTERN_1_IVB;
2629
    temp |= FDI_LINK_TRAIN_PATTERN_1_IVB;
2700
    temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2630
    temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2701
    temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B;
2631
		temp |= snb_b_fdi_train_param[j/2];
Line 2702... Line 2632...
2702
	temp |= FDI_COMPOSITE_SYNC;
2632
	temp |= FDI_COMPOSITE_SYNC;
2703
    I915_WRITE(reg, temp | FDI_TX_ENABLE);
2633
    I915_WRITE(reg, temp | FDI_TX_ENABLE);
Line 2704... Line 2634...
2704
 
2634
 
2705
	I915_WRITE(FDI_RX_MISC(pipe),
2635
	I915_WRITE(FDI_RX_MISC(pipe),
2706
		   FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90);
-
 
2707
 
-
 
2708
    reg = FDI_RX_CTL(pipe);
2636
		   FDI_RX_TP1_TO_TP2_48 | FDI_RX_FDI_DELAY_90);
2709
    temp = I915_READ(reg);
2637
 
2710
    temp &= ~FDI_LINK_TRAIN_AUTO;
2638
    reg = FDI_RX_CTL(pipe);
Line 2711... Line 2639...
2711
    temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT;
2639
    temp = I915_READ(reg);
2712
    temp |= FDI_LINK_TRAIN_PATTERN_1_CPT;
2640
    temp |= FDI_LINK_TRAIN_PATTERN_1_CPT;
Line 2713... Line 2641...
2713
	temp |= FDI_COMPOSITE_SYNC;
2641
	temp |= FDI_COMPOSITE_SYNC;
2714
    I915_WRITE(reg, temp | FDI_RX_ENABLE);
-
 
2715
 
-
 
2716
    POSTING_READ(reg);
-
 
2717
    udelay(150);
-
 
2718
 
-
 
2719
	for (i = 0; i < 4; i++) {
-
 
2720
        reg = FDI_TX_CTL(pipe);
-
 
2721
        temp = I915_READ(reg);
-
 
2722
        temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
-
 
2723
        temp |= snb_b_fdi_train_param[i];
2642
    I915_WRITE(reg, temp | FDI_RX_ENABLE);
2724
        I915_WRITE(reg, temp);
2643
 
2725
 
2644
    POSTING_READ(reg);
Line 2726... Line 2645...
2726
        POSTING_READ(reg);
2645
		udelay(1); /* should be 0.5us */
2727
        udelay(500);
2646
 
2728
 
2647
	for (i = 0; i < 4; i++) {
2729
        reg = FDI_RX_IIR(pipe);
2648
        reg = FDI_RX_IIR(pipe);
-
 
2649
        temp = I915_READ(reg);
2730
        temp = I915_READ(reg);
2650
        DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp);
2731
        DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp);
2651
 
-
 
2652
        if (temp & FDI_RX_BIT_LOCK ||
-
 
2653
            (I915_READ(reg) & FDI_RX_BIT_LOCK)) {
-
 
2654
            I915_WRITE(reg, temp | FDI_RX_BIT_LOCK);
-
 
2655
				DRM_DEBUG_KMS("FDI train 1 done, level %i.\n",
-
 
2656
					      i);
2732
 
2657
            break;
2733
        if (temp & FDI_RX_BIT_LOCK ||
-
 
2734
            (I915_READ(reg) & FDI_RX_BIT_LOCK)) {
-
 
Line 2735... Line 2658...
2735
            I915_WRITE(reg, temp | FDI_RX_BIT_LOCK);
2658
        }
2736
			DRM_DEBUG_KMS("FDI train 1 done, level %i.\n", i);
2659
			udelay(1); /* should be 0.5us */
2737
            break;
2660
		}
2738
        }
2661
		if (i == 4) {
2739
    }
2662
			DRM_DEBUG_KMS("FDI train 1 fail on vswing %d\n", j / 2);
2740
    if (i == 4)
-
 
2741
        DRM_ERROR("FDI train 1 fail!\n");
-
 
2742
 
2663
			continue;
Line 2743... Line 2664...
2743
    /* Train 2 */
2664
    }
2744
    reg = FDI_TX_CTL(pipe);
2665
 
2745
    temp = I915_READ(reg);
2666
    /* Train 2 */
2746
    temp &= ~FDI_LINK_TRAIN_NONE_IVB;
2667
    reg = FDI_TX_CTL(pipe);
2747
    temp |= FDI_LINK_TRAIN_PATTERN_2_IVB;
2668
    temp = I915_READ(reg);
Line 2748... Line 2669...
2748
    temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2669
    temp &= ~FDI_LINK_TRAIN_NONE_IVB;
2749
    temp |= FDI_LINK_TRAIN_400MV_0DB_SNB_B;
2670
    temp |= FDI_LINK_TRAIN_PATTERN_2_IVB;
Line 2750... Line 2671...
2750
    I915_WRITE(reg, temp);
2671
    I915_WRITE(reg, temp);
2751
 
-
 
2752
    reg = FDI_RX_CTL(pipe);
-
 
2753
    temp = I915_READ(reg);
-
 
2754
    temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT;
-
 
2755
    temp |= FDI_LINK_TRAIN_PATTERN_2_CPT;
-
 
2756
    I915_WRITE(reg, temp);
-
 
2757
 
-
 
2758
    POSTING_READ(reg);
-
 
2759
    udelay(150);
-
 
2760
 
2672
 
2761
	for (i = 0; i < 4; i++) {
2673
    reg = FDI_RX_CTL(pipe);
2762
        reg = FDI_TX_CTL(pipe);
2674
    temp = I915_READ(reg);
Line 2763... Line 2675...
2763
        temp = I915_READ(reg);
2675
    temp &= ~FDI_LINK_TRAIN_PATTERN_MASK_CPT;
-
 
2676
    temp |= FDI_LINK_TRAIN_PATTERN_2_CPT;
2764
        temp &= ~FDI_LINK_TRAIN_VOL_EMP_MASK;
2677
    I915_WRITE(reg, temp);
2765
        temp |= snb_b_fdi_train_param[i];
2678
 
2766
        I915_WRITE(reg, temp);
2679
    POSTING_READ(reg);
-
 
2680
		udelay(2); /* should be 1.5us */
2767
 
2681
 
-
 
2682
	for (i = 0; i < 4; i++) {
2768
        POSTING_READ(reg);
2683
        reg = FDI_RX_IIR(pipe);
2769
        udelay(500);
2684
        temp = I915_READ(reg);
2770
 
2685
        DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp);
-
 
2686
 
Line -... Line 2687...
-
 
2687
			if (temp & FDI_RX_SYMBOL_LOCK ||
2771
        reg = FDI_RX_IIR(pipe);
2688
			    (I915_READ(reg) & FDI_RX_SYMBOL_LOCK)) {
2772
        temp = I915_READ(reg);
2689
            I915_WRITE(reg, temp | FDI_RX_SYMBOL_LOCK);
Line 2773... Line 2690...
2773
        DRM_DEBUG_KMS("FDI_RX_IIR 0x%x\n", temp);
2690
				DRM_DEBUG_KMS("FDI train 2 done, level %i.\n",
2774
 
2691
					      i);
Line 2793... Line 2710...
2793
 
2710
 
2794
 
2711
 
2795
	/* enable PCH FDI RX PLL, wait warmup plus DMI latency */
2712
	/* enable PCH FDI RX PLL, wait warmup plus DMI latency */
2796
	reg = FDI_RX_CTL(pipe);
2713
	reg = FDI_RX_CTL(pipe);
2797
	temp = I915_READ(reg);
2714
	temp = I915_READ(reg);
2798
	temp &= ~((0x7 << 19) | (0x7 << 16));
2715
	temp &= ~(FDI_DP_PORT_WIDTH_MASK | (0x7 << 16));
2799
	temp |= (intel_crtc->fdi_lanes - 1) << 19;
2716
	temp |= FDI_DP_PORT_WIDTH(intel_crtc->config.fdi_lanes);
Line 2800... Line 2717...
2800
	temp |= (I915_READ(PIPECONF(pipe)) & PIPECONF_BPC_MASK) << 11;
2717
	temp |= (I915_READ(PIPECONF(pipe)) & PIPECONF_BPC_MASK) << 11;
2801
	I915_WRITE(reg, temp | FDI_RX_PLL_ENABLE);
2718
	I915_WRITE(reg, temp | FDI_RX_PLL_ENABLE);
Line 2940... Line 2857...
2940
	intel_finish_fb(crtc->fb);
2857
	intel_finish_fb(crtc->fb);
2941
	mutex_unlock(&dev->struct_mutex);
2858
	mutex_unlock(&dev->struct_mutex);
2942
}
2859
}
2943
#endif
2860
#endif
Line 2944... Line -...
2944
 
-
 
2945
 
-
 
2946
 
2861
 
2947
/* Program iCLKIP clock to the desired frequency */
2862
/* Program iCLKIP clock to the desired frequency */
2948
static void lpt_program_iclkip(struct drm_crtc *crtc)
2863
static void lpt_program_iclkip(struct drm_crtc *crtc)
2949
{
2864
{
2950
	struct drm_device *dev = crtc->dev;
2865
	struct drm_device *dev = crtc->dev;
Line 3030... Line 2945...
3030
	I915_WRITE(PIXCLK_GATE, PIXCLK_GATE_UNGATE);
2945
	I915_WRITE(PIXCLK_GATE, PIXCLK_GATE_UNGATE);
Line 3031... Line 2946...
3031
 
2946
 
3032
	mutex_unlock(&dev_priv->dpio_lock);
2947
	mutex_unlock(&dev_priv->dpio_lock);
Line -... Line 2948...
-
 
2948
}
-
 
2949
 
-
 
2950
static void ironlake_pch_transcoder_set_timings(struct intel_crtc *crtc,
-
 
2951
						enum pipe pch_transcoder)
-
 
2952
{
-
 
2953
	struct drm_device *dev = crtc->base.dev;
-
 
2954
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
2955
	enum transcoder cpu_transcoder = crtc->config.cpu_transcoder;
-
 
2956
 
-
 
2957
	I915_WRITE(PCH_TRANS_HTOTAL(pch_transcoder),
-
 
2958
		   I915_READ(HTOTAL(cpu_transcoder)));
-
 
2959
	I915_WRITE(PCH_TRANS_HBLANK(pch_transcoder),
-
 
2960
		   I915_READ(HBLANK(cpu_transcoder)));
-
 
2961
	I915_WRITE(PCH_TRANS_HSYNC(pch_transcoder),
-
 
2962
		   I915_READ(HSYNC(cpu_transcoder)));
-
 
2963
 
-
 
2964
	I915_WRITE(PCH_TRANS_VTOTAL(pch_transcoder),
-
 
2965
		   I915_READ(VTOTAL(cpu_transcoder)));
-
 
2966
	I915_WRITE(PCH_TRANS_VBLANK(pch_transcoder),
-
 
2967
		   I915_READ(VBLANK(cpu_transcoder)));
-
 
2968
	I915_WRITE(PCH_TRANS_VSYNC(pch_transcoder),
-
 
2969
		   I915_READ(VSYNC(cpu_transcoder)));
-
 
2970
	I915_WRITE(PCH_TRANS_VSYNCSHIFT(pch_transcoder),
-
 
2971
		   I915_READ(VSYNCSHIFT(cpu_transcoder)));
3033
}
2972
}
3034
 
2973
 
3035
/*
2974
/*
3036
 * Enable PCH resources required for PCH ports:
2975
 * Enable PCH resources required for PCH ports:
3037
 *   - PCH PLLs
2976
 *   - PCH PLLs
Line 3046... Line 2985...
3046
	struct drm_i915_private *dev_priv = dev->dev_private;
2985
	struct drm_i915_private *dev_priv = dev->dev_private;
3047
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2986
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3048
	int pipe = intel_crtc->pipe;
2987
	int pipe = intel_crtc->pipe;
3049
	u32 reg, temp;
2988
	u32 reg, temp;
Line 3050... Line 2989...
3050
 
2989
 
Line 3051... Line 2990...
3051
	assert_transcoder_disabled(dev_priv, pipe);
2990
	assert_pch_transcoder_disabled(dev_priv, pipe);
3052
 
2991
 
3053
	/* Write the TU size bits before fdi link training, so that error
2992
	/* Write the TU size bits before fdi link training, so that error
3054
	 * detection works. */
2993
	 * detection works. */
Line 3055... Line 2994...
3055
	I915_WRITE(FDI_RX_TUSIZE1(pipe),
2994
	I915_WRITE(FDI_RX_TUSIZE1(pipe),
3056
		   I915_READ(PIPE_DATA_M1(pipe)) & TU_SIZE_MASK);
2995
		   I915_READ(PIPE_DATA_M1(pipe)) & TU_SIZE_MASK);
Line 3057... Line 2996...
3057
 
2996
 
3058
	/* For PCH output, training FDI link */
-
 
3059
	dev_priv->display.fdi_link_train(crtc);
-
 
3060
 
-
 
3061
	/* XXX: pch pll's can be enabled any time before we enable the PCH
-
 
3062
	 * transcoder, and we actually should do this to not upset any PCH
-
 
3063
	 * transcoder that already use the clock when we share it.
2997
	/* For PCH output, training FDI link */
3064
	 *
-
 
3065
	 * Note that enable_pch_pll tries to do the right thing, but get_pch_pll
-
 
3066
	 * unconditionally resets the pll - we need that to have the right LVDS
2998
	dev_priv->display.fdi_link_train(crtc);
3067
	 * enable sequence. */
2999
 
Line 3068... Line 3000...
3068
	ironlake_enable_pch_pll(intel_crtc);
3000
	/* We need to program the right clock selection before writing the pixel
3069
 
-
 
3070
	if (HAS_PCH_CPT(dev)) {
-
 
3071
		u32 sel;
-
 
3072
 
3001
	 * mutliplier into the DPLL. */
3073
		temp = I915_READ(PCH_DPLL_SEL);
-
 
3074
		switch (pipe) {
-
 
3075
		default:
-
 
3076
		case 0:
-
 
3077
			temp |= TRANSA_DPLL_ENABLE;
-
 
3078
			sel = TRANSA_DPLLB_SEL;
-
 
3079
			break;
-
 
3080
		case 1:
-
 
3081
			temp |= TRANSB_DPLL_ENABLE;
3002
	if (HAS_PCH_CPT(dev)) {
3082
			sel = TRANSB_DPLLB_SEL;
-
 
3083
			break;
-
 
3084
		case 2:
3003
		u32 sel;
3085
			temp |= TRANSC_DPLL_ENABLE;
3004
 
3086
			sel = TRANSC_DPLLB_SEL;
3005
		temp = I915_READ(PCH_DPLL_SEL);
3087
			break;
3006
		temp |= TRANS_DPLL_ENABLE(pipe);
3088
		}
3007
		sel = TRANS_DPLLB_SEL(pipe);
3089
		if (intel_crtc->pch_pll->pll_reg == _PCH_DPLL_B)
3008
		if (intel_crtc->config.shared_dpll == DPLL_ID_PCH_PLL_B)
Line -... Line 3009...
-
 
3009
			temp |= sel;
-
 
3010
		else
-
 
3011
			temp &= ~sel;
-
 
3012
		I915_WRITE(PCH_DPLL_SEL, temp);
-
 
3013
	}
-
 
3014
 
-
 
3015
	/* XXX: pch pll's can be enabled any time before we enable the PCH
-
 
3016
	 * transcoder, and we actually should do this to not upset any PCH
-
 
3017
	 * transcoder that already use the clock when we share it.
3090
			temp |= sel;
3018
	 *
3091
		else
3019
	 * Note that enable_shared_dpll tries to do the right thing, but
3092
			temp &= ~sel;
-
 
3093
		I915_WRITE(PCH_DPLL_SEL, temp);
-
 
3094
	}
-
 
3095
 
-
 
3096
	/* set transcoder timing, panel must allow it */
-
 
3097
	assert_panel_unlocked(dev_priv, pipe);
3020
	 * get_shared_dpll unconditionally resets the pll - we need that to have
3098
	I915_WRITE(TRANS_HTOTAL(pipe), I915_READ(HTOTAL(pipe)));
-
 
3099
	I915_WRITE(TRANS_HBLANK(pipe), I915_READ(HBLANK(pipe)));
-
 
Line 3100... Line 3021...
3100
	I915_WRITE(TRANS_HSYNC(pipe),  I915_READ(HSYNC(pipe)));
3021
	 * the right LVDS enable sequence. */
Line 3101... Line 3022...
3101
 
3022
	ironlake_enable_shared_dpll(intel_crtc);
3102
	I915_WRITE(TRANS_VTOTAL(pipe), I915_READ(VTOTAL(pipe)));
3023
 
Line 3150... Line 3071...
3150
	struct drm_device *dev = crtc->dev;
3071
	struct drm_device *dev = crtc->dev;
3151
	struct drm_i915_private *dev_priv = dev->dev_private;
3072
	struct drm_i915_private *dev_priv = dev->dev_private;
3152
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3073
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3153
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
3074
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
Line 3154... Line 3075...
3154
 
3075
 
Line 3155... Line 3076...
3155
	assert_transcoder_disabled(dev_priv, TRANSCODER_A);
3076
	assert_pch_transcoder_disabled(dev_priv, TRANSCODER_A);
Line 3156... Line 3077...
3156
 
3077
 
3157
	lpt_program_iclkip(crtc);
-
 
3158
 
-
 
3159
	/* Set transcoder timing. */
-
 
3160
	I915_WRITE(_TRANS_HTOTAL_A, I915_READ(HTOTAL(cpu_transcoder)));
-
 
3161
	I915_WRITE(_TRANS_HBLANK_A, I915_READ(HBLANK(cpu_transcoder)));
-
 
3162
	I915_WRITE(_TRANS_HSYNC_A,  I915_READ(HSYNC(cpu_transcoder)));
-
 
3163
 
3078
	lpt_program_iclkip(crtc);
3164
	I915_WRITE(_TRANS_VTOTAL_A, I915_READ(VTOTAL(cpu_transcoder)));
-
 
Line 3165... Line 3079...
3165
	I915_WRITE(_TRANS_VBLANK_A, I915_READ(VBLANK(cpu_transcoder)));
3079
 
3166
	I915_WRITE(_TRANS_VSYNC_A,  I915_READ(VSYNC(cpu_transcoder)));
3080
	/* Set transcoder timing. */
Line 3167... Line 3081...
3167
	I915_WRITE(_TRANS_VSYNCSHIFT_A, I915_READ(VSYNCSHIFT(cpu_transcoder)));
3081
	ironlake_pch_transcoder_set_timings(intel_crtc, PIPE_A);
3168
 
3082
 
3169
	lpt_enable_pch_transcoder(dev_priv, cpu_transcoder);
3083
	lpt_enable_pch_transcoder(dev_priv, cpu_transcoder);
Line 3170... Line 3084...
3170
}
3084
}
3171
 
3085
 
Line 3172... Line 3086...
3172
static void intel_put_pch_pll(struct intel_crtc *intel_crtc)
3086
static void intel_put_shared_dpll(struct intel_crtc *crtc)
3173
{
3087
{
3174
	struct intel_pch_pll *pll = intel_crtc->pch_pll;
3088
	struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
3175
 
3089
 
Line 3176... Line 3090...
3176
	if (pll == NULL)
3090
	if (pll == NULL)
3177
		return;
3091
		return;
-
 
3092
 
3178
 
3093
	if (pll->refcount == 0) {
Line -... Line 3094...
-
 
3094
		WARN(1, "bad %s refcount\n", pll->name);
-
 
3095
		return;
-
 
3096
	}
3179
	if (pll->refcount == 0) {
3097
 
3180
		WARN(1, "bad PCH PLL refcount\n");
3098
	if (--pll->refcount == 0) {
3181
		return;
3099
		WARN_ON(pll->on);
3182
	}
3100
		WARN_ON(pll->active);
3183
 
3101
	}
Line 3184... Line -...
3184
	--pll->refcount;
-
 
3185
	intel_crtc->pch_pll = NULL;
3102
 
3186
}
3103
	crtc->config.shared_dpll = DPLL_ID_PRIVATE;
3187
 
3104
}
3188
static struct intel_pch_pll *intel_get_pch_pll(struct intel_crtc *intel_crtc, u32 dpll, u32 fp)
3105
 
3189
{
3106
static struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc)
Line 3190... Line 3107...
3190
	struct drm_i915_private *dev_priv = intel_crtc->base.dev->dev_private;
3107
{
3191
	struct intel_pch_pll *pll;
3108
	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
3192
	int i;
3109
	struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc);
3193
 
3110
	enum intel_dpll_id i;
Line 3194... Line 3111...
3194
	pll = intel_crtc->pch_pll;
3111
 
3195
	if (pll) {
3112
	if (pll) {
Line 3196... Line 3113...
3196
		DRM_DEBUG_KMS("CRTC:%d reusing existing PCH PLL %x\n",
3113
		DRM_DEBUG_KMS("CRTC:%d dropping existing %s\n",
3197
			      intel_crtc->base.base.id, pll->pll_reg);
3114
			      crtc->base.base.id, pll->name);
Line 3198... Line 3115...
3198
		goto prepare;
3115
		intel_put_shared_dpll(crtc);
3199
	}
3116
	}
Line 3200... Line 3117...
3200
 
3117
 
3201
	if (HAS_PCH_IBX(dev_priv->dev)) {
3118
	if (HAS_PCH_IBX(dev_priv->dev)) {
3202
		/* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
3119
		/* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
Line 3203... Line 3120...
3203
		i = intel_crtc->pipe;
3120
		i = (enum intel_dpll_id) crtc->pipe;
3204
		pll = &dev_priv->pch_plls[i];
3121
		pll = &dev_priv->shared_dplls[i];
3205
 
3122
 
3206
		DRM_DEBUG_KMS("CRTC:%d using pre-allocated PCH PLL %x\n",
3123
		DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
3207
			      intel_crtc->base.base.id, pll->pll_reg);
3124
			      crtc->base.base.id, pll->name);
Line 3208... Line 3125...
3208
 
3125
 
3209
		goto found;
3126
		goto found;
3210
	}
3127
	}
Line 3211... Line 3128...
3211
 
3128
 
3212
	for (i = 0; i < dev_priv->num_pch_pll; i++) {
3129
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
3213
		pll = &dev_priv->pch_plls[i];
3130
		pll = &dev_priv->shared_dplls[i];
3214
 
3131
 
3215
		/* Only want to check enabled timings first */
3132
		/* Only want to check enabled timings first */
3216
		if (pll->refcount == 0)
3133
		if (pll->refcount == 0)
3217
			continue;
3134
			continue;
3218
 
3135
 
3219
		if (dpll == (I915_READ(pll->pll_reg) & 0x7fffffff) &&
3136
		if (memcmp(&crtc->config.dpll_hw_state, &pll->hw_state,
Line 3220... Line 3137...
3220
		    fp == I915_READ(pll->fp0_reg)) {
3137
			   sizeof(pll->hw_state)) == 0) {
Line 3221... Line 3138...
3221
			DRM_DEBUG_KMS("CRTC:%d sharing existing PCH PLL %x (refcount %d, ative %d)\n",
3138
			DRM_DEBUG_KMS("CRTC:%d sharing existing %s (refcount %d, ative %d)\n",
3222
				      intel_crtc->base.base.id,
3139
				      crtc->base.base.id,
-
 
3140
				      pll->name, pll->refcount, pll->active);
-
 
3141
 
-
 
3142
			goto found;
-
 
3143
		}
-
 
3144
	}
-
 
3145
 
-
 
3146
	/* Ok no matching timings, maybe there's a free one? */
-
 
3147
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-
 
3148
		pll = &dev_priv->shared_dplls[i];
-
 
3149
		if (pll->refcount == 0) {
-
 
3150
			DRM_DEBUG_KMS("CRTC:%d allocated %s\n",
-
 
3151
				      crtc->base.base.id, pll->name);
-
 
3152
			goto found;
3223
				      pll->pll_reg, pll->refcount, pll->active);
3153
		}
3224
 
-
 
3225
			goto found;
-
 
3226
		}
-
 
3227
	}
-
 
3228
 
-
 
3229
	/* Ok no matching timings, maybe there's a free one? */
-
 
3230
	for (i = 0; i < dev_priv->num_pch_pll; i++) {
-
 
3231
		pll = &dev_priv->pch_plls[i];
-
 
Line 3232... Line -...
3232
		if (pll->refcount == 0) {
-
 
3233
			DRM_DEBUG_KMS("CRTC:%d allocated PCH PLL %x\n",
-
 
3234
				      intel_crtc->base.base.id, pll->pll_reg);
-
 
3235
			goto found;
3154
	}
3236
		}
3155
 
Line 3237... Line 3156...
3237
	}
3156
	return NULL;
3238
 
3157
 
3239
	return NULL;
3158
found:
3240
 
3159
	crtc->config.shared_dpll = i;
3241
found:
3160
	DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name,
Line 3242... Line 3161...
3242
	intel_crtc->pch_pll = pll;
3161
			 pipe_name(crtc->pipe));
3243
	pll->refcount++;
3162
 
3244
	DRM_DEBUG_DRIVER("using pll %d for pipe %d\n", i, intel_crtc->pipe);
3163
	if (pll->active == 0) {
3245
prepare: /* separate function? */
3164
		memcpy(&pll->hw_state, &crtc->config.dpll_hw_state,
3246
	DRM_DEBUG_DRIVER("switching PLL %x off\n", pll->pll_reg);
3165
		       sizeof(pll->hw_state));
3247
 
3166
 
3248
	/* Wait for the clocks to stabilize before rewriting the regs */
3167
		DRM_DEBUG_DRIVER("setting up %s\n", pll->name);
Line -... Line 3168...
-
 
3168
		WARN_ON(pll->on);
-
 
3169
		assert_shared_dpll_disabled(dev_priv, pll);
-
 
3170
 
-
 
3171
		pll->mode_set(dev_priv, pll);
-
 
3172
	}
-
 
3173
	pll->refcount++;
-
 
3174
 
-
 
3175
	return pll;
-
 
3176
}
-
 
3177
 
-
 
3178
static void cpt_verify_modeset(struct drm_device *dev, int pipe)
-
 
3179
{
-
 
3180
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3181
	int dslreg = PIPEDSL(pipe);
-
 
3182
	u32 temp;
-
 
3183
 
-
 
3184
	temp = I915_READ(dslreg);
-
 
3185
	udelay(500);
-
 
3186
	if (wait_for(I915_READ(dslreg) != temp, 5)) {
-
 
3187
		if (wait_for(I915_READ(dslreg) != temp, 5))
-
 
3188
			DRM_ERROR("mode set failed: pipe %c stuck\n", pipe_name(pipe));
-
 
3189
	}
-
 
3190
}
-
 
3191
 
-
 
3192
static void ironlake_pfit_enable(struct intel_crtc *crtc)
-
 
3193
{
-
 
3194
	struct drm_device *dev = crtc->base.dev;
-
 
3195
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3196
	int pipe = crtc->pipe;
-
 
3197
 
-
 
3198
	if (crtc->config.pch_pfit.enabled) {
-
 
3199
		/* Force use of hard-coded filter coefficients
-
 
3200
		 * as some pre-programmed values are broken,
-
 
3201
		 * e.g. x201.
-
 
3202
		 */
-
 
3203
		if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
-
 
3204
			I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3 |
-
 
3205
						 PF_PIPE_SEL_IVB(pipe));
-
 
3206
		else
-
 
3207
			I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);
-
 
3208
		I915_WRITE(PF_WIN_POS(pipe), crtc->config.pch_pfit.pos);
-
 
3209
		I915_WRITE(PF_WIN_SZ(pipe), crtc->config.pch_pfit.size);
-
 
3210
	}
3249
	I915_WRITE(pll->pll_reg, dpll & ~DPLL_VCO_ENABLE);
3211
}
3250
	POSTING_READ(pll->pll_reg);
3212
 
3251
	udelay(150);
3213
static void intel_enable_planes(struct drm_crtc *crtc)
3252
 
3214
{
3253
	I915_WRITE(pll->fp0_reg, fp);
3215
	struct drm_device *dev = crtc->dev;
3254
	I915_WRITE(pll->pll_reg, dpll & ~DPLL_VCO_ENABLE);
3216
	enum pipe pipe = to_intel_crtc(crtc)->pipe;
3255
	pll->on = false;
3217
	struct intel_plane *intel_plane;
3256
	return pll;
3218
 
3257
}
-
 
Line 3258... Line 3219...
3258
 
3219
	list_for_each_entry(intel_plane, &dev->mode_config.plane_list, base.head)
Line 3259... Line 3220...
3259
void intel_cpt_verify_modeset(struct drm_device *dev, int pipe)
3220
		if (intel_plane->pipe == pipe)
3260
{
3221
			intel_plane_restore(&intel_plane->base);
Line 3261... Line 3222...
3261
	struct drm_i915_private *dev_priv = dev->dev_private;
3222
}
3262
	int dslreg = PIPEDSL(pipe);
-
 
Line 3263... Line 3223...
3263
	u32 temp;
3223
 
3264
 
3224
static void intel_disable_planes(struct drm_crtc *crtc)
-
 
3225
{
3265
	temp = I915_READ(dslreg);
3226
	struct drm_device *dev = crtc->dev;
3266
	udelay(500);
-
 
3267
	if (wait_for(I915_READ(dslreg) != temp, 5)) {
-
 
Line -... Line 3227...
-
 
3227
	enum pipe pipe = to_intel_crtc(crtc)->pipe;
-
 
3228
	struct intel_plane *intel_plane;
-
 
3229
 
Line 3268... Line 3230...
3268
		if (wait_for(I915_READ(dslreg) != temp, 5))
3230
	list_for_each_entry(intel_plane, &dev->mode_config.plane_list, base.head)
3269
			DRM_ERROR("mode set failed: pipe %d stuck\n", pipe);
3231
		if (intel_plane->pipe == pipe)
3270
	}
3232
			intel_plane_disable(&intel_plane->base);
3271
}
3233
}
Line 3303... Line 3265...
3303
	} else {
3265
	} else {
3304
		assert_fdi_tx_disabled(dev_priv, pipe);
3266
		assert_fdi_tx_disabled(dev_priv, pipe);
3305
		assert_fdi_rx_disabled(dev_priv, pipe);
3267
		assert_fdi_rx_disabled(dev_priv, pipe);
3306
	}
3268
	}
Line 3307... Line -...
3307
 
-
 
3308
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3309
		if (encoder->pre_enable)
3269
 
3310
			encoder->pre_enable(encoder);
-
 
3311
 
-
 
3312
    /* Enable panel fitting for LVDS */
-
 
3313
    if (dev_priv->pch_pf_size &&
-
 
3314
	    (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) ||
-
 
3315
	     intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) {
-
 
3316
        /* Force use of hard-coded filter coefficients
-
 
3317
         * as some pre-programmed values are broken,
-
 
3318
         * e.g. x201.
-
 
3319
         */
-
 
3320
		if (IS_IVYBRIDGE(dev))
-
 
3321
			I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3 |
-
 
3322
						 PF_PIPE_SEL_IVB(pipe));
-
 
3323
		else
-
 
3324
        I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);
-
 
3325
        I915_WRITE(PF_WIN_POS(pipe), dev_priv->pch_pf_pos);
-
 
3326
        I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
-
 
Line 3327... Line 3270...
3327
    }
3270
	ironlake_pfit_enable(intel_crtc);
3328
 
3271
 
3329
    /*
3272
    /*
3330
     * On ILK+ LUT must be loaded before the pipe is running but with
3273
     * On ILK+ LUT must be loaded before the pipe is running but with
3331
     * clocks enabled
3274
     * clocks enabled
Line 3332... Line 3275...
3332
     */
3275
     */
3333
    intel_crtc_load_lut(crtc);
3276
    intel_crtc_load_lut(crtc);
3334
 
3277
 
-
 
3278
	intel_enable_pipe(dev_priv, pipe,
-
 
3279
			  intel_crtc->config.has_pch_encoder);
Line 3335... Line 3280...
3335
	intel_enable_pipe(dev_priv, pipe,
3280
    intel_enable_plane(dev_priv, plane, pipe);
3336
			  intel_crtc->config.has_pch_encoder);
3281
	intel_enable_planes(crtc);
Line 3337... Line 3282...
3337
    intel_enable_plane(dev_priv, plane, pipe);
3282
//	intel_crtc_update_cursor(crtc, true);
3338
 
3283
 
3339
	if (intel_crtc->config.has_pch_encoder)
3284
	if (intel_crtc->config.has_pch_encoder)
Line 3340... Line -...
3340
        ironlake_pch_enable(crtc);
-
 
3341
 
-
 
3342
    mutex_lock(&dev->struct_mutex);
3285
        ironlake_pch_enable(crtc);
3343
    intel_update_fbc(dev);
3286
 
Line 3344... Line 3287...
3344
    mutex_unlock(&dev->struct_mutex);
3287
    mutex_lock(&dev->struct_mutex);
3345
 
3288
    intel_update_fbc(dev);
Line 3346... Line 3289...
3346
//    intel_crtc_update_cursor(crtc, true);
3289
    mutex_unlock(&dev->struct_mutex);
3347
 
3290
 
3348
	for_each_encoder_on_crtc(dev, crtc, encoder)
3291
	for_each_encoder_on_crtc(dev, crtc, encoder)
3349
		encoder->enable(encoder);
3292
		encoder->enable(encoder);
Line 3360... Line 3303...
3360
	 * happening.
3303
	 * happening.
3361
	 */
3304
	 */
3362
	intel_wait_for_vblank(dev, intel_crtc->pipe);
3305
	intel_wait_for_vblank(dev, intel_crtc->pipe);
3363
}
3306
}
Line -... Line 3307...
-
 
3307
 
-
 
3308
/* IPS only exists on ULT machines and is tied to pipe A. */
-
 
3309
static bool hsw_crtc_supports_ips(struct intel_crtc *crtc)
-
 
3310
{
-
 
3311
	return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A;
-
 
3312
}
-
 
3313
 
-
 
3314
static void hsw_enable_ips(struct intel_crtc *crtc)
-
 
3315
{
-
 
3316
	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-
 
3317
 
-
 
3318
	if (!crtc->config.ips_enabled)
-
 
3319
		return;
-
 
3320
 
-
 
3321
	/* We can only enable IPS after we enable a plane and wait for a vblank.
-
 
3322
	 * We guarantee that the plane is enabled by calling intel_enable_ips
-
 
3323
	 * only after intel_enable_plane. And intel_enable_plane already waits
-
 
3324
	 * for a vblank, so all we need to do here is to enable the IPS bit. */
-
 
3325
	assert_plane_enabled(dev_priv, crtc->plane);
-
 
3326
	I915_WRITE(IPS_CTL, IPS_ENABLE);
-
 
3327
}
-
 
3328
 
-
 
3329
static void hsw_disable_ips(struct intel_crtc *crtc)
-
 
3330
{
-
 
3331
	struct drm_device *dev = crtc->base.dev;
-
 
3332
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3333
 
-
 
3334
	if (!crtc->config.ips_enabled)
-
 
3335
		return;
-
 
3336
 
-
 
3337
	assert_plane_enabled(dev_priv, crtc->plane);
-
 
3338
	I915_WRITE(IPS_CTL, 0);
-
 
3339
 
-
 
3340
	/* We need to wait for a vblank before we can disable the plane. */
-
 
3341
	intel_wait_for_vblank(dev, crtc->pipe);
-
 
3342
}
3364
 
3343
 
3365
static void haswell_crtc_enable(struct drm_crtc *crtc)
3344
static void haswell_crtc_enable(struct drm_crtc *crtc)
3366
{
3345
{
3367
	struct drm_device *dev = crtc->dev;
3346
	struct drm_device *dev = crtc->dev;
3368
	struct drm_i915_private *dev_priv = dev->dev_private;
3347
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 3375... Line 3354...
3375
 
3354
 
3376
	if (intel_crtc->active)
3355
	if (intel_crtc->active)
Line 3377... Line 3356...
3377
		return;
3356
		return;
-
 
3357
 
-
 
3358
	intel_crtc->active = true;
-
 
3359
 
-
 
3360
	intel_set_cpu_fifo_underrun_reporting(dev, pipe, true);
-
 
3361
	if (intel_crtc->config.has_pch_encoder)
3378
 
3362
		intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, true);
Line 3379... Line 3363...
3379
	intel_crtc->active = true;
3363
 
3380
	intel_update_watermarks(dev);
3364
	intel_update_watermarks(dev);
Line 3386... Line 3370...
3386
		if (encoder->pre_enable)
3370
		if (encoder->pre_enable)
3387
			encoder->pre_enable(encoder);
3371
			encoder->pre_enable(encoder);
Line 3388... Line 3372...
3388
 
3372
 
Line 3389... Line 3373...
3389
	intel_ddi_enable_pipe_clock(intel_crtc);
3373
	intel_ddi_enable_pipe_clock(intel_crtc);
3390
 
-
 
3391
	/* Enable panel fitting for eDP */
-
 
3392
	if (dev_priv->pch_pf_size &&
-
 
3393
	    intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) {
-
 
3394
		/* Force use of hard-coded filter coefficients
-
 
3395
		 * as some pre-programmed values are broken,
-
 
3396
		 * e.g. x201.
-
 
3397
		 */
-
 
3398
		I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3 |
-
 
3399
					 PF_PIPE_SEL_IVB(pipe));
-
 
3400
		I915_WRITE(PF_WIN_POS(pipe), dev_priv->pch_pf_pos);
-
 
Line 3401... Line 3374...
3401
		I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
3374
 
3402
	}
3375
	ironlake_pfit_enable(intel_crtc);
3403
 
3376
 
3404
	/*
3377
	/*
Line 3411... Line 3384...
3411
	intel_ddi_enable_transcoder_func(crtc);
3384
	intel_ddi_enable_transcoder_func(crtc);
Line 3412... Line 3385...
3412
 
3385
 
3413
	intel_enable_pipe(dev_priv, pipe,
3386
	intel_enable_pipe(dev_priv, pipe,
3414
			  intel_crtc->config.has_pch_encoder);
3387
			  intel_crtc->config.has_pch_encoder);
-
 
3388
	intel_enable_plane(dev_priv, plane, pipe);
-
 
3389
	intel_enable_planes(crtc);
-
 
3390
//	intel_crtc_update_cursor(crtc, true);
-
 
3391
 
Line 3415... Line 3392...
3415
	intel_enable_plane(dev_priv, plane, pipe);
3392
	hsw_enable_ips(intel_crtc);
3416
 
3393
 
Line 3417... Line 3394...
3417
	if (intel_crtc->config.has_pch_encoder)
3394
	if (intel_crtc->config.has_pch_encoder)
3418
		lpt_pch_enable(crtc);
3395
		lpt_pch_enable(crtc);
3419
 
3396
 
Line 3420... Line -...
3420
	mutex_lock(&dev->struct_mutex);
-
 
3421
	intel_update_fbc(dev);
-
 
3422
	mutex_unlock(&dev->struct_mutex);
3397
	mutex_lock(&dev->struct_mutex);
3423
 
3398
	intel_update_fbc(dev);
Line 3424... Line 3399...
3424
//	intel_crtc_update_cursor(crtc, true);
3399
	mutex_unlock(&dev->struct_mutex);
3425
 
3400
 
Line 3435... Line 3410...
3435
	 * happening.
3410
	 * happening.
3436
	 */
3411
	 */
3437
	intel_wait_for_vblank(dev, intel_crtc->pipe);
3412
	intel_wait_for_vblank(dev, intel_crtc->pipe);
3438
}
3413
}
Line -... Line 3414...
-
 
3414
 
-
 
3415
static void ironlake_pfit_disable(struct intel_crtc *crtc)
-
 
3416
{
-
 
3417
	struct drm_device *dev = crtc->base.dev;
-
 
3418
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3419
	int pipe = crtc->pipe;
-
 
3420
 
-
 
3421
	/* To avoid upsetting the power well on haswell only disable the pfit if
-
 
3422
	 * it's in use. The hw state code will make sure we get this right. */
-
 
3423
	if (crtc->config.pch_pfit.enabled) {
-
 
3424
		I915_WRITE(PF_CTL(pipe), 0);
-
 
3425
		I915_WRITE(PF_WIN_POS(pipe), 0);
-
 
3426
		I915_WRITE(PF_WIN_SZ(pipe), 0);
-
 
3427
	}
-
 
3428
}
3439
 
3429
 
3440
static void ironlake_crtc_disable(struct drm_crtc *crtc)
3430
static void ironlake_crtc_disable(struct drm_crtc *crtc)
3441
{
3431
{
3442
    struct drm_device *dev = crtc->dev;
3432
    struct drm_device *dev = crtc->dev;
3443
    struct drm_i915_private *dev_priv = dev->dev_private;
3433
    struct drm_i915_private *dev_priv = dev->dev_private;
Line 3454... Line 3444...
3454
	for_each_encoder_on_crtc(dev, crtc, encoder)
3444
	for_each_encoder_on_crtc(dev, crtc, encoder)
3455
		encoder->disable(encoder);
3445
		encoder->disable(encoder);
Line 3456... Line 3446...
3456
 
3446
 
3457
//    intel_crtc_wait_for_pending_flips(crtc);
3447
//    intel_crtc_wait_for_pending_flips(crtc);
3458
//    drm_vblank_off(dev, pipe);
-
 
Line -... Line 3448...
-
 
3448
//    drm_vblank_off(dev, pipe);
-
 
3449
 
-
 
3450
	if (dev_priv->fbc.plane == plane)
-
 
3451
		intel_disable_fbc(dev);
-
 
3452
 
3459
//    intel_crtc_update_cursor(crtc, false);
3453
//	intel_crtc_update_cursor(crtc, false);
Line 3460... Line 3454...
3460
 
3454
	intel_disable_planes(crtc);
3461
    intel_disable_plane(dev_priv, plane, pipe);
3455
    intel_disable_plane(dev_priv, plane, pipe);
Line 3462... Line 3456...
3462
 
3456
 
Line 3463... Line -...
3463
    if (dev_priv->cfb_plane == plane)
-
 
3464
        intel_disable_fbc(dev);
3457
	if (intel_crtc->config.has_pch_encoder)
3465
 
-
 
Line 3466... Line 3458...
3466
    intel_disable_pipe(dev_priv, pipe);
3458
		intel_set_pch_fifo_underrun_reporting(dev, pipe, false);
3467
 
3459
 
3468
    /* Disable PF */
3460
    intel_disable_pipe(dev_priv, pipe);
Line -... Line 3461...
-
 
3461
 
3469
    I915_WRITE(PF_CTL(pipe), 0);
3462
	ironlake_pfit_disable(intel_crtc);
Line 3470... Line 3463...
3470
    I915_WRITE(PF_WIN_SZ(pipe), 0);
3463
 
-
 
3464
	for_each_encoder_on_crtc(dev, crtc, encoder)
Line 3471... Line 3465...
3471
 
3465
		if (encoder->post_disable)
3472
	for_each_encoder_on_crtc(dev, crtc, encoder)
3466
			encoder->post_disable(encoder);
3473
		if (encoder->post_disable)
3467
 
3474
			encoder->post_disable(encoder);
3468
	if (intel_crtc->config.has_pch_encoder) {
3475
 
3469
    ironlake_fdi_disable(crtc);
-
 
3470
 
3476
    ironlake_fdi_disable(crtc);
3471
	ironlake_disable_pch_transcoder(dev_priv, pipe);
3477
 
3472
		intel_set_pch_fifo_underrun_reporting(dev, pipe, true);
Line 3478... Line 3473...
3478
	ironlake_disable_pch_transcoder(dev_priv, pipe);
3473
 
3479
 
3474
    if (HAS_PCH_CPT(dev)) {
3480
    if (HAS_PCH_CPT(dev)) {
-
 
3481
        /* disable TRANS_DP_CTL */
-
 
3482
        reg = TRANS_DP_CTL(pipe);
3475
        /* disable TRANS_DP_CTL */
3483
        temp = I915_READ(reg);
-
 
3484
        temp &= ~(TRANS_DP_OUTPUT_ENABLE | TRANS_DP_PORT_SEL_MASK);
-
 
3485
        temp |= TRANS_DP_PORT_SEL_NONE;
-
 
3486
        I915_WRITE(reg, temp);
-
 
3487
 
-
 
3488
        /* disable DPLL_SEL */
-
 
3489
        temp = I915_READ(PCH_DPLL_SEL);
-
 
3490
        switch (pipe) {
-
 
3491
        case 0:
-
 
3492
			temp &= ~(TRANSA_DPLL_ENABLE | TRANSA_DPLLB_SEL);
-
 
3493
            break;
-
 
3494
        case 1:
3476
        reg = TRANS_DP_CTL(pipe);
3495
            temp &= ~(TRANSB_DPLL_ENABLE | TRANSB_DPLLB_SEL);
3477
        temp = I915_READ(reg);
Line 3496... Line 3478...
3496
            break;
3478
			temp &= ~(TRANS_DP_OUTPUT_ENABLE |
3497
        case 2:
3479
				  TRANS_DP_PORT_SEL_MASK);
Line 3498... Line 3480...
3498
			/* C shares PLL A or B */
3480
        temp |= TRANS_DP_PORT_SEL_NONE;
-
 
3481
        I915_WRITE(reg, temp);
Line 3499... Line 3482...
3499
            temp &= ~(TRANSC_DPLL_ENABLE | TRANSC_DPLLB_SEL);
3482
 
3500
            break;
3483
        /* disable DPLL_SEL */
Line 3501... Line 3484...
3501
        default:
3484
        temp = I915_READ(PCH_DPLL_SEL);
Line 3532... Line 3515...
3532
 
3515
 
3533
	for_each_encoder_on_crtc(dev, crtc, encoder)
3516
	for_each_encoder_on_crtc(dev, crtc, encoder)
Line 3534... Line 3517...
3534
		encoder->disable(encoder);
3517
		encoder->disable(encoder);
3535
 
-
 
3536
 
3518
 
3537
	intel_disable_plane(dev_priv, plane, pipe);
3519
 
Line -... Line 3520...
-
 
3520
	/* FBC must be disabled before disabling the plane on HSW. */
-
 
3521
	if (dev_priv->fbc.plane == plane)
-
 
3522
		intel_disable_fbc(dev);
-
 
3523
 
-
 
3524
	hsw_disable_ips(intel_crtc);
-
 
3525
 
-
 
3526
//	intel_crtc_update_cursor(crtc, false);
-
 
3527
	intel_disable_planes(crtc);
3538
 
3528
	intel_disable_plane(dev_priv, plane, pipe);
Line 3539... Line 3529...
3539
	if (dev_priv->cfb_plane == plane)
3529
 
Line 3540... Line -...
3540
		intel_disable_fbc(dev);
-
 
3541
 
-
 
3542
	intel_disable_pipe(dev_priv, pipe);
-
 
3543
 
3530
	if (intel_crtc->config.has_pch_encoder)
3544
	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
-
 
3545
 
-
 
3546
	/* XXX: Once we have proper panel fitter state tracking implemented with
-
 
Line 3547... Line 3531...
3547
	 * hardware state read/check support we should switch to only disable
3531
		intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, false);
Line 3548... Line 3532...
3548
	 * the panel fitter when we know it's used. */
3532
	intel_disable_pipe(dev_priv, pipe);
3549
	if (intel_using_power_well(dev)) {
3533
 
3550
	I915_WRITE(PF_CTL(pipe), 0);
3534
	intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
Line 3551... Line 3535...
3551
	I915_WRITE(PF_WIN_SZ(pipe), 0);
3535
 
3552
	}
3536
	ironlake_pfit_disable(intel_crtc);
-
 
3537
 
3553
 
3538
	intel_ddi_disable_pipe_clock(intel_crtc);
3554
	intel_ddi_disable_pipe_clock(intel_crtc);
3539
 
Line 3555... Line 3540...
3555
 
3540
	for_each_encoder_on_crtc(dev, crtc, encoder)
3556
	for_each_encoder_on_crtc(dev, crtc, encoder)
3541
		if (encoder->post_disable)
Line 3571... Line 3556...
3571
}
3556
}
Line 3572... Line 3557...
3572
 
3557
 
3573
static void ironlake_crtc_off(struct drm_crtc *crtc)
3558
static void ironlake_crtc_off(struct drm_crtc *crtc)
3574
{
3559
{
3575
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3560
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3576
	intel_put_pch_pll(intel_crtc);
3561
	intel_put_shared_dpll(intel_crtc);
Line 3577... Line 3562...
3577
}
3562
}
3578
 
3563
 
3579
static void haswell_crtc_off(struct drm_crtc *crtc)
-
 
3580
{
-
 
3581
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
3582
 
-
 
3583
	/* Stop saying we're using TRANSCODER_EDP because some other CRTC might
-
 
3584
	 * start using it. */
-
 
3585
	intel_crtc->config.cpu_transcoder = (enum transcoder) intel_crtc->pipe;
3564
static void haswell_crtc_off(struct drm_crtc *crtc)
3586
 
3565
{
Line 3587... Line 3566...
3587
	intel_ddi_put_crtc_pll(crtc);
3566
	intel_ddi_put_crtc_pll(crtc);
3588
}
3567
}
Line 3627... Line 3606...
3627
		I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe)));
3606
		I915_WRITE(CURBASE(pipe), I915_READ(CURBASE(pipe)));
3628
		I915_WRITE(FW_BLC_SELF, fw_bcl_self);
3607
		I915_WRITE(FW_BLC_SELF, fw_bcl_self);
3629
	}
3608
	}
3630
}
3609
}
Line 3631... Line 3610...
3631
 
3610
 
-
 
3611
static void i9xx_pfit_enable(struct intel_crtc *crtc)
-
 
3612
{
-
 
3613
	struct drm_device *dev = crtc->base.dev;
-
 
3614
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3615
	struct intel_crtc_config *pipe_config = &crtc->config;
-
 
3616
 
-
 
3617
	if (!crtc->config.gmch_pfit.control)
-
 
3618
		return;
-
 
3619
 
-
 
3620
	/*
-
 
3621
	 * The panel fitter should only be adjusted whilst the pipe is disabled,
-
 
3622
	 * according to register description and PRM.
-
 
3623
	 */
-
 
3624
	WARN_ON(I915_READ(PFIT_CONTROL) & PFIT_ENABLE);
-
 
3625
	assert_pipe_disabled(dev_priv, crtc->pipe);
-
 
3626
 
-
 
3627
	I915_WRITE(PFIT_PGM_RATIOS, pipe_config->gmch_pfit.pgm_ratios);
-
 
3628
	I915_WRITE(PFIT_CONTROL, pipe_config->gmch_pfit.control);
-
 
3629
 
-
 
3630
	/* Border color in case we don't scale up to the full screen. Black by
-
 
3631
	 * default, change to something else for debugging. */
-
 
3632
	I915_WRITE(BCLRPAT(crtc->pipe), 0);
-
 
3633
}
-
 
3634
 
3632
static void i9xx_crtc_enable(struct drm_crtc *crtc)
3635
static void valleyview_crtc_enable(struct drm_crtc *crtc)
3633
{
3636
{
3634
    struct drm_device *dev = crtc->dev;
3637
	struct drm_device *dev = crtc->dev;
3635
    struct drm_i915_private *dev_priv = dev->dev_private;
3638
	struct drm_i915_private *dev_priv = dev->dev_private;
3636
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3639
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Line 3644... Line 3647...
3644
        return;
3647
		return;
Line 3645... Line 3648...
3645
 
3648
 
3646
    intel_crtc->active = true;
3649
	intel_crtc->active = true;
Line -... Line 3650...
-
 
3650
	intel_update_watermarks(dev);
-
 
3651
 
-
 
3652
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3653
		if (encoder->pre_pll_enable)
3647
    intel_update_watermarks(dev);
3654
			encoder->pre_pll_enable(encoder);
Line 3648... Line 3655...
3648
 
3655
 
3649
    intel_enable_pll(dev_priv, pipe);
3656
	vlv_enable_pll(intel_crtc);
3650
 
3657
 
Line -... Line 3658...
-
 
3658
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3659
		if (encoder->pre_enable)
-
 
3660
			encoder->pre_enable(encoder);
-
 
3661
 
3651
	for_each_encoder_on_crtc(dev, crtc, encoder)
3662
	i9xx_pfit_enable(intel_crtc);
3652
		if (encoder->pre_enable)
3663
 
3653
			encoder->pre_enable(encoder);
3664
	intel_crtc_load_lut(crtc);
3654
 
3665
 
Line 3655... Line -...
3655
    intel_enable_pipe(dev_priv, pipe, false);
-
 
3656
    intel_enable_plane(dev_priv, plane, pipe);
3666
	intel_enable_pipe(dev_priv, pipe, false);
Line -... Line 3667...
-
 
3667
	intel_enable_plane(dev_priv, plane, pipe);
-
 
3668
	intel_enable_planes(crtc);
-
 
3669
//	intel_crtc_update_cursor(crtc, true);
-
 
3670
 
-
 
3671
	intel_update_fbc(dev);
-
 
3672
 
-
 
3673
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3674
		encoder->enable(encoder);
-
 
3675
}
-
 
3676
 
-
 
3677
static void i9xx_crtc_enable(struct drm_crtc *crtc)
-
 
3678
{
-
 
3679
    struct drm_device *dev = crtc->dev;
-
 
3680
    struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3681
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
3682
	struct intel_encoder *encoder;
-
 
3683
    int pipe = intel_crtc->pipe;
-
 
3684
    int plane = intel_crtc->plane;
-
 
3685
 
-
 
3686
	WARN_ON(!crtc->enabled);
-
 
3687
 
-
 
3688
    if (intel_crtc->active)
-
 
3689
        return;
-
 
3690
 
-
 
3691
    intel_crtc->active = true;
-
 
3692
    intel_update_watermarks(dev);
-
 
3693
 
-
 
3694
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3695
		if (encoder->pre_enable)
-
 
3696
			encoder->pre_enable(encoder);
-
 
3697
 
-
 
3698
	i9xx_enable_pll(intel_crtc);
-
 
3699
 
-
 
3700
	i9xx_pfit_enable(intel_crtc);
-
 
3701
 
-
 
3702
	intel_crtc_load_lut(crtc);
-
 
3703
 
-
 
3704
    intel_enable_pipe(dev_priv, pipe, false);
-
 
3705
    intel_enable_plane(dev_priv, plane, pipe);
3657
	if (IS_G4X(dev))
3706
	intel_enable_planes(crtc);
3658
		g4x_fixup_plane(dev_priv, pipe);
3707
	/* The fixup needs to happen before cursor is enabled */
-
 
3708
	if (IS_G4X(dev))
3659
 
3709
		g4x_fixup_plane(dev_priv, pipe);
Line 3660... Line 3710...
3660
    intel_crtc_load_lut(crtc);
3710
//	intel_crtc_update_cursor(crtc, true);
3661
    intel_update_fbc(dev);
3711
 
3662
 
3712
    /* Give the overlay scaler a chance to enable if it's on this pipe */
Line 3663... Line 3713...
3663
    /* Give the overlay scaler a chance to enable if it's on this pipe */
3713
    intel_crtc_dpms_overlay(intel_crtc, true);
3664
    intel_crtc_dpms_overlay(intel_crtc, true);
3714
 
3665
//    intel_crtc_update_cursor(crtc, true);
3715
	intel_update_fbc(dev);
3666
 
3716
 
3667
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3668
		encoder->enable(encoder);
-
 
Line 3669... Line 3717...
3669
}
3717
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
3718
		encoder->enable(encoder);
Line 3670... Line 3719...
3670
 
3719
}
3671
static void i9xx_pfit_disable(struct intel_crtc *crtc)
-
 
3672
{
-
 
3673
	struct drm_device *dev = crtc->base.dev;
-
 
Line 3674... Line -...
3674
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3675
	enum pipe pipe;
3720
 
-
 
3721
static void i9xx_pfit_disable(struct intel_crtc *crtc)
3676
	uint32_t pctl = I915_READ(PFIT_CONTROL);
3722
{
3677
 
3723
	struct drm_device *dev = crtc->base.dev;
3678
	assert_pipe_disabled(dev_priv, crtc->pipe);
-
 
Line 3679... Line 3724...
3679
 
3724
	struct drm_i915_private *dev_priv = dev->dev_private;
3680
	if (INTEL_INFO(dev)->gen >= 4)
3725
 
3681
		pipe = (pctl & PFIT_PIPE_MASK) >> PFIT_PIPE_SHIFT;
3726
	if (!crtc->config.gmch_pfit.control)
3682
	else
3727
		return;
Line 3704... Line 3749...
3704
		encoder->disable(encoder);
3749
		encoder->disable(encoder);
Line 3705... Line 3750...
3705
 
3750
 
3706
    /* Give the overlay scaler a chance to disable if it's on this pipe */
3751
    /* Give the overlay scaler a chance to disable if it's on this pipe */
3707
//    intel_crtc_wait_for_pending_flips(crtc);
3752
//    intel_crtc_wait_for_pending_flips(crtc);
3708
//    drm_vblank_off(dev, pipe);
-
 
3709
    intel_crtc_dpms_overlay(intel_crtc, false);
-
 
Line 3710... Line 3753...
3710
//    intel_crtc_update_cursor(crtc, false);
3753
//    drm_vblank_off(dev, pipe);
3711
 
3754
 
Line -... Line 3755...
-
 
3755
	if (dev_priv->fbc.plane == plane)
-
 
3756
        intel_disable_fbc(dev);
-
 
3757
 
3712
    if (dev_priv->cfb_plane == plane)
3758
	intel_crtc_dpms_overlay(intel_crtc, false);
-
 
3759
//	intel_crtc_update_cursor(crtc, false);
3713
        intel_disable_fbc(dev);
3760
	intel_disable_planes(crtc);
Line 3714... Line 3761...
3714
 
3761
    intel_disable_plane(dev_priv, plane, pipe);
Line -... Line 3762...
-
 
3762
 
-
 
3763
    intel_disable_pipe(dev_priv, pipe);
-
 
3764
 
-
 
3765
	i9xx_pfit_disable(intel_crtc);
3715
    intel_disable_plane(dev_priv, plane, pipe);
3766
 
Line 3716... Line 3767...
3716
    intel_disable_pipe(dev_priv, pipe);
3767
	for_each_encoder_on_crtc(dev, crtc, encoder)
3717
 
3768
		if (encoder->post_disable)
3718
	i9xx_pfit_disable(intel_crtc);
3769
			encoder->post_disable(encoder);
3719
 
3770
 
Line 3791... Line 3842...
3791
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3842
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Line 3792... Line 3843...
3792
 
3843
 
3793
	/* crtc should still be enabled when we disable it. */
3844
	/* crtc should still be enabled when we disable it. */
Line 3794... Line -...
3794
	WARN_ON(!crtc->enabled);
-
 
3795
 
3845
	WARN_ON(!crtc->enabled);
-
 
3846
 
3796
	intel_crtc->eld_vld = false;
3847
	dev_priv->display.crtc_disable(crtc);
3797
	dev_priv->display.crtc_disable(crtc);
3848
	intel_crtc->eld_vld = false;
Line 3798... Line 3849...
3798
	intel_crtc_update_sarea(crtc, false);
3849
	intel_crtc_update_sarea(crtc, false);
3799
	dev_priv->display.off(crtc);
3850
	dev_priv->display.off(crtc);
Line 3819... Line 3870...
3819
		connector->dpms = DRM_MODE_DPMS_OFF;
3870
		connector->dpms = DRM_MODE_DPMS_OFF;
3820
		to_intel_encoder(connector->encoder)->connectors_active = false;
3871
		to_intel_encoder(connector->encoder)->connectors_active = false;
3821
	}
3872
	}
3822
}
3873
}
Line 3823... Line -...
3823
 
-
 
3824
void intel_modeset_disable(struct drm_device *dev)
-
 
3825
{
-
 
3826
	struct drm_crtc *crtc;
-
 
3827
 
-
 
3828
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
 
3829
		if (crtc->enabled)
-
 
3830
			intel_crtc_disable(crtc);
-
 
3831
	}
-
 
3832
}
-
 
3833
 
3874
 
3834
void intel_encoder_destroy(struct drm_encoder *encoder)
3875
void intel_encoder_destroy(struct drm_encoder *encoder)
3835
{
3876
{
Line 3836... Line 3877...
3836
	struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
3877
	struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
3837
 
3878
 
3838
	drm_encoder_cleanup(encoder);
3879
	drm_encoder_cleanup(encoder);
Line 3839... Line 3880...
3839
	kfree(intel_encoder);
3880
	kfree(intel_encoder);
3840
}
3881
}
3841
 
3882
 
3842
/* Simple dpms helper for encodres with just one connector, no cloning and only
3883
/* Simple dpms helper for encoders with just one connector, no cloning and only
3843
 * one kind of off state. It clamps all !ON modes to fully OFF and changes the
3884
 * one kind of off state. It clamps all !ON modes to fully OFF and changes the
3844
 * state of the entire output pipe. */
3885
 * state of the entire output pipe. */
3845
void intel_encoder_dpms(struct intel_encoder *encoder, int mode)
3886
static void intel_encoder_dpms(struct intel_encoder *encoder, int mode)
Line 3846... Line 3887...
3846
{
3887
{
Line 3892... Line 3933...
3892
 
3933
 
3893
/* Even simpler default implementation, if there's really no special case to
3934
/* Even simpler default implementation, if there's really no special case to
3894
 * consider. */
3935
 * consider. */
3895
void intel_connector_dpms(struct drm_connector *connector, int mode)
3936
void intel_connector_dpms(struct drm_connector *connector, int mode)
3896
{
-
 
3897
	struct intel_encoder *encoder = intel_attached_encoder(connector);
-
 
3898
 
3937
{
3899
	/* All the simple cases only support two dpms states. */
3938
	/* All the simple cases only support two dpms states. */
3900
	if (mode != DRM_MODE_DPMS_ON)
3939
	if (mode != DRM_MODE_DPMS_ON)
Line 3901... Line 3940...
3901
		mode = DRM_MODE_DPMS_OFF;
3940
		mode = DRM_MODE_DPMS_OFF;
3902
 
3941
 
Line 3903... Line 3942...
3903
	if (mode == connector->dpms)
3942
	if (mode == connector->dpms)
Line 3904... Line 3943...
3904
		return;
3943
		return;
3905
 
3944
 
3906
	connector->dpms = mode;
3945
	connector->dpms = mode;
3907
 
-
 
3908
	/* Only need to change hw state when actually enabled */
-
 
Line 3909... Line 3946...
3909
	if (encoder->base.crtc)
3946
 
3910
		intel_encoder_dpms(encoder, mode);
3947
	/* Only need to change hw state when actually enabled */
Line 3911... Line 3948...
3911
	else
3948
	if (connector->encoder)
Line 3923... Line 3960...
3923
	struct intel_encoder *encoder = connector->encoder;
3960
	struct intel_encoder *encoder = connector->encoder;
Line 3924... Line 3961...
3924
 
3961
 
3925
	return encoder->get_hw_state(encoder, &pipe);
3962
	return encoder->get_hw_state(encoder, &pipe);
Line 3926... Line 3963...
3926
}
3963
}
3927
 
3964
 
3928
static bool intel_crtc_compute_config(struct drm_crtc *crtc,
3965
static bool ironlake_check_fdi_lanes(struct drm_device *dev, enum pipe pipe,
-
 
3966
				     struct intel_crtc_config *pipe_config)
-
 
3967
{
-
 
3968
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
3969
	struct intel_crtc *pipe_B_crtc =
-
 
3970
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_B]);
-
 
3971
 
-
 
3972
	DRM_DEBUG_KMS("checking fdi config on pipe %c, lanes %i\n",
-
 
3973
		      pipe_name(pipe), pipe_config->fdi_lanes);
-
 
3974
	if (pipe_config->fdi_lanes > 4) {
-
 
3975
		DRM_DEBUG_KMS("invalid fdi lane config on pipe %c: %i lanes\n",
-
 
3976
			      pipe_name(pipe), pipe_config->fdi_lanes);
-
 
3977
		return false;
-
 
3978
	}
-
 
3979
 
-
 
3980
	if (IS_HASWELL(dev)) {
-
 
3981
		if (pipe_config->fdi_lanes > 2) {
-
 
3982
			DRM_DEBUG_KMS("only 2 lanes on haswell, required: %i lanes\n",
-
 
3983
				      pipe_config->fdi_lanes);
-
 
3984
			return false;
-
 
3985
		} else {
-
 
3986
			return true;
-
 
3987
		}
-
 
3988
	}
-
 
3989
 
-
 
3990
	if (INTEL_INFO(dev)->num_pipes == 2)
-
 
3991
		return true;
-
 
3992
 
-
 
3993
	/* Ivybridge 3 pipe is really complicated */
-
 
3994
	switch (pipe) {
-
 
3995
	case PIPE_A:
-
 
3996
		return true;
-
 
3997
	case PIPE_B:
-
 
3998
		if (dev_priv->pipe_to_crtc_mapping[PIPE_C]->enabled &&
-
 
3999
		    pipe_config->fdi_lanes > 2) {
-
 
4000
			DRM_DEBUG_KMS("invalid shared fdi lane config on pipe %c: %i lanes\n",
-
 
4001
				      pipe_name(pipe), pipe_config->fdi_lanes);
-
 
4002
			return false;
-
 
4003
		}
-
 
4004
		return true;
-
 
4005
	case PIPE_C:
-
 
4006
		if (!pipe_has_enabled_pch(pipe_B_crtc) ||
-
 
4007
		    pipe_B_crtc->config.fdi_lanes <= 2) {
-
 
4008
			if (pipe_config->fdi_lanes > 2) {
-
 
4009
				DRM_DEBUG_KMS("invalid shared fdi lane config on pipe %c: %i lanes\n",
-
 
4010
					      pipe_name(pipe), pipe_config->fdi_lanes);
-
 
4011
				return false;
-
 
4012
			}
-
 
4013
		} else {
-
 
4014
			DRM_DEBUG_KMS("fdi link B uses too many lanes to enable link C\n");
-
 
4015
			return false;
-
 
4016
		}
-
 
4017
		return true;
-
 
4018
	default:
-
 
4019
		BUG();
-
 
4020
	}
-
 
4021
}
-
 
4022
 
-
 
4023
#define RETRY 1
-
 
4024
static int ironlake_fdi_compute_config(struct intel_crtc *intel_crtc,
-
 
4025
				      struct intel_crtc_config *pipe_config)
-
 
4026
{
-
 
4027
	struct drm_device *dev = intel_crtc->base.dev;
-
 
4028
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
-
 
4029
	int lane, link_bw, fdi_dotclock;
-
 
4030
	bool setup_ok, needs_recompute = false;
-
 
4031
 
-
 
4032
retry:
-
 
4033
	/* FDI is a binary signal running at ~2.7GHz, encoding
-
 
4034
	 * each output octet as 10 bits. The actual frequency
-
 
4035
	 * is stored as a divider into a 100MHz clock, and the
-
 
4036
	 * mode pixel clock is stored in units of 1KHz.
-
 
4037
	 * Hence the bw of each lane in terms of the mode signal
-
 
4038
	 * is:
-
 
4039
	 */
-
 
4040
	link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10;
-
 
4041
 
-
 
4042
	fdi_dotclock = adjusted_mode->clock;
-
 
4043
	fdi_dotclock /= pipe_config->pixel_multiplier;
-
 
4044
 
-
 
4045
	lane = ironlake_get_lanes_required(fdi_dotclock, link_bw,
-
 
4046
					   pipe_config->pipe_bpp);
-
 
4047
 
-
 
4048
	pipe_config->fdi_lanes = lane;
-
 
4049
 
-
 
4050
	intel_link_compute_m_n(pipe_config->pipe_bpp, lane, fdi_dotclock,
-
 
4051
			       link_bw, &pipe_config->fdi_m_n);
-
 
4052
 
-
 
4053
	setup_ok = ironlake_check_fdi_lanes(intel_crtc->base.dev,
-
 
4054
					    intel_crtc->pipe, pipe_config);
-
 
4055
	if (!setup_ok && pipe_config->pipe_bpp > 6*3) {
-
 
4056
		pipe_config->pipe_bpp -= 2*3;
-
 
4057
		DRM_DEBUG_KMS("fdi link bw constraint, reducing pipe bpp to %i\n",
-
 
4058
			      pipe_config->pipe_bpp);
-
 
4059
		needs_recompute = true;
-
 
4060
		pipe_config->bw_constrained = true;
-
 
4061
 
-
 
4062
		goto retry;
-
 
4063
	}
-
 
4064
 
-
 
4065
	if (needs_recompute)
-
 
4066
		return RETRY;
-
 
4067
 
-
 
4068
	return setup_ok ? 0 : -EINVAL;
-
 
4069
}
-
 
4070
 
-
 
4071
static void hsw_compute_ips_config(struct intel_crtc *crtc,
-
 
4072
				   struct intel_crtc_config *pipe_config)
-
 
4073
{
-
 
4074
	pipe_config->ips_enabled = i915_enable_ips &&
-
 
4075
				   hsw_crtc_supports_ips(crtc) &&
-
 
4076
				   pipe_config->pipe_bpp <= 24;
-
 
4077
}
-
 
4078
 
-
 
4079
static int intel_crtc_compute_config(struct intel_crtc *crtc,
3929
				      struct intel_crtc_config *pipe_config)
4080
				     struct intel_crtc_config *pipe_config)
3930
{
4081
{
Line 3931... Line 4082...
3931
	struct drm_device *dev = crtc->dev;
4082
	struct drm_device *dev = crtc->base.dev;
3932
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
4083
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
3933
 
4084
 
3934
	if (HAS_PCH_SPLIT(dev)) {
4085
	if (HAS_PCH_SPLIT(dev)) {
3935
		/* FDI link clock is fixed at 2.7G */
4086
		/* FDI link clock is fixed at 2.7G */
3936
		if (pipe_config->requested_mode.clock * 3
4087
		if (pipe_config->requested_mode.clock * 3
Line 3937... Line 4088...
3937
		    > IRONLAKE_FDI_FREQ * 4)
4088
		    > IRONLAKE_FDI_FREQ * 4)
3938
			return false;
-
 
3939
	}
-
 
3940
 
-
 
3941
	/* All interlaced capable intel hw wants timings in frames. Note though
-
 
3942
	 * that intel_lvds_mode_fixup does some funny tricks with the crtc
-
 
3943
	 * timings, so we need to be careful not to clobber these.*/
4089
			return -EINVAL;
3944
	if (!pipe_config->timings_set)
-
 
3945
		drm_mode_set_crtcinfo(adjusted_mode, 0);
4090
	}
3946
 
4091
 
3947
	/* WaPruneModeWithIncorrectHsyncOffset: Cantiga+ cannot handle modes
4092
	/* Cantiga+ cannot handle modes with a hsync front porch of 0.
3948
	 * with a hsync front porch of 0.
4093
	 * WaPruneModeWithIncorrectHsyncOffset:ctg,elk,ilk,snb,ivb,vlv,hsw.
Line 3949... Line 4094...
3949
	 */
4094
	 */
3950
	if ((INTEL_INFO(dev)->gen > 4 || IS_G4X(dev)) &&
4095
	if ((INTEL_INFO(dev)->gen > 4 || IS_G4X(dev)) &&
3951
		adjusted_mode->hsync_start == adjusted_mode->hdisplay)
4096
		adjusted_mode->hsync_start == adjusted_mode->hdisplay)
3952
		return false;
4097
		return -EINVAL;
3953
 
4098
 
3954
	if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)) && pipe_config->pipe_bpp > 10*3) {
4099
	if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)) && pipe_config->pipe_bpp > 10*3) {
3955
		pipe_config->pipe_bpp = 10*3; /* 12bpc is gen5+ */
4100
		pipe_config->pipe_bpp = 10*3; /* 12bpc is gen5+ */
Line -... Line 4101...
-
 
4101
	} else if (INTEL_INFO(dev)->gen <= 4 && pipe_config->pipe_bpp > 8*3) {
-
 
4102
		/* only a 8bpc pipe, with 6bpc dither through the panel fitter
-
 
4103
		 * for lvds. */
-
 
4104
		pipe_config->pipe_bpp = 8*3;
-
 
4105
	}
-
 
4106
 
-
 
4107
	if (HAS_IPS(dev))
-
 
4108
		hsw_compute_ips_config(crtc, pipe_config);
-
 
4109
 
-
 
4110
	/* XXX: PCH clock sharing is done in ->mode_set, so make sure the old
-
 
4111
	 * clock survives for now. */
3956
	} else if (INTEL_INFO(dev)->gen <= 4 && pipe_config->pipe_bpp > 8*3) {
4112
	if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
3957
		/* only a 8bpc pipe, with 6bpc dither through the panel fitter
4113
		pipe_config->shared_dpll = crtc->config.shared_dpll;
Line 3958... Line 4114...
3958
		 * for lvds. */
4114
 
3959
		pipe_config->pipe_bpp = 8*3;
4115
	if (pipe_config->has_pch_encoder)
3960
	}
4116
		return ironlake_fdi_compute_config(crtc, pipe_config);
Line 3980... Line 4136...
3980
static int i9xx_misc_get_display_clock_speed(struct drm_device *dev)
4136
static int i9xx_misc_get_display_clock_speed(struct drm_device *dev)
3981
{
4137
{
3982
	return 200000;
4138
	return 200000;
3983
}
4139
}
Line -... Line 4140...
-
 
4140
 
-
 
4141
static int pnv_get_display_clock_speed(struct drm_device *dev)
-
 
4142
{
-
 
4143
	u16 gcfgc = 0;
-
 
4144
 
-
 
4145
	pci_read_config_word(dev->pdev, GCFGC, &gcfgc);
-
 
4146
 
-
 
4147
	switch (gcfgc & GC_DISPLAY_CLOCK_MASK) {
-
 
4148
	case GC_DISPLAY_CLOCK_267_MHZ_PNV:
-
 
4149
		return 267000;
-
 
4150
	case GC_DISPLAY_CLOCK_333_MHZ_PNV:
-
 
4151
		return 333000;
-
 
4152
	case GC_DISPLAY_CLOCK_444_MHZ_PNV:
-
 
4153
		return 444000;
-
 
4154
	case GC_DISPLAY_CLOCK_200_MHZ_PNV:
-
 
4155
		return 200000;
-
 
4156
	default:
-
 
4157
		DRM_ERROR("Unknown pnv display core clock 0x%04x\n", gcfgc);
-
 
4158
	case GC_DISPLAY_CLOCK_133_MHZ_PNV:
-
 
4159
		return 133000;
-
 
4160
	case GC_DISPLAY_CLOCK_167_MHZ_PNV:
-
 
4161
		return 167000;
-
 
4162
	}
-
 
4163
}
3984
 
4164
 
3985
static int i915gm_get_display_clock_speed(struct drm_device *dev)
4165
static int i915gm_get_display_clock_speed(struct drm_device *dev)
3986
{
4166
{
Line 3987... Line 4167...
3987
	u16 gcfgc = 0;
4167
	u16 gcfgc = 0;
Line 4066... Line 4246...
4066
 
4246
 
4067
static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
4247
static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
4068
{
4248
{
4069
	if (i915_panel_use_ssc >= 0)
4249
	if (i915_panel_use_ssc >= 0)
4070
		return i915_panel_use_ssc != 0;
4250
		return i915_panel_use_ssc != 0;
4071
	return dev_priv->lvds_use_ssc
4251
	return dev_priv->vbt.lvds_use_ssc
4072
		&& !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE);
4252
		&& !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE);
Line 4073... Line 4253...
4073
}
4253
}
4074
 
4254
 
Line 4102... Line 4282...
4102
 
4282
 
4103
	if (IS_VALLEYVIEW(dev)) {
4283
	if (IS_VALLEYVIEW(dev)) {
4104
		refclk = vlv_get_refclk(crtc);
4284
		refclk = vlv_get_refclk(crtc);
4105
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
4285
	} else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
4106
	    intel_panel_use_ssc(dev_priv) && num_connectors < 2) {
4286
	    intel_panel_use_ssc(dev_priv) && num_connectors < 2) {
4107
		refclk = dev_priv->lvds_ssc_freq * 1000;
4287
		refclk = dev_priv->vbt.lvds_ssc_freq * 1000;
4108
		DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n",
4288
		DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n",
4109
			      refclk / 1000);
4289
			      refclk / 1000);
4110
	} else if (!IS_GEN2(dev)) {
4290
	} else if (!IS_GEN2(dev)) {
4111
		refclk = 96000;
4291
		refclk = 96000;
Line 4114... Line 4294...
4114
	}
4294
	}
Line 4115... Line 4295...
4115
 
4295
 
4116
	return refclk;
4296
	return refclk;
Line 4117... Line 4297...
4117
}
4297
}
4118
 
4298
 
4119
static void i9xx_adjust_sdvo_tv_clock(struct intel_crtc *crtc)
-
 
4120
{
4299
static uint32_t pnv_dpll_compute_fp(struct dpll *dpll)
4121
	unsigned dotclock = crtc->config.adjusted_mode.clock;
-
 
4122
	struct dpll *clock = &crtc->config.dpll;
-
 
4123
 
-
 
4124
	/* SDVO TV has fixed PLL values depend on its clock range,
-
 
4125
	   this mirrors vbios setting. */
-
 
4126
	if (dotclock >= 100000 && dotclock < 140500) {
-
 
4127
		clock->p1 = 2;
-
 
4128
		clock->p2 = 10;
-
 
4129
		clock->n = 3;
-
 
4130
		clock->m1 = 16;
-
 
4131
		clock->m2 = 8;
-
 
4132
	} else if (dotclock >= 140500 && dotclock <= 200000) {
-
 
4133
		clock->p1 = 1;
-
 
4134
		clock->p2 = 10;
-
 
4135
		clock->n = 6;
-
 
4136
		clock->m1 = 12;
4300
{
Line -... Line 4301...
-
 
4301
	return (1 << dpll->n) << 16 | dpll->m2;
-
 
4302
}
4137
		clock->m2 = 8;
4303
 
4138
	}
4304
static uint32_t i9xx_dpll_compute_fp(struct dpll *dpll)
Line 4139... Line 4305...
4139
 
4305
{
4140
	crtc->config.clock_set = true;
4306
	return dpll->n << 16 | dpll->m1 << 8 | dpll->m2;
4141
}
4307
}
4142
 
4308
 
4143
static void i9xx_update_pll_dividers(struct intel_crtc *crtc,
4309
static void i9xx_update_pll_dividers(struct intel_crtc *crtc,
4144
				     intel_clock_t *reduced_clock)
4310
				     intel_clock_t *reduced_clock)
4145
{
4311
{
4146
	struct drm_device *dev = crtc->base.dev;
-
 
Line 4147... Line 4312...
4147
	struct drm_i915_private *dev_priv = dev->dev_private;
4312
	struct drm_device *dev = crtc->base.dev;
4148
	int pipe = crtc->pipe;
4313
	struct drm_i915_private *dev_priv = dev->dev_private;
4149
	u32 fp, fp2 = 0;
4314
	int pipe = crtc->pipe;
4150
	struct dpll *clock = &crtc->config.dpll;
-
 
4151
 
4315
	u32 fp, fp2 = 0;
4152
	if (IS_PINEVIEW(dev)) {
4316
 
4153
		fp = (1 << clock->n) << 16 | clock->m1 << 8 | clock->m2;
4317
	if (IS_PINEVIEW(dev)) {
4154
		if (reduced_clock)
4318
		fp = pnv_dpll_compute_fp(&crtc->config.dpll);
4155
			fp2 = (1 << reduced_clock->n) << 16 |
4319
		if (reduced_clock)
4156
				reduced_clock->m1 << 8 | reduced_clock->m2;
-
 
4157
	} else {
4320
			fp2 = pnv_dpll_compute_fp(reduced_clock);
Line 4158... Line 4321...
4158
		fp = clock->n << 16 | clock->m1 << 8 | clock->m2;
4321
	} else {
-
 
4322
		fp = i9xx_dpll_compute_fp(&crtc->config.dpll);
Line 4159... Line 4323...
4159
		if (reduced_clock)
4323
		if (reduced_clock)
4160
			fp2 = reduced_clock->n << 16 | reduced_clock->m1 << 8 |
4324
			fp2 = i9xx_dpll_compute_fp(reduced_clock);
4161
				reduced_clock->m2;
4325
	}
4162
	}
4326
 
-
 
4327
	I915_WRITE(FP0(pipe), fp);
4163
 
4328
	crtc->config.dpll_hw_state.fp0 = fp;
4164
	I915_WRITE(FP0(pipe), fp);
4329
 
4165
 
4330
	crtc->lowfreq_avail = false;
-
 
4331
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
-
 
4332
	    reduced_clock && i915_powersave) {
-
 
4333
		I915_WRITE(FP1(pipe), fp2);
-
 
4334
		crtc->config.dpll_hw_state.fp1 = fp2;
-
 
4335
		crtc->lowfreq_avail = true;
-
 
4336
	} else {
-
 
4337
		I915_WRITE(FP1(pipe), fp);
-
 
4338
		crtc->config.dpll_hw_state.fp1 = fp;
-
 
4339
	}
-
 
4340
}
-
 
4341
 
-
 
4342
static void vlv_pllb_recal_opamp(struct drm_i915_private *dev_priv)
-
 
4343
{
-
 
4344
	u32 reg_val;
-
 
4345
 
-
 
4346
	/*
-
 
4347
	 * PLLB opamp always calibrates to max value of 0x3f, force enable it
-
 
4348
	 * and set it to a reasonable value instead.
-
 
4349
	 */
-
 
4350
	reg_val = vlv_dpio_read(dev_priv, DPIO_IREF(1));
-
 
4351
	reg_val &= 0xffffff00;
-
 
4352
	reg_val |= 0x00000030;
-
 
4353
	vlv_dpio_write(dev_priv, DPIO_IREF(1), reg_val);
-
 
4354
 
-
 
4355
	reg_val = vlv_dpio_read(dev_priv, DPIO_CALIBRATION);
-
 
4356
	reg_val &= 0x8cffffff;
-
 
4357
	reg_val = 0x8c000000;
-
 
4358
	vlv_dpio_write(dev_priv, DPIO_CALIBRATION, reg_val);
-
 
4359
 
-
 
4360
	reg_val = vlv_dpio_read(dev_priv, DPIO_IREF(1));
-
 
4361
	reg_val &= 0xffffff00;
-
 
4362
	vlv_dpio_write(dev_priv, DPIO_IREF(1), reg_val);
-
 
4363
 
-
 
4364
	reg_val = vlv_dpio_read(dev_priv, DPIO_CALIBRATION);
-
 
4365
	reg_val &= 0x00ffffff;
-
 
4366
	reg_val |= 0xb0000000;
-
 
4367
	vlv_dpio_write(dev_priv, DPIO_CALIBRATION, reg_val);
-
 
4368
}
-
 
4369
 
-
 
4370
static void intel_pch_transcoder_set_m_n(struct intel_crtc *crtc,
-
 
4371
					 struct intel_link_m_n *m_n)
-
 
4372
{
-
 
4373
	struct drm_device *dev = crtc->base.dev;
-
 
4374
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4375
	int pipe = crtc->pipe;
-
 
4376
 
-
 
4377
	I915_WRITE(PCH_TRANS_DATA_M1(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m);
-
 
4378
	I915_WRITE(PCH_TRANS_DATA_N1(pipe), m_n->gmch_n);
-
 
4379
	I915_WRITE(PCH_TRANS_LINK_M1(pipe), m_n->link_m);
-
 
4380
	I915_WRITE(PCH_TRANS_LINK_N1(pipe), m_n->link_n);
-
 
4381
}
-
 
4382
 
-
 
4383
static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc,
-
 
4384
					 struct intel_link_m_n *m_n)
-
 
4385
{
-
 
4386
	struct drm_device *dev = crtc->base.dev;
-
 
4387
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4388
	int pipe = crtc->pipe;
-
 
4389
	enum transcoder transcoder = crtc->config.cpu_transcoder;
-
 
4390
 
-
 
4391
	if (INTEL_INFO(dev)->gen >= 5) {
-
 
4392
		I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m);
-
 
4393
		I915_WRITE(PIPE_DATA_N1(transcoder), m_n->gmch_n);
4166
	crtc->lowfreq_avail = false;
4394
		I915_WRITE(PIPE_LINK_M1(transcoder), m_n->link_m);
4167
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
4395
		I915_WRITE(PIPE_LINK_N1(transcoder), m_n->link_n);
Line 4168... Line 4396...
4168
	    reduced_clock && i915_powersave) {
4396
	} else {
4169
		I915_WRITE(FP1(pipe), fp2);
4397
		I915_WRITE(PIPE_DATA_M_G4X(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m);
Line 4184... Line 4412...
4184
static void vlv_update_pll(struct intel_crtc *crtc)
4412
static void vlv_update_pll(struct intel_crtc *crtc)
4185
{
4413
{
4186
	struct drm_device *dev = crtc->base.dev;
4414
	struct drm_device *dev = crtc->base.dev;
4187
	struct drm_i915_private *dev_priv = dev->dev_private;
4415
	struct drm_i915_private *dev_priv = dev->dev_private;
4188
	int pipe = crtc->pipe;
4416
	int pipe = crtc->pipe;
4189
	u32 dpll, mdiv, pdiv;
4417
	u32 dpll, mdiv;
4190
	u32 bestn, bestm1, bestm2, bestp1, bestp2;
4418
	u32 bestn, bestm1, bestm2, bestp1, bestp2;
4191
	bool is_sdvo;
4419
	u32 coreclk, reg_val, dpll_md;
4192
	u32 temp;
-
 
Line 4193... Line 4420...
4193
 
4420
 
Line 4194... Line -...
4194
	mutex_lock(&dev_priv->dpio_lock);
-
 
4195
 
-
 
4196
	is_sdvo = intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_SDVO) ||
-
 
4197
		intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI);
-
 
4198
 
-
 
4199
	dpll = DPLL_VGA_MODE_DIS;
-
 
4200
	dpll |= DPLL_EXT_BUFFER_ENABLE_VLV;
-
 
4201
	dpll |= DPLL_REFA_CLK_ENABLE_VLV;
-
 
4202
	dpll |= DPLL_INTEGRATED_CLOCK_VLV;
-
 
4203
 
-
 
4204
	I915_WRITE(DPLL(pipe), dpll);
-
 
4205
	POSTING_READ(DPLL(pipe));
4421
	mutex_lock(&dev_priv->dpio_lock);
4206
 
4422
 
4207
	bestn = crtc->config.dpll.n;
4423
	bestn = crtc->config.dpll.n;
4208
	bestm1 = crtc->config.dpll.m1;
4424
	bestm1 = crtc->config.dpll.m1;
4209
	bestm2 = crtc->config.dpll.m2;
4425
	bestm2 = crtc->config.dpll.m2;
Line -... Line 4426...
-
 
4426
	bestp1 = crtc->config.dpll.p1;
-
 
4427
	bestp2 = crtc->config.dpll.p2;
-
 
4428
 
-
 
4429
	/* See eDP HDMI DPIO driver vbios notes doc */
-
 
4430
 
4210
	bestp1 = crtc->config.dpll.p1;
4431
	/* PLL B needs special handling */
-
 
4432
	if (pipe)
-
 
4433
		vlv_pllb_recal_opamp(dev_priv);
-
 
4434
 
-
 
4435
	/* Set up Tx target for periodic Rcomp update */
-
 
4436
	vlv_dpio_write(dev_priv, DPIO_IREF_BCAST, 0x0100000f);
-
 
4437
 
4211
	bestp2 = crtc->config.dpll.p2;
4438
	/* Disable target IRef on PLL */
-
 
4439
	reg_val = vlv_dpio_read(dev_priv, DPIO_IREF_CTL(pipe));
4212
 
4440
	reg_val &= 0x00ffffff;
-
 
4441
	vlv_dpio_write(dev_priv, DPIO_IREF_CTL(pipe), reg_val);
4213
	/*
4442
 
-
 
4443
	/* Disable fast lock */
4214
	 * In Valleyview PLL and program lane counter registers are exposed
4444
	vlv_dpio_write(dev_priv, DPIO_FASTCLK_DISABLE, 0x610);
4215
	 * through DPIO interface
4445
 
4216
	 */
4446
	/* Set idtafcrecal before PLL is enabled */
4217
	mdiv = ((bestm1 << DPIO_M1DIV_SHIFT) | (bestm2 & DPIO_M2DIV_MASK));
-
 
4218
	mdiv |= ((bestp1 << DPIO_P1_SHIFT) | (bestp2 << DPIO_P2_SHIFT));
4447
	mdiv = ((bestm1 << DPIO_M1DIV_SHIFT) | (bestm2 & DPIO_M2DIV_MASK));
4219
	mdiv |= ((bestn << DPIO_N_SHIFT));
-
 
4220
	mdiv |= (1 << DPIO_POST_DIV_SHIFT);
-
 
Line -... Line 4448...
-
 
4448
	mdiv |= ((bestp1 << DPIO_P1_SHIFT) | (bestp2 << DPIO_P2_SHIFT));
-
 
4449
	mdiv |= ((bestn << DPIO_N_SHIFT));
-
 
4450
	mdiv |= (1 << DPIO_K_SHIFT);
-
 
4451
 
-
 
4452
	/*
-
 
4453
	 * Post divider depends on pixel clock rate, DAC vs digital (and LVDS,
4221
	mdiv |= (1 << DPIO_K_SHIFT);
4454
	 * but we don't support that).
Line 4222... Line -...
4222
	mdiv |= DPIO_ENABLE_CALIBRATION;
-
 
4223
	intel_dpio_write(dev_priv, DPIO_DIV(pipe), mdiv);
-
 
4224
 
-
 
4225
	intel_dpio_write(dev_priv, DPIO_CORE_CLK(pipe), 0x01000000);
4455
	 * Note: don't use the DAC post divider as it seems unstable.
4226
 
4456
	 */
Line -... Line 4457...
-
 
4457
	mdiv |= (DPIO_POST_DIV_HDMIDP << DPIO_POST_DIV_SHIFT);
-
 
4458
	vlv_dpio_write(dev_priv, DPIO_DIV(pipe), mdiv);
-
 
4459
 
-
 
4460
	mdiv |= DPIO_ENABLE_CALIBRATION;
-
 
4461
	vlv_dpio_write(dev_priv, DPIO_DIV(pipe), mdiv);
-
 
4462
 
-
 
4463
	/* Set HBR and RBR LPF coefficients */
-
 
4464
	if (crtc->config.port_clock == 162000 ||
-
 
4465
	    intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_ANALOG) ||
-
 
4466
	    intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI))
-
 
4467
		vlv_dpio_write(dev_priv, DPIO_LPF_COEFF(pipe),
-
 
4468
				 0x009f0003);
-
 
4469
	else
-
 
4470
		vlv_dpio_write(dev_priv, DPIO_LPF_COEFF(pipe),
-
 
4471
				 0x00d0000f);
-
 
4472
 
-
 
4473
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP) ||
-
 
4474
	    intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT)) {
-
 
4475
		/* Use SSC source */
-
 
4476
		if (!pipe)
-
 
4477
			vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe),
-
 
4478
					 0x0df40000);
-
 
4479
		else
-
 
4480
			vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe),
-
 
4481
					 0x0df70000);
-
 
4482
	} else { /* HDMI or VGA */
-
 
4483
		/* Use bend source */
-
 
4484
		if (!pipe)
-
 
4485
			vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe),
-
 
4486
					 0x0df70000);
-
 
4487
		else
-
 
4488
			vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe),
-
 
4489
					 0x0df40000);
-
 
4490
	}
-
 
4491
 
-
 
4492
	coreclk = vlv_dpio_read(dev_priv, DPIO_CORE_CLK(pipe));
4227
	pdiv = (1 << DPIO_REFSEL_OVERRIDE) | (5 << DPIO_PLL_MODESEL_SHIFT) |
4493
	coreclk = (coreclk & 0x0000ff00) | 0x01c00000;
-
 
4494
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT) ||
-
 
4495
	    intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP))
-
 
4496
		coreclk |= 0x01000000;
-
 
4497
	vlv_dpio_write(dev_priv, DPIO_CORE_CLK(pipe), coreclk);
-
 
4498
 
-
 
4499
	vlv_dpio_write(dev_priv, DPIO_PLL_CML(pipe), 0x87871000);
Line 4228... Line 4500...
4228
		(3 << DPIO_BIAS_CURRENT_CTL_SHIFT) | (1<<20) |
4500
 
4229
		(7 << DPIO_PLL_REFCLK_SEL_SHIFT) | (8 << DPIO_DRIVER_CTL_SHIFT) |
-
 
4230
		(5 << DPIO_CLK_BIAS_CTL_SHIFT);
-
 
4231
	intel_dpio_write(dev_priv, DPIO_REFSFR(pipe), pdiv);
-
 
4232
 
4501
	/* Enable DPIO clock input */
Line 4233... Line 4502...
4233
	intel_dpio_write(dev_priv, DPIO_LFP_COEFF(pipe), 0x005f003b);
4502
	dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV |
-
 
4503
		DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV;
-
 
4504
	if (pipe)
Line 4234... Line 4505...
4234
 
4505
		dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
4235
	dpll |= DPLL_VCO_ENABLE;
4506
 
Line 4236... Line -...
4236
	I915_WRITE(DPLL(pipe), dpll);
-
 
4237
	POSTING_READ(DPLL(pipe));
-
 
4238
	if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
-
 
4239
		DRM_ERROR("DPLL %d failed to lock\n", pipe);
-
 
4240
 
-
 
4241
	intel_dpio_write(dev_priv, DPIO_FASTCLK_DISABLE, 0x620);
-
 
4242
 
-
 
4243
	if (crtc->config.has_dp_encoder)
-
 
4244
		intel_dp_set_m_n(crtc);
-
 
4245
 
-
 
4246
	I915_WRITE(DPLL(pipe), dpll);
-
 
4247
 
-
 
4248
	/* Wait for the clocks to stabilize. */
-
 
4249
	POSTING_READ(DPLL(pipe));
-
 
4250
	udelay(150);
-
 
4251
 
-
 
4252
	temp = 0;
-
 
4253
	if (is_sdvo) {
-
 
4254
			temp = 0;
-
 
4255
		if (crtc->config.pixel_multiplier > 1) {
-
 
4256
			temp = (crtc->config.pixel_multiplier - 1)
-
 
4257
				<< DPLL_MD_UDI_MULTIPLIER_SHIFT;
-
 
4258
		}
-
 
4259
	}
-
 
4260
		I915_WRITE(DPLL_MD(pipe), temp);
-
 
4261
		POSTING_READ(DPLL_MD(pipe));
-
 
4262
 
-
 
4263
	/* Now program lane control registers */
-
 
4264
	if(intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT)
-
 
4265
	   || intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI)) {
-
 
4266
		temp = 0x1000C4;
-
 
4267
		if(pipe == 1)
-
 
4268
			temp |= (1 << 21);
-
 
4269
		intel_dpio_write(dev_priv, DPIO_DATA_CHANNEL1, temp);
4507
	dpll |= DPLL_VCO_ENABLE;
4270
	}
4508
	crtc->config.dpll_hw_state.dpll = dpll;
Line 4271... Line 4509...
4271
 
4509
 
4272
	if(intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP)) {
4510
	dpll_md = (crtc->config.pixel_multiplier - 1)
4273
		temp = 0x1000C4;
4511
		<< DPLL_MD_UDI_MULTIPLIER_SHIFT;
4274
		if(pipe == 1)
4512
	crtc->config.dpll_hw_state.dpll_md = dpll_md;
4275
			temp |= (1 << 21);
4513
 
4276
		intel_dpio_write(dev_priv, DPIO_DATA_CHANNEL2, temp);
4514
	if (crtc->config.has_dp_encoder)
4277
	}
-
 
4278
 
-
 
4279
	mutex_unlock(&dev_priv->dpio_lock);
4515
		intel_dp_set_m_n(crtc);
4280
}
4516
 
4281
 
4517
	mutex_unlock(&dev_priv->dpio_lock);
Line 4282... Line 4518...
4282
static void i9xx_update_pll(struct intel_crtc *crtc,
4518
}
Line 4301... Line 4537...
4301
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS))
4537
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS))
4302
		dpll |= DPLLB_MODE_LVDS;
4538
		dpll |= DPLLB_MODE_LVDS;
4303
	else
4539
	else
4304
		dpll |= DPLLB_MODE_DAC_SERIAL;
4540
		dpll |= DPLLB_MODE_DAC_SERIAL;
Line 4305... Line -...
4305
 
-
 
4306
	if (is_sdvo) {
-
 
4307
		if ((crtc->config.pixel_multiplier > 1) &&
4541
 
4308
		    (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))) {
4542
	if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) {
4309
			dpll |= (crtc->config.pixel_multiplier - 1)
4543
			dpll |= (crtc->config.pixel_multiplier - 1)
4310
				<< SDVO_MULTIPLIER_SHIFT_HIRES;
4544
				<< SDVO_MULTIPLIER_SHIFT_HIRES;
-
 
4545
		}
-
 
4546
 
4311
		}
4547
	if (is_sdvo)
4312
		dpll |= DPLL_DVO_HIGH_SPEED;
4548
		dpll |= DPLL_SDVO_HIGH_SPEED;
4313
	}
4549
 
4314
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT))
4550
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT))
Line 4315... Line 4551...
4315
		dpll |= DPLL_DVO_HIGH_SPEED;
4551
		dpll |= DPLL_SDVO_HIGH_SPEED;
4316
 
4552
 
4317
	/* compute bitmask from p1 value */
4553
	/* compute bitmask from p1 value */
4318
	if (IS_PINEVIEW(dev))
4554
	if (IS_PINEVIEW(dev))
Line 4337... Line 4573...
4337
		break;
4573
		break;
4338
	}
4574
	}
4339
	if (INTEL_INFO(dev)->gen >= 4)
4575
	if (INTEL_INFO(dev)->gen >= 4)
4340
		dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT);
4576
		dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT);
Line 4341... Line 4577...
4341
 
4577
 
4342
	if (is_sdvo && intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_TVOUT))
4578
	if (crtc->config.sdvo_tv_clock)
4343
		dpll |= PLL_REF_INPUT_TVCLKINBC;
-
 
4344
	else if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_TVOUT))
-
 
4345
		/* XXX: just matching BIOS for now */
-
 
4346
		/*	dpll |= PLL_REF_INPUT_TVCLKINBC; */
-
 
4347
		dpll |= 3;
4579
		dpll |= PLL_REF_INPUT_TVCLKINBC;
4348
	else if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
4580
	else if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
4349
		 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
4581
		 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
4350
		dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
4582
		dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
4351
	else
4583
	else
Line 4352... Line 4584...
4352
		dpll |= PLL_REF_INPUT_DREFCLK;
4584
		dpll |= PLL_REF_INPUT_DREFCLK;
4353
 
-
 
4354
	dpll |= DPLL_VCO_ENABLE;
-
 
4355
	I915_WRITE(DPLL(pipe), dpll & ~DPLL_VCO_ENABLE);
-
 
4356
	POSTING_READ(DPLL(pipe));
-
 
4357
	udelay(150);
-
 
4358
 
-
 
4359
	for_each_encoder_on_crtc(dev, &crtc->base, encoder)
-
 
4360
		if (encoder->pre_pll_enable)
-
 
4361
			encoder->pre_pll_enable(encoder);
4585
 
4362
 
-
 
4363
	if (crtc->config.has_dp_encoder)
-
 
4364
		intel_dp_set_m_n(crtc);
-
 
4365
 
-
 
4366
	I915_WRITE(DPLL(pipe), dpll);
-
 
4367
 
-
 
4368
	/* Wait for the clocks to stabilize. */
-
 
Line 4369... Line 4586...
4369
	POSTING_READ(DPLL(pipe));
4586
	dpll |= DPLL_VCO_ENABLE;
4370
	udelay(150);
-
 
4371
 
-
 
4372
	if (INTEL_INFO(dev)->gen >= 4) {
-
 
4373
		u32 temp = 0;
-
 
4374
		if (is_sdvo) {
4587
	crtc->config.dpll_hw_state.dpll = dpll;
4375
				temp = 0;
4588
 
-
 
4589
	if (INTEL_INFO(dev)->gen >= 4) {
4376
			if (crtc->config.pixel_multiplier > 1) {
4590
		u32 dpll_md = (crtc->config.pixel_multiplier - 1)
4377
				temp = (crtc->config.pixel_multiplier - 1)
4591
					<< DPLL_MD_UDI_MULTIPLIER_SHIFT;
4378
					<< DPLL_MD_UDI_MULTIPLIER_SHIFT;
4592
		crtc->config.dpll_hw_state.dpll_md = dpll_md;
4379
			}
-
 
4380
	}
-
 
4381
		I915_WRITE(DPLL_MD(pipe), temp);
-
 
4382
	} else {
-
 
4383
		/* The pixel multiplier can only be updated once the
4593
	}
4384
		 * DPLL is enabled and the clocks are stable.
-
 
4385
		 *
-
 
4386
		 * So write it again.
-
 
4387
		 */
4594
 
Line 4388... Line 4595...
4388
		I915_WRITE(DPLL(pipe), dpll);
4595
	if (crtc->config.has_dp_encoder)
4389
	}
-
 
4390
}
4596
		intel_dp_set_m_n(crtc);
4391
 
4597
}
4392
static void i8xx_update_pll(struct intel_crtc *crtc,
4598
 
4393
			    struct drm_display_mode *adjusted_mode,
4599
static void i8xx_update_pll(struct intel_crtc *crtc,
4394
			    intel_clock_t *reduced_clock,
4600
			    intel_clock_t *reduced_clock,
4395
			    int num_connectors)
-
 
4396
{
-
 
4397
	struct drm_device *dev = crtc->base.dev;
4601
			    int num_connectors)
4398
	struct drm_i915_private *dev_priv = dev->dev_private;
4602
{
Line 4399... Line 4603...
4399
	struct intel_encoder *encoder;
4603
	struct drm_device *dev = crtc->base.dev;
Line 4414... Line 4618...
4414
			dpll |= (clock->p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT;
4618
			dpll |= (clock->p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT;
4415
		if (clock->p2 == 4)
4619
		if (clock->p2 == 4)
4416
			dpll |= PLL_P2_DIVIDE_BY_4;
4620
			dpll |= PLL_P2_DIVIDE_BY_4;
4417
	}
4621
	}
Line -... Line 4622...
-
 
4622
 
-
 
4623
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DVO))
-
 
4624
		dpll |= DPLL_DVO_2X_MODE;
4418
 
4625
 
4419
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
4626
	if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) &&
4420
		 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
4627
		 intel_panel_use_ssc(dev_priv) && num_connectors < 2)
4421
		dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
4628
		dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
4422
	else
4629
	else
Line 4423... Line 4630...
4423
		dpll |= PLL_REF_INPUT_DREFCLK;
4630
		dpll |= PLL_REF_INPUT_DREFCLK;
4424
 
-
 
4425
	dpll |= DPLL_VCO_ENABLE;
-
 
4426
	I915_WRITE(DPLL(pipe), dpll & ~DPLL_VCO_ENABLE);
-
 
4427
	POSTING_READ(DPLL(pipe));
-
 
4428
	udelay(150);
-
 
4429
 
-
 
4430
	for_each_encoder_on_crtc(dev, &crtc->base, encoder)
4631
 
4431
		if (encoder->pre_pll_enable)
-
 
4432
			encoder->pre_pll_enable(encoder);
-
 
4433
 
-
 
4434
	I915_WRITE(DPLL(pipe), dpll);
-
 
4435
 
-
 
4436
	/* Wait for the clocks to stabilize. */
-
 
4437
	POSTING_READ(DPLL(pipe));
-
 
4438
	udelay(150);
-
 
4439
 
-
 
4440
	/* The pixel multiplier can only be updated once the
-
 
4441
	 * DPLL is enabled and the clocks are stable.
-
 
4442
	 *
-
 
4443
	 * So write it again.
-
 
4444
	 */
4632
	dpll |= DPLL_VCO_ENABLE;
Line 4445... Line 4633...
4445
	I915_WRITE(DPLL(pipe), dpll);
4633
	crtc->config.dpll_hw_state.dpll = dpll;
4446
}
-
 
4447
 
-
 
4448
static void intel_set_pipe_timings(struct intel_crtc *intel_crtc,
4634
}
4449
				   struct drm_display_mode *mode,
4635
 
4450
				   struct drm_display_mode *adjusted_mode)
4636
static void intel_set_pipe_timings(struct intel_crtc *intel_crtc)
4451
{
4637
{
4452
	struct drm_device *dev = intel_crtc->base.dev;
4638
	struct drm_device *dev = intel_crtc->base.dev;
-
 
4639
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4640
	enum pipe pipe = intel_crtc->pipe;
-
 
4641
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
4453
	struct drm_i915_private *dev_priv = dev->dev_private;
4642
	struct drm_display_mode *adjusted_mode =
-
 
4643
		&intel_crtc->config.adjusted_mode;
-
 
4644
	struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
-
 
4645
	uint32_t vsyncshift, crtc_vtotal, crtc_vblank_end;
-
 
4646
 
-
 
4647
	/* We need to be careful not to changed the adjusted mode, for otherwise
Line 4454... Line 4648...
4454
	enum pipe pipe = intel_crtc->pipe;
4648
	 * the hw state checker will get angry at the mismatch. */
4455
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
4649
	crtc_vtotal = adjusted_mode->crtc_vtotal;
4456
	uint32_t vsyncshift;
4650
	crtc_vblank_end = adjusted_mode->crtc_vblank_end;
4457
 
4651
 
4458
	if (!IS_GEN2(dev) && adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) {
4652
	if (!IS_GEN2(dev) && adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) {
4459
		/* the chip adds 2 halflines automatically */
4653
		/* the chip adds 2 halflines automatically */
4460
		adjusted_mode->crtc_vtotal -= 1;
4654
		crtc_vtotal -= 1;
4461
		adjusted_mode->crtc_vblank_end -= 1;
4655
		crtc_vblank_end -= 1;
4462
		vsyncshift = adjusted_mode->crtc_hsync_start
4656
		vsyncshift = adjusted_mode->crtc_hsync_start
Line 4478... Line 4672...
4478
		   (adjusted_mode->crtc_hsync_start - 1) |
4672
		   (adjusted_mode->crtc_hsync_start - 1) |
4479
		   ((adjusted_mode->crtc_hsync_end - 1) << 16));
4673
		   ((adjusted_mode->crtc_hsync_end - 1) << 16));
Line 4480... Line 4674...
4480
 
4674
 
4481
	I915_WRITE(VTOTAL(cpu_transcoder),
4675
	I915_WRITE(VTOTAL(cpu_transcoder),
4482
		   (adjusted_mode->crtc_vdisplay - 1) |
4676
		   (adjusted_mode->crtc_vdisplay - 1) |
4483
		   ((adjusted_mode->crtc_vtotal - 1) << 16));
4677
		   ((crtc_vtotal - 1) << 16));
4484
	I915_WRITE(VBLANK(cpu_transcoder),
4678
	I915_WRITE(VBLANK(cpu_transcoder),
4485
		   (adjusted_mode->crtc_vblank_start - 1) |
4679
		   (adjusted_mode->crtc_vblank_start - 1) |
4486
		   ((adjusted_mode->crtc_vblank_end - 1) << 16));
4680
		   ((crtc_vblank_end - 1) << 16));
4487
	I915_WRITE(VSYNC(cpu_transcoder),
4681
	I915_WRITE(VSYNC(cpu_transcoder),
4488
		   (adjusted_mode->crtc_vsync_start - 1) |
4682
		   (adjusted_mode->crtc_vsync_start - 1) |
Line 4489... Line 4683...
4489
		   ((adjusted_mode->crtc_vsync_end - 1) << 16));
4683
		   ((adjusted_mode->crtc_vsync_end - 1) << 16));
Line 4501... Line 4695...
4501
	 */
4695
	 */
4502
	I915_WRITE(PIPESRC(pipe),
4696
	I915_WRITE(PIPESRC(pipe),
4503
		   ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
4697
		   ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1));
4504
}
4698
}
Line -... Line 4699...
-
 
4699
 
-
 
4700
static void intel_get_pipe_timings(struct intel_crtc *crtc,
-
 
4701
				   struct intel_crtc_config *pipe_config)
-
 
4702
{
-
 
4703
	struct drm_device *dev = crtc->base.dev;
-
 
4704
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4705
	enum transcoder cpu_transcoder = pipe_config->cpu_transcoder;
-
 
4706
	uint32_t tmp;
-
 
4707
 
-
 
4708
	tmp = I915_READ(HTOTAL(cpu_transcoder));
-
 
4709
	pipe_config->adjusted_mode.crtc_hdisplay = (tmp & 0xffff) + 1;
-
 
4710
	pipe_config->adjusted_mode.crtc_htotal = ((tmp >> 16) & 0xffff) + 1;
-
 
4711
	tmp = I915_READ(HBLANK(cpu_transcoder));
-
 
4712
	pipe_config->adjusted_mode.crtc_hblank_start = (tmp & 0xffff) + 1;
-
 
4713
	pipe_config->adjusted_mode.crtc_hblank_end = ((tmp >> 16) & 0xffff) + 1;
-
 
4714
	tmp = I915_READ(HSYNC(cpu_transcoder));
-
 
4715
	pipe_config->adjusted_mode.crtc_hsync_start = (tmp & 0xffff) + 1;
-
 
4716
	pipe_config->adjusted_mode.crtc_hsync_end = ((tmp >> 16) & 0xffff) + 1;
-
 
4717
 
-
 
4718
	tmp = I915_READ(VTOTAL(cpu_transcoder));
-
 
4719
	pipe_config->adjusted_mode.crtc_vdisplay = (tmp & 0xffff) + 1;
-
 
4720
	pipe_config->adjusted_mode.crtc_vtotal = ((tmp >> 16) & 0xffff) + 1;
-
 
4721
	tmp = I915_READ(VBLANK(cpu_transcoder));
-
 
4722
	pipe_config->adjusted_mode.crtc_vblank_start = (tmp & 0xffff) + 1;
-
 
4723
	pipe_config->adjusted_mode.crtc_vblank_end = ((tmp >> 16) & 0xffff) + 1;
-
 
4724
	tmp = I915_READ(VSYNC(cpu_transcoder));
-
 
4725
	pipe_config->adjusted_mode.crtc_vsync_start = (tmp & 0xffff) + 1;
-
 
4726
	pipe_config->adjusted_mode.crtc_vsync_end = ((tmp >> 16) & 0xffff) + 1;
-
 
4727
 
-
 
4728
	if (I915_READ(PIPECONF(cpu_transcoder)) & PIPECONF_INTERLACE_MASK) {
-
 
4729
		pipe_config->adjusted_mode.flags |= DRM_MODE_FLAG_INTERLACE;
-
 
4730
		pipe_config->adjusted_mode.crtc_vtotal += 1;
-
 
4731
		pipe_config->adjusted_mode.crtc_vblank_end += 1;
-
 
4732
	}
-
 
4733
 
-
 
4734
	tmp = I915_READ(PIPESRC(crtc->pipe));
-
 
4735
	pipe_config->requested_mode.vdisplay = (tmp & 0xffff) + 1;
-
 
4736
	pipe_config->requested_mode.hdisplay = ((tmp >> 16) & 0xffff) + 1;
-
 
4737
}
-
 
4738
 
-
 
4739
static void intel_crtc_mode_from_pipe_config(struct intel_crtc *intel_crtc,
-
 
4740
					     struct intel_crtc_config *pipe_config)
-
 
4741
{
-
 
4742
	struct drm_crtc *crtc = &intel_crtc->base;
-
 
4743
 
-
 
4744
	crtc->mode.hdisplay = pipe_config->adjusted_mode.crtc_hdisplay;
-
 
4745
	crtc->mode.htotal = pipe_config->adjusted_mode.crtc_htotal;
-
 
4746
	crtc->mode.hsync_start = pipe_config->adjusted_mode.crtc_hsync_start;
-
 
4747
	crtc->mode.hsync_end = pipe_config->adjusted_mode.crtc_hsync_end;
-
 
4748
 
-
 
4749
	crtc->mode.vdisplay = pipe_config->adjusted_mode.crtc_vdisplay;
-
 
4750
	crtc->mode.vtotal = pipe_config->adjusted_mode.crtc_vtotal;
-
 
4751
	crtc->mode.vsync_start = pipe_config->adjusted_mode.crtc_vsync_start;
-
 
4752
	crtc->mode.vsync_end = pipe_config->adjusted_mode.crtc_vsync_end;
-
 
4753
 
-
 
4754
	crtc->mode.flags = pipe_config->adjusted_mode.flags;
-
 
4755
 
-
 
4756
	crtc->mode.clock = pipe_config->adjusted_mode.clock;
-
 
4757
	crtc->mode.flags |= pipe_config->adjusted_mode.flags;
-
 
4758
}
4505
 
4759
 
4506
static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc)
4760
static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc)
4507
{
4761
{
4508
	struct drm_device *dev = intel_crtc->base.dev;
4762
	struct drm_device *dev = intel_crtc->base.dev;
4509
	struct drm_i915_private *dev_priv = dev->dev_private;
4763
	struct drm_i915_private *dev_priv = dev->dev_private;
Line -... Line 4764...
-
 
4764
	uint32_t pipeconf;
-
 
4765
 
-
 
4766
	pipeconf = 0;
4510
	uint32_t pipeconf;
4767
 
-
 
4768
	if (dev_priv->quirks & QUIRK_PIPEA_FORCE &&
Line 4511... Line 4769...
4511
 
4769
	    I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE)
4512
	pipeconf = I915_READ(PIPECONF(intel_crtc->pipe));
4770
		pipeconf |= PIPECONF_ENABLE;
4513
 
4771
 
4514
	if (intel_crtc->pipe == 0 && INTEL_INFO(dev)->gen < 4) {
4772
	if (intel_crtc->pipe == 0 && INTEL_INFO(dev)->gen < 4) {
Line 4519... Line 4777...
4519
		 * pipe == 0 check?
4777
		 * pipe == 0 check?
4520
		 */
4778
		 */
4521
		if (intel_crtc->config.requested_mode.clock >
4779
		if (intel_crtc->config.requested_mode.clock >
4522
		    dev_priv->display.get_display_clock_speed(dev) * 9 / 10)
4780
		    dev_priv->display.get_display_clock_speed(dev) * 9 / 10)
4523
			pipeconf |= PIPECONF_DOUBLE_WIDE;
4781
			pipeconf |= PIPECONF_DOUBLE_WIDE;
4524
		else
-
 
4525
			pipeconf &= ~PIPECONF_DOUBLE_WIDE;
-
 
4526
	}
4782
	}
Line 4527... Line 4783...
4527
 
4783
 
4528
	/* default to 8bpc */
4784
	/* only g4x and later have fancy bpc/dither controls */
4529
	pipeconf &= ~(PIPECONF_BPC_MASK | PIPECONF_DITHER_EN);
4785
	if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) {
4530
	if (intel_crtc->config.has_dp_encoder) {
4786
		/* Bspec claims that we can't use dithering for 30bpp pipes. */
4531
		if (intel_crtc->config.dither) {
4787
		if (intel_crtc->config.dither && intel_crtc->config.pipe_bpp != 30)
4532
			pipeconf |= PIPECONF_6BPC |
-
 
4533
				    PIPECONF_DITHER_EN |
4788
			pipeconf |= PIPECONF_DITHER_EN |
4534
				    PIPECONF_DITHER_TYPE_SP;
-
 
4535
		}
-
 
Line 4536... Line 4789...
4536
	}
4789
				    PIPECONF_DITHER_TYPE_SP;
-
 
4790
 
4537
 
4791
		switch (intel_crtc->config.pipe_bpp) {
-
 
4792
		case 18:
4538
	if (IS_VALLEYVIEW(dev) && intel_pipe_has_type(&intel_crtc->base,
4793
			pipeconf |= PIPECONF_6BPC;
4539
						      INTEL_OUTPUT_EDP)) {
4794
			break;
4540
		if (intel_crtc->config.dither) {
4795
		case 24:
-
 
4796
			pipeconf |= PIPECONF_8BPC;
4541
			pipeconf |= PIPECONF_6BPC |
4797
			break;
-
 
4798
		case 30:
-
 
4799
			pipeconf |= PIPECONF_10BPC;
-
 
4800
			break;
-
 
4801
		default:
4542
					PIPECONF_ENABLE |
4802
			/* Case prevented by intel_choose_pipe_bpp_dither. */
4543
					I965_PIPECONF_ACTIVE;
4803
			BUG();
Line 4544... Line 4804...
4544
		}
4804
		}
4545
	}
4805
	}
4546
 
4806
 
4547
	if (HAS_PIPE_CXSR(dev)) {
4807
	if (HAS_PIPE_CXSR(dev)) {
4548
		if (intel_crtc->lowfreq_avail) {
4808
		if (intel_crtc->lowfreq_avail) {
4549
			DRM_DEBUG_KMS("enabling CxSR downclocking\n");
4809
			DRM_DEBUG_KMS("enabling CxSR downclocking\n");
4550
			pipeconf |= PIPECONF_CXSR_DOWNCLOCK;
-
 
4551
		} else {
4810
			pipeconf |= PIPECONF_CXSR_DOWNCLOCK;
4552
			DRM_DEBUG_KMS("disabling CxSR downclocking\n");
4811
		} else {
Line 4553... Line -...
4553
			pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK;
-
 
4554
		}
4812
			DRM_DEBUG_KMS("disabling CxSR downclocking\n");
4555
	}
4813
		}
4556
 
4814
	}
4557
	pipeconf &= ~PIPECONF_INTERLACE_MASK;
4815
 
4558
	if (!IS_GEN2(dev) &&
4816
	if (!IS_GEN2(dev) &&
Line 4559... Line -...
4559
	    intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
-
 
4560
		pipeconf |= PIPECONF_INTERLACE_W_FIELD_INDICATION;
4817
	    intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
4561
	else
4818
		pipeconf |= PIPECONF_INTERLACE_W_FIELD_INDICATION;
4562
		pipeconf |= PIPECONF_PROGRESSIVE;
-
 
4563
 
-
 
4564
	if (IS_VALLEYVIEW(dev)) {
-
 
Line 4565... Line 4819...
4565
		if (intel_crtc->config.limited_color_range)
4819
	else
4566
			pipeconf |= PIPECONF_COLOR_RANGE_SELECT;
4820
		pipeconf |= PIPECONF_PROGRESSIVE;
4567
		else
4821
 
Line 4577... Line 4831...
4577
			      struct drm_framebuffer *fb)
4831
			      struct drm_framebuffer *fb)
4578
{
4832
{
4579
	struct drm_device *dev = crtc->dev;
4833
	struct drm_device *dev = crtc->dev;
4580
	struct drm_i915_private *dev_priv = dev->dev_private;
4834
	struct drm_i915_private *dev_priv = dev->dev_private;
4581
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4835
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4582
	struct drm_display_mode *adjusted_mode =
-
 
4583
		&intel_crtc->config.adjusted_mode;
-
 
4584
	struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
4836
	struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
4585
	int pipe = intel_crtc->pipe;
4837
	int pipe = intel_crtc->pipe;
4586
	int plane = intel_crtc->plane;
4838
	int plane = intel_crtc->plane;
4587
	int refclk, num_connectors = 0;
4839
	int refclk, num_connectors = 0;
4588
	intel_clock_t clock, reduced_clock;
4840
	intel_clock_t clock, reduced_clock;
4589
	u32 dspcntr;
4841
	u32 dspcntr;
4590
	bool ok, has_reduced_clock = false, is_sdvo = false;
4842
	bool ok, has_reduced_clock = false;
4591
	bool is_lvds = false, is_tv = false;
4843
	bool is_lvds = false;
4592
	struct intel_encoder *encoder;
4844
	struct intel_encoder *encoder;
4593
	const intel_limit_t *limit;
4845
	const intel_limit_t *limit;
4594
	int ret;
4846
	int ret;
Line 4595... Line 4847...
4595
 
4847
 
4596
	for_each_encoder_on_crtc(dev, crtc, encoder) {
4848
	for_each_encoder_on_crtc(dev, crtc, encoder) {
4597
		switch (encoder->type) {
4849
		switch (encoder->type) {
4598
		case INTEL_OUTPUT_LVDS:
4850
		case INTEL_OUTPUT_LVDS:
4599
			is_lvds = true;
4851
			is_lvds = true;
4600
			break;
-
 
4601
		case INTEL_OUTPUT_SDVO:
-
 
4602
		case INTEL_OUTPUT_HDMI:
-
 
4603
			is_sdvo = true;
-
 
4604
			if (encoder->needs_tv_clock)
-
 
4605
				is_tv = true;
-
 
4606
			break;
-
 
4607
		case INTEL_OUTPUT_TVOUT:
-
 
4608
			is_tv = true;
-
 
4609
			break;
4852
			break;
Line 4610... Line 4853...
4610
		}
4853
		}
4611
 
4854
 
Line 4618... Line 4861...
4618
	 * Returns a set of divisors for the desired target clock with the given
4861
	 * Returns a set of divisors for the desired target clock with the given
4619
	 * refclk, or FALSE.  The returned values represent the clock equation:
4862
	 * refclk, or FALSE.  The returned values represent the clock equation:
4620
	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
4863
	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
4621
	 */
4864
	 */
4622
	limit = intel_limit(crtc, refclk);
4865
	limit = intel_limit(crtc, refclk);
4623
	ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, NULL,
4866
	ok = dev_priv->display.find_dpll(limit, crtc,
-
 
4867
					 intel_crtc->config.port_clock,
4624
			     &clock);
4868
					 refclk, NULL, &clock);
4625
	if (!ok) {
4869
	if (!ok && !intel_crtc->config.clock_set) {
4626
		DRM_ERROR("Couldn't find PLL settings for mode!\n");
4870
		DRM_ERROR("Couldn't find PLL settings for mode!\n");
4627
		return -EINVAL;
4871
		return -EINVAL;
4628
	}
4872
	}
Line 4629... Line -...
4629
 
-
 
4630
	/* Ensure that the cursor is valid for the new mode before changing... */
-
 
4631
//   intel_crtc_update_cursor(crtc, true);
-
 
4632
 
4873
 
4633
	if (is_lvds && dev_priv->lvds_downclock_avail) {
4874
	if (is_lvds && dev_priv->lvds_downclock_avail) {
4634
		/*
4875
		/*
4635
		 * Ensure we match the reduced clock's P to the target clock.
4876
		 * Ensure we match the reduced clock's P to the target clock.
4636
		 * If the clocks don't match, we can't switch the display clock
4877
		 * If the clocks don't match, we can't switch the display clock
4637
		 * by using the FP0/FP1. In such case we will disable the LVDS
4878
		 * by using the FP0/FP1. In such case we will disable the LVDS
4638
		 * downclock feature.
4879
		 * downclock feature.
-
 
4880
		*/
4639
		*/
4881
		has_reduced_clock =
4640
		has_reduced_clock = limit->find_pll(limit, crtc,
4882
			dev_priv->display.find_dpll(limit, crtc,
4641
						    dev_priv->lvds_downclock,
-
 
4642
						    refclk,
4883
						    dev_priv->lvds_downclock,
4643
						    &clock,
4884
						    refclk, &clock,
4644
						    &reduced_clock);
4885
						    &reduced_clock);
4645
	}
4886
	}
4646
	/* Compat-code for transition, will disappear. */
4887
	/* Compat-code for transition, will disappear. */
4647
	if (!intel_crtc->config.clock_set) {
4888
	if (!intel_crtc->config.clock_set) {
Line 4650... Line 4891...
4650
		intel_crtc->config.dpll.m2 = clock.m2;
4891
		intel_crtc->config.dpll.m2 = clock.m2;
4651
		intel_crtc->config.dpll.p1 = clock.p1;
4892
		intel_crtc->config.dpll.p1 = clock.p1;
4652
		intel_crtc->config.dpll.p2 = clock.p2;
4893
		intel_crtc->config.dpll.p2 = clock.p2;
4653
	}
4894
	}
Line 4654... Line -...
4654
 
-
 
4655
	if (is_sdvo && is_tv)
-
 
4656
		i9xx_adjust_sdvo_tv_clock(intel_crtc);
-
 
4657
 
4895
 
4658
	if (IS_GEN2(dev))
4896
	if (IS_GEN2(dev))
4659
		i8xx_update_pll(intel_crtc, adjusted_mode,
4897
		i8xx_update_pll(intel_crtc,
4660
				has_reduced_clock ? &reduced_clock : NULL,
4898
				has_reduced_clock ? &reduced_clock : NULL,
4661
				num_connectors);
4899
				num_connectors);
4662
	else if (IS_VALLEYVIEW(dev))
4900
	else if (IS_VALLEYVIEW(dev))
4663
		vlv_update_pll(intel_crtc);
4901
		vlv_update_pll(intel_crtc);
Line 4674... Line 4912...
4674
		dspcntr &= ~DISPPLANE_SEL_PIPE_MASK;
4912
		dspcntr &= ~DISPPLANE_SEL_PIPE_MASK;
4675
	else
4913
	else
4676
		dspcntr |= DISPPLANE_SEL_PIPE_B;
4914
		dspcntr |= DISPPLANE_SEL_PIPE_B;
4677
	}
4915
	}
Line 4678... Line -...
4678
 
-
 
4679
	DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
-
 
4680
	drm_mode_debug_printmodeline(mode);
-
 
4681
 
4916
 
Line 4682... Line 4917...
4682
	intel_set_pipe_timings(intel_crtc, mode, adjusted_mode);
4917
	intel_set_pipe_timings(intel_crtc);
4683
 
4918
 
4684
	/* pipesrc and dspsize control the size that is scaled from,
4919
	/* pipesrc and dspsize control the size that is scaled from,
4685
	 * which should always be the user's requested size.
4920
	 * which should always be the user's requested size.
Line 4689... Line 4924...
4689
		   (mode->hdisplay - 1));
4924
		   (mode->hdisplay - 1));
4690
	I915_WRITE(DSPPOS(plane), 0);
4925
	I915_WRITE(DSPPOS(plane), 0);
Line 4691... Line 4926...
4691
 
4926
 
Line 4692... Line -...
4692
	i9xx_set_pipeconf(intel_crtc);
-
 
4693
 
-
 
4694
	intel_enable_pipe(dev_priv, pipe, false);
-
 
4695
 
-
 
4696
	intel_wait_for_vblank(dev, pipe);
4927
	i9xx_set_pipeconf(intel_crtc);
4697
 
4928
 
Line 4698... Line 4929...
4698
	I915_WRITE(DSPCNTR(plane), dspcntr);
4929
	I915_WRITE(DSPCNTR(plane), dspcntr);
Line 4699... Line 4930...
4699
	POSTING_READ(DSPCNTR(plane));
4930
	POSTING_READ(DSPCNTR(plane));
Line 4700... Line 4931...
4700
 
4931
 
4701
	ret = intel_pipe_set_base(crtc, x, y, fb);
4932
	ret = intel_pipe_set_base(crtc, x, y, fb);
Line -... Line 4933...
-
 
4933
 
-
 
4934
	intel_update_watermarks(dev);
-
 
4935
 
-
 
4936
    return ret;
-
 
4937
}
-
 
4938
 
-
 
4939
static void i9xx_get_pfit_config(struct intel_crtc *crtc,
-
 
4940
				 struct intel_crtc_config *pipe_config)
-
 
4941
{
-
 
4942
	struct drm_device *dev = crtc->base.dev;
-
 
4943
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4944
	uint32_t tmp;
-
 
4945
 
-
 
4946
	tmp = I915_READ(PFIT_CONTROL);
-
 
4947
	if (!(tmp & PFIT_ENABLE))
-
 
4948
		return;
-
 
4949
 
-
 
4950
	/* Check whether the pfit is attached to our pipe. */
-
 
4951
	if (INTEL_INFO(dev)->gen < 4) {
-
 
4952
		if (crtc->pipe != PIPE_B)
-
 
4953
			return;
-
 
4954
	} else {
-
 
4955
		if ((tmp & PFIT_PIPE_MASK) != (crtc->pipe << PFIT_PIPE_SHIFT))
-
 
4956
			return;
-
 
4957
	}
-
 
4958
 
-
 
4959
	pipe_config->gmch_pfit.control = tmp;
4702
 
4960
	pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS);
4703
	intel_update_watermarks(dev);
4961
	if (INTEL_INFO(dev)->gen < 5)
4704
 
4962
		pipe_config->gmch_pfit.lvds_border_bits =
4705
    return ret;
4963
			I915_READ(LVDS) & LVDS_BORDER_ENABLE;
4706
}
4964
}
4707
 
4965
 
Line -... Line 4966...
-
 
4966
static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
-
 
4967
				 struct intel_crtc_config *pipe_config)
-
 
4968
{
4708
static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
4969
	struct drm_device *dev = crtc->base.dev;
4709
				 struct intel_crtc_config *pipe_config)
4970
	struct drm_i915_private *dev_priv = dev->dev_private;
4710
{
4971
	uint32_t tmp;
Line -... Line 4972...
-
 
4972
 
-
 
4973
	pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
-
 
4974
	pipe_config->shared_dpll = DPLL_ID_PRIVATE;
-
 
4975
 
-
 
4976
	tmp = I915_READ(PIPECONF(crtc->pipe));
-
 
4977
	if (!(tmp & PIPECONF_ENABLE))
-
 
4978
		return false;
-
 
4979
 
-
 
4980
	intel_get_pipe_timings(crtc, pipe_config);
-
 
4981
 
-
 
4982
	i9xx_get_pfit_config(crtc, pipe_config);
-
 
4983
 
-
 
4984
	if (INTEL_INFO(dev)->gen >= 4) {
-
 
4985
		tmp = I915_READ(DPLL_MD(crtc->pipe));
-
 
4986
		pipe_config->pixel_multiplier =
-
 
4987
			((tmp & DPLL_MD_UDI_MULTIPLIER_MASK)
-
 
4988
			 >> DPLL_MD_UDI_MULTIPLIER_SHIFT) + 1;
-
 
4989
		pipe_config->dpll_hw_state.dpll_md = tmp;
-
 
4990
	} else if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) {
-
 
4991
		tmp = I915_READ(DPLL(crtc->pipe));
-
 
4992
		pipe_config->pixel_multiplier =
-
 
4993
			((tmp & SDVO_MULTIPLIER_MASK)
-
 
4994
			 >> SDVO_MULTIPLIER_SHIFT_HIRES) + 1;
-
 
4995
	} else {
-
 
4996
		/* Note that on i915G/GM the pixel multiplier is in the sdvo
-
 
4997
		 * port and will be fixed up in the encoder->get_config
-
 
4998
		 * function. */
-
 
4999
		pipe_config->pixel_multiplier = 1;
-
 
5000
	}
-
 
5001
	pipe_config->dpll_hw_state.dpll = I915_READ(DPLL(crtc->pipe));
-
 
5002
	if (!IS_VALLEYVIEW(dev)) {
-
 
5003
		pipe_config->dpll_hw_state.fp0 = I915_READ(FP0(crtc->pipe));
4711
	struct drm_device *dev = crtc->base.dev;
5004
		pipe_config->dpll_hw_state.fp1 = I915_READ(FP1(crtc->pipe));
4712
	struct drm_i915_private *dev_priv = dev->dev_private;
5005
	} else {
Line 4713... Line 5006...
4713
	uint32_t tmp;
5006
		/* Mask out read-only status bits. */
4714
 
5007
		pipe_config->dpll_hw_state.dpll &= ~(DPLL_LOCK_VLV |
Line 4725... Line 5018...
4725
	struct drm_mode_config *mode_config = &dev->mode_config;
5018
	struct drm_mode_config *mode_config = &dev->mode_config;
4726
	struct intel_encoder *encoder;
5019
	struct intel_encoder *encoder;
4727
	u32 val, final;
5020
	u32 val, final;
4728
	bool has_lvds = false;
5021
	bool has_lvds = false;
4729
	bool has_cpu_edp = false;
5022
	bool has_cpu_edp = false;
4730
	bool has_pch_edp = false;
-
 
4731
	bool has_panel = false;
5023
	bool has_panel = false;
4732
	bool has_ck505 = false;
5024
	bool has_ck505 = false;
4733
	bool can_ssc = false;
5025
	bool can_ssc = false;
Line 4734... Line 5026...
4734
 
5026
 
Line 4740... Line 5032...
4740
			has_panel = true;
5032
			has_panel = true;
4741
				has_lvds = true;
5033
				has_lvds = true;
4742
			break;
5034
			break;
4743
			case INTEL_OUTPUT_EDP:
5035
			case INTEL_OUTPUT_EDP:
4744
			has_panel = true;
5036
			has_panel = true;
4745
			if (intel_encoder_is_pch_edp(&encoder->base))
5037
			if (enc_to_dig_port(&encoder->base)->port == PORT_A)
4746
				has_pch_edp = true;
-
 
4747
			else
-
 
4748
				has_cpu_edp = true;
5038
				has_cpu_edp = true;
4749
				break;
5039
				break;
4750
			}
5040
			}
4751
		}
5041
		}
Line 4752... Line 5042...
4752
 
5042
 
4753
	if (HAS_PCH_IBX(dev)) {
5043
	if (HAS_PCH_IBX(dev)) {
4754
		has_ck505 = dev_priv->display_clock_mode;
5044
		has_ck505 = dev_priv->vbt.display_clock_mode;
4755
		can_ssc = has_ck505;
5045
		can_ssc = has_ck505;
4756
	} else {
5046
	} else {
4757
		has_ck505 = false;
5047
		has_ck505 = false;
4758
		can_ssc = true;
5048
		can_ssc = true;
Line 4759... Line 5049...
4759
	}
5049
	}
4760
 
5050
 
4761
	DRM_DEBUG_KMS("has_panel %d has_lvds %d has_pch_edp %d has_cpu_edp %d has_ck505 %d\n",
-
 
Line 4762... Line 5051...
4762
		      has_panel, has_lvds, has_pch_edp, has_cpu_edp,
5051
	DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d\n",
4763
		      has_ck505);
5052
		      has_panel, has_lvds, has_ck505);
4764
 
5053
 
4765
	/* Ironlake: try to setup display ref clock before DPLL
5054
	/* Ironlake: try to setup display ref clock before DPLL
Line 4870... Line 5159...
4870
	}
5159
	}
Line 4871... Line 5160...
4871
 
5160
 
4872
	BUG_ON(val != final);
5161
	BUG_ON(val != final);
Line 4873... Line -...
4873
}
-
 
4874
 
5162
}
4875
/* Sequence to enable CLKOUT_DP for FDI usage and configure PCH FDI I/O. */
5163
 
4876
static void lpt_init_pch_refclk(struct drm_device *dev)
-
 
4877
{
-
 
4878
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
4879
	struct drm_mode_config *mode_config = &dev->mode_config;
-
 
4880
	struct intel_encoder *encoder;
-
 
4881
	bool has_vga = false;
5164
static void lpt_reset_fdi_mphy(struct drm_i915_private *dev_priv)
4882
	bool is_sdv = false;
-
 
4883
	u32 tmp;
-
 
4884
 
-
 
4885
	list_for_each_entry(encoder, &mode_config->encoder_list, base.head) {
-
 
4886
		switch (encoder->type) {
-
 
4887
		case INTEL_OUTPUT_ANALOG:
-
 
4888
			has_vga = true;
-
 
4889
			break;
-
 
4890
		}
-
 
4891
	}
-
 
4892
 
-
 
4893
	if (!has_vga)
-
 
4894
		return;
-
 
4895
 
-
 
4896
	mutex_lock(&dev_priv->dpio_lock);
-
 
4897
 
-
 
4898
	/* XXX: Rip out SDV support once Haswell ships for real. */
-
 
4899
	if (IS_HASWELL(dev) && (dev->pci_device & 0xFF00) == 0x0C00)
-
 
4900
		is_sdv = true;
-
 
4901
 
-
 
4902
	tmp = intel_sbi_read(dev_priv, SBI_SSCCTL, SBI_ICLK);
-
 
4903
	tmp &= ~SBI_SSCCTL_DISABLE;
-
 
4904
	tmp |= SBI_SSCCTL_PATHALT;
-
 
4905
	intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
-
 
4906
 
-
 
4907
	udelay(24);
-
 
4908
 
-
 
4909
	tmp = intel_sbi_read(dev_priv, SBI_SSCCTL, SBI_ICLK);
-
 
Line 4910... Line -...
4910
	tmp &= ~SBI_SSCCTL_PATHALT;
-
 
4911
	intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
5165
{
4912
 
5166
	uint32_t tmp;
4913
	if (!is_sdv) {
5167
 
Line 4914... Line 5168...
4914
		tmp = I915_READ(SOUTH_CHICKEN2);
5168
		tmp = I915_READ(SOUTH_CHICKEN2);
Line 4922... Line 5176...
4922
		tmp = I915_READ(SOUTH_CHICKEN2);
5176
		tmp = I915_READ(SOUTH_CHICKEN2);
4923
		tmp &= ~FDI_MPHY_IOSFSB_RESET_CTL;
5177
		tmp &= ~FDI_MPHY_IOSFSB_RESET_CTL;
4924
		I915_WRITE(SOUTH_CHICKEN2, tmp);
5178
		I915_WRITE(SOUTH_CHICKEN2, tmp);
Line 4925... Line 5179...
4925
 
5179
 
4926
		if (wait_for_atomic_us((I915_READ(SOUTH_CHICKEN2) &
5180
		if (wait_for_atomic_us((I915_READ(SOUTH_CHICKEN2) &
4927
				        FDI_MPHY_IOSFSB_RESET_STATUS) == 0,
-
 
4928
				       100))
5181
				FDI_MPHY_IOSFSB_RESET_STATUS) == 0, 100))
4929
			DRM_ERROR("FDI mPHY reset de-assert timeout\n");
5182
			DRM_ERROR("FDI mPHY reset de-assert timeout\n");
Line -... Line 5183...
-
 
5183
	}
-
 
5184
 
-
 
5185
/* WaMPhyProgramming:hsw */
-
 
5186
static void lpt_program_fdi_mphy(struct drm_i915_private *dev_priv)
-
 
5187
{
4930
	}
5188
	uint32_t tmp;
4931
 
5189
 
4932
	tmp = intel_sbi_read(dev_priv, 0x8008, SBI_MPHY);
5190
	tmp = intel_sbi_read(dev_priv, 0x8008, SBI_MPHY);
4933
	tmp &= ~(0xFF << 24);
5191
	tmp &= ~(0xFF << 24);
Line 4934... Line -...
4934
	tmp |= (0x12 << 24);
-
 
4935
	intel_sbi_write(dev_priv, 0x8008, tmp, SBI_MPHY);
-
 
4936
 
-
 
4937
	if (is_sdv) {
-
 
4938
		tmp = intel_sbi_read(dev_priv, 0x800C, SBI_MPHY);
-
 
4939
		tmp |= 0x7FFF;
-
 
4940
		intel_sbi_write(dev_priv, 0x800C, tmp, SBI_MPHY);
5192
	tmp |= (0x12 << 24);
4941
	}
5193
	intel_sbi_write(dev_priv, 0x8008, tmp, SBI_MPHY);
4942
 
5194
 
Line 4943... Line 5195...
4943
	tmp = intel_sbi_read(dev_priv, 0x2008, SBI_MPHY);
5195
	tmp = intel_sbi_read(dev_priv, 0x2008, SBI_MPHY);
4944
	tmp |= (1 << 11);
5196
	tmp |= (1 << 11);
4945
	intel_sbi_write(dev_priv, 0x2008, tmp, SBI_MPHY);
5197
	intel_sbi_write(dev_priv, 0x2008, tmp, SBI_MPHY);
Line 4946... Line -...
4946
 
-
 
4947
	tmp = intel_sbi_read(dev_priv, 0x2108, SBI_MPHY);
-
 
4948
	tmp |= (1 << 11);
-
 
4949
	intel_sbi_write(dev_priv, 0x2108, tmp, SBI_MPHY);
-
 
4950
 
-
 
4951
	if (is_sdv) {
-
 
4952
		tmp = intel_sbi_read(dev_priv, 0x2038, SBI_MPHY);
-
 
4953
		tmp |= (0x3F << 24) | (0xF << 20) | (0xF << 16);
-
 
4954
		intel_sbi_write(dev_priv, 0x2038, tmp, SBI_MPHY);
-
 
4955
 
-
 
4956
		tmp = intel_sbi_read(dev_priv, 0x2138, SBI_MPHY);
-
 
4957
		tmp |= (0x3F << 24) | (0xF << 20) | (0xF << 16);
-
 
4958
		intel_sbi_write(dev_priv, 0x2138, tmp, SBI_MPHY);
-
 
4959
 
-
 
4960
		tmp = intel_sbi_read(dev_priv, 0x203C, SBI_MPHY);
-
 
4961
		tmp |= (0x3F << 8);
-
 
4962
		intel_sbi_write(dev_priv, 0x203C, tmp, SBI_MPHY);
-
 
4963
 
-
 
4964
		tmp = intel_sbi_read(dev_priv, 0x213C, SBI_MPHY);
5198
 
4965
		tmp |= (0x3F << 8);
5199
	tmp = intel_sbi_read(dev_priv, 0x2108, SBI_MPHY);
4966
		intel_sbi_write(dev_priv, 0x213C, tmp, SBI_MPHY);
5200
	tmp |= (1 << 11);
Line 4967... Line 5201...
4967
	}
5201
	intel_sbi_write(dev_priv, 0x2108, tmp, SBI_MPHY);
4968
 
5202
 
4969
	tmp = intel_sbi_read(dev_priv, 0x206C, SBI_MPHY);
5203
	tmp = intel_sbi_read(dev_priv, 0x206C, SBI_MPHY);
Line 4970... Line -...
4970
	tmp |= (1 << 24) | (1 << 21) | (1 << 18);
-
 
4971
	intel_sbi_write(dev_priv, 0x206C, tmp, SBI_MPHY);
5204
	tmp |= (1 << 24) | (1 << 21) | (1 << 18);
4972
 
5205
	intel_sbi_write(dev_priv, 0x206C, tmp, SBI_MPHY);
4973
	tmp = intel_sbi_read(dev_priv, 0x216C, SBI_MPHY);
5206
 
4974
	tmp |= (1 << 24) | (1 << 21) | (1 << 18);
5207
	tmp = intel_sbi_read(dev_priv, 0x216C, SBI_MPHY);
Line 4975... Line 5208...
4975
	intel_sbi_write(dev_priv, 0x216C, tmp, SBI_MPHY);
5208
	tmp |= (1 << 24) | (1 << 21) | (1 << 18);
4976
 
5209
	intel_sbi_write(dev_priv, 0x216C, tmp, SBI_MPHY);
4977
	if (!is_sdv) {
5210
 
4978
		tmp = intel_sbi_read(dev_priv, 0x2080, SBI_MPHY);
5211
		tmp = intel_sbi_read(dev_priv, 0x2080, SBI_MPHY);
4979
		tmp &= ~(7 << 13);
-
 
Line 4980... Line 5212...
4980
		tmp |= (5 << 13);
5212
		tmp &= ~(7 << 13);
4981
		intel_sbi_write(dev_priv, 0x2080, tmp, SBI_MPHY);
5213
		tmp |= (5 << 13);
4982
 
5214
		intel_sbi_write(dev_priv, 0x2080, tmp, SBI_MPHY);
4983
		tmp = intel_sbi_read(dev_priv, 0x2180, SBI_MPHY);
5215
 
Line 5004... Line 5236...
5004
	tmp = intel_sbi_read(dev_priv, 0x2198, SBI_MPHY);
5236
	tmp = intel_sbi_read(dev_priv, 0x2198, SBI_MPHY);
5005
	tmp &= ~(0xFF << 16);
5237
	tmp &= ~(0xFF << 16);
5006
	tmp |= (0x1C << 16);
5238
	tmp |= (0x1C << 16);
5007
	intel_sbi_write(dev_priv, 0x2198, tmp, SBI_MPHY);
5239
	intel_sbi_write(dev_priv, 0x2198, tmp, SBI_MPHY);
Line 5008... Line -...
5008
 
-
 
5009
	if (!is_sdv) {
5240
 
5010
		tmp = intel_sbi_read(dev_priv, 0x20C4, SBI_MPHY);
5241
		tmp = intel_sbi_read(dev_priv, 0x20C4, SBI_MPHY);
5011
		tmp |= (1 << 27);
5242
		tmp |= (1 << 27);
Line 5012... Line 5243...
5012
		intel_sbi_write(dev_priv, 0x20C4, tmp, SBI_MPHY);
5243
		intel_sbi_write(dev_priv, 0x20C4, tmp, SBI_MPHY);
Line 5024... Line 5255...
5024
		tmp &= ~(0xF << 28);
5255
		tmp &= ~(0xF << 28);
5025
		tmp |= (4 << 28);
5256
		tmp |= (4 << 28);
5026
		intel_sbi_write(dev_priv, 0x21EC, tmp, SBI_MPHY);
5257
		intel_sbi_write(dev_priv, 0x21EC, tmp, SBI_MPHY);
5027
	}
5258
	}
Line -... Line 5259...
-
 
5259
 
-
 
5260
/* Implements 3 different sequences from BSpec chapter "Display iCLK
-
 
5261
 * Programming" based on the parameters passed:
-
 
5262
 * - Sequence to enable CLKOUT_DP
5028
 
5263
 * - Sequence to enable CLKOUT_DP without spread
-
 
5264
 * - Sequence to enable CLKOUT_DP for FDI usage and configure PCH FDI I/O
-
 
5265
 */
-
 
5266
static void lpt_enable_clkout_dp(struct drm_device *dev, bool with_spread,
-
 
5267
				 bool with_fdi)
-
 
5268
{
-
 
5269
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5270
	uint32_t reg, tmp;
-
 
5271
 
-
 
5272
	if (WARN(with_fdi && !with_spread, "FDI requires downspread\n"))
-
 
5273
		with_spread = true;
-
 
5274
	if (WARN(dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE &&
-
 
5275
		 with_fdi, "LP PCH doesn't have FDI\n"))
-
 
5276
		with_fdi = false;
-
 
5277
 
-
 
5278
	mutex_lock(&dev_priv->dpio_lock);
-
 
5279
 
-
 
5280
	tmp = intel_sbi_read(dev_priv, SBI_SSCCTL, SBI_ICLK);
-
 
5281
	tmp &= ~SBI_SSCCTL_DISABLE;
-
 
5282
	tmp |= SBI_SSCCTL_PATHALT;
-
 
5283
	intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
-
 
5284
 
-
 
5285
	udelay(24);
-
 
5286
 
-
 
5287
	if (with_spread) {
-
 
5288
		tmp = intel_sbi_read(dev_priv, SBI_SSCCTL, SBI_ICLK);
-
 
5289
		tmp &= ~SBI_SSCCTL_PATHALT;
-
 
5290
		intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
-
 
5291
 
-
 
5292
		if (with_fdi) {
-
 
5293
			lpt_reset_fdi_mphy(dev_priv);
-
 
5294
			lpt_program_fdi_mphy(dev_priv);
-
 
5295
		}
-
 
5296
	}
-
 
5297
 
-
 
5298
	reg = (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) ?
-
 
5299
	       SBI_GEN0 : SBI_DBUFF0;
-
 
5300
	tmp = intel_sbi_read(dev_priv, reg, SBI_ICLK);
-
 
5301
	tmp |= SBI_GEN0_CFG_BUFFENABLE_DISABLE;
-
 
5302
	intel_sbi_write(dev_priv, reg, tmp, SBI_ICLK);
-
 
5303
 
-
 
5304
	mutex_unlock(&dev_priv->dpio_lock);
-
 
5305
}
-
 
5306
 
-
 
5307
/* Sequence to disable CLKOUT_DP */
-
 
5308
static void lpt_disable_clkout_dp(struct drm_device *dev)
-
 
5309
{
-
 
5310
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5311
	uint32_t reg, tmp;
-
 
5312
 
-
 
5313
	mutex_lock(&dev_priv->dpio_lock);
-
 
5314
 
-
 
5315
	reg = (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) ?
-
 
5316
	       SBI_GEN0 : SBI_DBUFF0;
-
 
5317
	tmp = intel_sbi_read(dev_priv, reg, SBI_ICLK);
-
 
5318
	tmp &= ~SBI_GEN0_CFG_BUFFENABLE_DISABLE;
-
 
5319
	intel_sbi_write(dev_priv, reg, tmp, SBI_ICLK);
5029
	/* ULT uses SBI_GEN0, but ULT doesn't have VGA, so we don't care. */
5320
 
-
 
5321
	tmp = intel_sbi_read(dev_priv, SBI_SSCCTL, SBI_ICLK);
-
 
5322
	if (!(tmp & SBI_SSCCTL_DISABLE)) {
-
 
5323
		if (!(tmp & SBI_SSCCTL_PATHALT)) {
-
 
5324
			tmp |= SBI_SSCCTL_PATHALT;
-
 
5325
			intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
-
 
5326
			udelay(32);
5030
	tmp = intel_sbi_read(dev_priv, SBI_DBUFF0, SBI_ICLK);
5327
		}
5031
	tmp |= SBI_DBUFF0_ENABLE;
5328
		tmp |= SBI_SSCCTL_DISABLE;
-
 
5329
		intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK);
Line 5032... Line 5330...
5032
	intel_sbi_write(dev_priv, SBI_DBUFF0, tmp, SBI_ICLK);
5330
	}
5033
 
5331
 
Line -... Line 5332...
-
 
5332
	mutex_unlock(&dev_priv->dpio_lock);
-
 
5333
}
-
 
5334
 
-
 
5335
static void lpt_init_pch_refclk(struct drm_device *dev)
-
 
5336
{
-
 
5337
	struct drm_mode_config *mode_config = &dev->mode_config;
-
 
5338
	struct intel_encoder *encoder;
-
 
5339
	bool has_vga = false;
-
 
5340
 
-
 
5341
	list_for_each_entry(encoder, &mode_config->encoder_list, base.head) {
-
 
5342
		switch (encoder->type) {
-
 
5343
		case INTEL_OUTPUT_ANALOG:
-
 
5344
			has_vga = true;
-
 
5345
			break;
-
 
5346
		}
-
 
5347
	}
-
 
5348
 
-
 
5349
	if (has_vga)
-
 
5350
		lpt_enable_clkout_dp(dev, true, true);
-
 
5351
	else
5034
	mutex_unlock(&dev_priv->dpio_lock);
5352
		lpt_disable_clkout_dp(dev);
5035
}
5353
}
5036
 
5354
 
5037
/*
5355
/*
5038
 * Initialize reference clocks when the driver loads
5356
 * Initialize reference clocks when the driver loads
Line 5048... Line 5366...
5048
static int ironlake_get_refclk(struct drm_crtc *crtc)
5366
static int ironlake_get_refclk(struct drm_crtc *crtc)
5049
{
5367
{
5050
	struct drm_device *dev = crtc->dev;
5368
	struct drm_device *dev = crtc->dev;
5051
	struct drm_i915_private *dev_priv = dev->dev_private;
5369
	struct drm_i915_private *dev_priv = dev->dev_private;
5052
	struct intel_encoder *encoder;
5370
	struct intel_encoder *encoder;
5053
	struct intel_encoder *edp_encoder = NULL;
-
 
5054
	int num_connectors = 0;
5371
	int num_connectors = 0;
5055
	bool is_lvds = false;
5372
	bool is_lvds = false;
Line 5056... Line 5373...
5056
 
5373
 
5057
	for_each_encoder_on_crtc(dev, crtc, encoder) {
5374
	for_each_encoder_on_crtc(dev, crtc, encoder) {
5058
		switch (encoder->type) {
5375
		switch (encoder->type) {
5059
		case INTEL_OUTPUT_LVDS:
5376
		case INTEL_OUTPUT_LVDS:
5060
			is_lvds = true;
5377
			is_lvds = true;
5061
			break;
-
 
5062
		case INTEL_OUTPUT_EDP:
-
 
5063
			edp_encoder = encoder;
-
 
5064
			break;
5378
			break;
5065
		}
5379
		}
5066
		num_connectors++;
5380
		num_connectors++;
Line 5067... Line 5381...
5067
	}
5381
	}
5068
 
5382
 
5069
	if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2) {
5383
	if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2) {
5070
		DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n",
5384
		DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n",
5071
			      dev_priv->lvds_ssc_freq);
5385
			      dev_priv->vbt.lvds_ssc_freq);
Line 5072... Line 5386...
5072
		return dev_priv->lvds_ssc_freq * 1000;
5386
		return dev_priv->vbt.lvds_ssc_freq * 1000;
5073
	}
5387
	}
Line 5074... Line 5388...
5074
 
5388
 
5075
	return 120000;
-
 
5076
}
-
 
5077
 
5389
	return 120000;
5078
static void ironlake_set_pipeconf(struct drm_crtc *crtc,
5390
}
5079
				  struct drm_display_mode *adjusted_mode,
5391
 
5080
				  bool dither)
5392
static void ironlake_set_pipeconf(struct drm_crtc *crtc)
5081
{
5393
{
Line 5082... Line 5394...
5082
	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
5394
	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
Line 5083... Line -...
5083
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
5084
	int pipe = intel_crtc->pipe;
5395
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5085
	uint32_t val;
5396
	int pipe = intel_crtc->pipe;
5086
 
5397
	uint32_t val;
5087
	val = I915_READ(PIPECONF(pipe));
5398
 
5088
 
5399
	val = 0;
Line 5103... Line 5414...
5103
	default:
5414
	default:
5104
		/* Case prevented by intel_choose_pipe_bpp_dither. */
5415
		/* Case prevented by intel_choose_pipe_bpp_dither. */
5105
		BUG();
5416
		BUG();
5106
	}
5417
	}
Line 5107... Line -...
5107
 
-
 
5108
	val &= ~(PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_MASK);
5418
 
5109
	if (dither)
5419
	if (intel_crtc->config.dither)
Line 5110... Line -...
5110
		val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP);
-
 
5111
 
5420
		val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP);
5112
	val &= ~PIPECONF_INTERLACE_MASK;
5421
 
5113
	if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
5422
	if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
5114
		val |= PIPECONF_INTERLACED_ILK;
5423
		val |= PIPECONF_INTERLACED_ILK;
Line 5115... Line 5424...
5115
	else
5424
	else
5116
		val |= PIPECONF_PROGRESSIVE;
5425
		val |= PIPECONF_PROGRESSIVE;
5117
 
-
 
5118
	if (intel_crtc->config.limited_color_range)
-
 
Line 5119... Line 5426...
5119
		val |= PIPECONF_COLOR_RANGE_SELECT;
5426
 
5120
	else
5427
	if (intel_crtc->config.limited_color_range)
5121
		val &= ~PIPECONF_COLOR_RANGE_SELECT;
5428
		val |= PIPECONF_COLOR_RANGE_SELECT;
Line 5186... Line 5493...
5186
 
5493
 
5187
		I915_WRITE(PIPE_CSC_MODE(pipe), mode);
5494
		I915_WRITE(PIPE_CSC_MODE(pipe), mode);
5188
	}
5495
	}
Line 5189... Line 5496...
5189
}
5496
}
5190
 
-
 
5191
static void haswell_set_pipeconf(struct drm_crtc *crtc,
-
 
5192
				 struct drm_display_mode *adjusted_mode,
5497
 
5193
				 bool dither)
5498
static void haswell_set_pipeconf(struct drm_crtc *crtc)
5194
{
5499
{
5195
	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
5500
	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
5196
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5501
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Line 5197... Line 5502...
5197
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
5502
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
Line 5198... Line -...
5198
	uint32_t val;
-
 
5199
 
5503
	uint32_t val;
5200
	val = I915_READ(PIPECONF(cpu_transcoder));
5504
 
Line 5201... Line -...
5201
 
-
 
5202
	val &= ~(PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_MASK);
5505
	val = 0;
5203
	if (dither)
5506
 
5204
		val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP);
5507
	if (intel_crtc->config.dither)
5205
 
5508
		val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP);
Line 5206... Line 5509...
5206
	val &= ~PIPECONF_INTERLACE_MASK_HSW;
5509
 
5207
	if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
5510
	if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
-
 
5511
		val |= PIPECONF_INTERLACED_ILK;
-
 
5512
	else
-
 
5513
		val |= PIPECONF_PROGRESSIVE;
5208
		val |= PIPECONF_INTERLACED_ILK;
5514
 
Line 5209... Line 5515...
5209
	else
5515
	I915_WRITE(PIPECONF(cpu_transcoder), val);
5210
		val |= PIPECONF_PROGRESSIVE;
-
 
5211
 
5516
	POSTING_READ(PIPECONF(cpu_transcoder));
5212
	I915_WRITE(PIPECONF(cpu_transcoder), val);
5517
 
5213
	POSTING_READ(PIPECONF(cpu_transcoder));
5518
	I915_WRITE(GAMMA_MODE(intel_crtc->pipe), GAMMA_MODE_MODE_8BIT);
5214
}
5519
	POSTING_READ(GAMMA_MODE(intel_crtc->pipe));
5215
 
5520
}
5216
static bool ironlake_compute_clocks(struct drm_crtc *crtc,
5521
 
5217
				    struct drm_display_mode *adjusted_mode,
5522
static bool ironlake_compute_clocks(struct drm_crtc *crtc,
5218
				    intel_clock_t *clock,
5523
				    intel_clock_t *clock,
5219
				    bool *has_reduced_clock,
5524
				    bool *has_reduced_clock,
5220
				    intel_clock_t *reduced_clock)
5525
				    intel_clock_t *reduced_clock)
Line 5221... Line 5526...
5221
{
5526
{
5222
	struct drm_device *dev = crtc->dev;
5527
	struct drm_device *dev = crtc->dev;
5223
	struct drm_i915_private *dev_priv = dev->dev_private;
5528
	struct drm_i915_private *dev_priv = dev->dev_private;
5224
	struct intel_encoder *intel_encoder;
5529
	struct intel_encoder *intel_encoder;
5225
	int refclk;
5530
	int refclk;
5226
	const intel_limit_t *limit;
-
 
5227
	bool ret, is_sdvo = false, is_tv = false, is_lvds = false;
-
 
5228
 
-
 
5229
	for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
-
 
5230
		switch (intel_encoder->type) {
-
 
5231
		case INTEL_OUTPUT_LVDS:
-
 
5232
			is_lvds = true;
-
 
5233
			break;
-
 
5234
		case INTEL_OUTPUT_SDVO:
-
 
5235
		case INTEL_OUTPUT_HDMI:
5531
	const intel_limit_t *limit;
5236
			is_sdvo = true;
5532
	bool ret, is_lvds = false;
Line 5237... Line 5533...
5237
			if (intel_encoder->needs_tv_clock)
5533
 
Line 5249... Line 5545...
5249
	 * Returns a set of divisors for the desired target clock with the given
5545
	 * Returns a set of divisors for the desired target clock with the given
5250
	 * refclk, or FALSE.  The returned values represent the clock equation:
5546
	 * refclk, or FALSE.  The returned values represent the clock equation:
5251
	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
5547
	 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
5252
	 */
5548
	 */
5253
	limit = intel_limit(crtc, refclk);
5549
	limit = intel_limit(crtc, refclk);
5254
	ret = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, NULL,
5550
	ret = dev_priv->display.find_dpll(limit, crtc,
-
 
5551
					  to_intel_crtc(crtc)->config.port_clock,
5255
			      clock);
5552
					  refclk, NULL, clock);
5256
	if (!ret)
5553
	if (!ret)
5257
		return false;
5554
		return false;
Line 5258... Line 5555...
5258
 
5555
 
5259
	if (is_lvds && dev_priv->lvds_downclock_avail) {
5556
	if (is_lvds && dev_priv->lvds_downclock_avail) {
5260
		/*
5557
		/*
5261
		 * Ensure we match the reduced clock's P to the target clock.
5558
		 * Ensure we match the reduced clock's P to the target clock.
5262
		 * If the clocks don't match, we can't switch the display clock
5559
		 * If the clocks don't match, we can't switch the display clock
5263
		 * by using the FP0/FP1. In such case we will disable the LVDS
5560
		 * by using the FP0/FP1. In such case we will disable the LVDS
5264
		 * downclock feature.
5561
		 * downclock feature.
-
 
5562
		*/
5265
		*/
5563
		*has_reduced_clock =
5266
		*has_reduced_clock = limit->find_pll(limit, crtc,
5564
			dev_priv->display.find_dpll(limit, crtc,
5267
						     dev_priv->lvds_downclock,
-
 
5268
						     refclk,
5565
						     dev_priv->lvds_downclock,
5269
						     clock,
5566
						    refclk, clock,
5270
						     reduced_clock);
5567
						     reduced_clock);
Line 5271... Line -...
5271
	}
-
 
5272
 
-
 
5273
	if (is_sdvo && is_tv)
-
 
5274
		i9xx_adjust_sdvo_tv_clock(to_intel_crtc(crtc));
5568
	}
5275
 
5569
 
Line 5276... Line 5570...
5276
	return true;
5570
	return true;
5277
}
5571
}
Line 5292... Line 5586...
5292
	DRM_DEBUG_KMS("enabling fdi C rx\n");
5586
	DRM_DEBUG_KMS("enabling fdi C rx\n");
5293
	I915_WRITE(SOUTH_CHICKEN1, temp);
5587
	I915_WRITE(SOUTH_CHICKEN1, temp);
5294
	POSTING_READ(SOUTH_CHICKEN1);
5588
	POSTING_READ(SOUTH_CHICKEN1);
5295
}
5589
}
Line 5296... Line 5590...
5296
 
5590
 
5297
static bool ironlake_check_fdi_lanes(struct intel_crtc *intel_crtc)
5591
static void ivybridge_update_fdi_bc_bifurcation(struct intel_crtc *intel_crtc)
5298
{
5592
{
5299
	struct drm_device *dev = intel_crtc->base.dev;
5593
	struct drm_device *dev = intel_crtc->base.dev;
5300
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5301
	struct intel_crtc *pipe_B_crtc =
-
 
5302
		to_intel_crtc(dev_priv->pipe_to_crtc_mapping[PIPE_B]);
-
 
5303
 
-
 
5304
	DRM_DEBUG_KMS("checking fdi config on pipe %i, lanes %i\n",
-
 
5305
		      intel_crtc->pipe, intel_crtc->fdi_lanes);
-
 
5306
	if (intel_crtc->fdi_lanes > 4) {
-
 
5307
		DRM_DEBUG_KMS("invalid fdi lane config on pipe %i: %i lanes\n",
-
 
5308
			      intel_crtc->pipe, intel_crtc->fdi_lanes);
-
 
5309
		/* Clamp lanes to avoid programming the hw with bogus values. */
-
 
5310
		intel_crtc->fdi_lanes = 4;
-
 
5311
 
-
 
5312
		return false;
-
 
5313
	}
-
 
5314
 
-
 
5315
	if (INTEL_INFO(dev)->num_pipes == 2)
-
 
Line 5316... Line 5594...
5316
		return true;
5594
	struct drm_i915_private *dev_priv = dev->dev_private;
5317
 
5595
 
5318
	switch (intel_crtc->pipe) {
5596
	switch (intel_crtc->pipe) {
5319
	case PIPE_A:
5597
	case PIPE_A:
5320
		return true;
-
 
5321
	case PIPE_B:
-
 
5322
		if (dev_priv->pipe_to_crtc_mapping[PIPE_C]->enabled &&
-
 
5323
		    intel_crtc->fdi_lanes > 2) {
-
 
5324
			DRM_DEBUG_KMS("invalid shared fdi lane config on pipe %i: %i lanes\n",
-
 
5325
				      intel_crtc->pipe, intel_crtc->fdi_lanes);
-
 
5326
			/* Clamp lanes to avoid programming the hw with bogus values. */
-
 
5327
			intel_crtc->fdi_lanes = 2;
-
 
5328
 
-
 
5329
			return false;
-
 
5330
		}
5598
		break;
5331
 
5599
	case PIPE_B:
5332
		if (intel_crtc->fdi_lanes > 2)
5600
		if (intel_crtc->config.fdi_lanes > 2)
5333
			WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);
5601
			WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);
Line 5334... Line 5602...
5334
		else
5602
		else
5335
			cpt_enable_fdi_bc_bifurcation(dev);
5603
			cpt_enable_fdi_bc_bifurcation(dev);
5336
 
-
 
5337
		return true;
-
 
5338
	case PIPE_C:
-
 
5339
		if (!pipe_B_crtc->base.enabled || pipe_B_crtc->fdi_lanes <= 2) {
-
 
5340
			if (intel_crtc->fdi_lanes > 2) {
-
 
5341
				DRM_DEBUG_KMS("invalid shared fdi lane config on pipe %i: %i lanes\n",
-
 
5342
					      intel_crtc->pipe, intel_crtc->fdi_lanes);
-
 
5343
				/* Clamp lanes to avoid programming the hw with bogus values. */
-
 
5344
				intel_crtc->fdi_lanes = 2;
-
 
5345
 
-
 
5346
				return false;
-
 
5347
			}
-
 
5348
		} else {
-
 
5349
			DRM_DEBUG_KMS("fdi link B uses too many lanes to enable link C\n");
-
 
5350
			return false;
5604
 
Line 5351... Line 5605...
5351
		}
5605
		break;
5352
 
5606
	case PIPE_C:
5353
		cpt_enable_fdi_bc_bifurcation(dev);
5607
		cpt_enable_fdi_bc_bifurcation(dev);
5354
 
5608
 
5355
		return true;
5609
		break;
Line 5367... Line 5621...
5367
	 */
5621
	 */
5368
	u32 bps = target_clock * bpp * 21 / 20;
5622
	u32 bps = target_clock * bpp * 21 / 20;
5369
	return bps / (link_bw * 8) + 1;
5623
	return bps / (link_bw * 8) + 1;
5370
}
5624
}
Line 5371... Line 5625...
5371
 
5625
 
5372
void intel_pch_transcoder_set_m_n(struct intel_crtc *crtc,
-
 
5373
				  struct intel_link_m_n *m_n)
5626
static bool ironlake_needs_fb_cb_tune(struct dpll *dpll, int factor)
5374
{
-
 
5375
	struct drm_device *dev = crtc->base.dev;
5627
{
5376
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5377
	int pipe = crtc->pipe;
-
 
5378
 
-
 
5379
	I915_WRITE(TRANSDATA_M1(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m);
-
 
5380
	I915_WRITE(TRANSDATA_N1(pipe), m_n->gmch_n);
-
 
5381
	I915_WRITE(TRANSDPLINK_M1(pipe), m_n->link_m);
-
 
5382
	I915_WRITE(TRANSDPLINK_N1(pipe), m_n->link_n);
-
 
5383
}
-
 
5384
 
-
 
5385
void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc,
-
 
5386
				  struct intel_link_m_n *m_n)
-
 
5387
{
-
 
5388
	struct drm_device *dev = crtc->base.dev;
-
 
5389
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5390
	int pipe = crtc->pipe;
-
 
5391
	enum transcoder transcoder = crtc->config.cpu_transcoder;
-
 
5392
 
-
 
5393
	if (INTEL_INFO(dev)->gen >= 5) {
-
 
5394
		I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m);
-
 
5395
		I915_WRITE(PIPE_DATA_N1(transcoder), m_n->gmch_n);
-
 
5396
		I915_WRITE(PIPE_LINK_M1(transcoder), m_n->link_m);
-
 
5397
		I915_WRITE(PIPE_LINK_N1(transcoder), m_n->link_n);
-
 
5398
	} else {
-
 
5399
		I915_WRITE(PIPE_GMCH_DATA_M(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m);
-
 
5400
		I915_WRITE(PIPE_GMCH_DATA_N(pipe), m_n->gmch_n);
-
 
5401
		I915_WRITE(PIPE_DP_LINK_M(pipe), m_n->link_m);
-
 
5402
		I915_WRITE(PIPE_DP_LINK_N(pipe), m_n->link_n);
-
 
5403
	}
-
 
5404
}
-
 
5405
 
-
 
5406
static void ironlake_fdi_set_m_n(struct drm_crtc *crtc)
-
 
5407
{
-
 
5408
    struct drm_device *dev = crtc->dev;
-
 
5409
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
5410
	struct drm_display_mode *adjusted_mode =
-
 
5411
		&intel_crtc->config.adjusted_mode;
-
 
5412
	struct intel_link_m_n m_n = {0};
-
 
5413
	int target_clock, lane, link_bw;
-
 
5414
 
-
 
5415
        /* FDI is a binary signal running at ~2.7GHz, encoding
-
 
5416
         * each output octet as 10 bits. The actual frequency
-
 
5417
         * is stored as a divider into a 100MHz clock, and the
-
 
5418
         * mode pixel clock is stored in units of 1KHz.
-
 
5419
         * Hence the bw of each lane in terms of the mode signal
-
 
5420
         * is:
-
 
5421
         */
-
 
5422
        link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10;
-
 
5423
 
-
 
5424
	if (intel_crtc->config.pixel_target_clock)
-
 
5425
		target_clock = intel_crtc->config.pixel_target_clock;
-
 
5426
	else
-
 
5427
		target_clock = adjusted_mode->clock;
-
 
5428
 
-
 
5429
		lane = ironlake_get_lanes_required(target_clock, link_bw,
-
 
5430
					   intel_crtc->config.pipe_bpp);
-
 
5431
 
-
 
5432
    intel_crtc->fdi_lanes = lane;
-
 
5433
 
-
 
5434
	if (intel_crtc->config.pixel_multiplier > 1)
-
 
5435
		link_bw *= intel_crtc->config.pixel_multiplier;
-
 
5436
	intel_link_compute_m_n(intel_crtc->config.pipe_bpp, lane, target_clock,
-
 
5437
			       link_bw, &m_n);
-
 
5438
 
-
 
5439
	intel_cpu_transcoder_set_m_n(intel_crtc, &m_n);
5628
	return i9xx_dpll_compute_m(dpll) < factor * dpll->n;
Line 5440... Line 5629...
5440
}
5629
}
5441
 
5630
 
5442
static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
5631
static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
5443
				      intel_clock_t *clock, u32 *fp,
5632
				      u32 *fp,
5444
				      intel_clock_t *reduced_clock, u32 *fp2)
5633
				      intel_clock_t *reduced_clock, u32 *fp2)
5445
{
5634
{
5446
	struct drm_crtc *crtc = &intel_crtc->base;
5635
	struct drm_crtc *crtc = &intel_crtc->base;
5447
	struct drm_device *dev = crtc->dev;
5636
	struct drm_device *dev = crtc->dev;
5448
	struct drm_i915_private *dev_priv = dev->dev_private;
5637
	struct drm_i915_private *dev_priv = dev->dev_private;
5449
	struct intel_encoder *intel_encoder;
5638
	struct intel_encoder *intel_encoder;
5450
	uint32_t dpll;
5639
	uint32_t dpll;
Line 5451... Line 5640...
5451
	int factor, num_connectors = 0;
5640
	int factor, num_connectors = 0;
5452
	bool is_lvds = false, is_sdvo = false, is_tv = false;
5641
	bool is_lvds = false, is_sdvo = false;
5453
 
5642
 
5454
	for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
5643
	for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
5455
		switch (intel_encoder->type) {
5644
		switch (intel_encoder->type) {
5456
		case INTEL_OUTPUT_LVDS:
5645
		case INTEL_OUTPUT_LVDS:
5457
			is_lvds = true;
5646
			is_lvds = true;
5458
			break;
5647
			break;
5459
		case INTEL_OUTPUT_SDVO:
-
 
5460
		case INTEL_OUTPUT_HDMI:
-
 
5461
			is_sdvo = true;
-
 
5462
			if (intel_encoder->needs_tv_clock)
-
 
5463
				is_tv = true;
-
 
5464
			break;
5648
		case INTEL_OUTPUT_SDVO:
5465
		case INTEL_OUTPUT_TVOUT:
5649
		case INTEL_OUTPUT_HDMI:
Line 5466... Line 5650...
5466
			is_tv = true;
5650
			is_sdvo = true;
5467
			break;
5651
			break;
Line 5468... Line 5652...
5468
		}
5652
		}
5469
 
5653
 
5470
		num_connectors++;
5654
		num_connectors++;
5471
	}
5655
	}
5472
 
5656
 
5473
    /* Enable autotuning of the PLL clock (if permissible) */
5657
    /* Enable autotuning of the PLL clock (if permissible) */
5474
    factor = 21;
5658
    factor = 21;
5475
    if (is_lvds) {
5659
    if (is_lvds) {
5476
        if ((intel_panel_use_ssc(dev_priv) &&
5660
        if ((intel_panel_use_ssc(dev_priv) &&
Line 5477... Line 5661...
5477
             dev_priv->lvds_ssc_freq == 100) ||
5661
		     dev_priv->vbt.lvds_ssc_freq == 100) ||
5478
		    (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev)))
5662
		    (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev)))
Line 5479... Line 5663...
5479
            factor = 25;
5663
            factor = 25;
5480
    } else if (is_sdvo && is_tv)
5664
	} else if (intel_crtc->config.sdvo_tv_clock)
Line 5490... Line 5674...
5490
 
5674
 
5491
    if (is_lvds)
5675
    if (is_lvds)
5492
        dpll |= DPLLB_MODE_LVDS;
5676
        dpll |= DPLLB_MODE_LVDS;
5493
    else
5677
    else
5494
        dpll |= DPLLB_MODE_DAC_SERIAL;
-
 
5495
    if (is_sdvo) {
-
 
-
 
5678
        dpll |= DPLLB_MODE_DAC_SERIAL;
5496
		if (intel_crtc->config.pixel_multiplier > 1) {
5679
 
5497
			dpll |= (intel_crtc->config.pixel_multiplier - 1)
5680
			dpll |= (intel_crtc->config.pixel_multiplier - 1)
-
 
5681
				<< PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
5498
				<< PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
5682
 
5499
        }
5683
	if (is_sdvo)
5500
        dpll |= DPLL_DVO_HIGH_SPEED;
-
 
5501
    }
5684
		dpll |= DPLL_SDVO_HIGH_SPEED;
5502
	if (intel_crtc->config.has_dp_encoder &&
-
 
5503
	    intel_crtc->config.has_pch_encoder)
5685
	if (intel_crtc->config.has_dp_encoder)
Line 5504... Line 5686...
5504
        dpll |= DPLL_DVO_HIGH_SPEED;
5686
		dpll |= DPLL_SDVO_HIGH_SPEED;
5505
 
5687
 
5506
    /* compute bitmask from p1 value */
5688
    /* compute bitmask from p1 value */
5507
	dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
5689
	dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
Line 5508... Line 5690...
5508
    /* also FPA1 */
5690
    /* also FPA1 */
5509
	dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
5691
	dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
5510
 
5692
 
5511
	switch (clock->p2) {
5693
	switch (intel_crtc->config.dpll.p2) {
5512
    case 5:
5694
    case 5:
5513
        dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
5695
        dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
Line 5521... Line 5703...
5521
    case 14:
5703
    case 14:
5522
        dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
5704
        dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
5523
        break;
5705
        break;
5524
    }
5706
    }
Line 5525... Line -...
5525
 
-
 
5526
    if (is_sdvo && is_tv)
-
 
5527
        dpll |= PLL_REF_INPUT_TVCLKINBC;
-
 
5528
    else if (is_tv)
-
 
5529
        /* XXX: just matching BIOS for now */
-
 
5530
        /*  dpll |= PLL_REF_INPUT_TVCLKINBC; */
-
 
5531
        dpll |= 3;
5707
 
5532
    else if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2)
5708
	if (is_lvds && intel_panel_use_ssc(dev_priv) && num_connectors < 2)
5533
        dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
5709
        dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
5534
    else
5710
    else
Line 5535... Line 5711...
5535
        dpll |= PLL_REF_INPUT_DREFCLK;
5711
        dpll |= PLL_REF_INPUT_DREFCLK;
5536
 
5712
 
Line 5537... Line 5713...
5537
	return dpll;
5713
	return dpll | DPLL_VCO_ENABLE;
5538
}
5714
}
5539
 
5715
 
5540
static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5716
static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5541
				  int x, int y,
5717
				  int x, int y,
5542
				  struct drm_framebuffer *fb)
5718
				  struct drm_framebuffer *fb)
5543
{
5719
{
5544
	struct drm_device *dev = crtc->dev;
-
 
5545
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5546
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
5547
	struct drm_display_mode *adjusted_mode =
5720
	struct drm_device *dev = crtc->dev;
5548
		&intel_crtc->config.adjusted_mode;
5721
	struct drm_i915_private *dev_priv = dev->dev_private;
5549
	struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
5722
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5550
	int pipe = intel_crtc->pipe;
5723
	int pipe = intel_crtc->pipe;
5551
	int plane = intel_crtc->plane;
5724
	int plane = intel_crtc->plane;
5552
	int num_connectors = 0;
5725
	int num_connectors = 0;
5553
	intel_clock_t clock, reduced_clock;
5726
	intel_clock_t clock, reduced_clock;
5554
	u32 dpll, fp = 0, fp2 = 0;
5727
	u32 dpll = 0, fp = 0, fp2 = 0;
-
 
5728
	bool ok, has_reduced_clock = false;
5555
	bool ok, has_reduced_clock = false;
5729
	bool is_lvds = false;
5556
	bool is_lvds = false;
-
 
Line 5557... Line 5730...
5557
	struct intel_encoder *encoder;
5730
	struct intel_encoder *encoder;
5558
	int ret;
5731
	struct intel_shared_dpll *pll;
5559
	bool dither, fdi_config_ok;
5732
	int ret;
5560
 
5733
 
Line 5569... Line 5742...
5569
	}
5742
	}
Line 5570... Line 5743...
5570
 
5743
 
5571
	WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)),
5744
	WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)),
Line 5572... Line -...
5572
	     "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev));
-
 
5573
 
-
 
5574
	intel_crtc->config.cpu_transcoder = pipe;
5745
	     "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev));
5575
 
5746
 
5576
	ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock,
5747
	ok = ironlake_compute_clocks(crtc, &clock,
5577
				     &has_reduced_clock, &reduced_clock);
5748
				     &has_reduced_clock, &reduced_clock);
5578
	if (!ok) {
5749
	if (!ok && !intel_crtc->config.clock_set) {
5579
		DRM_ERROR("Couldn't find PLL settings for mode!\n");
5750
		DRM_ERROR("Couldn't find PLL settings for mode!\n");
5580
		return -EINVAL;
5751
		return -EINVAL;
5581
	}
5752
	}
Line 5586... Line 5757...
5586
		intel_crtc->config.dpll.m2 = clock.m2;
5757
		intel_crtc->config.dpll.m2 = clock.m2;
5587
		intel_crtc->config.dpll.p1 = clock.p1;
5758
		intel_crtc->config.dpll.p1 = clock.p1;
5588
		intel_crtc->config.dpll.p2 = clock.p2;
5759
		intel_crtc->config.dpll.p2 = clock.p2;
5589
	}
5760
	}
Line 5590... Line 5761...
5590
 
5761
 
5591
	/* Ensure that the cursor is valid for the new mode before changing... */
5762
	/* CPU eDP is the only output that doesn't need a PCH PLL of its own. */
5592
//	intel_crtc_update_cursor(crtc, true);
-
 
5593
 
-
 
5594
	/* determine panel color depth */
5763
	if (intel_crtc->config.has_pch_encoder) {
5595
	dither = intel_crtc->config.dither;
-
 
5596
	if (is_lvds && dev_priv->lvds_dither)
-
 
5597
		dither = true;
-
 
5598
 
-
 
5599
	fp = clock.n << 16 | clock.m1 << 8 | clock.m2;
5764
		fp = i9xx_dpll_compute_fp(&intel_crtc->config.dpll);
5600
	if (has_reduced_clock)
5765
	if (has_reduced_clock)
5601
		fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 |
-
 
Line 5602... Line 5766...
5602
			reduced_clock.m2;
5766
			fp2 = i9xx_dpll_compute_fp(&reduced_clock);
-
 
5767
 
5603
 
5768
		dpll = ironlake_compute_dpll(intel_crtc,
Line 5604... Line 5769...
5604
	dpll = ironlake_compute_dpll(intel_crtc, &clock, &fp, &reduced_clock,
5769
					     &fp, &reduced_clock,
5605
				     has_reduced_clock ? &fp2 : NULL);
5770
				     has_reduced_clock ? &fp2 : NULL);
5606
 
-
 
5607
	DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe);
5771
 
5608
    drm_mode_debug_printmodeline(mode);
5772
		intel_crtc->config.dpll_hw_state.dpll = dpll;
-
 
5773
		intel_crtc->config.dpll_hw_state.fp0 = fp;
5609
 
5774
		if (has_reduced_clock)
Line 5610... Line 5775...
5610
	/* CPU eDP is the only output that doesn't need a PCH PLL of its own. */
5775
			intel_crtc->config.dpll_hw_state.fp1 = fp2;
5611
	if (intel_crtc->config.has_pch_encoder) {
5776
		else
5612
		struct intel_pch_pll *pll;
5777
			intel_crtc->config.dpll_hw_state.fp1 = fp;
5613
 
5778
 
5614
		pll = intel_get_pch_pll(intel_crtc, dpll, fp);
5779
		pll = intel_get_shared_dpll(intel_crtc);
5615
		if (pll == NULL) {
5780
		if (pll == NULL) {
5616
			DRM_DEBUG_DRIVER("failed to find PLL for pipe %d\n",
5781
			DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
5617
					 pipe);
5782
					 pipe_name(pipe));
Line 5618... Line 5783...
5618
			return -EINVAL;
5783
			return -EINVAL;
5619
        }
5784
        }
Line 5620... Line 5785...
5620
	} else
5785
	} else
5621
		intel_put_pch_pll(intel_crtc);
5786
		intel_put_shared_dpll(intel_crtc);
5622
 
-
 
5623
	if (intel_crtc->config.has_dp_encoder)
5787
 
5624
		intel_dp_set_m_n(intel_crtc);
5788
	if (intel_crtc->config.has_dp_encoder)
5625
 
-
 
5626
	for_each_encoder_on_crtc(dev, crtc, encoder)
-
 
5627
		if (encoder->pre_pll_enable)
-
 
5628
			encoder->pre_pll_enable(encoder);
-
 
5629
 
-
 
Line 5630... Line -...
5630
	if (intel_crtc->pch_pll) {
-
 
5631
		I915_WRITE(intel_crtc->pch_pll->pll_reg, dpll);
5789
		intel_dp_set_m_n(intel_crtc);
5632
 
-
 
5633
        /* Wait for the clocks to stabilize. */
-
 
5634
		POSTING_READ(intel_crtc->pch_pll->pll_reg);
-
 
5635
        udelay(150);
5790
 
5636
 
-
 
Line 5637... Line -...
5637
        /* The pixel multiplier can only be updated once the
-
 
5638
         * DPLL is enabled and the clocks are stable.
-
 
5639
         *
-
 
5640
         * So write it again.
-
 
5641
         */
-
 
5642
		I915_WRITE(intel_crtc->pch_pll->pll_reg, dpll);
-
 
5643
    }
-
 
5644
 
-
 
5645
    intel_crtc->lowfreq_avail = false;
5791
	if (is_lvds && has_reduced_clock && i915_powersave)
Line 5646... Line 5792...
5646
	if (intel_crtc->pch_pll) {
5792
		intel_crtc->lowfreq_avail = true;
5647
    if (is_lvds && has_reduced_clock && i915_powersave) {
-
 
5648
			I915_WRITE(intel_crtc->pch_pll->fp1_reg, fp2);
-
 
5649
        intel_crtc->lowfreq_avail = true;
-
 
5650
    } else {
-
 
5651
			I915_WRITE(intel_crtc->pch_pll->fp1_reg, fp);
-
 
5652
    }
-
 
Line -... Line 5793...
-
 
5793
	else
5653
	}
5794
		intel_crtc->lowfreq_avail = false;
-
 
5795
 
-
 
5796
	if (intel_crtc->config.has_pch_encoder) {
Line -... Line 5797...
-
 
5797
		pll = intel_crtc_to_shared_dpll(intel_crtc);
5654
 
5798
 
Line 5655... Line 5799...
5655
	intel_set_pipe_timings(intel_crtc, mode, adjusted_mode);
5799
	}
Line 5656... Line 5800...
5656
 
5800
 
5657
	/* Note, this also computes intel_crtc->fdi_lanes which is used below in
5801
	intel_set_pipe_timings(intel_crtc);
5658
	 * ironlake_check_fdi_lanes. */
5802
 
Line 5659... Line 5803...
5659
	intel_crtc->fdi_lanes = 0;
5803
	if (intel_crtc->config.has_pch_encoder) {
Line 5660... Line 5804...
5660
	if (intel_crtc->config.has_pch_encoder)
5804
		intel_cpu_transcoder_set_m_n(intel_crtc,
Line -... Line 5805...
-
 
5805
					     &intel_crtc->config.fdi_m_n);
-
 
5806
	}
-
 
5807
 
-
 
5808
	if (IS_IVYBRIDGE(dev))
-
 
5809
		ivybridge_update_fdi_bc_bifurcation(intel_crtc);
-
 
5810
 
-
 
5811
	ironlake_set_pipeconf(crtc);
-
 
5812
 
5661
		ironlake_fdi_set_m_n(crtc);
5813
	/* Set up the display plane register */
Line -... Line 5814...
-
 
5814
	I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE);
-
 
5815
	POSTING_READ(DSPCNTR(plane));
-
 
5816
 
-
 
5817
	ret = intel_pipe_set_base(crtc, x, y, fb);
-
 
5818
 
-
 
5819
	intel_update_watermarks(dev);
-
 
5820
 
-
 
5821
	return ret;
-
 
5822
}
-
 
5823
 
-
 
5824
static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc,
-
 
5825
					struct intel_crtc_config *pipe_config)
5662
 
5826
{
-
 
5827
	struct drm_device *dev = crtc->base.dev;
-
 
5828
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5829
	enum transcoder transcoder = pipe_config->cpu_transcoder;
-
 
5830
 
-
 
5831
	pipe_config->fdi_m_n.link_m = I915_READ(PIPE_LINK_M1(transcoder));
-
 
5832
	pipe_config->fdi_m_n.link_n = I915_READ(PIPE_LINK_N1(transcoder));
-
 
5833
	pipe_config->fdi_m_n.gmch_m = I915_READ(PIPE_DATA_M1(transcoder))
-
 
5834
					& ~TU_SIZE_MASK;
-
 
5835
	pipe_config->fdi_m_n.gmch_n = I915_READ(PIPE_DATA_N1(transcoder));
-
 
5836
	pipe_config->fdi_m_n.tu = ((I915_READ(PIPE_DATA_M1(transcoder))
-
 
5837
				   & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1;
-
 
5838
}
-
 
5839
 
-
 
5840
static void ironlake_get_pfit_config(struct intel_crtc *crtc,
-
 
5841
				     struct intel_crtc_config *pipe_config)
-
 
5842
{
-
 
5843
	struct drm_device *dev = crtc->base.dev;
-
 
5844
	struct drm_i915_private *dev_priv = dev->dev_private;
5663
	fdi_config_ok = ironlake_check_fdi_lanes(intel_crtc);
5845
	uint32_t tmp;
Line 5664... Line 5846...
5664
 
5846
 
5665
	ironlake_set_pipeconf(crtc, adjusted_mode, dither);
5847
	tmp = I915_READ(PF_CTL(crtc->pipe));
5666
 
5848
 
5667
	intel_wait_for_vblank(dev, pipe);
5849
	if (tmp & PF_ENABLE) {
5668
 
5850
		pipe_config->pch_pfit.enabled = true;
5669
	/* Set up the display plane register */
5851
		pipe_config->pch_pfit.pos = I915_READ(PF_WIN_POS(crtc->pipe));
Line -... Line 5852...
-
 
5852
		pipe_config->pch_pfit.size = I915_READ(PF_WIN_SZ(crtc->pipe));
-
 
5853
 
-
 
5854
		/* We currently do not free assignements of panel fitters on
5670
	I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE);
5855
		 * ivb/hsw (since we don't use the higher upscaling modes which
5671
	POSTING_READ(DSPCNTR(plane));
5856
		 * differentiates them) so just WARN about this case for now. */
5672
 
5857
		if (IS_GEN7(dev)) {
Line 5673... Line 5858...
5673
	ret = intel_pipe_set_base(crtc, x, y, fb);
5858
			WARN_ON((tmp & PF_PIPE_SEL_MASK_IVB) !=
-
 
5859
				PF_PIPE_SEL_IVB(crtc->pipe));
-
 
5860
		}
5674
 
5861
	}
Line -... Line 5862...
-
 
5862
}
-
 
5863
 
-
 
5864
static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
-
 
5865
				     struct intel_crtc_config *pipe_config)
-
 
5866
{
-
 
5867
	struct drm_device *dev = crtc->base.dev;
-
 
5868
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
5869
	uint32_t tmp;
-
 
5870
 
-
 
5871
	pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
-
 
5872
	pipe_config->shared_dpll = DPLL_ID_PRIVATE;
-
 
5873
 
-
 
5874
	tmp = I915_READ(PIPECONF(crtc->pipe));
-
 
5875
	if (!(tmp & PIPECONF_ENABLE))
-
 
5876
		return false;
-
 
5877
 
-
 
5878
	if (I915_READ(PCH_TRANSCONF(crtc->pipe)) & TRANS_ENABLE) {
-
 
5879
		struct intel_shared_dpll *pll;
-
 
5880
 
-
 
5881
		pipe_config->has_pch_encoder = true;
-
 
5882
 
-
 
5883
		tmp = I915_READ(FDI_RX_CTL(crtc->pipe));
-
 
5884
		pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >>
-
 
5885
					  FDI_DP_PORT_WIDTH_SHIFT) + 1;
-
 
5886
 
-
 
5887
		ironlake_get_fdi_m_n_config(crtc, pipe_config);
-
 
5888
 
-
 
5889
		if (HAS_PCH_IBX(dev_priv->dev)) {
-
 
5890
			pipe_config->shared_dpll =
-
 
5891
				(enum intel_dpll_id) crtc->pipe;
-
 
5892
		} else {
-
 
5893
			tmp = I915_READ(PCH_DPLL_SEL);
-
 
5894
			if (tmp & TRANS_DPLLB_SEL(crtc->pipe))
-
 
5895
				pipe_config->shared_dpll = DPLL_ID_PCH_PLL_B;
5675
	intel_update_watermarks(dev);
5896
			else
5676
 
5897
				pipe_config->shared_dpll = DPLL_ID_PCH_PLL_A;
Line 5677... Line 5898...
5677
	intel_update_linetime_watermarks(dev, pipe, adjusted_mode);
5898
		}
5678
 
5899
 
5679
	return fdi_config_ok ? ret : -EINVAL;
5900
		pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
5680
}
5901
 
5681
 
5902
		WARN_ON(!pll->get_hw_state(dev_priv, pll,
5682
static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
5903
					   &pipe_config->dpll_hw_state));
-
 
5904
 
Line 5683... Line 5905...
5683
				     struct intel_crtc_config *pipe_config)
5905
		tmp = pipe_config->dpll_hw_state.dpll;
5684
{
5906
		pipe_config->pixel_multiplier =
5685
	struct drm_device *dev = crtc->base.dev;
5907
			((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK)
-
 
5908
			 >> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1;
-
 
5909
	} else {
-
 
5910
		pipe_config->pixel_multiplier = 1;
-
 
5911
	}
-
 
5912
 
-
 
5913
	intel_get_pipe_timings(crtc, pipe_config);
-
 
5914
 
-
 
5915
	ironlake_get_pfit_config(crtc, pipe_config);
-
 
5916
 
-
 
5917
	return true;
-
 
5918
}
-
 
5919
 
-
 
5920
static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv)
-
 
5921
{
5686
	struct drm_i915_private *dev_priv = dev->dev_private;
5922
	struct drm_device *dev = dev_priv->dev;
-
 
5923
	struct intel_ddi_plls *plls = &dev_priv->ddi_plls;
-
 
5924
	struct intel_crtc *crtc;
-
 
5925
	unsigned long irqflags;
-
 
5926
	uint32_t val;
5687
	uint32_t tmp;
5927
 
-
 
5928
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head)
-
 
5929
		WARN(crtc->base.enabled, "CRTC for pipe %c enabled\n",
5688
 
5930
		     pipe_name(crtc->pipe));
-
 
5931
 
5689
	tmp = I915_READ(PIPECONF(crtc->pipe));
5932
	WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n");
Line -... Line 5933...
-
 
5933
	WARN(plls->spll_refcount, "SPLL enabled\n");
-
 
5934
	WARN(plls->wrpll1_refcount, "WRPLL1 enabled\n");
-
 
5935
	WARN(plls->wrpll2_refcount, "WRPLL2 enabled\n");
-
 
5936
	WARN(I915_READ(PCH_PP_STATUS) & PP_ON, "Panel power on\n");
-
 
5937
	WARN(I915_READ(BLC_PWM_CPU_CTL2) & BLM_PWM_ENABLE,
-
 
5938
	     "CPU PWM1 enabled\n");
-
 
5939
	WARN(I915_READ(HSW_BLC_PWM2_CTL) & BLM_PWM_ENABLE,
-
 
5940
	     "CPU PWM2 enabled\n");
5690
	if (!(tmp & PIPECONF_ENABLE))
5941
	WARN(I915_READ(BLC_PWM_PCH_CTL1) & BLM_PCH_PWM_ENABLE,
-
 
5942
	     "PCH PWM1 enabled\n");
-
 
5943
	WARN(I915_READ(UTIL_PIN_CTL) & UTIL_PIN_ENABLE,
-
 
5944
	     "Utility pin enabled\n");
-
 
5945
	WARN(I915_READ(PCH_GTC_CTL) & PCH_GTC_ENABLE, "PCH GTC enabled\n");
-
 
5946
 
-
 
5947
	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
-
 
5948
	val = I915_READ(DEIMR);
-
 
5949
	WARN((val & ~DE_PCH_EVENT_IVB) != val,
5691
		return false;
5950
	     "Unexpected DEIMR bits enabled: 0x%x\n", val);
-
 
5951
	val = I915_READ(SDEIMR);
-
 
5952
	WARN((val | SDE_HOTPLUG_MASK_CPT) != 0xffffffff,
-
 
5953
	     "Unexpected SDEIMR bits enabled: 0x%x\n", val);
5692
 
5954
	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
5693
	if (I915_READ(TRANSCONF(crtc->pipe)) & TRANS_ENABLE)
5955
}
-
 
5956
 
-
 
5957
/*
5694
		pipe_config->has_pch_encoder = true;
5958
 * This function implements pieces of two sequences from BSpec:
5695
 
5959
 * - Sequence for display software to disable LCPLL
Line 5696... Line 5960...
5696
	return true;
5960
 * - Sequence for display software to allow package C8+
5697
}
5961
 * The steps implemented here are just the steps that actually touch the LCPLL
5698
 
5962
 * register. Callers should take care of disabling all the display engine
Line -... Line 5963...
-
 
5963
 * functions, doing the mode unset, fixing interrupts, etc.
-
 
5964
 */
-
 
5965
void hsw_disable_lcpll(struct drm_i915_private *dev_priv,
-
 
5966
		       bool switch_to_fclk, bool allow_power_down)
-
 
5967
{
-
 
5968
	uint32_t val;
-
 
5969
 
-
 
5970
	assert_can_disable_lcpll(dev_priv);
-
 
5971
 
-
 
5972
	val = I915_READ(LCPLL_CTL);
-
 
5973
 
-
 
5974
	if (switch_to_fclk) {
5699
static void haswell_modeset_global_resources(struct drm_device *dev)
5975
		val |= LCPLL_CD_SOURCE_FCLK;
-
 
5976
		I915_WRITE(LCPLL_CTL, val);
-
 
5977
 
-
 
5978
		if (wait_for_atomic_us(I915_READ(LCPLL_CTL) &
-
 
5979
				       LCPLL_CD_SOURCE_FCLK_DONE, 1))
-
 
5980
			DRM_ERROR("Switching to FCLK failed\n");
5700
{
5981
 
Line -... Line 5982...
-
 
5982
		val = I915_READ(LCPLL_CTL);
5701
	struct drm_i915_private *dev_priv = dev->dev_private;
5983
	}
5702
	bool enable = false;
5984
 
-
 
5985
	val |= LCPLL_PLL_DISABLE;
5703
	struct intel_crtc *crtc;
5986
	I915_WRITE(LCPLL_CTL, val);
5704
	struct intel_encoder *encoder;
5987
	POSTING_READ(LCPLL_CTL);
5705
 
-
 
5706
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
-
 
5707
		if (crtc->pipe != PIPE_A && crtc->base.enabled)
-
 
5708
			enable = true;
-
 
5709
		/* XXX: Should check for edp transcoder here, but thanks to init
-
 
5710
		 * sequence that's not yet available. Just in case desktop eDP
-
 
5711
		 * on PORT D is possible on haswell, too. */
-
 
5712
	}
-
 
5713
 
-
 
5714
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
-
 
5715
			    base.head) {
-
 
5716
		if (encoder->type != INTEL_OUTPUT_EDP &&
5988
 
5717
		    encoder->connectors_active)
-
 
Line -... Line 5989...
-
 
5989
	if (wait_for((I915_READ(LCPLL_CTL) & LCPLL_PLL_LOCK) == 0, 1))
-
 
5990
		DRM_ERROR("LCPLL still locked\n");
-
 
5991
 
5718
			enable = true;
5992
	val = I915_READ(D_COMP);
-
 
5993
	val |= D_COMP_COMP_DISABLE;
-
 
5994
	I915_WRITE(D_COMP, val);
-
 
5995
	POSTING_READ(D_COMP);
5719
	}
5996
    udelay(100);
-
 
5997
 
-
 
5998
	if (wait_for((I915_READ(D_COMP) & D_COMP_RCOMP_IN_PROGRESS) == 0, 1))
5720
 
5999
		DRM_ERROR("D_COMP RCOMP still in progress\n");
5721
	/* Even the eDP panel fitter is outside the always-on well. */
6000
 
5722
	if (dev_priv->pch_pf_size)
6001
	if (allow_power_down) {
5723
		enable = true;
6002
		val = I915_READ(LCPLL_CTL);
5724
 
6003
		val |= LCPLL_POWER_DOWN_ALLOW;
Line -... Line 6004...
-
 
6004
		I915_WRITE(LCPLL_CTL, val);
-
 
6005
		POSTING_READ(LCPLL_CTL);
-
 
6006
	}
-
 
6007
}
-
 
6008
 
-
 
6009
/*
-
 
6010
 * Fully restores LCPLL, disallowing power down and switching back to LCPLL
-
 
6011
 * source.
-
 
6012
 */
-
 
6013
void hsw_restore_lcpll(struct drm_i915_private *dev_priv)
-
 
6014
{
-
 
6015
	uint32_t val;
-
 
6016
 
-
 
6017
	val = I915_READ(LCPLL_CTL);
-
 
6018
 
-
 
6019
	if ((val & (LCPLL_PLL_LOCK | LCPLL_PLL_DISABLE | LCPLL_CD_SOURCE_FCLK |
-
 
6020
		    LCPLL_POWER_DOWN_ALLOW)) == LCPLL_PLL_LOCK)
-
 
6021
		return;
-
 
6022
 
-
 
6023
	/* Make sure we're not on PC8 state before disabling PC8, otherwise
-
 
6024
	 * we'll hang the machine! */
-
 
6025
	dev_priv->uncore.funcs.force_wake_get(dev_priv);
-
 
6026
 
-
 
6027
	if (val & LCPLL_POWER_DOWN_ALLOW) {
-
 
6028
		val &= ~LCPLL_POWER_DOWN_ALLOW;
-
 
6029
		I915_WRITE(LCPLL_CTL, val);
-
 
6030
		POSTING_READ(LCPLL_CTL);
-
 
6031
	}
-
 
6032
 
-
 
6033
	val = I915_READ(D_COMP);
5725
	intel_set_power_well(dev, enable);
6034
	val |= D_COMP_COMP_FORCE;
-
 
6035
	val &= ~D_COMP_COMP_DISABLE;
-
 
6036
	I915_WRITE(D_COMP, val);
-
 
6037
	POSTING_READ(D_COMP);
-
 
6038
 
-
 
6039
	val = I915_READ(LCPLL_CTL);
-
 
6040
	val &= ~LCPLL_PLL_DISABLE;
-
 
6041
	I915_WRITE(LCPLL_CTL, val);
-
 
6042
 
-
 
6043
	if (wait_for(I915_READ(LCPLL_CTL) & LCPLL_PLL_LOCK, 5))
-
 
6044
		DRM_ERROR("LCPLL not locked yet\n");
-
 
6045
 
-
 
6046
	if (val & LCPLL_CD_SOURCE_FCLK) {
-
 
6047
		val = I915_READ(LCPLL_CTL);
-
 
6048
		val &= ~LCPLL_CD_SOURCE_FCLK;
-
 
6049
		I915_WRITE(LCPLL_CTL, val);
-
 
6050
 
-
 
6051
		if (wait_for_atomic_us((I915_READ(LCPLL_CTL) &
-
 
6052
					LCPLL_CD_SOURCE_FCLK_DONE) == 0, 1))
-
 
6053
			DRM_ERROR("Switching back to LCPLL failed\n");
-
 
6054
	}
-
 
6055
 
-
 
6056
	dev_priv->uncore.funcs.force_wake_put(dev_priv);
-
 
6057
}
-
 
6058
 
-
 
6059
void hsw_enable_pc8_work(struct work_struct *__work)
-
 
6060
{
-
 
6061
	struct drm_i915_private *dev_priv =
-
 
6062
		container_of(to_delayed_work(__work), struct drm_i915_private,
-
 
6063
			     pc8.enable_work);
-
 
6064
	struct drm_device *dev = dev_priv->dev;
-
 
6065
	uint32_t val;
-
 
6066
 
-
 
6067
	if (dev_priv->pc8.enabled)
5726
}
6068
		return;
Line -... Line 6069...
-
 
6069
 
-
 
6070
	DRM_DEBUG_KMS("Enabling package C8+\n");
-
 
6071
 
-
 
6072
	dev_priv->pc8.enabled = true;
-
 
6073
 
-
 
6074
	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
-
 
6075
		val = I915_READ(SOUTH_DSPCLK_GATE_D);
-
 
6076
		val &= ~PCH_LP_PARTITION_LEVEL_DISABLE;
-
 
6077
		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
-
 
6078
	}
-
 
6079
 
-
 
6080
	lpt_disable_clkout_dp(dev);
-
 
6081
	hsw_pc8_disable_interrupts(dev);
-
 
6082
	hsw_disable_lcpll(dev_priv, true, true);
-
 
6083
}
-
 
6084
 
-
 
6085
static void __hsw_enable_package_c8(struct drm_i915_private *dev_priv)
-
 
6086
{
-
 
6087
	WARN_ON(!mutex_is_locked(&dev_priv->pc8.lock));
-
 
6088
	WARN(dev_priv->pc8.disable_count < 1,
-
 
6089
	     "pc8.disable_count: %d\n", dev_priv->pc8.disable_count);
-
 
6090
 
-
 
6091
	dev_priv->pc8.disable_count--;
-
 
6092
	if (dev_priv->pc8.disable_count != 0)
-
 
6093
		return;
-
 
6094
 
-
 
6095
	schedule_delayed_work(&dev_priv->pc8.enable_work,
-
 
6096
			      msecs_to_jiffies(i915_pc8_timeout));
-
 
6097
}
-
 
6098
 
-
 
6099
static void __hsw_disable_package_c8(struct drm_i915_private *dev_priv)
-
 
6100
{
-
 
6101
	struct drm_device *dev = dev_priv->dev;
-
 
6102
	uint32_t val;
-
 
6103
 
-
 
6104
	WARN_ON(!mutex_is_locked(&dev_priv->pc8.lock));
-
 
6105
	WARN(dev_priv->pc8.disable_count < 0,
-
 
6106
	     "pc8.disable_count: %d\n", dev_priv->pc8.disable_count);
-
 
6107
 
-
 
6108
	dev_priv->pc8.disable_count++;
-
 
6109
	if (dev_priv->pc8.disable_count != 1)
-
 
6110
		return;
-
 
6111
 
-
 
6112
//   cancel_delayed_work_sync(&dev_priv->pc8.enable_work);
-
 
6113
	if (!dev_priv->pc8.enabled)
-
 
6114
		return;
-
 
6115
 
-
 
6116
	DRM_DEBUG_KMS("Disabling package C8+\n");
-
 
6117
 
-
 
6118
	hsw_restore_lcpll(dev_priv);
-
 
6119
	hsw_pc8_restore_interrupts(dev);
-
 
6120
	lpt_init_pch_refclk(dev);
-
 
6121
 
-
 
6122
	if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
-
 
6123
		val = I915_READ(SOUTH_DSPCLK_GATE_D);
-
 
6124
		val |= PCH_LP_PARTITION_LEVEL_DISABLE;
-
 
6125
		I915_WRITE(SOUTH_DSPCLK_GATE_D, val);
-
 
6126
	}
-
 
6127
 
-
 
6128
	intel_prepare_ddi(dev);
-
 
6129
	i915_gem_init_swizzling(dev);
-
 
6130
	mutex_lock(&dev_priv->rps.hw_lock);
-
 
6131
	gen6_update_ring_freq(dev);
-
 
6132
	mutex_unlock(&dev_priv->rps.hw_lock);
-
 
6133
	dev_priv->pc8.enabled = false;
-
 
6134
}
-
 
6135
 
-
 
6136
void hsw_enable_package_c8(struct drm_i915_private *dev_priv)
-
 
6137
{
-
 
6138
	mutex_lock(&dev_priv->pc8.lock);
-
 
6139
	__hsw_enable_package_c8(dev_priv);
-
 
6140
	mutex_unlock(&dev_priv->pc8.lock);
-
 
6141
}
-
 
6142
 
-
 
6143
void hsw_disable_package_c8(struct drm_i915_private *dev_priv)
-
 
6144
{
-
 
6145
	mutex_lock(&dev_priv->pc8.lock);
-
 
6146
	__hsw_disable_package_c8(dev_priv);
-
 
6147
	mutex_unlock(&dev_priv->pc8.lock);
-
 
6148
}
-
 
6149
 
-
 
6150
static bool hsw_can_enable_package_c8(struct drm_i915_private *dev_priv)
-
 
6151
{
5727
 
6152
	struct drm_device *dev = dev_priv->dev;
-
 
6153
	struct intel_crtc *crtc;
-
 
6154
	uint32_t val;
-
 
6155
 
-
 
6156
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head)
-
 
6157
		if (crtc->base.enabled)
-
 
6158
			return false;
-
 
6159
 
-
 
6160
	/* This case is still possible since we have the i915.disable_power_well
-
 
6161
	 * parameter and also the KVMr or something else might be requesting the
5728
static int haswell_crtc_mode_set(struct drm_crtc *crtc,
6162
	 * power well. */
-
 
6163
	val = I915_READ(HSW_PWR_WELL_DRIVER);
-
 
6164
	if (val != 0) {
-
 
6165
		DRM_DEBUG_KMS("Not enabling PC8: power well on\n");
5729
				 int x, int y,
6166
		return false;
5730
				 struct drm_framebuffer *fb)
6167
	}
Line 5731... Line 6168...
5731
{
6168
 
5732
	struct drm_device *dev = crtc->dev;
-
 
5733
	struct drm_i915_private *dev_priv = dev->dev_private;
6169
	return true;
-
 
6170
}
Line 5734... Line 6171...
5734
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6171
 
-
 
6172
/* Since we're called from modeset_global_resources there's no way to
-
 
6173
 * symmetrically increase and decrease the refcount, so we use
-
 
6174
 * dev_priv->pc8.requirements_met to track whether we already have the refcount
5735
	struct drm_display_mode *adjusted_mode =
6175
 * or not.
-
 
6176
 */
-
 
6177
static void hsw_update_package_c8(struct drm_device *dev)
Line 5736... Line 6178...
5736
		&intel_crtc->config.adjusted_mode;
6178
{
-
 
6179
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
6180
	bool allow;
-
 
6181
 
5737
	struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
6182
	if (!i915_enable_pc8)
-
 
6183
		return;
-
 
6184
 
Line 5738... Line 6185...
5738
	int pipe = intel_crtc->pipe;
6185
	mutex_lock(&dev_priv->pc8.lock);
-
 
6186
 
-
 
6187
	allow = hsw_can_enable_package_c8(dev_priv);
-
 
6188
 
Line 5739... Line 6189...
5739
	int plane = intel_crtc->plane;
6189
	if (allow == dev_priv->pc8.requirements_met)
-
 
6190
		goto done;
5740
	int num_connectors = 0;
6191
 
Line 5741... Line 6192...
5741
	bool is_cpu_edp = false;
6192
	dev_priv->pc8.requirements_met = allow;
-
 
6193
 
-
 
6194
	if (allow)
-
 
6195
		__hsw_enable_package_c8(dev_priv);
-
 
6196
	else
5742
	struct intel_encoder *encoder;
6197
		__hsw_disable_package_c8(dev_priv);
-
 
6198
 
-
 
6199
done:
-
 
6200
	mutex_unlock(&dev_priv->pc8.lock);
Line -... Line 6201...
-
 
6201
}
-
 
6202
 
-
 
6203
static void hsw_package_c8_gpu_idle(struct drm_i915_private *dev_priv)
-
 
6204
{
5743
	int ret;
6205
	if (!dev_priv->pc8.gpu_idle) {
-
 
6206
		dev_priv->pc8.gpu_idle = true;
-
 
6207
		hsw_enable_package_c8(dev_priv);
5744
	bool dither;
6208
	}
-
 
6209
}
Line 5745... Line 6210...
5745
 
6210
 
5746
	for_each_encoder_on_crtc(dev, crtc, encoder) {
6211
static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv)
Line 5747... Line 6212...
5747
		switch (encoder->type) {
6212
{
5748
		case INTEL_OUTPUT_EDP:
6213
	if (dev_priv->pc8.gpu_idle) {
Line 5749... Line 6214...
5749
			if (!intel_encoder_is_pch_edp(&encoder->base))
6214
		dev_priv->pc8.gpu_idle = false;
Line 5750... Line 6215...
5750
				is_cpu_edp = true;
6215
		hsw_disable_package_c8(dev_priv);
Line 5751... Line 6216...
5751
			break;
6216
	}
5752
		}
6217
}
-
 
6218
 
-
 
6219
static void haswell_modeset_global_resources(struct drm_device *dev)
Line 5753... Line 6220...
5753
 
6220
{
Line 5754... Line 6221...
5754
		num_connectors++;
6221
	bool enable = false;
Line 5755... Line 6222...
5755
	}
6222
	struct intel_crtc *crtc;
5756
 
6223
 
Line 5803... Line 6270...
5803
 
6270
 
Line 5804... Line 6271...
5804
	ret = intel_pipe_set_base(crtc, x, y, fb);
6271
	ret = intel_pipe_set_base(crtc, x, y, fb);
Line 5805... Line -...
5805
 
-
 
5806
    intel_update_watermarks(dev);
-
 
5807
 
6272
 
5808
	intel_update_linetime_watermarks(dev, pipe, adjusted_mode);
6273
    intel_update_watermarks(dev);
Line 5809... Line 6274...
5809
 
6274
 
5810
    return ret;
6275
    return ret;
5811
}
6276
}
5812
 
6277
 
5813
static bool haswell_get_pipe_config(struct intel_crtc *crtc,
6278
static bool haswell_get_pipe_config(struct intel_crtc *crtc,
-
 
6279
				    struct intel_crtc_config *pipe_config)
5814
				    struct intel_crtc_config *pipe_config)
6280
{
Line -... Line 6281...
-
 
6281
	struct drm_device *dev = crtc->base.dev;
-
 
6282
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
6283
	enum intel_display_power_domain pfit_domain;
-
 
6284
	uint32_t tmp;
-
 
6285
 
-
 
6286
	pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
-
 
6287
	pipe_config->shared_dpll = DPLL_ID_PRIVATE;
-
 
6288
 
-
 
6289
	tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP));
-
 
6290
	if (tmp & TRANS_DDI_FUNC_ENABLE) {
-
 
6291
		enum pipe trans_edp_pipe;
-
 
6292
		switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
-
 
6293
		default:
-
 
6294
			WARN(1, "unknown pipe linked to edp transcoder\n");
-
 
6295
		case TRANS_DDI_EDP_INPUT_A_ONOFF:
-
 
6296
		case TRANS_DDI_EDP_INPUT_A_ON:
-
 
6297
			trans_edp_pipe = PIPE_A;
-
 
6298
			break;
-
 
6299
		case TRANS_DDI_EDP_INPUT_B_ONOFF:
-
 
6300
			trans_edp_pipe = PIPE_B;
-
 
6301
			break;
-
 
6302
		case TRANS_DDI_EDP_INPUT_C_ONOFF:
-
 
6303
			trans_edp_pipe = PIPE_C;
-
 
6304
			break;
-
 
6305
		}
-
 
6306
 
-
 
6307
		if (trans_edp_pipe == crtc->pipe)
-
 
6308
			pipe_config->cpu_transcoder = TRANSCODER_EDP;
-
 
6309
	}
5815
{
6310
 
5816
	struct drm_device *dev = crtc->base.dev;
6311
	if (!intel_display_power_enabled(dev,
5817
	struct drm_i915_private *dev_priv = dev->dev_private;
6312
			POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder)))
Line 5818... Line 6313...
5818
	uint32_t tmp;
6313
		return false;
5819
 
6314
 
5820
	tmp = I915_READ(PIPECONF(crtc->config.cpu_transcoder));
6315
	tmp = I915_READ(PIPECONF(pipe_config->cpu_transcoder));
5821
	if (!(tmp & PIPECONF_ENABLE))
6316
	if (!(tmp & PIPECONF_ENABLE))
5822
		return false;
6317
		return false;
5823
 
6318
 
5824
	/*
6319
	/*
5825
	 * aswell has only FDI/PCH transcoder A. It is which is connected to
6320
	 * Haswell has only FDI/PCH transcoder A. It is which is connected to
5826
	 * DDI E. So just check whether this pipe is wired to DDI E and whether
6321
	 * DDI E. So just check whether this pipe is wired to DDI E and whether
Line -... Line 6322...
-
 
6322
	 * the PCH transcoder is on.
-
 
6323
	 */
-
 
6324
	tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe_config->cpu_transcoder));
-
 
6325
	if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(PORT_E) &&
-
 
6326
	    I915_READ(LPT_TRANSCONF) & TRANS_ENABLE) {
-
 
6327
		pipe_config->has_pch_encoder = true;
-
 
6328
 
-
 
6329
		tmp = I915_READ(FDI_RX_CTL(PIPE_A));
-
 
6330
		pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >>
-
 
6331
					  FDI_DP_PORT_WIDTH_SHIFT) + 1;
-
 
6332
 
-
 
6333
		ironlake_get_fdi_m_n_config(crtc, pipe_config);
-
 
6334
	}
-
 
6335
 
-
 
6336
	intel_get_pipe_timings(crtc, pipe_config);
-
 
6337
 
-
 
6338
	pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
Line 5827... Line 6339...
5827
	 * the PCH transcoder is on.
6339
	if (intel_display_power_enabled(dev, pfit_domain))
5828
	 */
6340
		ironlake_get_pfit_config(crtc, pipe_config);
Line 5829... Line 6341...
5829
	tmp = I915_READ(TRANS_DDI_FUNC_CTL(crtc->pipe));
6341
 
5830
	if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(PORT_E) &&
6342
	pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) &&
5831
	    I915_READ(TRANSCONF(PIPE_A)) & TRANS_ENABLE)
6343
				   (I915_READ(IPS_CTL) & IPS_ENABLE);
5832
		pipe_config->has_pch_encoder = true;
6344
 
5833
 
6345
	pipe_config->pixel_multiplier = 1;
5834
 
6346
 
5835
	return true;
-
 
5836
}
6347
	return true;
5837
 
6348
}
5838
static int intel_crtc_mode_set(struct drm_crtc *crtc,
-
 
5839
			       int x, int y,
-
 
5840
			       struct drm_framebuffer *fb)
6349
 
5841
{
6350
static int intel_crtc_mode_set(struct drm_crtc *crtc,
5842
	struct drm_device *dev = crtc->dev;
6351
			       int x, int y,
Line 5843... Line 6352...
5843
	struct drm_i915_private *dev_priv = dev->dev_private;
6352
			       struct drm_framebuffer *fb)
Line 5862... Line 6371...
5862
	for_each_encoder_on_crtc(dev, crtc, encoder) {
6371
	for_each_encoder_on_crtc(dev, crtc, encoder) {
5863
		DRM_DEBUG_KMS("[ENCODER:%d:%s] set [MODE:%d:%s]\n",
6372
		DRM_DEBUG_KMS("[ENCODER:%d:%s] set [MODE:%d:%s]\n",
5864
			encoder->base.base.id,
6373
			encoder->base.base.id,
5865
			drm_get_encoder_name(&encoder->base),
6374
			drm_get_encoder_name(&encoder->base),
5866
			mode->base.id, mode->name);
6375
			mode->base.id, mode->name);
5867
		if (encoder->mode_set) {
-
 
5868
			encoder->mode_set(encoder);
6376
			encoder->mode_set(encoder);
5869
		} else {
-
 
5870
		encoder_funcs = encoder->base.helper_private;
-
 
5871
		encoder_funcs->mode_set(&encoder->base, mode, adjusted_mode);
-
 
5872
	}
-
 
5873
	}
6377
	}
Line 5874... Line 6378...
5874
 
6378
 
5875
	return 0;
6379
	return 0;
Line 5974... Line 6478...
5974
	/* Wait for 1 vertical blank */
6478
	/* Wait for 1 vertical blank */
5975
	intel_wait_for_vblank(dev, pipe);
6479
	intel_wait_for_vblank(dev, pipe);
Line 5976... Line 6480...
5976
 
6480
 
5977
	/* Set ELD valid state */
6481
	/* Set ELD valid state */
5978
	tmp = I915_READ(aud_cntrl_st2);
6482
	tmp = I915_READ(aud_cntrl_st2);
5979
	DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%8x\n", tmp);
6483
	DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%08x\n", tmp);
5980
	tmp |= (AUDIO_ELD_VALID_A << (pipe * 4));
6484
	tmp |= (AUDIO_ELD_VALID_A << (pipe * 4));
5981
	I915_WRITE(aud_cntrl_st2, tmp);
6485
	I915_WRITE(aud_cntrl_st2, tmp);
5982
	tmp = I915_READ(aud_cntrl_st2);
6486
	tmp = I915_READ(aud_cntrl_st2);
Line 5983... Line 6487...
5983
	DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%8x\n", tmp);
6487
	DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%08x\n", tmp);
5984
 
6488
 
5985
	/* Enable HDMI mode */
6489
	/* Enable HDMI mode */
5986
	tmp = I915_READ(aud_config);
6490
	tmp = I915_READ(aud_config);
5987
	DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%8x\n", tmp);
6491
	DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%08x\n", tmp);
5988
	/* clear N_programing_enable and N_value_index */
6492
	/* clear N_programing_enable and N_value_index */
Line 5989... Line 6493...
5989
	tmp &= ~(AUD_CONFIG_N_VALUE_INDEX | AUD_CONFIG_N_PROG_ENABLE);
6493
	tmp &= ~(AUD_CONFIG_N_VALUE_INDEX | AUD_CONFIG_N_PROG_ENABLE);
Line 6066... Line 6570...
6066
		/* operate blindly on all ports */
6570
		/* operate blindly on all ports */
6067
		eldv = IBX_ELD_VALIDB;
6571
		eldv = IBX_ELD_VALIDB;
6068
		eldv |= IBX_ELD_VALIDB << 4;
6572
		eldv |= IBX_ELD_VALIDB << 4;
6069
		eldv |= IBX_ELD_VALIDB << 8;
6573
		eldv |= IBX_ELD_VALIDB << 8;
6070
	} else {
6574
	} else {
6071
		DRM_DEBUG_DRIVER("ELD on port %c\n", 'A' + i);
6575
		DRM_DEBUG_DRIVER("ELD on port %c\n", port_name(i));
6072
		eldv = IBX_ELD_VALIDB << ((i - 1) * 4);
6576
		eldv = IBX_ELD_VALIDB << ((i - 1) * 4);
6073
	}
6577
	}
Line 6074... Line 6578...
6074
 
6578
 
6075
	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
6579
	if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) {
Line 6134... Line 6638...
6134
void intel_crtc_load_lut(struct drm_crtc *crtc)
6638
void intel_crtc_load_lut(struct drm_crtc *crtc)
6135
{
6639
{
6136
	struct drm_device *dev = crtc->dev;
6640
	struct drm_device *dev = crtc->dev;
6137
	struct drm_i915_private *dev_priv = dev->dev_private;
6641
	struct drm_i915_private *dev_priv = dev->dev_private;
6138
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6642
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
6643
	enum pipe pipe = intel_crtc->pipe;
6139
	int palreg = PALETTE(intel_crtc->pipe);
6644
	int palreg = PALETTE(pipe);
6140
	int i;
6645
	int i;
-
 
6646
	bool reenable_ips = false;
Line 6141... Line 6647...
6141
 
6647
 
6142
	/* The clocks have to be on to load the palette. */
6648
	/* The clocks have to be on to load the palette. */
6143
	if (!crtc->enabled || !intel_crtc->active)
6649
	if (!crtc->enabled || !intel_crtc->active)
Line -... Line 6650...
-
 
6650
		return;
-
 
6651
 
-
 
6652
	if (!HAS_PCH_SPLIT(dev_priv->dev))
6144
		return;
6653
		assert_pll_enabled(dev_priv, pipe);
6145
 
6654
 
6146
	/* use legacy palette for Ironlake */
6655
	/* use legacy palette for Ironlake */
-
 
6656
	if (HAS_PCH_SPLIT(dev))
-
 
6657
		palreg = LGC_PALETTE(pipe);
-
 
6658
 
-
 
6659
	/* Workaround : Do not read or write the pipe palette/gamma data while
-
 
6660
	 * GAMMA_MODE is configured for split gamma and IPS_CTL has IPS enabled.
-
 
6661
	 */
-
 
6662
	if (intel_crtc->config.ips_enabled &&
-
 
6663
	    ((I915_READ(GAMMA_MODE(pipe)) & GAMMA_MODE_MODE_MASK) ==
-
 
6664
	     GAMMA_MODE_MODE_SPLIT)) {
-
 
6665
		hsw_disable_ips(intel_crtc);
Line 6147... Line 6666...
6147
	if (HAS_PCH_SPLIT(dev))
6666
		reenable_ips = true;
6148
		palreg = LGC_PALETTE(intel_crtc->pipe);
6667
	}
6149
 
6668
 
6150
	for (i = 0; i < 256; i++) {
6669
	for (i = 0; i < 256; i++) {
6151
		I915_WRITE(palreg + 4 * i,
6670
		I915_WRITE(palreg + 4 * i,
6152
			   (intel_crtc->lut_r[i] << 16) |
6671
			   (intel_crtc->lut_r[i] << 16) |
-
 
6672
			   (intel_crtc->lut_g[i] << 8) |
-
 
6673
			   intel_crtc->lut_b[i]);
-
 
6674
	}
6153
			   (intel_crtc->lut_g[i] << 8) |
6675
 
Line 6154... Line 6676...
6154
			   intel_crtc->lut_b[i]);
6676
	if (reenable_ips)
6155
	}
6677
		hsw_enable_ips(intel_crtc);
6156
}
6678
}
Line 6227... Line 6749...
6227
			cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
6749
			cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
6228
		} else {
6750
		} else {
6229
			cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
6751
			cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
6230
			cntl |= CURSOR_MODE_DISABLE;
6752
			cntl |= CURSOR_MODE_DISABLE;
6231
		}
6753
		}
6232
		if (IS_HASWELL(dev))
6754
		if (IS_HASWELL(dev)) {
6233
			cntl |= CURSOR_PIPE_CSC_ENABLE;
6755
			cntl |= CURSOR_PIPE_CSC_ENABLE;
-
 
6756
			cntl &= ~CURSOR_TRICKLE_FEED_DISABLE;
-
 
6757
		}
6234
		I915_WRITE(CURCNTR_IVB(pipe), cntl);
6758
		I915_WRITE(CURCNTR_IVB(pipe), cntl);
Line 6235... Line 6759...
6235
 
6759
 
6236
		intel_crtc->cursor_visible = visible;
6760
		intel_crtc->cursor_visible = visible;
6237
	}
6761
	}
Line 6365... Line 6889...
6365
		if (ret) {
6889
		if (ret) {
6366
			DRM_ERROR("failed to release fence for cursor");
6890
			DRM_ERROR("failed to release fence for cursor");
6367
			goto fail_unpin;
6891
			goto fail_unpin;
6368
		}
6892
		}
Line 6369... Line 6893...
6369
 
6893
 
6370
		addr = obj->gtt_offset;
6894
		addr = i915_gem_obj_ggtt_offset(obj);
6371
	} else {
6895
	} else {
6372
		int align = IS_I830(dev) ? 16 * 1024 : 256;
6896
		int align = IS_I830(dev) ? 16 * 1024 : 256;
6373
		ret = i915_gem_attach_phys_object(dev, obj,
6897
		ret = i915_gem_attach_phys_object(dev, obj,
6374
						  (intel_crtc->pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1,
6898
						  (intel_crtc->pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1,
Line 6387... Line 6911...
6387
	if (intel_crtc->cursor_bo) {
6911
	if (intel_crtc->cursor_bo) {
6388
		if (dev_priv->info->cursor_needs_physical) {
6912
		if (dev_priv->info->cursor_needs_physical) {
6389
			if (intel_crtc->cursor_bo != obj)
6913
			if (intel_crtc->cursor_bo != obj)
6390
				i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
6914
				i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
6391
		} else
6915
		} else
6392
			i915_gem_object_unpin(intel_crtc->cursor_bo);
6916
			i915_gem_object_unpin_from_display_plane(intel_crtc->cursor_bo);
6393
		drm_gem_object_unreference(&intel_crtc->cursor_bo->base);
6917
		drm_gem_object_unreference(&intel_crtc->cursor_bo->base);
6394
	}
6918
	}
Line 6395... Line 6919...
6395
 
6919
 
Line 6396... Line 6920...
6396
	mutex_unlock(&dev->struct_mutex);
6920
	mutex_unlock(&dev->struct_mutex);
6397
 
6921
 
6398
	intel_crtc->cursor_addr = addr;
6922
	intel_crtc->cursor_addr = addr;
6399
	intel_crtc->cursor_bo = obj;
6923
	intel_crtc->cursor_bo = obj;
Line -... Line 6924...
-
 
6924
	intel_crtc->cursor_width = width;
6400
	intel_crtc->cursor_width = width;
6925
	intel_crtc->cursor_height = height;
Line 6401... Line 6926...
6401
	intel_crtc->cursor_height = height;
6926
 
6402
 
6927
	if (intel_crtc->active)
6403
//   intel_crtc_update_cursor(crtc, true);
6928
		intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
6404
 
6929
 
6405
	return 0;
6930
	return 0;
6406
fail_unpin:
6931
fail_unpin:
6407
	i915_gem_object_unpin(obj);
6932
	i915_gem_object_unpin_from_display_plane(obj);
6408
fail_locked:
6933
fail_locked:
Line 6417... Line 6942...
6417
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6942
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Line 6418... Line 6943...
6418
 
6943
 
6419
	intel_crtc->cursor_x = x;
6944
	intel_crtc->cursor_x = x;
Line -... Line 6945...
-
 
6945
	intel_crtc->cursor_y = y;
6420
	intel_crtc->cursor_y = y;
6946
 
Line 6421... Line 6947...
6421
 
6947
	if (intel_crtc->active)
6422
//   intel_crtc_update_cursor(crtc, true);
6948
		intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL);
6423
 
6949
 
Line 6511... Line 7037...
6511
				  int depth, int bpp)
7037
				  int depth, int bpp)
6512
{
7038
{
6513
	struct drm_i915_gem_object *obj;
7039
	struct drm_i915_gem_object *obj;
6514
	struct drm_mode_fb_cmd2 mode_cmd = { 0 };
7040
	struct drm_mode_fb_cmd2 mode_cmd = { 0 };
Line 6515... Line -...
6515
 
-
 
6516
//	obj = i915_gem_alloc_object(dev,
-
 
6517
//				    intel_framebuffer_size_for_mode(mode, bpp));
7041
 
6518
//	if (obj == NULL)
-
 
6519
		return ERR_PTR(-ENOMEM);
-
 
6520
 
-
 
6521
//	mode_cmd.width = mode->hdisplay;
-
 
6522
//	mode_cmd.height = mode->vdisplay;
-
 
6523
//	mode_cmd.depth = depth;
-
 
6524
//	mode_cmd.bpp = bpp;
-
 
6525
//	mode_cmd.pitch = intel_framebuffer_pitch_for_width(mode_cmd.width, bpp);
-
 
6526
 
-
 
6527
//	return intel_framebuffer_create(dev, &mode_cmd, obj);
7042
	return NULL;
Line 6528... Line 7043...
6528
}
7043
}
6529
 
7044
 
6530
static struct drm_framebuffer *
7045
static struct drm_framebuffer *
Line 6693... Line 7208...
6693
 
7208
 
6694
	mutex_unlock(&crtc->mutex);
7209
	mutex_unlock(&crtc->mutex);
Line 6695... Line 7210...
6695
}
7210
}
6696
 
7211
 
-
 
7212
/* Returns the clock of the currently programmed mode of the given pipe. */
6697
/* Returns the clock of the currently programmed mode of the given pipe. */
7213
static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
-
 
7214
				struct intel_crtc_config *pipe_config)
6698
static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
7215
{
6699
{
-
 
6700
	struct drm_i915_private *dev_priv = dev->dev_private;
7216
	struct drm_device *dev = crtc->base.dev;
6701
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7217
	struct drm_i915_private *dev_priv = dev->dev_private;
6702
	int pipe = intel_crtc->pipe;
7218
	int pipe = pipe_config->cpu_transcoder;
6703
	u32 dpll = I915_READ(DPLL(pipe));
7219
	u32 dpll = I915_READ(DPLL(pipe));
Line 6704... Line 7220...
6704
	u32 fp;
7220
	u32 fp;
Line 6736... Line 7252...
6736
				7 : 14;
7252
				7 : 14;
6737
			break;
7253
			break;
6738
		default:
7254
		default:
6739
			DRM_DEBUG_KMS("Unknown DPLL mode %08x in programmed "
7255
			DRM_DEBUG_KMS("Unknown DPLL mode %08x in programmed "
6740
				  "mode\n", (int)(dpll & DPLL_MODE_MASK));
7256
				  "mode\n", (int)(dpll & DPLL_MODE_MASK));
-
 
7257
			pipe_config->adjusted_mode.clock = 0;
6741
			return 0;
7258
			return;
6742
		}
7259
		}
Line -... Line 7260...
-
 
7260
 
6743
 
7261
		if (IS_PINEVIEW(dev))
-
 
7262
			pineview_clock(96000, &clock);
6744
		/* XXX: Handle the 100Mhz refclk */
7263
		else
6745
		intel_clock(dev, 96000, &clock);
7264
			i9xx_clock(96000, &clock);
6746
	} else {
7265
	} else {
Line 6747... Line 7266...
6747
		bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN);
7266
		bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN);
6748
 
7267
 
Line 6752... Line 7271...
6752
			clock.p2 = 14;
7271
			clock.p2 = 14;
Line 6753... Line 7272...
6753
 
7272
 
6754
			if ((dpll & PLL_REF_INPUT_MASK) ==
7273
			if ((dpll & PLL_REF_INPUT_MASK) ==
6755
			    PLLB_REF_INPUT_SPREADSPECTRUMIN) {
7274
			    PLLB_REF_INPUT_SPREADSPECTRUMIN) {
6756
				/* XXX: might not be 66MHz */
7275
				/* XXX: might not be 66MHz */
6757
				intel_clock(dev, 66000, &clock);
7276
				i9xx_clock(66000, &clock);
6758
			} else
7277
			} else
6759
				intel_clock(dev, 48000, &clock);
7278
				i9xx_clock(48000, &clock);
6760
		} else {
7279
		} else {
6761
			if (dpll & PLL_P1_DIVIDE_BY_TWO)
7280
			if (dpll & PLL_P1_DIVIDE_BY_TWO)
6762
				clock.p1 = 2;
7281
				clock.p1 = 2;
6763
			else {
7282
			else {
Line 6767... Line 7286...
6767
			if (dpll & PLL_P2_DIVIDE_BY_4)
7286
			if (dpll & PLL_P2_DIVIDE_BY_4)
6768
				clock.p2 = 4;
7287
				clock.p2 = 4;
6769
			else
7288
			else
6770
				clock.p2 = 2;
7289
				clock.p2 = 2;
Line 6771... Line 7290...
6771
 
7290
 
6772
			intel_clock(dev, 48000, &clock);
7291
			i9xx_clock(48000, &clock);
6773
		}
7292
		}
Line -... Line 7293...
-
 
7293
	}
-
 
7294
 
-
 
7295
	pipe_config->adjusted_mode.clock = clock.dot;
6774
	}
7296
}
-
 
7297
 
-
 
7298
static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
-
 
7299
				    struct intel_crtc_config *pipe_config)
-
 
7300
{
6775
 
7301
	struct drm_device *dev = crtc->base.dev;
-
 
7302
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
7303
	enum transcoder cpu_transcoder = pipe_config->cpu_transcoder;
-
 
7304
	int link_freq, repeat;
-
 
7305
	u64 clock;
-
 
7306
	u32 link_m, link_n;
-
 
7307
 
-
 
7308
	repeat = pipe_config->pixel_multiplier;
-
 
7309
 
-
 
7310
	/*
6776
	/* XXX: It would be nice to validate the clocks, but we can't reuse
7311
	 * The calculation for the data clock is:
-
 
7312
	 * pixel_clock = ((m/n)*(link_clock * nr_lanes * repeat))/bpp
-
 
7313
	 * But we want to avoid losing precison if possible, so:
-
 
7314
	 * pixel_clock = ((m * link_clock * nr_lanes * repeat)/(n*bpp))
-
 
7315
	 *
6777
	 * i830PllIsValid() because it relies on the xf86_config connector
7316
	 * and the link clock is simpler:
Line -... Line 7317...
-
 
7317
	 * link_clock = (m * link_clock * repeat) / n
-
 
7318
	 */
-
 
7319
 
-
 
7320
	/*
-
 
7321
	 * We need to get the FDI or DP link clock here to derive
-
 
7322
	 * the M/N dividers.
-
 
7323
	 *
-
 
7324
	 * For FDI, we read it from the BIOS or use a fixed 2.7GHz.
-
 
7325
	 * For DP, it's either 1.62GHz or 2.7GHz.
-
 
7326
	 * We do our calculations in 10*MHz since we don't need much precison.
-
 
7327
	 */
-
 
7328
	if (pipe_config->has_pch_encoder)
-
 
7329
		link_freq = intel_fdi_link_freq(dev) * 10000;
-
 
7330
	else
-
 
7331
		link_freq = pipe_config->port_clock;
-
 
7332
 
-
 
7333
	link_m = I915_READ(PIPE_LINK_M1(cpu_transcoder));
6778
	 * configuration being accurate, which it isn't necessarily.
7334
	link_n = I915_READ(PIPE_LINK_N1(cpu_transcoder));
-
 
7335
 
-
 
7336
	if (!link_m || !link_n)
-
 
7337
		return;
-
 
7338
 
-
 
7339
	clock = ((u64)link_m * (u64)link_freq * (u64)repeat);
6779
	 */
7340
	do_div(clock, link_n);
Line 6780... Line 7341...
6780
 
7341
 
6781
	return clock.dot;
7342
	pipe_config->adjusted_mode.clock = clock;
6782
}
7343
}
6783
 
7344
 
6784
/** Returns the currently programmed mode of the given pipe. */
7345
/** Returns the currently programmed mode of the given pipe. */
6785
struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
7346
struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
6786
					     struct drm_crtc *crtc)
7347
					     struct drm_crtc *crtc)
6787
{
7348
{
-
 
7349
	struct drm_i915_private *dev_priv = dev->dev_private;
6788
	struct drm_i915_private *dev_priv = dev->dev_private;
7350
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6789
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7351
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
6790
	enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
7352
	struct drm_display_mode *mode;
6791
	struct drm_display_mode *mode;
7353
	struct intel_crtc_config pipe_config;
Line 6792... Line 7354...
6792
	int htot = I915_READ(HTOTAL(cpu_transcoder));
7354
	int htot = I915_READ(HTOTAL(cpu_transcoder));
6793
	int hsync = I915_READ(HSYNC(cpu_transcoder));
7355
	int hsync = I915_READ(HSYNC(cpu_transcoder));
6794
	int vtot = I915_READ(VTOTAL(cpu_transcoder));
7356
	int vtot = I915_READ(VTOTAL(cpu_transcoder));
Line -... Line 7357...
-
 
7357
	int vsync = I915_READ(VSYNC(cpu_transcoder));
-
 
7358
 
-
 
7359
	mode = kzalloc(sizeof(*mode), GFP_KERNEL);
-
 
7360
	if (!mode)
-
 
7361
		return NULL;
-
 
7362
 
-
 
7363
	/*
-
 
7364
	 * Construct a pipe_config sufficient for getting the clock info
-
 
7365
	 * back out of crtc_clock_get.
-
 
7366
	 *
-
 
7367
	 * Note, if LVDS ever uses a non-1 pixel multiplier, we'll need
6795
	int vsync = I915_READ(VSYNC(cpu_transcoder));
7368
	 * to use a real value here instead.
6796
 
7369
	 */
6797
	mode = kzalloc(sizeof(*mode), GFP_KERNEL);
7370
	pipe_config.cpu_transcoder = (enum transcoder) intel_crtc->pipe;
6798
	if (!mode)
7371
	pipe_config.pixel_multiplier = 1;
6799
		return NULL;
7372
	i9xx_crtc_clock_get(intel_crtc, &pipe_config);
6800
 
7373
 
Line 6880... Line 7453...
6880
 
7453
 
Line 6881... Line 7454...
6881
}
7454
}
6882
 
7455
 
-
 
7456
void intel_mark_busy(struct drm_device *dev)
-
 
7457
{
-
 
7458
	struct drm_i915_private *dev_priv = dev->dev_private;
6883
void intel_mark_busy(struct drm_device *dev)
7459
 
6884
{
7460
	hsw_package_c8_gpu_busy(dev_priv);
Line 6885... Line 7461...
6885
	i915_update_gfx_val(dev->dev_private);
7461
	i915_update_gfx_val(dev_priv);
6886
}
7462
}
-
 
7463
 
6887
 
7464
void intel_mark_idle(struct drm_device *dev)
Line -... Line 7465...
-
 
7465
{
-
 
7466
	struct drm_i915_private *dev_priv = dev->dev_private;
6888
void intel_mark_idle(struct drm_device *dev)
7467
	struct drm_crtc *crtc;
6889
{
7468
 
Line 6890... Line 7469...
6890
	struct drm_crtc *crtc;
7469
	hsw_package_c8_gpu_idle(dev_priv);
6891
 
7470
 
Line 6898... Line 7477...
6898
 
7477
 
6899
		intel_decrease_pllclock(crtc);
7478
		intel_decrease_pllclock(crtc);
6900
	}
7479
	}
Line 6901... Line 7480...
6901
}
7480
}
-
 
7481
 
6902
 
7482
void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
6903
void intel_mark_fb_busy(struct drm_i915_gem_object *obj)
7483
			struct intel_ring_buffer *ring)
6904
{
7484
{
Line 6905... Line 7485...
6905
	struct drm_device *dev = obj->base.dev;
7485
	struct drm_device *dev = obj->base.dev;
Line 6910... Line 7490...
6910
 
7490
 
6911
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
7491
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
6912
		if (!crtc->fb)
7492
		if (!crtc->fb)
Line 6913... Line 7493...
6913
			continue;
7493
			continue;
-
 
7494
 
-
 
7495
		if (to_intel_framebuffer(crtc->fb)->obj != obj)
6914
 
7496
			continue;
-
 
7497
 
-
 
7498
			intel_increase_pllclock(crtc);
6915
		if (to_intel_framebuffer(crtc->fb)->obj == obj)
7499
		if (ring && intel_fbc_enabled(dev))
6916
			intel_increase_pllclock(crtc);
7500
			ring->fbc_dirty = true;
Line 6917... Line 7501...
6917
	}
7501
	}
6918
}
7502
}
Line 7045... Line 7629...
7045
}
7629
}
Line 7046... Line 7630...
7046
 
7630
 
7047
static int intel_gen2_queue_flip(struct drm_device *dev,
7631
static int intel_gen2_queue_flip(struct drm_device *dev,
7048
				 struct drm_crtc *crtc,
7632
				 struct drm_crtc *crtc,
7049
				 struct drm_framebuffer *fb,
7633
				 struct drm_framebuffer *fb,
-
 
7634
				 struct drm_i915_gem_object *obj,
7050
				 struct drm_i915_gem_object *obj)
7635
				 uint32_t flags)
7051
{
7636
{
7052
	struct drm_i915_private *dev_priv = dev->dev_private;
7637
	struct drm_i915_private *dev_priv = dev->dev_private;
7053
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7638
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7054
	u32 flip_mask;
7639
	u32 flip_mask;
Line 7073... Line 7658...
7073
	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | flip_mask);
7658
	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | flip_mask);
7074
	intel_ring_emit(ring, MI_NOOP);
7659
	intel_ring_emit(ring, MI_NOOP);
7075
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7660
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7076
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7661
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7077
	intel_ring_emit(ring, fb->pitches[0]);
7662
	intel_ring_emit(ring, fb->pitches[0]);
7078
	intel_ring_emit(ring, obj->gtt_offset + intel_crtc->dspaddr_offset);
7663
	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
7079
	intel_ring_emit(ring, 0); /* aux display base address, unused */
7664
	intel_ring_emit(ring, 0); /* aux display base address, unused */
Line 7080... Line 7665...
7080
 
7665
 
7081
	intel_mark_page_flip_active(intel_crtc);
7666
	intel_mark_page_flip_active(intel_crtc);
7082
	intel_ring_advance(ring);
7667
	intel_ring_advance(ring);
Line 7089... Line 7674...
7089
}
7674
}
Line 7090... Line 7675...
7090
 
7675
 
7091
static int intel_gen3_queue_flip(struct drm_device *dev,
7676
static int intel_gen3_queue_flip(struct drm_device *dev,
7092
				 struct drm_crtc *crtc,
7677
				 struct drm_crtc *crtc,
7093
				 struct drm_framebuffer *fb,
7678
				 struct drm_framebuffer *fb,
-
 
7679
				 struct drm_i915_gem_object *obj,
7094
				 struct drm_i915_gem_object *obj)
7680
				 uint32_t flags)
7095
{
7681
{
7096
	struct drm_i915_private *dev_priv = dev->dev_private;
7682
	struct drm_i915_private *dev_priv = dev->dev_private;
7097
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7683
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7098
	u32 flip_mask;
7684
	u32 flip_mask;
Line 7114... Line 7700...
7114
	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | flip_mask);
7700
	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | flip_mask);
7115
	intel_ring_emit(ring, MI_NOOP);
7701
	intel_ring_emit(ring, MI_NOOP);
7116
	intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 |
7702
	intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 |
7117
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7703
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7118
	intel_ring_emit(ring, fb->pitches[0]);
7704
	intel_ring_emit(ring, fb->pitches[0]);
7119
	intel_ring_emit(ring, obj->gtt_offset + intel_crtc->dspaddr_offset);
7705
	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
7120
	intel_ring_emit(ring, MI_NOOP);
7706
	intel_ring_emit(ring, MI_NOOP);
Line 7121... Line 7707...
7121
 
7707
 
7122
	intel_mark_page_flip_active(intel_crtc);
7708
	intel_mark_page_flip_active(intel_crtc);
7123
	intel_ring_advance(ring);
7709
	intel_ring_advance(ring);
Line 7130... Line 7716...
7130
}
7716
}
Line 7131... Line 7717...
7131
 
7717
 
7132
static int intel_gen4_queue_flip(struct drm_device *dev,
7718
static int intel_gen4_queue_flip(struct drm_device *dev,
7133
				 struct drm_crtc *crtc,
7719
				 struct drm_crtc *crtc,
7134
				 struct drm_framebuffer *fb,
7720
				 struct drm_framebuffer *fb,
-
 
7721
				 struct drm_i915_gem_object *obj,
7135
				 struct drm_i915_gem_object *obj)
7722
				 uint32_t flags)
7136
{
7723
{
7137
	struct drm_i915_private *dev_priv = dev->dev_private;
7724
	struct drm_i915_private *dev_priv = dev->dev_private;
7138
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7725
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7139
	uint32_t pf, pipesrc;
7726
	uint32_t pf, pipesrc;
Line 7154... Line 7741...
7154
	 */
7741
	 */
7155
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7742
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7156
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7743
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7157
	intel_ring_emit(ring, fb->pitches[0]);
7744
	intel_ring_emit(ring, fb->pitches[0]);
7158
	intel_ring_emit(ring,
7745
	intel_ring_emit(ring,
7159
			(obj->gtt_offset + intel_crtc->dspaddr_offset) |
7746
			(i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset) |
7160
			obj->tiling_mode);
7747
			obj->tiling_mode);
Line 7161... Line 7748...
7161
 
7748
 
7162
	/* XXX Enabling the panel-fitter across page-flip is so far
7749
	/* XXX Enabling the panel-fitter across page-flip is so far
7163
	 * untested on non-native modes, so ignore it for now.
7750
	 * untested on non-native modes, so ignore it for now.
Line 7178... Line 7765...
7178
}
7765
}
Line 7179... Line 7766...
7179
 
7766
 
7180
static int intel_gen6_queue_flip(struct drm_device *dev,
7767
static int intel_gen6_queue_flip(struct drm_device *dev,
7181
				 struct drm_crtc *crtc,
7768
				 struct drm_crtc *crtc,
7182
				 struct drm_framebuffer *fb,
7769
				 struct drm_framebuffer *fb,
-
 
7770
				 struct drm_i915_gem_object *obj,
7183
				 struct drm_i915_gem_object *obj)
7771
				 uint32_t flags)
7184
{
7772
{
7185
	struct drm_i915_private *dev_priv = dev->dev_private;
7773
	struct drm_i915_private *dev_priv = dev->dev_private;
7186
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7774
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7187
	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
7775
	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
Line 7197... Line 7785...
7197
		goto err_unpin;
7785
		goto err_unpin;
Line 7198... Line 7786...
7198
 
7786
 
7199
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7787
	intel_ring_emit(ring, MI_DISPLAY_FLIP |
7200
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7788
			MI_DISPLAY_FLIP_PLANE(intel_crtc->plane));
7201
	intel_ring_emit(ring, fb->pitches[0] | obj->tiling_mode);
7789
	intel_ring_emit(ring, fb->pitches[0] | obj->tiling_mode);
Line 7202... Line 7790...
7202
	intel_ring_emit(ring, obj->gtt_offset + intel_crtc->dspaddr_offset);
7790
	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
7203
 
7791
 
7204
	/* Contrary to the suggestions in the documentation,
7792
	/* Contrary to the suggestions in the documentation,
7205
	 * "Enable Panel Fitter" does not seem to be required when page
7793
	 * "Enable Panel Fitter" does not seem to be required when page
Line 7219... Line 7807...
7219
	intel_unpin_fb_obj(obj);
7807
	intel_unpin_fb_obj(obj);
7220
err:
7808
err:
7221
	return ret;
7809
	return ret;
7222
}
7810
}
Line 7223... Line -...
7223
 
-
 
7224
/*
-
 
7225
 * On gen7 we currently use the blit ring because (in early silicon at least)
-
 
7226
 * the render ring doesn't give us interrpts for page flip completion, which
-
 
7227
 * means clients will hang after the first flip is queued.  Fortunately the
-
 
7228
 * blit ring generates interrupts properly, so use it instead.
-
 
7229
 */
7811
 
7230
static int intel_gen7_queue_flip(struct drm_device *dev,
7812
static int intel_gen7_queue_flip(struct drm_device *dev,
7231
				 struct drm_crtc *crtc,
7813
				 struct drm_crtc *crtc,
7232
				 struct drm_framebuffer *fb,
7814
				 struct drm_framebuffer *fb,
-
 
7815
				 struct drm_i915_gem_object *obj,
7233
				 struct drm_i915_gem_object *obj)
7816
				 uint32_t flags)
7234
{
7817
{
7235
	struct drm_i915_private *dev_priv = dev->dev_private;
7818
	struct drm_i915_private *dev_priv = dev->dev_private;
7236
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7819
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
7237
	struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
7820
	struct intel_ring_buffer *ring;
7238
	uint32_t plane_bit = 0;
7821
	uint32_t plane_bit = 0;
-
 
7822
	int len, ret;
-
 
7823
 
-
 
7824
	ring = obj->ring;
-
 
7825
	if (IS_VALLEYVIEW(dev) || ring == NULL || ring->id != RCS)
Line 7239... Line 7826...
7239
	int ret;
7826
		ring = &dev_priv->ring[BCS];
7240
 
7827
 
7241
	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
7828
	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
Line 7256... Line 7843...
7256
		WARN_ONCE(1, "unknown plane in flip command\n");
7843
		WARN_ONCE(1, "unknown plane in flip command\n");
7257
		ret = -ENODEV;
7844
		ret = -ENODEV;
7258
		goto err_unpin;
7845
		goto err_unpin;
7259
	}
7846
	}
Line -... Line 7847...
-
 
7847
 
-
 
7848
	len = 4;
-
 
7849
	if (ring->id == RCS)
-
 
7850
		len += 6;
7260
 
7851
 
7261
	ret = intel_ring_begin(ring, 4);
7852
	ret = intel_ring_begin(ring, len);
7262
	if (ret)
7853
	if (ret)
Line -... Line 7854...
-
 
7854
		goto err_unpin;
-
 
7855
 
-
 
7856
	/* Unmask the flip-done completion message. Note that the bspec says that
-
 
7857
	 * we should do this for both the BCS and RCS, and that we must not unmask
-
 
7858
	 * more than one flip event at any time (or ensure that one flip message
-
 
7859
	 * can be sent by waiting for flip-done prior to queueing new flips).
-
 
7860
	 * Experimentation says that BCS works despite DERRMR masking all
-
 
7861
	 * flip-done completion events and that unmasking all planes at once
-
 
7862
	 * for the RCS also doesn't appear to drop events. Setting the DERRMR
-
 
7863
	 * to zero does lead to lockups within MI_DISPLAY_FLIP.
-
 
7864
	 */
-
 
7865
	if (ring->id == RCS) {
-
 
7866
		intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-
 
7867
		intel_ring_emit(ring, DERRMR);
-
 
7868
		intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
-
 
7869
					DERRMR_PIPEB_PRI_FLIP_DONE |
-
 
7870
					DERRMR_PIPEC_PRI_FLIP_DONE));
-
 
7871
		intel_ring_emit(ring, MI_STORE_REGISTER_MEM(1));
-
 
7872
		intel_ring_emit(ring, DERRMR);
-
 
7873
		intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
7263
		goto err_unpin;
7874
	}
7264
 
7875
 
7265
	intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane_bit);
7876
	intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane_bit);
7266
	intel_ring_emit(ring, (fb->pitches[0] | obj->tiling_mode));
7877
	intel_ring_emit(ring, (fb->pitches[0] | obj->tiling_mode));
Line 7267... Line 7878...
7267
	intel_ring_emit(ring, obj->gtt_offset + intel_crtc->dspaddr_offset);
7878
	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset);
7268
	intel_ring_emit(ring, (MI_NOOP));
7879
	intel_ring_emit(ring, (MI_NOOP));
7269
 
7880
 
Line 7278... Line 7889...
7278
}
7889
}
Line 7279... Line 7890...
7279
 
7890
 
7280
static int intel_default_queue_flip(struct drm_device *dev,
7891
static int intel_default_queue_flip(struct drm_device *dev,
7281
				    struct drm_crtc *crtc,
7892
				    struct drm_crtc *crtc,
7282
				    struct drm_framebuffer *fb,
7893
				    struct drm_framebuffer *fb,
-
 
7894
				    struct drm_i915_gem_object *obj,
7283
				    struct drm_i915_gem_object *obj)
7895
				    uint32_t flags)
7284
{
7896
{
7285
	return -ENODEV;
7897
	return -ENODEV;
Line 7286... Line 7898...
7286
}
7898
}
7287
 
7899
 
7288
static int intel_crtc_page_flip(struct drm_crtc *crtc,
7900
static int intel_crtc_page_flip(struct drm_crtc *crtc,
-
 
7901
				struct drm_framebuffer *fb,
7289
				struct drm_framebuffer *fb,
7902
				struct drm_pending_vblank_event *event,
7290
				struct drm_pending_vblank_event *event)
7903
				uint32_t page_flip_flags)
7291
{
7904
{
7292
	struct drm_device *dev = crtc->dev;
7905
	struct drm_device *dev = crtc->dev;
7293
	struct drm_i915_private *dev_priv = dev->dev_private;
7906
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 7355... Line 7968...
7355
	work->enable_stall_check = true;
7968
	work->enable_stall_check = true;
Line 7356... Line 7969...
7356
 
7969
 
7357
	atomic_inc(&intel_crtc->unpin_work_count);
7970
	atomic_inc(&intel_crtc->unpin_work_count);
Line 7358... Line 7971...
7358
	intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
7971
	intel_crtc->reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
7359
 
7972
 
7360
	ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
7973
	ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, page_flip_flags);
Line 7361... Line 7974...
7361
	if (ret)
7974
	if (ret)
7362
		goto cleanup_pending;
7975
		goto cleanup_pending;
7363
 
7976
 
Line 7364... Line 7977...
7364
	intel_disable_fbc(dev);
7977
	intel_disable_fbc(dev);
Line 7365... Line 7978...
7365
	intel_mark_fb_busy(obj);
7978
	intel_mark_fb_busy(obj, NULL);
Line 7385... Line 7998...
7385
free_work:
7998
free_work:
7386
	kfree(work);
7999
	kfree(work);
Line 7387... Line 8000...
7387
 
8000
 
7388
	return ret;
8001
	return ret;
7389
}
-
 
7390
 
8002
}
Line 7391... Line 8003...
7391
#endif
8003
#endif
7392
 
8004
 
7393
static struct drm_crtc_helper_funcs intel_helper_funcs = {
8005
static struct drm_crtc_helper_funcs intel_helper_funcs = {
7394
	.mode_set_base_atomic = intel_pipe_set_base_atomic,
8006
	.mode_set_base_atomic = intel_pipe_set_base_atomic,
Line 7395... Line -...
7395
	.load_lut = intel_crtc_load_lut,
-
 
7396
};
-
 
7397
 
-
 
7398
bool intel_encoder_check_is_cloned(struct intel_encoder *encoder)
-
 
7399
{
-
 
7400
	struct intel_encoder *other_encoder;
-
 
7401
	struct drm_crtc *crtc = &encoder->new_crtc->base;
-
 
7402
 
-
 
7403
	if (WARN_ON(!crtc))
-
 
7404
		return false;
-
 
7405
 
-
 
7406
	list_for_each_entry(other_encoder,
-
 
7407
			    &crtc->dev->mode_config.encoder_list,
-
 
7408
			    base.head) {
-
 
7409
 
-
 
7410
		if (&other_encoder->new_crtc->base != crtc ||
-
 
7411
		    encoder == other_encoder)
-
 
7412
			continue;
-
 
7413
		else
-
 
7414
			return true;
-
 
7415
	}
-
 
7416
 
-
 
7417
	return false;
8007
	.load_lut = intel_crtc_load_lut,
7418
}
8008
};
7419
 
8009
 
7420
static bool intel_encoder_crtc_ok(struct drm_encoder *encoder,
8010
static bool intel_encoder_crtc_ok(struct drm_encoder *encoder,
7421
				  struct drm_crtc *crtc)
8011
				  struct drm_crtc *crtc)
Line 7482... Line 8072...
7482
			    base.head) {
8072
			    base.head) {
7483
		encoder->base.crtc = &encoder->new_crtc->base;
8073
		encoder->base.crtc = &encoder->new_crtc->base;
7484
	}
8074
	}
7485
}
8075
}
Line -... Line 8076...
-
 
8076
 
-
 
8077
static void
-
 
8078
connected_sink_compute_bpp(struct intel_connector * connector,
-
 
8079
			   struct intel_crtc_config *pipe_config)
-
 
8080
{
-
 
8081
	int bpp = pipe_config->pipe_bpp;
-
 
8082
 
-
 
8083
	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] checking for sink bpp constrains\n",
-
 
8084
		connector->base.base.id,
-
 
8085
		drm_get_connector_name(&connector->base));
-
 
8086
 
-
 
8087
	/* Don't use an invalid EDID bpc value */
-
 
8088
	if (connector->base.display_info.bpc &&
-
 
8089
	    connector->base.display_info.bpc * 3 < bpp) {
-
 
8090
		DRM_DEBUG_KMS("clamping display bpp (was %d) to EDID reported max of %d\n",
-
 
8091
			      bpp, connector->base.display_info.bpc*3);
-
 
8092
		pipe_config->pipe_bpp = connector->base.display_info.bpc*3;
-
 
8093
	}
-
 
8094
 
-
 
8095
	/* Clamp bpp to 8 on screens without EDID 1.4 */
-
 
8096
	if (connector->base.display_info.bpc == 0 && bpp > 24) {
-
 
8097
		DRM_DEBUG_KMS("clamping display bpp (was %d) to default limit of 24\n",
-
 
8098
			      bpp);
-
 
8099
		pipe_config->pipe_bpp = 24;
-
 
8100
	}
-
 
8101
}
7486
 
8102
 
7487
static int
8103
static int
7488
pipe_config_set_bpp(struct drm_crtc *crtc,
8104
compute_baseline_pipe_bpp(struct intel_crtc *crtc,
7489
		    struct drm_framebuffer *fb,
8105
		    struct drm_framebuffer *fb,
7490
		    struct intel_crtc_config *pipe_config)
8106
		    struct intel_crtc_config *pipe_config)
7491
{
8107
{
7492
	struct drm_device *dev = crtc->dev;
8108
	struct drm_device *dev = crtc->base.dev;
7493
	struct drm_connector *connector;
8109
	struct intel_connector *connector;
Line 7494... Line 8110...
7494
	int bpp;
8110
	int bpp;
7495
 
8111
 
7496
	switch (fb->pixel_format) {
8112
	switch (fb->pixel_format) {
Line 7531... Line 8147...
7531
 
8147
 
Line 7532... Line 8148...
7532
	pipe_config->pipe_bpp = bpp;
8148
	pipe_config->pipe_bpp = bpp;
7533
 
8149
 
7534
	/* Clamp display bpp to EDID value */
8150
	/* Clamp display bpp to EDID value */
-
 
8151
	list_for_each_entry(connector, &dev->mode_config.connector_list,
7535
	list_for_each_entry(connector, &dev->mode_config.connector_list,
8152
			    base.head) {
7536
			    head) {
8153
		if (!connector->new_encoder ||
Line 7537... Line -...
7537
		if (connector->encoder && connector->encoder->crtc != crtc)
-
 
7538
			continue;
-
 
7539
 
-
 
7540
		/* Don't use an invalid EDID bpc value */
-
 
7541
		if (connector->display_info.bpc &&
-
 
7542
		    connector->display_info.bpc * 3 < bpp) {
8154
		    connector->new_encoder->new_crtc != crtc)
7543
			DRM_DEBUG_KMS("clamping display bpp (was %d) to EDID reported max of %d\n",
-
 
7544
				      bpp, connector->display_info.bpc*3);
8155
			continue;
Line 7545... Line 8156...
7545
			pipe_config->pipe_bpp = connector->display_info.bpc*3;
8156
 
7546
		}
8157
		connected_sink_compute_bpp(connector, pipe_config);
Line -... Line 8158...
-
 
8158
	}
-
 
8159
 
-
 
8160
	return bpp;
-
 
8161
}
-
 
8162
 
-
 
8163
static void intel_dump_pipe_config(struct intel_crtc *crtc,
-
 
8164
				   struct intel_crtc_config *pipe_config,
-
 
8165
				   const char *context)
-
 
8166
{
-
 
8167
	DRM_DEBUG_KMS("[CRTC:%d]%s config for pipe %c\n", crtc->base.base.id,
-
 
8168
		      context, pipe_name(crtc->pipe));
-
 
8169
 
-
 
8170
	DRM_DEBUG_KMS("cpu_transcoder: %c\n", transcoder_name(pipe_config->cpu_transcoder));
-
 
8171
	DRM_DEBUG_KMS("pipe bpp: %i, dithering: %i\n",
-
 
8172
		      pipe_config->pipe_bpp, pipe_config->dither);
-
 
8173
	DRM_DEBUG_KMS("fdi/pch: %i, lanes: %i, gmch_m: %u, gmch_n: %u, link_m: %u, link_n: %u, tu: %u\n",
-
 
8174
		      pipe_config->has_pch_encoder,
-
 
8175
		      pipe_config->fdi_lanes,
-
 
8176
		      pipe_config->fdi_m_n.gmch_m, pipe_config->fdi_m_n.gmch_n,
-
 
8177
		      pipe_config->fdi_m_n.link_m, pipe_config->fdi_m_n.link_n,
-
 
8178
		      pipe_config->fdi_m_n.tu);
-
 
8179
	DRM_DEBUG_KMS("requested mode:\n");
-
 
8180
	drm_mode_debug_printmodeline(&pipe_config->requested_mode);
-
 
8181
	DRM_DEBUG_KMS("adjusted mode:\n");
-
 
8182
	drm_mode_debug_printmodeline(&pipe_config->adjusted_mode);
-
 
8183
	DRM_DEBUG_KMS("gmch pfit: control: 0x%08x, ratios: 0x%08x, lvds border: 0x%08x\n",
-
 
8184
		      pipe_config->gmch_pfit.control,
-
 
8185
		      pipe_config->gmch_pfit.pgm_ratios,
-
 
8186
		      pipe_config->gmch_pfit.lvds_border_bits);
-
 
8187
	DRM_DEBUG_KMS("pch pfit: pos: 0x%08x, size: 0x%08x, %s\n",
-
 
8188
		      pipe_config->pch_pfit.pos,
-
 
8189
		      pipe_config->pch_pfit.size,
-
 
8190
		      pipe_config->pch_pfit.enabled ? "enabled" : "disabled");
-
 
8191
	DRM_DEBUG_KMS("ips: %i\n", pipe_config->ips_enabled);
-
 
8192
}
-
 
8193
 
-
 
8194
static bool check_encoder_cloning(struct drm_crtc *crtc)
-
 
8195
{
-
 
8196
	int num_encoders = 0;
-
 
8197
	bool uncloneable_encoders = false;
-
 
8198
	struct intel_encoder *encoder;
-
 
8199
 
-
 
8200
	list_for_each_entry(encoder, &crtc->dev->mode_config.encoder_list,
-
 
8201
			    base.head) {
-
 
8202
		if (&encoder->new_crtc->base != crtc)
-
 
8203
			continue;
-
 
8204
 
-
 
8205
		num_encoders++;
-
 
8206
		if (!encoder->cloneable)
-
 
8207
			uncloneable_encoders = true;
7547
	}
8208
	}
7548
 
8209
 
7549
	return bpp;
8210
	return !(num_encoders > 1 && uncloneable_encoders);
7550
}
8211
}
7551
 
8212
 
7552
static struct intel_crtc_config *
8213
static struct intel_crtc_config *
7553
intel_modeset_pipe_config(struct drm_crtc *crtc,
-
 
7554
			  struct drm_framebuffer *fb,
8214
intel_modeset_pipe_config(struct drm_crtc *crtc,
7555
			    struct drm_display_mode *mode)
8215
			  struct drm_framebuffer *fb,
7556
{
8216
			    struct drm_display_mode *mode)
-
 
8217
{
-
 
8218
	struct drm_device *dev = crtc->dev;
-
 
8219
	struct intel_encoder *encoder;
-
 
8220
	struct intel_crtc_config *pipe_config;
-
 
8221
	int plane_bpp, ret = -EINVAL;
-
 
8222
	bool retry = true;
Line 7557... Line 8223...
7557
	struct drm_device *dev = crtc->dev;
8223
 
7558
	struct drm_encoder_helper_funcs *encoder_funcs;
8224
	if (!check_encoder_cloning(crtc)) {
7559
	struct intel_encoder *encoder;
8225
		DRM_DEBUG_KMS("rejecting invalid cloning configuration\n");
Line 7560... Line 8226...
7560
	struct intel_crtc_config *pipe_config;
8226
		return ERR_PTR(-EINVAL);
7561
	int plane_bpp;
8227
	}
-
 
8228
 
-
 
8229
	pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL);
-
 
8230
	if (!pipe_config)
Line -... Line 8231...
-
 
8231
		return ERR_PTR(-ENOMEM);
-
 
8232
 
-
 
8233
	drm_mode_copy(&pipe_config->adjusted_mode, mode);
-
 
8234
	drm_mode_copy(&pipe_config->requested_mode, mode);
-
 
8235
	pipe_config->cpu_transcoder =
-
 
8236
		(enum transcoder) to_intel_crtc(crtc)->pipe;
-
 
8237
	pipe_config->shared_dpll = DPLL_ID_PRIVATE;
-
 
8238
 
-
 
8239
	/*
-
 
8240
	 * Sanitize sync polarity flags based on requested ones. If neither
-
 
8241
	 * positive or negative polarity is requested, treat this as meaning
-
 
8242
	 * negative polarity.
-
 
8243
	 */
-
 
8244
	if (!(pipe_config->adjusted_mode.flags &
-
 
8245
	      (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC)))
-
 
8246
		pipe_config->adjusted_mode.flags |= DRM_MODE_FLAG_NHSYNC;
-
 
8247
 
7562
 
8248
	if (!(pipe_config->adjusted_mode.flags &
-
 
8249
	      (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
7563
	pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL);
8250
		pipe_config->adjusted_mode.flags |= DRM_MODE_FLAG_NVSYNC;
7564
	if (!pipe_config)
8251
 
Line -... Line 8252...
-
 
8252
	/* Compute a starting value for pipe_config->pipe_bpp taking the source
-
 
8253
	 * plane pixel format and any sink constraints into account. Returns the
-
 
8254
	 * source plane bpp so that dithering can be selected on mismatches
-
 
8255
	 * after encoders and crtc also have had their say. */
-
 
8256
	plane_bpp = compute_baseline_pipe_bpp(to_intel_crtc(crtc),
-
 
8257
					      fb, pipe_config);
-
 
8258
	if (plane_bpp < 0)
-
 
8259
		goto fail;
7565
		return ERR_PTR(-ENOMEM);
8260
 
7566
 
8261
encoder_retry:
7567
	drm_mode_copy(&pipe_config->adjusted_mode, mode);
8262
	/* Ensure the port clock defaults are reset when retrying. */
7568
	drm_mode_copy(&pipe_config->requested_mode, mode);
8263
	pipe_config->port_clock = 0;
7569
 
8264
	pipe_config->pixel_multiplier = 1;
7570
	plane_bpp = pipe_config_set_bpp(crtc, fb, pipe_config);
8265
 
Line 7571... Line 8266...
7571
	if (plane_bpp < 0)
8266
	/* Fill in default crtc timings, allow encoders to overwrite them. */
7572
		goto fail;
8267
	drm_mode_set_crtcinfo(&pipe_config->adjusted_mode, 0);
Line 7573... Line -...
7573
 
-
 
7574
	/* Pass our mode to the connectors and the CRTC to give them a chance to
8268
 
7575
	 * adjust it according to limitations or connector properties, and also
8269
	/* Pass our mode to the connectors and the CRTC to give them a chance to
7576
	 * a chance to reject the mode entirely.
8270
	 * adjust it according to limitations or connector properties, and also
7577
	 */
8271
	 * a chance to reject the mode entirely.
7578
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
-
 
7579
			    base.head) {
-
 
7580
 
8272
	 */
Line 7581... Line 8273...
7581
		if (&encoder->new_crtc->base != crtc)
8273
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
7582
			continue;
8274
			    base.head) {
7583
 
8275
 
7584
		if (encoder->compute_config) {
8276
		if (&encoder->new_crtc->base != crtc)
-
 
8277
			continue;
-
 
8278
 
-
 
8279
			if (!(encoder->compute_config(encoder, pipe_config))) {
7585
			if (!(encoder->compute_config(encoder, pipe_config))) {
8280
				DRM_DEBUG_KMS("Encoder config failure\n");
7586
				DRM_DEBUG_KMS("Encoder config failure\n");
8281
				goto fail;
7587
				goto fail;
8282
			}
7588
			}
-
 
Line -... Line 8283...
-
 
8283
		}
7589
 
8284
 
7590
			continue;
8285
	/* Set default port clock if not overwritten by the encoder. Needs to be
7591
		}
8286
	 * done afterwards in case the encoder adjusts the mode. */
7592
 
8287
	if (!pipe_config->port_clock)
-
 
8288
		pipe_config->port_clock = pipe_config->adjusted_mode.clock;
7593
		encoder_funcs = encoder->base.helper_private;
8289
 
-
 
8290
	ret = intel_crtc_compute_config(to_intel_crtc(crtc), pipe_config);
-
 
8291
	if (ret < 0) {
-
 
8292
		DRM_DEBUG_KMS("CRTC fixup failed\n");
Line 7594... Line 8293...
7594
		if (!(encoder_funcs->mode_fixup(&encoder->base,
8293
		goto fail;
7595
						&pipe_config->requested_mode,
8294
	}
7596
						&pipe_config->adjusted_mode))) {
8295
 
Line 7597... Line 8296...
7597
			DRM_DEBUG_KMS("Encoder fixup failed\n");
8296
	if (ret == RETRY) {
7598
			goto fail;
8297
		if (WARN(!retry, "loop in pipe configuration computation\n")) {
7599
		}
8298
			ret = -EINVAL;
7600
	}
8299
			goto fail;
7601
 
8300
		}
Line 7602... Line 8301...
7602
	if (!(intel_crtc_compute_config(crtc, pipe_config))) {
8301
 
7603
		DRM_DEBUG_KMS("CRTC fixup failed\n");
8302
		DRM_DEBUG_KMS("CRTC bw constrained, retrying\n");
7604
		goto fail;
8303
		retry = false;
Line 7706... Line 8405...
7706
	 * obies this rule, but the modeset restore mode of
8405
	 * obies this rule, but the modeset restore mode of
7707
	 * intel_modeset_setup_hw_state does not.
8406
	 * intel_modeset_setup_hw_state does not.
7708
	 */
8407
	 */
7709
	*modeset_pipes &= 1 << intel_crtc->pipe;
8408
	*modeset_pipes &= 1 << intel_crtc->pipe;
7710
	*prepare_pipes &= 1 << intel_crtc->pipe;
8409
	*prepare_pipes &= 1 << intel_crtc->pipe;
-
 
8410
 
-
 
8411
	DRM_DEBUG_KMS("set mode pipe masks: modeset: %x, prepare: %x, disable: %x\n",
-
 
8412
		      *modeset_pipes, *prepare_pipes, *disable_pipes);
7711
}
8413
}
Line 7712... Line 8414...
7712
 
8414
 
7713
static bool intel_crtc_in_use(struct drm_crtc *crtc)
8415
static bool intel_crtc_in_use(struct drm_crtc *crtc)
7714
{
8416
{
Line 7768... Line 8470...
7768
		}
8470
		}
7769
	}
8471
	}
Line 7770... Line 8472...
7770
 
8472
 
Line -... Line 8473...
-
 
8473
}
-
 
8474
 
-
 
8475
static bool intel_fuzzy_clock_check(struct intel_crtc_config *cur,
-
 
8476
				    struct intel_crtc_config *new)
-
 
8477
{
-
 
8478
	int clock1, clock2, diff;
-
 
8479
 
-
 
8480
	clock1 = cur->adjusted_mode.clock;
-
 
8481
	clock2 = new->adjusted_mode.clock;
-
 
8482
 
-
 
8483
	if (clock1 == clock2)
-
 
8484
		return true;
-
 
8485
 
-
 
8486
	if (!clock1 || !clock2)
-
 
8487
		return false;
-
 
8488
 
-
 
8489
	diff = abs(clock1 - clock2);
-
 
8490
 
-
 
8491
	if (((((diff + clock1 + clock2) * 100)) / (clock1 + clock2)) < 105)
-
 
8492
		return true;
-
 
8493
 
-
 
8494
	return false;
7771
}
8495
}
7772
 
8496
 
7773
#define for_each_intel_crtc_masked(dev, mask, intel_crtc) \
8497
#define for_each_intel_crtc_masked(dev, mask, intel_crtc) \
7774
	list_for_each_entry((intel_crtc), \
8498
	list_for_each_entry((intel_crtc), \
7775
			    &(dev)->mode_config.crtc_list, \
8499
			    &(dev)->mode_config.crtc_list, \
Line 7776... Line 8500...
7776
			    base.head) \
8500
			    base.head) \
-
 
8501
		if (mask & (1 <<(intel_crtc)->pipe))
7777
		if (mask & (1 <<(intel_crtc)->pipe)) \
8502
 
7778
 
8503
static bool
7779
static bool
8504
intel_pipe_config_compare(struct drm_device *dev,
-
 
8505
			  struct intel_crtc_config *current_config,
7780
intel_pipe_config_compare(struct intel_crtc_config *current_config,
8506
			  struct intel_crtc_config *pipe_config)
-
 
8507
{
-
 
8508
#define PIPE_CONF_CHECK_X(name)	\
-
 
8509
	if (current_config->name != pipe_config->name) { \
-
 
8510
		DRM_ERROR("mismatch in " #name " " \
-
 
8511
			  "(expected 0x%08x, found 0x%08x)\n", \
-
 
8512
			  current_config->name, \
-
 
8513
			  pipe_config->name); \
-
 
8514
		return false; \
-
 
8515
	}
7781
			  struct intel_crtc_config *pipe_config)
8516
 
-
 
8517
#define PIPE_CONF_CHECK_I(name)	\
-
 
8518
	if (current_config->name != pipe_config->name) { \
-
 
8519
		DRM_ERROR("mismatch in " #name " " \
-
 
8520
			  "(expected %i, found %i)\n", \
-
 
8521
			  current_config->name, \
-
 
8522
			  pipe_config->name); \
-
 
8523
		return false; \
-
 
8524
	}
-
 
8525
 
7782
{
8526
#define PIPE_CONF_CHECK_FLAGS(name, mask)	\
7783
	if (current_config->has_pch_encoder != pipe_config->has_pch_encoder) {
8527
	if ((current_config->name ^ pipe_config->name) & (mask)) { \
-
 
8528
		DRM_ERROR("mismatch in " #name "(" #mask ") "	   \
-
 
8529
			  "(expected %i, found %i)\n", \
-
 
8530
			  current_config->name & (mask), \
-
 
8531
			  pipe_config->name & (mask)); \
-
 
8532
		return false; \
-
 
8533
	}
-
 
8534
 
-
 
8535
#define PIPE_CONF_QUIRK(quirk)	\
-
 
8536
	((current_config->quirks | pipe_config->quirks) & (quirk))
-
 
8537
 
-
 
8538
	PIPE_CONF_CHECK_I(cpu_transcoder);
-
 
8539
 
-
 
8540
	PIPE_CONF_CHECK_I(has_pch_encoder);
-
 
8541
	PIPE_CONF_CHECK_I(fdi_lanes);
-
 
8542
	PIPE_CONF_CHECK_I(fdi_m_n.gmch_m);
-
 
8543
	PIPE_CONF_CHECK_I(fdi_m_n.gmch_n);
-
 
8544
	PIPE_CONF_CHECK_I(fdi_m_n.link_m);
-
 
8545
	PIPE_CONF_CHECK_I(fdi_m_n.link_n);
-
 
8546
	PIPE_CONF_CHECK_I(fdi_m_n.tu);
-
 
8547
 
-
 
8548
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_hdisplay);
-
 
8549
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_htotal);
-
 
8550
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_start);
-
 
8551
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_end);
-
 
8552
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_hsync_start);
-
 
8553
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_hsync_end);
-
 
8554
 
-
 
8555
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vdisplay);
-
 
8556
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vtotal);
-
 
8557
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vblank_start);
-
 
8558
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vblank_end);
-
 
8559
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vsync_start);
-
 
8560
	PIPE_CONF_CHECK_I(adjusted_mode.crtc_vsync_end);
-
 
8561
 
-
 
8562
		PIPE_CONF_CHECK_I(pixel_multiplier);
-
 
8563
 
-
 
8564
	PIPE_CONF_CHECK_FLAGS(adjusted_mode.flags,
-
 
8565
			      DRM_MODE_FLAG_INTERLACE);
-
 
8566
 
-
 
8567
	if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS)) {
-
 
8568
		PIPE_CONF_CHECK_FLAGS(adjusted_mode.flags,
-
 
8569
				      DRM_MODE_FLAG_PHSYNC);
-
 
8570
		PIPE_CONF_CHECK_FLAGS(adjusted_mode.flags,
-
 
8571
				      DRM_MODE_FLAG_NHSYNC);
-
 
8572
		PIPE_CONF_CHECK_FLAGS(adjusted_mode.flags,
-
 
8573
				      DRM_MODE_FLAG_PVSYNC);
-
 
8574
		PIPE_CONF_CHECK_FLAGS(adjusted_mode.flags,
-
 
8575
				      DRM_MODE_FLAG_NVSYNC);
-
 
8576
	}
-
 
8577
 
-
 
8578
	PIPE_CONF_CHECK_I(requested_mode.hdisplay);
-
 
8579
	PIPE_CONF_CHECK_I(requested_mode.vdisplay);
-
 
8580
 
-
 
8581
	PIPE_CONF_CHECK_I(gmch_pfit.control);
-
 
8582
	/* pfit ratios are autocomputed by the hw on gen4+ */
-
 
8583
	if (INTEL_INFO(dev)->gen < 4)
-
 
8584
		PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
-
 
8585
	PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
-
 
8586
	PIPE_CONF_CHECK_I(pch_pfit.enabled);
-
 
8587
	if (current_config->pch_pfit.enabled) {
-
 
8588
	PIPE_CONF_CHECK_I(pch_pfit.pos);
-
 
8589
	PIPE_CONF_CHECK_I(pch_pfit.size);
-
 
8590
	}
-
 
8591
 
-
 
8592
	PIPE_CONF_CHECK_I(ips_enabled);
-
 
8593
 
-
 
8594
	PIPE_CONF_CHECK_I(shared_dpll);
-
 
8595
	PIPE_CONF_CHECK_X(dpll_hw_state.dpll);
-
 
8596
	PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md);
-
 
8597
	PIPE_CONF_CHECK_X(dpll_hw_state.fp0);
-
 
8598
	PIPE_CONF_CHECK_X(dpll_hw_state.fp1);
-
 
8599
 
-
 
8600
#undef PIPE_CONF_CHECK_X
-
 
8601
#undef PIPE_CONF_CHECK_I
-
 
8602
#undef PIPE_CONF_CHECK_FLAGS
-
 
8603
#undef PIPE_CONF_QUIRK
-
 
8604
 
-
 
8605
	if (!IS_HASWELL(dev)) {
7784
		DRM_ERROR("mismatch in has_pch_encoder "
8606
		if (!intel_fuzzy_clock_check(current_config, pipe_config)) {
7785
			  "(expected %i, found %i)\n",
8607
			DRM_ERROR("mismatch in clock (expected %d, found %d)\n",
7786
			  current_config->has_pch_encoder,
8608
				  current_config->adjusted_mode.clock,
-
 
8609
				  pipe_config->adjusted_mode.clock);
Line 7787... Line 8610...
7787
			  pipe_config->has_pch_encoder);
8610
			return false;
7788
		return false;
8611
		}
Line 7789... Line 8612...
7789
	}
8612
	}
7790
 
8613
 
7791
	return true;
8614
	return true;
7792
}
-
 
7793
 
-
 
7794
void
-
 
7795
intel_modeset_check_state(struct drm_device *dev)
8615
}
7796
{
-
 
Line 7797... Line 8616...
7797
	drm_i915_private_t *dev_priv = dev->dev_private;
8616
 
7798
	struct intel_crtc *crtc;
8617
static void
7799
	struct intel_encoder *encoder;
8618
check_connector_state(struct drm_device *dev)
7800
	struct intel_connector *connector;
8619
{
7801
	struct intel_crtc_config pipe_config;
8620
	struct intel_connector *connector;
Line 7802... Line 8621...
7802
 
8621
 
7803
	list_for_each_entry(connector, &dev->mode_config.connector_list,
8622
	list_for_each_entry(connector, &dev->mode_config.connector_list,
7804
			    base.head) {
8623
			    base.head) {
-
 
8624
		/* This also checks the encoder/connector hw state with the
-
 
8625
		 * ->get_hw_state callbacks. */
-
 
8626
		intel_connector_check_state(connector);
-
 
8627
 
-
 
8628
		WARN(&connector->new_encoder->base != connector->base.encoder,
-
 
8629
		     "connector's staged encoder doesn't match current encoder\n");
-
 
8630
	}
Line 7805... Line 8631...
7805
		/* This also checks the encoder/connector hw state with the
8631
}
7806
		 * ->get_hw_state callbacks. */
8632
 
7807
		intel_connector_check_state(connector);
8633
static void
7808
 
8634
check_encoder_state(struct drm_device *dev)
Line 7858... Line 8684...
7858
		     "active encoder's pipe doesn't match"
8684
		     "active encoder's pipe doesn't match"
7859
		     "(expected %i, found %i)\n",
8685
		     "(expected %i, found %i)\n",
7860
		     tracked_pipe, pipe);
8686
		     tracked_pipe, pipe);
Line 7861... Line 8687...
7861
 
8687
 
-
 
8688
	}
-
 
8689
}
-
 
8690
 
-
 
8691
static void
-
 
8692
check_crtc_state(struct drm_device *dev)
-
 
8693
{
-
 
8694
	drm_i915_private_t *dev_priv = dev->dev_private;
-
 
8695
	struct intel_crtc *crtc;
-
 
8696
	struct intel_encoder *encoder;
Line 7862... Line 8697...
7862
	}
8697
	struct intel_crtc_config pipe_config;
7863
 
8698
 
7864
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
8699
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
7865
			    base.head) {
8700
			    base.head) {
Line -... Line 8701...
-
 
8701
		bool enabled = false;
-
 
8702
		bool active = false;
7866
		bool enabled = false;
8703
 
7867
		bool active = false;
8704
		memset(&pipe_config, 0, sizeof(pipe_config));
Line 7868... Line 8705...
7868
 
8705
 
7869
		DRM_DEBUG_KMS("[CRTC:%d]\n",
8706
		DRM_DEBUG_KMS("[CRTC:%d]\n",
Line 7878... Line 8715...
7878
				continue;
8715
				continue;
7879
			enabled = true;
8716
			enabled = true;
7880
			if (encoder->connectors_active)
8717
			if (encoder->connectors_active)
7881
				active = true;
8718
				active = true;
7882
		}
8719
		}
-
 
8720
 
7883
		WARN(active != crtc->active,
8721
		WARN(active != crtc->active,
7884
		     "crtc's computed active state doesn't match tracked active state "
8722
		     "crtc's computed active state doesn't match tracked active state "
7885
		     "(expected %i, found %i)\n", active, crtc->active);
8723
		     "(expected %i, found %i)\n", active, crtc->active);
7886
		WARN(enabled != crtc->base.enabled,
8724
		WARN(enabled != crtc->base.enabled,
7887
		     "crtc's computed enabled state doesn't match tracked enabled state "
8725
		     "crtc's computed enabled state doesn't match tracked enabled state "
7888
		     "(expected %i, found %i)\n", enabled, crtc->base.enabled);
8726
		     "(expected %i, found %i)\n", enabled, crtc->base.enabled);
Line 7889... Line -...
7889
 
-
 
7890
		memset(&pipe_config, 0, sizeof(pipe_config));
8727
 
7891
		active = dev_priv->display.get_pipe_config(crtc,
8728
		active = dev_priv->display.get_pipe_config(crtc,
Line 7892... Line 8729...
7892
							   &pipe_config);
8729
							   &pipe_config);
7893
 
8730
 
7894
		/* hw state is inconsistent with the pipe A quirk */
8731
		/* hw state is inconsistent with the pipe A quirk */
Line -... Line 8732...
-
 
8732
		if (crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE)
-
 
8733
			active = crtc->active;
-
 
8734
 
-
 
8735
		list_for_each_entry(encoder, &dev->mode_config.encoder_list,
-
 
8736
				    base.head) {
-
 
8737
			enum pipe pipe;
-
 
8738
			if (encoder->base.crtc != &crtc->base)
-
 
8739
				continue;
-
 
8740
			if (encoder->get_config &&
-
 
8741
			    encoder->get_hw_state(encoder, &pipe))
-
 
8742
				encoder->get_config(encoder, &pipe_config);
-
 
8743
		}
-
 
8744
 
7895
		if (crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE)
8745
		if (dev_priv->display.get_clock)
7896
			active = crtc->active;
8746
			dev_priv->display.get_clock(crtc, &pipe_config);
7897
 
8747
 
Line 7898... Line 8748...
7898
		WARN(crtc->active != active,
8748
		WARN(crtc->active != active,
7899
		     "crtc active state doesn't match with hw state "
8749
		     "crtc active state doesn't match with hw state "
7900
		     "(expected %i, found %i)\n", crtc->active, active);
8750
		     "(expected %i, found %i)\n", crtc->active, active);
-
 
8751
 
-
 
8752
		if (active &&
-
 
8753
		    !intel_pipe_config_compare(dev, &crtc->config, &pipe_config)) {
-
 
8754
			WARN(1, "pipe state doesn't match!\n");
-
 
8755
			intel_dump_pipe_config(crtc, &pipe_config,
-
 
8756
					       "[hw state]");
-
 
8757
			intel_dump_pipe_config(crtc, &crtc->config,
-
 
8758
					       "[sw state]");
-
 
8759
		}
-
 
8760
	}
-
 
8761
}
-
 
8762
 
-
 
8763
static void
-
 
8764
check_shared_dpll_state(struct drm_device *dev)
-
 
8765
{
-
 
8766
	drm_i915_private_t *dev_priv = dev->dev_private;
-
 
8767
	struct intel_crtc *crtc;
-
 
8768
	struct intel_dpll_hw_state dpll_hw_state;
-
 
8769
	int i;
-
 
8770
 
-
 
8771
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-
 
8772
		struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
-
 
8773
		int enabled_crtcs = 0, active_crtcs = 0;
-
 
8774
		bool active;
-
 
8775
 
-
 
8776
		memset(&dpll_hw_state, 0, sizeof(dpll_hw_state));
-
 
8777
 
-
 
8778
		DRM_DEBUG_KMS("%s\n", pll->name);
-
 
8779
 
-
 
8780
		active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state);
-
 
8781
 
-
 
8782
		WARN(pll->active > pll->refcount,
-
 
8783
		     "more active pll users than references: %i vs %i\n",
-
 
8784
		     pll->active, pll->refcount);
-
 
8785
		WARN(pll->active && !pll->on,
-
 
8786
		     "pll in active use but not on in sw tracking\n");
-
 
8787
		WARN(pll->on && !pll->active,
-
 
8788
		     "pll in on but not on in use in sw tracking\n");
-
 
8789
		WARN(pll->on != active,
-
 
8790
		     "pll on state mismatch (expected %i, found %i)\n",
-
 
8791
		     pll->on, active);
-
 
8792
 
-
 
8793
		list_for_each_entry(crtc, &dev->mode_config.crtc_list,
-
 
8794
				    base.head) {
-
 
8795
			if (crtc->base.enabled && intel_crtc_to_shared_dpll(crtc) == pll)
-
 
8796
				enabled_crtcs++;
-
 
8797
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
-
 
8798
				active_crtcs++;
-
 
8799
		}
-
 
8800
		WARN(pll->active != active_crtcs,
-
 
8801
		     "pll active crtcs mismatch (expected %i, found %i)\n",
-
 
8802
		     pll->active, active_crtcs);
-
 
8803
		WARN(pll->refcount != enabled_crtcs,
-
 
8804
		     "pll enabled crtcs mismatch (expected %i, found %i)\n",
-
 
8805
		     pll->refcount, enabled_crtcs);
7901
 
8806
 
7902
		WARN(active &&
8807
		WARN(pll->on && memcmp(&pll->hw_state, &dpll_hw_state,
Line -... Line 8808...
-
 
8808
				       sizeof(dpll_hw_state)),
-
 
8809
		     "pll hw state mismatch\n");
-
 
8810
	}
-
 
8811
}
-
 
8812
 
-
 
8813
void
-
 
8814
intel_modeset_check_state(struct drm_device *dev)
-
 
8815
{
-
 
8816
	check_connector_state(dev);
7903
		     !intel_pipe_config_compare(&crtc->config, &pipe_config),
8817
	check_encoder_state(dev);
7904
		     "pipe state doesn't match!\n");
8818
	check_crtc_state(dev);
7905
	}
8819
	check_shared_dpll_state(dev);
7906
}
8820
}
7907
 
8821
 
Line 7939... Line 8853...
7939
			ret = PTR_ERR(pipe_config);
8853
			ret = PTR_ERR(pipe_config);
7940
			pipe_config = NULL;
8854
			pipe_config = NULL;
Line 7941... Line 8855...
7941
 
8855
 
7942
			goto out;
8856
			goto out;
-
 
8857
		}
-
 
8858
		intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config,
7943
		}
8859
				       "[modeset]");
Line 7944... Line -...
7944
	}
-
 
7945
 
-
 
7946
	DRM_DEBUG_KMS("set mode pipe masks: modeset: %x, prepare: %x, disable: %x\n",
-
 
7947
		      modeset_pipes, prepare_pipes, disable_pipes);
8860
	}
7948
 
8861
 
Line 7949... Line 8862...
7949
	for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc)
8862
	for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc)
7950
		intel_crtc_disable(&intel_crtc->base);
8863
		intel_crtc_disable(&intel_crtc->base);
Line 7956... Line 8869...
7956
 
8869
 
7957
	/* crtc->mode is already used by the ->mode_set callbacks, hence we need
8870
	/* crtc->mode is already used by the ->mode_set callbacks, hence we need
7958
	 * to set it here already despite that we pass it down the callchain.
8871
	 * to set it here already despite that we pass it down the callchain.
7959
	 */
8872
	 */
7960
	if (modeset_pipes) {
-
 
7961
		enum transcoder tmp = to_intel_crtc(crtc)->config.cpu_transcoder;
8873
	if (modeset_pipes) {
7962
		crtc->mode = *mode;
8874
		crtc->mode = *mode;
7963
		/* mode_set/enable/disable functions rely on a correct pipe
8875
		/* mode_set/enable/disable functions rely on a correct pipe
7964
		 * config. */
8876
		 * config. */
7965
		to_intel_crtc(crtc)->config = *pipe_config;
-
 
7966
		to_intel_crtc(crtc)->config.cpu_transcoder = tmp;
8877
		to_intel_crtc(crtc)->config = *pipe_config;
Line 7967... Line 8878...
7967
	}
8878
	}
7968
 
8879
 
7969
	/* Only after disabling all output pipelines that will be changed can we
8880
	/* Only after disabling all output pipelines that will be changed can we
Line 8009... Line 8920...
8009
	kfree(pipe_config);
8920
	kfree(pipe_config);
8010
	kfree(saved_mode);
8921
	kfree(saved_mode);
8011
	return ret;
8922
	return ret;
8012
}
8923
}
Line 8013... Line 8924...
8013
 
8924
 
8014
int intel_set_mode(struct drm_crtc *crtc,
8925
static int intel_set_mode(struct drm_crtc *crtc,
8015
		     struct drm_display_mode *mode,
8926
		     struct drm_display_mode *mode,
8016
		     int x, int y, struct drm_framebuffer *fb)
8927
		     int x, int y, struct drm_framebuffer *fb)
8017
{
8928
{
Line 8097... Line 9008...
8097
			to_intel_encoder(config->save_connector_encoders[count++]);
9008
			to_intel_encoder(config->save_connector_encoders[count++]);
8098
	}
9009
	}
8099
}
9010
}
Line 8100... Line 9011...
8100
 
9011
 
8101
static bool
9012
static bool
8102
is_crtc_connector_off(struct drm_crtc *crtc, struct drm_connector *connectors,
-
 
8103
		      int num_connectors)
9013
is_crtc_connector_off(struct drm_mode_set *set)
8104
{
9014
{
Line -... Line 9015...
-
 
9015
	int i;
-
 
9016
 
-
 
9017
	if (set->num_connectors == 0)
-
 
9018
		return false;
-
 
9019
 
-
 
9020
	if (WARN_ON(set->connectors == NULL))
8105
	int i;
9021
		return false;
8106
 
9022
 
8107
	for (i = 0; i < num_connectors; i++)
9023
	for (i = 0; i < set->num_connectors; i++)
8108
		if (connectors[i].encoder &&
9024
		if (set->connectors[i]->encoder &&
8109
		    connectors[i].encoder->crtc == crtc &&
9025
		    set->connectors[i]->encoder->crtc == set->crtc &&
Line 8110... Line 9026...
8110
		    connectors[i].dpms != DRM_MODE_DPMS_ON)
9026
		    set->connectors[i]->dpms != DRM_MODE_DPMS_ON)
8111
			return true;
9027
			return true;
Line 8118... Line 9034...
8118
				      struct intel_set_config *config)
9034
				      struct intel_set_config *config)
8119
{
9035
{
Line 8120... Line 9036...
8120
 
9036
 
8121
	/* We should be able to check here if the fb has the same properties
9037
	/* We should be able to check here if the fb has the same properties
8122
	 * and then just flip_or_move it */
9038
	 * and then just flip_or_move it */
8123
	if (set->connectors != NULL &&
-
 
8124
	    is_crtc_connector_off(set->crtc, *set->connectors,
-
 
8125
				  set->num_connectors)) {
9039
	if (is_crtc_connector_off(set)) {
8126
			config->mode_changed = true;
9040
			config->mode_changed = true;
8127
	} else if (set->crtc->fb != set->fb) {
9041
	} else if (set->crtc->fb != set->fb) {
8128
		/* If we have no fb then treat it as a full mode set */
9042
		/* If we have no fb then treat it as a full mode set */
-
 
9043
		if (set->crtc->fb == NULL) {
-
 
9044
			struct intel_crtc *intel_crtc =
-
 
9045
				to_intel_crtc(set->crtc);
-
 
9046
 
8129
		if (set->crtc->fb == NULL) {
9047
			if (intel_crtc->active && i915_fastboot) {
-
 
9048
				DRM_DEBUG_KMS("crtc has no fb, will flip\n");
-
 
9049
				config->fb_changed = true;
-
 
9050
			} else {
8130
			DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
9051
				DRM_DEBUG_KMS("inactive crtc, full mode set\n");
-
 
9052
			config->mode_changed = true;
8131
			config->mode_changed = true;
9053
			}
8132
		} else if (set->fb == NULL) {
9054
		} else if (set->fb == NULL) {
8133
			config->mode_changed = true;
9055
			config->mode_changed = true;
8134
		} else if (set->fb->pixel_format !=
9056
		} else if (set->fb->pixel_format !=
8135
			   set->crtc->fb->pixel_format) {
9057
			   set->crtc->fb->pixel_format) {
Line 8146... Line 9068...
8146
		DRM_DEBUG_KMS("modes are different, full mode set\n");
9068
		DRM_DEBUG_KMS("modes are different, full mode set\n");
8147
		drm_mode_debug_printmodeline(&set->crtc->mode);
9069
		drm_mode_debug_printmodeline(&set->crtc->mode);
8148
		drm_mode_debug_printmodeline(set->mode);
9070
		drm_mode_debug_printmodeline(set->mode);
8149
		config->mode_changed = true;
9071
		config->mode_changed = true;
8150
	}
9072
	}
-
 
9073
 
-
 
9074
	DRM_DEBUG_KMS("computed changes for [CRTC:%d], mode_changed=%d, fb_changed=%d\n",
-
 
9075
			set->crtc->base.id, config->mode_changed, config->fb_changed);
8151
}
9076
}
Line 8152... Line 9077...
8152
 
9077
 
8153
static int
9078
static int
8154
intel_modeset_stage_output_state(struct drm_device *dev,
9079
intel_modeset_stage_output_state(struct drm_device *dev,
8155
				 struct drm_mode_set *set,
9080
				 struct drm_mode_set *set,
8156
				 struct intel_set_config *config)
9081
				 struct intel_set_config *config)
8157
{
9082
{
8158
	struct drm_crtc *new_crtc;
9083
	struct drm_crtc *new_crtc;
8159
	struct intel_connector *connector;
9084
	struct intel_connector *connector;
8160
	struct intel_encoder *encoder;
9085
	struct intel_encoder *encoder;
Line 8161... Line 9086...
8161
	int count, ro;
9086
	int ro;
8162
 
9087
 
8163
	/* The upper layers ensure that we either disable a crtc or have a list
9088
	/* The upper layers ensure that we either disable a crtc or have a list
8164
	 * of connectors. For paranoia, double-check this. */
9089
	 * of connectors. For paranoia, double-check this. */
Line 8165... Line -...
8165
	WARN_ON(!set->fb && (set->num_connectors != 0));
-
 
8166
	WARN_ON(set->fb && (set->num_connectors == 0));
9090
	WARN_ON(!set->fb && (set->num_connectors != 0));
8167
 
9091
	WARN_ON(set->fb && (set->num_connectors == 0));
8168
	count = 0;
9092
 
8169
	list_for_each_entry(connector, &dev->mode_config.connector_list,
9093
	list_for_each_entry(connector, &dev->mode_config.connector_list,
8170
			    base.head) {
9094
			    base.head) {
Line 8197... Line 9121...
8197
		}
9121
		}
8198
	}
9122
	}
8199
	/* connector->new_encoder is now updated for all connectors. */
9123
	/* connector->new_encoder is now updated for all connectors. */
Line 8200... Line 9124...
8200
 
9124
 
8201
	/* Update crtc of enabled connectors. */
-
 
8202
	count = 0;
9125
	/* Update crtc of enabled connectors. */
8203
	list_for_each_entry(connector, &dev->mode_config.connector_list,
9126
	list_for_each_entry(connector, &dev->mode_config.connector_list,
8204
			    base.head) {
9127
			    base.head) {
8205
		if (!connector->new_encoder)
9128
		if (!connector->new_encoder)
Line 8300... Line 9223...
8300
	ret = intel_modeset_stage_output_state(dev, set, config);
9223
	ret = intel_modeset_stage_output_state(dev, set, config);
8301
	if (ret)
9224
	if (ret)
8302
		goto fail;
9225
		goto fail;
Line 8303... Line 9226...
8303
 
9226
 
8304
	if (config->mode_changed) {
-
 
8305
		if (set->mode) {
-
 
8306
			DRM_DEBUG_KMS("attempting to set mode from"
-
 
8307
					" userspace\n");
-
 
8308
			drm_mode_debug_printmodeline(set->mode);
-
 
8309
		}
-
 
8310
 
9227
	if (config->mode_changed) {
8311
		ret = intel_set_mode(set->crtc, set->mode,
9228
		ret = intel_set_mode(set->crtc, set->mode,
8312
				     set->x, set->y, set->fb);
9229
				     set->x, set->y, set->fb);
8313
	} else if (config->fb_changed) {
9230
	} else if (config->fb_changed) {
Line 8314... Line 9231...
8314
//       intel_crtc_wait_for_pending_flips(set->crtc);
9231
//       intel_crtc_wait_for_pending_flips(set->crtc);
8315
 
9232
 
8316
		ret = intel_pipe_set_base(set->crtc,
9233
		ret = intel_pipe_set_base(set->crtc,
Line 8317... Line 9234...
8317
					  set->x, set->y, set->fb);
9234
					  set->x, set->y, set->fb);
8318
	}
9235
	}
8319
 
9236
 
8320
	if (ret) {
9237
	if (ret) {
8321
		DRM_ERROR("failed to set mode on [CRTC:%d], err = %d\n",
9238
		DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
Line 8322... Line 9239...
8322
			  set->crtc->base.id, ret);
9239
			  set->crtc->base.id, ret);
Line 8348... Line 9265...
8348
{
9265
{
8349
	if (HAS_DDI(dev))
9266
	if (HAS_DDI(dev))
8350
		intel_ddi_pll_init(dev);
9267
		intel_ddi_pll_init(dev);
8351
}
9268
}
Line 8352... Line 9269...
8352
 
9269
 
-
 
9270
static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
-
 
9271
				      struct intel_shared_dpll *pll,
8353
static void intel_pch_pll_init(struct drm_device *dev)
9272
				      struct intel_dpll_hw_state *hw_state)
8354
{
-
 
8355
	drm_i915_private_t *dev_priv = dev->dev_private;
9273
{
Line 8356... Line 9274...
8356
	int i;
9274
	uint32_t val;
-
 
9275
 
-
 
9276
	val = I915_READ(PCH_DPLL(pll->id));
8357
 
9277
	hw_state->dpll = val;
-
 
9278
	hw_state->fp0 = I915_READ(PCH_FP0(pll->id));
8358
	if (dev_priv->num_pch_pll == 0) {
9279
	hw_state->fp1 = I915_READ(PCH_FP1(pll->id));
8359
		DRM_DEBUG_KMS("No PCH PLLs on this hardware, skipping initialisation\n");
9280
 
Line 8360... Line 9281...
8360
		return;
9281
	return val & DPLL_VCO_ENABLE;
8361
	}
9282
}
-
 
9283
 
8362
 
9284
static void ibx_pch_dpll_mode_set(struct drm_i915_private *dev_priv,
8363
	for (i = 0; i < dev_priv->num_pch_pll; i++) {
9285
				  struct intel_shared_dpll *pll)
8364
		dev_priv->pch_plls[i].pll_reg = _PCH_DPLL(i);
9286
{
-
 
9287
	I915_WRITE(PCH_FP0(pll->id), pll->hw_state.fp0);
-
 
9288
	I915_WRITE(PCH_FP1(pll->id), pll->hw_state.fp1);
-
 
9289
}
-
 
9290
 
-
 
9291
static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
-
 
9292
				struct intel_shared_dpll *pll)
-
 
9293
{
-
 
9294
	/* PCH refclock must be enabled first */
-
 
9295
	assert_pch_refclk_enabled(dev_priv);
-
 
9296
 
-
 
9297
	I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
-
 
9298
 
-
 
9299
	/* Wait for the clocks to stabilize. */
-
 
9300
	POSTING_READ(PCH_DPLL(pll->id));
-
 
9301
	udelay(150);
-
 
9302
 
-
 
9303
	/* The pixel multiplier can only be updated once the
-
 
9304
	 * DPLL is enabled and the clocks are stable.
-
 
9305
	 *
-
 
9306
	 * So write it again.
-
 
9307
	 */
-
 
9308
	I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
-
 
9309
	POSTING_READ(PCH_DPLL(pll->id));
-
 
9310
	udelay(200);
-
 
9311
}
-
 
9312
 
-
 
9313
static void ibx_pch_dpll_disable(struct drm_i915_private *dev_priv,
-
 
9314
				 struct intel_shared_dpll *pll)
-
 
9315
{
-
 
9316
	struct drm_device *dev = dev_priv->dev;
-
 
9317
	struct intel_crtc *crtc;
-
 
9318
 
-
 
9319
	/* Make sure no transcoder isn't still depending on us. */
-
 
9320
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
-
 
9321
		if (intel_crtc_to_shared_dpll(crtc) == pll)
-
 
9322
			assert_pch_transcoder_disabled(dev_priv, crtc->pipe);
-
 
9323
	}
-
 
9324
 
-
 
9325
	I915_WRITE(PCH_DPLL(pll->id), 0);
-
 
9326
	POSTING_READ(PCH_DPLL(pll->id));
-
 
9327
	udelay(200);
-
 
9328
}
-
 
9329
 
-
 
9330
static char *ibx_pch_dpll_names[] = {
-
 
9331
	"PCH DPLL A",
-
 
9332
	"PCH DPLL B",
-
 
9333
};
-
 
9334
 
-
 
9335
static void ibx_pch_dpll_init(struct drm_device *dev)
-
 
9336
{
-
 
9337
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
9338
	int i;
-
 
9339
 
-
 
9340
	dev_priv->num_shared_dpll = 2;
-
 
9341
 
-
 
9342
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-
 
9343
		dev_priv->shared_dplls[i].id = i;
-
 
9344
		dev_priv->shared_dplls[i].name = ibx_pch_dpll_names[i];
-
 
9345
		dev_priv->shared_dplls[i].mode_set = ibx_pch_dpll_mode_set;
-
 
9346
		dev_priv->shared_dplls[i].enable = ibx_pch_dpll_enable;
-
 
9347
		dev_priv->shared_dplls[i].disable = ibx_pch_dpll_disable;
-
 
9348
		dev_priv->shared_dplls[i].get_hw_state =
-
 
9349
			ibx_pch_dpll_get_hw_state;
-
 
9350
	}
-
 
9351
}
-
 
9352
 
-
 
9353
static void intel_shared_dpll_init(struct drm_device *dev)
-
 
9354
{
-
 
9355
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
9356
 
-
 
9357
	if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
-
 
9358
		ibx_pch_dpll_init(dev);
-
 
9359
	else
-
 
9360
		dev_priv->num_shared_dpll = 0;
-
 
9361
 
8365
		dev_priv->pch_plls[i].fp0_reg = _PCH_FP0(i);
9362
	BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
Line 8366... Line 9363...
8366
		dev_priv->pch_plls[i].fp1_reg = _PCH_FP1(i);
9363
	DRM_DEBUG_KMS("%i shared PLLs initialized\n",
8367
	}
9364
		      dev_priv->num_shared_dpll);
8368
}
9365
}
Line 8387... Line 9384...
8387
	}
9384
	}
Line 8388... Line 9385...
8388
 
9385
 
8389
	/* Swap pipes & planes for FBC on pre-965 */
9386
	/* Swap pipes & planes for FBC on pre-965 */
8390
	intel_crtc->pipe = pipe;
9387
	intel_crtc->pipe = pipe;
8391
	intel_crtc->plane = pipe;
-
 
8392
	intel_crtc->config.cpu_transcoder = pipe;
9388
	intel_crtc->plane = pipe;
8393
	if (IS_MOBILE(dev) && IS_GEN3(dev)) {
9389
	if (IS_MOBILE(dev) && IS_GEN3(dev)) {
8394
		DRM_DEBUG_KMS("swapping pipes & planes for FBC\n");
9390
		DRM_DEBUG_KMS("swapping pipes & planes for FBC\n");
8395
		intel_crtc->plane = !pipe;
9391
		intel_crtc->plane = !pipe;
Line 8470... Line 9466...
8470
static void intel_setup_outputs(struct drm_device *dev)
9466
static void intel_setup_outputs(struct drm_device *dev)
8471
{
9467
{
8472
	struct drm_i915_private *dev_priv = dev->dev_private;
9468
	struct drm_i915_private *dev_priv = dev->dev_private;
8473
	struct intel_encoder *encoder;
9469
	struct intel_encoder *encoder;
8474
	bool dpd_is_edp = false;
9470
	bool dpd_is_edp = false;
8475
	bool has_lvds;
-
 
Line 8476... Line 9471...
8476
 
9471
 
8477
		has_lvds = intel_lvds_init(dev);
-
 
8478
	if (!has_lvds && !HAS_PCH_SPLIT(dev)) {
-
 
8479
		/* disable the panel fitter on everything but LVDS */
-
 
8480
		I915_WRITE(PFIT_CONTROL, 0);
-
 
Line 8481... Line 9472...
8481
	}
9472
	intel_lvds_init(dev);
8482
 
9473
 
Line 8483... Line 9474...
8483
	if (!IS_ULT(dev))
9474
	if (!IS_ULT(dev))
Line 8529... Line 9520...
8529
 
9520
 
8530
		if (I915_READ(PCH_DP_D) & DP_DETECTED)
9521
		if (I915_READ(PCH_DP_D) & DP_DETECTED)
8531
			intel_dp_init(dev, PCH_DP_D, PORT_D);
9522
			intel_dp_init(dev, PCH_DP_D, PORT_D);
8532
	} else if (IS_VALLEYVIEW(dev)) {
9523
	} else if (IS_VALLEYVIEW(dev)) {
-
 
9524
		/* Check for built-in panel first. Shares lanes with HDMI on SDVOC */
-
 
9525
		if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) {
-
 
9526
			intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC,
8533
		/* Check for built-in panel first. Shares lanes with HDMI on SDVOC */
9527
					PORT_C);
8534
		if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED)
9528
		if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED)
-
 
9529
				intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C,
-
 
9530
					      PORT_C);
Line 8535... Line 9531...
8535
			intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C);
9531
		}
8536
 
9532
 
8537
		if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) {
9533
		if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) {
8538
			intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB,
9534
			intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB,
Line 8549... Line 9545...
8549
			if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) {
9545
			if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) {
8550
				DRM_DEBUG_KMS("probing HDMI on SDVOB\n");
9546
				DRM_DEBUG_KMS("probing HDMI on SDVOB\n");
8551
				intel_hdmi_init(dev, GEN4_HDMIB, PORT_B);
9547
				intel_hdmi_init(dev, GEN4_HDMIB, PORT_B);
8552
			}
9548
			}
Line 8553... Line 9549...
8553
 
9549
 
8554
			if (!found && SUPPORTS_INTEGRATED_DP(dev)) {
-
 
8555
				DRM_DEBUG_KMS("probing DP_B\n");
9550
			if (!found && SUPPORTS_INTEGRATED_DP(dev))
8556
				intel_dp_init(dev, DP_B, PORT_B);
9551
				intel_dp_init(dev, DP_B, PORT_B);
8557
			}
-
 
Line 8558... Line 9552...
8558
		}
9552
			}
Line 8559... Line 9553...
8559
 
9553
 
8560
		/* Before G4X SDVOC doesn't have its own detect register */
9554
		/* Before G4X SDVOC doesn't have its own detect register */
Line 8568... Line 9562...
8568
 
9562
 
8569
			if (SUPPORTS_INTEGRATED_HDMI(dev)) {
9563
			if (SUPPORTS_INTEGRATED_HDMI(dev)) {
8570
				DRM_DEBUG_KMS("probing HDMI on SDVOC\n");
9564
				DRM_DEBUG_KMS("probing HDMI on SDVOC\n");
8571
				intel_hdmi_init(dev, GEN4_HDMIC, PORT_C);
9565
				intel_hdmi_init(dev, GEN4_HDMIC, PORT_C);
8572
			}
9566
			}
8573
			if (SUPPORTS_INTEGRATED_DP(dev)) {
-
 
8574
				DRM_DEBUG_KMS("probing DP_C\n");
9567
			if (SUPPORTS_INTEGRATED_DP(dev))
8575
				intel_dp_init(dev, DP_C, PORT_C);
9568
				intel_dp_init(dev, DP_C, PORT_C);
8576
			}
-
 
Line 8577... Line 9569...
8577
		}
9569
			}
8578
 
9570
 
8579
		if (SUPPORTS_INTEGRATED_DP(dev) &&
-
 
8580
		    (I915_READ(DP_D) & DP_DETECTED)) {
9571
		if (SUPPORTS_INTEGRATED_DP(dev) &&
8581
			DRM_DEBUG_KMS("probing DP_D\n");
-
 
8582
			intel_dp_init(dev, DP_D, PORT_D);
9572
		    (I915_READ(DP_D) & DP_DETECTED))
8583
		}
9573
			intel_dp_init(dev, DP_D, PORT_D);
Line 8584... Line 9574...
8584
	} else if (IS_GEN2(dev))
9574
	} else if (IS_GEN2(dev))
8585
		intel_dvo_init(dev);
9575
		intel_dvo_init(dev);
Line 8608... Line 9598...
8608
int intel_framebuffer_init(struct drm_device *dev,
9598
int intel_framebuffer_init(struct drm_device *dev,
8609
			   struct intel_framebuffer *intel_fb,
9599
			   struct intel_framebuffer *intel_fb,
8610
			   struct drm_mode_fb_cmd2 *mode_cmd,
9600
			   struct drm_mode_fb_cmd2 *mode_cmd,
8611
			   struct drm_i915_gem_object *obj)
9601
			   struct drm_i915_gem_object *obj)
8612
{
9602
{
-
 
9603
	int pitch_limit;
8613
	int ret;
9604
	int ret;
Line 8614... Line 9605...
8614
 
9605
 
8615
	if (obj->tiling_mode == I915_TILING_Y) {
9606
	if (obj->tiling_mode == I915_TILING_Y) {
8616
		DRM_DEBUG("hardware does not support tiling Y\n");
9607
		DRM_DEBUG("hardware does not support tiling Y\n");
Line 8621... Line 9612...
8621
		DRM_DEBUG("pitch (%d) must be at least 64 byte aligned\n",
9612
		DRM_DEBUG("pitch (%d) must be at least 64 byte aligned\n",
8622
			  mode_cmd->pitches[0]);
9613
			  mode_cmd->pitches[0]);
8623
		return -EINVAL;
9614
		return -EINVAL;
8624
	}
9615
	}
Line -... Line 9616...
-
 
9616
 
-
 
9617
	if (INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev)) {
-
 
9618
		pitch_limit = 32*1024;
-
 
9619
	} else if (INTEL_INFO(dev)->gen >= 4) {
-
 
9620
		if (obj->tiling_mode)
-
 
9621
			pitch_limit = 16*1024;
-
 
9622
		else
-
 
9623
			pitch_limit = 32*1024;
-
 
9624
	} else if (INTEL_INFO(dev)->gen >= 3) {
-
 
9625
		if (obj->tiling_mode)
-
 
9626
			pitch_limit = 8*1024;
-
 
9627
		else
-
 
9628
			pitch_limit = 16*1024;
8625
 
9629
	} else
-
 
9630
		/* XXX DSPC is limited to 4k tiled */
-
 
9631
		pitch_limit = 8*1024;
8626
	/* FIXME <= Gen4 stride limits are bit unclear */
9632
 
8627
	if (mode_cmd->pitches[0] > 32768) {
9633
	if (mode_cmd->pitches[0] > pitch_limit) {
-
 
9634
		DRM_DEBUG("%s pitch (%d) must be at less than %d\n",
8628
		DRM_DEBUG("pitch (%d) must be at less than 32768\n",
9635
			  obj->tiling_mode ? "tiled" : "linear",
8629
			  mode_cmd->pitches[0]);
9636
			  mode_cmd->pitches[0], pitch_limit);
8630
		return -EINVAL;
9637
		return -EINVAL;
Line 8631... Line 9638...
8631
	}
9638
	}
8632
 
9639
 
Line 8645... Line 9652...
8645
	case DRM_FORMAT_ARGB8888:
9652
	case DRM_FORMAT_ARGB8888:
8646
		break;
9653
		break;
8647
	case DRM_FORMAT_XRGB1555:
9654
	case DRM_FORMAT_XRGB1555:
8648
	case DRM_FORMAT_ARGB1555:
9655
	case DRM_FORMAT_ARGB1555:
8649
		if (INTEL_INFO(dev)->gen > 3) {
9656
		if (INTEL_INFO(dev)->gen > 3) {
-
 
9657
			DRM_DEBUG("unsupported pixel format: %s\n",
8650
			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
9658
				  drm_get_format_name(mode_cmd->pixel_format));
8651
			return -EINVAL;
9659
			return -EINVAL;
8652
		}
9660
		}
8653
		break;
9661
		break;
8654
	case DRM_FORMAT_XBGR8888:
9662
	case DRM_FORMAT_XBGR8888:
8655
	case DRM_FORMAT_ABGR8888:
9663
	case DRM_FORMAT_ABGR8888:
8656
	case DRM_FORMAT_XRGB2101010:
9664
	case DRM_FORMAT_XRGB2101010:
8657
	case DRM_FORMAT_ARGB2101010:
9665
	case DRM_FORMAT_ARGB2101010:
8658
	case DRM_FORMAT_XBGR2101010:
9666
	case DRM_FORMAT_XBGR2101010:
8659
	case DRM_FORMAT_ABGR2101010:
9667
	case DRM_FORMAT_ABGR2101010:
8660
		if (INTEL_INFO(dev)->gen < 4) {
9668
		if (INTEL_INFO(dev)->gen < 4) {
-
 
9669
			DRM_DEBUG("unsupported pixel format: %s\n",
8661
			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
9670
				  drm_get_format_name(mode_cmd->pixel_format));
8662
			return -EINVAL;
9671
			return -EINVAL;
8663
		}
9672
		}
8664
		break;
9673
		break;
8665
	case DRM_FORMAT_YUYV:
9674
	case DRM_FORMAT_YUYV:
8666
	case DRM_FORMAT_UYVY:
9675
	case DRM_FORMAT_UYVY:
8667
	case DRM_FORMAT_YVYU:
9676
	case DRM_FORMAT_YVYU:
8668
	case DRM_FORMAT_VYUY:
9677
	case DRM_FORMAT_VYUY:
8669
		if (INTEL_INFO(dev)->gen < 5) {
9678
		if (INTEL_INFO(dev)->gen < 5) {
-
 
9679
			DRM_DEBUG("unsupported pixel format: %s\n",
8670
			DRM_DEBUG("invalid format: 0x%08x\n", mode_cmd->pixel_format);
9680
				  drm_get_format_name(mode_cmd->pixel_format));
8671
			return -EINVAL;
9681
			return -EINVAL;
8672
		}
9682
		}
8673
		break;
9683
		break;
8674
	default:
9684
	default:
8675
		DRM_DEBUG("unsupported pixel format 0x%08x\n", mode_cmd->pixel_format);
9685
		DRM_DEBUG("unsupported pixel format: %s\n",
-
 
9686
			  drm_get_format_name(mode_cmd->pixel_format));
8676
		return -EINVAL;
9687
		return -EINVAL;
8677
	}
9688
	}
Line 8678... Line 9689...
8678
 
9689
 
8679
	/* FIXME need to adjust LINOFF/TILEOFF accordingly. */
9690
	/* FIXME need to adjust LINOFF/TILEOFF accordingly. */
Line 8701... Line 9712...
8701
/* Set up chip specific display functions */
9712
/* Set up chip specific display functions */
8702
static void intel_init_display(struct drm_device *dev)
9713
static void intel_init_display(struct drm_device *dev)
8703
{
9714
{
8704
	struct drm_i915_private *dev_priv = dev->dev_private;
9715
	struct drm_i915_private *dev_priv = dev->dev_private;
Line -... Line 9716...
-
 
9716
 
-
 
9717
	if (HAS_PCH_SPLIT(dev) || IS_G4X(dev))
-
 
9718
		dev_priv->display.find_dpll = g4x_find_best_dpll;
-
 
9719
	else if (IS_VALLEYVIEW(dev))
-
 
9720
		dev_priv->display.find_dpll = vlv_find_best_dpll;
-
 
9721
	else if (IS_PINEVIEW(dev))
-
 
9722
		dev_priv->display.find_dpll = pnv_find_best_dpll;
-
 
9723
	else
-
 
9724
		dev_priv->display.find_dpll = i9xx_find_best_dpll;
8705
 
9725
 
8706
	if (HAS_DDI(dev)) {
9726
	if (HAS_DDI(dev)) {
8707
		dev_priv->display.get_pipe_config = haswell_get_pipe_config;
9727
		dev_priv->display.get_pipe_config = haswell_get_pipe_config;
8708
		dev_priv->display.crtc_mode_set = haswell_crtc_mode_set;
9728
		dev_priv->display.crtc_mode_set = haswell_crtc_mode_set;
8709
		dev_priv->display.crtc_enable = haswell_crtc_enable;
9729
		dev_priv->display.crtc_enable = haswell_crtc_enable;
8710
		dev_priv->display.crtc_disable = haswell_crtc_disable;
9730
		dev_priv->display.crtc_disable = haswell_crtc_disable;
8711
		dev_priv->display.off = haswell_crtc_off;
9731
		dev_priv->display.off = haswell_crtc_off;
8712
		dev_priv->display.update_plane = ironlake_update_plane;
9732
		dev_priv->display.update_plane = ironlake_update_plane;
8713
	} else if (HAS_PCH_SPLIT(dev)) {
9733
	} else if (HAS_PCH_SPLIT(dev)) {
-
 
9734
		dev_priv->display.get_pipe_config = ironlake_get_pipe_config;
8714
		dev_priv->display.get_pipe_config = ironlake_get_pipe_config;
9735
		dev_priv->display.get_clock = ironlake_crtc_clock_get;
8715
		dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set;
9736
		dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set;
8716
		dev_priv->display.crtc_enable = ironlake_crtc_enable;
9737
		dev_priv->display.crtc_enable = ironlake_crtc_enable;
8717
		dev_priv->display.crtc_disable = ironlake_crtc_disable;
9738
		dev_priv->display.crtc_disable = ironlake_crtc_disable;
8718
		dev_priv->display.off = ironlake_crtc_off;
9739
		dev_priv->display.off = ironlake_crtc_off;
-
 
9740
		dev_priv->display.update_plane = ironlake_update_plane;
-
 
9741
	} else if (IS_VALLEYVIEW(dev)) {
-
 
9742
		dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
-
 
9743
		dev_priv->display.get_clock = i9xx_crtc_clock_get;
-
 
9744
		dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
-
 
9745
		dev_priv->display.crtc_enable = valleyview_crtc_enable;
-
 
9746
		dev_priv->display.crtc_disable = i9xx_crtc_disable;
-
 
9747
		dev_priv->display.off = i9xx_crtc_off;
8719
		dev_priv->display.update_plane = ironlake_update_plane;
9748
		dev_priv->display.update_plane = i9xx_update_plane;
8720
	} else {
9749
	} else {
-
 
9750
		dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
8721
		dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
9751
		dev_priv->display.get_clock = i9xx_crtc_clock_get;
8722
		dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
9752
		dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
8723
		dev_priv->display.crtc_enable = i9xx_crtc_enable;
9753
		dev_priv->display.crtc_enable = i9xx_crtc_enable;
8724
		dev_priv->display.crtc_disable = i9xx_crtc_disable;
9754
		dev_priv->display.crtc_disable = i9xx_crtc_disable;
8725
		dev_priv->display.off = i9xx_crtc_off;
9755
		dev_priv->display.off = i9xx_crtc_off;
Line 8734... Line 9764...
8734
		dev_priv->display.get_display_clock_speed =
9764
		dev_priv->display.get_display_clock_speed =
8735
			i945_get_display_clock_speed;
9765
			i945_get_display_clock_speed;
8736
	else if (IS_I915G(dev))
9766
	else if (IS_I915G(dev))
8737
		dev_priv->display.get_display_clock_speed =
9767
		dev_priv->display.get_display_clock_speed =
8738
			i915_get_display_clock_speed;
9768
			i915_get_display_clock_speed;
8739
	else if (IS_I945GM(dev) || IS_845G(dev) || IS_PINEVIEW_M(dev))
9769
	else if (IS_I945GM(dev) || IS_845G(dev))
8740
		dev_priv->display.get_display_clock_speed =
9770
		dev_priv->display.get_display_clock_speed =
8741
			i9xx_misc_get_display_clock_speed;
9771
			i9xx_misc_get_display_clock_speed;
-
 
9772
	else if (IS_PINEVIEW(dev))
-
 
9773
		dev_priv->display.get_display_clock_speed =
-
 
9774
			pnv_get_display_clock_speed;
8742
	else if (IS_I915GM(dev))
9775
	else if (IS_I915GM(dev))
8743
		dev_priv->display.get_display_clock_speed =
9776
		dev_priv->display.get_display_clock_speed =
8744
			i915gm_get_display_clock_speed;
9777
			i915gm_get_display_clock_speed;
8745
	else if (IS_I865G(dev))
9778
	else if (IS_I865G(dev))
8746
		dev_priv->display.get_display_clock_speed =
9779
		dev_priv->display.get_display_clock_speed =
Line 8815... Line 9848...
8815
	struct drm_i915_private *dev_priv = dev->dev_private;
9848
	struct drm_i915_private *dev_priv = dev->dev_private;
8816
	dev_priv->quirks |= QUIRK_INVERT_BRIGHTNESS;
9849
	dev_priv->quirks |= QUIRK_INVERT_BRIGHTNESS;
8817
	DRM_INFO("applying inverted panel brightness quirk\n");
9850
	DRM_INFO("applying inverted panel brightness quirk\n");
8818
}
9851
}
Line -... Line 9852...
-
 
9852
 
-
 
9853
/*
-
 
9854
 * Some machines (Dell XPS13) suffer broken backlight controls if
-
 
9855
 * BLM_PCH_PWM_ENABLE is set.
-
 
9856
 */
-
 
9857
static void quirk_no_pcm_pwm_enable(struct drm_device *dev)
-
 
9858
{
-
 
9859
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
9860
	dev_priv->quirks |= QUIRK_NO_PCH_PWM_ENABLE;
-
 
9861
	DRM_INFO("applying no-PCH_PWM_ENABLE quirk\n");
-
 
9862
}
8819
 
9863
 
8820
struct intel_quirk {
9864
struct intel_quirk {
8821
	int device;
9865
	int device;
8822
	int subsystem_vendor;
9866
	int subsystem_vendor;
8823
	int subsystem_device;
9867
	int subsystem_device;
Line 8884... Line 9928...
8884
	/* Acer/Packard Bell NCL20 */
9928
	/* Acer/Packard Bell NCL20 */
8885
	{ 0x2a42, 0x1025, 0x034b, quirk_invert_brightness },
9929
	{ 0x2a42, 0x1025, 0x034b, quirk_invert_brightness },
Line 8886... Line 9930...
8886
 
9930
 
8887
	/* Acer Aspire 4736Z */
9931
	/* Acer Aspire 4736Z */
-
 
9932
	{ 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
-
 
9933
 
-
 
9934
	/* Dell XPS13 HD Sandy Bridge */
-
 
9935
	{ 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
-
 
9936
	/* Dell XPS13 HD and XPS13 FHD Ivy Bridge */
8888
	{ 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
9937
	{ 0x0166, 0x1028, 0x058b, quirk_no_pcm_pwm_enable },
Line 8889... Line 9938...
8889
};
9938
};
8890
 
9939
 
8891
static void intel_init_quirks(struct drm_device *dev)
9940
static void intel_init_quirks(struct drm_device *dev)
Line 8978... Line 10027...
8978
 
10027
 
8979
	DRM_DEBUG_KMS("%d display pipe%s available.\n",
10028
	DRM_DEBUG_KMS("%d display pipe%s available.\n",
8980
		      INTEL_INFO(dev)->num_pipes,
10029
		      INTEL_INFO(dev)->num_pipes,
Line 8981... Line 10030...
8981
		      INTEL_INFO(dev)->num_pipes > 1 ? "s" : "");
10030
		      INTEL_INFO(dev)->num_pipes > 1 ? "s" : "");
8982
 
10031
 
8983
	for (i = 0; i < INTEL_INFO(dev)->num_pipes; i++) {
10032
	for_each_pipe(i) {
8984
		intel_crtc_init(dev, i);
10033
		intel_crtc_init(dev, i);
8985
		for (j = 0; j < dev_priv->num_plane; j++) {
10034
		for (j = 0; j < dev_priv->num_plane; j++) {
8986
			ret = intel_plane_init(dev, i, j);
10035
			ret = intel_plane_init(dev, i, j);
8987
		if (ret)
10036
		if (ret)
8988
				DRM_DEBUG_KMS("pipe %d plane %d init failed: %d\n",
10037
				DRM_DEBUG_KMS("pipe %c sprite %c init failed: %d\n",
8989
					      i, j, ret);
10038
					      pipe_name(i), sprite_name(i, j), ret);
Line 8990... Line 10039...
8990
		}
10039
		}
8991
	}
10040
	}
Line 8992... Line 10041...
8992
 
10041
 
8993
	intel_cpu_pll_init(dev);
10042
	intel_cpu_pll_init(dev);
8994
	intel_pch_pll_init(dev);
10043
	intel_shared_dpll_init(dev);
Line 9184... Line 10233...
9184
void i915_redisable_vga(struct drm_device *dev)
10233
void i915_redisable_vga(struct drm_device *dev)
9185
{
10234
{
9186
	struct drm_i915_private *dev_priv = dev->dev_private;
10235
	struct drm_i915_private *dev_priv = dev->dev_private;
9187
	u32 vga_reg = i915_vgacntrl_reg(dev);
10236
	u32 vga_reg = i915_vgacntrl_reg(dev);
Line -... Line 10237...
-
 
10237
 
-
 
10238
	/* This function can be called both from intel_modeset_setup_hw_state or
-
 
10239
	 * at a very early point in our resume sequence, where the power well
-
 
10240
	 * structures are not yet restored. Since this function is at a very
-
 
10241
	 * paranoid "someone might have enabled VGA while we were not looking"
-
 
10242
	 * level, just check if the power well is enabled instead of trying to
-
 
10243
	 * follow the "don't touch the power well if we don't need it" policy
-
 
10244
	 * the rest of the driver uses. */
-
 
10245
	if (HAS_POWER_WELL(dev) &&
-
 
10246
	    (I915_READ(HSW_PWR_WELL_DRIVER) & HSW_PWR_WELL_STATE_ENABLED) == 0)
-
 
10247
		return;
9188
 
10248
 
9189
	if (I915_READ(vga_reg) != VGA_DISP_DISABLE) {
10249
	if (I915_READ(vga_reg) != VGA_DISP_DISABLE) {
9190
		DRM_DEBUG_KMS("Something enabled VGA plane, disabling it\n");
10250
		DRM_DEBUG_KMS("Something enabled VGA plane, disabling it\n");
9191
		i915_disable_vga(dev);
10251
		i915_disable_vga(dev);
9192
	}
10252
	}
Line 9193... Line -...
9193
}
-
 
9194
 
-
 
9195
/* Scan out the current hw modeset state, sanitizes it and maps it into the drm
10253
}
9196
 * and i915 state tracking structures. */
-
 
9197
void intel_modeset_setup_hw_state(struct drm_device *dev,
10254
 
9198
				  bool force_restore)
10255
static void intel_modeset_readout_hw_state(struct drm_device *dev)
9199
{
10256
{
9200
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
9201
	enum pipe pipe;
-
 
9202
	u32 tmp;
10257
	struct drm_i915_private *dev_priv = dev->dev_private;
9203
	struct drm_plane *plane;
10258
	enum pipe pipe;
9204
	struct intel_crtc *crtc;
10259
	struct intel_crtc *crtc;
-
 
10260
	struct intel_encoder *encoder;
Line 9205... Line -...
9205
	struct intel_encoder *encoder;
-
 
9206
	struct intel_connector *connector;
-
 
9207
 
-
 
9208
	if (HAS_DDI(dev)) {
-
 
9209
		tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP));
-
 
9210
 
-
 
9211
		if (tmp & TRANS_DDI_FUNC_ENABLE) {
-
 
9212
			switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
-
 
9213
			case TRANS_DDI_EDP_INPUT_A_ON:
-
 
9214
			case TRANS_DDI_EDP_INPUT_A_ONOFF:
-
 
9215
				pipe = PIPE_A;
-
 
9216
				break;
-
 
9217
			case TRANS_DDI_EDP_INPUT_B_ONOFF:
-
 
9218
				pipe = PIPE_B;
-
 
9219
				break;
-
 
9220
			case TRANS_DDI_EDP_INPUT_C_ONOFF:
-
 
9221
				pipe = PIPE_C;
-
 
9222
				break;
-
 
9223
			default:
-
 
9224
				/* A bogus value has been programmed, disable
-
 
9225
				 * the transcoder */
-
 
9226
				WARN(1, "Bogus eDP source %08x\n", tmp);
-
 
9227
				intel_ddi_disable_transcoder_func(dev_priv,
-
 
9228
						TRANSCODER_EDP);
-
 
9229
				goto setup_pipes;
-
 
9230
			}
-
 
9231
 
-
 
9232
			crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-
 
9233
			crtc->config.cpu_transcoder = TRANSCODER_EDP;
-
 
9234
 
-
 
9235
			DRM_DEBUG_KMS("Pipe %c using transcoder EDP\n",
-
 
9236
				      pipe_name(pipe));
-
 
9237
		}
-
 
9238
	}
10261
	struct intel_connector *connector;
9239
 
10262
	int i;
9240
setup_pipes:
-
 
9241
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
10263
 
9242
			    base.head) {
-
 
Line 9243... Line 10264...
9243
		enum transcoder tmp = crtc->config.cpu_transcoder;
10264
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
9244
		memset(&crtc->config, 0, sizeof(crtc->config));
10265
			    base.head) {
Line 9245... Line 10266...
9245
		crtc->config.cpu_transcoder = tmp;
10266
		memset(&crtc->config, 0, sizeof(crtc->config));
Line 9252... Line 10273...
9252
		DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
10273
		DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
9253
			      crtc->base.base.id,
10274
			      crtc->base.base.id,
9254
			      crtc->active ? "enabled" : "disabled");
10275
			      crtc->active ? "enabled" : "disabled");
9255
	}
10276
	}
Line -... Line 10277...
-
 
10277
 
9256
 
10278
	/* FIXME: Smash this into the new shared dpll infrastructure. */
9257
	if (HAS_DDI(dev))
10279
	if (HAS_DDI(dev))
Line -... Line 10280...
-
 
10280
		intel_ddi_setup_hw_pll_state(dev);
-
 
10281
 
-
 
10282
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-
 
10283
		struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
-
 
10284
 
-
 
10285
		pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state);
-
 
10286
		pll->active = 0;
-
 
10287
		list_for_each_entry(crtc, &dev->mode_config.crtc_list,
-
 
10288
				    base.head) {
-
 
10289
			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
-
 
10290
				pll->active++;
-
 
10291
		}
-
 
10292
		pll->refcount = pll->active;
-
 
10293
 
-
 
10294
		DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n",
-
 
10295
			      pll->name, pll->refcount, pll->on);
9258
		intel_ddi_setup_hw_pll_state(dev);
10296
	}
9259
 
10297
 
9260
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
10298
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
Line 9261... Line 10299...
9261
			    base.head) {
10299
			    base.head) {
-
 
10300
		pipe = 0;
9262
		pipe = 0;
10301
 
-
 
10302
		if (encoder->get_hw_state(encoder, &pipe)) {
9263
 
10303
			crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
9264
		if (encoder->get_hw_state(encoder, &pipe)) {
10304
			encoder->base.crtc = &crtc->base;
9265
			encoder->base.crtc =
10305
			if (encoder->get_config)
9266
				dev_priv->pipe_to_crtc_mapping[pipe];
10306
				encoder->get_config(encoder, &crtc->config);
Line 9267... Line 10307...
9267
		} else {
10307
		} else {
Line 9274... Line 10314...
9274
			      drm_get_encoder_name(&encoder->base),
10314
			      drm_get_encoder_name(&encoder->base),
9275
			      encoder->base.crtc ? "enabled" : "disabled",
10315
			      encoder->base.crtc ? "enabled" : "disabled",
9276
			      pipe);
10316
			      pipe);
9277
	}
10317
	}
Line -... Line 10318...
-
 
10318
 
-
 
10319
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
-
 
10320
			    base.head) {
-
 
10321
		if (!crtc->active)
-
 
10322
			continue;
-
 
10323
		if (dev_priv->display.get_clock)
-
 
10324
			dev_priv->display.get_clock(crtc,
-
 
10325
						    &crtc->config);
-
 
10326
	}
9278
 
10327
 
9279
	list_for_each_entry(connector, &dev->mode_config.connector_list,
10328
	list_for_each_entry(connector, &dev->mode_config.connector_list,
9280
			    base.head) {
10329
			    base.head) {
9281
		if (connector->get_hw_state(connector)) {
10330
		if (connector->get_hw_state(connector)) {
9282
			connector->base.dpms = DRM_MODE_DPMS_ON;
10331
			connector->base.dpms = DRM_MODE_DPMS_ON;
Line 9289... Line 10338...
9289
		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] hw state readout: %s\n",
10338
		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] hw state readout: %s\n",
9290
			      connector->base.base.id,
10339
			      connector->base.base.id,
9291
			      drm_get_connector_name(&connector->base),
10340
			      drm_get_connector_name(&connector->base),
9292
			      connector->base.encoder ? "enabled" : "disabled");
10341
			      connector->base.encoder ? "enabled" : "disabled");
9293
	}
10342
	}
-
 
10343
}
-
 
10344
 
-
 
10345
/* Scan out the current hw modeset state, sanitizes it and maps it into the drm
-
 
10346
 * and i915 state tracking structures. */
-
 
10347
void intel_modeset_setup_hw_state(struct drm_device *dev,
-
 
10348
				  bool force_restore)
-
 
10349
{
-
 
10350
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
10351
	enum pipe pipe;
-
 
10352
	struct drm_plane *plane;
-
 
10353
	struct intel_crtc *crtc;
-
 
10354
	struct intel_encoder *encoder;
-
 
10355
	int i;
-
 
10356
 
-
 
10357
	intel_modeset_readout_hw_state(dev);
-
 
10358
 
-
 
10359
	/*
-
 
10360
	 * Now that we have the config, copy it to each CRTC struct
-
 
10361
	 * Note that this could go away if we move to using crtc_config
-
 
10362
	 * checking everywhere.
-
 
10363
	 */
-
 
10364
	list_for_each_entry(crtc, &dev->mode_config.crtc_list,
-
 
10365
			    base.head) {
-
 
10366
		if (crtc->active && i915_fastboot) {
-
 
10367
			intel_crtc_mode_from_pipe_config(crtc, &crtc->config);
-
 
10368
 
-
 
10369
			DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
-
 
10370
				      crtc->base.base.id);
-
 
10371
			drm_mode_debug_printmodeline(&crtc->base.mode);
-
 
10372
		}
-
 
10373
	}
Line 9294... Line 10374...
9294
 
10374
 
9295
	/* HW state is read out, now we need to sanitize this mess. */
10375
	/* HW state is read out, now we need to sanitize this mess. */
9296
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
10376
	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
9297
			    base.head) {
10377
			    base.head) {
9298
		intel_sanitize_encoder(encoder);
10378
		intel_sanitize_encoder(encoder);
Line 9299... Line 10379...
9299
	}
10379
	}
9300
 
10380
 
9301
	for_each_pipe(pipe) {
10381
	for_each_pipe(pipe) {
-
 
10382
		crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-
 
10383
		intel_sanitize_crtc(crtc);
-
 
10384
		intel_dump_pipe_config(crtc, &crtc->config, "[setup_hw_state]");
-
 
10385
	}
-
 
10386
 
-
 
10387
	for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-
 
10388
		struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
-
 
10389
 
-
 
10390
		if (!pll->on || pll->active)
-
 
10391
			continue;
-
 
10392
 
-
 
10393
		DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", pll->name);
-
 
10394
 
9302
		crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
10395
		pll->disable(dev_priv, pll);
Line 9303... Line 10396...
9303
		intel_sanitize_crtc(crtc);
10396
		pll->on = false;
9304
	}
10397
	}
9305
 
10398
 
Line 9340... Line 10433...
9340
void intel_modeset_cleanup(struct drm_device *dev)
10433
void intel_modeset_cleanup(struct drm_device *dev)
9341
{
10434
{
9342
#if 0
10435
#if 0
9343
	struct drm_i915_private *dev_priv = dev->dev_private;
10436
	struct drm_i915_private *dev_priv = dev->dev_private;
9344
	struct drm_crtc *crtc;
10437
	struct drm_crtc *crtc;
9345
	struct intel_crtc *intel_crtc;
-
 
Line -... Line 10438...
-
 
10438
 
-
 
10439
	/*
-
 
10440
	 * Interrupts and polling as the first thing to avoid creating havoc.
-
 
10441
	 * Too much stuff here (turning of rps, connectors, ...) would
-
 
10442
	 * experience fancy races otherwise.
-
 
10443
	 */
-
 
10444
	drm_irq_uninstall(dev);
-
 
10445
	cancel_work_sync(&dev_priv->hotplug_work);
-
 
10446
	/*
-
 
10447
	 * Due to the hpd irq storm handling the hotplug work can re-arm the
-
 
10448
	 * poll handlers. Hence disable polling after hpd handling is shut down.
9346
 
10449
	 */
-
 
10450
//   drm_kms_helper_poll_fini(dev);
9347
//   drm_kms_helper_poll_fini(dev);
10451
 
Line 9348... Line 10452...
9348
	mutex_lock(&dev->struct_mutex);
10452
	mutex_lock(&dev->struct_mutex);
Line 9349... Line -...
9349
 
-
 
9350
//   intel_unregister_dsm_handler();
10453
 
9351
 
10454
//   intel_unregister_dsm_handler();
9352
 
10455
 
9353
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
10456
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
Line 9354... Line -...
9354
		/* Skip inactive CRTCs */
-
 
9355
		if (!crtc->fb)
10457
		/* Skip inactive CRTCs */
9356
			continue;
10458
		if (!crtc->fb)
Line 9357... Line 10459...
9357
 
10459
			continue;
Line 9358... Line 10460...
9358
		intel_crtc = to_intel_crtc(crtc);
10460
 
Line 9359... Line 10461...
9359
		intel_increase_pllclock(crtc);
10461
		intel_increase_pllclock(crtc);
Line 9360... Line -...
9360
	}
-
 
9361
 
-
 
9362
	intel_disable_fbc(dev);
-
 
9363
 
10462
	}
Line 9364... Line -...
9364
	intel_disable_gt_powersave(dev);
-
 
9365
 
10463
 
9366
	ironlake_teardown_rc6(dev);
10464
	intel_disable_fbc(dev);
9367
 
10465
 
9368
	if (IS_VALLEYVIEW(dev))
10466
	intel_disable_gt_powersave(dev);
Line 9369... Line 10467...
9369
		vlv_init_dpio(dev);
10467
 
9370
 
10468
	ironlake_teardown_rc6(dev);
Line 9418... Line 10516...
9418
 
10516
 
9419
#ifdef CONFIG_DEBUG_FS
10517
#ifdef CONFIG_DEBUG_FS
Line 9420... Line 10518...
9420
#include 
10518
#include 
-
 
10519
 
-
 
10520
struct intel_display_error_state {
-
 
10521
 
-
 
10522
	u32 power_well_driver;
-
 
10523
 
9421
 
10524
	int num_transcoders;
9422
struct intel_display_error_state {
10525
 
9423
	struct intel_cursor_error_state {
10526
	struct intel_cursor_error_state {
9424
		u32 control;
10527
		u32 control;
9425
		u32 position;
10528
		u32 position;
9426
		u32 base;
10529
		u32 base;
Line 9427... Line 10530...
9427
		u32 size;
10530
		u32 size;
9428
	} cursor[I915_MAX_PIPES];
-
 
9429
 
10531
	} cursor[I915_MAX_PIPES];
9430
	struct intel_pipe_error_state {
-
 
9431
		u32 conf;
-
 
9432
		u32 source;
-
 
9433
 
-
 
9434
		u32 htotal;
-
 
9435
		u32 hblank;
-
 
9436
		u32 hsync;
-
 
9437
		u32 vtotal;
10532
 
Line 9438... Line 10533...
9438
		u32 vblank;
10533
	struct intel_pipe_error_state {
9439
		u32 vsync;
10534
		u32 source;
9440
	} pipe[I915_MAX_PIPES];
10535
	} pipe[I915_MAX_PIPES];
Line 9446... Line 10541...
9446
		u32 pos;
10541
		u32 pos;
9447
		u32 addr;
10542
		u32 addr;
9448
		u32 surface;
10543
		u32 surface;
9449
		u32 tile_offset;
10544
		u32 tile_offset;
9450
	} plane[I915_MAX_PIPES];
10545
	} plane[I915_MAX_PIPES];
-
 
10546
 
-
 
10547
	struct intel_transcoder_error_state {
-
 
10548
		enum transcoder cpu_transcoder;
-
 
10549
 
-
 
10550
		u32 conf;
-
 
10551
 
-
 
10552
		u32 htotal;
-
 
10553
		u32 hblank;
-
 
10554
		u32 hsync;
-
 
10555
		u32 vtotal;
-
 
10556
		u32 vblank;
-
 
10557
		u32 vsync;
-
 
10558
	} transcoder[4];
9451
};
10559
};
Line 9452... Line 10560...
9452
 
10560
 
9453
struct intel_display_error_state *
10561
struct intel_display_error_state *
9454
intel_display_capture_error_state(struct drm_device *dev)
10562
intel_display_capture_error_state(struct drm_device *dev)
9455
{
10563
{
9456
	drm_i915_private_t *dev_priv = dev->dev_private;
10564
	drm_i915_private_t *dev_priv = dev->dev_private;
9457
	struct intel_display_error_state *error;
10565
	struct intel_display_error_state *error;
-
 
10566
	int transcoders[] = {
-
 
10567
		TRANSCODER_A,
-
 
10568
		TRANSCODER_B,
-
 
10569
		TRANSCODER_C,
-
 
10570
		TRANSCODER_EDP,
9458
	enum transcoder cpu_transcoder;
10571
	};
Line -... Line 10572...
-
 
10572
	int i;
-
 
10573
 
-
 
10574
	if (INTEL_INFO(dev)->num_pipes == 0)
9459
	int i;
10575
		return NULL;
9460
 
10576
 
9461
	error = kmalloc(sizeof(*error), GFP_ATOMIC);
10577
	error = kmalloc(sizeof(*error), GFP_ATOMIC);
Line 9462... Line 10578...
9462
	if (error == NULL)
10578
	if (error == NULL)
9463
		return NULL;
10579
		return NULL;
Line -... Line 10580...
-
 
10580
 
9464
 
10581
	if (HAS_POWER_WELL(dev))
9465
	for_each_pipe(i) {
10582
		error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER);
9466
		cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, i);
10583
 
9467
 
10584
	for_each_pipe(i) {
9468
		if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) {
10585
		if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) {
Line 9486... Line 10603...
9486
		if (INTEL_INFO(dev)->gen >= 4) {
10603
		if (INTEL_INFO(dev)->gen >= 4) {
9487
			error->plane[i].surface = I915_READ(DSPSURF(i));
10604
			error->plane[i].surface = I915_READ(DSPSURF(i));
9488
			error->plane[i].tile_offset = I915_READ(DSPTILEOFF(i));
10605
			error->plane[i].tile_offset = I915_READ(DSPTILEOFF(i));
9489
		}
10606
		}
Line 9490... Line -...
9490
 
-
 
9491
		error->pipe[i].conf = I915_READ(PIPECONF(cpu_transcoder));
10607
 
9492
		error->pipe[i].source = I915_READ(PIPESRC(i));
-
 
9493
		error->pipe[i].htotal = I915_READ(HTOTAL(cpu_transcoder));
-
 
9494
		error->pipe[i].hblank = I915_READ(HBLANK(cpu_transcoder));
-
 
9495
		error->pipe[i].hsync = I915_READ(HSYNC(cpu_transcoder));
-
 
9496
		error->pipe[i].vtotal = I915_READ(VTOTAL(cpu_transcoder));
-
 
9497
		error->pipe[i].vblank = I915_READ(VBLANK(cpu_transcoder));
-
 
9498
		error->pipe[i].vsync = I915_READ(VSYNC(cpu_transcoder));
10608
		error->pipe[i].source = I915_READ(PIPESRC(i));
Line -... Line 10609...
-
 
10609
	}
-
 
10610
 
-
 
10611
	error->num_transcoders = INTEL_INFO(dev)->num_pipes;
-
 
10612
	if (HAS_DDI(dev_priv->dev))
-
 
10613
		error->num_transcoders++; /* Account for eDP. */
-
 
10614
 
-
 
10615
	for (i = 0; i < error->num_transcoders; i++) {
-
 
10616
		enum transcoder cpu_transcoder = transcoders[i];
-
 
10617
 
-
 
10618
		error->transcoder[i].cpu_transcoder = cpu_transcoder;
-
 
10619
 
-
 
10620
		error->transcoder[i].conf = I915_READ(PIPECONF(cpu_transcoder));
-
 
10621
		error->transcoder[i].htotal = I915_READ(HTOTAL(cpu_transcoder));
-
 
10622
		error->transcoder[i].hblank = I915_READ(HBLANK(cpu_transcoder));
-
 
10623
		error->transcoder[i].hsync = I915_READ(HSYNC(cpu_transcoder));
-
 
10624
		error->transcoder[i].vtotal = I915_READ(VTOTAL(cpu_transcoder));
-
 
10625
		error->transcoder[i].vblank = I915_READ(VBLANK(cpu_transcoder));
-
 
10626
		error->transcoder[i].vsync = I915_READ(VSYNC(cpu_transcoder));
-
 
10627
	}
-
 
10628
 
-
 
10629
	/* In the code above we read the registers without checking if the power
-
 
10630
	 * well was on, so here we have to clear the FPGA_DBG_RM_NOCLAIM bit to
-
 
10631
	 * prevent the next I915_WRITE from detecting it and printing an error
-
 
10632
	 * message. */
9499
	}
10633
	intel_uncore_clear_errors(dev);
9500
 
10634
 
Line -... Line 10635...
-
 
10635
	return error;
-
 
10636
}
9501
	return error;
10637
 
9502
}
10638
#define err_printf(e, ...) i915_error_printf(e, __VA_ARGS__)
9503
 
10639
 
9504
void
10640
void
9505
intel_display_print_error_state(struct seq_file *m,
10641
intel_display_print_error_state(struct drm_i915_error_state_buf *m,
9506
				struct drm_device *dev,
10642
				struct drm_device *dev,
Line -... Line 10643...
-
 
10643
				struct intel_display_error_state *error)
-
 
10644
{
-
 
10645
	int i;
9507
				struct intel_display_error_state *error)
10646
 
-
 
10647
	if (!error)
-
 
10648
		return;
-
 
10649
 
9508
{
10650
	err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes);
9509
	int i;
10651
	if (HAS_POWER_WELL(dev))
9510
 
-
 
9511
	seq_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes);
10652
		err_printf(m, "PWR_WELL_CTL2: %08x\n",
9512
	for_each_pipe(i) {
-
 
9513
		seq_printf(m, "Pipe [%d]:\n", i);
-
 
9514
		seq_printf(m, "  CONF: %08x\n", error->pipe[i].conf);
-
 
9515
		seq_printf(m, "  SRC: %08x\n", error->pipe[i].source);
-
 
9516
		seq_printf(m, "  HTOTAL: %08x\n", error->pipe[i].htotal);
-
 
9517
		seq_printf(m, "  HBLANK: %08x\n", error->pipe[i].hblank);
-
 
9518
		seq_printf(m, "  HSYNC: %08x\n", error->pipe[i].hsync);
10653
			   error->power_well_driver);
9519
		seq_printf(m, "  VTOTAL: %08x\n", error->pipe[i].vtotal);
10654
	for_each_pipe(i) {
9520
		seq_printf(m, "  VBLANK: %08x\n", error->pipe[i].vblank);
10655
		err_printf(m, "Pipe [%d]:\n", i);
9521
		seq_printf(m, "  VSYNC: %08x\n", error->pipe[i].vsync);
10656
		err_printf(m, "  SRC: %08x\n", error->pipe[i].source);
9522
 
10657
 
9523
		seq_printf(m, "Plane [%d]:\n", i);
10658
		err_printf(m, "Plane [%d]:\n", i);
9524
		seq_printf(m, "  CNTR: %08x\n", error->plane[i].control);
10659
		err_printf(m, "  CNTR: %08x\n", error->plane[i].control);
9525
		seq_printf(m, "  STRIDE: %08x\n", error->plane[i].stride);
10660
		err_printf(m, "  STRIDE: %08x\n", error->plane[i].stride);
9526
		if (INTEL_INFO(dev)->gen <= 3) {
10661
		if (INTEL_INFO(dev)->gen <= 3) {
9527
		seq_printf(m, "  SIZE: %08x\n", error->plane[i].size);
10662
			err_printf(m, "  SIZE: %08x\n", error->plane[i].size);
9528
		seq_printf(m, "  POS: %08x\n", error->plane[i].pos);
10663
			err_printf(m, "  POS: %08x\n", error->plane[i].pos);
9529
		}
10664
		}
9530
		if (INTEL_INFO(dev)->gen <= 7 && !IS_HASWELL(dev))
10665
		if (INTEL_INFO(dev)->gen <= 7 && !IS_HASWELL(dev))
9531
		seq_printf(m, "  ADDR: %08x\n", error->plane[i].addr);
10666
			err_printf(m, "  ADDR: %08x\n", error->plane[i].addr);
Line 9532... Line 10667...
9532
		if (INTEL_INFO(dev)->gen >= 4) {
10667
		if (INTEL_INFO(dev)->gen >= 4) {
9533
			seq_printf(m, "  SURF: %08x\n", error->plane[i].surface);
10668
			err_printf(m, "  SURF: %08x\n", error->plane[i].surface);
9534
			seq_printf(m, "  TILEOFF: %08x\n", error->plane[i].tile_offset);
10669
			err_printf(m, "  TILEOFF: %08x\n", error->plane[i].tile_offset);
9535
		}
10670
		}
-
 
10671
 
-
 
10672
		err_printf(m, "Cursor [%d]:\n", i);
-
 
10673
		err_printf(m, "  CNTR: %08x\n", error->cursor[i].control);
-
 
10674
		err_printf(m, "  POS: %08x\n", error->cursor[i].position);
-
 
10675
		err_printf(m, "  BASE: %08x\n", error->cursor[i].base);
-
 
10676
	}
-
 
10677
 
-
 
10678
	for (i = 0; i < error->num_transcoders; i++) {
-
 
10679
		err_printf(m, "  CPU transcoder: %c\n",
-
 
10680
			   transcoder_name(error->transcoder[i].cpu_transcoder));
-
 
10681
		err_printf(m, "  CONF: %08x\n", error->transcoder[i].conf);
-
 
10682
		err_printf(m, "  HTOTAL: %08x\n", error->transcoder[i].htotal);
9536
 
10683
		err_printf(m, "  HBLANK: %08x\n", error->transcoder[i].hblank);
9537
		seq_printf(m, "Cursor [%d]:\n", i);
10684
		err_printf(m, "  HSYNC: %08x\n", error->transcoder[i].hsync);
9538
		seq_printf(m, "  CNTR: %08x\n", error->cursor[i].control);
10685
		err_printf(m, "  VTOTAL: %08x\n", error->transcoder[i].vtotal);