ASoC: au1x: psc-ac97: verify correct codec register was read
PATCH 1/2 ASoC: au1x: psc-ac97: verify correct codec register was read
Verify that the correct register has been received from the codec.
Signed-off-by Manuel Lauss <[email protected]>
--- sound/soc/au1x/psc-ac97.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
sound/soc/au1x/psc-ac97.c +8 -3
@@ -61,7 +61,8 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, {/* FIXME */ struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; -unsigned short data, retry, tmo; +unsigned short retry, tmo; +unsigned long data;au_writel (PSC_AC97EVNT_CD ,AC97_EVNT (pscdata));au_sync ();
@@ -79,15 +80,19 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, && --tmo)udelay (2 ); - data =au_readl (AC97_CDC (pscdata)) &0xffff ; + data =au_readl (AC97_CDC (pscdata));au_writel (PSC_AC97EVNT_CD ,AC97_EVNT (pscdata));au_sync ();mutex_unlock (&pscdata->lock); + +if (reg != ((data >>16 ) &0x7f )) + tmo =1 ;/* wrong register, try again */ + }while (--retry && !tmo); -return retry ? data :0xffff ; +return retry ? data &0xffff :0xffff ; }/* AC97 controller writes to codec register */
Signature · 1 line
1.6.5
PATCH 2/2 ASoC: au1x: psc-ac97: reorganize timeouts
Codec read/write functions: wait 21us between the pokings of hardware. Add timeouts to unbounded loops waiting for bits to change.
Signed-off-by Manuel Lauss <[email protected]>
--- sound/soc/au1x/psc-ac97.c | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-)
sound/soc/au1x/psc-ac97.c +25 -13
@@ -75,10 +75,12 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, AC97_CDC(pscdata));au_sync (); - tmo =2000 ; -while ((!(au_readl (AC97_EVNT (pscdata)) &PSC_AC97EVNT_CD )) - && --tmo) -udelay (2 ); + tmo =20 ; +do { +udelay (21 ); +if (au_readl (AC97_EVNT (pscdata)) &PSC_AC97EVNT_CD ) +break ; + }while (--tmo); data =au_readl (AC97_CDC (pscdata));
@@ -114,10 +116,12 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, AC97_CDC(pscdata));au_sync (); - tmo =2000 ; -while ((!(au_readl (AC97_EVNT (pscdata)) &PSC_AC97EVNT_CD )) - && --tmo) -udelay (2 ); + tmo =20 ; +do { +udelay (21 ); +if (au_readl (AC97_EVNT (pscdata)) &PSC_AC97EVNT_CD ) +break ; + }while (--tmo);au_writel (PSC_AC97EVNT_CD ,AC97_EVNT (pscdata));au_sync ();
@@ -200,7 +204,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,/* FIXME */ struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;unsigned long r, ro, stat; -int chans, stype =SUBSTREAM_TYPE (substream); +int chans, t, stype =SUBSTREAM_TYPE (substream); chans =params_channels (params);
@@ -242,8 +246,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,au_sync ();/* ...wait for it... */ -while (au_readl (AC97_STAT (pscdata)) &PSC_AC97STAT_DR ) - asmvolatile ("nop" ); + t =100 ; +while ((au_readl (AC97_STAT (pscdata)) &PSC_AC97STAT_DR ) && --t) +msleep (1 ); + +if (!t) +printk (KERN_ERR "PSC-AC97: can't disable!\n" );/* ...write config... */ au_writel (r,AC97_CFG (pscdata));
@@ -254,8 +262,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,au_sync ();/* ...and wait for ready bit */ -while (!(au_readl (AC97_STAT (pscdata)) &PSC_AC97STAT_DR )) - asmvolatile ("nop" ); + t =100 ; +while ((!(au_readl (AC97_STAT (pscdata)) &PSC_AC97STAT_DR )) && --t) +msleep (1 ); + +if (!t) +printk (KERN_ERR "PSC-AC97: can't enable!\n" );mutex_unlock (&pscdata->lock);
Signature · 1 line
1.6.5
Mark Brown
AppliedRe: [PATCH 2/2] ASoC: au1x: psc-ac97: reorganize timeouts
Quoted 4 lines · Manuel Lauss
Codec read/write functions: wait 21us between the pokings of hardware. Add timeouts to unbounded loops waiting for bits to change.
Signed-off-by Manuel Lauss <[email protected]>
Applied both, thanks.