diff options
Diffstat (limited to 'sound/soc/sh/hac.c')
| -rw-r--r-- | sound/soc/sh/hac.c | 79 |
1 files changed, 52 insertions, 27 deletions
diff --git a/sound/soc/sh/hac.c b/sound/soc/sh/hac.c index 8e3f03908cd..0af2e4dfd13 100644 --- a/sound/soc/sh/hac.c +++ b/sound/soc/sh/hac.c @@ -21,7 +21,6 @@ #include <linux/interrupt.h> #include <linux/wait.h> #include <linux/delay.h> -#include <sound/driver.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/ac97_codec.h> @@ -105,7 +104,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r, unsigned int to1, to2, i; unsigned short adr; - for (i = 0; i < AC97_READ_RETRY; ++i) { + for (i = AC97_READ_RETRY; i; i--) { *v = 0; /* wait for HAC to receive something from the codec */ for (to1 = TMO_E4; @@ -132,7 +131,7 @@ static int hac_get_codec_data(struct hac_priv *hac, unsigned short r, udelay(21); } HACREG(HACRSR) &= ~(RSR_STDRY | RSR_STARY); - return (i < AC97_READ_RETRY); + return i; } static unsigned short hac_read_codec_aux(struct hac_priv *hac, @@ -141,7 +140,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac, unsigned short val; unsigned int i, to; - for (i = 0; i < AC97_READ_RETRY; i++) { + for (i = AC97_READ_RETRY; i; i--) { /* send_read_request */ local_irq_disable(); HACREG(HACTSR) &= ~(TSR_CMDAMT); @@ -159,10 +158,7 @@ static unsigned short hac_read_codec_aux(struct hac_priv *hac, break; } - if (i == AC97_READ_RETRY) - return ~0; - - return val; + return i ? val : ~0; } static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg, @@ -172,7 +168,7 @@ static void hac_ac97_write(struct snd_ac97 *ac97, unsigned short reg, struct hac_priv *hac = &hac_cpu_data[unit_id]; unsigned int i, to; /* write_codec_aux */ - for (i = 0; i < AC97_WRITE_RETRY; i++) { + for (i = AC97_WRITE_RETRY; i; i--) { /* send_write_request */ local_irq_disable(); HACREG(HACTSR) &= ~(TSR_CMDDMT | TSR_CMDAMT); @@ -231,19 +227,18 @@ static void hac_ac97_coldrst(struct snd_ac97 *ac97) hac_ac97_warmrst(ac97); } -struct snd_ac97_bus_ops soc_ac97_ops = { +static struct snd_ac97_bus_ops hac_ac97_ops = { .read = hac_ac97_read, .write = hac_ac97_write, .reset = hac_ac97_coldrst, .warm_reset = hac_ac97_warmrst, }; -EXPORT_SYMBOL_GPL(soc_ac97_ops); static int hac_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hac_priv *hac = &hac_cpu_data[rtd->dai->cpu_dai->id]; + struct hac_priv *hac = &hac_cpu_data[dai->id]; int d = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1; switch (params->msbits) { @@ -270,11 +265,14 @@ static int hac_hw_params(struct snd_pcm_substream *substream, #define AC97_FMTS \ SNDRV_PCM_FMTBIT_S16_LE -struct snd_soc_cpu_dai sh4_hac_dai[] = { +static const struct snd_soc_dai_ops hac_dai_ops = { + .hw_params = hac_hw_params, +}; + +static struct snd_soc_dai_driver sh4_hac_dai[] = { { - .name = "HAC0", - .id = 0, - .type = SND_SOC_DAI_AC97, + .name = "hac-dai.0", + .ac97_control = 1, .playback = { .rates = AC97_RATES, .formats = AC97_FMTS, @@ -287,15 +285,12 @@ struct snd_soc_cpu_dai sh4_hac_dai[] = { .channels_min = 2, .channels_max = 2, }, - .ops = { - .hw_params = hac_hw_params, - }, + .ops = &hac_dai_ops, }, #ifdef CONFIG_CPU_SUBTYPE_SH7760 { - .name = "HAC1", + .name = "hac-dai.1", .id = 1, - .type = SND_SOC_DAI_AC97, .playback = { .rates = AC97_RATES, .formats = AC97_FMTS, @@ -308,14 +303,44 @@ struct snd_soc_cpu_dai sh4_hac_dai[] = { .channels_min = 2, .channels_max = 2, }, - .ops = { - .hw_params = hac_hw_params, - }, + .ops = &hac_dai_ops, }, #endif }; -EXPORT_SYMBOL_GPL(sh4_hac_dai); + +static const struct snd_soc_component_driver sh4_hac_component = { + .name = "sh4-hac", +}; + +static int hac_soc_platform_probe(struct platform_device *pdev) +{ + ret = snd_soc_set_ac97_ops(&hac_ac97_ops); + if (ret != 0) + return ret; + + return snd_soc_register_component(&pdev->dev, &sh4_hac_component, + sh4_hac_dai, ARRAY_SIZE(sh4_hac_dai)); +} + +static int hac_soc_platform_remove(struct platform_device *pdev) +{ + snd_soc_unregister_component(&pdev->dev); + snd_soc_set_ac97_ops(NULL); + return 0; +} + +static struct platform_driver hac_pcm_driver = { + .driver = { + .name = "hac-pcm-audio", + .owner = THIS_MODULE, + }, + + .probe = hac_soc_platform_probe, + .remove = hac_soc_platform_remove, +}; + +module_platform_driver(hac_pcm_driver); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("SuperH onchip HAC (AC97) audio driver"); |
