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

Alex Deucher alexdeucher at gmail.com
Sun Oct 13 18:59:13 CEST 2013


On Sun, Oct 13, 2013 at 12:26 PM, Rafał Miłecki <zajec5 at 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
>


More information about the dri-devel mailing list