radeon/audio: consolidate audio_init() functions
authorSlava Grigorev <slava.grigorev@amd.com>
Mon, 22 Dec 2014 22:26:51 +0000 (17:26 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 22 Jan 2015 15:38:59 +0000 (10:38 -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>
14 files changed:
drivers/gpu/drm/radeon/Makefile
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/dce6_afmt.c
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/ni.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/r600_hdmi.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_audio.c [new file with mode: 0644]
drivers/gpu/drm/radeon/radeon_audio.h [new file with mode: 0644]
drivers/gpu/drm/radeon/rs600.c
drivers/gpu/drm/radeon/rs690.c
drivers/gpu/drm/radeon/rv770.c
drivers/gpu/drm/radeon/si.c

index c58cfd3c3917845c137651c03b8ed41da672b11d..f9dab1cb85baee2364933fd232ecd6215b3e4166 100644 (file)
@@ -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 += \
index ed336fbfab7c50f6f7ddea35115e6ac224157faf..efbcd23e9c51ffb775451ff5c39a617f8e5f2d80 100644 (file)
@@ -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;
 
index f312edf4d50eaedeac6fca1af4de8a8457b10e17..a97fb22ed06afef20de76ea26ea42e14a7404abb 100644 (file)
@@ -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;
index 85995b4e33387586448629c44ae31bbff103f10e..406ea8ee085226fc7f27e86223ff6ff0aebdfc70 100644 (file)
@@ -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;
index aea48c89b24170e692bc91bf2b4c927ef9d08784..d2f10408c560148db4bb6d325a4af46a9e21ce07 100644 (file)
@@ -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;
 }
index ef5d6066fa5bbb95d40e8ff4ab99d8953d0f61b1..de7878aef65c760d5298994a33e7c9a827d1d8d8 100644 (file)
@@ -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;
index b90dc0eb08e6637623af76e3f76911ced593fba3..96a26b0c435b902ee0cd4e86a102d3d019ba6723 100644 (file)
@@ -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?
index 5142bc97f6b63188b866fe7b8b11379a53705885..6eacf410a45f3ce380cffe3774cb08a97925ce27 100644 (file)
@@ -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);
 
 /*
diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c
new file mode 100644 (file)
index 0000000..cc835e2
--- /dev/null
@@ -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;
+}
diff --git a/drivers/gpu/drm/radeon/radeon_audio.h b/drivers/gpu/drm/radeon/radeon_audio.h
new file mode 100644 (file)
index 0000000..8455fbd
--- /dev/null
@@ -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
index 9acb1c3c005b6ead68e940ba5443b88d3de0be0b..c26f96093a10487d5cf8aa283ac469ca9b2f6a5a 100644 (file)
@@ -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;
index 0a2d36e8110838d059b73663e5e055052741272c..0fc5592219336ea769d897f42fec48e742c5bf0f 100644 (file)
@@ -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;
index 372016e266d0add52a44b3a9a012d21415d77eea..9bdeb4edb722807ed9c6f5c08cfa59343122dd6f 100644 (file)
@@ -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;
index 5d89b874a1a25851aa331af54f3ae6a0fd7c39cc..86cdc6798240303f738525d39edc933d3fe4f64a 100644 (file)
@@ -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;