[RFC PATCH 4/7] ASoC: pxa: switch to new ac97 bus support

From: Robert Jarzmik
Date: Sat Apr 30 2016 - 17:18:10 EST


Switch to the new ac97 bus support in sound/ac97 instead of the legacy
snd_ac97 one.

Signed-off-by: Robert Jarzmik <robert.jarzmik@xxxxxxx>
---
include/sound/pxa2xx-lib.h | 14 ++++++++------
sound/arm/Kconfig | 1 -
sound/arm/pxa2xx-ac97-lib.c | 31 +++++++++++++++++++------------
sound/soc/pxa/Kconfig | 4 ++--
sound/soc/pxa/pxa2xx-ac97.c | 12 +++++++-----
5 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/include/sound/pxa2xx-lib.h b/include/sound/pxa2xx-lib.h
index 6ef629bde164..7072353234f9 100644
--- a/include/sound/pxa2xx-lib.h
+++ b/include/sound/pxa2xx-lib.h
@@ -2,7 +2,8 @@
#define PXA2XX_LIB_H

#include <linux/platform_device.h>
-#include <sound/ac97_codec.h>
+#include <sound/ac97/codec.h>
+#include <sound/ac97/compat.h>

/* PCM */

@@ -21,12 +22,13 @@ extern void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm);

/* AC97 */

-extern unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg);
-extern void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val);
+extern int pxa2xx_ac97_read(struct ac97_codec_device *ac97, unsigned short reg);
+extern int pxa2xx_ac97_write(struct ac97_codec_device *ac97,
+ unsigned short reg, unsigned short val);

-extern bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97);
-extern bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97);
-extern void pxa2xx_ac97_finish_reset(struct snd_ac97 *ac97);
+extern bool pxa2xx_ac97_try_warm_reset(struct ac97_codec_device *ac97);
+extern bool pxa2xx_ac97_try_cold_reset(struct ac97_codec_device *ac97);
+extern void pxa2xx_ac97_finish_reset(struct ac97_codec_device *ac97);

extern int pxa2xx_ac97_hw_suspend(void);
extern int pxa2xx_ac97_hw_resume(void);
diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index e0406211716b..94f7539a2c1f 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -11,7 +11,6 @@ menuconfig SND_ARM

config SND_PXA2XX_LIB
tristate
- select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
select SND_DMAENGINE_PCM

config SND_PXA2XX_LIB_AC97
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 39c3969ac1c7..bc5c6d72510a 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -20,7 +20,7 @@
#include <linux/io.h>
#include <linux/gpio.h>

-#include <sound/ac97_codec.h>
+#include <sound/ac97/controller.h>
#include <sound/pxa2xx-lib.h>

#include <mach/irqs.h>
@@ -46,11 +46,14 @@ extern void pxa27x_configure_ac97reset(int reset_gpio, bool to_gpio);
* 1 jiffy timeout if interrupt never comes).
*/

-unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
+int pxa2xx_ac97_read(struct ac97_codec_device *ac97, unsigned short reg)
{
- unsigned short val = -1;
+ int val = -ENODEV;
volatile u32 *reg_addr;

+ if (ac97->num > 0)
+ return -ENODEV;
+
mutex_lock(&car_mutex);

/* set up primary or secondary codec space */
@@ -63,21 +66,21 @@ unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
/* start read access across the ac97 link */
GSR = GSR_CDONE | GSR_SDONE;
gsr_bits = 0;
- val = *reg_addr;
+ val = (*reg_addr & 0xffff);
if (reg == AC97_GPIO_STATUS)
goto out;
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
!((GSR | gsr_bits) & GSR_SDONE)) {
printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
__func__, reg, GSR | gsr_bits);
- val = -1;
+ val = -ETIMEDOUT;
goto out;
}

/* valid data now */
GSR = GSR_CDONE | GSR_SDONE;
gsr_bits = 0;
- val = *reg_addr;
+ val = (*reg_addr & 0xffff);
/* but we've just started another cycle... */
wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);

@@ -86,10 +89,11 @@ out: mutex_unlock(&car_mutex);
}
EXPORT_SYMBOL_GPL(pxa2xx_ac97_read);

-void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
- unsigned short val)
+int pxa2xx_ac97_write(struct ac97_codec_device *ac97, unsigned short reg,
+ unsigned short val)
{
volatile u32 *reg_addr;
+ int ret = 0;

mutex_lock(&car_mutex);

@@ -104,11 +108,14 @@ void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
gsr_bits = 0;
*reg_addr = val;
if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
- !((GSR | gsr_bits) & GSR_CDONE))
+ !((GSR | gsr_bits) & GSR_CDONE)) {
printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
__func__, reg, GSR | gsr_bits);
+ ret = -EIO;
+ }

mutex_unlock(&car_mutex);
+ return ret;
}
EXPORT_SYMBOL_GPL(pxa2xx_ac97_write);

@@ -188,7 +195,7 @@ static inline void pxa_ac97_cold_pxa3xx(void)
}
#endif

-bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
+bool pxa2xx_ac97_try_warm_reset(struct ac97_codec_device *ac97)
{
unsigned long gsr;
unsigned int timeout = 100;
@@ -225,7 +232,7 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
}
EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);

-bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
+bool pxa2xx_ac97_try_cold_reset(struct ac97_codec_device *ac97)
{
unsigned long gsr;
unsigned int timeout = 1000;
@@ -263,7 +270,7 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_cold_reset);


-void pxa2xx_ac97_finish_reset(struct snd_ac97 *ac97)
+void pxa2xx_ac97_finish_reset(struct ac97_codec_device *ac97)
{
GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index f2bf8661dd21..784e6dedf5bf 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -23,9 +23,9 @@ config SND_PXA2XX_AC97

config SND_PXA2XX_SOC_AC97
tristate
- select AC97_BUS
+ select AC97_BUS_NEW
select SND_PXA2XX_LIB_AC97
- select SND_SOC_AC97_BUS
+ select SND_SOC_AC97_BUS_NEW

config SND_PXA2XX_SOC_I2S
tristate
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index f3de615aacd7..eb3ba630994b 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -10,6 +10,7 @@
* published by the Free Software Foundation.
*/

+#include <sound/ac97/controller.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -29,21 +30,21 @@

#include "pxa2xx-ac97.h"

-static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
+static void pxa2xx_ac97_warm_reset(struct ac97_codec_device *ac97)
{
pxa2xx_ac97_try_warm_reset(ac97);

pxa2xx_ac97_finish_reset(ac97);
}

-static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
+static void pxa2xx_ac97_cold_reset(struct ac97_codec_device *ac97)
{
pxa2xx_ac97_try_cold_reset(ac97);

pxa2xx_ac97_finish_reset(ac97);
}

-static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
+static struct ac97_controller_ops pxa2xx_ac97_ops = {
.read = pxa2xx_ac97_read,
.write = pxa2xx_ac97_write,
.warm_reset = pxa2xx_ac97_warm_reset,
@@ -236,7 +237,8 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
return ret;
}

- ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops);
+ //RJK: no more ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops);
+ ret = ac97_digital_controller_register(&pxa2xx_ac97_ops, &pdev->dev);
if (ret != 0)
return ret;

@@ -251,7 +253,7 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
static int pxa2xx_ac97_dev_remove(struct platform_device *pdev)
{
snd_soc_unregister_component(&pdev->dev);
- snd_soc_set_ac97_ops(NULL);
+ ac97_digital_controller_unregister(&pdev->dev);
pxa2xx_ac97_hw_remove(pdev);
return 0;
}
--
2.1.4