]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - sound/pci/emu10k1/emufx.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx
[mv-sheeva.git] / sound / pci / emu10k1 / emufx.c
index 191e1cd9997db53e8318ec4866efe327f9c012e4..7a9401462c1c698a0a8f21e2135a613d1efb5a0b 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
+#include <linux/moduleparam.h>
 
 #include <sound/core.h>
 #include <sound/tlv.h>
 #define EMU10K1_CENTER_LFE_FROM_FRONT
 #endif
 
+static bool high_res_gpr_volume;
+module_param(high_res_gpr_volume, bool, 0444);
+MODULE_PARM_DESC(high_res_gpr_volume, "GPR mixer controls use 31-bit range.");
+
 /*
  *  Tables
  */ 
@@ -296,6 +301,7 @@ static const u32 db_table[101] = {
 
 /* EMU10k1/EMU10k2 DSP control db gain */
 static const DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
+static const DECLARE_TLV_DB_LINEAR(snd_emu10k1_db_linear, TLV_DB_GAIN_MUTE, 0);
 
 static const u32 onoff_table[2] = {
        0x00000000, 0x00000001
@@ -1072,10 +1078,17 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
        strcpy(ctl->id.name, name);
        ctl->vcount = ctl->count = 1;
        ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
-       ctl->min = 0;
-       ctl->max = 100;
-       ctl->tlv = snd_emu10k1_db_scale1;
-       ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;    
+       if (high_res_gpr_volume) {
+               ctl->min = 0;
+               ctl->max = 0x7fffffff;
+               ctl->tlv = snd_emu10k1_db_linear;
+               ctl->translation = EMU10K1_GPR_TRANSLATION_NONE;
+       } else {
+               ctl->min = 0;
+               ctl->max = 100;
+               ctl->tlv = snd_emu10k1_db_scale1;
+               ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
+       }
 }
 
 static void __devinit
@@ -1087,10 +1100,17 @@ snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
        ctl->vcount = ctl->count = 2;
        ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
        ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;
-       ctl->min = 0;
-       ctl->max = 100;
-       ctl->tlv = snd_emu10k1_db_scale1;
-       ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
+       if (high_res_gpr_volume) {
+               ctl->min = 0;
+               ctl->max = 0x7fffffff;
+               ctl->tlv = snd_emu10k1_db_linear;
+               ctl->translation = EMU10K1_GPR_TRANSLATION_NONE;
+       } else {
+               ctl->min = 0;
+               ctl->max = 100;
+               ctl->tlv = snd_emu10k1_db_scale1;
+               ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
+       }
 }
 
 static void __devinit
@@ -2493,24 +2513,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
        case SNDRV_EMU10K1_IOCTL_CODE_POKE:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               icode = kmalloc(sizeof(*icode), GFP_KERNEL);
-               if (icode == NULL)
-                       return -ENOMEM;
-               if (copy_from_user(icode, argp, sizeof(*icode))) {
-                       kfree(icode);
-                       return -EFAULT;
-               }
+
+               icode = memdup_user(argp, sizeof(*icode));
+               if (IS_ERR(icode))
+                       return PTR_ERR(icode);
                res = snd_emu10k1_icode_poke(emu, icode);
                kfree(icode);
                return res;
        case SNDRV_EMU10K1_IOCTL_CODE_PEEK:
-               icode = kmalloc(sizeof(*icode), GFP_KERNEL);
-               if (icode == NULL)
-                       return -ENOMEM;
-               if (copy_from_user(icode, argp, sizeof(*icode))) {
-                       kfree(icode);
-                       return -EFAULT;
-               }
+               icode = memdup_user(argp, sizeof(*icode));
+               if (IS_ERR(icode))
+                       return PTR_ERR(icode);
                res = snd_emu10k1_icode_peek(emu, icode);
                if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) {
                        kfree(icode);
@@ -2519,24 +2532,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
                kfree(icode);
                return res;
        case SNDRV_EMU10K1_IOCTL_PCM_POKE:
-               ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL);
-               if (ipcm == NULL)
-                       return -ENOMEM;
-               if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
-                       kfree(ipcm);
-                       return -EFAULT;
-               }
+               ipcm = memdup_user(argp, sizeof(*ipcm));
+               if (IS_ERR(ipcm))
+                       return PTR_ERR(ipcm);
                res = snd_emu10k1_ipcm_poke(emu, ipcm);
                kfree(ipcm);
                return res;
        case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
-               ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
-               if (ipcm == NULL)
-                       return -ENOMEM;
-               if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
-                       kfree(ipcm);
-                       return -EFAULT;
-               }
+               ipcm = memdup_user(argp, sizeof(*ipcm));
+               if (IS_ERR(ipcm))
+                       return PTR_ERR(ipcm);
                res = snd_emu10k1_ipcm_peek(emu, ipcm);
                if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) {
                        kfree(ipcm);