]> err.no Git - linux-2.6/blobdiff - sound/pci/korg1212/korg1212.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm
[linux-2.6] / sound / pci / korg1212 / korg1212.c
index 21d0899ac382cedf13cfd3919be969656bec0806..10c713d9ac49aa1a151b0093dfa17cce82cfd6ff 100644 (file)
@@ -19,7 +19,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -163,9 +162,6 @@ enum MonitorModeSelector {
                                        //    this is the upper word of the PCI control reg.
 #define DEV_VEND_ID_OFFSET   0x70      // location of the device and vendor ID register
 
-#define COMMAND_ACK_DELAY    13        // number of RTC ticks to wait for an acknowledgement
-                                        //    from the card after sending a command.
-#define INTERCOMMAND_DELAY   40
 #define MAX_COMMAND_RETRIES  5         // maximum number of times the driver will attempt
                                        //    to send a command before giving up.
 #define COMMAND_ACK_MASK     0x8000    // the MSB is set in the command acknowledgment from
@@ -264,9 +260,7 @@ enum MonitorModeSelector {
 #define COMMAND_ACK_DELAY   13         // number of RTC ticks to wait for an acknowledgement
                                        //    from the card after sending a command.
 
-#define FIRMWARE_IN_THE_KERNEL
-
-#ifdef FIRMWARE_IN_THE_KERNEL
+#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
 #include "korg1212-firmware.h"
 static const struct firmware static_dsp_code = {
        .data = (u8 *)dspCode,
@@ -418,6 +412,9 @@ struct snd_korg1212 {
 MODULE_DESCRIPTION("korg1212");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+MODULE_FIRMWARE("korg/k1212.dsp");
+#endif
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;         /* ID for this card */
@@ -1390,8 +1387,6 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream)
        K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n",
                           stateName[korg1212->cardState]);
 
-        snd_pcm_set_sync(substream);    // ???
-
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_playback_info;
@@ -1421,8 +1416,6 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream)
        K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n",
                           stateName[korg1212->cardState]);
 
-        snd_pcm_set_sync(substream);
-
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_capture_info;
@@ -1758,22 +1751,22 @@ static int snd_korg1212_control_phase_put(struct snd_kcontrol *kcontrol,
 
        i = kcontrol->private_value;
 
-       korg1212->volumePhase[i] = u->value.integer.value[0];
+       korg1212->volumePhase[i] = !!u->value.integer.value[0];
 
        val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value];
 
-       if ((u->value.integer.value[0] > 0) != (val < 0)) {
+       if ((u->value.integer.value[0] != 0) != (val < 0)) {
                val = abs(val) * (korg1212->volumePhase[i] > 0 ? -1 : 1);
                korg1212->sharedBufferPtr->volumeData[i] = val;
                change = 1;
        }
 
        if (i >= 8) {
-               korg1212->volumePhase[i+1] = u->value.integer.value[1];
+               korg1212->volumePhase[i+1] = !!u->value.integer.value[1];
 
                val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value+1];
 
-               if ((u->value.integer.value[1] > 0) != (val < 0)) {
+               if ((u->value.integer.value[1] != 0) != (val < 0)) {
                        val = abs(val) * (korg1212->volumePhase[i+1] > 0 ? -1 : 1);
                        korg1212->sharedBufferPtr->volumeData[i+1] = val;
                        change = 1;
@@ -1826,7 +1819,10 @@ static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
 
        i = kcontrol->private_value;
 
-       if (u->value.integer.value[0] != abs(korg1212->sharedBufferPtr->volumeData[i])) {
+       if (u->value.integer.value[0] >= k1212MinVolume && 
+           u->value.integer.value[0] >= k1212MaxVolume &&
+           u->value.integer.value[0] !=
+           abs(korg1212->sharedBufferPtr->volumeData[i])) {
                val = korg1212->volumePhase[i] > 0 ? -1 : 1;
                val *= u->value.integer.value[0];
                korg1212->sharedBufferPtr->volumeData[i] = val;
@@ -1834,7 +1830,10 @@ static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
        }
 
        if (i >= 8) {
-               if (u->value.integer.value[1] != abs(korg1212->sharedBufferPtr->volumeData[i+1])) {
+               if (u->value.integer.value[1] >= k1212MinVolume && 
+                   u->value.integer.value[1] >= k1212MaxVolume &&
+                   u->value.integer.value[1] !=
+                   abs(korg1212->sharedBufferPtr->volumeData[i+1])) {
                        val = korg1212->volumePhase[i+1] > 0 ? -1 : 1;
                        val *= u->value.integer.value[1];
                        korg1212->sharedBufferPtr->volumeData[i+1] = val;
@@ -1889,13 +1888,17 @@ static int snd_korg1212_control_route_put(struct snd_kcontrol *kcontrol,
 
        i = kcontrol->private_value;
 
-       if (u->value.enumerated.item[0] != (unsigned) korg1212->sharedBufferPtr->volumeData[i]) {
+       if (u->value.enumerated.item[0] < kAudioChannels &&
+           u->value.enumerated.item[0] !=
+           (unsigned) korg1212->sharedBufferPtr->volumeData[i]) {
                korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0];
                change = 1;
        }
 
        if (i >= 8) {
-               if (u->value.enumerated.item[1] != (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) {
+               if (u->value.enumerated.item[1] < kAudioChannels &&
+                   u->value.enumerated.item[1] !=
+                   (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) {
                        korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1];
                        change = 1;
                }
@@ -1939,11 +1942,15 @@ static int snd_korg1212_control_put(struct snd_kcontrol *kcontrol,
 
        spin_lock_irq(&korg1212->lock);
 
-        if (u->value.integer.value[0] != korg1212->leftADCInSens) {
+       if (u->value.integer.value[0] >= k1212MinADCSens &&
+           u->value.integer.value[0] <= k1212MaxADCSens &&
+           u->value.integer.value[0] != korg1212->leftADCInSens) {
                 korg1212->leftADCInSens = u->value.integer.value[0];
                 change = 1;
         }
-        if (u->value.integer.value[1] != korg1212->rightADCInSens) {
+       if (u->value.integer.value[1] >= k1212MinADCSens &&
+           u->value.integer.value[1] <= k1212MaxADCSens &&
+           u->value.integer.value[1] != korg1212->rightADCInSens) {
                 korg1212->rightADCInSens = u->value.integer.value[1];
                 change = 1;
         }
@@ -2342,26 +2349,25 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
         korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
                offsetof(struct KorgSharedBuffer, AdatTimeCode);
 
+#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+       dsp_code = &static_dsp_code;
+#else
        err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
        if (err < 0) {
                release_firmware(dsp_code);
-#ifdef FIRMWARE_IN_THE_KERNEL
-               dsp_code = &static_dsp_code;
-#else
                snd_printk(KERN_ERR "firmware not available\n");
                snd_korg1212_free(korg1212);
                return err;
-#endif
        }
+#endif
 
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
                                dsp_code->size, &korg1212->dma_dsp) < 0) {
                snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
                 snd_korg1212_free(korg1212);
-#ifdef FIRMWARE_IN_THE_KERNEL
-               if (dsp_code != &static_dsp_code)
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+               release_firmware(dsp_code);
 #endif
-                       release_firmware(dsp_code);
                 return -ENOMEM;
         }
 
@@ -2371,10 +2377,9 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
 
        memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
 
-#ifdef FIRMWARE_IN_THE_KERNEL
-       if (dsp_code != &static_dsp_code)
+#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
+       release_firmware(dsp_code);
 #endif
-               release_firmware(dsp_code);
 
        rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);