Skip to contentSkip to conversation

drm/radeon/kms: support for audio on Evergreen

RFC PATCH New Rafał Miłecki 1 participant 2 messages Dec 4, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 drm/radeon/kms: support for audio on Evergreen

---
 drivers/gpu/drm/radeon/evergreen.c     |   14 ++++++++++++++
 drivers/gpu/drm/radeon/evergreen_reg.h |    7 +++++++
 drivers/gpu/drm/radeon/r600_audio.c    |   17 ++++++++++++++---
 3 files changed, 35 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +14 -0
index e4c384b..a7da8d4 100644
@@ -3069,6 +3069,12 @@ static int evergreen_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
+	r = r600_audio_init(rdev);
+	if (r) {
+		DRM_ERROR("radeon: audio init failed\n");
+		return r;
+	}
+
 	return 0;
 }
 
@@ -3100,12 +3106,19 @@ int evergreen_resume(struct radeon_device *rdev)
 		return r;
 	}
 
+	r = r600_audio_init(rdev);
+	if (r) {
+		DRM_ERROR("radeon: audio resume failed\n");
+		return r;
+	}
+
 	return r;
 
 }
 
 int evergreen_suspend(struct radeon_device *rdev)
 {
+	r600_audio_fini(rdev);
 	/* FIXME: we should wait for ring to be empty */
 	r700_cp_stop(rdev);
 	rdev->cp.ready = false;
@@ -3225,6 +3238,7 @@ int evergreen_init(struct radeon_device *rdev)
 
 void evergreen_fini(struct radeon_device *rdev)
 {
+	r600_audio_fini(rdev);
 	r600_blit_fini(rdev);
 	r700_cp_fini(rdev);
 	r600_irq_fini(rdev);
drivers/gpu/drm/radeon/evergreen_reg.h +7 -0
index c781c92..b883911 100644
@@ -35,6 +35,13 @@
 #define EVERGREEN_P1PLL_SS_CNTL                         0x414
 #define EVERGREEN_P2PLL_SS_CNTL                         0x454
 #       define EVERGREEN_PxPLL_SS_EN                    (1 << 12)
+
+#define EVERGREEN_AUDIO_PLL1_MUL                        0x5b0
+#define EVERGREEN_AUDIO_PLL1_DIV                        0x5b4
+#define EVERGREEN_AUDIO_PLL1_UNK                        0x5bc
+
+#define EVERGREEN_AUDIO_ENABLE                          0x5e78
+
 /* GRPH blocks at 0x6800, 0x7400, 0x10000, 0x10c00, 0x11800, 0x12400 */
 #define EVERGREEN_GRPH_ENABLE                           0x6800
 #define EVERGREEN_GRPH_CONTROL                          0x6804
drivers/gpu/drm/radeon/r600_audio.c +14 -3
index fa3bb53..9fe1c0d 100644
@@ -36,7 +36,7 @@
  */
 static int r600_audio_chipset_supported(struct radeon_device *rdev)
 {
-	return (rdev->family >= CHIP_R600 && !ASIC_IS_DCE4(rdev))
+	return (rdev->family >= CHIP_R600 && !ASIC_IS_DCE5(rdev))
 		|| rdev->family == CHIP_RS600
 		|| rdev->family == CHIP_RS690
 		|| rdev->family == CHIP_RS740;
@@ -162,7 +162,12 @@ static void r600_audio_update_hdmi(unsigned long param)
 static void r600_audio_engine_enable(struct radeon_device *rdev, bool enable)
 {
 	DRM_INFO("%s audio support\n", enable ? "Enabling" : "Disabling");
-	WREG32_P(R600_AUDIO_ENABLE, enable ? 0x81000000 : 0x0, ~0x81000000);
+	if (ASIC_IS_DCE4(rdev))
+		WREG32_P(EVERGREEN_AUDIO_ENABLE,
+			 enable ? 0x81000000 : 0x0, ~0x81000000);
+	else
+		WREG32_P(R600_AUDIO_ENABLE,
+			 enable ? 0x81000000 : 0x0, ~0x81000000);
 	rdev->audio_enabled = enable;
 }
 
@@ -249,7 +254,13 @@ void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
 	}
 
 	if (ASIC_IS_DCE4(rdev)) {
-		/* TODO */
+		/* TODO: other PLLs? */
+		WREG32(EVERGREEN_AUDIO_PLL1_MUL, base_rate * 10);
+		WREG32(EVERGREEN_AUDIO_PLL1_DIV, clock * 10);
+		WREG32(EVERGREEN_AUDIO_PLL1_UNK, 0x00000071);
+
+		/* Some magic trigger or src sel? */
+		WREG32_P(0x5ac, 0x01, ~0x77);
 	} else {
 		switch (dig->dig_encoder) {
 		case 0:
Signature · 1 line
1.7.7
#1 lore raw

RFC PATCH 2/2 drm/radeon/kms: enable HDMI on Evergreen encoders

---
 drivers/gpu/drm/radeon/evergreen_reg.h |    3 +++
 drivers/gpu/drm/radeon/r600_hdmi.c     |   16 ++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/evergreen_reg.h +3 -0
index b883911..2dc1365 100644
@@ -198,4 +198,7 @@
 #define EVERGREEN_DC_GPIO_HPD_EN                        0x64b8
 #define EVERGREEN_DC_GPIO_HPD_Y                         0x64bc
 
+#define EVERGREEN_HDMI_BLOCK1                           0x7c30
+#define EVERGREEN_HDMI_CONFIG1                          0x7d20
+
 #endif
drivers/gpu/drm/radeon/r600_hdmi.c +10 -6
index 5021372..fe9c7bc 100644
@@ -313,7 +313,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
 	struct radeon_device *rdev = dev->dev_private;
 	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
 
-	if (ASIC_IS_DCE4(rdev))
+	if (ASIC_IS_DCE5(rdev))
 		return;
 
 	if (!offset)
@@ -463,7 +463,9 @@ static void r600_hdmi_assign_block(struct drm_encoder *encoder)
 	if (ASIC_IS_DCE5(rdev)) {
 		/* TODO */
 	} else if (ASIC_IS_DCE4(rdev)) {
-		/* TODO */
+		/* FIXME: what about other blocks? */
+		radeon_encoder->hdmi_offset = EVERGREEN_HDMI_BLOCK1;
+		radeon_encoder->hdmi_config_offset = EVERGREEN_HDMI_CONFIG1;
 	} else if (ASIC_IS_DCE3(rdev)) {
 		radeon_encoder->hdmi_offset = dig->dig_encoder ?
 			R600_HDMI_BLOCK3 : R600_HDMI_BLOCK1;
@@ -486,7 +488,7 @@ void r600_hdmi_enable(struct drm_encoder *encoder)
 	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 	uint32_t offset;
 
-	if (ASIC_IS_DCE4(rdev))
+	if (ASIC_IS_DCE5(rdev))
 		return;
 
 	if (!radeon_encoder->hdmi_offset) {
@@ -502,7 +504,9 @@ void r600_hdmi_enable(struct drm_encoder *encoder)
 	if (ASIC_IS_DCE5(rdev)) {
 		/* TODO */
 	} else if (ASIC_IS_DCE4(rdev)) {
-		/* TODO */
+		/* FIXME: This -=0x30 is hacky, are the blocks correct? */
+		WREG32_P(offset - 0x30, 0x1000, ~0x1000);
+		WREG32_P(radeon_encoder->hdmi_config_offset + 0xc, 0x1, ~0x1);
 	} else if (ASIC_IS_DCE32(rdev)) {
 		WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0x1, ~0x1);
 	} else if (ASIC_IS_DCE3(rdev)) {
@@ -526,8 +530,8 @@ void r600_hdmi_enable(struct drm_encoder *encoder)
 	if (rdev->irq.installed
 	    && rdev->family != CHIP_RS600
 	    && rdev->family != CHIP_RS690
-	    && rdev->family != CHIP_RS740) {
-
+	    && rdev->family != CHIP_RS740
+	    && !ASIC_IS_DCE4(rdev)) {
 		/* if irq is available use it */
 		rdev->irq.hdmi[offset == R600_HDMI_BLOCK1 ? 0 : 1] = true;
 		radeon_irq_set(rdev);
Signature · 1 line
1.7.7