Skip to contentSkip to conversation

drm/radeon: put DCE4 audio init/fini in evergreen_hdmi.c

RFC PATCH In review Rafał Miłecki 2 participants 4 messages Oct 13, 2013

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

RFC PATCH 1/1 drm/radeon: put DCE4 audio init/fini in evergreen_hdmi.c

That allow us to use registers defined in evergreend.h.
---
This is another proposal for HDMI code improvment. I'll start testing my patches soon, so I hope to re-send all of them in the following days.

---
 drivers/gpu/drm/radeon/evergreen.c      |    4 +--
 drivers/gpu/drm/radeon/evergreen_hdmi.c |   56 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/r600_audio.c     |   15 ++-------
 drivers/gpu/drm/radeon/radeon_asic.h    |    4 +++
 4 files changed, 65 insertions(+), 14 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +2 -2
index 52fa3be..68a5200 100644
@@ -5246,7 +5246,7 @@ static int evergreen_startup(struct radeon_device *rdev)
 		return r;
 	}
 
-	r = r600_audio_init(rdev);
+	r = dce4_audio_init(rdev);
 	if (r) {
 		DRM_ERROR("radeon: audio init failed\n");
 		return r;
@@ -5288,7 +5288,7 @@ int evergreen_resume(struct radeon_device *rdev)
 
 int evergreen_suspend(struct radeon_device *rdev)
 {
-	r600_audio_fini(rdev);
+	dce4_audio_fini(rdev);
 	uvd_v1_0_fini(rdev);
 	radeon_uvd_suspend(rdev);
 	r700_cp_stop(rdev);
drivers/gpu/drm/radeon/evergreen_hdmi.c +56 -0

59 lines not on this page · raw message

drivers/gpu/drm/radeon/r600_audio.c +3 -12
index 47fc2b8..1511cc5 100644
@@ -146,18 +146,9 @@ static void r600_audio_enable(struct radeon_device *rdev,
 			      struct r600_audio_pin *pin,
 			      bool enable)
 {
-	u32 value = 0;
-
-	if (ASIC_IS_DCE4(rdev)) {
-		if (enable) {
-			value |= 0x81000000; /* Required to enable audio */
-			value |= 0x0e1000f0; /* fglrx sets that too */
-		}
-		WREG32(EVERGREEN_AUDIO_ENABLE, value);
-	} else {
-		WREG32_P(R600_AUDIO_ENABLE,
-			 enable ? 0x81000000 : 0x0, ~0x81000000);
-	}
+	WREG32_P(R600_AUDIO_ENABLE,
+		 enable ? 0x81000000 : 0x0, ~0x81000000);
+
 	DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id);
 }
 
drivers/gpu/drm/radeon/radeon_asic.h +4 -0
index 86d871b..5cf52c0 100644
@@ -469,6 +469,10 @@ int rv770_dpm_force_performance_level(struct radeon_device *rdev,
 				      enum radeon_dpm_forced_level level);
 bool rv770_dpm_vblank_too_short(struct radeon_device *rdev);
 
+/* DCE4 */
+int dce4_audio_init(struct radeon_device *rdev);
+void dce4_audio_fini(struct radeon_device *rdev);
+
 /*
  * evergreen
  */
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 4 lines · Rafał Miłecki

That allow us to use registers defined in evergreend.h.
---
This is another proposal for HDMI code improvment. I'll start testing my patches soon, so I hope to re-send all of them in the following days.

Might be worth adding audio_init/fini callbacks the radeon_asic struct like we dis for hdmi_enable and hdmi_setmode. Might also be worth changing the hdmi_enable and hdmi_setmode callbacks to afmt_enable and afmt_setmode in preparation DP audio support. Either way, patch looks good to me.

Alex

Quoted 135 lines
---
 drivers/gpu/drm/radeon/evergreen.c      |    4 +--
 drivers/gpu/drm/radeon/evergreen_hdmi.c |   56 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/r600_audio.c     |   15 ++-------
 drivers/gpu/drm/radeon/radeon_asic.h    |    4 +++
 4 files changed, 65 insertions(+), 14 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +2 -2
index 52fa3be..68a5200 100644
@@ -5246,7 +5246,7 @@ static int evergreen_startup(struct radeon_device *rdev)
                return r;
        }
 
-       r = r600_audio_init(rdev);
+       r = dce4_audio_init(rdev);
        if (r) {
                DRM_ERROR("radeon: audio init failed\n");
                return r;
@@ -5288,7 +5288,7 @@ int evergreen_resume(struct radeon_device *rdev)
 
 int evergreen_suspend(struct radeon_device *rdev)
 {
-       r600_audio_fini(rdev);
+       dce4_audio_fini(rdev);
        uvd_v1_0_fini(rdev);
        radeon_uvd_suspend(rdev);
        r700_cp_stop(rdev);
drivers/gpu/drm/radeon/evergreen_hdmi.c +56 -0
index 9153b24..98b420e 100644
@@ -403,3 +403,59 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
        DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n",
                  enable ? "En" : "Dis", dig->afmt->offset, radeon_encoder->encoder_id);
 }
+
+static void dce4_audio_enable(struct radeon_device *rdev,
+                             struct r600_audio_pin *pin,
+                             bool enable)
+{
+       static u32 ctl_bits = PIN0_AUDIO_ENABLED |
+                             PIN1_AUDIO_ENABLED |
+                             PIN2_AUDIO_ENABLED |
+                             PIN3_AUDIO_ENABLED |
+                             AUDIO_ENABLED;
+       u32 tmp;
+
+       tmp = RREG32(AZ_HOT_PLUG_CONTROL);
+       if (enable) {
+               tmp |= ctl_bits;
+               WREG32_P(0x5e80, 0x1, ~0x03ffffff);
+       } else {
+               tmp &= ~ctl_bits;
+       }
+       WREG32(AZ_HOT_PLUG_CONTROL, tmp);
+
+       DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id);
+}
+
+int dce4_audio_init(struct radeon_device *rdev)
+{
+       if (!radeon_audio || ASIC_IS_NODCE(rdev))
+               return 0;
+
+       rdev->audio.enabled = true;
+
+       rdev->audio.num_pins = 1;
+       rdev->audio.pin[0].channels = -1;
+       rdev->audio.pin[0].rate = -1;
+       rdev->audio.pin[0].bits_per_sample = -1;
+       rdev->audio.pin[0].status_bits = 0;
+       rdev->audio.pin[0].category_code = 0;
+       rdev->audio.pin[0].id = 0;
+
+       dce4_audio_enable(rdev, &rdev->audio.pin[0], true);
+
+       return 0;
+}
+
+void dce4_audio_fini(struct radeon_device *rdev)
+{
+       int i;
+
+       if (!rdev->audio.enabled)
+               return;
+
+       for (i = 0; i < rdev->audio.num_pins; i++)
+               dce4_audio_enable(rdev, &rdev->audio.pin[i], false);
+
+       rdev->audio.enabled = false;
+}
drivers/gpu/drm/radeon/r600_audio.c +3 -12
index 47fc2b8..1511cc5 100644
@@ -146,18 +146,9 @@ static void r600_audio_enable(struct radeon_device *rdev,
                              struct r600_audio_pin *pin,
                              bool enable)
 {
-       u32 value = 0;
-
-       if (ASIC_IS_DCE4(rdev)) {
-               if (enable) {
-                       value |= 0x81000000; /* Required to enable audio */
-                       value |= 0x0e1000f0; /* fglrx sets that too */
-               }
-               WREG32(EVERGREEN_AUDIO_ENABLE, value);
-       } else {
-               WREG32_P(R600_AUDIO_ENABLE,
-                        enable ? 0x81000000 : 0x0, ~0x81000000);
-       }
+       WREG32_P(R600_AUDIO_ENABLE,
+                enable ? 0x81000000 : 0x0, ~0x81000000);
+
        DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id);
 }
 
drivers/gpu/drm/radeon/radeon_asic.h +4 -1
index 86d871b..5cf52c0 100644
@@ -469,6 +469,10 @@ int rv770_dpm_force_performance_level(struct radeon_device *rdev,
                                      enum radeon_dpm_forced_level level);
 bool rv770_dpm_vblank_too_short(struct radeon_device *rdev);
 
+/* DCE4 */
+int dce4_audio_init(struct radeon_device *rdev);
+void dce4_audio_fini(struct radeon_device *rdev);
+
 /*
  * evergreen
  */
--
Quoted 2 lines

1.7.10.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

2013/10/13 Alex Deucher <[email protected]>:

Quoted 8 lines · Rafał Miłecki
Quoted 4 lines

That allow us to use registers defined in evergreend.h.
---
This is another proposal for HDMI code improvment. I'll start testing my patches soon, so I hope to re-send all of them in the following days.

Might be worth adding audio_init/fini callbacks the radeon_asic struct like we dis for hdmi_enable and hdmi_setmode.

Good idea, thanks.

Quoted 4 lines

Might also be worth
changing the hdmi_enable and hdmi_setmode callbacks to afmt_enable and afmt_setmode in preparation DP audio support. Either way, patch looks good to me.

It's a bit too early for me, I'm not sure what part of code can be shared between HDMI and DP. On the other hand, I want to clean DCE2/3.0/3.2 code too, I'm in progress to collecting the hardware.

Too bad DP monitors/TVs are still so uncommon. Maybe I'll just buy an active DP to HDMI adapter, I think it should make the trick.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 17 lines · Rafał Miłecki

2013/10/13 Alex Deucher <[email protected]>:

Quoted 8 lines · Rafał Miłecki
Quoted 4 lines

That allow us to use registers defined in evergreend.h.
---
This is another proposal for HDMI code improvment. I'll start testing my patches soon, so I hope to re-send all of them in the following days.

Might be worth adding audio_init/fini callbacks the radeon_asic struct like we dis for hdmi_enable and hdmi_setmode.

Good idea, thanks.

Quoted 4 lines

Might also be worth
changing the hdmi_enable and hdmi_setmode callbacks to afmt_enable and afmt_setmode in preparation DP audio support. Either way, patch looks good to me.

Quoted 6 lines

It's a bit too early for me, I'm not sure what part of code can be shared between HDMI and DP. On the other hand, I want to clean DCE2/3.0/3.2 code too, I'm in progress to collecting the hardware.

Too bad DP monitors/TVs are still so uncommon. Maybe I'll just buy an active DP to HDMI adapter, I think it should make the trick.

Audio works pretty much the same between DP and HDMI (IIRC, the use the same CEA infoframes, etc) so most of the code can be shared. We can help clarify things when we get there. Also, I think maybe only DCE4 and newer support DP audio (DCE3.2 might, not sure).

Alex
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel