Commit 22f74587 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: fireface: code refactoring for dump of sync status

This commit adds refactoring for dump of sync status by adding
tables for check bits.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b1d0cb0a
...@@ -190,126 +190,100 @@ static void dump_clock_config(struct snd_ff *ff, struct snd_info_buffer *buffer) ...@@ -190,126 +190,100 @@ static void dump_clock_config(struct snd_ff *ff, struct snd_info_buffer *buffer)
static void dump_sync_status(struct snd_ff *ff, struct snd_info_buffer *buffer) static void dump_sync_status(struct snd_ff *ff, struct snd_info_buffer *buffer)
{ {
__le32 reg; static const struct {
u32 data; char *const label;
u32 locked_mask;
u32 synced_mask;
} *clk_entry, clk_entries[] = {
{ "WDClk", 0x40000000, 0x20000000, },
{ "S/PDIF", 0x00080000, 0x00040000, },
{ "ADAT1", 0x00000400, 0x00001000, },
{ "ADAT2", 0x00000800, 0x00002000, },
};
static const struct {
char *const label;
u32 mask;
} *referred_entry, referred_entries[] = {
{ "ADAT1", 0x00000000, },
{ "ADAT2", 0x00400000, },
{ "S/PDIF", 0x00c00000, },
{ "WDclk", 0x01000000, },
{ "TCO", 0x01400000, },
};
static const struct {
unsigned int rate;
u32 mask;
} *rate_entry, rate_entries[] = {
{ 32000, 0x02000000, },
{ 44100, 0x04000000, },
{ 48000, 0x06000000, },
{ 64000, 0x08000000, },
{ 88200, 0x0a000000, },
{ 96000, 0x0c000000, },
{ 128000, 0x0e000000, },
{ 176400, 0x10000000, },
{ 192000, 0x12000000, },
};
__le32 reg[2];
u32 data[2];
int i;
int err; int err;
err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST, err = snd_fw_transaction(ff->unit, TCODE_READ_BLOCK_REQUEST,
FORMER_REG_SYNC_STATUS, &reg, sizeof(reg), 0); FORMER_REG_SYNC_STATUS, reg, sizeof(reg), 0);
if (err < 0) if (err < 0)
return; return;
data[0] = le32_to_cpu(reg[0]);
data = le32_to_cpu(reg); data[1] = le32_to_cpu(reg[1]);
snd_iprintf(buffer, "External source detection:\n"); snd_iprintf(buffer, "External source detection:\n");
snd_iprintf(buffer, "Word Clock:"); for (i = 0; i < ARRAY_SIZE(clk_entries); ++i) {
if ((data >> 24) & 0x20) { const char *state;
if ((data >> 24) & 0x40)
snd_iprintf(buffer, "sync\n");
else
snd_iprintf(buffer, "lock\n");
} else {
snd_iprintf(buffer, "none\n");
}
snd_iprintf(buffer, "S/PDIF:"); clk_entry = clk_entries + i;
if ((data >> 16) & 0x10) { if (data[0] & clk_entry->locked_mask) {
if ((data >> 16) & 0x04) if (data[0] & clk_entry->synced_mask)
snd_iprintf(buffer, "sync\n"); state = "sync";
else else
snd_iprintf(buffer, "lock\n"); state = "lock";
} else { } else {
snd_iprintf(buffer, "none\n"); state = "none";
} }
snd_iprintf(buffer, "ADAT1:"); snd_iprintf(buffer, "%s: %s\n", clk_entry->label, state);
if ((data >> 8) & 0x04) {
if ((data >> 8) & 0x10)
snd_iprintf(buffer, "sync\n");
else
snd_iprintf(buffer, "lock\n");
} else {
snd_iprintf(buffer, "none\n");
} }
snd_iprintf(buffer, "ADAT2:"); snd_iprintf(buffer, "Referred clock:\n");
if ((data >> 8) & 0x08) {
if ((data >> 8) & 0x20)
snd_iprintf(buffer, "sync\n");
else
snd_iprintf(buffer, "lock\n");
} else {
snd_iprintf(buffer, "none\n");
}
snd_iprintf(buffer, "\nUsed external source:\n"); if (data[1] & 0x00000001) {
snd_iprintf(buffer, "Internal\n");
if (((data >> 22) & 0x07) == 0x07) {
snd_iprintf(buffer, "None\n");
} else { } else {
switch ((data >> 22) & 0x07) { unsigned int rate;
case 0x00: const char *label;
snd_iprintf(buffer, "ADAT1:");
break; for (i = 0; i < ARRAY_SIZE(referred_entries); ++i) {
case 0x01: referred_entry = referred_entries + i;
snd_iprintf(buffer, "ADAT2:"); if ((data[0] & 0x1e0000) == referred_entry->mask) {
break; label = referred_entry->label;
case 0x03:
snd_iprintf(buffer, "S/PDIF:");
break;
case 0x04:
snd_iprintf(buffer, "Word:");
break;
case 0x07:
snd_iprintf(buffer, "Nothing:");
break;
case 0x02:
case 0x05:
case 0x06:
default:
snd_iprintf(buffer, "unknown:");
break; break;
} }
}
if (i == ARRAY_SIZE(referred_entries))
label = "none";
if ((data >> 25) & 0x07) { for (i = 0; i < ARRAY_SIZE(rate_entries); ++i) {
switch ((data >> 25) & 0x07) { rate_entry = rate_entries + i;
case 0x01: if ((data[0] & 0x1e000000) == rate_entry->mask) {
snd_iprintf(buffer, "32000\n"); rate = rate_entry->rate;
break;
case 0x02:
snd_iprintf(buffer, "44100\n");
break;
case 0x03:
snd_iprintf(buffer, "48000\n");
break; break;
case 0x04:
snd_iprintf(buffer, "64000\n");
break;
case 0x05:
snd_iprintf(buffer, "88200\n");
break;
case 0x06:
snd_iprintf(buffer, "96000\n");
break;
case 0x07:
snd_iprintf(buffer, "128000\n");
break;
case 0x08:
snd_iprintf(buffer, "176400\n");
break;
case 0x09:
snd_iprintf(buffer, "192000\n");
break;
case 0x00:
snd_iprintf(buffer, "unknown\n");
break;
}
} }
} }
if (i == ARRAY_SIZE(rate_entries))
rate = 0;
snd_iprintf(buffer, "Multiplied:"); snd_iprintf(buffer, "%s %d\n", label, rate);
snd_iprintf(buffer, "%d\n", (data & 0x3ff) * 250); }
} }
static void former_dump_status(struct snd_ff *ff, static void former_dump_status(struct snd_ff *ff,
......
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