Rev 1246 | Rev 1321 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1246 | Rev 1268 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #include "radeon_fixed.h" |
29 | #include "radeon_fixed.h" |
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 | - | ||
34 | /* evil but including atombios.h is much worse */ |
- | |
35 | bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, |
- | |
36 | SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION *crtc_timing, |
- | |
37 | int32_t *pixel_clock); |
33 | |
38 | static void atombios_overscan_setup(struct drm_crtc *crtc, |
34 | static void atombios_overscan_setup(struct drm_crtc *crtc, |
39 | struct drm_display_mode *mode, |
35 | struct drm_display_mode *mode, |
40 | struct drm_display_mode *adjusted_mode) |
36 | struct drm_display_mode *adjusted_mode) |
41 | { |
37 | { |
Line 246... | Line 242... | ||
246 | struct drm_device *dev = crtc->dev; |
242 | struct drm_device *dev = crtc->dev; |
247 | struct radeon_device *rdev = dev->dev_private; |
243 | struct radeon_device *rdev = dev->dev_private; |
Line 248... | Line 244... | ||
248 | 244 | ||
249 | switch (mode) { |
245 | switch (mode) { |
- | 246 | case DRM_MODE_DPMS_ON: |
|
250 | case DRM_MODE_DPMS_ON: |
247 | atombios_enable_crtc(crtc, 1); |
251 | if (ASIC_IS_DCE3(rdev)) |
248 | if (ASIC_IS_DCE3(rdev)) |
252 | atombios_enable_crtc_memreq(crtc, 1); |
- | |
253 | atombios_enable_crtc(crtc, 1); |
249 | atombios_enable_crtc_memreq(crtc, 1); |
254 | atombios_blank_crtc(crtc, 0); |
250 | atombios_blank_crtc(crtc, 0); |
255 | break; |
251 | break; |
256 | case DRM_MODE_DPMS_STANDBY: |
252 | case DRM_MODE_DPMS_STANDBY: |
257 | case DRM_MODE_DPMS_SUSPEND: |
253 | case DRM_MODE_DPMS_SUSPEND: |
258 | case DRM_MODE_DPMS_OFF: |
254 | case DRM_MODE_DPMS_OFF: |
259 | atombios_blank_crtc(crtc, 1); |
- | |
260 | atombios_enable_crtc(crtc, 0); |
255 | atombios_blank_crtc(crtc, 1); |
261 | if (ASIC_IS_DCE3(rdev)) |
256 | if (ASIC_IS_DCE3(rdev)) |
- | 257 | atombios_enable_crtc_memreq(crtc, 0); |
|
262 | atombios_enable_crtc_memreq(crtc, 0); |
258 | atombios_enable_crtc(crtc, 0); |
263 | break; |
259 | break; |
Line 264... | Line 260... | ||
264 | } |
260 | } |
265 | 261 | ||
266 | if (mode != DRM_MODE_DPMS_OFF) { |
262 | if (mode != DRM_MODE_DPMS_OFF) { |
267 | radeon_crtc_load_lut(crtc); |
263 | radeon_crtc_load_lut(crtc); |
Line 268... | Line 264... | ||
268 | } |
264 | } |
269 | } |
265 | } |
270 | 266 | ||
271 | static void |
267 | static void |
- | 268 | atombios_set_crtc_dtd_timing(struct drm_crtc *crtc, |
|
272 | atombios_set_crtc_dtd_timing(struct drm_crtc *crtc, |
269 | struct drm_display_mode *mode) |
273 | SET_CRTC_USING_DTD_TIMING_PARAMETERS * crtc_param) |
270 | { |
274 | { |
271 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
275 | struct drm_device *dev = crtc->dev; |
272 | struct drm_device *dev = crtc->dev; |
- | 273 | struct radeon_device *rdev = dev->dev_private; |
|
Line -... | Line 274... | ||
- | 274 | SET_CRTC_USING_DTD_TIMING_PARAMETERS args; |
|
276 | struct radeon_device *rdev = dev->dev_private; |
275 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_UsingDTDTiming); |
277 | SET_CRTC_USING_DTD_TIMING_PARAMETERS conv_param; |
276 | u16 misc = 0; |
278 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_UsingDTDTiming); |
277 | |
279 | 278 | memset(&args, 0, sizeof(args)); |
|
280 | conv_param.usH_Size = cpu_to_le16(crtc_param->usH_Size); |
279 | args.usH_Size = cpu_to_le16(mode->crtc_hdisplay); |
281 | conv_param.usH_Blanking_Time = |
280 | args.usH_Blanking_Time = |
- | 281 | cpu_to_le16(mode->crtc_hblank_end - mode->crtc_hdisplay); |
|
282 | cpu_to_le16(crtc_param->usH_Blanking_Time); |
282 | args.usV_Size = cpu_to_le16(mode->crtc_vdisplay); |
- | 283 | args.usV_Blanking_Time = |
|
283 | conv_param.usV_Size = cpu_to_le16(crtc_param->usV_Size); |
284 | cpu_to_le16(mode->crtc_vblank_end - mode->crtc_vdisplay); |
- | 285 | args.usH_SyncOffset = |
|
284 | conv_param.usV_Blanking_Time = |
286 | cpu_to_le16(mode->crtc_hsync_start - mode->crtc_hdisplay); |
- | 287 | args.usH_SyncWidth = |
|
285 | cpu_to_le16(crtc_param->usV_Blanking_Time); |
288 | cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start); |
- | 289 | args.usV_SyncOffset = |
|
286 | conv_param.usH_SyncOffset = cpu_to_le16(crtc_param->usH_SyncOffset); |
290 | cpu_to_le16(mode->crtc_vsync_start - mode->crtc_vdisplay); |
- | 291 | args.usV_SyncWidth = |
|
- | 292 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
|
- | 293 | /*args.ucH_Border = mode->hborder;*/ |
|
- | 294 | /*args.ucV_Border = mode->vborder;*/ |
|
- | 295 | ||
- | 296 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
|
- | 297 | misc |= ATOM_VSYNC_POLARITY; |
|
- | 298 | if (mode->flags & DRM_MODE_FLAG_NHSYNC) |
|
- | 299 | misc |= ATOM_HSYNC_POLARITY; |
|
- | 300 | if (mode->flags & DRM_MODE_FLAG_CSYNC) |
|
- | 301 | misc |= ATOM_COMPOSITESYNC; |
|
- | 302 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
|
287 | conv_param.usH_SyncWidth = cpu_to_le16(crtc_param->usH_SyncWidth); |
303 | misc |= ATOM_INTERLACE; |
288 | conv_param.usV_SyncOffset = cpu_to_le16(crtc_param->usV_SyncOffset); |
304 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
Line 289... | Line 305... | ||
289 | conv_param.usV_SyncWidth = cpu_to_le16(crtc_param->usV_SyncWidth); |
305 | misc |= ATOM_DOUBLE_CLOCK_MODE; |
290 | conv_param.susModeMiscInfo.usAccess = |
306 | |
291 | cpu_to_le16(crtc_param->susModeMiscInfo.usAccess); |
307 | args.susModeMiscInfo.usAccess = cpu_to_le16(misc); |
Line 292... | Line 308... | ||
292 | conv_param.ucCRTC = crtc_param->ucCRTC; |
308 | args.ucCRTC = radeon_crtc->crtc_id; |
293 | - | ||
294 | printk("executing set crtc dtd timing\n"); |
309 | |
295 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&conv_param); |
310 | printk("executing set crtc dtd timing\n"); |
- | 311 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
|
296 | } |
312 | } |
297 | 313 | ||
298 | void atombios_crtc_set_timing(struct drm_crtc *crtc, |
314 | static void atombios_crtc_set_timing(struct drm_crtc *crtc, |
299 | SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION * |
315 | struct drm_display_mode *mode) |
- | 316 | { |
|
- | 317 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 318 | struct drm_device *dev = crtc->dev; |
|
- | 319 | struct radeon_device *rdev = dev->dev_private; |
|
- | 320 | SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION args; |
|
- | 321 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_Timing); |
|
- | 322 | u16 misc = 0; |
|
- | 323 | ||
- | 324 | memset(&args, 0, sizeof(args)); |
|
- | 325 | args.usH_Total = cpu_to_le16(mode->crtc_htotal); |
|
- | 326 | args.usH_Disp = cpu_to_le16(mode->crtc_hdisplay); |
|
- | 327 | args.usH_SyncStart = cpu_to_le16(mode->crtc_hsync_start); |
|
- | 328 | args.usH_SyncWidth = |
|
- | 329 | cpu_to_le16(mode->crtc_hsync_end - mode->crtc_hsync_start); |
|
- | 330 | args.usV_Total = cpu_to_le16(mode->crtc_vtotal); |
|
- | 331 | args.usV_Disp = cpu_to_le16(mode->crtc_vdisplay); |
|
- | 332 | args.usV_SyncStart = cpu_to_le16(mode->crtc_vsync_start); |
|
- | 333 | args.usV_SyncWidth = |
|
- | 334 | cpu_to_le16(mode->crtc_vsync_end - mode->crtc_vsync_start); |
|
- | 335 | ||
- | 336 | if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
|
- | 337 | misc |= ATOM_VSYNC_POLARITY; |
|
- | 338 | if (mode->flags & DRM_MODE_FLAG_NHSYNC) |
|
- | 339 | misc |= ATOM_HSYNC_POLARITY; |
|
Line 300... | Line -... | ||
300 | crtc_param) |
- | |
301 | { |
- | |
302 | struct drm_device *dev = crtc->dev; |
- | |
303 | struct radeon_device *rdev = dev->dev_private; |
- | |
304 | SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION conv_param; |
- | |
305 | int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_Timing); |
- | |
306 | - | ||
307 | conv_param.usH_Total = cpu_to_le16(crtc_param->usH_Total); |
- | |
308 | conv_param.usH_Disp = cpu_to_le16(crtc_param->usH_Disp); |
340 | if (mode->flags & DRM_MODE_FLAG_CSYNC) |
309 | conv_param.usH_SyncStart = cpu_to_le16(crtc_param->usH_SyncStart); |
- | |
310 | conv_param.usH_SyncWidth = cpu_to_le16(crtc_param->usH_SyncWidth); |
341 | misc |= ATOM_COMPOSITESYNC; |
311 | conv_param.usV_Total = cpu_to_le16(crtc_param->usV_Total); |
- | |
312 | conv_param.usV_Disp = cpu_to_le16(crtc_param->usV_Disp); |
- | |
313 | conv_param.usV_SyncStart = cpu_to_le16(crtc_param->usV_SyncStart); |
- | |
314 | conv_param.usV_SyncWidth = cpu_to_le16(crtc_param->usV_SyncWidth); |
- | |
315 | conv_param.susModeMiscInfo.usAccess = |
- | |
Line 316... | Line 342... | ||
316 | cpu_to_le16(crtc_param->susModeMiscInfo.usAccess); |
342 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
317 | conv_param.ucCRTC = crtc_param->ucCRTC; |
343 | misc |= ATOM_INTERLACE; |
- | 344 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
|
- | 345 | misc |= ATOM_DOUBLE_CLOCK_MODE; |
|
- | 346 | ||
- | 347 | args.susModeMiscInfo.usAccess = cpu_to_le16(misc); |
|
- | 348 | args.ucCRTC = radeon_crtc->crtc_id; |
|
- | 349 | ||
- | 350 | printk("executing set crtc timing\n"); |
|
- | 351 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
|
- | 352 | } |
|
- | 353 | ||
- | 354 | static void atombios_set_ss(struct drm_crtc *crtc, int enable) |
|
- | 355 | { |
|
- | 356 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
|
- | 357 | struct drm_device *dev = crtc->dev; |
|
- | 358 | struct radeon_device *rdev = dev->dev_private; |
|
- | 359 | struct drm_encoder *encoder = NULL; |
|
- | 360 | struct radeon_encoder *radeon_encoder = NULL; |
|
- | 361 | struct radeon_encoder_atom_dig *dig = NULL; |
|
- | 362 | int index = GetIndexIntoMasterTable(COMMAND, EnableSpreadSpectrumOnPPLL); |
|
- | 363 | ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION args; |
|
- | 364 | ENABLE_LVDS_SS_PARAMETERS legacy_args; |
|
- | 365 | uint16_t percentage = 0; |
|
- | 366 | uint8_t type = 0, step = 0, delay = 0, range = 0; |
|
- | 367 | ||
- | 368 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
|
- | 369 | if (encoder->crtc == crtc) { |
|
- | 370 | radeon_encoder = to_radeon_encoder(encoder); |
|
- | 371 | /* only enable spread spectrum on LVDS */ |
|
- | 372 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
|
- | 373 | dig = radeon_encoder->enc_priv; |
|
- | 374 | if (dig && dig->ss) { |
|
- | 375 | percentage = dig->ss->percentage; |
|
- | 376 | type = dig->ss->type; |
|
- | 377 | step = dig->ss->step; |
|
- | 378 | delay = dig->ss->delay; |
|
- | 379 | range = dig->ss->range; |
|
- | 380 | } else if (enable) |
|
- | 381 | return; |
|
- | 382 | } else if (enable) |
|
- | 383 | return; |
|
- | 384 | break; |
|
- | 385 | } |
|
- | 386 | } |
|
- | 387 | ||
- | 388 | if (!radeon_encoder) |
|
- | 389 | return; |
|
- | 390 | ||
- | 391 | if (ASIC_IS_AVIVO(rdev)) { |
|
- | 392 | memset(&args, 0, sizeof(args)); |
|
- | 393 | args.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
|
- | 394 | args.ucSpreadSpectrumType = type; |
|
- | 395 | args.ucSpreadSpectrumStep = step; |
|
- | 396 | args.ucSpreadSpectrumDelay = delay; |
|
- | 397 | args.ucSpreadSpectrumRange = range; |
|
- | 398 | args.ucPpll = radeon_crtc->crtc_id ? ATOM_PPLL2 : ATOM_PPLL1; |
|
- | 399 | args.ucEnable = enable; |
|
- | 400 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
|
- | 401 | } else { |
|
318 | conv_param.ucOverscanRight = crtc_param->ucOverscanRight; |
402 | memset(&legacy_args, 0, sizeof(legacy_args)); |
Line 319... | Line 403... | ||
319 | conv_param.ucOverscanLeft = crtc_param->ucOverscanLeft; |
403 | legacy_args.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
320 | conv_param.ucOverscanBottom = crtc_param->ucOverscanBottom; |
404 | legacy_args.ucSpreadSpectrumType = type; |
321 | conv_param.ucOverscanTop = crtc_param->ucOverscanTop; |
405 | legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; |
322 | conv_param.ucReserved = crtc_param->ucReserved; |
406 | legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; |
323 | 407 | legacy_args.ucEnable = enable; |
|
324 | printk("executing set crtc timing\n"); |
408 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&legacy_args); |
325 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&conv_param); |
409 | } |
326 | } |
410 | } |
327 | 411 | ||
328 | void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode) |
412 | void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode *mode) |
329 | { |
413 | { |
330 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
414 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
331 | struct drm_device *dev = crtc->dev; |
415 | struct drm_device *dev = crtc->dev; |
332 | struct radeon_device *rdev = dev->dev_private; |
416 | struct radeon_device *rdev = dev->dev_private; |
- | 417 | struct drm_encoder *encoder = NULL; |
|
333 | struct drm_encoder *encoder = NULL; |
418 | struct radeon_encoder *radeon_encoder = NULL; |
334 | struct radeon_encoder *radeon_encoder = NULL; |
419 | uint8_t frev, crev; |
335 | uint8_t frev, crev; |
420 | int index; |
Line 336... | Line 421... | ||
336 | int index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
421 | SET_PIXEL_CLOCK_PS_ALLOCATION args; |
Line 337... | Line 422... | ||
337 | SET_PIXEL_CLOCK_PS_ALLOCATION args; |
422 | PIXEL_CLOCK_PARAMETERS *spc1_ptr; |
338 | PIXEL_CLOCK_PARAMETERS *spc1_ptr; |
- | |
339 | PIXEL_CLOCK_PARAMETERS_V2 *spc2_ptr; |
- | |
340 | PIXEL_CLOCK_PARAMETERS_V3 *spc3_ptr; |
423 | PIXEL_CLOCK_PARAMETERS_V2 *spc2_ptr; |
341 | uint32_t sclock = mode->clock; |
424 | PIXEL_CLOCK_PARAMETERS_V3 *spc3_ptr; |
342 | uint32_t ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; |
425 | uint32_t pll_clock = mode->clock; |
343 | struct radeon_pll *pll; |
426 | uint32_t adjusted_clock; |
344 | int pll_flags = 0; |
427 | uint32_t ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; |
Line 345... | Line 428... | ||
345 | 428 | struct radeon_pll *pll; |
|
346 | memset(&args, 0, sizeof(args)); |
429 | int pll_flags = 0; |
347 | 430 | ||
348 | if (ASIC_IS_AVIVO(rdev)) { |
431 | memset(&args, 0, sizeof(args)); |
349 | uint32_t ss_cntl; |
- | |
350 | - | ||
351 | if ((rdev->family == CHIP_RS600) || |
- | |
352 | (rdev->family == CHIP_RS690) || |
- | |
353 | (rdev->family == CHIP_RS740)) |
- | |
354 | pll_flags |= (RADEON_PLL_USE_FRAC_FB_DIV | |
- | |
355 | RADEON_PLL_PREFER_CLOSEST_LOWER); |
- | |
356 | - | ||
357 | if (ASIC_IS_DCE32(rdev) && mode->clock > 200000) /* range limits??? */ |
- | |
358 | pll_flags |= RADEON_PLL_PREFER_HIGH_FB_DIV; |
432 | |
359 | else |
433 | if (ASIC_IS_AVIVO(rdev)) { |
Line 360... | Line 434... | ||
360 | pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV; |
434 | if ((rdev->family == CHIP_RS600) || |
361 | 435 | (rdev->family == CHIP_RS690) || |
|
Line 391... | Line 465... | ||
391 | radeon_encoder = to_radeon_encoder(encoder); |
465 | radeon_encoder = to_radeon_encoder(encoder); |
392 | break; |
466 | break; |
393 | } |
467 | } |
394 | } |
468 | } |
Line -... | Line 469... | ||
- | 469 | ||
- | 470 | /* DCE3+ has an AdjustDisplayPll that will adjust the pixel clock |
|
- | 471 | * accordingly based on the encoder/transmitter to work around |
|
- | 472 | * special hw requirements. |
|
- | 473 | */ |
|
- | 474 | if (ASIC_IS_DCE3(rdev)) { |
|
- | 475 | ADJUST_DISPLAY_PLL_PS_ALLOCATION adjust_pll_args; |
|
- | 476 | ||
- | 477 | if (!encoder) |
|
- | 478 | return; |
|
- | 479 | ||
- | 480 | memset(&adjust_pll_args, 0, sizeof(adjust_pll_args)); |
|
- | 481 | adjust_pll_args.usPixelClock = cpu_to_le16(mode->clock / 10); |
|
- | 482 | adjust_pll_args.ucTransmitterID = radeon_encoder->encoder_id; |
|
- | 483 | adjust_pll_args.ucEncodeMode = atombios_get_encoder_mode(encoder); |
|
- | 484 | ||
- | 485 | index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll); |
|
- | 486 | atom_execute_table(rdev->mode_info.atom_context, |
|
- | 487 | index, (uint32_t *)&adjust_pll_args); |
|
- | 488 | adjusted_clock = le16_to_cpu(adjust_pll_args.usPixelClock) * 10; |
|
- | 489 | } else { |
|
- | 490 | /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */ |
|
- | 491 | if (ASIC_IS_AVIVO(rdev) && |
|
- | 492 | (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1)) |
|
- | 493 | adjusted_clock = mode->clock * 2; |
|
- | 494 | else |
|
- | 495 | adjusted_clock = mode->clock; |
|
- | 496 | } |
|
395 | 497 | ||
396 | if (radeon_crtc->crtc_id == 0) |
498 | if (radeon_crtc->crtc_id == 0) |
397 | pll = &rdev->clock.p1pll; |
499 | pll = &rdev->clock.p1pll; |
398 | else |
500 | else |
Line 399... | Line 501... | ||
399 | pll = &rdev->clock.p2pll; |
501 | pll = &rdev->clock.p2pll; |
400 | 502 | ||
Line -... | Line 503... | ||
- | 503 | radeon_compute_pll(pll, adjusted_clock, &pll_clock, &fb_div, &frac_fb_div, |
|
401 | radeon_compute_pll(pll, mode->clock, &sclock, &fb_div, &frac_fb_div, |
504 | &ref_div, &post_div, pll_flags); |
402 | &ref_div, &post_div, pll_flags); |
505 | |
Line 403... | Line 506... | ||
403 | 506 | index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); |
|
404 | atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
507 | atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, |
405 | &crev); |
508 | &crev); |
406 | 509 | ||
407 | switch (frev) { |
510 | switch (frev) { |
408 | case 1: |
511 | case 1: |
409 | switch (crev) { |
512 | switch (crev) { |
410 | case 1: |
513 | case 1: |
411 | spc1_ptr = (PIXEL_CLOCK_PARAMETERS *) & args.sPCLKInput; |
514 | spc1_ptr = (PIXEL_CLOCK_PARAMETERS *) & args.sPCLKInput; |
412 | spc1_ptr->usPixelClock = cpu_to_le16(sclock); |
515 | spc1_ptr->usPixelClock = cpu_to_le16(mode->clock / 10); |
413 | spc1_ptr->usRefDiv = cpu_to_le16(ref_div); |
516 | spc1_ptr->usRefDiv = cpu_to_le16(ref_div); |
Line 420... | Line 523... | ||
420 | spc1_ptr->ucRefDivSrc = 1; |
523 | spc1_ptr->ucRefDivSrc = 1; |
421 | break; |
524 | break; |
422 | case 2: |
525 | case 2: |
423 | spc2_ptr = |
526 | spc2_ptr = |
424 | (PIXEL_CLOCK_PARAMETERS_V2 *) & args.sPCLKInput; |
527 | (PIXEL_CLOCK_PARAMETERS_V2 *) & args.sPCLKInput; |
425 | spc2_ptr->usPixelClock = cpu_to_le16(sclock); |
528 | spc2_ptr->usPixelClock = cpu_to_le16(mode->clock / 10); |
426 | spc2_ptr->usRefDiv = cpu_to_le16(ref_div); |
529 | spc2_ptr->usRefDiv = cpu_to_le16(ref_div); |
427 | spc2_ptr->usFbDiv = cpu_to_le16(fb_div); |
530 | spc2_ptr->usFbDiv = cpu_to_le16(fb_div); |
428 | spc2_ptr->ucFracFbDiv = frac_fb_div; |
531 | spc2_ptr->ucFracFbDiv = frac_fb_div; |
429 | spc2_ptr->ucPostDiv = post_div; |
532 | spc2_ptr->ucPostDiv = post_div; |
430 | spc2_ptr->ucPpll = |
533 | spc2_ptr->ucPpll = |
Line 435... | Line 538... | ||
435 | case 3: |
538 | case 3: |
436 | if (!encoder) |
539 | if (!encoder) |
437 | return; |
540 | return; |
438 | spc3_ptr = |
541 | spc3_ptr = |
439 | (PIXEL_CLOCK_PARAMETERS_V3 *) & args.sPCLKInput; |
542 | (PIXEL_CLOCK_PARAMETERS_V3 *) & args.sPCLKInput; |
440 | spc3_ptr->usPixelClock = cpu_to_le16(sclock); |
543 | spc3_ptr->usPixelClock = cpu_to_le16(mode->clock / 10); |
441 | spc3_ptr->usRefDiv = cpu_to_le16(ref_div); |
544 | spc3_ptr->usRefDiv = cpu_to_le16(ref_div); |
442 | spc3_ptr->usFbDiv = cpu_to_le16(fb_div); |
545 | spc3_ptr->usFbDiv = cpu_to_le16(fb_div); |
443 | spc3_ptr->ucFracFbDiv = frac_fb_div; |
546 | spc3_ptr->ucFracFbDiv = frac_fb_div; |
444 | spc3_ptr->ucPostDiv = post_div; |
547 | spc3_ptr->ucPostDiv = post_div; |
445 | spc3_ptr->ucPpll = |
548 | spc3_ptr->ucPpll = |
Line 529... | Line 632... | ||
529 | 632 | ||
530 | if (radeon_crtc->crtc_id == 0) |
633 | if (radeon_crtc->crtc_id == 0) |
531 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
634 | WREG32(AVIVO_D1VGA_CONTROL, 0); |
532 | else |
635 | else |
- | 636 | WREG32(AVIVO_D2VGA_CONTROL, 0); |
|
- | 637 | ||
- | 638 | if (rdev->family >= CHIP_RV770) { |
|
- | 639 | if (radeon_crtc->crtc_id) { |
|
- | 640 | WREG32(R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0); |
|
- | 641 | WREG32(R700_D2GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0); |
|
- | 642 | } else { |
|
- | 643 | WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH, 0); |
|
- | 644 | WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH, 0); |
|
- | 645 | } |
|
533 | WREG32(AVIVO_D2VGA_CONTROL, 0); |
646 | } |
534 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
647 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
535 | (u32) fb_location); |
648 | (u32) fb_location); |
536 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + |
649 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + |
537 | radeon_crtc->crtc_offset, (u32) fb_location); |
650 | radeon_crtc->crtc_offset, (u32) fb_location); |
Line 566... | Line 679... | ||
566 | // if (old_fb && old_fb != crtc->fb) { |
679 | // if (old_fb && old_fb != crtc->fb) { |
567 | // radeon_fb = to_radeon_framebuffer(old_fb); |
680 | // radeon_fb = to_radeon_framebuffer(old_fb); |
568 | // radeon_gem_object_unpin(radeon_fb->obj); |
681 | // radeon_gem_object_unpin(radeon_fb->obj); |
569 | // } |
682 | // } |
Line -... | Line 683... | ||
- | 683 | ||
- | 684 | /* Bytes per pixel may have changed */ |
|
- | 685 | radeon_bandwidth_update(rdev); |
|
570 | 686 | ||
Line 571... | Line 687... | ||
571 | LEAVE(); |
687 | LEAVE(); |
572 | 688 | ||
Line 579... | Line 695... | ||
579 | int x, int y, struct drm_framebuffer *old_fb) |
695 | int x, int y, struct drm_framebuffer *old_fb) |
580 | { |
696 | { |
581 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
697 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
582 | struct drm_device *dev = crtc->dev; |
698 | struct drm_device *dev = crtc->dev; |
583 | struct radeon_device *rdev = dev->dev_private; |
699 | struct radeon_device *rdev = dev->dev_private; |
584 | struct drm_encoder *encoder; |
- | |
585 | SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION crtc_timing; |
- | |
586 | int need_tv_timings = 0; |
- | |
587 | bool ret; |
- | |
Line 588... | Line 700... | ||
588 | 700 | ||
589 | /* TODO color tiling */ |
- | |
590 | memset(&crtc_timing, 0, sizeof(crtc_timing)); |
- | |
591 | - | ||
592 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
- | |
593 | /* find tv std */ |
- | |
594 | if (encoder->crtc == crtc) { |
- | |
595 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
- | |
596 | - | ||
597 | if (radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT) { |
- | |
598 | struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv; |
- | |
599 | if (tv_dac) { |
- | |
600 | if (tv_dac->tv_std == TV_STD_NTSC || |
- | |
601 | tv_dac->tv_std == TV_STD_NTSC_J || |
- | |
602 | tv_dac->tv_std == TV_STD_PAL_M) |
- | |
603 | need_tv_timings = 1; |
- | |
604 | else |
- | |
605 | need_tv_timings = 2; |
- | |
606 | break; |
- | |
607 | } |
- | |
608 | } |
- | |
609 | } |
- | |
610 | } |
- | |
611 | - | ||
612 | crtc_timing.ucCRTC = radeon_crtc->crtc_id; |
- | |
613 | if (need_tv_timings) { |
- | |
614 | ret = radeon_atom_get_tv_timings(rdev, need_tv_timings - 1, |
- | |
615 | &crtc_timing, &adjusted_mode->clock); |
- | |
616 | if (ret == false) |
- | |
617 | need_tv_timings = 0; |
- | |
618 | } |
- | |
619 | - | ||
620 | if (!need_tv_timings) { |
- | |
621 | crtc_timing.usH_Total = adjusted_mode->crtc_htotal; |
- | |
622 | crtc_timing.usH_Disp = adjusted_mode->crtc_hdisplay; |
- | |
623 | crtc_timing.usH_SyncStart = adjusted_mode->crtc_hsync_start; |
- | |
624 | crtc_timing.usH_SyncWidth = |
- | |
625 | adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start; |
- | |
626 | - | ||
627 | crtc_timing.usV_Total = adjusted_mode->crtc_vtotal; |
- | |
628 | crtc_timing.usV_Disp = adjusted_mode->crtc_vdisplay; |
- | |
629 | crtc_timing.usV_SyncStart = adjusted_mode->crtc_vsync_start; |
- | |
630 | crtc_timing.usV_SyncWidth = |
- | |
631 | adjusted_mode->crtc_vsync_end - adjusted_mode->crtc_vsync_start; |
- | |
632 | - | ||
633 | if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) |
- | |
634 | crtc_timing.susModeMiscInfo.usAccess |= ATOM_VSYNC_POLARITY; |
- | |
635 | - | ||
636 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) |
- | |
637 | crtc_timing.susModeMiscInfo.usAccess |= ATOM_HSYNC_POLARITY; |
- | |
638 | - | ||
639 | if (adjusted_mode->flags & DRM_MODE_FLAG_CSYNC) |
- | |
640 | crtc_timing.susModeMiscInfo.usAccess |= ATOM_COMPOSITESYNC; |
- | |
641 | - | ||
642 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) |
- | |
643 | crtc_timing.susModeMiscInfo.usAccess |= ATOM_INTERLACE; |
- | |
644 | - | ||
645 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) |
- | |
646 | crtc_timing.susModeMiscInfo.usAccess |= ATOM_DOUBLE_CLOCK_MODE; |
- | |
Line -... | Line 701... | ||
- | 701 | /* TODO color tiling */ |
|
647 | } |
702 | |
- | 703 | atombios_set_ss(crtc, 0); |
|
648 | 704 | atombios_crtc_set_pll(crtc, adjusted_mode); |
|
Line 649... | Line 705... | ||
649 | atombios_crtc_set_pll(crtc, adjusted_mode); |
705 | atombios_set_ss(crtc, 1); |
650 | atombios_crtc_set_timing(crtc, &crtc_timing); |
706 | atombios_crtc_set_timing(crtc, adjusted_mode); |
651 | 707 | ||
652 | if (ASIC_IS_AVIVO(rdev)) |
708 | if (ASIC_IS_AVIVO(rdev)) |
653 | atombios_crtc_set_base(crtc, x, y, old_fb); |
- | |
654 | else { |
- | |
655 | if (radeon_crtc->crtc_id == 0) { |
- | |
656 | SET_CRTC_USING_DTD_TIMING_PARAMETERS crtc_dtd_timing; |
- | |
657 | memset(&crtc_dtd_timing, 0, sizeof(crtc_dtd_timing)); |
- | |
658 | - | ||
659 | /* setup FP shadow regs on R4xx */ |
- | |
660 | crtc_dtd_timing.ucCRTC = radeon_crtc->crtc_id; |
- | |
661 | crtc_dtd_timing.usH_Size = adjusted_mode->crtc_hdisplay; |
- | |
662 | crtc_dtd_timing.usV_Size = adjusted_mode->crtc_vdisplay; |
- | |
663 | crtc_dtd_timing.usH_Blanking_Time = |
- | |
664 | adjusted_mode->crtc_hblank_end - |
- | |
665 | adjusted_mode->crtc_hdisplay; |
- | |
666 | crtc_dtd_timing.usV_Blanking_Time = |
- | |
667 | adjusted_mode->crtc_vblank_end - |
- | |
668 | adjusted_mode->crtc_vdisplay; |
- | |
669 | crtc_dtd_timing.usH_SyncOffset = |
- | |
670 | adjusted_mode->crtc_hsync_start - |
- | |
671 | adjusted_mode->crtc_hdisplay; |
- | |
672 | crtc_dtd_timing.usV_SyncOffset = |
- | |
673 | adjusted_mode->crtc_vsync_start - |
- | |
674 | adjusted_mode->crtc_vdisplay; |
- | |
675 | crtc_dtd_timing.usH_SyncWidth = |
- | |
676 | adjusted_mode->crtc_hsync_end - |
- | |
677 | adjusted_mode->crtc_hsync_start; |
- | |
678 | crtc_dtd_timing.usV_SyncWidth = |
- | |
679 | adjusted_mode->crtc_vsync_end - |
- | |
680 | adjusted_mode->crtc_vsync_start; |
- | |
681 | /* crtc_dtd_timing.ucH_Border = adjusted_mode->crtc_hborder; */ |
- | |
682 | /* crtc_dtd_timing.ucV_Border = adjusted_mode->crtc_vborder; */ |
- | |
683 | - | ||
684 | if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC) |
- | |
685 | crtc_dtd_timing.susModeMiscInfo.usAccess |= |
- | |
686 | ATOM_VSYNC_POLARITY; |
- | |
687 | - | ||
688 | if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC) |
- | |
689 | crtc_dtd_timing.susModeMiscInfo.usAccess |= |
- | |
690 | ATOM_HSYNC_POLARITY; |
- | |
691 | - | ||
692 | if (adjusted_mode->flags & DRM_MODE_FLAG_CSYNC) |
- | |
693 | crtc_dtd_timing.susModeMiscInfo.usAccess |= |
- | |
694 | ATOM_COMPOSITESYNC; |
- | |
695 | - | ||
696 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) |
- | |
697 | crtc_dtd_timing.susModeMiscInfo.usAccess |= |
- | |
698 | ATOM_INTERLACE; |
- | |
699 | - | ||
700 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) |
- | |
701 | crtc_dtd_timing.susModeMiscInfo.usAccess |= |
709 | atombios_crtc_set_base(crtc, x, y, old_fb); |
702 | ATOM_DOUBLE_CLOCK_MODE; |
- | |
703 | 710 | else { |
|
704 | atombios_set_crtc_dtd_timing(crtc, &crtc_dtd_timing); |
711 | if (radeon_crtc->crtc_id == 0) |
705 | } |
712 | atombios_set_crtc_dtd_timing(crtc, adjusted_mode); |
706 | radeon_crtc_set_base(crtc, x, y, old_fb); |
713 | radeon_crtc_set_base(crtc, x, y, old_fb); |
707 | radeon_legacy_atom_set_surface(crtc); |
714 | radeon_legacy_atom_set_surface(crtc); |
708 | } |
- | |
709 | atombios_overscan_setup(crtc, mode, adjusted_mode); |
715 | } |
710 | atombios_scaler_setup(crtc); |
716 | atombios_overscan_setup(crtc, mode, adjusted_mode); |
Line 711... | Line 717... | ||
711 | radeon_bandwidth_update(rdev); |
717 | atombios_scaler_setup(crtc); |
712 | return 0; |
718 | return 0; |