Message ID | 1381681584-14810-1-git-send-email-zajec5@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, Oct 13, 2013 at 12:26 PM, Rafa? Mi?ecki <zajec5@gmail.com> wrote: > 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 > --- > 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(-) > > diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c > index 52fa3be..68a5200 100644 > --- a/drivers/gpu/drm/radeon/evergreen.c > +++ b/drivers/gpu/drm/radeon/evergreen.c > @@ -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); > diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c > index 9153b24..98b420e 100644 > --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c > +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c > @@ -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; > +} > diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c > index 47fc2b8..1511cc5 100644 > --- a/drivers/gpu/drm/radeon/r600_audio.c > +++ b/drivers/gpu/drm/radeon/r600_audio.c > @@ -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); > } > > diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h > index 86d871b..5cf52c0 100644 > --- a/drivers/gpu/drm/radeon/radeon_asic.h > +++ b/drivers/gpu/drm/radeon/radeon_asic.h > @@ -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 > */ > -- > 1.7.10.4 >
2013/10/13 Alex Deucher <alexdeucher@gmail.com>: > On Sun, Oct 13, 2013 at 12:26 PM, Rafa? Mi?ecki <zajec5@gmail.com> wrote: >> 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. > 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.
On Sun, Oct 13, 2013 at 1:06 PM, Rafa? Mi?ecki <zajec5@gmail.com> wrote: > 2013/10/13 Alex Deucher <alexdeucher@gmail.com>: >> On Sun, Oct 13, 2013 at 12:26 PM, Rafa? Mi?ecki <zajec5@gmail.com> wrote: >>> 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. > >> 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. 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
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index 52fa3be..68a5200 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c @@ -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); diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index 9153b24..98b420e 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c @@ -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; +} diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c index 47fc2b8..1511cc5 100644 --- a/drivers/gpu/drm/radeon/r600_audio.c +++ b/drivers/gpu/drm/radeon/r600_audio.c @@ -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); } diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 86d871b..5cf52c0 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h @@ -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 */