ALSA: emu10k1: add support for high-bitrate modes of E-MU cards
v2 cover ALSA: emu10k1: add support for high-bitrate modes of E-MU cards
This series is what all the work was about: support the "dual-/quad-pumped" modes of the E-MU cards.
Oswald Buddenhagen (8):
ALSA: emu10k1: introduce alternative E-MU D.A.S. mode
ALSA: emu10k1: improve mixer control naming in E-MU D.A.S. mode
ALSA: emu10k1: set the "no filtering" bits on PCM voices
ALSA: emu10k1: make playback in E-MU D.A.S. mode 32-bit
ALSA: add snd_ctl_add_locked()
ALSA: emu10k1: add support for 2x/4x word clocks in E-MU D.A.S. mode
ALSA: emu10k1: add high-rate capture in E-MU D.A.S. mode
ALSA: emu10k1: add high-rate playback in E-MU D.A.S. mode
include/sound/control.h | 1 + include/sound/emu10k1.h | 11 + sound/core/control.c | 31 ++ sound/pci/emu10k1/emu10k1.c | 29 +- sound/pci/emu10k1/emu10k1_main.c | 19 +- sound/pci/emu10k1/emufx.c | 109 +++- sound/pci/emu10k1/emumixer.c | 901 +++++++++++++++++++++++++++---- sound/pci/emu10k1/emupcm.c | 422 +++++++++++++-- sound/pci/emu10k1/emuproc.c | 5 + sound/pci/emu10k1/io.c | 30 +- sound/pci/emu10k1/voice.c | 6 + 11 files changed, 1383 insertions(+), 181 deletions(-)
Range-diff against v1:
1: c8c1fbba5e52 = 1: 7cb49147164f ALSA: emu10k1: introduce alternative E-MU D.A.S. mode 2: 879066428bee = 2: aa9ead00e045 ALSA: emu10k1: improve mixer control naming in E-MU D.A.S. mode 3: b663229a0f46 = 3: ac830e67322f ALSA: emu10k1: set the "no filtering" bits on PCM voices 4: a9de9a73571e = 4: 26e0b7c02c1d ALSA: emu10k1: make playback in E-MU D.A.S. mode 32-bit 5: 0f1950b03193 ! 5: 94b64e6c123d ALSA: add snd_ctl_add_locked()
@@ Commit message
This is in fact more symmetrical to snd_ctl_remove() than snd_ctl_add() is - the former could be named snd_ctl_remove_locked() just as well.
+ One may argue that this is going in the wrong direction, as drivers have
+ no business managing the lock. This may be true in principle, but in
+ practice the vast majority of controls is created even before the device
+ was registered, and therefore before any locking is necessary at all.
+ That means that an even more radical approach of changing snd_ctl_add()
+ do do no locking, and converting the call sites that actually need
+ locking to a new function, would better match reality, and would be
+ somewhat more efficient at that. However, that seems a bit risky and way
+ too much work.
+
This will be used to dynamically change the available controls from another control's put() callback, which is already locked.
One might want to add snd_ctl_replace_locked() for completeness, but I have no use for it now.
+ ---
+ v2:
+ - extended commit message
## include/sound/control.h ##
@@ include/sound/control.h: void snd_ctl_notify_one(struct snd_card * card, unsigned int mask, struct snd_kc
6: 511efe4ac7ad ! 6: 7bc314bae7f2 ALSA: emu10k1: add support for 2x/4x word clocks in E-MU D.A.S. mode
@@ Commit message
on playback, and throw away the excess ones on capture. Input-to-output
monitoring does actually use the full sample rate, though.
- Notably, add_ctls() now uses snd_ctl_add_locked(), so it doesn't
- deadlock when called from snd_emu1010_clock_shift_put(). This also
- affects the initial creation of the controls, which is OK, as that is
- done before the card is registered, so no concurrent access can occur.
+ Due to hardware constraints, changing the clock multiplier (CM) changes
+ the available audio ports and the number of available channels. This has
+ an impact on the channel routing mixer controls. One way to deal with
+ this would be presenting a union of all possibilities, and simply
+ ignoring currently inapplicable settings. However, this would be a
+ terrible user experience, and go against the spirit of prior patches
+ aimed at decluttering the mixer. Therefore, we do dynamic
+ reconfiguration (DR) of the mixer in response to changing the CM.
+
+ DR is somewhat controversial, as it has the potential to crash poorly
+ programmed applications. But that in itself isn't a very convincing
+ argument against it, as by that logic we'd have to ban all hot-plugging.
+ Such crashes would also not really qualify as regressions, as the D.A.S.
+ mode is a new opt-in feature, and therefore no previously stable setups
+ would be impacted. Also, pendantically, the driver already had DR via
+ SNDRV_EMU10K1_IOCTL_CODE_POKE. A somewhat valid concern is that changing
+ mixer settings is a non-privileged operation and therefore potential
+ crashes could be exploited for a somewhat more impactful nuisance attack
+ on another user than messing with the mixer per se. However, systemd &
+ co. limit device access to the user currently logged in on the seat
+ owning the device.
+
+ There is a specific concern about doing DR in response to changing a
+ mixer control's value, as an application may legitimately react to DR by
+ updating all mixer settings in turn. However, that update should write
+ the same value to the clock multiplier, thus terminating the recursion.
+
+ One may limit DR to merely disabling inapplicable controls, in the hope
+ that this would be better handled than completely tearing down and
+ re-creating controls as we do. However, there is no guarantee for that.
+ And because it is impossible to disable particular enum values within a
+ control, it would be necessary to have three complete sets of
+ per-channel controls. This would yield an extremely cluttered and
+ confusing UI if the application (reasonably) chose to merely visually
+ disable inactive controls rather than hiding them.
+
+ We do the DR synchronously from within snd_emu1010_clock_shift_put().
+ This was enabled by commit 5bbb1ab5bd ("control: use counting semaphore
+ as write lock for ELEM_WRITE operation"); we merely need to make
+ add_ctls() use snd_ctl_add_locked() instead of snd_ctl_add(), so it
+ doesn't deadlock. That also affects the initial creation of the
+ controls, which is OK, as that is done before the card is registered, so
+ no concurrent access can occur.
+
+ It would be possible to do the DR in a tasklet after the ioctl finishes.
+ However, it is not obvious what actual problem that would solve, and the
+ added asynchronicity would significantly complicate matters, esp. wrt.
+ the batch updates expected during mixer state restoration.
+ ---
+ v2:
+ - expanded commit message
## include/sound/emu10k1.h ##
@@ include/sound/emu10k1.h: struct snd_emu1010 {
7: d5cb50ca707f = 7: 72a156fb32cd ALSA: emu10k1: add high-rate capture in E-MU D.A.S. mode
8: 319425a4ccb6 ! 8: 6d35891832b3 ALSA: emu10k1: add high-rate playback in E-MU D.A.S. mode
@@ Commit message
d948035a92 ("Remove PCM xfer_align sw params").
Signed-off-by: Oswald Buddenhagen <[email protected]>
+ ---
+ v2:
+ - fixed `sparse` warning re missing __user annotation
## sound/pci/emu10k1/emufx.c ##
@@ sound/pci/emu10k1/emufx.c: static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu)
@@ sound/pci/emu10k1/emupcm.c: static int snd_emu10k1_efx_playback_trigger(struct s
+ for (i = 0; i < channels; i++) {
+ for (j = 0; j < subchans; j++) {
+ u32 *dst = get_dma_ptr_x(runtime, shift, i, j, hwoff);
-+ u32 *src = (u32 *)buf + j * channels + i;
++ u32 __user *src = (u32 __user *)buf + j * channels + i;
+ for (k = 0; k < frames; k++, dst++, src += voices)
+ unsafe_get_user(*dst, src, faulted);
+ }Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 1/8 ALSA: emu10k1: introduce alternative E-MU D.A.S. mode
As noted in a previous commit, the E-MU Digital Audio System cards don't try very hard to be Sound Blasters. This commit takes it further and introduces a module option to switch to a completely separate mode.
In that mode:
- The regular PCM playback/capture devices are removed
- The EFX playback/capture devices get index 0
- Consequently, the regular mixer controls are also completely removed. This is no real loss, given the expected use with a sound server.
- The voice send routing+amount & attenuation controls are also removed, as they are just another mixer. The routing is redundant with the FPGA channel routing, and amounts/att'n can be done in software. The latter are also incompatible with 32-bit playback, which we'll add support for later.
- A_EXTOUT is now also free for multi-channel capture, so we use that instead of A_FXBUS2 - this will later simplify using both at once.
- For the same reason, the FX outputs are not listed in /proc anymore
- The device name is changed, so mixer settings don't get mixed up
This continues the pre-existing design with a single multi-channel device where the channels are routed by manual mixer controls from/to the physical ports. De-/multiplexing must be done by the sound server if independent streams are to be used.
An alternative design would be exposing each physical port as a separate device and automatically setting up the routes. This would be a somewhat radical departure from the status quo, and I don't know whether it would be a net benefit. It certainly would be harder to implement, as it would require sync start of streams and a channel allocator (the latter would have the added benefit of properly reporting EMU32 & EDI bus over- allocation, which the mixer does not). There is only one big multi- channel capture engine, so streams would have to be de-multiplexed by the driver in software - which seems a bit counter-productive if the sound server would re-multiplex them again.
--- include/sound/emu10k1.h | 4 ++ sound/pci/emu10k1/emu10k1.c | 29 ++++++--- sound/pci/emu10k1/emu10k1_main.c | 14 +++- sound/pci/emu10k1/emufx.c | 94 ++++++++++++++++++++++++++- sound/pci/emu10k1/emumixer.c | 93 ++++++++++++++------------- sound/pci/emu10k1/emupcm.c | 107 +++++++++++++++++++++++++++---- sound/pci/emu10k1/emuproc.c | 5 ++ 7 files changed, 280 insertions(+), 66 deletions(-)
include/sound/emu10k1.h +4 -0
@@ -1700,6 +1700,7 @@ struct snd_emu10k1 {unsigned int address_mode;/* address mode */ unsigned long dma_mask;/* PCI DMA mask */ bool iommu_workaround;/* IOMMU workaround needed */ +bool das_mode;/* Alternative E-MU Digital Audio System mode */ int max_cache_pages;/* max memory size / PAGE_SIZE */ struct snd_dma_buffer silent_page;/* silent page */ struct snd_dma_buffer ptb_pages;/* page table pages */
@@ -1729,6 +1730,7 @@ struct snd_emu10k1 {struct snd_pcm *pcm_mic;struct snd_pcm *pcm_efx;struct snd_pcm *pcm_multi; +struct snd_pcm *pcm_das;struct snd_pcm *pcm_p16v;spinlock_t synth_lock;
@@ -1793,17 +1795,19 @@ struct snd_emu10k1 {int snd_emu10k1_create (struct snd_card *card,struct pci_dev *pci, +bool emu_das,unsigned short extin_mask,unsigned short extout_mask,long max_cache_bytes,int enable_ir,uint subsystem);int snd_emu10k1_pcm (struct snd_emu10k1 *emu,int device);int snd_emu10k1_pcm_mic (struct snd_emu10k1 *emu,int device);int snd_emu10k1_pcm_efx (struct snd_emu10k1 *emu,int device);int snd_p16v_pcm (struct snd_emu10k1 *emu,int device);int snd_p16v_mixer (struct snd_emu10k1 * emu); +int snd_emu10k1_pcm_das (struct snd_emu10k1 *emu,int device);int snd_emu10k1_pcm_multi (struct snd_emu10k1 *emu,int device);int snd_emu10k1_fx8010_pcm (struct snd_emu10k1 *emu,int device);int snd_emu10k1_mixer (struct snd_emu10k1 * emu,int pcm_device,int multi_device);
sound/pci/emu10k1/emu10k1.c +20 -9
@@ -27,6 +27,7 @@ MODULE_LICENSE("GPL");static int index[SNDRV_CARDS ] =SNDRV_DEFAULT_IDX ;/* Index 0-MAX */ static char *id[SNDRV_CARDS ] =SNDRV_DEFAULT_STR ;/* ID for this card */ static bool enable[SNDRV_CARDS ] =SNDRV_DEFAULT_ENABLE_PNP ;/* Enable this card */ +static bool emu_das[SNDRV_CARDS ];static int extin[SNDRV_CARDS ];static int extout[SNDRV_CARDS ];static int seq_ports[SNDRV_CARDS ] = {[0 ... (SNDRV_CARDS -1 )] =4 };
@@ -41,6 +42,8 @@ module_param_array(id, charp, NULL, 0444);MODULE_PARM_DESC (id,"ID string for the EMU10K1 soundcard." );module_param_array (enable, bool,NULL ,0444 );MODULE_PARM_DESC (enable,"Enable the EMU10K1 soundcard." ); +module_param_array (emu_das, bool,NULL ,0444 ); +MODULE_PARM_DESC (emu_das,"Use alternative E-MU Digital Audio System mode." );module_param_array (extin, int,NULL ,0444 );MODULE_PARM_DESC (extin,"Available external inputs for FX8010. Zero=default." );module_param_array (extout, int,NULL ,0444 );
@@ -95,22 +98,27 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, max_buffer_size[dev] =32 ; else if (max_buffer_size[dev] > 1024) max_buffer_size[dev] =1024 ; - err =snd_emu10k1_create (card, pci, extin[dev], extout[dev], + err =snd_emu10k1_create (card, pci, emu_das[dev], extin[dev], extout[dev], (long )max_buffer_size[dev] *1024 *1024 , enable_ir[dev], subsystem[dev]);if (err <0 )return err; - err =snd_emu10k1_pcm (emu,0 ); +if (emu->das_mode) + err =snd_emu10k1_pcm_das (emu,0 ); +else + err =snd_emu10k1_pcm (emu,0 );if (err <0 )return err;if (emu->card_capabilities->ac97_chip) { err =snd_emu10k1_pcm_mic (emu,1 );if (err <0 )return err; } - err =snd_emu10k1_pcm_efx (emu,2 ); -if (err <0 ) -return err; +if (!emu->das_mode) { + err =snd_emu10k1_pcm_efx (emu,2 ); +if (err <0 ) +return err; + }/* This stores the periods table. */ if (emu->card_capabilities->ca0151_chip) {/* P16V */ emu->p16v_buffer =
@@ -127,9 +135,11 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,if (err <0 )return err; - err =snd_emu10k1_pcm_multi (emu,3 ); -if (err <0 ) -return err; +if (!emu->das_mode) { + err =snd_emu10k1_pcm_multi (emu,3 ); +if (err <0 ) +return err; + }if (emu->card_capabilities->ca0151_chip) {/* P16V */ err =snd_p16v_pcm (emu,4 );if (err <0 )
@@ -148,7 +158,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,if (err <0 )return err;#ifdef ENABLE_SYNTH -if (snd_seq_device_new (card,1 ,SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH , +if (emu->das_mode) { + }else if (snd_seq_device_new (card,1 ,SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH ,sizeof (struct snd_emu10k1_synth_arg ), &wave) <0 || wave ==NULL ) { dev_warn(emu->card->dev,
sound/pci/emu10k1/emu10k1_main.c +13 -1
@@ -1482,6 +1482,7 @@ static void snd_emu10k1_detect_iommu(struct snd_emu10k1 *emu) int snd_emu10k1_create(struct snd_card *card, struct pci_dev *pci, + bool emu_das, unsigned short extin_mask, unsigned short extout_mask, long max_cache_bytes,
@@ -1560,8 +1561,19 @@ int snd_emu10k1_create(struct snd_card *card, c->name, pci->vendor, pci->device, emu->serial); -if (!*card->id && c->id) +if (c->emu_model) { +if (emu_das) + emu->das_mode =1 ; +else +dev_notice (card->dev, +"You may want to use emu_das=1 with your %s\n" , c->name); + } + +if (!*card->id && c->id) {strscpy (card->id, c->id,sizeof (card->id)); +if (emu->das_mode) +strlcat (card->id,"das" ,sizeof (card->id)); + } is_audigy = emu->audigy = c->emu10k2_chip;
sound/pci/emu10k1/emufx.c +93 -1
106 lines not on this page · raw message
sound/pci/emu10k1/emumixer.c +49 -44
100 lines not on this page · raw message
sound/pci/emu10k1/emupcm.c +96 -11
178 lines not on this page · raw message
sound/pci/emu10k1/emuproc.c +5 -0
@@ -85,6 +85,11 @@ static void snd_emu10k1_proc_read(struct snd_info_entry *entry,snd_iprintf (buffer,"Internal TRAM (words) : 0x%x\n" , emu->fx8010.itram_size);snd_iprintf (buffer,"External TRAM (words) : 0x%x\n" , (int )emu->fx8010.etram_pages.bytes /2 ); +// The following are internal details in D.A.S. mode, +// so there is no use in displaying them to the user. +if (emu->das_mode) +return ; +snd_iprintf (buffer,"\nEffect Send Routing & Amounts:\n" );for (idx =0 ; idx <NUM_G ; idx++) { ptrx =snd_emu10k1_ptr_read (emu,PTRX , idx);
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 2/8 ALSA: emu10k1: improve mixer control naming in E-MU D.A.S. mode
In reply to Oswald BuddenhagenUse the clearer "PbChn <n>" instead of "DSP <n>" for the source names. In particular, this is much less confusing in the capture source selection - "DSP 0" having the source "DSP 0" really didn't help. I didn't use "Playback Channel <n>", because that would be a tad too long to be sensibly displayed in alsamixer.
The capture enums also get a "DSP" => "CpChn" replacement.
I used zero-padded decimals, so the capture elements are properly sorted in alsamixer. I found hex too confusing.
Note that unlike in the legacy mixer, we define enum values only for actually "wired" channels.
I'm leaving the legacy mixer alone, as I don't want to completely invalidate saved mixer states. This introduces some bloat, but it seems bearable.
--- sound/pci/emu10k1/emumixer.c | 108 ++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 27 deletions(-)
sound/pci/emu10k1/emumixer.c +81 -27
@@ -106,6 +106,12 @@ static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol, "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 PB_TEXTS \ + "PbChn 00", "PbChn 01", "PbChn 02", "PbChn 03", \ + "PbChn 04", "PbChn 05", "PbChn 06", "PbChn 07", \ + "PbChn 08", "PbChn 09", "PbChn 10", "PbChn 11", \ + "PbChn 12", "PbChn 13", "PbChn 14", "PbChn 15" +#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, "")
@@ -161,6 +167,11 @@ static const char * const emu1010_src_texts[] = { DSP_TEXTS, }; +static const char *const emu1010_das_src_texts[] = { +EMU1010_COMMON_TEXTS , +PB_TEXTS , +}; +static const unsigned short emu1010_src_regs[] = {EMU_SRC_SILENCE ,PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B),
@@ -192,6 +203,11 @@ static const char * const emu1010b_src_texts[] = { DSP_TEXTS, }; +static const char *const emu1010b_das_src_texts[] = { + EMU1010b_COMMON_TEXTS, +PB_TEXTS , +}; +static const unsigned short emu1010b_src_regs[] = {EMU_SRC_SILENCE ,PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B),
@@ -221,6 +237,11 @@ static const char * const emu1616_src_texts[] = { DSP_TEXTS, }; +static const char *const emu1616_das_src_texts[] = { +EMU1616_COMMON_TEXTS , +PB_TEXTS , +}; +static const unsigned short emu1616_src_regs[] = {EMU_SRC_SILENCE ,PAIR_REGS (EMU_SRC_DOCK_MIC , _A, _B),
@@ -244,6 +265,11 @@ static const char * const emu0404_src_texts[] = { DSP_TEXTS, }; +static const char *const emu0404_das_src_texts[] = { +EMU0404_COMMON_TEXTS , +PB_TEXTS , +}; +static const unsigned short emu0404_src_regs[] = {EMU_SRC_SILENCE ,LR_REGS (EMU_SRC_HAMOA_ADC ),
@@ -427,6 +453,25 @@ static const char * const emu1010_input_texts[] = { };static_assert (ARRAY_SIZE (emu1010_input_texts) <=NUM_INPUT_DESTS ); +static const char *const emu1010_das_input_texts[] = { +"CpChn 00 Capture Enum" , +"CpChn 01 Capture Enum" , +"CpChn 02 Capture Enum" , +"CpChn 03 Capture Enum" , +"CpChn 04 Capture Enum" , +"CpChn 05 Capture Enum" , +"CpChn 06 Capture Enum" , +"CpChn 07 Capture Enum" , +"CpChn 08 Capture Enum" , +"CpChn 09 Capture Enum" , +"CpChn 10 Capture Enum" , +"CpChn 11 Capture Enum" , +"CpChn 12 Capture Enum" , +"CpChn 13 Capture Enum" , +"CpChn 14 Capture Enum" , +"CpChn 15 Capture Enum" , +}; +static const unsigned short emu1010_input_dst[] = {EMU_DST_ALICE2_EMU32_0 ,EMU_DST_ALICE2_EMU32_1 ,
@@ -504,78 +549,78 @@ static const unsigned short emu0404_input_dflt[] = { };struct snd_emu1010_routing_info { -const char *const *src_texts; +const char *const *src_texts[2 ];const char *const *out_texts;const unsigned short *src_regs;const unsigned short *out_regs;const unsigned short *in_regs;const unsigned short *out_dflts;const unsigned short *in_dflts; -unsigned n_srcs; +unsigned n_srcs[2 ];unsigned n_outs; -unsigned n_ins; +unsigned n_ins[2 ]; };static const struct snd_emu1010_routing_info emu1010_routing_info[] = { {/* rev1 1010 */ .src_regs = emu1010_src_regs, - .src_texts = emu1010_src_texts, - .n_srcs =ARRAY_SIZE (emu1010_src_texts), + .src_texts = { emu1010_src_texts, emu1010_das_src_texts }, + .n_srcs = {ARRAY_SIZE (emu1010_src_texts),ARRAY_SIZE (emu1010_das_src_texts) }, .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, .in_regs = emu1010_input_dst, - .n_ins =ARRAY_SIZE (emu1010_input_dst), + .n_ins = {ARRAY_SIZE (emu1010_input_dst),16 }, }, {/* rev2 1010 */ .src_regs = emu1010b_src_regs, - .src_texts = emu1010b_src_texts, - .n_srcs =ARRAY_SIZE (emu1010b_src_texts), + .src_texts = { emu1010b_src_texts, emu1010b_das_src_texts }, + .n_srcs = {ARRAY_SIZE (emu1010b_src_texts),ARRAY_SIZE (emu1010b_das_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 , + .n_ins = {ARRAY_SIZE (emu1010_input_dst) -6 ,16 }, }, {/* 1616(m) cardbus */ .src_regs = emu1616_src_regs, - .src_texts = emu1616_src_texts, - .n_srcs =ARRAY_SIZE (emu1616_src_texts), + .src_texts = { emu1616_src_texts, emu1616_das_src_texts }, + .n_srcs = {ARRAY_SIZE (emu1616_src_texts),ARRAY_SIZE (emu1616_das_src_texts) }, .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, .in_regs = emu1010_input_dst, - .n_ins =ARRAY_SIZE (emu1010_input_dst) -6 , + .n_ins = {ARRAY_SIZE (emu1010_input_dst) -6 ,16 }, }, {/* 0404 */ .src_regs = emu0404_src_regs, - .src_texts = emu0404_src_texts, - .n_srcs =ARRAY_SIZE (emu0404_src_texts), + .src_texts = { emu0404_src_texts, emu0404_das_src_texts }, + .n_srcs = {ARRAY_SIZE (emu0404_src_texts),ARRAY_SIZE (emu0404_das_src_texts) }, .out_dflts = emu0404_output_dflt, .out_regs = emu0404_output_dst, .out_texts = snd_emu0404_output_texts, .n_outs =ARRAY_SIZE (emu0404_output_dflt), .in_dflts = emu0404_input_dflt, .in_regs = emu1010_input_dst, - .n_ins =ARRAY_SIZE (emu1010_input_dst) -6 , + .n_ins = {ARRAY_SIZE (emu1010_input_dst) -6 ,16 }, }, };
@@ -608,32 +653,34 @@ static void snd_emu1010_apply_sources(struct snd_emu10k1 *emu) {const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx (emu)]; +unsigned iidx = emu->das_mode;for (unsigned i =0 ; i < emu_ri->n_outs; i++)snd_emu1010_output_source_apply ( emu, i, emu->emu1010.output_source[i]); -for (unsigned i =0 ; i < emu_ri->n_ins; i++) +for (unsigned i =0 ; i < emu_ri->n_ins[iidx]; i++)snd_emu1010_input_source_apply ( emu, i, emu->emu1010.input_source[i]); }static u8 emu1010_map_source (const struct snd_emu1010_routing_info *emu_ri, -unsigned val) +unsigned das_mode,unsigned val) { -for (unsigned i =0 ; i < emu_ri->n_srcs; i++) +for (unsigned i =0 ; i < emu_ri->n_srcs[das_mode]; i++)if (val == emu_ri->src_regs[i])return i;return 0 ; }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)]; +unsigned iidx = emu->das_mode; -return snd_ctl_enum_info (uinfo,1 , emu_ri->n_srcs, emu_ri->src_texts); +return snd_ctl_enum_info (uinfo,1 , emu_ri->n_srcs[iidx], emu_ri->src_texts[iidx]); } static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol,
@@ -656,11 +703,12 @@ static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol,struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol);const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx (emu)]; +unsigned iidx = emu->das_mode;unsigned val = ucontrol->value.enumerated.item[0 ];unsigned channel = kcontrol->private_value;int change; -if (val >= emu_ri->n_srcs) +if (val >= emu_ri->n_srcs[iidx])return -EINVAL ;if (channel >= emu_ri->n_outs)return -EINVAL ;
@@ -686,27 +734,29 @@ static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol,struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol);const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx (emu)]; +unsigned iidx = emu->das_mode;unsigned channel = kcontrol->private_value; -if (channel >= emu_ri->n_ins) +if (channel >= emu_ri->n_ins[iidx])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);const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx (emu)]; +unsigned iidx = emu->das_mode;unsigned val = ucontrol->value.enumerated.item[0 ];unsigned channel = kcontrol->private_value;int change; -if (val >= emu_ri->n_srcs) +if (val >= emu_ri->n_srcs[iidx])return -EINVAL ; -if (channel >= emu_ri->n_ins) +if (channel >= emu_ri->n_ins[iidx])return -EINVAL ; change = (emu->emu1010.input_source[channel] != val);if (change) {
@@ -728,14 +778,17 @@ static int add_emu1010_source_mixers(struct snd_emu10k1 *emu) {const struct snd_emu1010_routing_info *emu_ri = &emu1010_routing_info[emu1010_idx (emu)]; +unsigned iidx = emu->das_mode;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); + iidx ? emu1010_das_input_texts : + emu1010_input_texts, + emu_ri->n_ins[iidx]);return err; }
@@ -2338,13 +2391,14 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *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]; +int midx = emu->das_mode; -for (i =0 ; i < emu_ri->n_ins; i++) +for (i =0 ; i < emu_ri->n_ins[midx]; i++) emu->emu1010.input_source[i] = -emu1010_map_source (emu_ri, emu_ri->in_dflts[i]); +emu1010_map_source (emu_ri, midx, 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]); +emu1010_map_source (emu_ri, midx, emu_ri->out_dflts[i]);snd_emu1010_apply_sources (emu); err = snd_ctl_add(card,
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 3/8 ALSA: emu10k1: set the "no filtering" bits on PCM voices
In reply to Oswald Buddenhagen... on Audigy, when we are not pitch-shifting.
The only observable effect is that the Z1/Z2/FXBUS registers don't have a stray bit set for negative numbers anymore. The bit is below the ones significant for output, but it would mess with 32-bit sample recombination, which we are about to add.
kX-project does that, but I had to figure out myself why.
--- sound/pci/emu10k1/emupcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/pci/emu10k1/emupcm.c +3 -2
@@ -318,9 +318,10 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu, REGLIST_END);// Setup routing if (emu->audigy) { +u32 unfiltered = (evoice->epcm->pitch_target ==PITCH_48000 ) ?0x80808080 :0 ;snd_emu10k1_ptr_write_multiple (emu, voice, -A_FXRT1 ,snd_emu10k1_compose_audigy_fxrt1 (send_routing), -A_FXRT2 ,snd_emu10k1_compose_audigy_fxrt2 (send_routing), +A_FXRT1 ,snd_emu10k1_compose_audigy_fxrt1 (send_routing) | unfiltered, +A_FXRT2 ,snd_emu10k1_compose_audigy_fxrt2 (send_routing) | unfiltered,A_SENDAMOUNTS ,snd_emu10k1_compose_audigy_sendamounts (send_amount),REGLIST_END );for (int i =0 ; i <4 ; i++) {
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 4/8 ALSA: emu10k1: make playback in E-MU D.A.S. mode 32-bit
In reply to Oswald BuddenhagenEach channel now uses a stereo voice pair. But the FX send amounts and attenuation are per voice, so we have to use fixed values tuned to the DSP code to avoid messing up the split samples.
As "regular" mode allows manipulating the amounts and att'n via mixer controls, we can either:
- "Fake" them with DSP code, which doesn't seem worth the bother
- Ignore them, which doesn't seem very nice
So 32-bit playback simply remains unavailable in non-D.A.S. mode.
--- sound/pci/emu10k1/emufx.c | 18 ++++++++++----- sound/pci/emu10k1/emupcm.c | 46 +++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 21 deletions(-)
sound/pci/emu10k1/emufx.c +13 -5
@@ -1290,7 +1290,8 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu) {enum { ENUM_GPR(bit_shifter16, 1), - ENUM_GPR(tmp, 1), + ENUM_GPR(lowword_mask, 1), + ENUM_GPR(tmp, 2), num_static_gprs };int gpr = num_static_gprs;
@@ -1321,10 +1322,14 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu) gpr_map = icode->gpr_map; gpr_map[bit_shifter16] =0x00008000 ; + gpr_map[lowword_mask] =0x0000ffff ;if (emu->card_capabilities->ca0108_chip) { -for (int z =0 ; z <16 ; z++) -A_OP (icode, &ptr, iMACINT0,A3_EMU32OUT (z),A_C_00000000 ,A_FXBUS (z),A_C_00000002 ); +for (int z =0 ; z <16 ; z++) { +A_OP (icode, &ptr, iMAC0,A_GPR (tmp),A_C_00000000 ,A_FXBUS (z *2 ),A_C_00010000 );// >> 15 +A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +1 ),A_C_00000002 );// << 1 +A_OP (icode, &ptr, iANDXOR,A3_EMU32OUT (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 )); + }snd_emu10k1_audigy_dsp_convert_32_to_2x16 ( icode, &ptr, tmp, bit_shifter16,A3_EMU32IN (0 ),A_EXTOUT (0 ));
@@ -1337,8 +1342,11 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu) gpr_map[gpr++] =0x00000000 ; } }else { -for (int z =0 ; z <16 ; z++) -A_OP (icode, &ptr, iMACINT0,A_EMU32OUTL (z),A_C_00000000 ,A_FXBUS (z),A_C_00000002 ); +for (int z =0 ; z <16 ; z++) { +A_OP (icode, &ptr, iMAC0,A_GPR (tmp),A_C_00000000 ,A_FXBUS (z *2 ),A_C_00010000 );// >> 15 +A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +1 ),A_C_00000002 );// << 1 +A_OP (icode, &ptr, iANDXOR,A_EMU32OUTL (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 )); + }/* Note that the Alice2 DSPs have 6 I2S inputs which we don't use. */ snd_emu10k1_audigy_dsp_convert_32_to_2x16(
sound/pci/emu10k1/emupcm.c +30 -16
146 lines not on this page · raw message
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 5/8 ALSA: add snd_ctl_add_locked()
In reply to Oswald BuddenhagenThis is in fact more symmetrical to snd_ctl_remove() than snd_ctl_add() is - the former could be named snd_ctl_remove_locked() just as well.
One may argue that this is going in the wrong direction, as drivers have no business managing the lock. This may be true in principle, but in practice the vast majority of controls is created even before the device was registered, and therefore before any locking is necessary at all. That means that an even more radical approach of changing snd_ctl_add() do do no locking, and converting the call sites that actually need locking to a new function, would better match reality, and would be somewhat more efficient at that. However, that seems a bit risky and way too much work.
This will be used to dynamically change the available controls from another control's put() callback, which is already locked.
One might want to add snd_ctl_replace_locked() for completeness, but I have no use for it now.
---
v2:
- extended commit message
--- include/sound/control.h | 1 + sound/core/control.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
include/sound/control.h +1 -0
@@ -134,6 +134,7 @@ void snd_ctl_notify_one(struct snd_card * card, unsigned int mask, struct snd_kcstruct snd_kcontrol *snd_ctl_new1 (const struct snd_kcontrol_new * kcontrolnew,void * private_data);void snd_ctl_free_one (struct snd_kcontrol * kcontrol);int snd_ctl_add (struct snd_card * card,struct snd_kcontrol * kcontrol); +int snd_ctl_add_locked (struct snd_card * card,struct snd_kcontrol * kcontrol);int snd_ctl_remove (struct snd_card * card,struct snd_kcontrol * kcontrol);int snd_ctl_replace (struct snd_card *card,struct snd_kcontrol *kcontrol,bool add_on_replace);int snd_ctl_remove_id (struct snd_card * card,struct snd_ctl_elem_id *id);
sound/core/control.c +31 -0
@@ -527,6 +527,27 @@ static int snd_ctl_add_replace(struct snd_card *card,return err; } +static int snd_ctl_add_replace_locked (struct snd_card *card, +struct snd_kcontrol *kcontrol, +enum snd_ctl_add_mode mode) +{ +int err = -EINVAL ; + +if (! kcontrol) +return err; +if (snd_BUG_ON (!card || !kcontrol->info)) + goto error; + + err =__snd_ctl_add_replace (card, kcontrol, mode); +if (err <0 ) + goto error; +return 0 ; + + error: +snd_ctl_free_one (kcontrol); +return err; +} +/** * snd_ctl_add - add the control instance to the card * @card: the card instance
@@ -547,6 +568,16 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) }EXPORT_SYMBOL (snd_ctl_add); +/** +* snd_ctl_add_locked - same as snd_ctl_add(), but card->controls_rwsem +* is expected to be already locked if necessary. +*/ +int snd_ctl_add_locked (struct snd_card *card,struct snd_kcontrol *kcontrol) +{ +return snd_ctl_add_replace_locked (card, kcontrol,CTL_ADD_EXCLUSIVE ); +} +EXPORT_SYMBOL (snd_ctl_add_locked); +/** * snd_ctl_replace - replace the control instance of the card * @card: the card instance
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 6/8 ALSA: emu10k1: add support for 2x/4x word clocks in E-MU D.A.S. mode
In reply to Oswald BuddenhagenThis lays the groundwork for supporting 88.2/96/176.4/192 kHz rates without actually doing so yet - we simply multi-feed the same samples on playback, and throw away the excess ones on capture. Input-to-output monitoring does actually use the full sample rate, though.
Due to hardware constraints, changing the clock multiplier (CM) changes the available audio ports and the number of available channels. This has an impact on the channel routing mixer controls. One way to deal with this would be presenting a union of all possibilities, and simply ignoring currently inapplicable settings. However, this would be a terrible user experience, and go against the spirit of prior patches aimed at decluttering the mixer. Therefore, we do dynamic reconfiguration (DR) of the mixer in response to changing the CM.
DR is somewhat controversial, as it has the potential to crash poorly programmed applications. But that in itself isn't a very convincing argument against it, as by that logic we'd have to ban all hot-plugging. Such crashes would also not really qualify as regressions, as the D.A.S. mode is a new opt-in feature, and therefore no previously stable setups would be impacted. Also, pendantically, the driver already had DR via SNDRV_EMU10K1_IOCTL_CODE_POKE. A somewhat valid concern is that changing mixer settings is a non-privileged operation and therefore potential crashes could be exploited for a somewhat more impactful nuisance attack on another user than messing with the mixer per se. However, systemd & co. limit device access to the user currently logged in on the seat owning the device.
There is a specific concern about doing DR in response to changing a mixer control's value, as an application may legitimately react to DR by updating all mixer settings in turn. However, that update should write the same value to the clock multiplier, thus terminating the recursion.
One may limit DR to merely disabling inapplicable controls, in the hope that this would be better handled than completely tearing down and re-creating controls as we do. However, there is no guarantee for that. And because it is impossible to disable particular enum values within a control, it would be necessary to have three complete sets of per-channel controls. This would yield an extremely cluttered and confusing UI if the application (reasonably) chose to merely visually disable inactive controls rather than hiding them.
We do the DR synchronously from within snd_emu1010_clock_shift_put(). This was enabled by commit 5bbb1ab5bd ("control: use counting semaphore as write lock for ELEM_WRITE operation"); we merely need to make add_ctls() use snd_ctl_add_locked() instead of snd_ctl_add(), so it doesn't deadlock. That also affects the initial creation of the controls, which is OK, as that is done before the card is registered, so no concurrent access can occur.
It would be possible to do the DR in a tasklet after the ioctl finishes. However, it is not obvious what actual problem that would solve, and the added asynchronicity would significantly complicate matters, esp. wrt. the batch updates expected during mixer state restoration.
---
v2:
- expanded commit message
--- include/sound/emu10k1.h | 3 + sound/pci/emu10k1/emu10k1_main.c | 2 +- sound/pci/emu10k1/emumixer.c | 648 ++++++++++++++++++++++++++++--- sound/pci/emu10k1/emupcm.c | 41 +- sound/pci/emu10k1/io.c | 30 +- 5 files changed, 663 insertions(+), 61 deletions(-)
include/sound/emu10k1.h +3 -0
@@ -1676,6 +1676,8 @@ struct snd_emu1010 {unsigned int word_clock;/* Cached effective value */ unsigned int clock_source;unsigned int clock_fallback; +unsigned int clock_shift;/* EMU_HANA_WCLOCK_MULT_MASK >> 3 */ +unsigned int clock_users;unsigned int optical_in;/* 0:SPDIF, 1:ADAT */ unsigned int optical_out;/* 0:SPDIF, 1:ADAT */ struct delayed_work firmware_work;
@@ -1756,6 +1758,7 @@ struct snd_emu10k1 {struct snd_kcontrol *ctl_efx_send_routing;struct snd_kcontrol *ctl_efx_send_volume;struct snd_kcontrol *ctl_efx_attn; +struct snd_kcontrol *ctl_clock_shift;void (*hwvol_interrupt)(struct snd_emu10k1 *emu,unsigned int status);void (*capture_interrupt)(struct snd_emu10k1 *emu,unsigned int status);
sound/pci/emu10k1/emu10k1_main.c +1 -1
@@ -902,12 +902,12 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) emu->emu1010.clock_source =1 ;/* 48000 */ emu->emu1010.clock_fallback =1 ;/* 48000 */ + emu->emu1010.clock_shift =0 ;/* 1x */ /* Default WCLK set to 48kHz. */ snd_emu1010_fpga_write (emu,EMU_HANA_DEFCLOCK ,EMU_HANA_DEFCLOCK_48K );/* Word Clock source, Internal 48kHz x1 */ emu->emu1010.wclock =EMU_HANA_WCLOCK_INT_48K ;snd_emu1010_fpga_write (emu,EMU_HANA_WCLOCK ,EMU_HANA_WCLOCK_INT_48K ); -/* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */ snd_emu1010_update_clock (emu);// The routes are all set to EMU_SRC_SILENCE due to the reset,
sound/pci/emu10k1/emumixer.c +591 -57
909 lines not on this page · raw message
sound/pci/emu10k1/emupcm.c +39 -2
79 lines not on this page · raw message
sound/pci/emu10k1/io.c +29 -1
@@ -404,19 +404,47 @@ void snd_emu1010_update_clock(struct snd_emu10k1 *emu) clock =48000 ; leds =EMU_HANA_DOCK_LEDS_2_48K ;break ; +case EMU_HANA_WCLOCK_INT_44_1K |EMU_HANA_WCLOCK_2X : + clock =44100 ; + leds =0 ; +break ; +case EMU_HANA_WCLOCK_INT_48K |EMU_HANA_WCLOCK_2X : + clock =48000 ; + leds =EMU_HANA_DOCK_LEDS_2_96K ; +break ; +case EMU_HANA_WCLOCK_INT_44_1K |EMU_HANA_WCLOCK_4X : + clock =44100 ; + leds =0 ; +break ; +case EMU_HANA_WCLOCK_INT_48K |EMU_HANA_WCLOCK_4X : + clock =48000 ; + leds =EMU_HANA_DOCK_LEDS_2_192K ; +break ;default : clock =snd_emu1010_get_raw_rate ( emu, emu->emu1010.wclock &EMU_HANA_WCLOCK_SRC_MASK );// The raw rate reading is rather coarse (it cannot accurately // represent 44.1 kHz) and fluctuates slightly. Luckily, the // clock comes from digital inputs, which use standardized rates. // So we round to the closest standard rate and ignore discrepancies. if (clock <46000 ) { clock =44100 ; leds =EMU_HANA_DOCK_LEDS_2_EXT |EMU_HANA_DOCK_LEDS_2_44K ; - }else { + }else if (clock <75000 ) { clock =48000 ; leds =EMU_HANA_DOCK_LEDS_2_EXT |EMU_HANA_DOCK_LEDS_2_48K ; + }else if (clock <92000 ) { + clock =44100 ; + leds =EMU_HANA_DOCK_LEDS_2_EXT ; + }else if (clock <150000 ) { + clock =48000 ; + leds =EMU_HANA_DOCK_LEDS_2_EXT |EMU_HANA_DOCK_LEDS_2_96K ; + }else if (clock <184000 ) { + clock =44100 ; + leds =EMU_HANA_DOCK_LEDS_2_EXT ; + }else { + clock =48000 ; + leds =EMU_HANA_DOCK_LEDS_2_EXT |EMU_HANA_DOCK_LEDS_2_192K ; }break ; }
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 7/8 ALSA: emu10k1: add high-rate capture in E-MU D.A.S. mode
In reply to Oswald BuddenhagenThis is tested only with a 0404b card, so it is unclear whether the EMU_DST_TINA_EMU32B (1010b) & EMU_DST_TINA2_EMU32B (1616m CardBus) register definitions (derived from comments in the same file) are correct, and whether they actually lack the one-sample delay relative to EMU_DST_ALICE2_EMU32_0.
--- include/sound/emu10k1.h | 4 ++ sound/pci/emu10k1/emu10k1_main.c | 3 + sound/pci/emu10k1/emufx.c | 4 +- sound/pci/emu10k1/emumixer.c | 107 +++++++++++++++++++++++++++---- sound/pci/emu10k1/emupcm.c | 40 +++++++++--- 5 files changed, 135 insertions(+), 23 deletions(-)
include/sound/emu10k1.h +4 -0
@@ -1286,6 +1286,9 @@ SUB_REG_NC(A_EHC, A_I2S_CAPTURE_RATE, 0x00000e00) /* This sets the capture PCM#define EMU_DST_HAMOA_DAC_RIGHT4 0x0307/* Hamoa DAC Right, 4th or 192kHz */ // In S/MUX mode, the samples of one channel are adjacent. #define EMU_DST_HANA_ADAT 0x0400/* Hana ADAT 8 channel out +0 to +7 */ +/* FIXME: It is not clear whether these are actually enumerated like that. */ +#define EMU_DST_TINA2_EMU32B 0x0400/* 16 EMU32 channels to Tina2 +0 to +0xf */ +#define EMU_DST_TINA_EMU32B 0x0500/* 16 EMU32 channels to Tina +0 to +0xf */ #define EMU_DST_ALICE_I2S0_LEFT 0x0500/* Alice2 I2S0 Left */ #define EMU_DST_ALICE_I2S0_RIGHT 0x0501/* Alice2 I2S0 Right */ #define EMU_DST_ALICE_I2S1_LEFT 0x0600/* Alice2 I2S1 Left */
@@ -1648,6 +1651,7 @@ 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 emu_in_32:1; /* EMU32 input has 32 (connected) channels */ unsigned int spk20:1; /* Stereo only */ unsigned int spk71:1; /* Has 7.1 speakers */ unsigned int no_adat:1; /* Has no ADAT, only SPDIF */
sound/pci/emu10k1/emu10k1_main.c +3 -0
@@ -1093,6 +1093,7 @@ static const struct snd_emu_chip_details emu_chip_details[] = { .emu10k2_chip = 1, .ca0108_chip = 1, .ca_cardbus_chip = 1, + .emu_in_32 = 1, .spk71 = 1 , .emu_model = EMU_MODEL_EMU1616},/* Tested by [email protected] 4th Nov 2007. */
@@ -1105,6 +1106,7 @@ static const struct snd_emu_chip_details emu_chip_details[] = { .id = "EMU1010", .emu10k2_chip = 1, .ca0108_chip = 1, + .emu_in_32 = 1, .spk71 = 1, .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision *//* Tested by Maxim Kachur <[email protected]> 17th Oct 2012. */
@@ -1119,6 +1121,7 @@ static const struct snd_emu_chip_details emu_chip_details[] = { .id = "EMU1010", .emu10k2_chip = 1, .ca0108_chip = 1, + .emu_in_32 = 1, .spk71 = 1, .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 PCIe *//* Tested by [email protected] 8th July 2005. */
sound/pci/emu10k1/emufx.c +3 -1
@@ -1325,17 +1325,19 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu) gpr_map[lowword_mask] =0x0000ffff ;if (emu->card_capabilities->ca0108_chip) { +int num_cap = emu->card_capabilities->emu_in_32 ?32 :16 ; +for (int z =0 ; z <16 ; z++) {A_OP (icode, &ptr, iMAC0,A_GPR (tmp),A_C_00000000 ,A_FXBUS (z *2 ),A_C_00010000 );// >> 15 A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +1 ),A_C_00000002 );// << 1 A_OP (icode, &ptr, iANDXOR,A3_EMU32OUT (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 )); }snd_emu10k1_audigy_dsp_convert_32_to_2x16 ( icode, &ptr, tmp, bit_shifter16,A3_EMU32IN (0 ),A_EXTOUT (0 ));// A3_EMU32IN(0) is delayed by one sample, so all other A3_EMU32IN channels // need to be delayed as well; we use an auxiliary register for that. -for (int z =1 ; z <16 ; z++) { +for (int z =1 ; z < num_cap; z++) {snd_emu10k1_audigy_dsp_convert_32_to_2x16 ( icode, &ptr, tmp, bit_shifter16,A_GPR (gpr),A_EXTOUT (z *2 ));A_OP (icode, &ptr, iACC3,A_GPR (gpr),A3_EMU32IN (z),A_C_00000000 ,A_C_00000000 );
sound/pci/emu10k1/emumixer.c +95 -12
151 lines not on this page · raw message
sound/pci/emu10k1/emupcm.c +30 -10
@@ -233,6 +233,16 @@ static void snd_emu1010_constrain_efx_rate(struct snd_emu10k1 *emu, runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); } +static void snd_emu1010_constrain_efx_capture_rate (struct snd_emu10k1 *emu, +struct snd_pcm_runtime *runtime) +{ +int rate; + + rate = emu->emu1010.word_clock << emu->emu1010.clock_shift; + runtime->hw.rate_min = runtime->hw.rate_max = rate; + runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); +} +static unsigned int emu10k1_calc_pitch_target (unsigned int rate) {unsigned int pitch_target;
@@ -570,8 +580,22 @@ static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream)if (emu->card_capabilities->emu_model) {unsigned mask =0xffffffff >> (32 - runtime->channels *2 );if (emu->das_mode) { +unsigned shift = emu->emu1010.clock_shift; +if (shift) { +if (emu->card_capabilities->emu_in_32) { +if (shift ==2 ) + mask |= mask <<16 ; + epcm->capture_cr_val2 = mask; + }else { +if (shift ==2 ) + mask |= mask <<8 ; + mask |= mask <<16 ; + epcm->capture_cr_val2 =0 ; + } + }else { + epcm->capture_cr_val2 =0 ; + } epcm->capture_cr_val = mask; - epcm->capture_cr_val2 =0 ; }else {// The upper 32 16-bit capture voices, two for each of the 16 32-bit channels. // The lower voices are occupied by A_EXTOUT_*_CAP*.
@@ -1446,26 +1470,22 @@ static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) substream->runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_capture_efx;if (emu->card_capabilities->emu_model) { -snd_emu1010_constrain_efx_rate (emu, runtime); +snd_emu1010_constrain_efx_capture_rate (emu, runtime);/* * There are 32 mono channels of 16bits each. * 24bit Audio uses 2x channels over 16bit, * 96kHz uses 2x channels over 48kHz, * 192kHz uses 4x channels over 48kHz. * So, for 48kHz 24bit, one has 16 channels, * for 96kHz 24bit, one has 8 channels, * for 192kHz 24bit, one has 4 channels. * 1010rev2 and 1616(m) cards have double that, * but we don't exceed 16 channels anyway. */ -#if 0 -/* For 96kHz */ - runtime->hw.channels_min = runtime->hw.channels_max =4 ; -#endif -#if 0 -/* For 192kHz */ - runtime->hw.channels_min = runtime->hw.channels_max =2 ; -#endif +if (emu->das_mode) + runtime->hw.channels_max = +min (16 ,32 >> (emu->emu1010.clock_shift + + !emu->card_capabilities->emu_in_32)); runtime->hw.formats =SNDRV_PCM_FMTBIT_S32_LE ; }else {spin_lock_irq (&emu->reg_lock);
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 8/8 ALSA: emu10k1: add high-rate playback in E-MU D.A.S. mode
In reply to Oswald BuddenhagenThis mode does not offer mmapped I/O, as we need to copy the buffer anyway to reshuffle it.
A limitation is that we'll refuse writes which aren't a multiple of 2/4 frames, but that's unlikely to be significant. But if one really wanted to make it work, this could be done either locally, or by reviving (and fixing) snd_pcm_sw_params.xfer_align, which was obsoleted in commit d948035a92 ("Remove PCM xfer_align sw params").
---
v2:
- fixed sparse warning re missing __user annotation
--- sound/pci/emu10k1/emufx.c | 7 +- sound/pci/emu10k1/emumixer.c | 59 ++++---- sound/pci/emu10k1/emupcm.c | 257 ++++++++++++++++++++++++++++------- sound/pci/emu10k1/voice.c | 6 + 4 files changed, 247 insertions(+), 82 deletions(-)
sound/pci/emu10k1/emufx.c +6 -1
@@ -1327,7 +1327,7 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu)if (emu->card_capabilities->ca0108_chip) {int num_cap = emu->card_capabilities->emu_in_32 ?32 :16 ; -for (int z =0 ; z <16 ; z++) { +for (int z =0 ; z <32 ; z++) {A_OP (icode, &ptr, iMAC0,A_GPR (tmp),A_C_00000000 ,A_FXBUS (z *2 ),A_C_00010000 );// >> 15 A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +1 ),A_C_00000002 );// << 1 A_OP (icode, &ptr, iANDXOR,A3_EMU32OUT (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 ));
@@ -1349,6 +1349,11 @@ static int _snd_emu10k1_das_init_efx(struct snd_emu10k1 *emu)A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +1 ),A_C_00000002 );// << 1 A_OP (icode, &ptr, iANDXOR,A_EMU32OUTL (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 )); } +for (int z =0 ; z <16 ; z++) { +A_OP (icode, &ptr, iMAC0,A_GPR (tmp),A_C_00000000 ,A_FXBUS (z *2 +32 ),A_C_00010000 );// >> 15 +A_OP (icode, &ptr, iMACINT0,A_GPR (tmp +1 ),A_C_00000000 ,A_FXBUS (z *2 +33 ),A_C_00000002 );// << 1 +A_OP (icode, &ptr, iANDXOR,A_EMU32OUTH (z),A_GPR (tmp),A_GPR (lowword_mask),A_GPR (tmp +1 )); + }/* Note that the Alice2 DSPs have 6 I2S inputs which we don't use. */ snd_emu10k1_audigy_dsp_convert_32_to_2x16(
sound/pci/emu10k1/emumixer.c +30 -29
83 lines not on this page · raw message
sound/pci/emu10k1/emupcm.c +205 -52
463 lines not on this page · raw message
sound/pci/emu10k1/voice.c +6 -0
@@ -45,6 +45,12 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,continue ; } +// The voices must be consecutive without wrap-around +if (i + number >NUM_G ) { + skip =NUM_G - i; +continue ; + } +for (k =0 ; k < number; k++) { voice = &emu->voices[i + k];if (voice->use) {
Signature · 1 line
2.40.0.152.g15d061e6df
Quoted 4 lines · Oswald Buddenhagen
This series is what all the work was about: support the "dual-/quad-pumped" modes of the E-MU cards.
Quoted 9 lines
Oswald Buddenhagen (8):
ALSA: emu10k1: introduce alternative E-MUD.A.S. mode
ALSA: emu10k1: improve mixer control naming in E-MUD.A.S. mode
ALSA: emu10k1: set the "no filtering" bits on PCM voices
ALSA: emu10k1: make playback in E-MUD.A.S. mode 32-bit
ALSA: addsnd_ctl_add_locked()
ALSA: emu10k1: add support for 2x/4x word clocks in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate capture in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate playback in E-MUD.A.S. mode
I still can't agree with the basic design using the dynamic kctl addition / deletion in kcontrol's put action.
Takashi
Quoted 16 lines · Takashi Iwai
Quoted 4 lines · Oswald Buddenhagen
This series is what all the work was about: support the "dual-/quad-pumped" modes of the E-MU cards.
Quoted 9 lines
Oswald Buddenhagen (8):
ALSA: emu10k1: introduce alternative E-MUD.A.S. mode
ALSA: emu10k1: improve mixer control naming in E-MUD.A.S. mode
ALSA: emu10k1: set the "no filtering" bits on PCM voices
ALSA: emu10k1: make playback in E-MUD.A.S. mode 32-bit
ALSA: addsnd_ctl_add_locked()
ALSA: emu10k1: add support for 2x/4x word clocks in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate capture in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate playback in E-MUD.A.S. mode
Quoted 3 lines
I still can't agree with the basic design using the dynamic kctl addition / deletion in kcontrol's put action.
you are not being constructive. please provide specific, actionable responses to _all_ challenges/questions.
regards
Quoted 18 lines · Oswald Buddenhagen
Quoted 16 lines · Takashi Iwai
Quoted 13 lines · Oswald Buddenhagen
This series is what all the work was about: support the "dual-/quad-pumped" modes of the E-MU cards.
Oswald Buddenhagen (8):
ALSA: emu10k1: introduce alternative E-MUD.A.S. mode
ALSA: emu10k1: improve mixer control naming in E-MUD.A.S. mode
ALSA: emu10k1: set the "no filtering" bits on PCM voices
ALSA: emu10k1: make playback in E-MUD.A.S. mode 32-bit
ALSA: addsnd_ctl_add_locked()
ALSA: emu10k1: add support for 2x/4x word clocks in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate capture in E-MUD.A.S. mode
ALSA: emu10k1: add high-rate playback in E-MUD.A.S. mode
Quoted 5 lines
Quoted 3 lines
I still can't agree with the basic design using the dynamic kctl addition / deletion in kcontrol's put action.
you are not being constructive. please provide specific, actionable responses to _all_ challenges/questions.
The fundamental idea to add / delete the kctls from the put callback is unacceptable; as repeated many times, this is known to break existing applications. As long as you are sticking with this idea, it can go further. Please avoid it and use the (more or less) static configuration instead.
thanks,
Takashi
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Oswald Buddenhagen
Quoted 3 lines · Takashi Iwai
I still can't agree with the basic design using the dynamic kctl addition / deletion in kcontrol's put action.
Quoted 9 lines
Quoted 2 lines
you are not being constructive. please provide specific, actionable responses to _all_ challenges/questions.
The fundamental idea to add / delete the kctls from the put callback is unacceptable; as repeated many times, this is known to break existing applications. As long as you are sticking with this idea, it can go [no] further. Please avoid it and use the (more or less) static configuration instead.
to put the implications of this in clear words:
you want me to spend additional time
on a driver barely anyone still cares about to actively degrade the (my!) user experience to avoid hypothetical / likely obsolete crashes that would happen upon a rare user-controlled event in unspecified buggy (mixer? (!)) applications, while a known-good fallback exists (alsamixer).
i fail to see how that is even _remotely_ a reasonable request, and therefore have no intention whatsoever to follow it.
regards
Quoted 18 lines · Oswald Buddenhagen
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Oswald Buddenhagen
Quoted 3 lines · Takashi Iwai
I still can't agree with the basic design using the dynamic kctl addition / deletion in kcontrol's put action.
you are not being constructive. please provide specific,Quoted 9 lines
Quoted 2 lines
actionable
responses to _all_ challenges/questions.The fundamental idea to add / delete the kctls from the put callback is unacceptable; as repeated many times, this is known to break existing applications. As long as you are sticking with this idea, it can go [no] further. Please avoid it and use the (more or less) static configuration instead.
Quoted 8 lines
to put the implications of this in clear words:
you want me to spend additional time
on a driver barely anyone still cares about to actively degrade the (my!) user experience to avoid hypothetical / likely obsolete crashes that would happen upon a rare user-controlled event in unspecified buggy (mixer? (!)) applications, while a known-good fallback exists (alsamixer).
Simply put, YES. It's breaking applications pretty easily. This already happened in the past, so it's no hypothesis.
If you've ever programmed applications that deal with ALSA mixer/control stuff by yourself, you'll notice that it's really tough to deal with the dynamic deletion/addition. alsamixer can accept it in the limited manner, but it's no fallback for everything, of course.
Takashi
Quoted 11 lines · Takashi Iwai
Quoted 8 lines · Oswald Buddenhagen
you want me to spend additional time
on a driver barely anyone still cares about to actively degrade the (my!) user experience to avoid hypothetical / likely obsolete crashes that would happen upon a rare user-controlled event in unspecified buggy (mixer? (!)) applications, while a known-good fallback exists (alsamixer).
Quoted 2 lines
Simply put, YES.
well, your priorities don't align with the needs of actual users (that would be me, in this case).
Quoted 4 lines
If you've ever programmed applications that deal with ALSA mixer/control stuff by yourself, you'll notice that it's really tough to deal with the dynamic deletion/addition.
hot-plugging always requires some care to handle. i don't consider this a showstopper, esp. in the year 2023, when udev and pulseaudio/pipewire go all crazy on us (and yes, that crashed kmix - big deal). i don't think it's sane to set the bar at 1995 standards. even less so when the class of potentially affected apps holds no user data of note.
Quoted 3 lines
alsamixer can accept it in the limited manner,
but it's no fallback for everything, of course.
i have no clue what point you're trying to make.
regards