Skip to content

Commit a869057

Browse files
ossilatortiwai
authored andcommitted
ALSA: emu10k1: comment updates
Move comments to better locations, de-duplicate, fix/remove incorrect/ outdated ones, add new ones, and unify spacing somewhat. While at it, also add testing credits for Jonathan Dowland (SB Live! Platinum) and myself (E-MU 0404b). Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230422161021.1143903-2-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 6fb861b commit a869057

10 files changed

Lines changed: 312 additions & 340 deletions

File tree

include/sound/emu10k1.h

Lines changed: 240 additions & 264 deletions
Large diffs are not rendered by default.

include/uapi/sound/emu10k1.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
#define CC_REG_NONZERO C_00000100
112112

113113
/* FX buses */
114+
// These are arbitrary mappings; our DSP code simply expects
115+
// the config files to route the channels this way.
116+
// The numbers are documented in {audigy,sb-live}-mixer.rst.
114117
#define FXBUS_PCM_LEFT 0x00
115118
#define FXBUS_PCM_RIGHT 0x01
116119
#define FXBUS_PCM_LEFT_REAR 0x02

sound/pci/emu10k1/emu10k1.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,6 @@ static const struct pci_device_id snd_emu10k1_ids[] = {
6868
{ 0, }
6969
};
7070

71-
/*
72-
* Audigy 2 Value notes:
73-
* A_IOCFG Input (GPIO)
74-
* 0x400 = Front analog jack plugged in. (Green socket)
75-
* 0x1000 = Read analog jack plugged in. (Black socket)
76-
* 0x2000 = Center/LFE analog jack plugged in. (Orange socket)
77-
* A_IOCFG Output (GPIO)
78-
* 0x60 = Sound out of front Left.
79-
* Win sets it to 0xXX61
80-
*/
81-
8271
MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids);
8372

8473
static int snd_card_emu10k1_probe(struct pci_dev *pci,

sound/pci/emu10k1/emu10k1_main.c

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir)
162162
outl(0, emu->port + INTE);
163163
snd_emu10k1_ptr_write(emu, CLIEL, 0, 0);
164164
snd_emu10k1_ptr_write(emu, CLIEH, 0, 0);
165+
166+
/* disable stop on loop end */
165167
snd_emu10k1_ptr_write(emu, SOLEL, 0, 0);
166168
snd_emu10k1_ptr_write(emu, SOLEH, 0, 0);
167169

@@ -660,13 +662,14 @@ static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu,
660662
return -EIO;
661663

662664
/* The FPGA is a Xilinx Spartan IIE XC2S50E */
665+
/* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */
663666
/* GPIO7 -> FPGA PGMN
664667
* GPIO6 -> FPGA CCLK
665668
* GPIO5 -> FPGA DIN
666669
* FPGA CONFIG OFF -> FPGA PGMN
667670
*/
668671
spin_lock_irqsave(&emu->emu_lock, flags);
669-
outw(0x00, emu->port + A_GPIO); /* Set PGMN low for 1uS. */
672+
outw(0x00, emu->port + A_GPIO); /* Set PGMN low for 100uS. */
670673
write_post = inw(emu->port + A_GPIO);
671674
udelay(100);
672675
outw(0x80, emu->port + A_GPIO); /* Leave bit 7 set during netlist setup. */
@@ -782,7 +785,7 @@ static void emu1010_firmware_work(struct work_struct *work)
782785
} else if (!reg && emu->emu1010.last_reg) {
783786
/* Audio Dock removed */
784787
dev_info(emu->card->dev, "emu1010: Audio Dock detached\n");
785-
/* Unmute all */
788+
/* The hardware auto-mutes all, so we unmute again */
786789
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
787790
}
788791

@@ -794,29 +797,6 @@ static void emu1010_firmware_work(struct work_struct *work)
794797
}
795798

796799
/*
797-
* EMU-1010 - details found out from this driver, official MS Win drivers,
798-
* testing the card:
799-
*
800-
* Audigy2 (aka Alice2):
801-
* ---------------------
802-
* * communication over PCI
803-
* * conversion of 32-bit data coming over EMU32 links from HANA FPGA
804-
* to 2 x 16-bit, using internal DSP instructions
805-
* * slave mode, clock supplied by HANA
806-
* * linked to HANA using:
807-
* 32 x 32-bit serial EMU32 output channels
808-
* 16 x EMU32 input channels
809-
* (?) x I2S I/O channels (?)
810-
*
811-
* FPGA (aka HANA):
812-
* ---------------
813-
* * provides all (?) physical inputs and outputs of the card
814-
* (ADC, DAC, SPDIF I/O, ADAT I/O, etc.)
815-
* * provides clock signal for the card and Alice2
816-
* * two crystals - for 44.1kHz and 48kHz multiples
817-
* * provides internal routing of signal sources to signal destinations
818-
* * inputs/outputs to Alice2 - see above
819-
*
820800
* Current status of the driver:
821801
* ----------------------------
822802
* * only 44.1/48kHz supported (the MS Win driver supports up to 192 kHz)
@@ -884,11 +864,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
884864
snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
885865
dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
886866
/* Optical -> ADAT I/O */
887-
/* 0 : SPDIF
888-
* 1 : ADAT
889-
*/
890867
emu->emu1010.optical_in = 1; /* IN_ADAT */
891-
emu->emu1010.optical_out = 1; /* IN_ADAT */
868+
emu->emu1010.optical_out = 1; /* OUT_ADAT */
892869
tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) |
893870
(emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0);
894871
snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp);
@@ -1279,6 +1256,15 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
12791256
* AC97: STAC9750
12801257
* CA0151: None
12811258
*/
1259+
/*
1260+
* A_IOCFG Input (GPIO)
1261+
* 0x400 = Front analog jack plugged in. (Green socket)
1262+
* 0x1000 = Rear analog jack plugged in. (Black socket)
1263+
* 0x2000 = Center/LFE analog jack plugged in. (Orange socket)
1264+
* A_IOCFG Output (GPIO)
1265+
* 0x60 = Sound out of front Left.
1266+
* Win sets it to 0xXX61
1267+
*/
12821268
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
12831269
.driver = "Audigy2", .name = "SB Audigy 2 Value [SB0400]",
12841270
.id = "Audigy2",
@@ -1327,6 +1313,9 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
13271313
.spi_dac = 1,
13281314
.i2c_adc = 1,
13291315
.spk71 = 1} ,
1316+
/* This is MAEM8950 "Mana" */
1317+
/* Attach MicroDock[M] to make it an E-MU 1616[m]. */
1318+
/* Does NOT support sync daughter card (obviously). */
13301319
/* Tested by James@superbug.co.uk 4th Nov 2007. */
13311320
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
13321321
.driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
@@ -1337,7 +1326,10 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
13371326
.spk71 = 1 ,
13381327
.emu_model = EMU_MODEL_EMU1616},
13391328
/* Tested by James@superbug.co.uk 4th Nov 2007. */
1340-
/* This is MAEM8960, 0202 is MAEM 8980 */
1329+
/* This is MAEM8960 "Hana3", 0202 is MAEM8980 */
1330+
/* Attach 0202 daughter card to make it an E-MU 1212m, OR a
1331+
* MicroDock[M] to make it an E-MU 1616[m]. */
1332+
/* Does NOT support sync daughter card. */
13411333
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
13421334
.driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM8960]",
13431335
.id = "EMU1010",
@@ -1347,6 +1339,11 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
13471339
.emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */
13481340
/* Tested by Maxim Kachur <mcdebugger@duganet.ru> 17th Oct 2012. */
13491341
/* This is MAEM8986, 0202 is MAEM8980 */
1342+
/* Attach 0202 daughter card to make it an E-MU 1212m, OR a
1343+
* MicroDockM to make it an E-MU 1616m. The non-m
1344+
* version was never sold with this card, but should
1345+
* still work. */
1346+
/* Does NOT support sync daughter card. */
13501347
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40071102,
13511348
.driver = "Audigy2", .name = "E-mu 1010 PCIe [MAEM8986]",
13521349
.id = "EMU1010",
@@ -1355,22 +1352,29 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
13551352
.spk71 = 1,
13561353
.emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 PCIe */
13571354
/* Tested by James@superbug.co.uk 8th July 2005. */
1358-
/* This is MAEM8810, 0202 is MAEM8820 */
1355+
/* This is MAEM8810 "Hana", 0202 is MAEM8820 "Hamoa" */
1356+
/* Attach 0202 daughter card to make it an E-MU 1212m, OR an
1357+
* AudioDock[M] to make it an E-MU 1820[m]. */
1358+
/* Supports sync daughter card. */
13591359
{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
13601360
.driver = "Audigy2", .name = "E-mu 1010 [MAEM8810]",
13611361
.id = "EMU1010",
13621362
.emu10k2_chip = 1,
13631363
.ca0102_chip = 1,
13641364
.spk71 = 1,
13651365
.emu_model = EMU_MODEL_EMU1010}, /* EMU 1010 old revision */
1366-
/* EMU0404b */
1366+
/* This is MAEM8852 "HanaLiteLite" */
1367+
/* Supports sync daughter card. */
1368+
/* Tested by oswald.buddenhagen@gmx.de Mar 2023. */
13671369
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102,
13681370
.driver = "Audigy2", .name = "E-mu 0404b PCI [MAEM8852]",
13691371
.id = "EMU0404",
13701372
.emu10k2_chip = 1,
13711373
.ca0108_chip = 1,
13721374
.spk71 = 1,
13731375
.emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 new revision */
1376+
/* This is MAEM8850 "HanaLite" */
1377+
/* Supports sync daughter card. */
13741378
/* Tested by James@superbug.co.uk 20-3-2007. */
13751379
{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102,
13761380
.driver = "Audigy2", .name = "E-mu 0404 [MAEM8850]",
@@ -1380,14 +1384,14 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
13801384
.spk71 = 1,
13811385
.emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */
13821386
/* EMU0404 PCIe */
1387+
/* Does NOT support sync daughter card. */
13831388
{.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40051102,
13841389
.driver = "Audigy2", .name = "E-mu 0404 PCIe [MAEM8984]",
13851390
.id = "EMU0404",
13861391
.emu10k2_chip = 1,
13871392
.ca0108_chip = 1,
13881393
.spk71 = 1,
13891394
.emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 PCIe ver_03 */
1390-
/* Note that all E-mu cards require kernel 2.6 or newer. */
13911395
{.vendor = 0x1102, .device = 0x0008,
13921396
.driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]",
13931397
.id = "Audigy2",
@@ -1468,6 +1472,8 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
14681472
.spdif_bug = 1,
14691473
.adc_1361t = 1, /* 24 bit capture instead of 16bit */
14701474
.ac97_chip = 1} ,
1475+
/* Audigy 2 Platinum EX */
1476+
/* Win driver sets A_IOCFG output to 0x1c00 */
14711477
{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
14721478
.driver = "Audigy2", .name = "Audigy 2 Platinum EX [SB0280]",
14731479
.id = "Audigy2",
@@ -1488,6 +1494,8 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
14881494
.spdif_bug = 1,
14891495
.invert_shared_spdif = 1, /* digital/analog switch swapped */
14901496
.ac97_chip = 1} ,
1497+
/* Audigy 2 Platinum */
1498+
/* Win driver sets A_IOCFG output to 0xa00 */
14911499
{.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
14921500
.driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]",
14931501
.id = "Audigy2",
@@ -1593,6 +1601,9 @@ static const struct snd_emu_chip_details emu_chip_details[] = {
15931601
.emu10k1_chip = 1,
15941602
.ac97_chip = 1,
15951603
.sblive51 = 1} ,
1604+
/* SB Live! Platinum */
1605+
/* Win driver sets A_IOCFG output to 0 */
1606+
/* Tested by Jonathan Dowland <jon@dow.land> Apr 2023. */
15961607
{.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
15971608
.driver = "EMU10K1", .name = "SB Live! Platinum [CT4760P]",
15981609
.id = "Live",

sound/pci/emu10k1/emufx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,8 @@ snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl
11871187
}
11881188

11891189
/*
1190-
* Used for emu1010 - conversion from 32-bit capture inputs from HANA
1191-
* to 2 x 16-bit registers in audigy - their values are read via DMA.
1190+
* Used for emu1010 - conversion from 32-bit capture inputs from the FPGA
1191+
* to 2 x 16-bit registers in Audigy - their values are read via DMA.
11921192
* Conversion is performed by Audigy DSP instructions of FX8010.
11931193
*/
11941194
static int snd_emu10k1_audigy_dsp_convert_32_to_2x16(
@@ -1330,8 +1330,9 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
13301330
#define A_ADD_VOLUME_IN(var,vol,input) \
13311331
A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
13321332

1333-
/* emu1212 DSP 0 and DSP 1 Capture */
13341333
if (emu->card_capabilities->emu_model) {
1334+
/* EMU1010 DSP 0 and DSP 1 Capture */
1335+
// The 24 MSB hold the actual value. We implicitly discard the 16 LSB.
13351336
if (emu->card_capabilities->ca0108_chip) {
13361337
/* Note:JCD:No longer bit shift lower 16bits to upper 16bits of 32bit value. */
13371338
A_OP(icode, &ptr, iMACINT0, A_GPR(tmp), A_C_00000000, A3_EMU32IN(0x0), A_C_00000001);
@@ -1636,8 +1637,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
16361637
#endif
16371638

16381639
if (emu->card_capabilities->emu_model) {
1640+
/* Capture 16 channels of S32_LE sound. */
16391641
if (emu->card_capabilities->ca0108_chip) {
16401642
dev_info(emu->card->dev, "EMU2 inputs on\n");
1643+
/* Note that the Tina[2] DSPs have 16 more EMU32 inputs which we don't use. */
1644+
16411645
for (z = 0; z < 0x10; z++) {
16421646
snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp,
16431647
bit_shifter16,
@@ -1646,7 +1650,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
16461650
}
16471651
} else {
16481652
dev_info(emu->card->dev, "EMU inputs on\n");
1649-
/* Capture 16 (originally 8) channels of S32_LE sound */
1653+
/* Note that the Alice2 DSPs have 6 I2S inputs which we don't use. */
16501654

16511655
/*
16521656
dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n",

sound/pci/emu10k1/emumixer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static const unsigned int emu1616_output_dst[] = {
346346
};
347347

348348
/*
349-
* Data destinations - HANA outputs going to Alice2 (audigy) for
349+
* Data destinations - FPGA outputs going to Alice2 (Audigy) for
350350
* capture (EMU32 + I2S links)
351351
* Each destination has an enum mixer control to choose a data source
352352
*/
@@ -367,6 +367,7 @@ static const unsigned int emu1010_input_dst[] = {
367367
EMU_DST_ALICE2_EMU32_D,
368368
EMU_DST_ALICE2_EMU32_E,
369369
EMU_DST_ALICE2_EMU32_F,
370+
/* These exist only on rev1 EMU1010 cards. */
370371
EMU_DST_ALICE_I2S0_LEFT,
371372
EMU_DST_ALICE_I2S0_RIGHT,
372373
EMU_DST_ALICE_I2S1_LEFT,
@@ -708,7 +709,7 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
708709
/* 44100 */
709710
/* Mute all */
710711
snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_MUTE );
711-
/* Default fallback clock 48kHz */
712+
/* Default fallback clock 44.1kHz */
712713
snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, EMU_HANA_DEFCLOCK_44_1K );
713714
/* Word Clock source, Internal 44.1kHz x1 */
714715
snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK,

sound/pci/emu10k1/emupcm.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
326326
} else
327327
snd_emu10k1_ptr_write(emu, FXRT, voice,
328328
snd_emu10k1_compose_send_routing(send_routing));
329-
/* Stop CA */
330329
/* Assumption that PT is already 0 so no harm overwriting */
331330
snd_emu10k1_ptr_write(emu, PTRX, voice, (send_amount[0] << 8) | send_amount[1]);
332331
snd_emu10k1_ptr_write(emu, DSL, voice, end_addr | (send_amount[3] << 24));
@@ -480,9 +479,6 @@ static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream)
480479
start_addr = epcm->start_addr;
481480
end_addr = epcm->start_addr + snd_pcm_lib_buffer_bytes(substream);
482481

483-
/*
484-
* the kX driver leaves some space between voices
485-
*/
486482
channel_size = ( end_addr - start_addr ) / NUM_EFX_PLAYBACK;
487483

488484
snd_emu10k1_pcm_init_voice(emu, 1, 1, epcm->extra,
@@ -1218,9 +1214,7 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
12181214
runtime->hw.rate_min = runtime->hw.rate_max = 48000;
12191215
spin_lock_irq(&emu->reg_lock);
12201216
if (emu->card_capabilities->emu_model) {
1221-
/* Nb. of channels has been increased to 16 */
12221217
/* TODO
1223-
* SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE
12241218
* SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
12251219
* SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
12261220
* SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000
@@ -1231,13 +1225,14 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream)
12311225
* Need to add mixer control to fix sample rate
12321226
*
12331227
* There are 32 mono channels of 16bits each.
1234-
* 24bit Audio uses 2x channels over 16bit
1235-
* 96kHz uses 2x channels over 48kHz
1236-
* 192kHz uses 4x channels over 48kHz
1237-
* So, for 48kHz 24bit, one has 16 channels
1238-
* for 96kHz 24bit, one has 8 channels
1239-
* for 192kHz 24bit, one has 4 channels
1240-
*
1228+
* 24bit Audio uses 2x channels over 16bit,
1229+
* 96kHz uses 2x channels over 48kHz,
1230+
* 192kHz uses 4x channels over 48kHz.
1231+
* So, for 48kHz 24bit, one has 16 channels,
1232+
* for 96kHz 24bit, one has 8 channels,
1233+
* for 192kHz 24bit, one has 4 channels.
1234+
* 1010rev2 and 1616(m) cards have double that,
1235+
* but we don't exceed 16 channels anyway.
12411236
*/
12421237
#if 1
12431238
switch (emu->emu1010.internal_clock) {
@@ -1459,11 +1454,12 @@ static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol *kcontrol, st
14591454
nval[idx / 32] |= 1 << (idx % 32);
14601455
bits++;
14611456
}
1462-
1457+
1458+
// Check that the number of requested channels is a power of two
1459+
// not bigger than the number of available channels.
14631460
for (idx = 0; idx < nefxb; idx++)
14641461
if (1 << idx == bits)
14651462
break;
1466-
14671463
if (idx >= nefxb)
14681464
return -EINVAL;
14691465

0 commit comments

Comments
 (0)