Commit 8bf59820 authored by Slava Grigorev's avatar Slava Grigorev Committed by Alex Deucher

radeon/audio: consolidate audio_enable() functions

Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarSlava Grigorev <slava.grigorev@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 88252d77
...@@ -137,7 +137,7 @@ void dce3_1_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *m ...@@ -137,7 +137,7 @@ void dce3_1_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *m
/* disable audio prior to setting up hw */ /* disable audio prior to setting up hw */
dig->afmt->pin = radeon_audio_get_pin(encoder); dig->afmt->pin = radeon_audio_get_pin(encoder);
r600_audio_enable(rdev, dig->afmt->pin, 0); radeon_audio_enable(rdev, dig->afmt->pin, 0);
r600_audio_set_dto(encoder, mode->clock); r600_audio_set_dto(encoder, mode->clock);
...@@ -212,5 +212,5 @@ void dce3_1_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *m ...@@ -212,5 +212,5 @@ void dce3_1_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *m
r600_hdmi_audio_workaround(encoder); r600_hdmi_audio_workaround(encoder);
/* enable audio after to setting up hw */ /* enable audio after to setting up hw */
r600_audio_enable(rdev, dig->afmt->pin, 0xf); radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
} }
...@@ -257,7 +257,7 @@ void dce6_audio_fini(struct radeon_device *rdev) ...@@ -257,7 +257,7 @@ void dce6_audio_fini(struct radeon_device *rdev)
return; return;
for (i = 0; i < rdev->audio.num_pins; i++) for (i = 0; i < rdev->audio.num_pins; i++)
dce6_audio_enable(rdev, &rdev->audio.pin[i], false); radeon_audio_enable(rdev, &rdev->audio.pin[i], false);
rdev->audio.enabled = false; rdev->audio.enabled = false;
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "atom.h" #include "atom.h"
/* enable the audio stream */ /* enable the audio stream */
static void dce4_audio_enable(struct radeon_device *rdev, void dce4_audio_enable(struct radeon_device *rdev,
struct r600_audio_pin *pin, struct r600_audio_pin *pin,
u8 enable_mask) u8 enable_mask)
{ {
...@@ -300,11 +300,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode ...@@ -300,11 +300,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
/* disable audio prior to setting up hw */ /* disable audio prior to setting up hw */
dig->afmt->pin = radeon_audio_get_pin(encoder); dig->afmt->pin = radeon_audio_get_pin(encoder);
if (ASIC_IS_DCE6(rdev)) { radeon_audio_enable(rdev, dig->afmt->pin, 0);
dce6_audio_enable(rdev, dig->afmt->pin, 0);
} else {
dce4_audio_enable(rdev, dig->afmt->pin, 0);
}
evergreen_audio_set_dto(encoder, mode->clock); evergreen_audio_set_dto(encoder, mode->clock);
...@@ -435,10 +431,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode ...@@ -435,10 +431,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
WREG32(AFMT_RAMP_CONTROL3 + offset, 0x00000001); WREG32(AFMT_RAMP_CONTROL3 + offset, 0x00000001);
/* enable audio after to setting up hw */ /* enable audio after to setting up hw */
if (ASIC_IS_DCE6(rdev)) radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
dce6_audio_enable(rdev, dig->afmt->pin, 1);
else
dce4_audio_enable(rdev, dig->afmt->pin, 0xf);
} }
void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
...@@ -458,10 +451,7 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) ...@@ -458,10 +451,7 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
return; return;
if (!enable && dig->afmt->pin) { if (!enable && dig->afmt->pin) {
if (ASIC_IS_DCE6(rdev)) radeon_audio_enable(rdev, dig->afmt->pin, 0);
dce6_audio_enable(rdev, dig->afmt->pin, 0);
else
dce4_audio_enable(rdev, dig->afmt->pin, 0);
dig->afmt->pin = NULL; dig->afmt->pin = NULL;
} }
......
...@@ -192,8 +192,7 @@ void r600_audio_fini(struct radeon_device *rdev) ...@@ -192,8 +192,7 @@ void r600_audio_fini(struct radeon_device *rdev)
if (!rdev->audio.enabled) if (!rdev->audio.enabled)
return; return;
r600_audio_enable(rdev, &rdev->audio.pin[0], 0); radeon_audio_enable(rdev, &rdev->audio.pin[0], 0);
rdev->audio.enabled = false; rdev->audio.enabled = false;
} }
...@@ -489,7 +488,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod ...@@ -489,7 +488,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
/* disable audio prior to setting up hw */ /* disable audio prior to setting up hw */
dig->afmt->pin = radeon_audio_get_pin(encoder); dig->afmt->pin = radeon_audio_get_pin(encoder);
r600_audio_enable(rdev, dig->afmt->pin, 0xf); radeon_audio_enable(rdev, dig->afmt->pin, 0);
r600_audio_set_dto(encoder, mode->clock); r600_audio_set_dto(encoder, mode->clock);
...@@ -575,7 +574,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod ...@@ -575,7 +574,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
WREG32(HDMI0_RAMP_CONTROL3 + offset, 0x00000001); WREG32(HDMI0_RAMP_CONTROL3 + offset, 0x00000001);
/* enable audio after to setting up hw */ /* enable audio after to setting up hw */
r600_audio_enable(rdev, dig->afmt->pin, 0xf); radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
} }
/** /**
...@@ -661,7 +660,7 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable) ...@@ -661,7 +660,7 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
return; return;
if (!enable && dig->afmt->pin) { if (!enable && dig->afmt->pin) {
r600_audio_enable(rdev, dig->afmt->pin, 0); radeon_audio_enable(rdev, dig->afmt->pin, 0);
dig->afmt->pin = NULL; dig->afmt->pin = NULL;
} }
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
void r600_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin, void r600_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin,
u8 enable_mask); u8 enable_mask);
void dce4_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin,
u8 enable_mask);
void dce6_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin, void dce6_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin,
u8 enable_mask); u8 enable_mask);
u32 dce6_endpoint_rreg(struct radeon_device *rdev, u32 offset, u32 reg); u32 dce6_endpoint_rreg(struct radeon_device *rdev, u32 offset, u32 reg);
...@@ -86,16 +88,19 @@ static void radeon_audio_wreg(struct radeon_device *rdev, u32 offset, ...@@ -86,16 +88,19 @@ static void radeon_audio_wreg(struct radeon_device *rdev, u32 offset,
static struct radeon_audio_basic_funcs dce32_funcs = { static struct radeon_audio_basic_funcs dce32_funcs = {
.endpoint_rreg = radeon_audio_rreg, .endpoint_rreg = radeon_audio_rreg,
.endpoint_wreg = radeon_audio_wreg, .endpoint_wreg = radeon_audio_wreg,
.enable = r600_audio_enable,
}; };
static struct radeon_audio_basic_funcs dce4_funcs = { static struct radeon_audio_basic_funcs dce4_funcs = {
.endpoint_rreg = radeon_audio_rreg, .endpoint_rreg = radeon_audio_rreg,
.endpoint_wreg = radeon_audio_wreg, .endpoint_wreg = radeon_audio_wreg,
.enable = dce4_audio_enable,
}; };
static struct radeon_audio_basic_funcs dce6_funcs = { static struct radeon_audio_basic_funcs dce6_funcs = {
.endpoint_rreg = dce6_endpoint_rreg, .endpoint_rreg = dce6_endpoint_rreg,
.endpoint_wreg = dce6_endpoint_wreg, .endpoint_wreg = dce6_endpoint_wreg,
.enable = dce6_audio_enable,
}; };
static struct radeon_audio_funcs dce32_hdmi_funcs = { static struct radeon_audio_funcs dce32_hdmi_funcs = {
...@@ -201,10 +206,7 @@ int radeon_audio_init(struct radeon_device *rdev) ...@@ -201,10 +206,7 @@ int radeon_audio_init(struct radeon_device *rdev)
/* disable audio. it will be set up later */ /* disable audio. it will be set up later */
for (i = 0; i < rdev->audio.num_pins; i++) for (i = 0; i < rdev->audio.num_pins; i++)
if (ASIC_IS_DCE6(rdev)) radeon_audio_enable(rdev, &rdev->audio.pin[i], false);
dce6_audio_enable(rdev, &rdev->audio.pin[i], false);
else
r600_audio_enable(rdev, &rdev->audio.pin[i], false);
return 0; return 0;
} }
...@@ -371,3 +373,10 @@ void radeon_audio_select_pin(struct drm_encoder *encoder) ...@@ -371,3 +373,10 @@ void radeon_audio_select_pin(struct drm_encoder *encoder)
if (radeon_encoder->audio && radeon_encoder->audio->select_pin) if (radeon_encoder->audio && radeon_encoder->audio->select_pin)
radeon_encoder->audio->select_pin(encoder); radeon_encoder->audio->select_pin(encoder);
} }
void radeon_audio_enable(struct radeon_device *rdev,
struct r600_audio_pin *pin, u8 enable_mask)
{
if (rdev->audio.funcs->enable)
rdev->audio.funcs->enable(rdev, pin, enable_mask);
}
...@@ -37,6 +37,8 @@ struct radeon_audio_basic_funcs ...@@ -37,6 +37,8 @@ struct radeon_audio_basic_funcs
u32 (*endpoint_rreg)(struct radeon_device *rdev, u32 offset, u32 reg); u32 (*endpoint_rreg)(struct radeon_device *rdev, u32 offset, u32 reg);
void (*endpoint_wreg)(struct radeon_device *rdev, void (*endpoint_wreg)(struct radeon_device *rdev,
u32 offset, u32 reg, u32 v); u32 offset, u32 reg, u32 v);
void (*enable)(struct radeon_device *rdev,
struct r600_audio_pin *pin, u8 enable_mask);
}; };
struct radeon_audio_funcs struct radeon_audio_funcs
...@@ -64,5 +66,7 @@ void radeon_audio_write_latency_fields(struct drm_encoder *encoder, ...@@ -64,5 +66,7 @@ void radeon_audio_write_latency_fields(struct drm_encoder *encoder,
struct drm_display_mode *mode); struct drm_display_mode *mode);
struct r600_audio_pin *radeon_audio_get_pin(struct drm_encoder *encoder); struct r600_audio_pin *radeon_audio_get_pin(struct drm_encoder *encoder);
void radeon_audio_select_pin(struct drm_encoder *encoder); void radeon_audio_select_pin(struct drm_encoder *encoder);
void radeon_audio_enable(struct radeon_device *rdev,
struct r600_audio_pin *pin, u8 enable_mask);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment