Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: seq: Allow the modular sequencer registration

Many drivers bind the sequencer stuff in off-load by another driver
module, so that it's loaded only on demand. In the current code, this
mechanism doesn't work when the driver is built-in while the sequencer
is module. We check with IS_REACHABLE() and enable only when the
sequencer is in the same level of build.

However, this is basically a overshoot. The binder code
(snd-seq-device) is an individual module from the sequencer core
(snd-seq), and we just have to make the former a built-in while
keeping the latter a module for allowing the scenario like the above.

This patch achieves that by rewriting Kconfig slightly. Now, a driver
that provides the manual sequencer device binding should select
CONFIG_SND_SEQ_DEVICE in a way as
select SND_SEQ_DEVICE if SND_SEQUENCER != n

Note that the "!=n" is needed here to avoid the influence of the
sequencer core is module while the driver is built-in.

Also, since rawmidi.o may be linked with snd_seq_device.o when
built-in, we have to shuffle the code to make the linker happy.
(the kernel linker isn't smart enough yet to handle such a case.)
That is, snd_seq_device.c is moved to sound/core from sound/core/seq,
as well as Makefile.

Last but not least, the patch replaces the code using IS_REACHABLE()
with IS_ENABLED(), since now the condition meets always when enabled.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+21 -12
+4
sound/core/Kconfig
··· 18 18 config SND_HWDEP 19 19 tristate 20 20 21 + config SND_SEQ_DEVICE 22 + tristate 23 + 21 24 config SND_RAWMIDI 22 25 tristate 26 + select SND_SEQ_DEVICE if SND_SEQUENCER != n 23 27 24 28 config SND_COMPRESS_OFFLOAD 25 29 tristate
+2
sound/core/Makefile
··· 31 31 snd-hrtimer-objs := hrtimer.o 32 32 snd-rtctimer-objs := rtctimer.o 33 33 snd-hwdep-objs := hwdep.o 34 + snd-seq-device-objs := seq_device.o 34 35 35 36 snd-compress-objs := compress_offload.o 36 37 ··· 41 40 obj-$(CONFIG_SND_HRTIMER) += snd-hrtimer.o 42 41 obj-$(CONFIG_SND_PCM) += snd-pcm.o 43 42 obj-$(CONFIG_SND_DMAENGINE_PCM) += snd-pcm-dmaengine.o 43 + obj-$(CONFIG_SND_SEQ_DEVICE) += snd-seq-device.o 44 44 obj-$(CONFIG_SND_RAWMIDI) += snd-rawmidi.o 45 45 46 46 obj-$(CONFIG_SND_OSSEMUL) += oss/
+2 -2
sound/core/rawmidi.c
··· 1610 1610 return snd_rawmidi_free(rmidi); 1611 1611 } 1612 1612 1613 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 1613 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 1614 1614 static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) 1615 1615 { 1616 1616 struct snd_rawmidi *rmidi = device->private_data; ··· 1691 1691 } 1692 1692 } 1693 1693 rmidi->proc_entry = entry; 1694 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 1694 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 1695 1695 if (!rmidi->ops || !rmidi->ops->dev_register) { /* own registration mechanism */ 1696 1696 if (snd_seq_device_new(rmidi->card, rmidi->device, SNDRV_SEQ_DEV_ID_MIDISYNTH, 0, &rmidi->seq_dev) >= 0) { 1697 1697 rmidi->seq_dev->private_data = rmidi;
+1 -1
sound/core/seq/Kconfig
··· 1 1 config SND_SEQUENCER 2 2 tristate "Sequencer support" 3 3 select SND_TIMER 4 + select SND_SEQ_DEVICE 4 5 help 5 6 Say Y or M to enable MIDI sequencer and router support. This 6 7 feature allows routing and enqueueing of MIDI events. Events ··· 60 59 tristate 61 60 62 61 endif # SND_SEQUENCER 63 -
+1 -2
sound/core/seq/Makefile
··· 3 3 # Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz> 4 4 # 5 5 6 - snd-seq-device-objs := seq_device.o 7 6 snd-seq-objs := seq.o seq_lock.o seq_clientmgr.o seq_memory.o seq_queue.o \ 8 7 seq_fifo.o seq_prioq.o seq_timer.o \ 9 8 seq_system.o seq_ports.o ··· 13 14 snd-seq-dummy-objs := seq_dummy.o 14 15 snd-seq-virmidi-objs := seq_virmidi.o 15 16 16 - obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o 17 + obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o 17 18 obj-$(CONFIG_SND_SEQUENCER_OSS) += oss/ 18 19 19 20 obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o
sound/core/seq/seq_device.c sound/core/seq_device.c
+2
sound/drivers/Kconfig
··· 6 6 tristate 7 7 select SND_TIMER 8 8 select SND_HWDEP 9 + select SND_SEQ_DEVICE if SND_SEQUENCER != n 9 10 10 11 config SND_OPL4_LIB 11 12 tristate 12 13 select SND_TIMER 13 14 select SND_HWDEP 15 + select SND_SEQ_DEVICE if SND_SEQUENCER != n 14 16 15 17 # select SEQ stuff to min(SND_SEQUENCER,SND_XXX) 16 18 config SND_OPL3_LIB_SEQ
+1 -1
sound/drivers/opl3/opl3_lib.c
··· 528 528 529 529 opl3->hwdep = hw; 530 530 opl3->seq_dev_num = seq_device; 531 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 531 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 532 532 if (snd_seq_device_new(card, seq_device, SNDRV_SEQ_DEV_ID_OPL3, 533 533 sizeof(struct snd_opl3 *), &opl3->seq_dev) >= 0) { 534 534 strcpy(opl3->seq_dev->name, hw->name);
+2 -2
sound/drivers/opl4/opl4_lib.c
··· 153 153 return 0; 154 154 } 155 155 156 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 156 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 157 157 static void snd_opl4_seq_dev_free(struct snd_seq_device *seq_dev) 158 158 { 159 159 struct snd_opl4 *opl4 = seq_dev->private_data; ··· 249 249 snd_opl4_create_mixer(opl4); 250 250 snd_opl4_create_proc(opl4); 251 251 252 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 252 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 253 253 opl4->seq_client = -1; 254 254 if (opl4->hardware < OPL3_HW_OPL4_ML) 255 255 snd_opl4_create_seq_dev(opl4, seq_device);
+1 -1
sound/drivers/opl4/opl4_local.h
··· 184 184 #endif 185 185 struct mutex access_mutex; 186 186 187 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 187 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 188 188 int used; 189 189 190 190 int seq_dev_num;
+1
sound/isa/Kconfig
··· 377 377 select SND_OPL3_LIB 378 378 select SND_MPU401_UART 379 379 select SND_SB16_DSP 380 + select SND_SEQ_DEVICE if SND_SEQUENCER != n 380 381 help 381 382 Say Y here to include support for Sound Blaster AWE soundcards 382 383 (including the Plug and Play version).
+1 -1
sound/isa/sb/emu8000.c
··· 1138 1138 snd_emu8000_free(hw); 1139 1139 return err; 1140 1140 } 1141 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 1141 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 1142 1142 if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000, 1143 1143 sizeof(struct snd_emu8000*), &awe) >= 0) { 1144 1144 strcpy(awe->name, "EMU-8000");
+1 -1
sound/isa/sb/sb16.c
··· 62 62 #define SNDRV_DEBUG_IRQ 63 63 #endif 64 64 65 - #if defined(SNDRV_SBAWE) && IS_REACHABLE(CONFIG_SND_SEQUENCER) 65 + #if defined(SNDRV_SBAWE) && IS_ENABLED(CONFIG_SND_SEQUENCER) 66 66 #define SNDRV_SBAWE_EMU8000 67 67 #endif 68 68
+1
sound/pci/Kconfig
··· 465 465 select SND_RAWMIDI 466 466 select SND_AC97_CODEC 467 467 select SND_TIMER 468 + select SND_SEQ_DEVICE if SND_SEQUENCER != n 468 469 depends on ZONE_DMA 469 470 help 470 471 Say Y to include support for Sound Blaster PCI 512, Live!,
+1 -1
sound/pci/emu10k1/emu10k1.c
··· 37 37 MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS}," 38 38 "{Creative Labs,SB Audigy}}"); 39 39 40 - #if IS_REACHABLE(CONFIG_SND_SEQUENCER) 40 + #if IS_ENABLED(CONFIG_SND_SEQUENCER) 41 41 #define ENABLE_SYNTH 42 42 #include <sound/emu10k1_synth.h> 43 43 #endif