Commit 6ab13291 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Takashi Iwai

ALSA: emu10k1: make E-MU FPGA register dump in /proc more useful

Include the routing information, which can be actually read back.

Somewhat as a drive-by, make the register dump format less obscure - the
previous one made no sense at all.
Signed-off-by: default avatarOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230526101659.437969-6-oswald.buddenhagen@gmx.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ad326d4a
......@@ -1812,6 +1812,7 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value);
void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src);
u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst);
unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
......
......@@ -496,6 +496,15 @@ static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
}
#ifdef CONFIG_SND_DEBUG
static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu,
struct snd_info_buffer *buffer,
u32 dst)
{
u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst);
snd_iprintf(buffer, "%04x: %04x\n", dst, src);
}
static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
......@@ -506,7 +515,39 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
for(i = 0; i < 0x40; i+=1) {
snd_emu1010_fpga_read(emu, i, &value);
snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
snd_iprintf(buffer, "%02x: %02x\n", i, value);
}
snd_iprintf(buffer, "\nEMU1010 Routes:\n\n");
for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32
snd_emu_proc_emu1010_link_read(emu, buffer, i);
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404)
for (i = 0; i < 32; i++) // To Dock via EDI
snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i);
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616)
for (i = 0; i < 8; i++) // To Hamoa/local
snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i);
for (i = 0; i < 8; i++) // To Hamoa/Mana/local
snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i);
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
for (i = 0; i < 16; i++) // To Tina2 via EMU32
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
} else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
for (i = 0; i < 8; i++) // To Hana ADAT
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) {
for (i = 0; i < 16; i++) // To Tina via EMU32
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i);
} else {
// To Alice2 via I2S
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500);
snd_emu_proc_emu1010_link_read(emu, buffer, 0x501);
snd_emu_proc_emu1010_link_read(emu, buffer, 0x600);
snd_emu_proc_emu1010_link_read(emu, buffer, 0x601);
snd_emu_proc_emu1010_link_read(emu, buffer, 0x700);
snd_emu_proc_emu1010_link_read(emu, buffer, 0x701);
}
}
}
......
......@@ -298,21 +298,27 @@ void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value)
spin_unlock_irqrestore(&emu->emu_lock, flags);
}
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value)
static void snd_emu1010_fpga_read_locked(struct snd_emu10k1 *emu, u32 reg, u32 *value)
{
// The higest input pin is used as the designated interrupt trigger,
// so it needs to be masked out.
u32 mask = emu->card_capabilities->ca0108_chip ? 0x1f : 0x7f;
unsigned long flags;
if (snd_BUG_ON(reg > 0x3f))
return;
reg += 0x40; /* 0x40 upwards are registers. */
spin_lock_irqsave(&emu->emu_lock, flags);
outw(reg, emu->port + A_GPIO);
udelay(10);
outw(reg | 0x80, emu->port + A_GPIO); /* High bit clocks the value into the fpga. */
udelay(10);
*value = ((inw(emu->port + A_GPIO) >> 8) & mask);
}
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value)
{
unsigned long flags;
spin_lock_irqsave(&emu->emu_lock, flags);
snd_emu1010_fpga_read_locked(emu, reg, value);
spin_unlock_irqrestore(&emu->emu_lock, flags);
}
......@@ -335,6 +341,22 @@ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 s
spin_unlock_irqrestore(&emu->emu_lock, flags);
}
u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst)
{
unsigned long flags;
u32 hi, lo;
if (snd_BUG_ON(dst & ~0x71f))
return 0;
spin_lock_irqsave(&emu->emu_lock, flags);
snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTHI, dst >> 8);
snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTLO, dst & 0x1f);
snd_emu1010_fpga_read_locked(emu, EMU_HANA_SRCHI, &hi);
snd_emu1010_fpga_read_locked(emu, EMU_HANA_SRCLO, &lo);
spin_unlock_irqrestore(&emu->emu_lock, flags);
return (hi << 8) | lo;
}
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
{
unsigned long flags;
......
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