radeon/audio: consolidate audio_init() functions
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>
This commit is contained in:
parent
49ead33b9f
commit
bfc1f97d8a
|
@ -81,7 +81,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
|
|||
rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \
|
||||
trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \
|
||||
ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o radeon_mn.o \
|
||||
radeon_sync.o
|
||||
radeon_sync.o radeon_audio.o
|
||||
|
||||
# add async DMA block
|
||||
radeon-y += \
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "drmP.h"
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include "cikd.h"
|
||||
#include "atom.h"
|
||||
#include "cik_blit_shaders.h"
|
||||
|
@ -8517,7 +8518,7 @@ static int cik_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = dce6_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -277,11 +277,6 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder)
|
|||
kfree(sads);
|
||||
}
|
||||
|
||||
static int dce6_audio_chipset_supported(struct radeon_device *rdev)
|
||||
{
|
||||
return !ASIC_IS_NODCE(rdev);
|
||||
}
|
||||
|
||||
void dce6_audio_enable(struct radeon_device *rdev,
|
||||
struct r600_audio_pin *pin,
|
||||
u8 enable_mask)
|
||||
|
@ -293,55 +288,6 @@ void dce6_audio_enable(struct radeon_device *rdev,
|
|||
enable_mask ? AUDIO_ENABLED : 0);
|
||||
}
|
||||
|
||||
static const u32 pin_offsets[7] =
|
||||
{
|
||||
(0x5e00 - 0x5e00),
|
||||
(0x5e18 - 0x5e00),
|
||||
(0x5e30 - 0x5e00),
|
||||
(0x5e48 - 0x5e00),
|
||||
(0x5e60 - 0x5e00),
|
||||
(0x5e78 - 0x5e00),
|
||||
(0x5e90 - 0x5e00),
|
||||
};
|
||||
|
||||
int dce6_audio_init(struct radeon_device *rdev)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!radeon_audio || !dce6_audio_chipset_supported(rdev))
|
||||
return 0;
|
||||
|
||||
rdev->audio.enabled = true;
|
||||
|
||||
if (ASIC_IS_DCE81(rdev)) /* KV: 4 streams, 7 endpoints */
|
||||
rdev->audio.num_pins = 7;
|
||||
else if (ASIC_IS_DCE83(rdev)) /* KB: 2 streams, 3 endpoints */
|
||||
rdev->audio.num_pins = 3;
|
||||
else if (ASIC_IS_DCE8(rdev)) /* BN/HW: 6 streams, 7 endpoints */
|
||||
rdev->audio.num_pins = 7;
|
||||
else if (ASIC_IS_DCE61(rdev)) /* TN: 4 streams, 6 endpoints */
|
||||
rdev->audio.num_pins = 6;
|
||||
else if (ASIC_IS_DCE64(rdev)) /* OL: 2 streams, 2 endpoints */
|
||||
rdev->audio.num_pins = 2;
|
||||
else /* SI: 6 streams, 6 endpoints */
|
||||
rdev->audio.num_pins = 6;
|
||||
|
||||
for (i = 0; i < rdev->audio.num_pins; i++) {
|
||||
rdev->audio.pin[i].channels = -1;
|
||||
rdev->audio.pin[i].rate = -1;
|
||||
rdev->audio.pin[i].bits_per_sample = -1;
|
||||
rdev->audio.pin[i].status_bits = 0;
|
||||
rdev->audio.pin[i].category_code = 0;
|
||||
rdev->audio.pin[i].connected = false;
|
||||
rdev->audio.pin[i].offset = pin_offsets[i];
|
||||
rdev->audio.pin[i].id = i;
|
||||
/* disable audio. it will be set up later */
|
||||
dce6_audio_enable(rdev, &rdev->audio.pin[i], false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dce6_audio_fini(struct radeon_device *rdev)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include <drm/radeon_drm.h>
|
||||
#include "evergreend.h"
|
||||
#include "atom.h"
|
||||
|
@ -5286,7 +5287,7 @@ static int evergreen_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = r600_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r) {
|
||||
DRM_ERROR("radeon: audio init failed\n");
|
||||
return r;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include <drm/radeon_drm.h>
|
||||
#include "nid.h"
|
||||
#include "atom.h"
|
||||
|
@ -2097,15 +2098,9 @@ static int cayman_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
if (ASIC_IS_DCE6(rdev)) {
|
||||
r = dce6_audio_init(rdev);
|
||||
if (r)
|
||||
return r;
|
||||
} else {
|
||||
r = r600_audio_init(rdev);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <drm/radeon_drm.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include "radeon_mode.h"
|
||||
#include "r600d.h"
|
||||
#include "atom.h"
|
||||
|
@ -3054,7 +3055,7 @@ static int r600_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = r600_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r) {
|
||||
DRM_ERROR("radeon: audio init failed\n");
|
||||
return r;
|
||||
|
|
|
@ -70,15 +70,6 @@ static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = {
|
|||
{ 148500, 4096, 148500, 6272, 165000, 6144, 148500 }, /* 148.50 MHz */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* check if the chipset is supported
|
||||
*/
|
||||
static int r600_audio_chipset_supported(struct radeon_device *rdev)
|
||||
{
|
||||
return ASIC_IS_DCE2(rdev) && !ASIC_IS_NODCE(rdev);
|
||||
}
|
||||
|
||||
static struct r600_audio_pin r600_audio_status(struct radeon_device *rdev)
|
||||
{
|
||||
struct r600_audio_pin status;
|
||||
|
@ -191,29 +182,6 @@ void r600_audio_enable(struct radeon_device *rdev,
|
|||
WREG32(AZ_HOT_PLUG_CONTROL, tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize the audio vars
|
||||
*/
|
||||
int r600_audio_init(struct radeon_device *rdev)
|
||||
{
|
||||
if (!radeon_audio || !r600_audio_chipset_supported(rdev))
|
||||
return 0;
|
||||
|
||||
rdev->audio.enabled = true;
|
||||
|
||||
rdev->audio.num_pins = 1;
|
||||
rdev->audio.pin[0].channels = -1;
|
||||
rdev->audio.pin[0].rate = -1;
|
||||
rdev->audio.pin[0].bits_per_sample = -1;
|
||||
rdev->audio.pin[0].status_bits = 0;
|
||||
rdev->audio.pin[0].category_code = 0;
|
||||
rdev->audio.pin[0].id = 0;
|
||||
/* disable audio. it will be set up later */
|
||||
r600_audio_enable(rdev, &rdev->audio.pin[0], 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* release the audio timer
|
||||
* TODO: How to do this correctly on SMP systems?
|
||||
|
|
|
@ -390,7 +390,6 @@ void r600_irq_suspend(struct radeon_device *rdev);
|
|||
void r600_disable_interrupts(struct radeon_device *rdev);
|
||||
void r600_rlc_stop(struct radeon_device *rdev);
|
||||
/* r600 audio */
|
||||
int r600_audio_init(struct radeon_device *rdev);
|
||||
void r600_audio_fini(struct radeon_device *rdev);
|
||||
void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock);
|
||||
void r600_hdmi_update_avi_infoframe(struct drm_encoder *encoder, void *buffer,
|
||||
|
@ -680,7 +679,6 @@ void trinity_dpm_enable_bapm(struct radeon_device *rdev, bool enable);
|
|||
|
||||
/* DCE6 - SI */
|
||||
void dce6_bandwidth_update(struct radeon_device *rdev);
|
||||
int dce6_audio_init(struct radeon_device *rdev);
|
||||
void dce6_audio_fini(struct radeon_device *rdev);
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: Slava Grigorev <slava.grigorev@amd.com>
|
||||
*/
|
||||
|
||||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
|
||||
void r600_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,
|
||||
u8 enable_mask);
|
||||
|
||||
static const u32 pin_offsets[7] =
|
||||
{
|
||||
(0x5e00 - 0x5e00),
|
||||
(0x5e18 - 0x5e00),
|
||||
(0x5e30 - 0x5e00),
|
||||
(0x5e48 - 0x5e00),
|
||||
(0x5e60 - 0x5e00),
|
||||
(0x5e78 - 0x5e00),
|
||||
(0x5e90 - 0x5e00),
|
||||
};
|
||||
|
||||
static int radeon_audio_chipset_supported(struct radeon_device *rdev)
|
||||
{
|
||||
return ASIC_IS_DCE2(rdev) && !ASIC_IS_NODCE(rdev);
|
||||
}
|
||||
|
||||
int radeon_audio_init(struct radeon_device *rdev)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!radeon_audio || !radeon_audio_chipset_supported(rdev))
|
||||
return 0;
|
||||
|
||||
rdev->audio.enabled = true;
|
||||
|
||||
if (ASIC_IS_DCE83(rdev)) /* KB: 2 streams, 3 endpoints */
|
||||
rdev->audio.num_pins = 3;
|
||||
else if (ASIC_IS_DCE81(rdev)) /* KV: 4 streams, 7 endpoints */
|
||||
rdev->audio.num_pins = 7;
|
||||
else if (ASIC_IS_DCE8(rdev)) /* BN/HW: 6 streams, 7 endpoints */
|
||||
rdev->audio.num_pins = 7;
|
||||
else if (ASIC_IS_DCE64(rdev)) /* OL: 2 streams, 2 endpoints */
|
||||
rdev->audio.num_pins = 2;
|
||||
else if (ASIC_IS_DCE61(rdev)) /* TN: 4 streams, 6 endpoints */
|
||||
rdev->audio.num_pins = 6;
|
||||
else if (ASIC_IS_DCE6(rdev)) /* SI: 6 streams, 6 endpoints */
|
||||
rdev->audio.num_pins = 6;
|
||||
else
|
||||
rdev->audio.num_pins = 1;
|
||||
|
||||
for (i = 0; i < rdev->audio.num_pins; i++) {
|
||||
rdev->audio.pin[i].channels = -1;
|
||||
rdev->audio.pin[i].rate = -1;
|
||||
rdev->audio.pin[i].bits_per_sample = -1;
|
||||
rdev->audio.pin[i].status_bits = 0;
|
||||
rdev->audio.pin[i].category_code = 0;
|
||||
rdev->audio.pin[i].connected = false;
|
||||
rdev->audio.pin[i].offset = pin_offsets[i];
|
||||
rdev->audio.pin[i].id = i;
|
||||
/* disable audio. it will be set up later */
|
||||
if (ASIC_IS_DCE6(rdev))
|
||||
dce6_audio_enable(rdev, &rdev->audio.pin[i], false);
|
||||
else
|
||||
r600_audio_enable(rdev, &rdev->audio.pin[i], false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors: Slava Grigorev <slava.grigorev@amd.com>
|
||||
*/
|
||||
#ifndef __RADEON_AUDIO_H__
|
||||
#define __RADEON_AUDIO_H__
|
||||
|
||||
int radeon_audio_init(struct radeon_device *rdev);
|
||||
|
||||
#endif
|
|
@ -38,6 +38,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include "atom.h"
|
||||
#include "rs600d.h"
|
||||
|
||||
|
@ -1012,7 +1013,7 @@ static int rs600_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = r600_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r) {
|
||||
dev_err(rdev->dev, "failed initializing audio\n");
|
||||
return r;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include "atom.h"
|
||||
#include "rs690d.h"
|
||||
|
||||
|
@ -729,7 +730,7 @@ static int rs690_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = r600_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r) {
|
||||
dev_err(rdev->dev, "failed initializing audio\n");
|
||||
return r;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include <drm/radeon_drm.h>
|
||||
#include "rv770d.h"
|
||||
#include "atom.h"
|
||||
|
@ -1788,7 +1789,7 @@ static int rv770_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = r600_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r) {
|
||||
DRM_ERROR("radeon: audio init failed\n");
|
||||
return r;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <drm/drmP.h>
|
||||
#include "radeon.h"
|
||||
#include "radeon_asic.h"
|
||||
#include "radeon_audio.h"
|
||||
#include <drm/radeon_drm.h>
|
||||
#include "sid.h"
|
||||
#include "atom.h"
|
||||
|
@ -6869,7 +6870,7 @@ static int si_startup(struct radeon_device *rdev)
|
|||
return r;
|
||||
}
|
||||
|
||||
r = dce6_audio_init(rdev);
|
||||
r = radeon_audio_init(rdev);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
|
|
Loading…
Reference in New Issue