Skip to content

Commit 6fb861b

Browse files
ossilatortiwai
authored andcommitted
ALSA: emu10k1: fix snd_emu1010_fpga_read() input masking for rev2 cards
Unlike the Alice2 chips used on 1st generation E-MU cards, the Tina/Tina2 chips used on the 2nd gen cards have only six GPIN pins, which means that we need to use a smaller mask. Failure to do so would falsify the read data if the FPGA tried to raise an IRQ right at that moment. This wasn't a problem so far, as we didn't actually enable FPGA IRQs, but that's going to change soon. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230422132430.1057490-1-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 8b2dd46 commit 6fb861b

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

include/sound/emu10k1.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@
252252
#define MUSTAT_ORDYN 0x40 /* 0 = MUDATA can accept a command or data */
253253

254254
#define A_GPIO 0x18 /* GPIO on Audigy card (16bits) */
255-
#define A_GPINPUT_MASK 0xff00
255+
#define A_GPINPUT_MASK 0xff00 /* Alice/2 has 8 input pins */
256+
#define A3_GPINPUT_MASK 0x3f00 /* ... while Tina/2 has only 6 */
256257
#define A_GPOUTPUT_MASK 0x00ff
257258

258259
// The GPIO port is used for I/O config on Sound Blasters;

sound/pci/emu10k1/io.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value)
255255

256256
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value)
257257
{
258+
// The higest input pin is used as the designated interrupt trigger,
259+
// so it needs to be masked out.
260+
u32 mask = emu->card_capabilities->ca0108_chip ? 0x1f : 0x7f;
258261
unsigned long flags;
259262
if (snd_BUG_ON(reg > 0x3f))
260263
return;
@@ -264,7 +267,7 @@ void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value)
264267
udelay(10);
265268
outw(reg | 0x80, emu->port + A_GPIO); /* High bit clocks the value into the fpga. */
266269
udelay(10);
267-
*value = ((inw(emu->port + A_GPIO) >> 8) & 0x7f);
270+
*value = ((inw(emu->port + A_GPIO) >> 8) & mask);
268271
spin_unlock_irqrestore(&emu->emu_lock, flags);
269272
}
270273

0 commit comments

Comments
 (0)