ALSA: fireface: share helper function to get current sampling rate and clock source
As long as investigating packet dumps from Fireface 400/800, bits on status registers for clock synchronization are the same. This commit moves a parser for a register of clock configuration to obsolete model-specific operations. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:

committed by
Takashi Iwai

szülő
72f10f08b6
commit
3c3b892b37
@@ -8,6 +8,65 @@
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
int snd_ff_transaction_get_clock(struct snd_ff *ff, unsigned int *rate,
|
||||
enum snd_ff_clock_src *src)
|
||||
{
|
||||
__le32 reg;
|
||||
u32 data;
|
||||
int err;
|
||||
|
||||
err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST,
|
||||
SND_FF_REG_CLOCK_CONFIG, ®, sizeof(reg), 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
data = le32_to_cpu(reg);
|
||||
|
||||
/* Calculate sampling rate. */
|
||||
switch ((data >> 1) & 0x03) {
|
||||
case 0x01:
|
||||
*rate = 32000;
|
||||
break;
|
||||
case 0x00:
|
||||
*rate = 44100;
|
||||
break;
|
||||
case 0x03:
|
||||
*rate = 48000;
|
||||
break;
|
||||
case 0x02:
|
||||
default:
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (data & 0x08)
|
||||
*rate *= 2;
|
||||
else if (data & 0x10)
|
||||
*rate *= 4;
|
||||
|
||||
/* Calculate source of clock. */
|
||||
if (data & 0x01) {
|
||||
*src = SND_FF_CLOCK_SRC_INTERNAL;
|
||||
} else {
|
||||
/* TODO: 0x00, 0x01, 0x02, 0x06, 0x07? */
|
||||
switch ((data >> 10) & 0x07) {
|
||||
case 0x03:
|
||||
*src = SND_FF_CLOCK_SRC_SPDIF;
|
||||
break;
|
||||
case 0x04:
|
||||
*src = SND_FF_CLOCK_SRC_WORD;
|
||||
break;
|
||||
case 0x05:
|
||||
*src = SND_FF_CLOCK_SRC_LTC;
|
||||
break;
|
||||
case 0x00:
|
||||
default:
|
||||
*src = SND_FF_CLOCK_SRC_ADAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void finish_transmit_midi_msg(struct snd_ff *ff, unsigned int port,
|
||||
int rcode)
|
||||
{
|
||||
|
Reference in New Issue
Block a user