diff options
author | Slava Grigorev <slava.grigorev@amd.com> | 2014-12-02 11:20:48 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-01-22 10:42:06 -0500 |
commit | 87654f87af2a06f325cc1a1a6e6a6a27f8837bf3 (patch) | |
tree | d973cd687c2e120ea9ae55c7f9e765f8df0c17bf /drivers/gpu | |
parent | 00a9d4bcf8983a5aefcabf5de26b3cb7f805121c (diff) |
radeon/audio: consolidate write_latency_fields() functions
Signed-off-by: Slava Grigorev <slava.grigorev@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/dce6_afmt.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen_hdmi.c | 29 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_audio.c | 34 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_audio.h | 4 |
4 files changed, 44 insertions, 39 deletions
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c index a24c95a6e71e..96f298c92481 100644 --- a/drivers/gpu/drm/radeon/dce6_afmt.c +++ b/drivers/gpu/drm/radeon/dce6_afmt.c | |||
@@ -102,13 +102,11 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder) | |||
102 | } | 102 | } |
103 | 103 | ||
104 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, | 104 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, |
105 | struct drm_display_mode *mode) | 105 | struct drm_connector *connector, struct drm_display_mode *mode) |
106 | { | 106 | { |
107 | struct radeon_device *rdev = encoder->dev->dev_private; | 107 | struct radeon_device *rdev = encoder->dev->dev_private; |
108 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 108 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
109 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | 109 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
110 | struct drm_connector *connector; | ||
111 | struct radeon_connector *radeon_connector = NULL; | ||
112 | u32 tmp = 0, offset; | 110 | u32 tmp = 0, offset; |
113 | 111 | ||
114 | if (!dig || !dig->afmt || !dig->afmt->pin) | 112 | if (!dig || !dig->afmt || !dig->afmt->pin) |
@@ -116,18 +114,6 @@ void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, | |||
116 | 114 | ||
117 | offset = dig->afmt->pin->offset; | 115 | offset = dig->afmt->pin->offset; |
118 | 116 | ||
119 | list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { | ||
120 | if (connector->encoder == encoder) { | ||
121 | radeon_connector = to_radeon_connector(connector); | ||
122 | break; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | if (!radeon_connector) { | ||
127 | DRM_ERROR("Couldn't find encoder's connector\n"); | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { | 117 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
132 | if (connector->latency_present[1]) | 118 | if (connector->latency_present[1]) |
133 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | | 119 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | |
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index 58ff82b94f97..aa8a31b99c6e 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c | |||
@@ -34,8 +34,6 @@ | |||
34 | #include "atom.h" | 34 | #include "atom.h" |
35 | 35 | ||
36 | extern void dce6_afmt_select_pin(struct drm_encoder *encoder); | 36 | extern void dce6_afmt_select_pin(struct drm_encoder *encoder); |
37 | extern void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, | ||
38 | struct drm_display_mode *mode); | ||
39 | 37 | ||
40 | /* enable the audio stream */ | 38 | /* enable the audio stream */ |
41 | static void dce4_audio_enable(struct radeon_device *rdev, | 39 | static void dce4_audio_enable(struct radeon_device *rdev, |
@@ -90,26 +88,12 @@ static void evergreen_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t cloc | |||
90 | WREG32(HDMI_ACR_48_1 + offset, acr.n_48khz); | 88 | WREG32(HDMI_ACR_48_1 + offset, acr.n_48khz); |
91 | } | 89 | } |
92 | 90 | ||
93 | static void dce4_afmt_write_latency_fields(struct drm_encoder *encoder, | 91 | void dce4_afmt_write_latency_fields(struct drm_encoder *encoder, |
94 | struct drm_display_mode *mode) | 92 | struct drm_connector *connector, struct drm_display_mode *mode) |
95 | { | 93 | { |
96 | struct radeon_device *rdev = encoder->dev->dev_private; | 94 | struct radeon_device *rdev = encoder->dev->dev_private; |
97 | struct drm_connector *connector; | ||
98 | struct radeon_connector *radeon_connector = NULL; | ||
99 | u32 tmp = 0; | 95 | u32 tmp = 0; |
100 | 96 | ||
101 | list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { | ||
102 | if (connector->encoder == encoder) { | ||
103 | radeon_connector = to_radeon_connector(connector); | ||
104 | break; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | if (!radeon_connector) { | ||
109 | DRM_ERROR("Couldn't find encoder's connector\n"); | ||
110 | return; | ||
111 | } | ||
112 | |||
113 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { | 97 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
114 | if (connector->latency_present[1]) | 98 | if (connector->latency_present[1]) |
115 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | | 99 | tmp = VIDEO_LIPSYNC(connector->video_latency[1]) | |
@@ -123,7 +107,7 @@ static void dce4_afmt_write_latency_fields(struct drm_encoder *encoder, | |||
123 | else | 107 | else |
124 | tmp = VIDEO_LIPSYNC(255) | AUDIO_LIPSYNC(255); | 108 | tmp = VIDEO_LIPSYNC(255) | AUDIO_LIPSYNC(255); |
125 | } | 109 | } |
126 | WREG32(AZ_F0_CODEC_PIN0_CONTROL_RESPONSE_LIPSYNC, tmp); | 110 | WREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_RESPONSE_LIPSYNC, tmp); |
127 | } | 111 | } |
128 | 112 | ||
129 | void dce4_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, | 113 | void dce4_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, |
@@ -418,14 +402,11 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode | |||
418 | 402 | ||
419 | /* fglrx sets 0x40 in 0x5f80 here */ | 403 | /* fglrx sets 0x40 in 0x5f80 here */ |
420 | 404 | ||
421 | if (ASIC_IS_DCE6(rdev)) { | 405 | if (ASIC_IS_DCE6(rdev)) |
422 | dce6_afmt_select_pin(encoder); | 406 | dce6_afmt_select_pin(encoder); |
423 | dce6_afmt_write_latency_fields(encoder, mode); | ||
424 | } else { | ||
425 | dce4_afmt_write_latency_fields(encoder, mode); | ||
426 | } | ||
427 | 407 | ||
428 | radeon_audio_write_sad_regs(encoder); | 408 | radeon_audio_write_sad_regs(encoder); |
409 | radeon_audio_write_latency_fields(encoder, mode); | ||
429 | 410 | ||
430 | err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); | 411 | err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); |
431 | if (err < 0) { | 412 | if (err < 0) { |
diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c index 22f12e8e1b14..a95eee14c4bf 100644 --- a/drivers/gpu/drm/radeon/radeon_audio.c +++ b/drivers/gpu/drm/radeon/radeon_audio.c | |||
@@ -53,6 +53,10 @@ void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder, | |||
53 | u8 *sadb, int sad_count); | 53 | u8 *sadb, int sad_count); |
54 | void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder, | 54 | void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder, |
55 | u8 *sadb, int sad_count); | 55 | u8 *sadb, int sad_count); |
56 | void dce4_afmt_write_latency_fields(struct drm_encoder *encoder, | ||
57 | struct drm_connector *connector, struct drm_display_mode *mode); | ||
58 | void dce6_afmt_write_latency_fields(struct drm_encoder *encoder, | ||
59 | struct drm_connector *connector, struct drm_display_mode *mode); | ||
56 | 60 | ||
57 | static const u32 pin_offsets[7] = | 61 | static const u32 pin_offsets[7] = |
58 | { | 62 | { |
@@ -104,21 +108,25 @@ static struct radeon_audio_funcs dce32_dp_funcs = { | |||
104 | static struct radeon_audio_funcs dce4_hdmi_funcs = { | 108 | static struct radeon_audio_funcs dce4_hdmi_funcs = { |
105 | .write_sad_regs = evergreen_hdmi_write_sad_regs, | 109 | .write_sad_regs = evergreen_hdmi_write_sad_regs, |
106 | .write_speaker_allocation = dce4_afmt_hdmi_write_speaker_allocation, | 110 | .write_speaker_allocation = dce4_afmt_hdmi_write_speaker_allocation, |
111 | .write_latency_fields = dce4_afmt_write_latency_fields, | ||
107 | }; | 112 | }; |
108 | 113 | ||
109 | static struct radeon_audio_funcs dce4_dp_funcs = { | 114 | static struct radeon_audio_funcs dce4_dp_funcs = { |
110 | .write_sad_regs = evergreen_hdmi_write_sad_regs, | 115 | .write_sad_regs = evergreen_hdmi_write_sad_regs, |
111 | .write_speaker_allocation = dce4_afmt_dp_write_speaker_allocation, | 116 | .write_speaker_allocation = dce4_afmt_dp_write_speaker_allocation, |
117 | .write_latency_fields = dce4_afmt_write_latency_fields, | ||
112 | }; | 118 | }; |
113 | 119 | ||
114 | static struct radeon_audio_funcs dce6_hdmi_funcs = { | 120 | static struct radeon_audio_funcs dce6_hdmi_funcs = { |
115 | .write_sad_regs = dce6_afmt_write_sad_regs, | 121 | .write_sad_regs = dce6_afmt_write_sad_regs, |
116 | .write_speaker_allocation = dce6_afmt_hdmi_write_speaker_allocation, | 122 | .write_speaker_allocation = dce6_afmt_hdmi_write_speaker_allocation, |
123 | .write_latency_fields = dce6_afmt_write_latency_fields, | ||
117 | }; | 124 | }; |
118 | 125 | ||
119 | static struct radeon_audio_funcs dce6_dp_funcs = { | 126 | static struct radeon_audio_funcs dce6_dp_funcs = { |
120 | .write_sad_regs = dce6_afmt_write_sad_regs, | 127 | .write_sad_regs = dce6_afmt_write_sad_regs, |
121 | .write_speaker_allocation = dce6_afmt_dp_write_speaker_allocation, | 128 | .write_speaker_allocation = dce6_afmt_dp_write_speaker_allocation, |
129 | .write_latency_fields = dce6_afmt_write_latency_fields, | ||
122 | }; | 130 | }; |
123 | 131 | ||
124 | static void radeon_audio_interface_init(struct radeon_device *rdev) | 132 | static void radeon_audio_interface_init(struct radeon_device *rdev) |
@@ -307,3 +315,29 @@ void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder) | |||
307 | 315 | ||
308 | kfree(sadb); | 316 | kfree(sadb); |
309 | } | 317 | } |
318 | |||
319 | void radeon_audio_write_latency_fields(struct drm_encoder *encoder, | ||
320 | struct drm_display_mode *mode) | ||
321 | { | ||
322 | struct radeon_encoder *radeon_encoder; | ||
323 | struct drm_connector *connector; | ||
324 | struct radeon_connector *radeon_connector = 0; | ||
325 | |||
326 | list_for_each_entry(connector, | ||
327 | &encoder->dev->mode_config.connector_list, head) { | ||
328 | if (connector->encoder == encoder) { | ||
329 | radeon_connector = to_radeon_connector(connector); | ||
330 | break; | ||
331 | } | ||
332 | } | ||
333 | |||
334 | if (!radeon_connector) { | ||
335 | DRM_ERROR("Couldn't find encoder's connector\n"); | ||
336 | return; | ||
337 | } | ||
338 | |||
339 | radeon_encoder = to_radeon_encoder(encoder); | ||
340 | |||
341 | if (radeon_encoder->audio && radeon_encoder->audio->write_latency_fields) | ||
342 | radeon_encoder->audio->write_latency_fields(encoder, connector, mode); | ||
343 | } | ||
diff --git a/drivers/gpu/drm/radeon/radeon_audio.h b/drivers/gpu/drm/radeon/radeon_audio.h index cc0596f24d9a..33981c8dd035 100644 --- a/drivers/gpu/drm/radeon/radeon_audio.h +++ b/drivers/gpu/drm/radeon/radeon_audio.h | |||
@@ -41,6 +41,8 @@ struct radeon_audio_basic_funcs | |||
41 | 41 | ||
42 | struct radeon_audio_funcs | 42 | struct radeon_audio_funcs |
43 | { | 43 | { |
44 | void (*write_latency_fields)(struct drm_encoder *encoder, | ||
45 | struct drm_connector *connector, struct drm_display_mode *mode); | ||
44 | void (*write_sad_regs)(struct drm_encoder *encoder, | 46 | void (*write_sad_regs)(struct drm_encoder *encoder, |
45 | struct cea_sad *sads, int sad_count); | 47 | struct cea_sad *sads, int sad_count); |
46 | void (*write_speaker_allocation)(struct drm_encoder *encoder, | 48 | void (*write_speaker_allocation)(struct drm_encoder *encoder, |
@@ -56,5 +58,7 @@ void radeon_audio_endpoint_wreg(struct radeon_device *rdev, | |||
56 | u32 offset, u32 reg, u32 v); | 58 | u32 offset, u32 reg, u32 v); |
57 | void radeon_audio_write_sad_regs(struct drm_encoder *encoder); | 59 | void radeon_audio_write_sad_regs(struct drm_encoder *encoder); |
58 | void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder); | 60 | void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder); |
61 | void radeon_audio_write_latency_fields(struct drm_encoder *encoder, | ||
62 | struct drm_display_mode *mode); | ||
59 | 63 | ||
60 | #endif | 64 | #endif |