Subversion Repositories Kolibri OS

Rev

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

Rev 1275 Rev 1321
Line 28... Line 28...
28
#include 
28
#include 
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"
Line -... Line 32...
-
 
32
 
-
 
33
static void radeon_overscan_setup(struct drm_crtc *crtc,
-
 
34
				  struct drm_display_mode *mode)
-
 
35
{
-
 
36
	struct drm_device *dev = crtc->dev;
-
 
37
	struct radeon_device *rdev = dev->dev_private;
-
 
38
	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-
 
39
 
-
 
40
	WREG32(RADEON_OVR_CLR + radeon_crtc->crtc_offset, 0);
-
 
41
	WREG32(RADEON_OVR_WID_LEFT_RIGHT + radeon_crtc->crtc_offset, 0);
-
 
42
	WREG32(RADEON_OVR_WID_TOP_BOTTOM + radeon_crtc->crtc_offset, 0);
-
 
43
}
32
 
44
 
33
static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
45
static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
34
				       struct drm_display_mode *mode,
46
				       struct drm_display_mode *mode,
35
				       struct drm_display_mode *adjusted_mode)
47
				       struct drm_display_mode *adjusted_mode)
36
{
48
{
Line 290... Line 302...
290
	struct drm_device *dev = crtc->dev;
302
	struct drm_device *dev = crtc->dev;
291
	struct radeon_device *rdev = dev->dev_private;
303
	struct radeon_device *rdev = dev->dev_private;
292
	uint32_t mask;
304
	uint32_t mask;
Line 293... Line 305...
293
 
305
 
294
	if (radeon_crtc->crtc_id)
306
	if (radeon_crtc->crtc_id)
295
		mask = (RADEON_CRTC2_EN |
-
 
296
			RADEON_CRTC2_DISP_DIS |
307
		mask = (RADEON_CRTC2_DISP_DIS |
297
			RADEON_CRTC2_VSYNC_DIS |
308
			RADEON_CRTC2_VSYNC_DIS |
298
			RADEON_CRTC2_HSYNC_DIS |
309
			RADEON_CRTC2_HSYNC_DIS |
299
			RADEON_CRTC2_DISP_REQ_EN_B);
310
			RADEON_CRTC2_DISP_REQ_EN_B);
300
	else
311
	else
Line 303... Line 314...
303
			RADEON_CRTC_HSYNC_DIS);
314
			RADEON_CRTC_HSYNC_DIS);
Line 304... Line 315...
304
 
315
 
305
	switch (mode) {
316
	switch (mode) {
306
	case DRM_MODE_DPMS_ON:
317
	case DRM_MODE_DPMS_ON:
307
		if (radeon_crtc->crtc_id)
318
		if (radeon_crtc->crtc_id)
308
			WREG32_P(RADEON_CRTC2_GEN_CNTL, RADEON_CRTC2_EN, ~mask);
319
			WREG32_P(RADEON_CRTC2_GEN_CNTL, RADEON_CRTC2_EN, ~(RADEON_CRTC2_EN | mask));
309
		else {
320
		else {
310
			WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_EN, ~(RADEON_CRTC_EN |
321
			WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_EN, ~(RADEON_CRTC_EN |
311
									 RADEON_CRTC_DISP_REQ_EN_B));
322
									 RADEON_CRTC_DISP_REQ_EN_B));
312
			WREG32_P(RADEON_CRTC_EXT_CNTL, 0, ~mask);
323
			WREG32_P(RADEON_CRTC_EXT_CNTL, 0, ~mask);
Line 317... Line 328...
317
	case DRM_MODE_DPMS_STANDBY:
328
	case DRM_MODE_DPMS_STANDBY:
318
	case DRM_MODE_DPMS_SUSPEND:
329
	case DRM_MODE_DPMS_SUSPEND:
319
	case DRM_MODE_DPMS_OFF:
330
	case DRM_MODE_DPMS_OFF:
320
//       drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id);
331
//       drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id);
321
		if (radeon_crtc->crtc_id)
332
		if (radeon_crtc->crtc_id)
322
			WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~mask);
333
			WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~(RADEON_CRTC2_EN | mask));
323
		else {
334
		else {
324
			WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_DISP_REQ_EN_B, ~(RADEON_CRTC_EN |
335
			WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_DISP_REQ_EN_B, ~(RADEON_CRTC_EN |
325
										    RADEON_CRTC_DISP_REQ_EN_B));
336
										    RADEON_CRTC_DISP_REQ_EN_B));
326
			WREG32_P(RADEON_CRTC_EXT_CNTL, mask, ~mask);
337
			WREG32_P(RADEON_CRTC_EXT_CNTL, mask, ~mask);
327
		}
338
		}
Line 398... Line 409...
398
	struct drm_device *dev = crtc->dev;
409
	struct drm_device *dev = crtc->dev;
399
	struct radeon_device *rdev = dev->dev_private;
410
	struct radeon_device *rdev = dev->dev_private;
400
	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
411
	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
401
	struct radeon_framebuffer *radeon_fb;
412
	struct radeon_framebuffer *radeon_fb;
402
	struct drm_gem_object *obj;
413
	struct drm_gem_object *obj;
-
 
414
	struct radeon_bo *rbo;
403
	uint64_t base;
415
	uint64_t base;
404
	uint32_t crtc_offset, crtc_offset_cntl, crtc_tile_x0_y0 = 0;
416
	uint32_t crtc_offset, crtc_offset_cntl, crtc_tile_x0_y0 = 0;
405
	uint32_t crtc_pitch, pitch_pixels;
417
	uint32_t crtc_pitch, pitch_pixels;
406
	uint32_t tiling_flags;
418
	uint32_t tiling_flags;
407
	int format;
419
	int format;
408
	uint32_t gen_cntl_reg, gen_cntl_val;
420
	uint32_t gen_cntl_reg, gen_cntl_val;
-
 
421
	int r;
Line 409... Line 422...
409
 
422
 
-
 
423
	DRM_DEBUG("\n");
-
 
424
	/* no fb bound */
-
 
425
	if (!crtc->fb) {
-
 
426
		DRM_DEBUG("No FB bound\n");
-
 
427
		return 0;
Line 410... Line 428...
410
	DRM_DEBUG("\n");
428
	}
Line 411... Line 429...
411
 
429
 
412
	radeon_fb = to_radeon_framebuffer(crtc->fb);
430
	radeon_fb = to_radeon_framebuffer(crtc->fb);
Line 429... Line 447...
429
		break;
447
		break;
430
	default:
448
	default:
431
		return false;
449
		return false;
432
	}
450
	}
Line -... Line 451...
-
 
451
 
433
 
452
	/* Pin framebuffer & get tilling informations */
-
 
453
	obj = radeon_fb->obj;
-
 
454
	rbo = obj->driver_private;
-
 
455
	r = radeon_bo_reserve(rbo, false);
-
 
456
	if (unlikely(r != 0))
434
	obj = radeon_fb->obj;
457
		return r;
-
 
458
	r = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &base);
-
 
459
	if (unlikely(r != 0)) {
435
//   if (radeon_gem_object_pin(obj, RADEON_GEM_DOMAIN_VRAM, &base)) {
460
		radeon_bo_unreserve(rbo);
436
//       return -EINVAL;
461
		return -EINVAL;
-
 
462
	}
437
//   }
463
	radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
-
 
464
	radeon_bo_unreserve(rbo);
-
 
465
	if (tiling_flags & RADEON_TILING_MICRO)
Line 438... Line 466...
438
    base = rdev->mc.vram_location;
466
		DRM_ERROR("trying to scanout microtiled buffer\n");
439
 
467
 
440
	/* if scanout was in GTT this really wouldn't work */
468
	/* if scanout was in GTT this really wouldn't work */
Line 449... Line 477...
449
	crtc_pitch  = (((pitch_pixels * crtc->fb->bits_per_pixel) +
477
	crtc_pitch  = (((pitch_pixels * crtc->fb->bits_per_pixel) +
450
			((crtc->fb->bits_per_pixel * 8) - 1)) /
478
			((crtc->fb->bits_per_pixel * 8) - 1)) /
451
		       (crtc->fb->bits_per_pixel * 8));
479
		       (crtc->fb->bits_per_pixel * 8));
452
	crtc_pitch |= crtc_pitch << 16;
480
	crtc_pitch |= crtc_pitch << 16;
Line 453... Line -...
453
 
-
 
454
//	radeon_object_get_tiling_flags(obj->driver_private,
-
 
455
//				       &tiling_flags, NULL);
-
 
456
    tiling_flags = 0;
-
 
457
 
-
 
458
	if (tiling_flags & RADEON_TILING_MICRO)
-
 
Line 459... Line 481...
459
		DRM_ERROR("trying to scanout microtiled buffer\n");
481
 
460
 
482
 
461
	if (tiling_flags & RADEON_TILING_MACRO) {
483
	if (tiling_flags & RADEON_TILING_MACRO) {
462
		if (ASIC_IS_R300(rdev))
484
		if (ASIC_IS_R300(rdev))
Line 530... Line 552...
530
	}
552
	}
531
	WREG32(RADEON_CRTC_OFFSET_CNTL + radeon_crtc->crtc_offset, crtc_offset_cntl);
553
	WREG32(RADEON_CRTC_OFFSET_CNTL + radeon_crtc->crtc_offset, crtc_offset_cntl);
532
	WREG32(RADEON_CRTC_OFFSET + radeon_crtc->crtc_offset, crtc_offset);
554
	WREG32(RADEON_CRTC_OFFSET + radeon_crtc->crtc_offset, crtc_offset);
533
	WREG32(RADEON_CRTC_PITCH + radeon_crtc->crtc_offset, crtc_pitch);
555
	WREG32(RADEON_CRTC_PITCH + radeon_crtc->crtc_offset, crtc_pitch);
Line 534... Line 556...
534
 
556
 
535
//   if (old_fb && old_fb != crtc->fb) {
557
	if (old_fb && old_fb != crtc->fb) {
536
//       radeon_fb = to_radeon_framebuffer(old_fb);
558
		radeon_fb = to_radeon_framebuffer(old_fb);
-
 
559
		rbo = radeon_fb->obj->driver_private;
-
 
560
		r = radeon_bo_reserve(rbo, false);
-
 
561
		if (unlikely(r != 0))
-
 
562
			return r;
-
 
563
		radeon_bo_unpin(rbo);
537
//       radeon_gem_object_unpin(radeon_fb->obj);
564
		radeon_bo_unreserve(rbo);
Line 538... Line 565...
538
//   }
565
	}
539
 
566
 
Line 540... Line 567...
540
	/* Bytes per pixel may have changed */
567
	/* Bytes per pixel may have changed */
Line 644... Line 671...
644
 
671
 
645
	if (radeon_crtc->crtc_id) {
672
	if (radeon_crtc->crtc_id) {
646
		uint32_t crtc2_gen_cntl;
673
		uint32_t crtc2_gen_cntl;
Line 647... Line 674...
647
		uint32_t disp2_merge_cntl;
674
		uint32_t disp2_merge_cntl;
648
 
-
 
649
		/* check to see if TV DAC is enabled for another crtc and keep it enabled */
675
 
650
		if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_CRT2_ON)
-
 
651
			crtc2_gen_cntl = RADEON_CRTC2_CRT2_ON;
-
 
652
		else
-
 
653
			crtc2_gen_cntl = 0;
676
		/* if TV DAC is enabled for another crtc and keep it enabled */
654
 
677
		crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL) & 0x00718080;
655
		crtc2_gen_cntl |= ((format << 8)
678
		crtc2_gen_cntl |= ((format << 8)
656
				   | RADEON_CRTC2_VSYNC_DIS
679
				   | RADEON_CRTC2_VSYNC_DIS
657
				   | RADEON_CRTC2_HSYNC_DIS
680
				   | RADEON_CRTC2_HSYNC_DIS
Line 678... Line 701...
678
	} else {
701
	} else {
679
		uint32_t crtc_gen_cntl;
702
		uint32_t crtc_gen_cntl;
680
		uint32_t crtc_ext_cntl;
703
		uint32_t crtc_ext_cntl;
681
		uint32_t disp_merge_cntl;
704
		uint32_t disp_merge_cntl;
Line -... Line 705...
-
 
705
 
682
 
706
		crtc_gen_cntl = RREG32(RADEON_CRTC_GEN_CNTL) & 0x00718000;
683
		crtc_gen_cntl = (RADEON_CRTC_EXT_DISP_EN
707
		crtc_gen_cntl |= (RADEON_CRTC_EXT_DISP_EN
684
				 | (format << 8)
708
				 | (format << 8)
685
				 | RADEON_CRTC_DISP_REQ_EN_B
709
				 | RADEON_CRTC_DISP_REQ_EN_B
686
				 | ((mode->flags & DRM_MODE_FLAG_DBLSCAN)
710
				 | ((mode->flags & DRM_MODE_FLAG_DBLSCAN)
687
				    ? RADEON_CRTC_DBL_SCAN_EN
711
				    ? RADEON_CRTC_DBL_SCAN_EN
Line 781... Line 805...
781
			}
805
			}
Line 782... Line 806...
782
 
806
 
783
			if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
807
			if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
784
				pll_flags |= RADEON_PLL_NO_ODD_POST_DIV;
808
				pll_flags |= RADEON_PLL_NO_ODD_POST_DIV;
-
 
809
			if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) {
785
			if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) {
810
				if (!rdev->is_atom_bios) {
786
				struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
811
				struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
787
				struct radeon_encoder_lvds *lvds = (struct radeon_encoder_lvds *)radeon_encoder->enc_priv;
812
				struct radeon_encoder_lvds *lvds = (struct radeon_encoder_lvds *)radeon_encoder->enc_priv;
788
				if (lvds) {
813
				if (lvds) {
789
					if (lvds->use_bios_dividers) {
814
					if (lvds->use_bios_dividers) {
Line 792... Line 817...
792
								     (lvds->panel_post_divider << 16));
817
								     (lvds->panel_post_divider << 16));
793
						htotal_cntl  = 0;
818
						htotal_cntl  = 0;
794
						use_bios_divs = true;
819
						use_bios_divs = true;
795
					}
820
					}
796
				}
821
				}
-
 
822
				}
797
				pll_flags |= RADEON_PLL_USE_REF_DIV;
823
				pll_flags |= RADEON_PLL_USE_REF_DIV;
798
			}
824
			}
799
		}
825
		}
800
	}
826
	}
Line 1029... Line 1055...
1029
 
1055
 
1030
	/* TODO TV */
1056
	/* TODO TV */
1031
	radeon_crtc_set_base(crtc, x, y, old_fb);
1057
	radeon_crtc_set_base(crtc, x, y, old_fb);
1032
	radeon_set_crtc_timing(crtc, adjusted_mode);
1058
	radeon_set_crtc_timing(crtc, adjusted_mode);
-
 
1059
	radeon_set_pll(crtc, adjusted_mode);
1033
	radeon_set_pll(crtc, adjusted_mode);
1060
	radeon_overscan_setup(crtc, adjusted_mode);
1034
	if (radeon_crtc->crtc_id == 0) {
1061
	if (radeon_crtc->crtc_id == 0) {
1035
		radeon_legacy_rmx_mode_set(crtc, mode, adjusted_mode);
1062
		radeon_legacy_rmx_mode_set(crtc, mode, adjusted_mode);
1036
	} else {
1063
	} else {
1037
		if (radeon_crtc->rmx_type != RMX_OFF) {
1064
		if (radeon_crtc->rmx_type != RMX_OFF) {
Line 1044... Line 1071...
1044
	return 0;
1071
	return 0;
1045
}
1072
}
Line 1046... Line 1073...
1046
 
1073
 
1047
static void radeon_crtc_prepare(struct drm_crtc *crtc)
1074
static void radeon_crtc_prepare(struct drm_crtc *crtc)
-
 
1075
{
-
 
1076
	struct drm_device *dev = crtc->dev;
-
 
1077
	struct drm_crtc *crtci;
-
 
1078
 
-
 
1079
	/*
-
 
1080
	* The hardware wedges sometimes if you reconfigure one CRTC
-
 
1081
	* whilst another is running (see fdo bug #24611).
-
 
1082
	*/
1048
{
1083
	list_for_each_entry(crtci, &dev->mode_config.crtc_list, head)
1049
	radeon_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
1084
		radeon_crtc_dpms(crtci, DRM_MODE_DPMS_OFF);
Line 1050... Line 1085...
1050
}
1085
}
1051
 
1086
 
-
 
1087
static void radeon_crtc_commit(struct drm_crtc *crtc)
-
 
1088
{
-
 
1089
	struct drm_device *dev = crtc->dev;
-
 
1090
	struct drm_crtc *crtci;
-
 
1091
 
-
 
1092
	/*
-
 
1093
	* Reenable the CRTCs that should be running.
-
 
1094
	*/
1052
static void radeon_crtc_commit(struct drm_crtc *crtc)
1095
	list_for_each_entry(crtci, &dev->mode_config.crtc_list, head) {
-
 
1096
		if (crtci->enabled)
1053
{
1097
			radeon_crtc_dpms(crtci, DRM_MODE_DPMS_ON);
Line 1054... Line 1098...
1054
	radeon_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
1098
	}
1055
}
1099
}
1056
 
1100