int snd_ak4114_external_rate(struct ak4114 *ak4114) { unsigned char rcs1; rcs1 = reg_read(ak4114, AK4114_REG_RCS1); return external_rate(rcs1); }
int snd_ak4117_external_rate(ak4117_t *ak4117) { unsigned char rcs1; rcs1 = reg_read(ak4117, AK4117_REG_RCS1); return external_rate(rcs1); }
static int snd_ak4114_rate_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct ak4114 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = external_rate(reg_read(chip, AK4114_REG_RCS1)); return 0; }
static int snd_ak4117_rate_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { ak4117_t *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = external_rate(reg_read(chip, AK4117_REG_RCS1)); return 0; }
int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags) { struct snd_pcm_runtime *runtime = ak4114->capture_substream ? ak4114->capture_substream->runtime : NULL; unsigned long _flags; int res = 0; unsigned char rcs0, rcs1; unsigned char c0, c1; rcs1 = reg_read(ak4114, AK4114_REG_RCS1); if (flags & AK4114_CHECK_NO_STAT) goto __rate; rcs0 = reg_read(ak4114, AK4114_REG_RCS0); spin_lock_irqsave(&ak4114->lock, _flags); if (rcs0 & AK4114_PAR) ak4114->parity_errors++; if (rcs1 & AK4114_V) ak4114->v_bit_errors++; if (rcs1 & AK4114_CCRC) ak4114->ccrc_errors++; if (rcs1 & AK4114_QCRC) ak4114->qcrc_errors++; c0 = (ak4114->rcs0 & (AK4114_QINT | AK4114_CINT | AK4114_PEM | AK4114_AUDION | AK4114_AUTO | AK4114_UNLCK)) ^ (rcs0 & (AK4114_QINT | AK4114_CINT | AK4114_PEM | AK4114_AUDION | AK4114_AUTO | AK4114_UNLCK)); c1 = (ak4114->rcs1 & 0xf0) ^ (rcs1 & 0xf0); ak4114->rcs0 = rcs0 & ~(AK4114_QINT | AK4114_CINT); ak4114->rcs1 = rcs1; spin_unlock_irqrestore(&ak4114->lock, _flags); ak4114_notify(ak4114, rcs0, rcs1, c0, c1); if (ak4114->change_callback && (c0 | c1) != 0) ak4114->change_callback(ak4114, c0, c1); __rate: /* compare rate */ res = external_rate(rcs1); if (!(flags & AK4114_CHECK_NO_RATE) && runtime && runtime->rate != res) { snd_pcm_stream_lock_irqsave(ak4114->capture_substream, _flags); if (snd_pcm_running(ak4114->capture_substream)) { // printk(KERN_DEBUG "rate changed (%i <- %i)\n", runtime->rate, res); snd_pcm_stop(ak4114->capture_substream, SNDRV_PCM_STATE_DRAINING); res = 1; } snd_pcm_stream_unlock_irqrestore(ak4114->capture_substream, _flags); } return res; }
int snd_ak4117_check_rate_and_errors(struct ak4117 *ak4117, unsigned int flags) { struct snd_pcm_runtime *runtime = ak4117->substream ? ak4117->substream->runtime : NULL; unsigned long _flags; int res = 0; unsigned char rcs0, rcs1, rcs2; unsigned char c0, c1; rcs1 = reg_read(ak4117, AK4117_REG_RCS1); if (flags & AK4117_CHECK_NO_STAT) goto __rate; rcs0 = reg_read(ak4117, AK4117_REG_RCS0); rcs2 = reg_read(ak4117, AK4117_REG_RCS2); // printk(KERN_DEBUG "AK IRQ: rcs0 = 0x%x, rcs1 = 0x%x, rcs2 = 0x%x\n", rcs0, rcs1, rcs2); spin_lock_irqsave(&ak4117->lock, _flags); if (rcs0 & AK4117_PAR) ak4117->parity_errors++; if (rcs0 & AK4117_V) ak4117->v_bit_errors++; if (rcs2 & AK4117_CCRC) ak4117->ccrc_errors++; if (rcs2 & AK4117_QCRC) ak4117->qcrc_errors++; c0 = (ak4117->rcs0 & (AK4117_QINT | AK4117_CINT | AK4117_STC | AK4117_AUDION | AK4117_AUTO | AK4117_UNLCK)) ^ (rcs0 & (AK4117_QINT | AK4117_CINT | AK4117_STC | AK4117_AUDION | AK4117_AUTO | AK4117_UNLCK)); c1 = (ak4117->rcs1 & (AK4117_DTSCD | AK4117_NPCM | AK4117_PEM | 0x0f)) ^ (rcs1 & (AK4117_DTSCD | AK4117_NPCM | AK4117_PEM | 0x0f)); ak4117->rcs0 = rcs0 & ~(AK4117_QINT | AK4117_CINT | AK4117_STC); ak4117->rcs1 = rcs1; ak4117->rcs2 = rcs2; spin_unlock_irqrestore(&ak4117->lock, _flags); if (rcs0 & AK4117_PAR) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[0]->id); if (rcs0 & AK4117_V) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[1]->id); if (rcs2 & AK4117_CCRC) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[2]->id); if (rcs2 & AK4117_QCRC) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[3]->id); /* rate change */ if (c1 & 0x0f) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[4]->id); if ((c1 & AK4117_PEM) | (c0 & AK4117_CINT)) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[6]->id); if (c0 & AK4117_QINT) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[8]->id); if (c0 & AK4117_AUDION) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[9]->id); if (c1 & AK4117_NPCM) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[10]->id); if (c1 & AK4117_DTSCD) snd_ctl_notify(ak4117->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4117->kctls[11]->id); if (ak4117->change_callback && (c0 | c1) != 0) ak4117->change_callback(ak4117, c0, c1); __rate: /* compare rate */ res = external_rate(rcs1); if (!(flags & AK4117_CHECK_NO_RATE) && runtime && runtime->rate != res) { snd_pcm_stream_lock_irqsave(ak4117->substream, _flags); if (snd_pcm_running(ak4117->substream)) { // printk(KERN_DEBUG "rate changed (%i <- %i)\n", runtime->rate, res); snd_pcm_stop(ak4117->substream, SNDRV_PCM_STATE_DRAINING); wake_up(&runtime->sleep); res = 1; } snd_pcm_stream_unlock_irqrestore(ak4117->substream, _flags); } return res; }
int snd_ak4114_check_rate_and_errors(ak4114_t *ak4114, unsigned int flags) { snd_pcm_runtime_t *runtime = ak4114->capture_substream ? ak4114->capture_substream->runtime : NULL; unsigned long _flags; int res = 0; unsigned char rcs0, rcs1; unsigned char c0, c1; rcs1 = reg_read(ak4114, AK4114_REG_RCS1); if (flags & AK4114_CHECK_NO_STAT) goto __rate; rcs0 = reg_read(ak4114, AK4114_REG_RCS0); spin_lock_irqsave(&ak4114->lock, _flags); if (rcs0 & AK4114_PAR) ak4114->parity_errors++; if (rcs1 & AK4114_V) ak4114->v_bit_errors++; if (rcs1 & AK4114_CCRC) ak4114->ccrc_errors++; if (rcs1 & AK4114_QCRC) ak4114->qcrc_errors++; c0 = (ak4114->rcs0 & (AK4114_QINT | AK4114_CINT | AK4114_PEM | AK4114_AUDION | AK4114_AUTO | AK4114_UNLCK)) ^ (rcs0 & (AK4114_QINT | AK4114_CINT | AK4114_PEM | AK4114_AUDION | AK4114_AUTO | AK4114_UNLCK)); c1 = (ak4114->rcs1 & 0xf0) ^ (rcs1 & 0xf0); ak4114->rcs0 = rcs0 & ~(AK4114_QINT | AK4114_CINT); ak4114->rcs1 = rcs1; spin_unlock_irqrestore(&ak4114->lock, _flags); if (rcs0 & AK4114_PAR) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[0]->id); if (rcs0 & AK4114_V) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[1]->id); if (rcs1 & AK4114_CCRC) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[2]->id); if (rcs1 & AK4114_QCRC) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[3]->id); /* rate change */ if (c1 & 0xf0) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[4]->id); if ((c0 & AK4114_PEM) | (c0 & AK4114_CINT)) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[9]->id); if (c0 & AK4114_QINT) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[10]->id); if (c0 & AK4114_AUDION) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[11]->id); if (c0 & AK4114_AUTO) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[12]->id); if (c0 & AK4114_DTSCD) snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[13]->id); if (ak4114->change_callback && (c0 | c1) != 0) ak4114->change_callback(ak4114, c0, c1); __rate: /* compare rate */ res = external_rate(rcs1); if (!(flags & AK4114_CHECK_NO_RATE) && runtime && runtime->rate != res) { snd_pcm_stream_lock_irqsave(ak4114->capture_substream, _flags); if (snd_pcm_running(ak4114->capture_substream)) { // printk("rate changed (%i <- %i)\n", runtime->rate, res); snd_pcm_stop(ak4114->capture_substream, SNDRV_PCM_STATE_DRAINING); res = 1; } snd_pcm_stream_unlock_irqrestore(ak4114->capture_substream, _flags); } return res; }