[ALSA] PCM midlevel & PCM OSS - make procfs & OSS plugin code optional
authorJaroslav Kysela <perex@suse.cz>
Fri, 13 Jan 2006 08:12:11 +0000 (09:12 +0100)
committerJaroslav Kysela <perex@suse.cz>
Wed, 22 Mar 2006 09:23:12 +0000 (10:23 +0100)
Modules: ALSA Core,PCM Midlevel,ALSA<-OSS emulation,USB generic driver

1) The verbose procfs code for the PCM midlevel and usb audio
   can be removed now (more patches will follow).
   CONFIG_SND_VERBOSE_PROCFS
2) The PCM OSS plugin system can be also compiled optionaly.
   CONFIG_SND_PCM_OSS_PLUGINS

Signed-off-by: Jaroslav Kysela <perex@suse.cz>
13 files changed:
include/sound/pcm_oss.h
sound/core/Kconfig
sound/core/oss/copy.c
sound/core/oss/io.c
sound/core/oss/linear.c
sound/core/oss/mulaw.c
sound/core/oss/pcm_oss.c
sound/core/oss/pcm_plugin.c
sound/core/oss/pcm_plugin.h
sound/core/oss/rate.c
sound/core/oss/route.c
sound/core/pcm.c
sound/usb/usbaudio.c

index fddaddde47b4f1803a66216c76394ebdb0c7d80f..d6ec886637db38ae292aa57fd89fb240085d4453 100644 (file)
@@ -56,8 +56,10 @@ struct snd_pcm_oss_runtime {
        size_t mmap_bytes;
        char *buffer;                           /* vmallocated period */
        size_t buffer_used;                     /* used length from period buffer */
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        struct snd_pcm_plugin *plugin_first;
        struct snd_pcm_plugin *plugin_last;
+#endif
        unsigned int prev_hw_ptr_interrupt;
 };
 
index f79755f77a81f5158152076a7ed81f0d85f3d998..9dd121bb56380827656ddc5f64dd4096a8524022 100644 (file)
@@ -73,6 +73,15 @@ config SND_PCM_OSS
          To compile this driver as a module, choose M here: the module
          will be called snd-pcm-oss.
 
+config SND_PCM_OSS_PLUGINS
+       bool "OSS PCM (digital audio) API - Include plugin system"
+       depends on SND_PCM_OSS
+        default y
+       help
+          If you disable this option, the ALSA's OSS PCM API will not
+          support conversion of channels, formats and rates. It will
+          behave like most of new OSS/Free drivers in 2.4/2.6 kernels.
+
 config SND_SEQUENCER_OSS
        bool "OSS Sequencer API"
        depends on SND && SND_SEQUENCER
@@ -130,6 +139,15 @@ config SND_SUPPORT_OLD_API
          Say Y here to support the obsolete ALSA PCM API (ver.0.9.0 rc3
          or older).
 
+config SND_VERBOSE_PROCFS
+       bool "Verbose procfs contents"
+       depends on SND
+       default y
+       help
+         Say Y here to include code for verbose procfs contents (provides
+          usefull information to developers when a problem occurs). On the
+          other side, it makes the ALSA subsystem larger.
+
 config SND_VERBOSE_PRINTK
        bool "Verbose printk"
        depends on SND
index d6a04c2d5a75a7933fd5d7f9c51008a08536565a..7c008c4c0dd135a0575f4971a068156afaa6456c 100644 (file)
@@ -20,6 +20,9 @@
  */
 
 #include <sound/driver.h>
+
+#ifdef SND_PCM_OSS_PLUGINS
+
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -85,3 +88,5 @@ int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 322702e05f3eca5f8850c33db074089add489ebb..b6e7ce30e5a35dea6927d323d4390eb7e11824ec 100644 (file)
@@ -20,6 +20,9 @@
  */
   
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -132,3 +135,5 @@ int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 8cbfa415ce409f86ee12ef9f51976fdab83e2625..ef331230b3a6ba01c2d913b693950a443935ace2 100644 (file)
@@ -21,6 +21,9 @@
  */
 
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -156,3 +159,5 @@ int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 14f5578ec7a7842fce9c16307467a3f883209b19..ed12c81fcf1b94f449d1bc81622cb26068a6af68 100644 (file)
@@ -22,6 +22,9 @@
  */
   
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -306,3 +309,5 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 7fd072392c7e89ad0eec524a51563c42477fcbf9..bc24d028f5181e6f482d2a787de9abfed01ef14a 100644 (file)
@@ -78,6 +78,7 @@ static inline void snd_leave_user(mm_segment_t fs)
        set_fs(fs);
 }
 
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
 static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
@@ -122,6 +123,7 @@ int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin)
        }
        return 0;
 }
+#endif /* CONFIG_SND_PCM_OSS_PLUGINS */
 
 static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames)
 {
@@ -412,6 +414,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        oss_frame_size = snd_pcm_format_physical_width(params_format(params)) *
                         params_channels(params) / 8;
 
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        snd_pcm_oss_plugin_clear(substream);
        if (!direct) {
                /* add necessary plugins */
@@ -441,6 +444,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
                        }
                }
        }
+#endif
 
        err = snd_pcm_oss_period_size(substream, params, sparams);
        if (err < 0)
@@ -498,11 +502,13 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
        runtime->oss.periods = params_periods(sparams);
        oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams));
        snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure);
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        if (runtime->oss.plugin_first) {
                err = snd_pcm_plug_alloc(substream, oss_period_size);
                if (err < 0)
                        goto failure;
        }
+#endif
        oss_period_size *= oss_frame_size;
 
        oss_buffer_size = oss_period_size * runtime->oss.periods;
@@ -784,6 +790,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        snd_pcm_sframes_t frames, frames1;
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        if (runtime->oss.plugin_first) {
                struct snd_pcm_plugin_channel *channels;
                size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
@@ -800,7 +807,9 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
                if (frames1 <= 0)
                        return frames1;
                bytes = frames1 * oss_frame_bytes;
-       } else {
+       } else
+#endif
+       {
                frames = bytes_to_frames(runtime, bytes);
                frames1 = snd_pcm_oss_write3(substream, buf, frames, in_kernel);
                if (frames1 <= 0)
@@ -871,6 +880,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        snd_pcm_sframes_t frames, frames1;
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        char __user *final_dst = (char __user *)buf;
        if (runtime->oss.plugin_first) {
                struct snd_pcm_plugin_channel *channels;
@@ -887,7 +897,9 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
                bytes = frames1 * oss_frame_bytes;
                if (!in_kernel && copy_to_user(final_dst, buf, bytes))
                        return -EFAULT;
-       } else {
+       } else
+#endif
+       {
                frames = bytes_to_frames(runtime, bytes);
                frames1 = snd_pcm_oss_read3(substream, buf, frames, in_kernel);
                if (frames1 <= 0)
@@ -1692,7 +1704,9 @@ static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime;
        runtime = substream->runtime;
        vfree(runtime->oss.buffer);
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        snd_pcm_oss_plugin_clear(substream);
+#endif
        substream->oss.file = NULL;
        substream->oss.oss = 0;
 }
@@ -2246,8 +2260,10 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
                if ((err = snd_pcm_oss_change_params(substream)) < 0)
                        return err;
        }
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
        if (runtime->oss.plugin_first != NULL)
                return -EIO;
+#endif
 
        if (area->vm_pgoff != 0)
                return -EINVAL;
index 7e8676880dde16f5d74fb75f63d361883c9b08b2..89bc8f965043972a99601d2c8e09e5e6953167b1 100644 (file)
@@ -25,6 +25,9 @@
 #endif
 
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/vmalloc.h>
@@ -916,3 +919,5 @@ int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_of
        }
        return 0;
 }
+
+#endif
index 29198da615cd1fdb89224a80f057aaa947098312..a8a4f958043565dfbda0a93f196daf6d8c7e5c87 100644 (file)
@@ -22,6 +22,8 @@
  *
  */
 
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/bitmap.h>
 
 static inline unsigned long *bitmap_alloc(unsigned int nbits)
@@ -191,6 +193,14 @@ void zero_channel(struct snd_pcm_plugin *plugin,
                  const struct snd_pcm_plugin_channel *dst_channel,
                  size_t samples);
 
+#else
+
+static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; }
+static inline snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size) { return clt_size; }
+static inline int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) { return format; }
+
+#endif
+
 #ifdef PLUGIN_DEBUG
 #define pdprintf( fmt, args... ) printk( "plugin: " fmt, ##args)
 #else
index 4854cef6fb4f69014c910eedeee9177810cec7ca..c4b75bff0ee5213da99681fd84a92271e037e869 100644 (file)
@@ -20,6 +20,9 @@
  */
   
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -377,3 +380,5 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 726c5caa3fdb29df7caf198a394d38560901adf1..f99a54e6551a67d04fad50538d86fc991b1555e4 100644 (file)
@@ -20,6 +20,9 @@
  */
 
 #include <sound/driver.h>
+
+#ifdef CONFIG_SND_PCM_OSS_PLUGINS
+
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <sound/core.h>
@@ -519,3 +522,5 @@ int snd_pcm_plugin_build_route(struct snd_pcm_substream *plug,
        *r_plugin = plugin;
        return 0;
 }
+
+#endif
index 28ca61eb0b0d9948515985a687e71e5543e9866e..d92c3ce4a4c9ca5b7323c54b8f9ae4b8e0c7074b 100644 (file)
@@ -140,6 +140,9 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
        }
        return -ENOIOCTLCMD;
 }
+
+#if defined(CONFIG_PROC_FS) && defined(CONFIG_SND_VERBOSE_PROCFS)
+
 #define STATE(v) [SNDRV_PCM_STATE_##v] = #v
 #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v
 #define READY(v) [SNDRV_PCM_READY_##v] = #v
@@ -197,7 +200,6 @@ const char *snd_pcm_format_name(snd_pcm_format_t format)
        return snd_pcm_format_names[format];
 }
 
-#ifdef CONFIG_PROC_FS
 static char *snd_pcm_stream_names[] = {
        STREAM(PLAYBACK),
        STREAM(CAPTURE),
index f5aadb001986f2f9d8287686e10345f15e4e3cec..c9476c237c4222522845d92c88d9cc265b1f3066 100644 (file)
@@ -1384,8 +1384,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
        channels = params_channels(hw_params);
        fmt = find_format(subs, format, rate, channels);
        if (! fmt) {
-               snd_printd(KERN_DEBUG "cannot set format: format = %s, rate = %d, channels = %d\n",
-                          snd_pcm_format_name(format), rate, channels);
+               snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n",
+                          format, rate, channels);
                return -EINVAL;
        }
 
@@ -2011,6 +2011,8 @@ static struct usb_driver usb_audio_driver = {
 };
 
 
+#if defined(CONFIG_PROCFS) && defined(CONFIG_SND_VERBOSE_PROCFS)
+
 /*
  * proc interface for list the supported pcm formats
  */
@@ -2101,6 +2103,13 @@ static void proc_pcm_format_add(struct snd_usb_stream *stream)
                snd_info_set_text_ops(entry, stream, 1024, proc_pcm_format_read);
 }
 
+#else
+
+static inline void proc_pcm_format_add(struct snd_usb_stream *stream)
+{
+}
+
+#endif
 
 /*
  * initialize the substream instance.