From 96ea7afbc256ce7e2b2446909f52dab357942c3c Mon Sep 17 00:00:00 2001 From: Slava Grigorev Date: Fri, 5 Dec 2014 17:59:56 -0500 Subject: [PATCH] radeon/audio: consolidate update_avi_infoframe() functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Christian König Signed-off-by: Slava Grigorev Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/dce3_1_afmt.c | 2 +- drivers/gpu/drm/radeon/evergreen_hdmi.c | 16 +++++----------- drivers/gpu/drm/radeon/r600_hdmi.c | 14 ++++---------- drivers/gpu/drm/radeon/radeon_audio.c | 20 ++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_audio.h | 4 ++++ 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c index 6cb2f1171539..0accc5ee0e39 100644 --- a/drivers/gpu/drm/radeon/dce3_1_afmt.c +++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c @@ -254,7 +254,7 @@ void dce3_1_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *m return; } - r600_hdmi_update_avi_infoframe(encoder, buffer, sizeof(buffer)); + radeon_update_avi_infoframe(encoder, buffer, sizeof(buffer)); r600_hdmi_update_ACR(encoder, mode->clock); /* it's unknown what these bits do excatly, but it's indeed quite useful for debugging */ diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index 38b1c51cce4d..f2896e5ff055 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c @@ -195,18 +195,12 @@ void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder, } /* - * build a HDMI Video Info Frame + * build a AVI Info Frame */ -static void evergreen_hdmi_update_avi_infoframe(struct drm_encoder *encoder, - void *buffer, size_t size) +void evergreen_update_avi_infoframe(struct radeon_device *rdev, u32 offset, + unsigned char *buffer, size_t size) { - struct drm_device *dev = encoder->dev; - struct radeon_device *rdev = dev->dev_private; - struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); - struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; - uint32_t offset = dig->afmt->offset; uint8_t *frame = buffer + 3; - uint8_t *header = buffer; WREG32(AFMT_AVI_INFO0 + offset, frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24)); @@ -215,7 +209,7 @@ static void evergreen_hdmi_update_avi_infoframe(struct drm_encoder *encoder, WREG32(AFMT_AVI_INFO2 + offset, frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24)); WREG32(AFMT_AVI_INFO3 + offset, - frame[0xC] | (frame[0xD] << 8) | (header[1] << 24)); + frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24)); } void dce4_hdmi_audio_set_dto(struct radeon_device *rdev, @@ -431,7 +425,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode return; } - evergreen_hdmi_update_avi_infoframe(encoder, buffer, sizeof(buffer)); + radeon_update_avi_infoframe(encoder, buffer, sizeof(buffer)); WREG32_OR(HDMI_INFOFRAME_CONTROL0 + offset, HDMI_AVI_INFO_SEND | /* enable AVI info frames */ diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c index 30580d1a14f0..53ee7ad9612c 100644 --- a/drivers/gpu/drm/radeon/r600_hdmi.c +++ b/drivers/gpu/drm/radeon/r600_hdmi.c @@ -285,16 +285,10 @@ void r600_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t clock) /* * build a HDMI Video Info Frame */ -void r600_hdmi_update_avi_infoframe(struct drm_encoder *encoder, void *buffer, - size_t size) +void r600_update_avi_infoframe(struct radeon_device *rdev, u32 offset, + unsigned char *buffer, size_t size) { - struct drm_device *dev = encoder->dev; - struct radeon_device *rdev = dev->dev_private; - struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); - struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; - uint32_t offset = dig->afmt->offset; uint8_t *frame = buffer + 3; - uint8_t *header = buffer; WREG32(HDMI0_AVI_INFO0 + offset, frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24)); @@ -303,7 +297,7 @@ void r600_hdmi_update_avi_infoframe(struct drm_encoder *encoder, void *buffer, WREG32(HDMI0_AVI_INFO2 + offset, frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24)); WREG32(HDMI0_AVI_INFO3 + offset, - frame[0xC] | (frame[0xD] << 8) | (header[1] << 24)); + frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24)); } /* @@ -486,7 +480,7 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod return; } - r600_hdmi_update_avi_infoframe(encoder, buffer, sizeof(buffer)); + radeon_update_avi_infoframe(encoder, buffer, sizeof(buffer)); /* fglrx duplicates INFOFRAME_CONTROL0 & INFOFRAME_CONTROL1 ops here */ diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c index 2a2bf5b5b805..cc58ee8c7d2f 100644 --- a/drivers/gpu/drm/radeon/radeon_audio.c +++ b/drivers/gpu/drm/radeon/radeon_audio.c @@ -74,6 +74,10 @@ void dce6_hdmi_audio_set_dto(struct radeon_device *rdev, struct radeon_crtc *crtc, unsigned int clock); void dce6_dp_audio_set_dto(struct radeon_device *rdev, struct radeon_crtc *crtc, unsigned int clock); +void r600_update_avi_infoframe(struct radeon_device *rdev, u32 offset, + unsigned char *buffer, size_t size); +void evergreen_update_avi_infoframe(struct radeon_device *rdev, u32 offset, + unsigned char *buffer, size_t size); static const u32 pin_offsets[7] = { @@ -101,24 +105,28 @@ static struct radeon_audio_basic_funcs r600_funcs = { .endpoint_rreg = radeon_audio_rreg, .endpoint_wreg = radeon_audio_wreg, .enable = r600_audio_enable, + .update_avi_infoframe = r600_update_avi_infoframe, }; static struct radeon_audio_basic_funcs dce32_funcs = { .endpoint_rreg = radeon_audio_rreg, .endpoint_wreg = radeon_audio_wreg, .enable = r600_audio_enable, + .update_avi_infoframe = r600_update_avi_infoframe, }; static struct radeon_audio_basic_funcs dce4_funcs = { .endpoint_rreg = radeon_audio_rreg, .endpoint_wreg = radeon_audio_wreg, .enable = dce4_audio_enable, + .update_avi_infoframe = evergreen_update_avi_infoframe, }; static struct radeon_audio_basic_funcs dce6_funcs = { .endpoint_rreg = dce6_endpoint_rreg, .endpoint_wreg = dce6_endpoint_wreg, .enable = dce6_audio_enable, + .update_avi_infoframe = evergreen_update_avi_infoframe, }; static struct radeon_audio_funcs r600_hdmi_funcs = { @@ -436,3 +444,15 @@ void radeon_audio_set_dto(struct drm_encoder *encoder, unsigned int clock) if (radeon_encoder->audio && radeon_encoder->audio->set_dto) radeon_encoder->audio->set_dto(rdev, crtc, clock); } + +void radeon_update_avi_infoframe(struct drm_encoder *encoder, void *buffer, + size_t size) +{ + struct radeon_device *rdev = encoder->dev->dev_private; + struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); + struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; + + if (dig && dig->afmt && rdev->audio.funcs->update_avi_infoframe) + rdev->audio.funcs->update_avi_infoframe(rdev, dig->afmt->offset, + buffer, size); +} diff --git a/drivers/gpu/drm/radeon/radeon_audio.h b/drivers/gpu/drm/radeon/radeon_audio.h index 06b80de7cdbe..dc85d53d1587 100644 --- a/drivers/gpu/drm/radeon/radeon_audio.h +++ b/drivers/gpu/drm/radeon/radeon_audio.h @@ -39,6 +39,8 @@ struct radeon_audio_basic_funcs u32 offset, u32 reg, u32 v); void (*enable)(struct radeon_device *rdev, struct r600_audio_pin *pin, u8 enable_mask); + void (*update_avi_infoframe)(struct radeon_device *rdev, u32 offset, + unsigned char *buffer, size_t size); }; struct radeon_audio_funcs @@ -72,5 +74,7 @@ void radeon_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin, u8 enable_mask); void radeon_audio_fini(struct radeon_device *rdev); void radeon_audio_set_dto(struct drm_encoder *encoder, unsigned int clock); +void radeon_update_avi_infoframe(struct drm_encoder *encoder, void *buffer, + size_t size); #endif -- 2.39.5