radeon/audio: consolidate update_avi_infoframe() functions
authorSlava Grigorev <slava.grigorev@amd.com>
Fri, 5 Dec 2014 22:59:56 +0000 (17:59 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 22 Jan 2015 15:42:10 +0000 (10:42 -0500)
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Slava Grigorev <slava.grigorev@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/dce3_1_afmt.c
drivers/gpu/drm/radeon/evergreen_hdmi.c
drivers/gpu/drm/radeon/r600_hdmi.c
drivers/gpu/drm/radeon/radeon_audio.c
drivers/gpu/drm/radeon/radeon_audio.h

index 6cb2f1171539c37717f9fd82b04526b765ccc9f4..0accc5ee0e39b731c78963b0486885d441da997a 100644 (file)
@@ -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 */
index 38b1c51cce4d19ed7c2c072881785c75d221eee6..f2896e5ff05558d95e5d80a8f46e87f1a9fc2871 100644 (file)
@@ -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 */
index 30580d1a14f0d4fee7ed3add9725758d11959c4a..53ee7ad9612c47dbe3da6e205c646efb1e3bc2c9 100644 (file)
@@ -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 */
 
index 2a2bf5b5b805e6d520d6a91c895cf8ac1bf70bb8..cc58ee8c7d2f8e8cdb2296e560bc32c31493dc15 100644 (file)
@@ -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);
+}
index 06b80de7cdbe4eaddf693cdc8784ee2c55cb7d8d..dc85d53d1587cd7309d5aba358707050b1046193 100644 (file)
@@ -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