Rev 1430 | Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1430 | Rev 1963 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * Alex Deucher |
24 | * Alex Deucher |
25 | */ |
25 | */ |
26 | #include |
26 | #include |
27 | #include |
27 | #include |
28 | #include |
28 | #include |
29 | #include "radeon_fixed.h" |
29 | #include |
30 | #include "radeon.h" |
30 | #include "radeon.h" |
31 | #include "atom.h" |
31 | #include "atom.h" |
32 | #include "atom-bits.h" |
32 | #include "atom-bits.h" |
Line 33... | Line 33... | ||
33 | 33 | ||
Line 42... | Line 42... | ||
42 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_OverScan); |
42 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_OverScan); |
43 | int a1, a2; |
43 | int a1, a2; |
Line 44... | Line 44... | ||
44 | 44 | ||
Line 45... | Line -... | ||
45 | memset(&args, 0, sizeof(args)); |
- | |
46 | - | ||
47 | args.usOverscanRight = 0; |
- | |
48 | args.usOverscanLeft = 0; |
- | |
49 | args.usOverscanBottom = 0; |
45 | memset(&args, 0, sizeof(args)); |
Line 50... | Line 46... | ||
50 | args.usOverscanTop = 0; |
46 | |
51 | args.ucCRTC = radeon_crtc->crtc_id; |
47 | args.ucCRTC = radeon_crtc->crtc_id; |
52 | 48 | ||
53 | switch (radeon_crtc->rmx_type) { |
49 | switch (radeon_crtc->rmx_type) { |
54 | case RMX_CENTER: |
50 | case RMX_CENTER: |
55 | args.usOverscanTop = (adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2; |
51 | args.usOverscanTop = cpu_to_le16((adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2); |
56 | args.usOverscanBottom = (adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2; |
- | |
57 | args.usOverscanLeft = (adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2; |
52 | args.usOverscanBottom = cpu_to_le16((adjusted_mode->crtc_vdisplay - mode->crtc_vdisplay) / 2); |
58 | args.usOverscanRight = (adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2; |
53 | args.usOverscanLeft = cpu_to_le16((adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2); |
59 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
54 | args.usOverscanRight = cpu_to_le16((adjusted_mode->crtc_hdisplay - mode->crtc_hdisplay) / 2); |
60 | break; |
55 | break; |
Line 61... | Line 56... | ||
61 | case RMX_ASPECT: |
56 | case RMX_ASPECT: |
62 | a1 = mode->crtc_vdisplay * adjusted_mode->crtc_hdisplay; |
57 | a1 = mode->crtc_vdisplay * adjusted_mode->crtc_hdisplay; |
63 | a2 = adjusted_mode->crtc_vdisplay * mode->crtc_hdisplay; |
58 | a2 = adjusted_mode->crtc_vdisplay * mode->crtc_hdisplay; |
64 | 59 | ||
65 | if (a1 > a2) { |
60 | if (a1 > a2) { |
66 | args.usOverscanLeft = (adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2; |
61 | args.usOverscanLeft = cpu_to_le16((adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2); |
67 | args.usOverscanRight = (adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2; |
62 | args.usOverscanRight = cpu_to_le16((adjusted_mode->crtc_hdisplay - (a2 / mode->crtc_vdisplay)) / 2); |
68 | } else if (a2 > a1) { |
- | |
69 | args.usOverscanLeft = (adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2; |
63 | } else if (a2 > a1) { |
70 | args.usOverscanRight = (adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2; |
64 | args.usOverscanTop = cpu_to_le16((adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2); |
71 | } |
65 | args.usOverscanBottom = cpu_to_le16((adjusted_mode->crtc_vdisplay - (a1 / mode->crtc_hdisplay)) / 2); |
72 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
66 | } |
73 | break; |
67 | break; |
74 | case RMX_FULL: |
68 | case RMX_FULL: |
75 | default: |
69 | default: |
76 | args.usOverscanRight = 0; |
- | |
77 | args.usOverscanLeft = 0; |
70 | args.usOverscanRight = cpu_to_le16(radeon_crtc->h_border); |
78 | args.usOverscanBottom = 0; |
71 | args.usOverscanLeft = cpu_to_le16(radeon_crtc->h_border); |
- | 72 | args.usOverscanBottom = cpu_to_le16(radeon_crtc->v_border); |
|
79 | args.usOverscanTop = 0; |
73 | args.usOverscanTop = cpu_to_le16(radeon_crtc->v_border); |
Line 80... | Line 74... | ||
80 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
74 | break; |
81 | break; |
75 | } |
82 | } |
76 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Line 243... | Line 237... | ||
243 | struct radeon_device *rdev = dev->dev_private; |
237 | struct radeon_device *rdev = dev->dev_private; |
244 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
238 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
Line 245... | Line 239... | ||
245 | 239 | ||
246 | switch (mode) { |
240 | switch (mode) { |
- | 241 | case DRM_MODE_DPMS_ON: |
|
- | 242 | radeon_crtc->enabled = true; |
|
- | 243 | /* adjust pm to dpms changes BEFORE enabling crtcs */ |
|
247 | case DRM_MODE_DPMS_ON: |
244 | radeon_pm_compute_clocks(rdev); |
248 | atombios_enable_crtc(crtc, ATOM_ENABLE); |
245 | atombios_enable_crtc(crtc, ATOM_ENABLE); |
249 | if (ASIC_IS_DCE3(rdev)) |
246 | if (ASIC_IS_DCE3(rdev)) |
250 | atombios_enable_crtc_memreq(crtc, ATOM_ENABLE); |
247 | atombios_enable_crtc_memreq(crtc, ATOM_ENABLE); |
251 | atombios_blank_crtc(crtc, ATOM_DISABLE); |
- | |
252 | /* XXX re-enable when interrupt support is added */ |
- | |
253 | if (!ASIC_IS_DCE4(rdev)) |
248 | atombios_blank_crtc(crtc, ATOM_DISABLE); |
254 | drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); |
249 | drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); |
255 | radeon_crtc_load_lut(crtc); |
250 | radeon_crtc_load_lut(crtc); |
256 | break; |
251 | break; |
257 | case DRM_MODE_DPMS_STANDBY: |
252 | case DRM_MODE_DPMS_STANDBY: |
258 | case DRM_MODE_DPMS_SUSPEND: |
253 | case DRM_MODE_DPMS_SUSPEND: |
259 | case DRM_MODE_DPMS_OFF: |
- | |
260 | /* XXX re-enable when interrupt support is added */ |
- | |
261 | if (!ASIC_IS_DCE4(rdev)) |
254 | case DRM_MODE_DPMS_OFF: |
- | 255 | drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); |
|
262 | drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); |
256 | if (radeon_crtc->enabled) |
263 | atombios_blank_crtc(crtc, ATOM_ENABLE); |
257 | atombios_blank_crtc(crtc, ATOM_ENABLE); |
264 | if (ASIC_IS_DCE3(rdev)) |
258 | if (ASIC_IS_DCE3(rdev)) |
265 | atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); |
259 | atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); |
- | 260 | atombios_enable_crtc(crtc, ATOM_DISABLE); |
|
- | 261 | radeon_crtc->enabled = false; |
|
- | 262 | /* adjust pm to dpms changes AFTER disabling crtcs */ |
|
266 | atombios_enable_crtc(crtc, ATOM_DISABLE); |
263 | radeon_pm_compute_clocks(rdev); |
267 | break; |
264 | break; |
268 | } |
265 | } |
Line 269... | Line 266... | ||
269 | } |
266 | } |
Line 278... | Line 275... | ||
278 | SET_CRTC_USING_DTD_TIMING_PARAMETERS args; |
275 | SET_CRTC_USING_DTD_TIMING_PARAMETERS args; |
279 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_UsingDTDTiming); |
276 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_UsingDTDTiming); |
280 | u16 misc = 0; |
277 | u16 misc = 0; |
Line 281... | Line 278... | ||
281 | 278 | ||
282 | memset(&args, 0, sizeof(args)); |
279 | memset(&args, 0, sizeof(args)); |
283 | args.usH_Size = cpu_to_le16(mode->crtc_hdisplay); |
280 | args.usH_Size = cpu_to_le16(mode->crtc_hdisplay - (radeon_crtc->h_border * 2)); |
284 | args.usH_Blanking_Time = |
281 | args.usH_Blanking_Time = |
285 | cpu_to_le16(mode->crtc_hblank_end - mode->crtc_hdisplay); |
282 | cpu_to_le16(mode->crtc_hblank_end - mode->crtc_hdisplay + (radeon_crtc->h_border * 2)); |
286 | args.usV_Size = cpu_to_le16(mode->crtc_vdisplay); |
283 | args.usV_Size = cpu_to_le16(mode->crtc_vdisplay - (radeon_crtc->v_border * 2)); |
287 | args.usV_Blanking_Time = |
284 | args.usV_Blanking_Time = |
288 | cpu_to_le16(mode->crtc_vblank_end - mode->crtc_vdisplay); |
285 | cpu_to_le16(mode->crtc_vblank_end - mode->crtc_vdisplay + (radeon_crtc->v_border * 2)); |
289 | args.usH_SyncOffset = |
286 | args.usH_SyncOffset = |
290 | cpu_to_le16(mode->crtc_hsync_start - mode->crtc_hdisplay); |
287 | cpu_to_le16(mode->crtc_hsync_start - mode->crtc_hdisplay + radeon_crtc->h_border); |
291 | args.usH_SyncWidth = |
288 | args.usH_SyncWidth = |
292 | cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start); |
289 | cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start); |
293 | args.usV_SyncOffset = |
290 | args.usV_SyncOffset = |
294 | cpu_to_le16(mode->crtc_vsync_start - mode->crtc_vdisplay); |
291 | cpu_to_le16(mode->crtc_vsync_start - mode->crtc_vdisplay + radeon_crtc->v_border); |
295 | args.usV_SyncWidth = |
292 | args.usV_SyncWidth = |
296 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
293 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
297 | /*args.ucH_Border = mode->hborder;*/ |
294 | args.ucH_Border = radeon_crtc->h_border; |
Line 298... | Line 295... | ||
298 | /*args.ucV_Border = mode->vborder;*/ |
295 | args.ucV_Border = radeon_crtc->v_border; |
299 | 296 | ||
300 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
297 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
301 | misc |= ATOM_VSYNC_POLARITY; |
298 | misc |= ATOM_VSYNC_POLARITY; |
Line 334... | Line 331... | ||
334 | args.usV_Disp = cpu_to_le16(mode->crtc_vdisplay); |
331 | args.usV_Disp = cpu_to_le16(mode->crtc_vdisplay); |
335 | args.usV_SyncStart = cpu_to_le16(mode->crtc_vsync_start); |
332 | args.usV_SyncStart = cpu_to_le16(mode->crtc_vsync_start); |
336 | args.usV_SyncWidth = |
333 | args.usV_SyncWidth = |
337 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
334 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
Line -... | Line 335... | ||
- | 335 | ||
- | 336 | args.ucOverscanRight = radeon_crtc->h_border; |
|
- | 337 | args.ucOverscanLeft = radeon_crtc->h_border; |
|
- | 338 | args.ucOverscanBottom = radeon_crtc->v_border; |
|
- | 339 | args.ucOverscanTop = radeon_crtc->v_border; |
|
338 | 340 | ||
339 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
341 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
340 | misc |= ATOM_VSYNC_POLARITY; |
342 | misc |= ATOM_VSYNC_POLARITY; |
341 | if (mode->flags & DRM_MODE_FLAG_NHSYNC) |
343 | if (mode->flags & DRM_MODE_FLAG_NHSYNC) |
342 | misc |= ATOM_HSYNC_POLARITY; |
344 | misc |= ATOM_HSYNC_POLARITY; |
Line 351... | Line 353... | ||
351 | args.ucCRTC = radeon_crtc->crtc_id; |
353 | args.ucCRTC = radeon_crtc->crtc_id; |
Line 352... | Line 354... | ||
352 | 354 | ||
353 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
355 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Line -... | Line 356... | ||
- | 356 | } |
|
- | 357 | ||
- | 358 | static void atombios_disable_ss(struct drm_crtc *crtc) |
|
- | 359 | { |
|
- | 360 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 361 | struct drm_device *dev = crtc->dev; |
|
- | 362 | struct radeon_device *rdev = dev->dev_private; |
|
- | 363 | u32 ss_cntl; |
|
- | 364 | ||
- | 365 | if (ASIC_IS_DCE4(rdev)) { |
|
- | 366 | switch (radeon_crtc->pll_id) { |
|
- | 367 | case ATOM_PPLL1: |
|
- | 368 | ss_cntl = RREG32(EVERGREEN_P1PLL_SS_CNTL); |
|
- | 369 | ss_cntl &= ~EVERGREEN_PxPLL_SS_EN; |
|
- | 370 | WREG32(EVERGREEN_P1PLL_SS_CNTL, ss_cntl); |
|
- | 371 | break; |
|
- | 372 | case ATOM_PPLL2: |
|
- | 373 | ss_cntl = RREG32(EVERGREEN_P2PLL_SS_CNTL); |
|
- | 374 | ss_cntl &= ~EVERGREEN_PxPLL_SS_EN; |
|
- | 375 | WREG32(EVERGREEN_P2PLL_SS_CNTL, ss_cntl); |
|
- | 376 | break; |
|
- | 377 | case ATOM_DCPLL: |
|
- | 378 | case ATOM_PPLL_INVALID: |
|
- | 379 | return; |
|
- | 380 | } |
|
- | 381 | } else if (ASIC_IS_AVIVO(rdev)) { |
|
- | 382 | switch (radeon_crtc->pll_id) { |
|
- | 383 | case ATOM_PPLL1: |
|
- | 384 | ss_cntl = RREG32(AVIVO_P1PLL_INT_SS_CNTL); |
|
- | 385 | ss_cntl &= ~1; |
|
- | 386 | WREG32(AVIVO_P1PLL_INT_SS_CNTL, ss_cntl); |
|
- | 387 | break; |
|
- | 388 | case ATOM_PPLL2: |
|
- | 389 | ss_cntl = RREG32(AVIVO_P2PLL_INT_SS_CNTL); |
|
- | 390 | ss_cntl &= ~1; |
|
- | 391 | WREG32(AVIVO_P2PLL_INT_SS_CNTL, ss_cntl); |
|
- | 392 | break; |
|
- | 393 | case ATOM_DCPLL: |
|
- | 394 | case ATOM_PPLL_INVALID: |
|
- | 395 | return; |
|
- | 396 | } |
|
- | 397 | } |
|
- | 398 | } |
|
354 | } |
399 | |
355 | 400 | ||
- | 401 | union atom_enable_ss { |
|
356 | union atom_enable_ss { |
402 | ENABLE_LVDS_SS_PARAMETERS lvds_ss; |
- | 403 | ENABLE_LVDS_SS_PARAMETERS_V2 lvds_ss_2; |
|
- | 404 | ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION v1; |
|
357 | ENABLE_LVDS_SS_PARAMETERS legacy; |
405 | ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2 v2; |
Line 358... | Line 406... | ||
358 | ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION v1; |
406 | ENABLE_SPREAD_SPECTRUM_ON_PPLL_V3 v3; |
- | 407 | }; |
|
- | 408 | ||
- | 409 | static void atombios_crtc_program_ss(struct drm_crtc *crtc, |
|
359 | }; |
410 | int enable, |
360 | - | ||
361 | static void atombios_set_ss(struct drm_crtc *crtc, int enable) |
411 | int pll_id, |
362 | { |
412 | struct radeon_atom_ss *ss) |
363 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
- | |
364 | struct drm_device *dev = crtc->dev; |
- | |
365 | struct radeon_device *rdev = dev->dev_private; |
- | |
366 | struct drm_encoder *encoder = NULL; |
413 | { |
367 | struct radeon_encoder *radeon_encoder = NULL; |
414 | struct drm_device *dev = crtc->dev; |
368 | struct radeon_encoder_atom_dig *dig = NULL; |
- | |
369 | int index = GetIndexIntoMasterTable(COMMAND, EnableSpreadSpectrumOnPPLL); |
- | |
Line 370... | Line 415... | ||
370 | union atom_enable_ss args; |
415 | struct radeon_device *rdev = dev->dev_private; |
371 | uint16_t percentage = 0; |
- | |
372 | uint8_t type = 0, step = 0, delay = 0, range = 0; |
- | |
Line 373... | Line -... | ||
373 | - | ||
374 | /* XXX add ss support for DCE4 */ |
416 | int index = GetIndexIntoMasterTable(COMMAND, EnableSpreadSpectrumOnPPLL); |
375 | if (ASIC_IS_DCE4(rdev)) |
417 | union atom_enable_ss args; |
376 | return; |
- | |
377 | 418 | ||
378 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
- | |
379 | if (encoder->crtc == crtc) { |
419 | memset(&args, 0, sizeof(args)); |
380 | radeon_encoder = to_radeon_encoder(encoder); |
- | |
381 | /* only enable spread spectrum on LVDS */ |
420 | |
382 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
421 | if (ASIC_IS_DCE5(rdev)) { |
383 | dig = radeon_encoder->enc_priv; |
422 | args.v3.usSpreadSpectrumAmountFrac = cpu_to_le16(0); |
384 | if (dig && dig->ss) { |
423 | args.v3.ucSpreadSpectrumType = ss->type & ATOM_SS_CENTRE_SPREAD_MODE_MASK; |
385 | percentage = dig->ss->percentage; |
- | |
386 | type = dig->ss->type; |
- | |
387 | step = dig->ss->step; |
- | |
388 | delay = dig->ss->delay; |
- | |
389 | range = dig->ss->range; |
424 | switch (pll_id) { |
- | 425 | case ATOM_PPLL1: |
|
- | 426 | args.v3.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V3_P1PLL; |
|
- | 427 | args.v3.usSpreadSpectrumAmount = cpu_to_le16(ss->amount); |
|
- | 428 | args.v3.usSpreadSpectrumStep = cpu_to_le16(ss->step); |
|
- | 429 | break; |
|
- | 430 | case ATOM_PPLL2: |
|
- | 431 | args.v3.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V3_P2PLL; |
|
- | 432 | args.v3.usSpreadSpectrumAmount = cpu_to_le16(ss->amount); |
|
- | 433 | args.v3.usSpreadSpectrumStep = cpu_to_le16(ss->step); |
|
- | 434 | break; |
|
- | 435 | case ATOM_DCPLL: |
|
- | 436 | args.v3.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V3_DCPLL; |
|
390 | } else if (enable) |
437 | args.v3.usSpreadSpectrumAmount = cpu_to_le16(0); |
- | 438 | args.v3.usSpreadSpectrumStep = cpu_to_le16(0); |
|
- | 439 | break; |
|
- | 440 | case ATOM_PPLL_INVALID: |
|
- | 441 | return; |
|
- | 442 | } |
|
- | 443 | args.v3.ucEnable = enable; |
|
- | 444 | if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK)) |
|
- | 445 | args.v3.ucEnable = ATOM_DISABLE; |
|
- | 446 | } else if (ASIC_IS_DCE4(rdev)) { |
|
- | 447 | args.v2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); |
|
- | 448 | args.v2.ucSpreadSpectrumType = ss->type & ATOM_SS_CENTRE_SPREAD_MODE_MASK; |
|
391 | return; |
449 | switch (pll_id) { |
- | 450 | case ATOM_PPLL1: |
|
- | 451 | args.v2.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V2_P1PLL; |
|
- | 452 | args.v2.usSpreadSpectrumAmount = cpu_to_le16(ss->amount); |
|
- | 453 | args.v2.usSpreadSpectrumStep = cpu_to_le16(ss->step); |
|
392 | } else if (enable) |
454 | break; |
- | 455 | case ATOM_PPLL2: |
|
- | 456 | args.v2.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V2_P2PLL; |
|
- | 457 | args.v2.usSpreadSpectrumAmount = cpu_to_le16(ss->amount); |
|
- | 458 | args.v2.usSpreadSpectrumStep = cpu_to_le16(ss->step); |
|
- | 459 | break; |
|
393 | return; |
460 | case ATOM_DCPLL: |
394 | break; |
461 | args.v2.ucSpreadSpectrumType |= ATOM_PPLL_SS_TYPE_V2_DCPLL; |
395 | } |
462 | args.v2.usSpreadSpectrumAmount = cpu_to_le16(0); |
396 | } |
463 | args.v2.usSpreadSpectrumStep = cpu_to_le16(0); |
- | 464 | break; |
|
- | 465 | case ATOM_PPLL_INVALID: |
|
397 | 466 | return; |
|
398 | if (!radeon_encoder) |
467 | } |
399 | return; |
468 | args.v2.ucEnable = enable; |
400 | 469 | if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK)) |
|
401 | memset(&args, 0, sizeof(args)); |
470 | args.v2.ucEnable = ATOM_DISABLE; |
402 | if (ASIC_IS_AVIVO(rdev)) { |
471 | } else if (ASIC_IS_DCE3(rdev)) { |
403 | args.v1.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
472 | args.v1.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); |
404 | args.v1.ucSpreadSpectrumType = type; |
473 | args.v1.ucSpreadSpectrumType = ss->type & ATOM_SS_CENTRE_SPREAD_MODE_MASK; |
- | 474 | args.v1.ucSpreadSpectrumStep = ss->step; |
|
- | 475 | args.v1.ucSpreadSpectrumDelay = ss->delay; |
|
- | 476 | args.v1.ucSpreadSpectrumRange = ss->range; |
|
- | 477 | args.v1.ucPpll = pll_id; |
|
- | 478 | args.v1.ucEnable = enable; |
|
- | 479 | } else if (ASIC_IS_AVIVO(rdev)) { |
|
- | 480 | if ((enable == ATOM_DISABLE) || (ss->percentage == 0) || |
|
- | 481 | (ss->type & ATOM_EXTERNAL_SS_MASK)) { |
|
- | 482 | atombios_disable_ss(crtc); |
|
- | 483 | return; |
|
- | 484 | } |
|
- | 485 | args.lvds_ss_2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); |
|
405 | args.v1.ucSpreadSpectrumStep = step; |
486 | args.lvds_ss_2.ucSpreadSpectrumType = ss->type & ATOM_SS_CENTRE_SPREAD_MODE_MASK; |
- | 487 | args.lvds_ss_2.ucSpreadSpectrumStep = ss->step; |
|
- | 488 | args.lvds_ss_2.ucSpreadSpectrumDelay = ss->delay; |
|
- | 489 | args.lvds_ss_2.ucSpreadSpectrumRange = ss->range; |
|
- | 490 | args.lvds_ss_2.ucEnable = enable; |
|
- | 491 | } else { |
|
406 | args.v1.ucSpreadSpectrumDelay = delay; |
492 | if ((enable == ATOM_DISABLE) || (ss->percentage == 0) || |
407 | args.v1.ucSpreadSpectrumRange = range; |
493 | (ss->type & ATOM_EXTERNAL_SS_MASK)) { |
408 | args.v1.ucPpll = radeon_crtc->crtc_id ? ATOM_PPLL2 : ATOM_PPLL1; |
494 | atombios_disable_ss(crtc); |
409 | args.v1.ucEnable = enable; |
495 | return; |
410 | } else { |
496 | } |
411 | args.legacy.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
497 | args.lvds_ss.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); |
412 | args.legacy.ucSpreadSpectrumType = type; |
498 | args.lvds_ss.ucSpreadSpectrumType = ss->type & ATOM_SS_CENTRE_SPREAD_MODE_MASK; |
413 | args.legacy.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; |
499 | args.lvds_ss.ucSpreadSpectrumStepSize_Delay = (ss->step & 3) << 2; |
Line 414... | Line 500... | ||
414 | args.legacy.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; |
500 | args.lvds_ss.ucSpreadSpectrumStepSize_Delay |= (ss->delay & 7) << 4; |
Line 422... | Line 508... | ||
422 | ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3 v3; |
508 | ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3 v3; |
423 | }; |
509 | }; |
Line 424... | Line 510... | ||
424 | 510 | ||
425 | static u32 atombios_adjust_pll(struct drm_crtc *crtc, |
511 | static u32 atombios_adjust_pll(struct drm_crtc *crtc, |
426 | struct drm_display_mode *mode, |
512 | struct drm_display_mode *mode, |
- | 513 | struct radeon_pll *pll, |
|
- | 514 | bool ss_enabled, |
|
427 | struct radeon_pll *pll) |
515 | struct radeon_atom_ss *ss) |
428 | { |
516 | { |
429 | struct drm_device *dev = crtc->dev; |
517 | struct drm_device *dev = crtc->dev; |
430 | struct radeon_device *rdev = dev->dev_private; |
518 | struct radeon_device *rdev = dev->dev_private; |
431 | struct drm_encoder *encoder = NULL; |
519 | struct drm_encoder *encoder = NULL; |
- | 520 | struct radeon_encoder *radeon_encoder = NULL; |
|
432 | struct radeon_encoder *radeon_encoder = NULL; |
521 | struct drm_connector *connector = NULL; |
433 | u32 adjusted_clock = mode->clock; |
522 | u32 adjusted_clock = mode->clock; |
- | 523 | int encoder_mode = 0; |
|
- | 524 | u32 dp_clock = mode->clock; |
|
Line 434... | Line 525... | ||
434 | int encoder_mode = 0; |
525 | int bpc = 8; |
435 | 526 | ||
Line 436... | Line -... | ||
436 | /* reset the pll flags */ |
- | |
437 | pll->flags = 0; |
- | |
438 | - | ||
439 | /* select the PLL algo */ |
- | |
440 | if (ASIC_IS_AVIVO(rdev)) { |
- | |
441 | if (radeon_new_pll == 0) |
- | |
442 | pll->algo = PLL_ALGO_LEGACY; |
- | |
443 | else |
- | |
444 | pll->algo = PLL_ALGO_NEW; |
- | |
445 | } else { |
- | |
446 | if (radeon_new_pll == 1) |
- | |
447 | pll->algo = PLL_ALGO_NEW; |
- | |
448 | else |
- | |
449 | pll->algo = PLL_ALGO_LEGACY; |
527 | /* reset the pll flags */ |
450 | } |
528 | pll->flags = 0; |
451 | 529 | ||
452 | if (ASIC_IS_AVIVO(rdev)) { |
530 | if (ASIC_IS_AVIVO(rdev)) { |
453 | if ((rdev->family == CHIP_RS600) || |
531 | if ((rdev->family == CHIP_RS600) || |
454 | (rdev->family == CHIP_RS690) || |
532 | (rdev->family == CHIP_RS690) || |
Line 455... | Line 533... | ||
455 | (rdev->family == CHIP_RS740)) |
533 | (rdev->family == CHIP_RS740)) |
456 | pll->flags |= (RADEON_PLL_USE_FRAC_FB_DIV | |
534 | pll->flags |= (/*RADEON_PLL_USE_FRAC_FB_DIV |*/ |
457 | RADEON_PLL_PREFER_CLOSEST_LOWER); |
535 | RADEON_PLL_PREFER_CLOSEST_LOWER); |
458 | 536 | ||
- | 537 | if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */ |
|
- | 538 | pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; |
|
- | 539 | else |
|
459 | if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */ |
540 | pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV; |
460 | pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; |
541 | |
Line 461... | Line 542... | ||
461 | else |
542 | if (rdev->family < CHIP_RV770) |
462 | pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV; |
543 | pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP; |
463 | } else { |
544 | } else { |
464 | pll->flags |= RADEON_PLL_LEGACY; |
545 | pll->flags |= RADEON_PLL_LEGACY; |
465 | - | ||
466 | if (mode->clock > 200000) /* range limits??? */ |
546 | |
Line 467... | Line 547... | ||
467 | pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; |
547 | if (mode->clock > 200000) /* range limits??? */ |
468 | else |
548 | pll->flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; |
469 | pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV; |
549 | else |
- | 550 | pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV; |
|
- | 551 | } |
|
- | 552 | ||
470 | 553 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
|
- | 554 | if (encoder->crtc == crtc) { |
|
- | 555 | radeon_encoder = to_radeon_encoder(encoder); |
|
- | 556 | connector = radeon_get_connector_for_encoder(encoder); |
|
- | 557 | if (connector) |
|
- | 558 | bpc = connector->display_info.bpc; |
|
- | 559 | encoder_mode = atombios_get_encoder_mode(encoder); |
|
- | 560 | if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) || |
|
- | 561 | radeon_encoder_is_dp_bridge(encoder)) { |
|
- | 562 | if (connector) { |
|
- | 563 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
|
- | 564 | struct radeon_connector_atom_dig *dig_connector = |
|
- | 565 | radeon_connector->con_priv; |
|
- | 566 | ||
- | 567 | dp_clock = dig_connector->dp_clock; |
|
- | 568 | } |
|
- | 569 | } |
|
- | 570 | ||
- | 571 | /* use recommended ref_div for ss */ |
|
- | 572 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
|
- | 573 | if (ss_enabled) { |
|
- | 574 | if (ss->refdiv) { |
|
- | 575 | pll->flags |= RADEON_PLL_USE_REF_DIV; |
|
- | 576 | pll->reference_div = ss->refdiv; |
|
471 | } |
577 | if (ASIC_IS_AVIVO(rdev)) |
472 | 578 | pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV; |
|
473 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
579 | } |
474 | if (encoder->crtc == crtc) { |
580 | } |
475 | radeon_encoder = to_radeon_encoder(encoder); |
581 | } |
476 | encoder_mode = atombios_get_encoder_mode(encoder); |
582 | |
477 | if (ASIC_IS_AVIVO(rdev)) { |
583 | if (ASIC_IS_AVIVO(rdev)) { |
478 | /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */ |
584 | /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */ |
479 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1) |
- | |
480 | adjusted_clock = mode->clock * 2; |
585 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1) |
481 | /* LVDS PLL quirks */ |
586 | adjusted_clock = mode->clock * 2; |
482 | if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) { |
587 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
483 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
588 | pll->flags |= RADEON_PLL_PREFER_CLOSEST_LOWER; |
484 | pll->algo = dig->pll_algo; |
589 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) |
Line 501... | Line 606... | ||
501 | union adjust_pixel_clock args; |
606 | union adjust_pixel_clock args; |
502 | u8 frev, crev; |
607 | u8 frev, crev; |
503 | int index; |
608 | int index; |
Line 504... | Line 609... | ||
504 | 609 | ||
505 | index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll); |
610 | index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll); |
506 | atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
611 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
- | 612 | &crev)) |
|
Line 507... | Line 613... | ||
507 | &crev); |
613 | return adjusted_clock; |
Line 508... | Line 614... | ||
508 | 614 | ||
509 | memset(&args, 0, sizeof(args)); |
615 | memset(&args, 0, sizeof(args)); |
Line 514... | Line 620... | ||
514 | case 1: |
620 | case 1: |
515 | case 2: |
621 | case 2: |
516 | args.v1.usPixelClock = cpu_to_le16(mode->clock / 10); |
622 | args.v1.usPixelClock = cpu_to_le16(mode->clock / 10); |
517 | args.v1.ucTransmitterID = radeon_encoder->encoder_id; |
623 | args.v1.ucTransmitterID = radeon_encoder->encoder_id; |
518 | args.v1.ucEncodeMode = encoder_mode; |
624 | args.v1.ucEncodeMode = encoder_mode; |
- | 625 | if (ss_enabled && ss->percentage) |
|
- | 626 | args.v1.ucConfig |= |
|
- | 627 | ADJUST_DISPLAY_CONFIG_SS_ENABLE; |
|
Line 519... | Line 628... | ||
519 | 628 | ||
520 | atom_execute_table(rdev->mode_info.atom_context, |
629 | atom_execute_table(rdev->mode_info.atom_context, |
521 | index, (uint32_t *)&args); |
630 | index, (uint32_t *)&args); |
522 | adjusted_clock = le16_to_cpu(args.v1.usPixelClock) * 10; |
631 | adjusted_clock = le16_to_cpu(args.v1.usPixelClock) * 10; |
523 | break; |
632 | break; |
524 | case 3: |
633 | case 3: |
525 | args.v3.sInput.usPixelClock = cpu_to_le16(mode->clock / 10); |
634 | args.v3.sInput.usPixelClock = cpu_to_le16(mode->clock / 10); |
526 | args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id; |
635 | args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id; |
527 | args.v3.sInput.ucEncodeMode = encoder_mode; |
636 | args.v3.sInput.ucEncodeMode = encoder_mode; |
- | 637 | args.v3.sInput.ucDispPllConfig = 0; |
|
- | 638 | if (ss_enabled && ss->percentage) |
|
- | 639 | args.v3.sInput.ucDispPllConfig |= |
|
528 | args.v3.sInput.ucDispPllConfig = 0; |
640 | DISPPLL_CONFIG_SS_ENABLE; |
- | 641 | if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT) || |
|
529 | if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { |
642 | radeon_encoder_is_dp_bridge(encoder)) { |
530 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
- | |
531 | 643 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
|
532 | if (encoder_mode == ATOM_ENCODER_MODE_DP) |
644 | if (encoder_mode == ATOM_ENCODER_MODE_DP) { |
533 | args.v3.sInput.ucDispPllConfig |= |
645 | args.v3.sInput.ucDispPllConfig |= |
- | 646 | DISPPLL_CONFIG_COHERENT_MODE; |
|
- | 647 | /* 16200 or 27000 */ |
|
534 | DISPPLL_CONFIG_COHERENT_MODE; |
648 | args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10); |
- | 649 | } else { |
|
- | 650 | if (encoder_mode == ATOM_ENCODER_MODE_HDMI) { |
|
- | 651 | /* deep color support */ |
|
- | 652 | args.v3.sInput.usPixelClock = |
|
- | 653 | cpu_to_le16((mode->clock * bpc / 8) / 10); |
|
535 | else { |
654 | } |
536 | if (dig->coherent_mode) |
655 | if (dig->coherent_mode) |
537 | args.v3.sInput.ucDispPllConfig |= |
656 | args.v3.sInput.ucDispPllConfig |= |
538 | DISPPLL_CONFIG_COHERENT_MODE; |
657 | DISPPLL_CONFIG_COHERENT_MODE; |
539 | if (mode->clock > 165000) |
658 | if (mode->clock > 165000) |
540 | args.v3.sInput.ucDispPllConfig |= |
659 | args.v3.sInput.ucDispPllConfig |= |
541 | DISPPLL_CONFIG_DUAL_LINK; |
660 | DISPPLL_CONFIG_DUAL_LINK; |
542 | } |
661 | } |
543 | } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
662 | } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
544 | /* may want to enable SS on DP/eDP eventually */ |
663 | if (encoder_mode == ATOM_ENCODER_MODE_DP) { |
545 | args.v3.sInput.ucDispPllConfig |= |
664 | args.v3.sInput.ucDispPllConfig |= |
- | 665 | DISPPLL_CONFIG_COHERENT_MODE; |
|
- | 666 | /* 16200 or 27000 */ |
|
- | 667 | args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10); |
|
546 | DISPPLL_CONFIG_SS_ENABLE; |
668 | } else if (encoder_mode != ATOM_ENCODER_MODE_LVDS) { |
547 | if (mode->clock > 165000) |
669 | if (mode->clock > 165000) |
548 | args.v3.sInput.ucDispPllConfig |= |
670 | args.v3.sInput.ucDispPllConfig |= |
549 | DISPPLL_CONFIG_DUAL_LINK; |
671 | DISPPLL_CONFIG_DUAL_LINK; |
- | 672 | } |
|
550 | } |
673 | } |
551 | atom_execute_table(rdev->mode_info.atom_context, |
674 | atom_execute_table(rdev->mode_info.atom_context, |
552 | index, (uint32_t *)&args); |
675 | index, (uint32_t *)&args); |
553 | adjusted_clock = le32_to_cpu(args.v3.sOutput.ulDispPllFreq) * 10; |
676 | adjusted_clock = le32_to_cpu(args.v3.sOutput.ulDispPllFreq) * 10; |
- | 677 | if (args.v3.sOutput.ucRefDiv) { |
|
554 | if (args.v3.sOutput.ucRefDiv) { |
678 | pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV; |
555 | pll->flags |= RADEON_PLL_USE_REF_DIV; |
679 | pll->flags |= RADEON_PLL_USE_REF_DIV; |
556 | pll->reference_div = args.v3.sOutput.ucRefDiv; |
680 | pll->reference_div = args.v3.sOutput.ucRefDiv; |
557 | } |
681 | } |
- | 682 | if (args.v3.sOutput.ucPostDiv) { |
|
558 | if (args.v3.sOutput.ucPostDiv) { |
683 | pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV; |
559 | pll->flags |= RADEON_PLL_USE_POST_DIV; |
684 | pll->flags |= RADEON_PLL_USE_POST_DIV; |
560 | pll->post_div = args.v3.sOutput.ucPostDiv; |
685 | pll->post_div = args.v3.sOutput.ucPostDiv; |
561 | } |
686 | } |
562 | break; |
687 | break; |
Line 577... | Line 702... | ||
577 | SET_PIXEL_CLOCK_PS_ALLOCATION base; |
702 | SET_PIXEL_CLOCK_PS_ALLOCATION base; |
578 | PIXEL_CLOCK_PARAMETERS v1; |
703 | PIXEL_CLOCK_PARAMETERS v1; |
579 | PIXEL_CLOCK_PARAMETERS_V2 v2; |
704 | PIXEL_CLOCK_PARAMETERS_V2 v2; |
580 | PIXEL_CLOCK_PARAMETERS_V3 v3; |
705 | PIXEL_CLOCK_PARAMETERS_V3 v3; |
581 | PIXEL_CLOCK_PARAMETERS_V5 v5; |
706 | PIXEL_CLOCK_PARAMETERS_V5 v5; |
- | 707 | PIXEL_CLOCK_PARAMETERS_V6 v6; |
|
582 | }; |
708 | }; |
Line -... | Line 709... | ||
- | 709 | ||
- | 710 | /* on DCE5, make sure the voltage is high enough to support the |
|
- | 711 | * required disp clk. |
|
583 | 712 | */ |
|
- | 713 | static void atombios_crtc_set_dcpll(struct drm_crtc *crtc, |
|
584 | static void atombios_crtc_set_dcpll(struct drm_crtc *crtc) |
714 | u32 dispclk) |
585 | { |
715 | { |
586 | struct drm_device *dev = crtc->dev; |
716 | struct drm_device *dev = crtc->dev; |
587 | struct radeon_device *rdev = dev->dev_private; |
717 | struct radeon_device *rdev = dev->dev_private; |
588 | u8 frev, crev; |
718 | u8 frev, crev; |
589 | int index; |
719 | int index; |
Line 590... | Line 720... | ||
590 | union set_pixel_clock args; |
720 | union set_pixel_clock args; |
Line 591... | Line 721... | ||
591 | 721 | ||
592 | memset(&args, 0, sizeof(args)); |
722 | memset(&args, 0, sizeof(args)); |
593 | 723 | ||
- | 724 | index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
|
Line 594... | Line 725... | ||
594 | index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
725 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
595 | atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
726 | &crev)) |
596 | &crev); |
727 | return; |
597 | 728 | ||
598 | switch (frev) { |
729 | switch (frev) { |
599 | case 1: |
730 | case 1: |
600 | switch (crev) { |
731 | switch (crev) { |
601 | case 5: |
732 | case 5: |
602 | /* if the default dcpll clock is specified, |
733 | /* if the default dcpll clock is specified, |
603 | * SetPixelClock provides the dividers |
734 | * SetPixelClock provides the dividers |
604 | */ |
735 | */ |
- | 736 | args.v5.ucCRTC = ATOM_CRTC_INVALID; |
|
- | 737 | args.v5.usPixelClock = cpu_to_le16(dispclk); |
|
- | 738 | args.v5.ucPpll = ATOM_DCPLL; |
|
- | 739 | break; |
|
- | 740 | case 6: |
|
- | 741 | /* if the default dcpll clock is specified, |
|
- | 742 | * SetPixelClock provides the dividers |
|
605 | args.v5.ucCRTC = ATOM_CRTC_INVALID; |
743 | */ |
606 | args.v5.usPixelClock = rdev->clock.default_dispclk; |
744 | args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk); |
607 | args.v5.ucPpll = ATOM_DCPLL; |
745 | args.v6.ucPpll = ATOM_DCPLL; |
608 | break; |
746 | break; |
609 | default: |
747 | default: |
Line 616... | Line 754... | ||
616 | return; |
754 | return; |
617 | } |
755 | } |
618 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
756 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
619 | } |
757 | } |
Line 620... | Line 758... | ||
620 | 758 | ||
- | 759 | static void atombios_crtc_program_pll(struct drm_crtc *crtc, |
|
- | 760 | int crtc_id, |
|
- | 761 | int pll_id, |
|
- | 762 | u32 encoder_mode, |
|
- | 763 | u32 encoder_id, |
|
- | 764 | u32 clock, |
|
- | 765 | u32 ref_div, |
|
- | 766 | u32 fb_div, |
|
- | 767 | u32 frac_fb_div, |
|
- | 768 | u32 post_div, |
|
- | 769 | int bpc, |
|
- | 770 | bool ss_enabled, |
|
621 | static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode) |
771 | struct radeon_atom_ss *ss) |
622 | { |
- | |
623 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
772 | { |
624 | struct drm_device *dev = crtc->dev; |
773 | struct drm_device *dev = crtc->dev; |
625 | struct radeon_device *rdev = dev->dev_private; |
- | |
626 | struct drm_encoder *encoder = NULL; |
- | |
627 | struct radeon_encoder *radeon_encoder = NULL; |
774 | struct radeon_device *rdev = dev->dev_private; |
628 | u8 frev, crev; |
775 | u8 frev, crev; |
629 | int index; |
776 | int index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
630 | union set_pixel_clock args; |
- | |
631 | u32 pll_clock = mode->clock; |
- | |
632 | u32 ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; |
- | |
633 | struct radeon_pll *pll; |
- | |
634 | u32 adjusted_clock; |
- | |
Line 635... | Line 777... | ||
635 | int encoder_mode = 0; |
777 | union set_pixel_clock args; |
Line 636... | Line 778... | ||
636 | 778 | ||
637 | memset(&args, 0, sizeof(args)); |
- | |
638 | - | ||
639 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
- | |
640 | if (encoder->crtc == crtc) { |
779 | memset(&args, 0, sizeof(args)); |
641 | radeon_encoder = to_radeon_encoder(encoder); |
- | |
642 | encoder_mode = atombios_get_encoder_mode(encoder); |
- | |
643 | break; |
- | |
644 | } |
- | |
645 | } |
780 | |
Line 646... | Line -... | ||
646 | - | ||
647 | if (!radeon_encoder) |
- | |
648 | return; |
- | |
649 | - | ||
650 | switch (radeon_crtc->pll_id) { |
- | |
651 | case ATOM_PPLL1: |
- | |
652 | pll = &rdev->clock.p1pll; |
- | |
653 | break; |
- | |
654 | case ATOM_PPLL2: |
- | |
655 | pll = &rdev->clock.p2pll; |
- | |
656 | break; |
- | |
657 | case ATOM_DCPLL: |
- | |
658 | case ATOM_PPLL_INVALID: |
- | |
659 | pll = &rdev->clock.dcpll; |
- | |
660 | break; |
- | |
661 | } |
- | |
662 | - | ||
663 | /* adjust pixel clock as needed */ |
- | |
664 | adjusted_clock = atombios_adjust_pll(crtc, mode, pll); |
- | |
665 | - | ||
666 | radeon_compute_pll(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, |
- | |
667 | &ref_div, &post_div); |
- | |
668 | - | ||
669 | index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
781 | if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
670 | atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
782 | &crev)) |
671 | &crev); |
783 | return; |
672 | 784 | ||
- | 785 | switch (frev) { |
|
- | 786 | case 1: |
|
673 | switch (frev) { |
787 | switch (crev) { |
674 | case 1: |
788 | case 1: |
675 | switch (crev) { |
789 | if (clock == ATOM_DISABLE) |
676 | case 1: |
790 | return; |
677 | args.v1.usPixelClock = cpu_to_le16(mode->clock / 10); |
791 | args.v1.usPixelClock = cpu_to_le16(clock / 10); |
678 | args.v1.usRefDiv = cpu_to_le16(ref_div); |
792 | args.v1.usRefDiv = cpu_to_le16(ref_div); |
679 | args.v1.usFbDiv = cpu_to_le16(fb_div); |
793 | args.v1.usFbDiv = cpu_to_le16(fb_div); |
680 | args.v1.ucFracFbDiv = frac_fb_div; |
794 | args.v1.ucFracFbDiv = frac_fb_div; |
681 | args.v1.ucPostDiv = post_div; |
795 | args.v1.ucPostDiv = post_div; |
682 | args.v1.ucPpll = radeon_crtc->pll_id; |
796 | args.v1.ucPpll = pll_id; |
683 | args.v1.ucCRTC = radeon_crtc->crtc_id; |
797 | args.v1.ucCRTC = crtc_id; |
684 | args.v1.ucRefDivSrc = 1; |
798 | args.v1.ucRefDivSrc = 1; |
685 | break; |
799 | break; |
686 | case 2: |
800 | case 2: |
687 | args.v2.usPixelClock = cpu_to_le16(mode->clock / 10); |
801 | args.v2.usPixelClock = cpu_to_le16(clock / 10); |
688 | args.v2.usRefDiv = cpu_to_le16(ref_div); |
802 | args.v2.usRefDiv = cpu_to_le16(ref_div); |
689 | args.v2.usFbDiv = cpu_to_le16(fb_div); |
803 | args.v2.usFbDiv = cpu_to_le16(fb_div); |
690 | args.v2.ucFracFbDiv = frac_fb_div; |
804 | args.v2.ucFracFbDiv = frac_fb_div; |
691 | args.v2.ucPostDiv = post_div; |
805 | args.v2.ucPostDiv = post_div; |
692 | args.v2.ucPpll = radeon_crtc->pll_id; |
806 | args.v2.ucPpll = pll_id; |
693 | args.v2.ucCRTC = radeon_crtc->crtc_id; |
807 | args.v2.ucCRTC = crtc_id; |
694 | args.v2.ucRefDivSrc = 1; |
808 | args.v2.ucRefDivSrc = 1; |
695 | break; |
809 | break; |
696 | case 3: |
810 | case 3: |
697 | args.v3.usPixelClock = cpu_to_le16(mode->clock / 10); |
811 | args.v3.usPixelClock = cpu_to_le16(clock / 10); |
698 | args.v3.usRefDiv = cpu_to_le16(ref_div); |
812 | args.v3.usRefDiv = cpu_to_le16(ref_div); |
699 | args.v3.usFbDiv = cpu_to_le16(fb_div); |
813 | args.v3.usFbDiv = cpu_to_le16(fb_div); |
- | 814 | args.v3.ucFracFbDiv = frac_fb_div; |
|
- | 815 | args.v3.ucPostDiv = post_div; |
|
700 | args.v3.ucFracFbDiv = frac_fb_div; |
816 | args.v3.ucPpll = pll_id; |
701 | args.v3.ucPostDiv = post_div; |
817 | args.v3.ucMiscInfo = (pll_id << 2); |
702 | args.v3.ucPpll = radeon_crtc->pll_id; |
818 | if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK)) |
703 | args.v3.ucMiscInfo = (radeon_crtc->pll_id << 2); |
819 | args.v3.ucMiscInfo |= PIXEL_CLOCK_MISC_REF_DIV_SRC; |
704 | args.v3.ucTransmitterId = radeon_encoder->encoder_id; |
820 | args.v3.ucTransmitterId = encoder_id; |
705 | args.v3.ucEncoderMode = encoder_mode; |
821 | args.v3.ucEncoderMode = encoder_mode; |
706 | break; |
822 | break; |
707 | case 5: |
823 | case 5: |
708 | args.v5.ucCRTC = radeon_crtc->crtc_id; |
824 | args.v5.ucCRTC = crtc_id; |
709 | args.v5.usPixelClock = cpu_to_le16(mode->clock / 10); |
825 | args.v5.usPixelClock = cpu_to_le16(clock / 10); |
710 | args.v5.ucRefDiv = ref_div; |
826 | args.v5.ucRefDiv = ref_div; |
- | 827 | args.v5.usFbDiv = cpu_to_le16(fb_div); |
|
- | 828 | args.v5.ulFbDivDecFrac = cpu_to_le32(frac_fb_div * 100000); |
|
- | 829 | args.v5.ucPostDiv = post_div; |
|
- | 830 | args.v5.ucMiscInfo = 0; /* HDMI depth, etc. */ |
|
- | 831 | if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK)) |
|
- | 832 | args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_REF_DIV_SRC; |
|
- | 833 | switch (bpc) { |
|
- | 834 | case 8: |
|
- | 835 | default: |
|
- | 836 | args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_24BPP; |
|
- | 837 | break; |
|
711 | args.v5.usFbDiv = cpu_to_le16(fb_div); |
838 | case 10: |
712 | args.v5.ulFbDivDecFrac = cpu_to_le32(frac_fb_div * 100000); |
839 | args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP; |
713 | args.v5.ucPostDiv = post_div; |
840 | break; |
- | 841 | } |
|
- | 842 | args.v5.ucTransmitterID = encoder_id; |
|
- | 843 | args.v5.ucEncoderMode = encoder_mode; |
|
- | 844 | args.v5.ucPpll = pll_id; |
|
- | 845 | break; |
|
- | 846 | case 6: |
|
- | 847 | args.v6.ulCrtcPclkFreq.ucCRTC = crtc_id; |
|
- | 848 | args.v6.ulCrtcPclkFreq.ulPixelClock = cpu_to_le32(clock / 10); |
|
- | 849 | args.v6.ucRefDiv = ref_div; |
|
- | 850 | args.v6.usFbDiv = cpu_to_le16(fb_div); |
|
- | 851 | args.v6.ulFbDivDecFrac = cpu_to_le32(frac_fb_div * 100000); |
|
- | 852 | args.v6.ucPostDiv = post_div; |
|
- | 853 | args.v6.ucMiscInfo = 0; /* HDMI depth, etc. */ |
|
- | 854 | if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK)) |
|
- | 855 | args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_REF_DIV_SRC; |
|
- | 856 | switch (bpc) { |
|
- | 857 | case 8: |
|
- | 858 | default: |
|
- | 859 | args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_24BPP; |
|
- | 860 | break; |
|
- | 861 | case 10: |
|
- | 862 | args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP; |
|
- | 863 | break; |
|
- | 864 | case 12: |
|
- | 865 | args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP; |
|
- | 866 | break; |
|
- | 867 | case 16: |
|
- | 868 | args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP; |
|
- | 869 | break; |
|
714 | args.v5.ucMiscInfo = 0; /* HDMI depth, etc. */ |
870 | } |
715 | args.v5.ucTransmitterID = radeon_encoder->encoder_id; |
871 | args.v6.ucTransmitterID = encoder_id; |
716 | args.v5.ucEncoderMode = encoder_mode; |
872 | args.v6.ucEncoderMode = encoder_mode; |
717 | args.v5.ucPpll = radeon_crtc->pll_id; |
873 | args.v6.ucPpll = pll_id; |
718 | break; |
874 | break; |
Line 727... | Line 883... | ||
727 | } |
883 | } |
Line 728... | Line 884... | ||
728 | 884 | ||
729 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
885 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
Line -... | Line 886... | ||
- | 886 | } |
|
- | 887 | ||
- | 888 | static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode) |
|
- | 889 | { |
|
- | 890 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 891 | struct drm_device *dev = crtc->dev; |
|
- | 892 | struct radeon_device *rdev = dev->dev_private; |
|
- | 893 | struct drm_encoder *encoder = NULL; |
|
- | 894 | struct radeon_encoder *radeon_encoder = NULL; |
|
- | 895 | u32 pll_clock = mode->clock; |
|
- | 896 | u32 ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; |
|
- | 897 | struct radeon_pll *pll; |
|
- | 898 | u32 adjusted_clock; |
|
- | 899 | int encoder_mode = 0; |
|
- | 900 | struct radeon_atom_ss ss; |
|
- | 901 | bool ss_enabled = false; |
|
- | 902 | int bpc = 8; |
|
- | 903 | ||
- | 904 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
|
- | 905 | if (encoder->crtc == crtc) { |
|
- | 906 | radeon_encoder = to_radeon_encoder(encoder); |
|
- | 907 | encoder_mode = atombios_get_encoder_mode(encoder); |
|
- | 908 | break; |
|
- | 909 | } |
|
- | 910 | } |
|
- | 911 | ||
- | 912 | if (!radeon_encoder) |
|
- | 913 | return; |
|
- | 914 | ||
- | 915 | switch (radeon_crtc->pll_id) { |
|
- | 916 | case ATOM_PPLL1: |
|
- | 917 | pll = &rdev->clock.p1pll; |
|
- | 918 | break; |
|
- | 919 | case ATOM_PPLL2: |
|
- | 920 | pll = &rdev->clock.p2pll; |
|
- | 921 | break; |
|
- | 922 | case ATOM_DCPLL: |
|
- | 923 | case ATOM_PPLL_INVALID: |
|
- | 924 | default: |
|
- | 925 | pll = &rdev->clock.dcpll; |
|
- | 926 | break; |
|
- | 927 | } |
|
- | 928 | ||
- | 929 | if (radeon_encoder->active_device & |
|
- | 930 | (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) { |
|
- | 931 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
|
- | 932 | struct drm_connector *connector = |
|
- | 933 | radeon_get_connector_for_encoder(encoder); |
|
- | 934 | struct radeon_connector *radeon_connector = |
|
- | 935 | to_radeon_connector(connector); |
|
- | 936 | struct radeon_connector_atom_dig *dig_connector = |
|
- | 937 | radeon_connector->con_priv; |
|
- | 938 | int dp_clock; |
|
- | 939 | bpc = connector->display_info.bpc; |
|
- | 940 | ||
- | 941 | switch (encoder_mode) { |
|
- | 942 | case ATOM_ENCODER_MODE_DP: |
|
- | 943 | /* DP/eDP */ |
|
- | 944 | dp_clock = dig_connector->dp_clock / 10; |
|
- | 945 | if (ASIC_IS_DCE4(rdev)) |
|
- | 946 | ss_enabled = |
|
- | 947 | radeon_atombios_get_asic_ss_info(rdev, &ss, |
|
- | 948 | ASIC_INTERNAL_SS_ON_DP, |
|
- | 949 | dp_clock); |
|
- | 950 | else { |
|
- | 951 | if (dp_clock == 16200) { |
|
- | 952 | ss_enabled = |
|
- | 953 | radeon_atombios_get_ppll_ss_info(rdev, &ss, |
|
- | 954 | ATOM_DP_SS_ID2); |
|
- | 955 | if (!ss_enabled) |
|
- | 956 | ss_enabled = |
|
- | 957 | radeon_atombios_get_ppll_ss_info(rdev, &ss, |
|
- | 958 | ATOM_DP_SS_ID1); |
|
- | 959 | } else |
|
- | 960 | ss_enabled = |
|
- | 961 | radeon_atombios_get_ppll_ss_info(rdev, &ss, |
|
- | 962 | ATOM_DP_SS_ID1); |
|
- | 963 | } |
|
- | 964 | break; |
|
- | 965 | case ATOM_ENCODER_MODE_LVDS: |
|
- | 966 | if (ASIC_IS_DCE4(rdev)) |
|
- | 967 | ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss, |
|
- | 968 | dig->lcd_ss_id, |
|
- | 969 | mode->clock / 10); |
|
- | 970 | else |
|
- | 971 | ss_enabled = radeon_atombios_get_ppll_ss_info(rdev, &ss, |
|
- | 972 | dig->lcd_ss_id); |
|
- | 973 | break; |
|
- | 974 | case ATOM_ENCODER_MODE_DVI: |
|
- | 975 | if (ASIC_IS_DCE4(rdev)) |
|
- | 976 | ss_enabled = |
|
- | 977 | radeon_atombios_get_asic_ss_info(rdev, &ss, |
|
- | 978 | ASIC_INTERNAL_SS_ON_TMDS, |
|
- | 979 | mode->clock / 10); |
|
- | 980 | break; |
|
- | 981 | case ATOM_ENCODER_MODE_HDMI: |
|
- | 982 | if (ASIC_IS_DCE4(rdev)) |
|
- | 983 | ss_enabled = |
|
- | 984 | radeon_atombios_get_asic_ss_info(rdev, &ss, |
|
- | 985 | ASIC_INTERNAL_SS_ON_HDMI, |
|
- | 986 | mode->clock / 10); |
|
- | 987 | break; |
|
- | 988 | default: |
|
- | 989 | break; |
|
- | 990 | } |
|
- | 991 | } |
|
- | 992 | ||
- | 993 | /* adjust pixel clock as needed */ |
|
- | 994 | adjusted_clock = atombios_adjust_pll(crtc, mode, pll, ss_enabled, &ss); |
|
- | 995 | ||
- | 996 | if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) |
|
- | 997 | /* TV seems to prefer the legacy algo on some boards */ |
|
- | 998 | radeon_compute_pll_legacy(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, |
|
- | 999 | &ref_div, &post_div); |
|
- | 1000 | else if (ASIC_IS_AVIVO(rdev)) |
|
- | 1001 | radeon_compute_pll_avivo(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, |
|
- | 1002 | &ref_div, &post_div); |
|
- | 1003 | else |
|
- | 1004 | radeon_compute_pll_legacy(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, |
|
- | 1005 | &ref_div, &post_div); |
|
- | 1006 | ||
- | 1007 | atombios_crtc_program_ss(crtc, ATOM_DISABLE, radeon_crtc->pll_id, &ss); |
|
- | 1008 | ||
- | 1009 | atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, |
|
- | 1010 | encoder_mode, radeon_encoder->encoder_id, mode->clock, |
|
- | 1011 | ref_div, fb_div, frac_fb_div, post_div, bpc, ss_enabled, &ss); |
|
- | 1012 | ||
- | 1013 | if (ss_enabled) { |
|
- | 1014 | /* calculate ss amount and step size */ |
|
- | 1015 | if (ASIC_IS_DCE4(rdev)) { |
|
- | 1016 | u32 step_size; |
|
- | 1017 | u32 amount = (((fb_div * 10) + frac_fb_div) * ss.percentage) / 10000; |
|
- | 1018 | ss.amount = (amount / 10) & ATOM_PPLL_SS_AMOUNT_V2_FBDIV_MASK; |
|
- | 1019 | ss.amount |= ((amount - (amount / 10)) << ATOM_PPLL_SS_AMOUNT_V2_NFRAC_SHIFT) & |
|
- | 1020 | ATOM_PPLL_SS_AMOUNT_V2_NFRAC_MASK; |
|
- | 1021 | if (ss.type & ATOM_PPLL_SS_TYPE_V2_CENTRE_SPREAD) |
|
- | 1022 | step_size = (4 * amount * ref_div * (ss.rate * 2048)) / |
|
- | 1023 | (125 * 25 * pll->reference_freq / 100); |
|
- | 1024 | else |
|
- | 1025 | step_size = (2 * amount * ref_div * (ss.rate * 2048)) / |
|
- | 1026 | (125 * 25 * pll->reference_freq / 100); |
|
- | 1027 | ss.step = step_size; |
|
- | 1028 | } |
|
- | 1029 | ||
- | 1030 | atombios_crtc_program_ss(crtc, ATOM_ENABLE, radeon_crtc->pll_id, &ss); |
|
- | 1031 | } |
|
730 | } |
1032 | } |
731 | 1033 | ||
- | 1034 | static int dce4_crtc_do_set_base(struct drm_crtc *crtc, |
|
732 | static int evergreen_crtc_set_base(struct drm_crtc *crtc, int x, int y, |
1035 | struct drm_framebuffer *fb, |
733 | struct drm_framebuffer *old_fb) |
1036 | int x, int y, int atomic) |
734 | { |
1037 | { |
735 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
1038 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
736 | struct drm_device *dev = crtc->dev; |
1039 | struct drm_device *dev = crtc->dev; |
- | 1040 | struct radeon_device *rdev = dev->dev_private; |
|
737 | struct radeon_device *rdev = dev->dev_private; |
1041 | struct radeon_framebuffer *radeon_fb; |
738 | struct radeon_framebuffer *radeon_fb; |
1042 | struct drm_framebuffer *target_fb; |
739 | struct drm_gem_object *obj; |
1043 | struct drm_gem_object *obj; |
740 | struct radeon_bo *rbo; |
1044 | struct radeon_bo *rbo; |
- | 1045 | uint64_t fb_location; |
|
- | 1046 | uint32_t fb_format, fb_pitch_pixels, tiling_flags; |
|
741 | uint64_t fb_location; |
1047 | u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE); |
Line 742... | Line 1048... | ||
742 | uint32_t fb_format, fb_pitch_pixels, tiling_flags; |
1048 | u32 tmp, viewport_w, viewport_h; |
743 | int r; |
1049 | int r; |
744 | 1050 | ||
745 | /* no fb bound */ |
1051 | /* no fb bound */ |
746 | if (!crtc->fb) { |
1052 | if (!atomic && !crtc->fb) { |
Line -... | Line 1053... | ||
- | 1053 | DRM_DEBUG_KMS("No FB bound\n"); |
|
- | 1054 | return 0; |
|
- | 1055 | } |
|
- | 1056 | ||
- | 1057 | if (atomic) { |
|
747 | DRM_DEBUG("No FB bound\n"); |
1058 | radeon_fb = to_radeon_framebuffer(fb); |
- | 1059 | target_fb = fb; |
|
- | 1060 | } |
|
Line 748... | Line 1061... | ||
748 | return 0; |
1061 | else { |
- | 1062 | radeon_fb = to_radeon_framebuffer(crtc->fb); |
|
- | 1063 | target_fb = crtc->fb; |
|
749 | } |
1064 | } |
750 | 1065 | ||
751 | radeon_fb = to_radeon_framebuffer(crtc->fb); |
1066 | /* If atomic, assume fb object is pinned & idle & fenced and |
752 | 1067 | * just update base pointers |
|
753 | /* Pin framebuffer & get tilling informations */ |
1068 | */ |
- | 1069 | obj = radeon_fb->obj; |
|
- | 1070 | rbo = gem_to_radeon_bo(obj); |
|
- | 1071 | r = radeon_bo_reserve(rbo, false); |
|
- | 1072 | if (unlikely(r != 0)) |
|
754 | obj = radeon_fb->obj; |
1073 | return r; |
755 | rbo = obj->driver_private; |
1074 | |
756 | r = radeon_bo_reserve(rbo, false); |
1075 | if (atomic) |
757 | if (unlikely(r != 0)) |
1076 | fb_location = radeon_bo_gpu_offset(rbo); |
758 | return r; |
1077 | else { |
- | 1078 | r = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &fb_location); |
|
- | 1079 | if (unlikely(r != 0)) { |
|
759 | r = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &fb_location); |
1080 | radeon_bo_unreserve(rbo); |
760 | if (unlikely(r != 0)) { |
1081 | return -EINVAL; |
Line 761... | Line 1082... | ||
761 | radeon_bo_unreserve(rbo); |
1082 | } |
762 | return -EINVAL; |
1083 | } |
763 | } |
1084 | |
764 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); |
1085 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); |
765 | radeon_bo_unreserve(rbo); |
1086 | radeon_bo_unreserve(rbo); |
766 | 1087 | ||
Line 774... | Line 1095... | ||
774 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB1555)); |
1095 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB1555)); |
775 | break; |
1096 | break; |
776 | case 16: |
1097 | case 16: |
777 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | |
1098 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | |
778 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565)); |
1099 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565)); |
- | 1100 | #ifdef __BIG_ENDIAN |
|
- | 1101 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); |
|
- | 1102 | #endif |
|
779 | break; |
1103 | break; |
780 | case 24: |
1104 | case 24: |
781 | case 32: |
1105 | case 32: |
782 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | |
1106 | fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | |
783 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888)); |
1107 | EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888)); |
- | 1108 | #ifdef __BIG_ENDIAN |
|
- | 1109 | fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32); |
|
- | 1110 | #endif |
|
784 | break; |
1111 | break; |
785 | default: |
1112 | default: |
786 | DRM_ERROR("Unsupported screen depth %d\n", |
1113 | DRM_ERROR("Unsupported screen depth %d\n", |
787 | crtc->fb->bits_per_pixel); |
1114 | target_fb->bits_per_pixel); |
788 | return -EINVAL; |
1115 | return -EINVAL; |
789 | } |
1116 | } |
Line -... | Line 1117... | ||
- | 1117 | ||
- | 1118 | if (tiling_flags & RADEON_TILING_MACRO) |
|
- | 1119 | fb_format |= EVERGREEN_GRPH_ARRAY_MODE(EVERGREEN_GRPH_ARRAY_2D_TILED_THIN1); |
|
- | 1120 | else if (tiling_flags & RADEON_TILING_MICRO) |
|
- | 1121 | fb_format |= EVERGREEN_GRPH_ARRAY_MODE(EVERGREEN_GRPH_ARRAY_1D_TILED_THIN1); |
|
790 | 1122 | ||
791 | switch (radeon_crtc->crtc_id) { |
1123 | switch (radeon_crtc->crtc_id) { |
792 | case 0: |
1124 | case 0: |
793 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
1125 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
794 | break; |
1126 | break; |
Line 818... | Line 1150... | ||
818 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
1150 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
819 | (u32)fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); |
1151 | (u32)fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); |
820 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
1152 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
821 | (u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); |
1153 | (u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); |
822 | WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); |
1154 | WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); |
- | 1155 | WREG32(EVERGREEN_GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap); |
|
Line 823... | Line 1156... | ||
823 | 1156 | ||
824 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); |
1157 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); |
825 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); |
1158 | WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); |
826 | WREG32(EVERGREEN_GRPH_X_START + radeon_crtc->crtc_offset, 0); |
1159 | WREG32(EVERGREEN_GRPH_X_START + radeon_crtc->crtc_offset, 0); |
827 | WREG32(EVERGREEN_GRPH_Y_START + radeon_crtc->crtc_offset, 0); |
1160 | WREG32(EVERGREEN_GRPH_Y_START + radeon_crtc->crtc_offset, 0); |
828 | WREG32(EVERGREEN_GRPH_X_END + radeon_crtc->crtc_offset, crtc->fb->width); |
1161 | WREG32(EVERGREEN_GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width); |
Line 829... | Line 1162... | ||
829 | WREG32(EVERGREEN_GRPH_Y_END + radeon_crtc->crtc_offset, crtc->fb->height); |
1162 | WREG32(EVERGREEN_GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height); |
830 | 1163 | ||
831 | fb_pitch_pixels = crtc->fb->pitch / (crtc->fb->bits_per_pixel / 8); |
1164 | fb_pitch_pixels = target_fb->pitch / (target_fb->bits_per_pixel / 8); |
Line 832... | Line 1165... | ||
832 | WREG32(EVERGREEN_GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels); |
1165 | WREG32(EVERGREEN_GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels); |
833 | WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1); |
1166 | WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 1); |
834 | 1167 | ||
835 | WREG32(EVERGREEN_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, |
1168 | WREG32(EVERGREEN_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, |
836 | crtc->mode.vdisplay); |
1169 | crtc->mode.vdisplay); |
837 | x &= ~3; |
1170 | x &= ~3; |
- | 1171 | y &= ~1; |
|
- | 1172 | WREG32(EVERGREEN_VIEWPORT_START + radeon_crtc->crtc_offset, |
|
838 | y &= ~1; |
1173 | (x << 16) | y); |
839 | WREG32(EVERGREEN_VIEWPORT_START + radeon_crtc->crtc_offset, |
1174 | viewport_w = crtc->mode.hdisplay; |
840 | (x << 16) | y); |
- | |
841 | WREG32(EVERGREEN_VIEWPORT_SIZE + radeon_crtc->crtc_offset, |
- | |
842 | (crtc->mode.hdisplay << 16) | crtc->mode.vdisplay); |
- | |
843 | - | ||
844 | if (crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) |
- | |
845 | WREG32(EVERGREEN_DATA_FORMAT + radeon_crtc->crtc_offset, |
- | |
Line -... | Line 1175... | ||
- | 1175 | viewport_h = (crtc->mode.vdisplay + 1) & ~1; |
|
- | 1176 | WREG32(EVERGREEN_VIEWPORT_SIZE + radeon_crtc->crtc_offset, |
|
- | 1177 | (viewport_w << 16) | viewport_h); |
|
- | 1178 | ||
- | 1179 | /* pageflip setup */ |
|
- | 1180 | /* make sure flip is at vb rather than hb */ |
|
- | 1181 | tmp = RREG32(EVERGREEN_GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset); |
|
- | 1182 | tmp &= ~EVERGREEN_GRPH_SURFACE_UPDATE_H_RETRACE_EN; |
|
- | 1183 | WREG32(EVERGREEN_GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); |
|
846 | EVERGREEN_INTERLEAVE_EN); |
1184 | |
847 | else |
1185 | /* set pageflip to happen anywhere in vblank interval */ |
848 | WREG32(EVERGREEN_DATA_FORMAT + radeon_crtc->crtc_offset, 0); |
1186 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0); |
849 | 1187 | ||
850 | if (old_fb && old_fb != crtc->fb) { |
1188 | if (!atomic && fb && fb != crtc->fb) { |
851 | radeon_fb = to_radeon_framebuffer(old_fb); |
1189 | radeon_fb = to_radeon_framebuffer(fb); |
852 | rbo = radeon_fb->obj->driver_private; |
1190 | rbo = gem_to_radeon_bo(radeon_fb->obj); |
853 | r = radeon_bo_reserve(rbo, false); |
1191 | r = radeon_bo_reserve(rbo, false); |
Line 861... | Line 1199... | ||
861 | radeon_bandwidth_update(rdev); |
1199 | radeon_bandwidth_update(rdev); |
Line 862... | Line 1200... | ||
862 | 1200 | ||
863 | return 0; |
1201 | return 0; |
Line 864... | Line 1202... | ||
864 | } |
1202 | } |
865 | 1203 | ||
- | 1204 | static int avivo_crtc_do_set_base(struct drm_crtc *crtc, |
|
866 | static int avivo_crtc_set_base(struct drm_crtc *crtc, int x, int y, |
1205 | struct drm_framebuffer *fb, |
867 | struct drm_framebuffer *old_fb) |
1206 | int x, int y, int atomic) |
868 | { |
1207 | { |
869 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
1208 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
870 | struct drm_device *dev = crtc->dev; |
1209 | struct drm_device *dev = crtc->dev; |
871 | struct radeon_device *rdev = dev->dev_private; |
1210 | struct radeon_device *rdev = dev->dev_private; |
872 | struct radeon_framebuffer *radeon_fb; |
1211 | struct radeon_framebuffer *radeon_fb; |
- | 1212 | struct drm_gem_object *obj; |
|
873 | struct drm_gem_object *obj; |
1213 | struct radeon_bo *rbo; |
874 | struct radeon_bo *rbo; |
1214 | struct drm_framebuffer *target_fb; |
- | 1215 | uint64_t fb_location; |
|
- | 1216 | uint32_t fb_format, fb_pitch_pixels, tiling_flags; |
|
875 | uint64_t fb_location; |
1217 | u32 fb_swap = R600_D1GRPH_SWAP_ENDIAN_NONE; |
Line 876... | Line 1218... | ||
876 | uint32_t fb_format, fb_pitch_pixels, tiling_flags; |
1218 | u32 tmp, viewport_w, viewport_h; |
877 | int r; |
1219 | int r; |
878 | 1220 | ||
879 | /* no fb bound */ |
1221 | /* no fb bound */ |
880 | if (!crtc->fb) { |
1222 | if (!atomic && !crtc->fb) { |
Line -... | Line 1223... | ||
- | 1223 | DRM_DEBUG_KMS("No FB bound\n"); |
|
- | 1224 | return 0; |
|
- | 1225 | } |
|
- | 1226 | ||
- | 1227 | if (atomic) { |
|
881 | DRM_DEBUG("No FB bound\n"); |
1228 | radeon_fb = to_radeon_framebuffer(fb); |
- | 1229 | target_fb = fb; |
|
- | 1230 | } |
|
Line 882... | Line -... | ||
882 | return 0; |
- | |
883 | } |
1231 | else { |
884 | 1232 | radeon_fb = to_radeon_framebuffer(crtc->fb); |
|
885 | radeon_fb = to_radeon_framebuffer(crtc->fb); |
1233 | target_fb = crtc->fb; |
886 | 1234 | } |
|
887 | /* Pin framebuffer & get tilling informations */ |
1235 | |
- | 1236 | obj = radeon_fb->obj; |
|
- | 1237 | rbo = gem_to_radeon_bo(obj); |
|
- | 1238 | r = radeon_bo_reserve(rbo, false); |
|
- | 1239 | if (unlikely(r != 0)) |
|
- | 1240 | return r; |
|
- | 1241 | ||
- | 1242 | /* If atomic, assume fb object is pinned & idle & fenced and |
|
888 | obj = radeon_fb->obj; |
1243 | * just update base pointers |
889 | rbo = obj->driver_private; |
1244 | */ |
890 | r = radeon_bo_reserve(rbo, false); |
1245 | if (atomic) |
891 | if (unlikely(r != 0)) |
1246 | fb_location = radeon_bo_gpu_offset(rbo); |
892 | return r; |
1247 | else { |
- | 1248 | r = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &fb_location); |
|
893 | r = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &fb_location); |
1249 | if (unlikely(r != 0)) { |
894 | if (unlikely(r != 0)) { |
1250 | radeon_bo_unreserve(rbo); |
Line 895... | Line 1251... | ||
895 | radeon_bo_unreserve(rbo); |
1251 | return -EINVAL; |
896 | return -EINVAL; |
1252 | } |
897 | } |
1253 | } |
898 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); |
1254 | radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); |
899 | radeon_bo_unreserve(rbo); |
1255 | radeon_bo_unreserve(rbo); |
900 | 1256 | ||
Line 911... | Line 1267... | ||
911 | break; |
1267 | break; |
912 | case 16: |
1268 | case 16: |
913 | fb_format = |
1269 | fb_format = |
914 | AVIVO_D1GRPH_CONTROL_DEPTH_16BPP | |
1270 | AVIVO_D1GRPH_CONTROL_DEPTH_16BPP | |
915 | AVIVO_D1GRPH_CONTROL_16BPP_RGB565; |
1271 | AVIVO_D1GRPH_CONTROL_16BPP_RGB565; |
- | 1272 | #ifdef __BIG_ENDIAN |
|
- | 1273 | fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT; |
|
- | 1274 | #endif |
|
916 | break; |
1275 | break; |
917 | case 24: |
1276 | case 24: |
918 | case 32: |
1277 | case 32: |
919 | fb_format = |
1278 | fb_format = |
920 | AVIVO_D1GRPH_CONTROL_DEPTH_32BPP | |
1279 | AVIVO_D1GRPH_CONTROL_DEPTH_32BPP | |
921 | AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888; |
1280 | AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888; |
- | 1281 | #ifdef __BIG_ENDIAN |
|
- | 1282 | fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT; |
|
- | 1283 | #endif |
|
922 | break; |
1284 | break; |
923 | default: |
1285 | default: |
924 | DRM_ERROR("Unsupported screen depth %d\n", |
1286 | DRM_ERROR("Unsupported screen depth %d\n", |
925 | crtc->fb->bits_per_pixel); |
1287 | target_fb->bits_per_pixel); |
926 | return -EINVAL; |
1288 | return -EINVAL; |
927 | } |
1289 | } |
Line -... | Line 1290... | ||
- | 1290 | ||
- | 1291 | if (rdev->family >= CHIP_R600) { |
|
- | 1292 | if (tiling_flags & RADEON_TILING_MACRO) |
|
- | 1293 | fb_format |= R600_D1GRPH_ARRAY_MODE_2D_TILED_THIN1; |
|
- | 1294 | else if (tiling_flags & RADEON_TILING_MICRO) |
|
- | 1295 | fb_format |= R600_D1GRPH_ARRAY_MODE_1D_TILED_THIN1; |
|
928 | 1296 | } else { |
|
929 | if (tiling_flags & RADEON_TILING_MACRO) |
1297 | if (tiling_flags & RADEON_TILING_MACRO) |
Line 930... | Line 1298... | ||
930 | fb_format |= AVIVO_D1GRPH_MACRO_ADDRESS_MODE; |
1298 | fb_format |= AVIVO_D1GRPH_MACRO_ADDRESS_MODE; |
931 | 1299 | ||
- | 1300 | if (tiling_flags & RADEON_TILING_MICRO) |
|
Line 932... | Line 1301... | ||
932 | if (tiling_flags & RADEON_TILING_MICRO) |
1301 | fb_format |= AVIVO_D1GRPH_TILED; |
933 | fb_format |= AVIVO_D1GRPH_TILED; |
1302 | } |
934 | 1303 | ||
935 | if (radeon_crtc->crtc_id == 0) |
1304 | if (radeon_crtc->crtc_id == 0) |
Line 936... | Line 1305... | ||
936 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
1305 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
937 | else |
1306 | else |
938 | WREG32(AVIVO_D2VGA_CONTROL, 0); |
1307 | WREG32(AVIVO_D2VGA_CONTROL, 0); |
939 | 1308 | ||
940 | if (rdev->family >= CHIP_RV770) { |
1309 | if (rdev->family >= CHIP_RV770) { |
941 | if (radeon_crtc->crtc_id) { |
1310 | if (radeon_crtc->crtc_id) { |
942 | WREG32(R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0); |
1311 | WREG32(R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location)); |
943 | WREG32(R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0); |
1312 | WREG32(R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location)); |
944 | } else { |
1313 | } else { |
945 | WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0); |
1314 | WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location)); |
946 | WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0); |
1315 | WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, upper_32_bits(fb_location)); |
947 | } |
1316 | } |
948 | } |
1317 | } |
949 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
1318 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
- | 1319 | (u32) fb_location); |
|
- | 1320 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + |
|
Line 950... | Line 1321... | ||
950 | (u32) fb_location); |
1321 | radeon_crtc->crtc_offset, (u32) fb_location); |
951 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + |
1322 | WREG32(AVIVO_D1GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); |
952 | radeon_crtc->crtc_offset, (u32) fb_location); |
1323 | if (rdev->family >= CHIP_R600) |
953 | WREG32(AVIVO_D1GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); |
1324 | WREG32(R600_D1GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap); |
954 | 1325 | ||
955 | WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); |
1326 | WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); |
Line 956... | Line 1327... | ||
956 | WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); |
1327 | WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); |
957 | WREG32(AVIVO_D1GRPH_X_START + radeon_crtc->crtc_offset, 0); |
1328 | WREG32(AVIVO_D1GRPH_X_START + radeon_crtc->crtc_offset, 0); |
958 | WREG32(AVIVO_D1GRPH_Y_START + radeon_crtc->crtc_offset, 0); |
1329 | WREG32(AVIVO_D1GRPH_Y_START + radeon_crtc->crtc_offset, 0); |
Line 959... | Line 1330... | ||
959 | WREG32(AVIVO_D1GRPH_X_END + radeon_crtc->crtc_offset, crtc->fb->width); |
1330 | WREG32(AVIVO_D1GRPH_X_END + radeon_crtc->crtc_offset, target_fb->width); |
960 | WREG32(AVIVO_D1GRPH_Y_END + radeon_crtc->crtc_offset, crtc->fb->height); |
1331 | WREG32(AVIVO_D1GRPH_Y_END + radeon_crtc->crtc_offset, target_fb->height); |
961 | 1332 | ||
962 | fb_pitch_pixels = crtc->fb->pitch / (crtc->fb->bits_per_pixel / 8); |
1333 | fb_pitch_pixels = target_fb->pitch / (target_fb->bits_per_pixel / 8); |
963 | WREG32(AVIVO_D1GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels); |
1334 | WREG32(AVIVO_D1GRPH_PITCH + radeon_crtc->crtc_offset, fb_pitch_pixels); |
964 | WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1); |
1335 | WREG32(AVIVO_D1GRPH_ENABLE + radeon_crtc->crtc_offset, 1); |
- | 1336 | ||
- | 1337 | WREG32(AVIVO_D1MODE_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, |
|
965 | 1338 | crtc->mode.vdisplay); |
|
966 | WREG32(AVIVO_D1MODE_DESKTOP_HEIGHT + radeon_crtc->crtc_offset, |
1339 | x &= ~3; |
967 | crtc->mode.vdisplay); |
- | |
968 | x &= ~3; |
- | |
969 | y &= ~1; |
- | |
970 | WREG32(AVIVO_D1MODE_VIEWPORT_START + radeon_crtc->crtc_offset, |
- | |
971 | (x << 16) | y); |
- | |
972 | WREG32(AVIVO_D1MODE_VIEWPORT_SIZE + radeon_crtc->crtc_offset, |
- | |
Line -... | Line 1340... | ||
- | 1340 | y &= ~1; |
|
- | 1341 | WREG32(AVIVO_D1MODE_VIEWPORT_START + radeon_crtc->crtc_offset, |
|
- | 1342 | (x << 16) | y); |
|
- | 1343 | viewport_w = crtc->mode.hdisplay; |
|
- | 1344 | viewport_h = (crtc->mode.vdisplay + 1) & ~1; |
|
- | 1345 | WREG32(AVIVO_D1MODE_VIEWPORT_SIZE + radeon_crtc->crtc_offset, |
|
- | 1346 | (viewport_w << 16) | viewport_h); |
|
- | 1347 | ||
- | 1348 | /* pageflip setup */ |
|
973 | (crtc->mode.hdisplay << 16) | crtc->mode.vdisplay); |
1349 | /* make sure flip is at vb rather than hb */ |
974 | 1350 | tmp = RREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset); |
|
975 | if (crtc->mode.flags & DRM_MODE_FLAG_INTERLACE) |
1351 | tmp &= ~AVIVO_D1GRPH_SURFACE_UPDATE_H_RETRACE_EN; |
976 | WREG32(AVIVO_D1MODE_DATA_FORMAT + radeon_crtc->crtc_offset, |
1352 | WREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); |
977 | AVIVO_D1MODE_INTERLEAVE_EN); |
1353 | |
978 | else |
1354 | /* set pageflip to happen anywhere in vblank interval */ |
979 | WREG32(AVIVO_D1MODE_DATA_FORMAT + radeon_crtc->crtc_offset, 0); |
1355 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0); |
980 | 1356 | ||
Line 999... | Line 1375... | ||
999 | { |
1375 | { |
1000 | struct drm_device *dev = crtc->dev; |
1376 | struct drm_device *dev = crtc->dev; |
1001 | struct radeon_device *rdev = dev->dev_private; |
1377 | struct radeon_device *rdev = dev->dev_private; |
Line 1002... | Line 1378... | ||
1002 | 1378 | ||
1003 | if (ASIC_IS_DCE4(rdev)) |
1379 | if (ASIC_IS_DCE4(rdev)) |
1004 | return evergreen_crtc_set_base(crtc, x, y, old_fb); |
1380 | return dce4_crtc_do_set_base(crtc, old_fb, x, y, 0); |
1005 | else if (ASIC_IS_AVIVO(rdev)) |
1381 | else if (ASIC_IS_AVIVO(rdev)) |
1006 | return avivo_crtc_set_base(crtc, x, y, old_fb); |
1382 | return avivo_crtc_do_set_base(crtc, old_fb, x, y, 0); |
- | 1383 | else |
|
- | 1384 | return radeon_crtc_do_set_base(crtc, old_fb, x, y, 0); |
|
- | 1385 | } |
|
- | 1386 | ||
- | 1387 | int atombios_crtc_set_base_atomic(struct drm_crtc *crtc, |
|
- | 1388 | struct drm_framebuffer *fb, |
|
- | 1389 | int x, int y, enum mode_set_atomic state) |
|
- | 1390 | { |
|
- | 1391 | struct drm_device *dev = crtc->dev; |
|
- | 1392 | struct radeon_device *rdev = dev->dev_private; |
|
- | 1393 | ||
- | 1394 | if (ASIC_IS_DCE4(rdev)) |
|
- | 1395 | return dce4_crtc_do_set_base(crtc, fb, x, y, 1); |
|
- | 1396 | else if (ASIC_IS_AVIVO(rdev)) |
|
- | 1397 | return avivo_crtc_do_set_base(crtc, fb, x, y, 1); |
|
1007 | else |
1398 | else |
1008 | return radeon_crtc_set_base(crtc, x, y, old_fb); |
1399 | return radeon_crtc_do_set_base(crtc, fb, x, y, 1); |
Line 1009... | Line 1400... | ||
1009 | } |
1400 | } |
1010 | 1401 | ||
1011 | /* properly set additional regs when using atombios */ |
1402 | /* properly set additional regs when using atombios */ |
Line 1040... | Line 1431... | ||
1040 | struct drm_encoder *test_encoder; |
1431 | struct drm_encoder *test_encoder; |
1041 | struct drm_crtc *test_crtc; |
1432 | struct drm_crtc *test_crtc; |
1042 | uint32_t pll_in_use = 0; |
1433 | uint32_t pll_in_use = 0; |
Line 1043... | Line 1434... | ||
1043 | 1434 | ||
1044 | if (ASIC_IS_DCE4(rdev)) { |
- | |
1045 | /* if crtc is driving DP and we have an ext clock, use that */ |
1435 | if (ASIC_IS_DCE4(rdev)) { |
1046 | list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { |
1436 | list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { |
- | 1437 | if (test_encoder->crtc && (test_encoder->crtc == crtc)) { |
|
- | 1438 | /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock, |
|
- | 1439 | * depending on the asic: |
|
- | 1440 | * DCE4: PPLL or ext clock |
|
- | 1441 | * DCE5: DCPLL or ext clock |
|
- | 1442 | * |
|
- | 1443 | * Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip |
|
- | 1444 | * PPLL/DCPLL programming and only program the DP DTO for the |
|
- | 1445 | * crtc virtual pixel clock. |
|
1047 | if (test_encoder->crtc && (test_encoder->crtc == crtc)) { |
1446 | */ |
1048 | if (atombios_get_encoder_mode(test_encoder) == ATOM_ENCODER_MODE_DP) { |
1447 | if (atombios_get_encoder_mode(test_encoder) == ATOM_ENCODER_MODE_DP) { |
1049 | if (rdev->clock.dp_extclk) |
1448 | if (ASIC_IS_DCE5(rdev) || rdev->clock.dp_extclk) |
1050 | return ATOM_PPLL_INVALID; |
1449 | return ATOM_PPLL_INVALID; |
1051 | } |
1450 | } |
1052 | } |
1451 | } |
Line 1078... | Line 1477... | ||
1078 | int x, int y, struct drm_framebuffer *old_fb) |
1477 | int x, int y, struct drm_framebuffer *old_fb) |
1079 | { |
1478 | { |
1080 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
1479 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
1081 | struct drm_device *dev = crtc->dev; |
1480 | struct drm_device *dev = crtc->dev; |
1082 | struct radeon_device *rdev = dev->dev_private; |
1481 | struct radeon_device *rdev = dev->dev_private; |
- | 1482 | struct drm_encoder *encoder; |
|
- | 1483 | bool is_tvcv = false; |
|
Line -... | Line 1484... | ||
- | 1484 | ||
1083 | 1485 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
|
1084 | /* TODO color tiling */ |
- | |
1085 | 1486 | /* find tv std */ |
|
1086 | /* pick pll */ |
1487 | if (encoder->crtc == crtc) { |
- | 1488 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
|
- | 1489 | if (radeon_encoder->active_device & |
|
- | 1490 | (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) |
|
- | 1491 | is_tvcv = true; |
|
- | 1492 | } |
|
Line 1087... | Line -... | ||
1087 | radeon_crtc->pll_id = radeon_atom_pick_pll(crtc); |
- | |
1088 | 1493 | } |
|
1089 | atombios_set_ss(crtc, 0); |
1494 | |
- | 1495 | /* always set DCPLL */ |
|
- | 1496 | if (ASIC_IS_DCE4(rdev)) { |
|
- | 1497 | struct radeon_atom_ss ss; |
|
- | 1498 | bool ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss, |
|
- | 1499 | ASIC_INTERNAL_SS_ON_DCPLL, |
|
- | 1500 | rdev->clock.default_dispclk); |
|
- | 1501 | if (ss_enabled) |
|
1090 | /* always set DCPLL */ |
1502 | atombios_crtc_program_ss(crtc, ATOM_DISABLE, ATOM_DCPLL, &ss); |
- | 1503 | /* XXX: DCE5, make sure voltage, dispclk is high enough */ |
|
- | 1504 | atombios_crtc_set_dcpll(crtc, rdev->clock.default_dispclk); |
|
- | 1505 | if (ss_enabled) |
|
1091 | if (ASIC_IS_DCE4(rdev)) |
1506 | atombios_crtc_program_ss(crtc, ATOM_ENABLE, ATOM_DCPLL, &ss); |
1092 | atombios_crtc_set_dcpll(crtc); |
- | |
Line 1093... | Line 1507... | ||
1093 | atombios_crtc_set_pll(crtc, adjusted_mode); |
1507 | } |
1094 | atombios_set_ss(crtc, 1); |
1508 | atombios_crtc_set_pll(crtc, adjusted_mode); |
1095 | 1509 | ||
- | 1510 | if (ASIC_IS_DCE4(rdev)) |
|
1096 | if (ASIC_IS_DCE4(rdev)) |
1511 | atombios_set_crtc_dtd_timing(crtc, adjusted_mode); |
- | 1512 | else if (ASIC_IS_AVIVO(rdev)) { |
|
- | 1513 | if (is_tvcv) |
|
1097 | atombios_set_crtc_dtd_timing(crtc, adjusted_mode); |
1514 | atombios_crtc_set_timing(crtc, adjusted_mode); |
1098 | else if (ASIC_IS_AVIVO(rdev)) |
1515 | else |
1099 | atombios_crtc_set_timing(crtc, adjusted_mode); |
1516 | atombios_set_crtc_dtd_timing(crtc, adjusted_mode); |
1100 | else { |
1517 | } else { |
1101 | atombios_crtc_set_timing(crtc, adjusted_mode); |
1518 | atombios_crtc_set_timing(crtc, adjusted_mode); |
1102 | if (radeon_crtc->crtc_id == 0) |
1519 | if (radeon_crtc->crtc_id == 0) |
Line 1111... | Line 1528... | ||
1111 | 1528 | ||
1112 | static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc, |
1529 | static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc, |
1113 | struct drm_display_mode *mode, |
1530 | struct drm_display_mode *mode, |
1114 | struct drm_display_mode *adjusted_mode) |
1531 | struct drm_display_mode *adjusted_mode) |
- | 1532 | { |
|
- | 1533 | struct drm_device *dev = crtc->dev; |
|
- | 1534 | struct radeon_device *rdev = dev->dev_private; |
|
- | 1535 | ||
- | 1536 | /* adjust pm to upcoming mode change */ |
|
- | 1537 | radeon_pm_compute_clocks(rdev); |
|
1115 | { |
1538 | |
1116 | if (!radeon_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) |
1539 | if (!radeon_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) |
1117 | return false; |
1540 | return false; |
1118 | return true; |
1541 | return true; |
Line 1119... | Line 1542... | ||
1119 | } |
1542 | } |
1120 | 1543 | ||
- | 1544 | static void atombios_crtc_prepare(struct drm_crtc *crtc) |
|
- | 1545 | { |
|
- | 1546 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 1547 | ||
- | 1548 | /* pick pll */ |
|
1121 | static void atombios_crtc_prepare(struct drm_crtc *crtc) |
1549 | radeon_crtc->pll_id = radeon_atom_pick_pll(crtc); |
1122 | { |
1550 | |
1123 | atombios_lock_crtc(crtc, ATOM_ENABLE); |
1551 | atombios_lock_crtc(crtc, ATOM_ENABLE); |
Line 1124... | Line 1552... | ||
1124 | atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
1552 | atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
1125 | } |
1553 | } |
1126 | 1554 | ||
1127 | static void atombios_crtc_commit(struct drm_crtc *crtc) |
1555 | static void atombios_crtc_commit(struct drm_crtc *crtc) |
1128 | { |
1556 | { |
Line -... | Line 1557... | ||
- | 1557 | atombios_crtc_dpms(crtc, DRM_MODE_DPMS_ON); |
|
- | 1558 | atombios_lock_crtc(crtc, ATOM_DISABLE); |
|
- | 1559 | } |
|
- | 1560 | ||
- | 1561 | static void atombios_crtc_disable(struct drm_crtc *crtc) |
|
- | 1562 | { |
|
- | 1563 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 1564 | struct radeon_atom_ss ss; |
|
- | 1565 | ||
- | 1566 | atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); |
|
- | 1567 | ||
- | 1568 | switch (radeon_crtc->pll_id) { |
|
- | 1569 | case ATOM_PPLL1: |
|
- | 1570 | case ATOM_PPLL2: |
|
- | 1571 | /* disable the ppll */ |
|
- | 1572 | atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, |
|
- | 1573 | 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss); |
|
- | 1574 | break; |
|
- | 1575 | default: |
|
- | 1576 | break; |
|
1129 | atombios_crtc_dpms(crtc, DRM_MODE_DPMS_ON); |
1577 | } |
1130 | atombios_lock_crtc(crtc, ATOM_DISABLE); |
1578 | radeon_crtc->pll_id = -1; |
1131 | } |
1579 | } |
1132 | 1580 | ||
1133 | static const struct drm_crtc_helper_funcs atombios_helper_funcs = { |
1581 | static const struct drm_crtc_helper_funcs atombios_helper_funcs = { |
- | 1582 | .dpms = atombios_crtc_dpms, |
|
1134 | .dpms = atombios_crtc_dpms, |
1583 | .mode_fixup = atombios_crtc_mode_fixup, |
1135 | .mode_fixup = atombios_crtc_mode_fixup, |
1584 | .mode_set = atombios_crtc_mode_set, |
1136 | .mode_set = atombios_crtc_mode_set, |
1585 | .mode_set_base = atombios_crtc_set_base, |
- | 1586 | .mode_set_base_atomic = atombios_crtc_set_base_atomic, |
|
1137 | .mode_set_base = atombios_crtc_set_base, |
1587 | .prepare = atombios_crtc_prepare, |
Line 1138... | Line 1588... | ||
1138 | .prepare = atombios_crtc_prepare, |
1588 | .commit = atombios_crtc_commit, |
1139 | .commit = atombios_crtc_commit, |
1589 | .load_lut = radeon_crtc_load_lut, |
1140 | .load_lut = radeon_crtc_load_lut, |
1590 | .disable = atombios_crtc_disable, |