ALSA: emu10k1: improvements mostly to the I/O routing mixers for E-MU cards
cover ALSA: emu10k1: improvements mostly to the I/O routing mixers for E-MU cards
Oswald Buddenhagen (10):
ALSA: emu10k1: make some initializer arrays less wasteful
ALSA: emu10k1: compactize E-MU routing source arrays
ALSA: emu10k1: make mixer control mass creation less wasteful
ALSA: emu10k1: un-hardcode E-MU mixer control callbacks somewhat
ALSA: emu10k1: fix return value of snd_emu1010_dac_pads_put()
ALSA: emu10k1: make E-MU I/O routing init data-driven
ALSA: emu10k1: make E-MU mixer control creation more data-driven
ALSA: emu10k1: improve mixer controls for E-MU 1010 rev2 card
ALSA: emu10k1: add explicit support for E-MU 0404
ALSA: emu10k1: make struct snd_emu1010 less wasteful
include/sound/emu10k1.h | 47 +- sound/pci/emu10k1/emu10k1_main.c | 268 +------ sound/pci/emu10k1/emumixer.c | 1242 +++++++++++++++++------------- sound/pci/emu10k1/emuproc.c | 18 +- 4 files changed, 759 insertions(+), 816 deletions(-)
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 1/10 ALSA: emu10k1: make some initializer arrays less wasteful
- Use bit fields in struct snd_emu_chip_details
- Use shorts in the E-MU routing register arrays
--- include/sound/emu10k1.h | 36 ++++++++++++++++++------------------ sound/pci/emu10k1/emumixer.c | 10 +++++----- 2 files changed, 23 insertions(+), 23 deletions(-)
include/sound/emu10k1.h +18 -18
@@ -1601,24 +1601,24 @@ struct snd_emu_chip_details {u32 device;u32 subsystem;unsigned char revision; -unsigned char emu10k1_chip;/* Original SB Live. Not SB Live 24bit. */ -/* Redundant with emu10k2_chip being unset. */ -unsigned char emu10k2_chip;/* Audigy 1 or Audigy 2. */ -unsigned char ca0102_chip;/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ -/* Redundant with ca0108_chip being unset. */ -unsigned char ca0108_chip;/* Audigy 2 Value */ -unsigned char ca_cardbus_chip;/* Audigy 2 ZS Notebook */ -unsigned char ca0151_chip;/* P16V */ -unsigned char spk71;/* Has 7.1 speakers */ -unsigned char sblive51;/* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ -unsigned char spdif_bug;/* Has Spdif phasing bug */ -unsigned char ac97_chip;/* Has an AC97 chip: 1 = mandatory, 2 = optional */ -unsigned char ecard;/* APS EEPROM */ -unsigned char emu_model;/* EMU model type */ -unsigned char spi_dac;/* SPI interface for DAC; requires ca0108_chip */ -unsigned char i2c_adc;/* I2C interface for ADC; requires ca0108_chip */ -unsigned char adc_1361t;/* Use Philips 1361T ADC */ -unsigned char invert_shared_spdif;/* analog/digital switch inverted */ +unsigned char emu_model;/* EMU model type */ + unsigned int emu10k1_chip:1; /* Original SB Live. Not SB Live 24bit. */ +/* Redundant with emu10k2_chip being unset. */ + unsigned int emu10k2_chip:1; /* Audigy 1 or Audigy 2. */ + unsigned int ca0102_chip:1; /* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ +/* Redundant with ca0108_chip being unset. */ + unsigned int ca0108_chip:1; /* Audigy 2 Value */ + unsigned int ca_cardbus_chip:1; /* Audigy 2 ZS Notebook */ + unsigned int ca0151_chip:1; /* P16V */ + unsigned int spk71:1; /* Has 7.1 speakers */ + unsigned int sblive51:1; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ + unsigned int spdif_bug:1; /* Has Spdif phasing bug */ + unsigned int ac97_chip:2; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ + unsigned int ecard:1; /* APS EEPROM */ + unsigned int spi_dac:1; /* SPI interface for DAC; requires ca0108_chip */ + unsigned int i2c_adc:1; /* I2C interface for ADC; requires ca0108_chip */ + unsigned int adc_1361t:1; /* Use Philips 1361T ADC */ + unsigned int invert_shared_spdif:1; /* analog/digital switch inverted */const char *driver;const char *name;const char *id;/* for backward compatibility - can be NULL if not needed */
sound/pci/emu10k1/emumixer.c +5 -5
@@ -180,7 +180,7 @@ static const char * const emu1616_src_texts[] = {/* * List of data sources available for each destination */ -static const unsigned int emu1010_src_regs[] = { +static const unsigned short emu1010_src_regs[] = {EMU_SRC_SILENCE ,/* 0 */ EMU_SRC_DOCK_MIC_A1 ,/* 1 */ EMU_SRC_DOCK_MIC_B1 ,/* 2 */
@@ -237,7 +237,7 @@ static const unsigned int emu1010_src_regs[] = { };/* 1616(m) cardbus */ -static const unsigned int emu1616_src_regs[] = { +static const unsigned short emu1616_src_regs[] = {EMU_SRC_SILENCE ,EMU_SRC_DOCK_MIC_A1 ,EMU_SRC_DOCK_MIC_B1 ,
@@ -293,7 +293,7 @@ static const unsigned int emu1616_src_regs[] = {* Data destinations - physical EMU outputs. * Each destination has an enum mixer control to choose a data source */ -static const unsigned int emu1010_output_dst[] = { +static const unsigned short emu1010_output_dst[] = {EMU_DST_DOCK_DAC1_LEFT1 ,/* 0 */ EMU_DST_DOCK_DAC1_RIGHT1 ,/* 1 */ EMU_DST_DOCK_DAC2_LEFT1 ,/* 2 */
@@ -321,7 +321,7 @@ static const unsigned int emu1010_output_dst[] = { };/* 1616(m) cardbus */ -static const unsigned int emu1616_output_dst[] = { +static const unsigned short emu1616_output_dst[] = {EMU_DST_DOCK_DAC1_LEFT1 ,EMU_DST_DOCK_DAC1_RIGHT1 ,EMU_DST_DOCK_DAC2_LEFT1 ,
@@ -347,7 +347,7 @@ static const unsigned int emu1616_output_dst[] = {* capture (EMU32 + I2S links) * Each destination has an enum mixer control to choose a data source */ -static const unsigned int emu1010_input_dst[] = { +static const unsigned short emu1010_input_dst[] = {EMU_DST_ALICE2_EMU32_0 ,EMU_DST_ALICE2_EMU32_1 ,EMU_DST_ALICE2_EMU32_2 ,
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 2/10 ALSA: emu10k1: compactize E-MU routing source arrays
In reply to Oswald BuddenhagenUse macros to avoid duplication. Arguably, this is somewhat less legible, but future additions would grow this part of the file to completely unmanageable dimensions.
The EMU*_COMMON_TEXTS macros will save duplication in a future commit; I pulled them ahead to reduce churn.
While rewriting the tables anyway, rearrange them such that each card's strings and registers are adjacent.
Also, add some static asserts to verify that the array sizes match.
--- sound/pci/emu10k1/emumixer.c | 317 ++++++++++++----------------------- 1 file changed, 104 insertions(+), 213 deletions(-)
sound/pci/emu10k1/emumixer.c +104 -213
@@ -62,232 +62,123 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol,return 0 ; } -/* -* Items labels in enum mixer controls assigning source data to -* each destination -*/ -static const char *const emu1010_src_texts[] = { -"Silence" , -"Dock Mic A" , -"Dock Mic B" , -"Dock ADC1 Left" , -"Dock ADC1 Right" , -"Dock ADC2 Left" , -"Dock ADC2 Right" , -"Dock ADC3 Left" , -"Dock ADC3 Right" , -"0202 ADC Left" , -"0202 ADC Right" , -"1010 SPDIF Left" , -"1010 SPDIF Right" , -"1010 ADAT 0" , -"1010 ADAT 1" , -"1010 ADAT 2" , -"1010 ADAT 3" , -"1010 ADAT 4" , -"1010 ADAT 5" , -"1010 ADAT 6" , -"1010 ADAT 7" , -"DSP 0" , -"DSP 1" , -"DSP 2" , -"DSP 3" , -"DSP 4" , -"DSP 5" , -"DSP 6" , -"DSP 7" , -"DSP 8" , -"DSP 9" , -"DSP 10" , -"DSP 11" , -"DSP 12" , -"DSP 13" , -"DSP 14" , -"DSP 15" , -"DSP 16" , -"DSP 17" , -"DSP 18" , -"DSP 19" , -"DSP 20" , -"DSP 21" , -"DSP 22" , -"DSP 23" , -"DSP 24" , -"DSP 25" , -"DSP 26" , -"DSP 27" , -"DSP 28" , -"DSP 29" , -"DSP 30" , -"DSP 31" , -}; +#define PAIR_PS (base, one, two, sfx) base " " one sfx, base " " two sfx +#define LR_PS (base, sfx) PAIR_PS(base, "Left", "Right", sfx) -/* 1616(m) cardbus */ +#define ADAT_PS (pfx, sfx) \ + pfx "ADAT 0" sfx, pfx "ADAT 1" sfx, pfx "ADAT 2" sfx, pfx "ADAT 3" sfx, \ + pfx "ADAT 4" sfx, pfx "ADAT 5" sfx, pfx "ADAT 6" sfx, pfx "ADAT 7" sfx -static const char *const emu1616_src_texts[] = { -"Silence" , -"Mic A" , -"Mic B" , -"ADC1 Left" , -"ADC1 Right" , -"ADC2 Left" , -"ADC2 Right" , -"SPDIF Left" , -"SPDIF Right" , -"ADAT 0" , -"ADAT 1" , -"ADAT 2" , -"ADAT 3" , -"ADAT 4" , -"ADAT 5" , -"ADAT 6" , -"ADAT 7" , -"DSP 0" , -"DSP 1" , -"DSP 2" , -"DSP 3" , -"DSP 4" , -"DSP 5" , -"DSP 6" , -"DSP 7" , -"DSP 8" , -"DSP 9" , -"DSP 10" , -"DSP 11" , -"DSP 12" , -"DSP 13" , -"DSP 14" , -"DSP 15" , -"DSP 16" , -"DSP 17" , -"DSP 18" , -"DSP 19" , -"DSP 20" , -"DSP 21" , -"DSP 22" , -"DSP 23" , -"DSP 24" , -"DSP 25" , -"DSP 26" , -"DSP 27" , -"DSP 28" , -"DSP 29" , -"DSP 30" , -"DSP 31" , -}; +#define PAIR_REGS (base, one, two) \ + base ## one ## 1, \ + base ## two ## 1 +#define LR_REGS (base) PAIR_REGS(base, _LEFT, _RIGHT) + +#define ADAT_REGS (base) \ + base+0, base+1, base+2, base+3, base+4, base+5, base+6, base+7/* * List of data sources available for each destination */ -static const unsigned short emu1010_src_regs[] = { -EMU_SRC_SILENCE ,/* 0 */ -EMU_SRC_DOCK_MIC_A1 ,/* 1 */ -EMU_SRC_DOCK_MIC_B1 ,/* 2 */ -EMU_SRC_DOCK_ADC1_LEFT1 ,/* 3 */ -EMU_SRC_DOCK_ADC1_RIGHT1 ,/* 4 */ -EMU_SRC_DOCK_ADC2_LEFT1 ,/* 5 */ -EMU_SRC_DOCK_ADC2_RIGHT1 ,/* 6 */ -EMU_SRC_DOCK_ADC3_LEFT1 ,/* 7 */ -EMU_SRC_DOCK_ADC3_RIGHT1 ,/* 8 */ -EMU_SRC_HAMOA_ADC_LEFT1 ,/* 9 */ -EMU_SRC_HAMOA_ADC_RIGHT1 ,/* 10 */ -EMU_SRC_HANA_SPDIF_LEFT1 ,/* 11 */ -EMU_SRC_HANA_SPDIF_RIGHT1 ,/* 12 */ -EMU_SRC_HANA_ADAT ,/* 13 */ -EMU_SRC_HANA_ADAT +1 ,/* 14 */ -EMU_SRC_HANA_ADAT +2 ,/* 15 */ -EMU_SRC_HANA_ADAT +3 ,/* 16 */ -EMU_SRC_HANA_ADAT +4 ,/* 17 */ -EMU_SRC_HANA_ADAT +5 ,/* 18 */ -EMU_SRC_HANA_ADAT +6 ,/* 19 */ -EMU_SRC_HANA_ADAT +7 ,/* 20 */ -EMU_SRC_ALICE_EMU32A ,/* 21 */ -EMU_SRC_ALICE_EMU32A +1 ,/* 22 */ -EMU_SRC_ALICE_EMU32A +2 ,/* 23 */ -EMU_SRC_ALICE_EMU32A +3 ,/* 24 */ -EMU_SRC_ALICE_EMU32A +4 ,/* 25 */ -EMU_SRC_ALICE_EMU32A +5 ,/* 26 */ -EMU_SRC_ALICE_EMU32A +6 ,/* 27 */ -EMU_SRC_ALICE_EMU32A +7 ,/* 28 */ -EMU_SRC_ALICE_EMU32A +8 ,/* 29 */ -EMU_SRC_ALICE_EMU32A +9 ,/* 30 */ -EMU_SRC_ALICE_EMU32A +0xa ,/* 31 */ -EMU_SRC_ALICE_EMU32A +0xb ,/* 32 */ -EMU_SRC_ALICE_EMU32A +0xc ,/* 33 */ -EMU_SRC_ALICE_EMU32A +0xd ,/* 34 */ -EMU_SRC_ALICE_EMU32A +0xe ,/* 35 */ -EMU_SRC_ALICE_EMU32A +0xf ,/* 36 */ -EMU_SRC_ALICE_EMU32B ,/* 37 */ -EMU_SRC_ALICE_EMU32B +1 ,/* 38 */ -EMU_SRC_ALICE_EMU32B +2 ,/* 39 */ -EMU_SRC_ALICE_EMU32B +3 ,/* 40 */ -EMU_SRC_ALICE_EMU32B +4 ,/* 41 */ -EMU_SRC_ALICE_EMU32B +5 ,/* 42 */ -EMU_SRC_ALICE_EMU32B +6 ,/* 43 */ -EMU_SRC_ALICE_EMU32B +7 ,/* 44 */ -EMU_SRC_ALICE_EMU32B +8 ,/* 45 */ -EMU_SRC_ALICE_EMU32B +9 ,/* 46 */ -EMU_SRC_ALICE_EMU32B +0xa ,/* 47 */ -EMU_SRC_ALICE_EMU32B +0xb ,/* 48 */ -EMU_SRC_ALICE_EMU32B +0xc ,/* 49 */ -EMU_SRC_ALICE_EMU32B +0xd ,/* 50 */ -EMU_SRC_ALICE_EMU32B +0xe ,/* 51 */ -EMU_SRC_ALICE_EMU32B +0xf ,/* 52 */ + +#define DSP_TEXTS \ + "DSP 0", "DSP 1", "DSP 2", "DSP 3", "DSP 4", "DSP 5", "DSP 6", "DSP 7", \ + "DSP 8", "DSP 9", "DSP 10", "DSP 11", "DSP 12", "DSP 13", "DSP 14", "DSP 15", \ + "DSP 16", "DSP 17", "DSP 18", "DSP 19", "DSP 20", "DSP 21", "DSP 22", "DSP 23", \ + "DSP 24", "DSP 25", "DSP 26", "DSP 27", "DSP 28", "DSP 29", "DSP 30", "DSP 31" + +#define PAIR_TEXTS (base, one, two) PAIR_PS(base, one, two, "") +#define LR_TEXTS (base) LR_PS(base, "") +#define ADAT_TEXTS (pfx) ADAT_PS(pfx, "") + +#define EMU32_SRC_REGS \ + EMU_SRC_ALICE_EMU32A, \ + EMU_SRC_ALICE_EMU32A+1, \ + EMU_SRC_ALICE_EMU32A+2, \ + EMU_SRC_ALICE_EMU32A+3, \ + EMU_SRC_ALICE_EMU32A+4, \ + EMU_SRC_ALICE_EMU32A+5, \ + EMU_SRC_ALICE_EMU32A+6, \ + EMU_SRC_ALICE_EMU32A+7, \ + EMU_SRC_ALICE_EMU32A+8, \ + EMU_SRC_ALICE_EMU32A+9, \ + EMU_SRC_ALICE_EMU32A+0xa, \ + EMU_SRC_ALICE_EMU32A+0xb, \ + EMU_SRC_ALICE_EMU32A+0xc, \ + EMU_SRC_ALICE_EMU32A+0xd, \ + EMU_SRC_ALICE_EMU32A+0xe, \ + EMU_SRC_ALICE_EMU32A+0xf, \ + EMU_SRC_ALICE_EMU32B, \ + EMU_SRC_ALICE_EMU32B+1, \ + EMU_SRC_ALICE_EMU32B+2, \ + EMU_SRC_ALICE_EMU32B+3, \ + EMU_SRC_ALICE_EMU32B+4, \ + EMU_SRC_ALICE_EMU32B+5, \ + EMU_SRC_ALICE_EMU32B+6, \ + EMU_SRC_ALICE_EMU32B+7, \ + EMU_SRC_ALICE_EMU32B+8, \ + EMU_SRC_ALICE_EMU32B+9, \ + EMU_SRC_ALICE_EMU32B+0xa, \ + EMU_SRC_ALICE_EMU32B+0xb, \ + EMU_SRC_ALICE_EMU32B+0xc, \ + EMU_SRC_ALICE_EMU32B+0xd, \ + EMU_SRC_ALICE_EMU32B+0xe, \ + EMU_SRC_ALICE_EMU32B+0xf + +#define EMU1010_COMMON_TEXTS \ + "Silence", \ + PAIR_TEXTS("Dock Mic", "A", "B"), \ + LR_TEXTS("Dock ADC1"), \ + LR_TEXTS("Dock ADC2"), \ + LR_TEXTS("Dock ADC3"), \ + LR_TEXTS("0202 ADC"), \ + LR_TEXTS("1010 SPDIF"), \ + ADAT_TEXTS("1010 ") + +static const char *const emu1010_src_texts[] = { +EMU1010_COMMON_TEXTS , +DSP_TEXTS , }; +static const unsigned short emu1010_src_regs[] = { +EMU_SRC_SILENCE , +PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B), +LR_REGS (EMU_SRC_DOCK_ADC1 ), +LR_REGS (EMU_SRC_DOCK_ADC2 ), +LR_REGS (EMU_SRC_DOCK_ADC3 ), +LR_REGS (EMU_SRC_HAMOA_ADC ), +LR_REGS (EMU_SRC_HANA_SPDIF ), +ADAT_REGS (EMU_SRC_HANA_ADAT ), +EMU32_SRC_REGS , +}; +static_assert (ARRAY_SIZE (emu1010_src_regs) ==ARRAY_SIZE (emu1010_src_texts)); +/* 1616(m) cardbus */ + +#define EMU1616_COMMON_TEXTS \ + "Silence", \ + PAIR_TEXTS("Mic", "A", "B"), \ + LR_TEXTS("ADC1"), \ + LR_TEXTS("ADC2"), \ + LR_TEXTS("SPDIF"), \ + ADAT_TEXTS("") + +static const char *const emu1616_src_texts[] = { +EMU1616_COMMON_TEXTS , +DSP_TEXTS , +}; +static const unsigned short emu1616_src_regs[] = {EMU_SRC_SILENCE , -EMU_SRC_DOCK_MIC_A1 , -EMU_SRC_DOCK_MIC_B1 , -EMU_SRC_DOCK_ADC1_LEFT1 , -EMU_SRC_DOCK_ADC1_RIGHT1 , -EMU_SRC_DOCK_ADC2_LEFT1 , -EMU_SRC_DOCK_ADC2_RIGHT1 , -EMU_SRC_MDOCK_SPDIF_LEFT1 , -EMU_SRC_MDOCK_SPDIF_RIGHT1 , -EMU_SRC_MDOCK_ADAT , -EMU_SRC_MDOCK_ADAT +1 , -EMU_SRC_MDOCK_ADAT +2 , -EMU_SRC_MDOCK_ADAT +3 , -EMU_SRC_MDOCK_ADAT +4 , -EMU_SRC_MDOCK_ADAT +5 , -EMU_SRC_MDOCK_ADAT +6 , -EMU_SRC_MDOCK_ADAT +7 , -EMU_SRC_ALICE_EMU32A , -EMU_SRC_ALICE_EMU32A +1 , -EMU_SRC_ALICE_EMU32A +2 , -EMU_SRC_ALICE_EMU32A +3 , -EMU_SRC_ALICE_EMU32A +4 , -EMU_SRC_ALICE_EMU32A +5 , -EMU_SRC_ALICE_EMU32A +6 , -EMU_SRC_ALICE_EMU32A +7 , -EMU_SRC_ALICE_EMU32A +8 , -EMU_SRC_ALICE_EMU32A +9 , -EMU_SRC_ALICE_EMU32A +0xa , -EMU_SRC_ALICE_EMU32A +0xb , -EMU_SRC_ALICE_EMU32A +0xc , -EMU_SRC_ALICE_EMU32A +0xd , -EMU_SRC_ALICE_EMU32A +0xe , -EMU_SRC_ALICE_EMU32A +0xf , -EMU_SRC_ALICE_EMU32B , -EMU_SRC_ALICE_EMU32B +1 , -EMU_SRC_ALICE_EMU32B +2 , -EMU_SRC_ALICE_EMU32B +3 , -EMU_SRC_ALICE_EMU32B +4 , -EMU_SRC_ALICE_EMU32B +5 , -EMU_SRC_ALICE_EMU32B +6 , -EMU_SRC_ALICE_EMU32B +7 , -EMU_SRC_ALICE_EMU32B +8 , -EMU_SRC_ALICE_EMU32B +9 , -EMU_SRC_ALICE_EMU32B +0xa , -EMU_SRC_ALICE_EMU32B +0xb , -EMU_SRC_ALICE_EMU32B +0xc , -EMU_SRC_ALICE_EMU32B +0xd , -EMU_SRC_ALICE_EMU32B +0xe , -EMU_SRC_ALICE_EMU32B +0xf , +PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B), +LR_REGS (EMU_SRC_DOCK_ADC1 ), +LR_REGS (EMU_SRC_DOCK_ADC2 ), +LR_REGS (EMU_SRC_MDOCK_SPDIF ), +ADAT_REGS (EMU_SRC_MDOCK_ADAT ), +EMU32_SRC_REGS , }; +static_assert (ARRAY_SIZE (emu1616_src_regs) ==ARRAY_SIZE (emu1616_src_texts));/* * Data destinations - physical EMU outputs.
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 3/10 ALSA: emu10k1: make mixer control mass creation less wasteful
In reply to Oswald BuddenhagenDefine arrays of strings instead of snd_kcontrol_new.
While at it, move the E-MU source & destination enum defs next to their hardware defs, which is a lot more logical and will come in handy in a followup commit. And add some static asserts to verify that the array sizes match.
This also applies the compactization from the previous commit to the destination registers.
While reshuffling the arrays anyway, switch the order of the HAMOA_DAC & HANA_SPDIF output destinations for the 1010 card, so they follow a more regular pattern. This should have no functional impact.
The code is somewhat de-duplicated by the extraction of add_ctls().
--- include/sound/emu10k1.h | 2 +- sound/pci/emu10k1/emumixer.c | 455 ++++++++++++++++------------------- 2 files changed, 206 insertions(+), 251 deletions(-)
include/sound/emu10k1.h +1 -1
@@ -1187,7 +1187,7 @@ SUB_REG_NC(A_EHC, A_I2S_CAPTURE_RATE, 0x00000e00) /* This sets the capture PCM* physical outputs of Hana, or outputs going to Alice2/Tina for capture - * 16 x EMU_DST_ALICE2_EMU32_X (2x on rev2 boards). Which data is fed into * a channel depends on the mixer control setting for each destination - see -* emumixer.c - snd_emu1010_output_enum_ctls[], snd_emu1010_input_enum_ctls[] +* the register arrays in emumixer.c. */ #define EMU_DST_ALICE2_EMU32_0 0x000f/* 16 EMU32 channels to Alice2 +0 to +0xf */ /* This channel is delayed by one sample. */
sound/pci/emu10k1/emumixer.c +205 -250
571 lines not on this page · raw message
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 4/10 ALSA: emu10k1: un-hardcode E-MU mixer control callbacks somewhat
In reply to Oswald BuddenhagenInstead of hard-coding the card-specific arrays and their sizes in each function, use a more data-driven approach.
As a drive-by, also hide the unavailable I2S input destinations on the 1616 cardbus card.
Also as a drive-by, use more assignments at variable declaration for brevity. This also removes the pointless masking of kctl.private_value.
--- sound/pci/emu10k1/emumixer.c | 155 +++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 54 deletions(-)
sound/pci/emu10k1/emumixer.c +101 -54
@@ -311,61 +311,114 @@ static const unsigned short emu1010_input_dst[] = { };static_assert (ARRAY_SIZE (emu1010_input_dst) ==ARRAY_SIZE (emu1010_input_texts)); +struct snd_emu1010_routing_info { +const char *const *src_texts; +const unsigned short *src_regs; +const unsigned short *out_regs; +const unsigned short *in_regs; +unsigned n_srcs; +unsigned n_outs; +unsigned n_ins; +}; + +const struct snd_emu1010_routing_info emu1010_routing_info[] = { + { + .src_regs = emu1010_src_regs, + .src_texts = emu1010_src_texts, + .n_srcs =ARRAY_SIZE (emu1010_src_texts), + + .out_regs = emu1010_output_dst, + .n_outs =ARRAY_SIZE (emu1010_output_dst), + + .in_regs = emu1010_input_dst, + .n_ins =ARRAY_SIZE (emu1010_input_dst), + }, + { +/* 1616(m) cardbus */ + .src_regs = emu1616_src_regs, + .src_texts = emu1616_src_texts, + .n_srcs =ARRAY_SIZE (emu1616_src_texts), + + .out_regs = emu1616_output_dst, + .n_outs =ARRAY_SIZE (emu1616_output_dst), + + .in_regs = emu1010_input_dst, + .n_ins =ARRAY_SIZE (emu1010_input_dst) -6 , + }, +}; + +static unsigned emu1010_idx (struct snd_emu10k1 *emu) +{ +if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) +return 1 ; +else +return 0 ; +} + +static void snd_emu1010_output_source_apply (struct snd_emu10k1 *emu, +int channel,int src) +{ +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; + +snd_emu1010_fpga_link_dst_src_write (emu, + emu_ri->out_regs[channel], emu_ri->src_regs[src]); +} + +static void snd_emu1010_input_source_apply (struct snd_emu10k1 *emu, +int channel,int src) +{ +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; + +snd_emu1010_fpga_link_dst_src_write (emu, + emu_ri->in_regs[channel], emu_ri->src_regs[src]); +} +static int snd_emu1010_input_output_source_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol); +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; -if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) -return snd_ctl_enum_info (uinfo,1 ,49 , emu1616_src_texts); -else -return snd_ctl_enum_info (uinfo,1 ,53 , emu1010_src_texts); +return snd_ctl_enum_info (uinfo,1 , emu_ri->n_srcs, emu_ri->src_texts); }static int snd_emu1010_output_source_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol); -unsigned int channel; +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; +unsigned channel = kcontrol->private_value; - channel = (kcontrol->private_value) &0xff ; -/* Limit: emu1010_output_dst, emu->emu1010.output_source */ -if (channel >=24 || - (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 && - channel >=18 )) +if (channel >= emu_ri->n_outs)return -EINVAL ; ucontrol->value.enumerated.item[0 ] = emu->emu1010.output_source[channel];return 0 ; }static int snd_emu1010_output_source_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol); -unsigned int val; -unsigned int channel; +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; +unsigned val = ucontrol->value.enumerated.item[0 ]; +unsigned channel = kcontrol->private_value; +int change; - val = ucontrol->value.enumerated.item[0 ]; -if (val >=53 || - (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 && - val >=49 )) +if (val >= emu_ri->n_srcs)return -EINVAL ; - channel = (kcontrol->private_value) &0xff ; -/* Limit: emu1010_output_dst, emu->emu1010.output_source */ -if (channel >=24 || - (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 && - channel >=18 )) +if (channel >= emu_ri->n_outs)return -EINVAL ; -if (emu->emu1010.output_source[channel] == val) -return 0 ; - emu->emu1010.output_source[channel] = val; -if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) -snd_emu1010_fpga_link_dst_src_write (emu, - emu1616_output_dst[channel], emu1616_src_regs[val]); -else -snd_emu1010_fpga_link_dst_src_write (emu, - emu1010_output_dst[channel], emu1010_src_regs[val]); -return 1 ; + change = (emu->emu1010.output_source[channel] != val); +if (change) { + emu->emu1010.output_source[channel] = val; +snd_emu1010_output_source_apply (emu, channel, val); + } +return change; }static const struct snd_kcontrol_new emu1010_output_source_ctl = {
@@ -380,42 +433,36 @@ static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol); -unsigned int channel; +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; +unsigned channel = kcontrol->private_value; - channel = (kcontrol->private_value) &0xff ; -/* Limit: emu1010_input_dst, emu->emu1010.input_source */ -if (channel >=22 ) +if (channel >= emu_ri->n_ins)return -EINVAL ; ucontrol->value.enumerated.item[0 ] = emu->emu1010.input_source[channel];return 0 ; }static int snd_emu1010_input_source_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol); -unsigned int val; -unsigned int channel; +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; +unsigned val = ucontrol->value.enumerated.item[0 ]; +unsigned channel = kcontrol->private_value; +int change; - val = ucontrol->value.enumerated.item[0 ]; -if (val >=53 || - (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 && - val >=49 )) +if (val >= emu_ri->n_srcs)return -EINVAL ; - channel = (kcontrol->private_value) &0xff ; -/* Limit: emu1010_input_dst, emu->emu1010.input_source */ -if (channel >=22 ) +if (channel >= emu_ri->n_ins)return -EINVAL ; -if (emu->emu1010.input_source[channel] == val) -return 0 ; - emu->emu1010.input_source[channel] = val; -if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) -snd_emu1010_fpga_link_dst_src_write (emu, - emu1010_input_dst[channel], emu1616_src_regs[val]); -else -snd_emu1010_fpga_link_dst_src_write (emu, - emu1010_input_dst[channel], emu1010_src_regs[val]); -return 1 ; + change = (emu->emu1010.input_source[channel] != val); +if (change) { + emu->emu1010.input_source[channel] = val; +snd_emu1010_input_source_apply (emu, channel, val); + } +return change; }static const struct snd_kcontrol_new emu1010_input_source_ctl = {
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 5/10 ALSA: emu10k1: fix return value of snd_emu1010_dac_pads_put()
In reply to Oswald BuddenhagenIt returned zero even if the value had changed.
--- sound/pci/emu10k1/emumixer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/emu10k1/emumixer.c +5 -2
@@ -559,18 +559,21 @@ static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ctstruct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol);unsigned int mask = snd_emu1010_dac_regs[kcontrol->private_value];unsigned int val, cache; +int change; + val = ucontrol->value.integer.value[0 ]; cache = emu->emu1010.dac_pads;if (val ==1 ) cache = cache | mask;else cache = cache & ~mask; -if (cache != emu->emu1010.dac_pads) { + change = (cache != emu->emu1010.dac_pads); +if (change) {snd_emu1010_fpga_write (emu,EMU_HANA_DAC_PADS , cache ); emu->emu1010.dac_pads = cache; } -return 0 ; +return change; }static const struct snd_kcontrol_new emu1010_dac_pads_ctl = {
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 6/10 ALSA: emu10k1: make E-MU I/O routing init data-driven
In reply to Oswald Buddenhagen... and move it to the mixer init, as it's logically part of it.
As a side effect, this fixes the initial values of the input destination mixer controls, which would have previously remained at "Silent" despite different defaults. This didn't really matter, though, as ALSA state restoration would hide that bug beyond first use.
Note that this completely does away with clearing the output routing registers, as it was rather pointless - we just programmed the FPGA (resetting it first if necessary), so everything is zeroed anyway (that's documented by Xilinx, and as further evidence, some of the loops terminated too early, and we didn't bother clearing the high channels of the input routes at all, all with no observed adverse effects).
As a drive-by, this also fixes some capture channel defaults - any EMU_SRC_*2 isn't a sensible value in 1x clock mode.
--- sound/pci/emu10k1/emu10k1_main.c | 248 +------------------------------ sound/pci/emu10k1/emumixer.c | 97 ++++++++++++ 2 files changed, 99 insertions(+), 246 deletions(-)
sound/pci/emu10k1/emu10k1_main.c +2 -246
@@ -798,7 +798,6 @@ static void emu1010_firmware_work(struct work_struct *work)*/ static int snd_emu10k1_emu1010_init (struct snd_emu10k1 *emu) { -unsigned int i;u32 tmp, tmp2, reg;int err;
@@ -889,253 +888,10 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)/* Audio Dock LEDs. */ snd_emu1010_fpga_write (emu,EMU_HANA_DOCK_LEDS_2 ,EMU_HANA_DOCK_LEDS_2_LOCK |EMU_HANA_DOCK_LEDS_2_48K ); -#if 0 -/* For 96kHz */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_0 ,EMU_SRC_HAMOA_ADC_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_1 ,EMU_SRC_HAMOA_ADC_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_4 ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_5 ,EMU_SRC_HAMOA_ADC_RIGHT2 ); -#endif -#if 0 -/* For 192kHz */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_0 ,EMU_SRC_HAMOA_ADC_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_1 ,EMU_SRC_HAMOA_ADC_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_2 ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_3 ,EMU_SRC_HAMOA_ADC_RIGHT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_4 ,EMU_SRC_HAMOA_ADC_LEFT3 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_5 ,EMU_SRC_HAMOA_ADC_RIGHT3 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_6 ,EMU_SRC_HAMOA_ADC_LEFT4 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_7 ,EMU_SRC_HAMOA_ADC_RIGHT4 ); -#endif -#if 1 -/* For 48kHz */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_0 ,EMU_SRC_DOCK_MIC_A1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_1 ,EMU_SRC_DOCK_MIC_B1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_2 ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_3 ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_4 ,EMU_SRC_DOCK_ADC1_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_5 ,EMU_SRC_DOCK_ADC1_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_6 ,EMU_SRC_DOCK_ADC2_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_7 ,EMU_SRC_DOCK_ADC2_RIGHT1 ); -/* Pavel Hofman - setting defaults for 8 more capture channels -* Defaults only, users will set their own values anyways, let's -* just copy/paste. -*/ - -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_8 ,EMU_SRC_DOCK_MIC_A1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_9 ,EMU_SRC_DOCK_MIC_B1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_A ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_B ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_C ,EMU_SRC_DOCK_ADC1_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_D ,EMU_SRC_DOCK_ADC1_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_E ,EMU_SRC_DOCK_ADC2_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_F ,EMU_SRC_DOCK_ADC2_RIGHT1 ); -#endif -#if 0 -/* Original */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_4 ,EMU_SRC_HANA_ADAT ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_5 ,EMU_SRC_HANA_ADAT +1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_6 ,EMU_SRC_HANA_ADAT +2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_7 ,EMU_SRC_HANA_ADAT +3 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_8 ,EMU_SRC_HANA_ADAT +4 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_9 ,EMU_SRC_HANA_ADAT +5 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_A ,EMU_SRC_HANA_ADAT +6 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_B ,EMU_SRC_HANA_ADAT +7 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_C ,EMU_SRC_DOCK_MIC_A1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_D ,EMU_SRC_DOCK_MIC_B1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_E ,EMU_SRC_HAMOA_ADC_LEFT2 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE2_EMU32_F ,EMU_SRC_HAMOA_ADC_LEFT2 ); -#endif -for (i =0 ; i <0x20 ; i++) { -/* AudioDock Elink <- Silence */ -snd_emu1010_fpga_link_dst_src_write (emu,0x0100 + i,EMU_SRC_SILENCE ); - } -for (i =0 ; i <4 ; i++) { -/* Hana SPDIF Out <- Silence */ -snd_emu1010_fpga_link_dst_src_write (emu,0x0200 + i,EMU_SRC_SILENCE ); - } -for (i =0 ; i <7 ; i++) { -/* Hamoa DAC <- Silence */ -snd_emu1010_fpga_link_dst_src_write (emu,0x0300 + i,EMU_SRC_SILENCE ); - } -for (i =0 ; i <7 ; i++) { -/* Hana ADAT Out <- Silence */ -snd_emu1010_fpga_link_dst_src_write (emu,EMU_DST_HANA_ADAT + i,EMU_SRC_SILENCE ); - } -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S0_LEFT ,EMU_SRC_DOCK_ADC1_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S0_RIGHT ,EMU_SRC_DOCK_ADC1_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S1_LEFT ,EMU_SRC_DOCK_ADC2_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S1_RIGHT ,EMU_SRC_DOCK_ADC2_RIGHT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S2_LEFT ,EMU_SRC_DOCK_ADC3_LEFT1 ); -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_ALICE_I2S2_RIGHT ,EMU_SRC_DOCK_ADC3_RIGHT1 ); +// The routes are all set to EMU_SRC_SILENCE due to the reset, +// so it is safe to simply enable the outputs. snd_emu1010_fpga_write (emu,EMU_HANA_UNMUTE ,EMU_UNMUTE ); -#if 0 -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HAMOA_DAC_LEFT1 ,EMU_SRC_ALICE_EMU32B +2 );/* ALICE2 bus 0xa2 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HAMOA_DAC_RIGHT1 ,EMU_SRC_ALICE_EMU32B +3 );/* ALICE2 bus 0xa3 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_SPDIF_LEFT1 ,EMU_SRC_ALICE_EMU32A +2 );/* ALICE2 bus 0xb2 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_SPDIF_RIGHT1 ,EMU_SRC_ALICE_EMU32A +3 );/* ALICE2 bus 0xb3 */ -#endif -/* Default outputs */ -if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) { -/* 1616(M) cardbus default outputs */ -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC1_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[0 ] =17 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC1_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[1 ] =18 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC2_LEFT1 ,EMU_SRC_ALICE_EMU32A +2 ); - emu->emu1010.output_source[2 ] =19 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC2_RIGHT1 ,EMU_SRC_ALICE_EMU32A +3 ); - emu->emu1010.output_source[3 ] =20 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC3_LEFT1 ,EMU_SRC_ALICE_EMU32A +4 ); - emu->emu1010.output_source[4 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC3_RIGHT1 ,EMU_SRC_ALICE_EMU32A +5 ); - emu->emu1010.output_source[5 ] =22 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_MANA_DAC_LEFT ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[16 ] =17 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_MANA_DAC_RIGHT ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[17 ] =18 ; - }else { -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC1_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[0 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC1_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[1 ] =22 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC2_LEFT1 ,EMU_SRC_ALICE_EMU32A +2 ); - emu->emu1010.output_source[2 ] =23 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC2_RIGHT1 ,EMU_SRC_ALICE_EMU32A +3 ); - emu->emu1010.output_source[3 ] =24 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC3_LEFT1 ,EMU_SRC_ALICE_EMU32A +4 ); - emu->emu1010.output_source[4 ] =25 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC3_RIGHT1 ,EMU_SRC_ALICE_EMU32A +5 ); - emu->emu1010.output_source[5 ] =26 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC4_LEFT1 ,EMU_SRC_ALICE_EMU32A +6 ); - emu->emu1010.output_source[6 ] =27 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_DAC4_RIGHT1 ,EMU_SRC_ALICE_EMU32A +7 ); - emu->emu1010.output_source[7 ] =28 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_PHONES_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[8 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_PHONES_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[9 ] =22 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_SPDIF_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[10 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_DOCK_SPDIF_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[11 ] =22 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_SPDIF_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[12 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_SPDIF_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[13 ] =22 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HAMOA_DAC_LEFT1 ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[14 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HAMOA_DAC_RIGHT1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[15 ] =22 ; -/* ALICE2 bus 0xa0 */ -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT ,EMU_SRC_ALICE_EMU32A +0 ); - emu->emu1010.output_source[16 ] =21 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +1 ,EMU_SRC_ALICE_EMU32A +1 ); - emu->emu1010.output_source[17 ] =22 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +2 ,EMU_SRC_ALICE_EMU32A +2 ); - emu->emu1010.output_source[18 ] =23 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +3 ,EMU_SRC_ALICE_EMU32A +3 ); - emu->emu1010.output_source[19 ] =24 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +4 ,EMU_SRC_ALICE_EMU32A +4 ); - emu->emu1010.output_source[20 ] =25 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +5 ,EMU_SRC_ALICE_EMU32A +5 ); - emu->emu1010.output_source[21 ] =26 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +6 ,EMU_SRC_ALICE_EMU32A +6 ); - emu->emu1010.output_source[22 ] =27 ; -snd_emu1010_fpga_link_dst_src_write (emu, -EMU_DST_HANA_ADAT +7 ,EMU_SRC_ALICE_EMU32A +7 ); - emu->emu1010.output_source[23 ] =28 ; - } -return 0 ; }/*
sound/pci/emu10k1/emumixer.c +97 -0
158 lines not on this page · raw message
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 7/10 ALSA: emu10k1: make E-MU mixer control creation more data-driven
In reply to Oswald BuddenhagenThe more card models are handled separately, the more code duplication this saves.
add_emu1010_source_mixers() is factored out the save duplication in a later commit.
--- sound/pci/emu10k1/emumixer.c | 108 +++++++++++++++++------------------ 1 file changed, 53 insertions(+), 55 deletions(-)
sound/pci/emu10k1/emumixer.c +53 -55
@@ -368,6 +368,7 @@ static_assert(ARRAY_SIZE(emu1010_input_dflt) == ARRAY_SIZE(emu1010_input_dst));struct snd_emu1010_routing_info {const char *const *src_texts; +const char *const *out_texts;const unsigned short *src_regs;const unsigned short *out_regs;const unsigned short *in_regs;
@@ -386,6 +387,7 @@ const struct snd_emu1010_routing_info emu1010_routing_info[] = { .out_dflts = emu1010_output_dflt, .out_regs = emu1010_output_dst, + .out_texts = emu1010_output_texts, .n_outs = ARRAY_SIZE(emu1010_output_dst), .in_dflts = emu1010_input_dflt,
@@ -400,6 +402,7 @@ const struct snd_emu1010_routing_info emu1010_routing_info[] = { .out_dflts = emu1616_output_dflt, .out_regs = emu1616_output_dst, + .out_texts = snd_emu1616_output_texts, .n_outs = ARRAY_SIZE(emu1616_output_dst), .in_dflts = emu1010_input_dflt,
@@ -556,6 +559,21 @@ static const struct snd_kcontrol_new emu1010_input_source_ctl = { .put = snd_emu1010_input_source_put }; +static int add_emu1010_source_mixers (struct snd_emu10k1 *emu) +{ +const struct snd_emu1010_routing_info *emu_ri = + &emu1010_routing_info[emu1010_idx (emu)]; +int err; + + err =add_ctls (emu, &emu1010_output_source_ctl, + emu_ri->out_texts, emu_ri->n_outs); +if (err <0 ) +return err; + err =add_ctls (emu, &emu1010_input_source_ctl, + emu1010_input_texts, emu_ri->n_ins); +return err; +} +static const char *const snd_emu1010_adc_pads[] = {"ADC1 14dB PAD Audio Dock Capture Switch" ,
@@ -668,6 +686,29 @@ static const struct snd_kcontrol_new emu1010_dac_pads_ctl = { }; +struct snd_emu1010_pads_info { +const char *const *adc_ctls, *const *dac_ctls; +unsigned n_adc_ctls, n_dac_ctls; +}; + +const struct snd_emu1010_pads_info emu1010_pads_info[] = { + { +/* all other e-mu cards for now */ + .adc_ctls = snd_emu1010_adc_pads, + .n_adc_ctls =ARRAY_SIZE (snd_emu1010_adc_pads), + .dac_ctls = snd_emu1010_dac_pads, + .n_dac_ctls =ARRAY_SIZE (snd_emu1010_dac_pads), + }, + { +/* 1616(m) cardbus */ + .adc_ctls = snd_emu1010_adc_pads, + .n_adc_ctls =ARRAY_SIZE (snd_emu1010_adc_pads) -2 , + .dac_ctls = snd_emu1010_dac_pads, + .n_dac_ctls =ARRAY_SIZE (snd_emu1010_dac_pads) -2 , + }, +}; + +static int snd_emu1010_internal_clock_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) {
@@ -2111,83 +2152,40 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,unsigned i, emu_idx =emu1010_idx (emu);const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu_idx]; +const struct snd_emu1010_pads_info *emu_pi = &emu1010_pads_info[emu_idx];for (i =0 ; i < emu_ri->n_ins; i++) emu->emu1010.input_source[i] =emu1010_map_source (emu_ri, emu_ri->in_dflts[i]);for (i =0 ; i < emu_ri->n_outs; i++) emu->emu1010.output_source[i] =emu1010_map_source (emu_ri, emu_ri->out_dflts[i]);snd_emu1010_apply_sources (emu); - } -if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) { -/* 1616(m) cardbus */ - err =add_ctls (emu, &emu1010_output_source_ctl, - snd_emu1616_output_texts, -ARRAY_SIZE (snd_emu1616_output_texts)); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_input_source_ctl, - emu1010_input_texts, -ARRAY_SIZE (emu1010_input_texts)); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_adc_pads_ctl, - snd_emu1010_adc_pads, -ARRAY_SIZE (snd_emu1010_adc_pads) -2 ); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_dac_pads_ctl, - snd_emu1010_dac_pads, -ARRAY_SIZE (snd_emu1010_dac_pads) -2 ); -if (err <0 ) -return err; err =snd_ctl_add (card,snd_ctl_new1 (&snd_emu1010_internal_clock, emu));if (err <0 )return err; + + err =add_ctls (emu, &emu1010_adc_pads_ctl, + emu_pi->adc_ctls, emu_pi->n_adc_ctls); +if (err <0 ) +return err; + err =add_ctls (emu, &emu1010_dac_pads_ctl, + emu_pi->dac_ctls, emu_pi->n_dac_ctls); +if (err <0 ) +return err; + err =snd_ctl_add (card,snd_ctl_new1 (&snd_emu1010_optical_out, emu));if (err <0 )return err; err =snd_ctl_add (card,snd_ctl_new1 (&snd_emu1010_optical_in, emu));if (err <0 )return err; - }else if (emu->card_capabilities->emu_model) { -/* all other e-mu cards for now */ - err =add_ctls (emu, &emu1010_output_source_ctl, - emu1010_output_texts, -ARRAY_SIZE (emu1010_output_texts)); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_input_source_ctl, - emu1010_input_texts, -ARRAY_SIZE (emu1010_input_texts)); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_adc_pads_ctl, - snd_emu1010_adc_pads, -ARRAY_SIZE (snd_emu1010_adc_pads)); -if (err <0 ) -return err; - err =add_ctls (emu, &emu1010_dac_pads_ctl, - snd_emu1010_dac_pads, -ARRAY_SIZE (snd_emu1010_dac_pads)); -if (err <0 ) -return err; - err =snd_ctl_add (card, -snd_ctl_new1 (&snd_emu1010_internal_clock, emu)); -if (err <0 ) -return err; - err =snd_ctl_add (card, -snd_ctl_new1 (&snd_emu1010_optical_out, emu)); -if (err <0 ) -return err; - err =snd_ctl_add (card, -snd_ctl_new1 (&snd_emu1010_optical_in, emu)); + err =add_emu1010_source_mixers (emu);if (err <0 )return err; }
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 8/10 ALSA: emu10k1: improve mixer controls for E-MU 1010 rev2 card
In reply to Oswald BuddenhagenThis card has rather different inputs/outputs due to switching from the AudioDock to the MicroDock.
--- sound/pci/emu10k1/emumixer.c | 106 +++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 6 deletions(-)
sound/pci/emu10k1/emumixer.c +100 -6
@@ -172,6 +172,38 @@ static const unsigned short emu1010_src_regs[] = { };static_assert (ARRAY_SIZE (emu1010_src_regs) ==ARRAY_SIZE (emu1010_src_texts)); +/* 1010 rev2 */ + +#define EMU1010b_COMMON_TEXTS \ + "Silence", \ + PAIR_TEXTS("Dock Mic", "A", "B"), \ + LR_TEXTS("Dock ADC1"), \ + LR_TEXTS("Dock ADC2"), \ + LR_TEXTS("0202 ADC"), \ + LR_TEXTS("Dock SPDIF"), \ + LR_TEXTS("1010 SPDIF"), \ + ADAT_TEXTS("Dock "), \ + ADAT_TEXTS("1010 ") + +static const char *const emu1010b_src_texts[] = { + EMU1010b_COMMON_TEXTS, +DSP_TEXTS , +}; + +static const unsigned short emu1010b_src_regs[] = { +EMU_SRC_SILENCE , +PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B), +LR_REGS (EMU_SRC_DOCK_ADC1 ), +LR_REGS (EMU_SRC_DOCK_ADC2 ), +LR_REGS (EMU_SRC_HAMOA_ADC ), +LR_REGS (EMU_SRC_MDOCK_SPDIF ), +LR_REGS (EMU_SRC_HANA_SPDIF ), +ADAT_REGS (EMU_SRC_MDOCK_ADAT ), +ADAT_REGS (EMU_SRC_HANA_ADAT ), +EMU32_SRC_REGS , +}; +static_assert (ARRAY_SIZE (emu1010b_src_regs) ==ARRAY_SIZE (emu1010b_src_texts)); +/* 1616(m) cardbus */ #define EMU1616_COMMON_TEXTS \
@@ -245,6 +277,44 @@ static const unsigned short emu1010_output_dflt[] = { };static_assert (ARRAY_SIZE (emu1010_output_dflt) ==ARRAY_SIZE (emu1010_output_dst)); +/* 1010 rev2 */ + +static const char *const snd_emu1010b_output_texts[] = { +LR_CTLS ("Dock DAC1" ), +LR_CTLS ("Dock DAC2" ), +LR_CTLS ("Dock DAC3" ), +LR_CTLS ("Dock SPDIF" ), +ADAT_CTLS ("Dock " ), +LR_CTLS ("0202 DAC" ), +LR_CTLS ("1010 SPDIF" ), +ADAT_CTLS ("1010 " ), +}; + +static const unsigned short emu1010b_output_dst[] = { +LR_REGS (EMU_DST_DOCK_DAC1 ), +LR_REGS (EMU_DST_DOCK_DAC2 ), +LR_REGS (EMU_DST_DOCK_DAC3 ), +LR_REGS (EMU_DST_MDOCK_SPDIF ), +ADAT_REGS (EMU_DST_MDOCK_ADAT ), +LR_REGS (EMU_DST_HAMOA_DAC ), +LR_REGS (EMU_DST_HANA_SPDIF ), +ADAT_REGS (EMU_DST_HANA_ADAT ), +}; +static_assert (ARRAY_SIZE (emu1010b_output_dst) ==ARRAY_SIZE (snd_emu1010b_output_texts)); + +static const unsigned short emu1010b_output_dflt[] = { +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 , +EMU_SRC_ALICE_EMU32A +2 ,EMU_SRC_ALICE_EMU32A +3 , +EMU_SRC_ALICE_EMU32A +4 ,EMU_SRC_ALICE_EMU32A +5 , +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 , +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 ,EMU_SRC_ALICE_EMU32A +2 ,EMU_SRC_ALICE_EMU32A +3 , +EMU_SRC_ALICE_EMU32A +4 ,EMU_SRC_ALICE_EMU32A +5 ,EMU_SRC_ALICE_EMU32A +6 ,EMU_SRC_ALICE_EMU32A +7 , +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 , +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 , +EMU_SRC_ALICE_EMU32A +0 ,EMU_SRC_ALICE_EMU32A +1 ,EMU_SRC_ALICE_EMU32A +2 ,EMU_SRC_ALICE_EMU32A +3 , +EMU_SRC_ALICE_EMU32A +4 ,EMU_SRC_ALICE_EMU32A +5 ,EMU_SRC_ALICE_EMU32A +6 ,EMU_SRC_ALICE_EMU32A +7 , +}; +/* 1616(m) cardbus */ static const char *const snd_emu1616_output_texts[] = {
@@ -394,6 +464,21 @@ const struct snd_emu1010_routing_info emu1010_routing_info[] = { .in_regs = emu1010_input_dst, .n_ins = ARRAY_SIZE(emu1010_input_dst), }, + { +/* rev2 1010 */ + .src_regs = emu1010b_src_regs, + .src_texts = emu1010b_src_texts, + .n_srcs = ARRAY_SIZE(emu1010b_src_texts), + + .out_dflts = emu1010b_output_dflt, + .out_regs = emu1010b_output_dst, + .out_texts = snd_emu1010b_output_texts, + .n_outs = ARRAY_SIZE(emu1010b_output_dst), + + .in_dflts = emu1010_input_dflt, + .in_regs = emu1010_input_dst, + .n_ins = ARRAY_SIZE(emu1010_input_dst) - 6, + }, {/* 1616(m) cardbus */ .src_regs = emu1616_src_regs,
@@ -414,6 +499,8 @@ const struct snd_emu1010_routing_info emu1010_routing_info[] = {static unsigned emu1010_idx (struct snd_emu10k1 *emu) {if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1616 ) +return 2 ; +else if (emu->card_capabilities->emu_model ==EMU_MODEL_EMU1010B )return 1 ;else return 0 ;
@@ -576,17 +663,17 @@ static int add_emu1010_source_mixers(struct snd_emu10k1 *emu)static const char *const snd_emu1010_adc_pads[] = { +"ADC1 14dB PAD 0202 Capture Switch" ,"ADC1 14dB PAD Audio Dock Capture Switch" ,"ADC2 14dB PAD Audio Dock Capture Switch" ,"ADC3 14dB PAD Audio Dock Capture Switch" , -"ADC1 14dB PAD 0202 Capture Switch" , };static const unsigned short snd_emu1010_adc_pad_regs[] = { +EMU_HANA_0202_ADC_PAD1 ,EMU_HANA_DOCK_ADC_PAD1 ,EMU_HANA_DOCK_ADC_PAD2 ,EMU_HANA_DOCK_ADC_PAD3 , -EMU_HANA_0202_ADC_PAD1 , };#define snd_emu1010_adc_pads_info snd_ctl_boolean_mono_info
@@ -629,19 +716,19 @@ static const struct snd_kcontrol_new emu1010_adc_pads_ctl = {static const char *const snd_emu1010_dac_pads[] = { +"DAC1 0202 14dB PAD Playback Switch" ,"DAC1 Audio Dock 14dB PAD Playback Switch" ,"DAC2 Audio Dock 14dB PAD Playback Switch" ,"DAC3 Audio Dock 14dB PAD Playback Switch" ,"DAC4 Audio Dock 14dB PAD Playback Switch" , -"DAC1 0202 14dB PAD Playback Switch" , };static const unsigned short snd_emu1010_dac_regs[] = { +EMU_HANA_0202_DAC_PAD1 ,EMU_HANA_DOCK_DAC_PAD1 ,EMU_HANA_DOCK_DAC_PAD2 ,EMU_HANA_DOCK_DAC_PAD3 ,EMU_HANA_DOCK_DAC_PAD4 , -EMU_HANA_0202_DAC_PAD1 , };#define snd_emu1010_dac_pads_info snd_ctl_boolean_mono_info
@@ -700,10 +787,17 @@ const struct snd_emu1010_pads_info emu1010_pads_info[] = { .n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads), }, { -/* 1616(m) cardbus */ +/* rev2 1010 */ .adc_ctls = snd_emu1010_adc_pads, - .n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads) - 2, + .n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads) - 1, .dac_ctls = snd_emu1010_dac_pads, + .n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads) - 1, + }, + { +/* 1616(m) cardbus */ + .adc_ctls = snd_emu1010_adc_pads + 1, + .n_adc_ctls = ARRAY_SIZE(snd_emu1010_adc_pads) - 2, + .dac_ctls = snd_emu1010_dac_pads + 1, .n_dac_ctls = ARRAY_SIZE(snd_emu1010_dac_pads) - 2, }, };
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 9/10 ALSA: emu10k1: add explicit support for E-MU 0404
In reply to Oswald BuddenhagenUnlike the other models, this is actually a distinct card, rather than an E-MU 1010 with different "dongles". It is stereo only, and supports no ADAT (there is no trace of ADAT in the manual, switching the output mode to ADAT has no effect, and switching the input mode to ADAT just breaks input (presumably ... my only ADAT source is the card's output)).
--- include/sound/emu10k1.h | 2 + sound/pci/emu10k1/emu10k1_main.c | 20 ++++-- sound/pci/emu10k1/emumixer.c | 112 ++++++++++++++++++++++++++----- sound/pci/emu10k1/emuproc.c | 18 ++--- 4 files changed, 123 insertions(+), 29 deletions(-)
include/sound/emu10k1.h +2 -0
@@ -1610,7 +1610,9 @@ struct snd_emu_chip_details { unsigned int ca0108_chip:1; /* Audigy 2 Value */ unsigned int ca_cardbus_chip:1; /* Audigy 2 ZS Notebook */ unsigned int ca0151_chip:1; /* P16V */ + unsigned int spk20:1; /* Stereo only */ unsigned int spk71:1; /* Has 7.1 speakers */ + unsigned int no_adat:1; /* Has no ADAT, only SPDIF */ unsigned int sblive51:1; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ unsigned int spdif_bug:1; /* Has Spdif phasing bug */ unsigned int ac97_chip:2; /* Has an AC97 chip: 1 = mandatory, 2 = optional */
sound/pci/emu10k1/emu10k1_main.c +14 -6
@@ -854,9 +854,14 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)snd_emu1010_fpga_read (emu,EMU_HANA_OPTION_CARDS , ®);dev_info (emu->card->dev,"emu1010: Card options = 0x%x\n" , reg); -/* Optical -> ADAT I/O */ - emu->emu1010.optical_in =1 ;/* IN_ADAT */ - emu->emu1010.optical_out =1 ;/* OUT_ADAT */ +if (emu->card_capabilities->no_adat) { + emu->emu1010.optical_in =0 ;/* IN_SPDIF */ + emu->emu1010.optical_out =0 ;/* OUT_SPDIF */ + }else { +/* Optical -> ADAT I/O */ + emu->emu1010.optical_in =1 ;/* IN_ADAT */ + emu->emu1010.optical_out =1 ;/* OUT_ADAT */ + } tmp = (emu->emu1010.optical_in ?EMU_HANA_OPTICAL_IN_ADAT :EMU_HANA_OPTICAL_IN_SPDIF ) | (emu->emu1010.optical_out ?EMU_HANA_OPTICAL_OUT_ADAT :EMU_HANA_OPTICAL_OUT_SPDIF );snd_emu1010_fpga_write (emu,EMU_HANA_OPTICAL_TYPE , tmp);
@@ -1119,26 +1124,29 @@ static const struct snd_emu_chip_details emu_chip_details[] = { .id = "EMU0404", .emu10k2_chip = 1, .ca0108_chip = 1, - .spk71 = 1, + .spk20 = 1, + .no_adat = 1, .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 new revision *//* This is MAEM8850 "HanaLite" */ /* Supports sync daughter card. */ /* Tested by [email protected] 20-3-2007. */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102, .driver = "Audigy2", .name = "E-MU 0404 [MAEM8850]", .id = "EMU0404", .emu10k2_chip = 1, .ca0102_chip = 1, - .spk71 = 1, + .spk20 = 1, + .no_adat = 1, .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ /* EMU0404 PCIe */ /* Does NOT support sync daughter card. */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40051102, .driver = "Audigy2", .name = "E-MU 0404 PCIe [MAEM8984]", .id = "EMU0404", .emu10k2_chip = 1, .ca0108_chip = 1, - .spk71 = 1, + .spk20 = 1, + .no_adat = 1, .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 PCIe ver_03 */ {.vendor = 0x1102, .device = 0x0008, .driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]",
sound/pci/emu10k1/emumixer.c +97 -15
178 lines not on this page · raw message
sound/pci/emu10k1/emuproc.c +10 -8
@@ -229,14 +229,16 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,u32 rate;if (emu->card_capabilities->emu_model) { -snd_emu1010_fpga_read (emu,0x38 , &value); -if ((value &0x1 ) ==0 ) { -snd_emu1010_fpga_read (emu,0x2a , &value); -snd_emu1010_fpga_read (emu,0x2b , &value2); - rate =0x1770000 / (((value <<5 ) | value2)+1 ); -snd_iprintf (buffer,"ADAT Locked : %u\n" , rate); - }else { -snd_iprintf (buffer,"ADAT Unlocked\n" ); +if (!emu->card_capabilities->no_adat) { +snd_emu1010_fpga_read (emu,0x38 , &value); +if ((value &0x1 ) ==0 ) { +snd_emu1010_fpga_read (emu,0x2a , &value); +snd_emu1010_fpga_read (emu,0x2b , &value2); + rate =0x1770000 / (((value <<5 ) | value2)+1 ); +snd_iprintf (buffer,"ADAT Locked : %u\n" , rate); + }else { +snd_iprintf (buffer,"ADAT Unlocked\n" ); + } }snd_emu1010_fpga_read (emu,0x20 , &value);if ((value &0x4 ) ==0 ) {
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 10/10 ALSA: emu10k1: make struct snd_emu1010 less wasteful
In reply to Oswald BuddenhagenShrink the {in,out}put_source arrays and their data type to what is actually necessary.
To be still on the safe side, add some static asserts.
--- include/sound/emu10k1.h | 7 +++++-- sound/pci/emu10k1/emumixer.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-)
include/sound/emu10k1.h +5 -2
@@ -1626,9 +1626,12 @@ struct snd_emu_chip_details {const char *id;/* for backward compatibility - can be NULL if not needed */ }; +#define NUM_OUTPUT_DESTS 28 +#define NUM_INPUT_DESTS 22 +struct snd_emu1010 { -unsigned int output_source[64 ]; -unsigned int input_source[64 ]; +unsigned char output_source[NUM_OUTPUT_DESTS ]; +unsigned char input_source[NUM_INPUT_DESTS ];unsigned int adc_pads;/* bit mask */ unsigned int dac_pads;/* bit mask */ unsigned int internal_clock;/* 44100 or 48000 */
sound/pci/emu10k1/emumixer.c +5 -0
@@ -273,6 +273,7 @@ static const char * const emu1010_output_texts[] = {LR_CTLS ("1010 SPDIF" ),ADAT_CTLS ("1010 " ), }; +static_assert (ARRAY_SIZE (emu1010_output_texts) <=NUM_OUTPUT_DESTS );static const unsigned short emu1010_output_dst[] = { LR_REGS(EMU_DST_DOCK_DAC1),
@@ -313,6 +314,7 @@ static const char * const snd_emu1010b_output_texts[] = {LR_CTLS ("1010 SPDIF" ),ADAT_CTLS ("1010 " ), }; +static_assert (ARRAY_SIZE (snd_emu1010b_output_texts) <=NUM_OUTPUT_DESTS );static const unsigned short emu1010b_output_dst[] = { LR_REGS(EMU_DST_DOCK_DAC1),
@@ -349,6 +351,7 @@ static const char * const snd_emu1616_output_texts[] = {ADAT_CTLS ("Dock " ),LR_CTLS ("Mana DAC" ), }; +static_assert (ARRAY_SIZE (snd_emu1616_output_texts) <=NUM_OUTPUT_DESTS );static const unsigned short emu1616_output_dst[] = { LR_REGS(EMU_DST_DOCK_DAC1),
@@ -377,6 +380,7 @@ static const char * const snd_emu0404_output_texts[] = {LR_CTLS ("DAC" ),LR_CTLS ("SPDIF" ), }; +static_assert (ARRAY_SIZE (snd_emu0404_output_texts) <=NUM_OUTPUT_DESTS );static const unsigned short emu0404_output_dst[] = { LR_REGS(EMU_DST_HAMOA_DAC),
@@ -421,6 +425,7 @@ static const char * const emu1010_input_texts[] = {"DSP 14 Capture Enum" ,"DSP 15 Capture Enum" , }; +static_assert (ARRAY_SIZE (emu1010_input_texts) <=NUM_INPUT_DESTS );static const unsigned short emu1010_input_dst[] = { EMU_DST_ALICE2_EMU32_0,
Signature · 1 line
2.40.0.152.g15d061e6df
Takashi Iwai
AppliedQuoted 13 lines · Oswald Buddenhagen
Oswald Buddenhagen (10):
ALSA: emu10k1: make some initializer arrays less wasteful
ALSA: emu10k1: compactize E-MU routing source arrays
ALSA: emu10k1: make mixer control mass creation less wasteful
ALSA: emu10k1: un-hardcode E-MU mixer control callbacks somewhat
ALSA: emu10k1: fix return value ofsnd_emu1010_dac_pads_put()
ALSA: emu10k1: make E-MU I/O routing init data-driven
ALSA: emu10k1: make E-MU mixer control creation more data-driven
ALSA: emu10k1: improve mixer controls for E-MU 1010 rev2 card
ALSA: emu10k1: add explicit support for E-MU 0404
ALSA: emu10k1: make structsnd_emu1010less wasteful
Applied all 10 patches. Thanks.
Takashi