diff options
Diffstat (limited to 'sound/pci/ac97/ak4531_codec.c')
-rw-r--r-- | sound/pci/ac97/ak4531_codec.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c index dcfb5036ff8b..0fb7b3407312 100644 --- a/sound/pci/ac97/ak4531_codec.c +++ b/sound/pci/ac97/ak4531_codec.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/mutex.h> | ||
27 | |||
26 | #include <sound/core.h> | 28 | #include <sound/core.h> |
27 | #include <sound/ak4531_codec.h> | 29 | #include <sound/ak4531_codec.h> |
28 | 30 | ||
@@ -82,9 +84,9 @@ static int snd_ak4531_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
82 | int invert = (kcontrol->private_value >> 22) & 1; | 84 | int invert = (kcontrol->private_value >> 22) & 1; |
83 | int val; | 85 | int val; |
84 | 86 | ||
85 | down(&ak4531->reg_mutex); | 87 | mutex_lock(&ak4531->reg_mutex); |
86 | val = (ak4531->regs[reg] >> shift) & mask; | 88 | val = (ak4531->regs[reg] >> shift) & mask; |
87 | up(&ak4531->reg_mutex); | 89 | mutex_unlock(&ak4531->reg_mutex); |
88 | if (invert) { | 90 | if (invert) { |
89 | val = mask - val; | 91 | val = mask - val; |
90 | } | 92 | } |
@@ -107,11 +109,11 @@ static int snd_ak4531_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
107 | val = mask - val; | 109 | val = mask - val; |
108 | } | 110 | } |
109 | val <<= shift; | 111 | val <<= shift; |
110 | down(&ak4531->reg_mutex); | 112 | mutex_lock(&ak4531->reg_mutex); |
111 | val = (ak4531->regs[reg] & ~(mask << shift)) | val; | 113 | val = (ak4531->regs[reg] & ~(mask << shift)) | val; |
112 | change = val != ak4531->regs[reg]; | 114 | change = val != ak4531->regs[reg]; |
113 | ak4531->write(ak4531, reg, ak4531->regs[reg] = val); | 115 | ak4531->write(ak4531, reg, ak4531->regs[reg] = val); |
114 | up(&ak4531->reg_mutex); | 116 | mutex_unlock(&ak4531->reg_mutex); |
115 | return change; | 117 | return change; |
116 | } | 118 | } |
117 | 119 | ||
@@ -143,10 +145,10 @@ static int snd_ak4531_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
143 | int invert = (kcontrol->private_value >> 22) & 1; | 145 | int invert = (kcontrol->private_value >> 22) & 1; |
144 | int left, right; | 146 | int left, right; |
145 | 147 | ||
146 | down(&ak4531->reg_mutex); | 148 | mutex_lock(&ak4531->reg_mutex); |
147 | left = (ak4531->regs[left_reg] >> left_shift) & mask; | 149 | left = (ak4531->regs[left_reg] >> left_shift) & mask; |
148 | right = (ak4531->regs[right_reg] >> right_shift) & mask; | 150 | right = (ak4531->regs[right_reg] >> right_shift) & mask; |
149 | up(&ak4531->reg_mutex); | 151 | mutex_unlock(&ak4531->reg_mutex); |
150 | if (invert) { | 152 | if (invert) { |
151 | left = mask - left; | 153 | left = mask - left; |
152 | right = mask - right; | 154 | right = mask - right; |
@@ -176,7 +178,7 @@ static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
176 | } | 178 | } |
177 | left <<= left_shift; | 179 | left <<= left_shift; |
178 | right <<= right_shift; | 180 | right <<= right_shift; |
179 | down(&ak4531->reg_mutex); | 181 | mutex_lock(&ak4531->reg_mutex); |
180 | if (left_reg == right_reg) { | 182 | if (left_reg == right_reg) { |
181 | left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right; | 183 | left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right; |
182 | change = left != ak4531->regs[left_reg]; | 184 | change = left != ak4531->regs[left_reg]; |
@@ -188,7 +190,7 @@ static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
188 | ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left); | 190 | ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left); |
189 | ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right); | 191 | ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right); |
190 | } | 192 | } |
191 | up(&ak4531->reg_mutex); | 193 | mutex_unlock(&ak4531->reg_mutex); |
192 | return change; | 194 | return change; |
193 | } | 195 | } |
194 | 196 | ||
@@ -215,12 +217,12 @@ static int snd_ak4531_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl | |||
215 | int left_shift = (kcontrol->private_value >> 16) & 0x0f; | 217 | int left_shift = (kcontrol->private_value >> 16) & 0x0f; |
216 | int right_shift = (kcontrol->private_value >> 24) & 0x0f; | 218 | int right_shift = (kcontrol->private_value >> 24) & 0x0f; |
217 | 219 | ||
218 | down(&ak4531->reg_mutex); | 220 | mutex_lock(&ak4531->reg_mutex); |
219 | ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1; | 221 | ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1; |
220 | ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1; | 222 | ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1; |
221 | ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1; | 223 | ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1; |
222 | ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1; | 224 | ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1; |
223 | up(&ak4531->reg_mutex); | 225 | mutex_unlock(&ak4531->reg_mutex); |
224 | return 0; | 226 | return 0; |
225 | } | 227 | } |
226 | 228 | ||
@@ -234,7 +236,7 @@ static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl | |||
234 | int change; | 236 | int change; |
235 | int val1, val2; | 237 | int val1, val2; |
236 | 238 | ||
237 | down(&ak4531->reg_mutex); | 239 | mutex_lock(&ak4531->reg_mutex); |
238 | val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift)); | 240 | val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift)); |
239 | val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift)); | 241 | val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift)); |
240 | val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift; | 242 | val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift; |
@@ -244,7 +246,7 @@ static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl | |||
244 | change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2]; | 246 | change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2]; |
245 | ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1); | 247 | ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1); |
246 | ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2); | 248 | ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2); |
247 | up(&ak4531->reg_mutex); | 249 | mutex_unlock(&ak4531->reg_mutex); |
248 | return change; | 250 | return change; |
249 | } | 251 | } |
250 | 252 | ||
@@ -366,7 +368,7 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, | |||
366 | if (ak4531 == NULL) | 368 | if (ak4531 == NULL) |
367 | return -ENOMEM; | 369 | return -ENOMEM; |
368 | *ak4531 = *_ak4531; | 370 | *ak4531 = *_ak4531; |
369 | init_MUTEX(&ak4531->reg_mutex); | 371 | mutex_init(&ak4531->reg_mutex); |
370 | if ((err = snd_component_add(card, "AK4531")) < 0) { | 372 | if ((err = snd_component_add(card, "AK4531")) < 0) { |
371 | snd_ak4531_free(ak4531); | 373 | snd_ak4531_free(ak4531); |
372 | return err; | 374 | return err; |