vserver 1.9.5.x5
[linux-2.6.git] / sound / pci / ac97 / ak4531_codec.c
index d33cd42..f9ce0fd 100644 (file)
@@ -72,16 +72,15 @@ static int snd_ak4531_info_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t
 static int snd_ak4531_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int reg = kcontrol->private_value & 0xff;
        int shift = (kcontrol->private_value >> 16) & 0x07;
        int mask = (kcontrol->private_value >> 24) & 0xff;
        int invert = (kcontrol->private_value >> 22) & 1;
        int val;
 
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        val = (ak4531->regs[reg] >> shift) & mask;
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        if (invert) {
                val = mask - val;
        }
@@ -92,7 +91,6 @@ static int snd_ak4531_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 static int snd_ak4531_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int reg = kcontrol->private_value & 0xff;
        int shift = (kcontrol->private_value >> 16) & 0x07;
        int mask = (kcontrol->private_value >> 24) & 0xff;
@@ -105,11 +103,11 @@ static int snd_ak4531_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
                val = mask - val;
        }
        val <<= shift;
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        val = (ak4531->regs[reg] & ~(mask << shift)) | val;
        change = val != ak4531->regs[reg];
        ak4531->write(ak4531, reg, ak4531->regs[reg] = val);
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        return change;
 }
 
@@ -133,7 +131,6 @@ static int snd_ak4531_info_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t
 static int snd_ak4531_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int left_reg = kcontrol->private_value & 0xff;
        int right_reg = (kcontrol->private_value >> 8) & 0xff;
        int left_shift = (kcontrol->private_value >> 16) & 0x07;
@@ -142,10 +139,10 @@ static int snd_ak4531_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        int invert = (kcontrol->private_value >> 22) & 1;
        int left, right;
 
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        left = (ak4531->regs[left_reg] >> left_shift) & mask;
        right = (ak4531->regs[right_reg] >> right_shift) & mask;
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        if (invert) {
                left = mask - left;
                right = mask - right;
@@ -158,7 +155,6 @@ static int snd_ak4531_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
 static int snd_ak4531_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int left_reg = kcontrol->private_value & 0xff;
        int right_reg = (kcontrol->private_value >> 8) & 0xff;
        int left_shift = (kcontrol->private_value >> 16) & 0x07;
@@ -176,7 +172,7 @@ static int snd_ak4531_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
        }
        left <<= left_shift;
        right <<= right_shift;
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        if (left_reg == right_reg) {
                left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right;
                change = left != ak4531->regs[left_reg];
@@ -188,7 +184,7 @@ static int snd_ak4531_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
                ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left);
                ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right);
        }
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        return change;
 }
 
@@ -210,25 +206,23 @@ static int snd_ak4531_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info
 static int snd_ak4531_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int reg1 = kcontrol->private_value & 0xff;
        int reg2 = (kcontrol->private_value >> 8) & 0xff;
        int left_shift = (kcontrol->private_value >> 16) & 0x0f;
        int right_shift = (kcontrol->private_value >> 24) & 0x0f;
 
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1;
        ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1;
        ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1;
        ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1;
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        return 0;
 }
 
 static int snd_ak4531_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
        ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
        int reg1 = kcontrol->private_value & 0xff;
        int reg2 = (kcontrol->private_value >> 8) & 0xff;
        int left_shift = (kcontrol->private_value >> 16) & 0x0f;
@@ -236,7 +230,7 @@ static int snd_ak4531_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
        int change;
        int val1, val2;
 
-       spin_lock_irqsave(&ak4531->reg_lock, flags);
+       down(&ak4531->reg_mutex);
        val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift));
        val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift));
        val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift;
@@ -246,7 +240,7 @@ static int snd_ak4531_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
        change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2];
        ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1);
        ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2);
-       spin_unlock_irqrestore(&ak4531->reg_lock, flags);
+       up(&ak4531->reg_mutex);
        return change;
 }
 
@@ -367,7 +361,7 @@ int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531)
        if (ak4531 == NULL)
                return -ENOMEM;
        *ak4531 = *_ak4531;
-       spin_lock_init(&ak4531->reg_lock);
+       init_MUTEX(&ak4531->reg_mutex);
        if ((err = snd_component_add(card, "AK4531")) < 0) {
                snd_ak4531_free(ak4531);
                return err;
@@ -388,7 +382,7 @@ int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531)
                }
        }
        snd_ak4531_proc_init(card, ak4531);
-       if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ak4531, &ops)) < 0) {
+       if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) {
                snd_ak4531_free(ak4531);
                return err;
        }