]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/isa/sb/sb16_csp.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6-omap-h63xx.git] / sound / isa / sb / sb16_csp.c
index 3d9d7e0107cad3828aa74b0fa4935bea38a5b26a..f3fd7b4f46683d30b059b6808861b6ea2e303c31 100644 (file)
@@ -23,7 +23,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
 MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor");
 MODULE_LICENSE("GPL");
+#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
+MODULE_FIRMWARE("sb16/mulaw_main.csp");
+MODULE_FIRMWARE("sb16/alaw_main.csp");
+MODULE_FIRMWARE("sb16/ima_adpcm_init.csp");
+MODULE_FIRMWARE("sb16/ima_adpcm_playback.csp");
+MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp");
+#endif
 
 #ifdef SNDRV_LITTLE_ENDIAN
 #define CSP_HDR_VALUE(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
@@ -111,7 +117,8 @@ static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buff
 int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
 {
        struct snd_sb_csp *p;
-       int version, err;
+       int uninitialized_var(version);
+       int err;
        struct snd_hwdep *hw;
 
        if (rhwdep)
@@ -161,13 +168,17 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
  */
 static void snd_sb_csp_free(struct snd_hwdep *hwdep)
 {
+#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
        int i;
+#endif
        struct snd_sb_csp *p = hwdep->private_data;
        if (p) {
                if (p->running & SNDRV_SB_CSP_ST_RUNNING)
                        snd_sb_csp_stop(p);
+#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
                for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i)
                        release_firmware(p->csp_programs[i]);
+#endif
                kfree(p);
        }
 }
@@ -320,7 +331,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
                return -EFAULT;
        if ((file_h.name != RIFF_HEADER) ||
            (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
-               snd_printd("%s: Invalid RIFF header\n", __FUNCTION__);
+               snd_printd("%s: Invalid RIFF header\n", __func__);
                return -EINVAL;
        }
        data_ptr += sizeof(file_h);
@@ -329,7 +340,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
        if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
                return -EFAULT;
        if (item_type != CSP__HEADER) {
-               snd_printd("%s: Invalid RIFF file type\n", __FUNCTION__);
+               snd_printd("%s: Invalid RIFF file type\n", __func__);
                return -EINVAL;
        }
        data_ptr += sizeof (item_type);
@@ -384,7 +395,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
                                return -EFAULT;
 
                        if (code_h.name != MAIN_HEADER) {
-                               snd_printd("%s: Missing 'main' microcode\n", __FUNCTION__);
+                               snd_printd("%s: Missing 'main' microcode\n", __func__);
                                return -EINVAL;
                        }
                        data_ptr += sizeof(code_h);
@@ -428,7 +439,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
                                p->acc_format = p->acc_width = p->acc_rates = 0;
                                p->mode = 0;
                                snd_printd("%s: Unsupported CSP codec type: 0x%04x\n",
-                                          __FUNCTION__,
+                                          __func__,
                                           le16_to_cpu(funcdesc_h.VOC_type));
                                return -EINVAL;
                        }
@@ -447,7 +458,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
                        return 0;
                }
        }
-       snd_printd("%s: Function #%d not found\n", __FUNCTION__, info.func_req);
+       snd_printd("%s: Function #%d not found\n", __func__, info.func_req);
        return -EINVAL;
 }
 
@@ -601,7 +612,7 @@ static int get_version(struct snd_sb *chip)
 static int snd_sb_csp_check_version(struct snd_sb_csp * p)
 {
        if (p->version < 0x10 || p->version > 0x1f) {
-               snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version);
+               snd_printd("%s: Invalid CSP version: 0x%x\n", __func__, p->version);
                return 1;
        }
        return 0;
@@ -620,7 +631,7 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
        spin_lock_irqsave(&p->chip->reg_lock, flags);
        snd_sbdsp_command(p->chip, 0x01);       /* CSP download command */
        if (snd_sbdsp_get_byte(p->chip)) {
-               snd_printd("%s: Download command failed\n", __FUNCTION__);
+               snd_printd("%s: Download command failed\n", __func__);
                goto __fail;
        }
        /* Send CSP low byte (size - 1) */
@@ -647,7 +658,7 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
                        udelay (10);
                }
                if (status != 0x55) {
-                       snd_printd("%s: Microcode initialization failed\n", __FUNCTION__);
+                       snd_printd("%s: Microcode initialization failed\n", __func__);
                        goto __fail;
                }
        } else {
@@ -690,9 +701,7 @@ static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __use
        return err;
 }
 
-#define FIRMWARE_IN_THE_KERNEL
-
-#ifdef FIRMWARE_IN_THE_KERNEL
+#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
 #include "sb16_csp_codecs.h"
 
 static const struct firmware snd_sb_csp_static_programs[] = {
@@ -714,22 +723,19 @@ static int snd_sb_csp_firmware_load(struct snd_sb_csp *p, int index, int flags)
                "sb16/ima_adpcm_capture.csp",
        };
        const struct firmware *program;
-       int err;
 
        BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT);
        program = p->csp_programs[index];
        if (!program) {
-               err = request_firmware(&program, names[index],
-                                      p->chip->card->dev);
-               if (err >= 0)
-                       p->csp_programs[index] = program;
-               else {
-#ifdef FIRMWARE_IN_THE_KERNEL
-                       program = &snd_sb_csp_static_programs[index];
+#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
+               program = &snd_sb_csp_static_programs[index];
 #else
+               int err = request_firmware(&program, names[index],
+                                      p->chip->card->dev);
+               if (err < 0)
                        return err;
 #endif
-               }
+               p->csp_programs[index] = program;
        }
        return snd_sb_csp_load(p, program->data, program->size, flags);
 }
@@ -818,19 +824,19 @@ static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channel
        unsigned long flags;
 
        if (!(p->running & (SNDRV_SB_CSP_ST_LOADED | SNDRV_SB_CSP_ST_AUTO))) {
-               snd_printd("%s: Microcode not loaded\n", __FUNCTION__);
+               snd_printd("%s: Microcode not loaded\n", __func__);
                return -ENXIO;
        }
        if (p->running & SNDRV_SB_CSP_ST_RUNNING) {
-               snd_printd("%s: CSP already running\n", __FUNCTION__);
+               snd_printd("%s: CSP already running\n", __func__);
                return -EBUSY;
        }
        if (!(sample_width & p->acc_width)) {
-               snd_printd("%s: Unsupported PCM sample width\n", __FUNCTION__);
+               snd_printd("%s: Unsupported PCM sample width\n", __func__);
                return -EINVAL;
        }
        if (!(channels & p->acc_channels)) {
-               snd_printd("%s: Invalid number of channels\n", __FUNCTION__);
+               snd_printd("%s: Invalid number of channels\n", __func__);
                return -EINVAL;
        }
 
@@ -852,11 +858,11 @@ static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channel
                s_type |= 0x22; /* 00dX 00dX    (d = 1 if 8 bit samples) */
 
        if (set_codec_parameter(p->chip, 0x81, s_type)) {
-               snd_printd("%s: Set sample type command failed\n", __FUNCTION__);
+               snd_printd("%s: Set sample type command failed\n", __func__);
                goto __fail;
        }
        if (set_codec_parameter(p->chip, 0x80, 0x00)) {
-               snd_printd("%s: Codec start command failed\n", __FUNCTION__);
+               snd_printd("%s: Codec start command failed\n", __func__);
                goto __fail;
        }
        p->run_width = sample_width;
@@ -973,14 +979,7 @@ static int snd_sb_csp_restart(struct snd_sb_csp * p)
  * QSound mixer control for PCM
  */
 
-static int snd_sb_qsound_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
+#define snd_sb_qsound_switch_info      snd_ctl_boolean_mono_info
 
 static int snd_sb_qsound_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {