Commit a68660e0 authored by Liam Girdwood's avatar Liam Girdwood Committed by Jaroslav Kysela

[ALSA] ASoC AC97 device reg bugfix

This patch fixes a bug whereby AC97 bus device data was being clobbered
when AC97 codecs using the generic ac97_codec.c driver were being
registered. Codecs that didn't use the generic driver were unaffected
(e.g. WM9712, WM9713).
Changes:-
 o Add new AC97 codec class for custom (or need bus dev registration)
AC97 codecs.
 o Only register/deregister this custom codec device with the AC97 bus.
The generic AC97 driver already does this for generic codec devices.
This may be related to bug #3038 :-
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3038Signed-off-by: default avatarLiam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 9ae67c7b
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <sound/control.h> #include <sound/control.h>
#include <sound/ac97_codec.h> #include <sound/ac97_codec.h>
#define SND_SOC_VERSION "0.13.0" #define SND_SOC_VERSION "0.13.1"
/* /*
* Convenience kcontrol builders * Convenience kcontrol builders
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#define SND_SOC_DAI_AC97 0x1 #define SND_SOC_DAI_AC97 0x1
#define SND_SOC_DAI_I2S 0x2 #define SND_SOC_DAI_I2S 0x2
#define SND_SOC_DAI_PCM 0x4 #define SND_SOC_DAI_PCM 0x4
#define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
/* /*
* DAI hardware audio formats * DAI hardware audio formats
...@@ -278,6 +279,7 @@ struct snd_soc_cpu_ops { ...@@ -278,6 +279,7 @@ struct snd_soc_cpu_ops {
struct snd_soc_codec_dai { struct snd_soc_codec_dai {
char *name; char *name;
int id; int id;
unsigned char type;
/* DAI capabilities */ /* DAI capabilities */
struct snd_soc_pcm_stream playback; struct snd_soc_pcm_stream playback;
......
...@@ -45,6 +45,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream) ...@@ -45,6 +45,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream)
struct snd_soc_codec_dai ac97_dai = { struct snd_soc_codec_dai ac97_dai = {
.name = "AC97 HiFi", .name = "AC97 HiFi",
.type = SND_SOC_DAI_AC97,
.playback = { .playback = {
.stream_name = "AC97 Playback", .stream_name = "AC97 Playback",
.channels_min = 1, .channels_min = 1,
......
...@@ -544,6 +544,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream) ...@@ -544,6 +544,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream)
struct snd_soc_codec_dai wm9712_dai[] = { struct snd_soc_codec_dai wm9712_dai[] = {
{ {
.name = "AC97 HiFi", .name = "AC97 HiFi",
.type = SND_SOC_DAI_AC97_BUS,
.playback = { .playback = {
.stream_name = "HiFi Playback", .stream_name = "HiFi Playback",
.channels_min = 1, .channels_min = 1,
......
...@@ -116,6 +116,7 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec) ...@@ -116,6 +116,7 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
static inline const char* get_dai_name(int type) static inline const char* get_dai_name(int type)
{ {
switch(type) { switch(type) {
case SND_SOC_DAI_AC97_BUS:
case SND_SOC_DAI_AC97: case SND_SOC_DAI_AC97:
return "AC97"; return "AC97";
case SND_SOC_DAI_I2S: case SND_SOC_DAI_I2S:
...@@ -1099,7 +1100,8 @@ int snd_soc_register_card(struct snd_soc_device *socdev) ...@@ -1099,7 +1100,8 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
continue; continue;
} }
} }
if (socdev->machine->dai_link[i].cpu_dai->type == SND_SOC_DAI_AC97) if (socdev->machine->dai_link[i].codec_dai->type ==
SND_SOC_DAI_AC97_BUS)
ac97 = 1; ac97 = 1;
} }
snprintf(codec->card->shortname, sizeof(codec->card->shortname), snprintf(codec->card->shortname, sizeof(codec->card->shortname),
...@@ -1148,11 +1150,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card); ...@@ -1148,11 +1150,21 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
void snd_soc_free_pcms(struct snd_soc_device *socdev) void snd_soc_free_pcms(struct snd_soc_device *socdev)
{ {
struct snd_soc_codec *codec = socdev->codec; struct snd_soc_codec *codec = socdev->codec;
#ifdef CONFIG_SND_SOC_AC97_BUS
struct snd_soc_codec_dai *codec_dai;
int i;
#endif
mutex_lock(&codec->mutex); mutex_lock(&codec->mutex);
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
if (codec->ac97) for(i = 0; i < codec->num_dai; i++) {
codec_dai = &codec->dai[i];
if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) {
soc_ac97_dev_unregister(codec); soc_ac97_dev_unregister(codec);
goto free_card;
}
}
free_card:
#endif #endif
if (codec->card) if (codec->card)
......
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