]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ALSA: emu10k1: improve voice status display in /proc
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Thu, 18 May 2023 14:09:43 +0000 (16:09 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 18 May 2023 14:49:09 +0000 (16:49 +0200)
Eliminate the MIDI type, as there is no such thing - the MPU401 port
doesn't have anything to do with voices.

For clarity, differentiate between regular and extra voices.

Don't atomize the enum into bits in the table display.

Simplify/optimize the storage.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230518140947.3725394-4-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/emu10k1.h
sound/pci/emu10k1/emupcm.c
sound/pci/emu10k1/emuproc.c
sound/pci/emu10k1/voice.c

index 583fabef0b994d47a5c44b497696721874f62464..1fa7816c07fda75eff948aa17a88f4ec8a703f0e 100644 (file)
@@ -1439,21 +1439,20 @@ SUB_REG_NC(A_EHC, A_I2S_CAPTURE_RATE, 0x00000e00)  /* This sets the capture PCM
 /* ------------------- STRUCTURES -------------------- */
 
 enum {
+       EMU10K1_UNUSED,  // This must be zero
        EMU10K1_EFX,
+       EMU10K1_EFX_IRQ,
        EMU10K1_PCM,
+       EMU10K1_PCM_IRQ,
        EMU10K1_SYNTH,
-       EMU10K1_MIDI
+       EMU10K1_NUM_TYPES
 };
 
 struct snd_emu10k1;
 
 struct snd_emu10k1_voice {
-       int number;
-       unsigned int use: 1,
-           pcm: 1,
-           efx: 1,
-           synth: 1,
-           midi: 1;
+       unsigned char number;
+       unsigned char use;
        void (*interrupt)(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *pvoice);
 
        struct snd_emu10k1_pcm *epcm;
index 903a68a4d396040dc6a9140f9695b88cb71baa70..216b6cde326f5ba9132a11e02364107b13731096 100644 (file)
@@ -117,7 +117,7 @@ static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voic
                // period-sized loop as the interrupt source. Additionally, the interrupt
                // timing of the hardware is "suboptimal" and needs some compensation.
                err = snd_emu10k1_voice_alloc(epcm->emu,
-                                             epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM : EMU10K1_EFX,
+                                             epcm->type == PLAYBACK_EMUVOICE ? EMU10K1_PCM_IRQ : EMU10K1_EFX_IRQ,
                                              1,
                                              &epcm->extra);
                if (err < 0) {
index 708aff6cf09a72c5947864925cc7909ff0efba54..c423a56ebf9eb49da5d66ef5a69e723d264b069a 100644 (file)
@@ -367,17 +367,17 @@ static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
        struct snd_emu10k1 *emu = entry->private_data;
        struct snd_emu10k1_voice *voice;
        int idx;
-       
-       snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n");
+       static const char * const types[] = {
+               "Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth"
+       };
+       static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES);
+
+       snd_iprintf(buffer, "ch\tuse\n");
        for (idx = 0; idx < NUM_G; idx++) {
                voice = &emu->voices[idx];
-               snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n",
+               snd_iprintf(buffer, "%i\t%s\n",
                        idx,
-                       voice->use,
-                       voice->pcm,
-                       voice->efx,
-                       voice->synth,
-                       voice->midi);
+                       types[voice->use]);
        }
 }
 
index a602df9117f6254ab66b88af2a92b0056ad653cf..ac89d09ed9bc2a44b6d1870b9999061e31c1161d 100644 (file)
@@ -78,21 +78,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
                dev_dbg(emu->card->dev, "voice alloc - %i, %i of %i\n",
                       voice->number, idx-first_voice+1, number);
                */
-               voice->use = 1;
-               switch (type) {
-               case EMU10K1_PCM:
-                       voice->pcm = 1;
-                       break;
-               case EMU10K1_SYNTH:
-                       voice->synth = 1;
-                       break;
-               case EMU10K1_MIDI:
-                       voice->midi = 1;
-                       break;
-               case EMU10K1_EFX:
-                       voice->efx = 1;
-                       break;
-               }
+               voice->use = type;
        }
        *rvoice = &emu->voices[first_voice];
        return 0;
@@ -103,7 +89,7 @@ static void voice_free(struct snd_emu10k1 *emu,
 {
        snd_emu10k1_voice_init(emu, pvoice->number);
        pvoice->interrupt = NULL;
-       pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0;
+       pvoice->use = 0;
        pvoice->epcm = NULL;
 }
 
@@ -121,7 +107,7 @@ int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number,
        spin_lock_irqsave(&emu->voice_lock, flags);
        for (;;) {
                result = voice_alloc(emu, type, number, rvoice);
-               if (result == 0 || type == EMU10K1_SYNTH || type == EMU10K1_MIDI)
+               if (result == 0 || type == EMU10K1_SYNTH)
                        break;
 
                /* free a voice from synth */