Commit beb86f29 authored by Tom St Denis's avatar Tom St Denis Committed by Alex Deucher

drm/amd/amdgpu: Clean up afmt allocation in DCEv6. (v2)

v2: minor build fix
Signed-off-by: default avatarTom St Denis <tom.stdenis@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e37e4f05
...@@ -1422,21 +1422,29 @@ static void dce_v6_0_afmt_enable(struct drm_encoder *encoder, bool enable) ...@@ -1422,21 +1422,29 @@ static void dce_v6_0_afmt_enable(struct drm_encoder *encoder, bool enable)
enable ? "En" : "Dis", dig->afmt->offset, amdgpu_encoder->encoder_id); enable ? "En" : "Dis", dig->afmt->offset, amdgpu_encoder->encoder_id);
} }
static void dce_v6_0_afmt_init(struct amdgpu_device *adev) static int dce_v6_0_afmt_init(struct amdgpu_device *adev)
{ {
int i; int i, j;
for (i = 0; i < adev->mode_info.num_dig; i++) for (i = 0; i < adev->mode_info.num_dig; i++)
adev->mode_info.afmt[i] = NULL; adev->mode_info.afmt[i] = NULL;
/* DCE8 has audio blocks tied to DIG encoders */ /* DCE6 has audio blocks tied to DIG encoders */
for (i = 0; i < adev->mode_info.num_dig; i++) { for (i = 0; i < adev->mode_info.num_dig; i++) {
adev->mode_info.afmt[i] = kzalloc(sizeof(struct amdgpu_afmt), GFP_KERNEL); adev->mode_info.afmt[i] = kzalloc(sizeof(struct amdgpu_afmt), GFP_KERNEL);
if (adev->mode_info.afmt[i]) { if (adev->mode_info.afmt[i]) {
adev->mode_info.afmt[i]->offset = dig_offsets[i]; adev->mode_info.afmt[i]->offset = dig_offsets[i];
adev->mode_info.afmt[i]->id = i; adev->mode_info.afmt[i]->id = i;
} else {
for (j = 0; j < i; j++) {
kfree(adev->mode_info.afmt[j]);
adev->mode_info.afmt[j] = NULL;
}
DRM_ERROR("Out of memory allocating afmt table\n");
return -ENOMEM;
} }
} }
return 0;
} }
static void dce_v6_0_afmt_fini(struct amdgpu_device *adev) static void dce_v6_0_afmt_fini(struct amdgpu_device *adev)
...@@ -2399,7 +2407,9 @@ static int dce_v6_0_sw_init(void *handle) ...@@ -2399,7 +2407,9 @@ static int dce_v6_0_sw_init(void *handle)
return -EINVAL; return -EINVAL;
/* setup afmt */ /* setup afmt */
dce_v6_0_afmt_init(adev); r = dce_v6_0_afmt_init(adev);
if (r)
return r;
r = dce_v6_0_audio_init(adev); r = dce_v6_0_audio_init(adev);
if (r) if (r)
......
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