aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/emu10k1/emumixer.c60
1 files changed, 51 insertions, 9 deletions
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 54a2034d8edd..88eab4a461bd 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -58,6 +58,9 @@ static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol,
58 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 58 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
59 unsigned long flags; 59 unsigned long flags;
60 60
61 /* Limit: emu->spdif_bits */
62 if (idx >= 3)
63 return -EINVAL;
61 spin_lock_irqsave(&emu->reg_lock, flags); 64 spin_lock_irqsave(&emu->reg_lock, flags);
62 ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; 65 ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff;
63 ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff; 66 ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff;
@@ -272,9 +275,12 @@ static int snd_emu1010_output_source_get(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_value *ucontrol) 275 struct snd_ctl_elem_value *ucontrol)
273{ 276{
274 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 277 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
275 int channel; 278 unsigned int channel;
276 279
277 channel = (kcontrol->private_value) & 0xff; 280 channel = (kcontrol->private_value) & 0xff;
281 /* Limit: emu1010_output_dst, emu->emu1010.output_source */
282 if (channel >= 24)
283 return -EINVAL;
278 ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel]; 284 ucontrol->value.enumerated.item[0] = emu->emu1010.output_source[channel];
279 return 0; 285 return 0;
280} 286}
@@ -285,9 +291,12 @@ static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol,
285 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 291 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
286 int change = 0; 292 int change = 0;
287 unsigned int val; 293 unsigned int val;
288 int channel; 294 unsigned int channel;
289 295
290 channel = (kcontrol->private_value) & 0xff; 296 channel = (kcontrol->private_value) & 0xff;
297 /* Limit: emu1010_output_dst, emu->emu1010.output_source */
298 if (channel >= 24)
299 return -EINVAL;
291 if (emu->emu1010.output_source[channel] != ucontrol->value.enumerated.item[0]) { 300 if (emu->emu1010.output_source[channel] != ucontrol->value.enumerated.item[0]) {
292 val = emu->emu1010.output_source[channel] = ucontrol->value.enumerated.item[0]; 301 val = emu->emu1010.output_source[channel] = ucontrol->value.enumerated.item[0];
293 change = 1; 302 change = 1;
@@ -301,9 +310,12 @@ static int snd_emu1010_input_source_get(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_value *ucontrol) 310 struct snd_ctl_elem_value *ucontrol)
302{ 311{
303 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 312 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
304 int channel; 313 unsigned int channel;
305 314
306 channel = (kcontrol->private_value) & 0xff; 315 channel = (kcontrol->private_value) & 0xff;
316 /* Limit: emu1010_input_dst, emu->emu1010.input_source */
317 if (channel >= 22)
318 return -EINVAL;
307 ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel]; 319 ucontrol->value.enumerated.item[0] = emu->emu1010.input_source[channel];
308 return 0; 320 return 0;
309} 321}
@@ -314,9 +326,12 @@ static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol,
314 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 326 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
315 int change = 0; 327 int change = 0;
316 unsigned int val; 328 unsigned int val;
317 int channel; 329 unsigned int channel;
318 330
319 channel = (kcontrol->private_value) & 0xff; 331 channel = (kcontrol->private_value) & 0xff;
332 /* Limit: emu1010_input_dst, emu->emu1010.input_source */
333 if (channel >= 22)
334 return -EINVAL;
320 if (emu->emu1010.input_source[channel] != ucontrol->value.enumerated.item[0]) { 335 if (emu->emu1010.input_source[channel] != ucontrol->value.enumerated.item[0]) {
321 val = emu->emu1010.input_source[channel] = ucontrol->value.enumerated.item[0]; 336 val = emu->emu1010.input_source[channel] = ucontrol->value.enumerated.item[0];
322 change = 1; 337 change = 1;
@@ -533,6 +548,9 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
533 int change = 0; 548 int change = 0;
534 549
535 val = ucontrol->value.enumerated.item[0] ; 550 val = ucontrol->value.enumerated.item[0] ;
551 /* Limit: uinfo->value.enumerated.items = 4; */
552 if (val >= 4)
553 return -EINVAL;
536 change = (emu->emu1010.internal_clock != val); 554 change = (emu->emu1010.internal_clock != val);
537 if (change) { 555 if (change) {
538 emu->emu1010.internal_clock = val; 556 emu->emu1010.internal_clock = val;
@@ -669,7 +687,11 @@ static int snd_audigy_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
669 * update the capture volume from the cached value 687 * update the capture volume from the cached value
670 * for the particular source. 688 * for the particular source.
671 */ 689 */
672 source_id = ucontrol->value.enumerated.item[0]; /* Use 2 and 3 */ 690 source_id = ucontrol->value.enumerated.item[0];
691 /* Limit: uinfo->value.enumerated.items = 2; */
692 /* emu->i2c_capture_volume */
693 if (source_id >= 2)
694 return -EINVAL;
673 change = (emu->i2c_capture_source != source_id); 695 change = (emu->i2c_capture_source != source_id);
674 if (change) { 696 if (change) {
675 snd_emu10k1_i2c_write(emu, ADC_MUX, 0); /* Mute input */ 697 snd_emu10k1_i2c_write(emu, ADC_MUX, 0); /* Mute input */
@@ -720,9 +742,13 @@ static int snd_audigy_i2c_volume_get(struct snd_kcontrol *kcontrol,
720 struct snd_ctl_elem_value *ucontrol) 742 struct snd_ctl_elem_value *ucontrol)
721{ 743{
722 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 744 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
723 int source_id; 745 unsigned int source_id;
724 746
725 source_id = kcontrol->private_value; 747 source_id = kcontrol->private_value;
748 /* Limit: emu->i2c_capture_volume */
749 /* capture_source: uinfo->value.enumerated.items = 2 */
750 if (source_id >= 2)
751 return -EINVAL;
726 752
727 ucontrol->value.integer.value[0] = emu->i2c_capture_volume[source_id][0]; 753 ucontrol->value.integer.value[0] = emu->i2c_capture_volume[source_id][0];
728 ucontrol->value.integer.value[1] = emu->i2c_capture_volume[source_id][1]; 754 ucontrol->value.integer.value[1] = emu->i2c_capture_volume[source_id][1];
@@ -735,10 +761,14 @@ static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
735 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 761 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
736 unsigned int ogain; 762 unsigned int ogain;
737 unsigned int ngain; 763 unsigned int ngain;
738 int source_id; 764 unsigned int source_id;
739 int change = 0; 765 int change = 0;
740 766
741 source_id = kcontrol->private_value; 767 source_id = kcontrol->private_value;
768 /* Limit: emu->i2c_capture_volume */
769 /* capture_source: uinfo->value.enumerated.items = 2 */
770 if (source_id >= 2)
771 return -EINVAL;
742 ogain = emu->i2c_capture_volume[source_id][0]; /* Left */ 772 ogain = emu->i2c_capture_volume[source_id][0]; /* Left */
743 ngain = ucontrol->value.integer.value[0]; 773 ngain = ucontrol->value.integer.value[0];
744 if (ngain > 0xff) 774 if (ngain > 0xff)
@@ -746,7 +776,7 @@ static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
746 if (ogain != ngain) { 776 if (ogain != ngain) {
747 if (emu->i2c_capture_source == source_id) 777 if (emu->i2c_capture_source == source_id)
748 snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff) ); 778 snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff) );
749 emu->i2c_capture_volume[source_id][0] = ucontrol->value.integer.value[0]; 779 emu->i2c_capture_volume[source_id][0] = ngain;
750 change = 1; 780 change = 1;
751 } 781 }
752 ogain = emu->i2c_capture_volume[source_id][1]; /* Right */ 782 ogain = emu->i2c_capture_volume[source_id][1]; /* Right */
@@ -756,7 +786,7 @@ static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol,
756 if (ogain != ngain) { 786 if (ogain != ngain) {
757 if (emu->i2c_capture_source == source_id) 787 if (emu->i2c_capture_source == source_id)
758 snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff)); 788 snd_emu10k1_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
759 emu->i2c_capture_volume[source_id][1] = ucontrol->value.integer.value[1]; 789 emu->i2c_capture_volume[source_id][1] = ngain;
760 change = 1; 790 change = 1;
761 } 791 }
762 792
@@ -877,6 +907,9 @@ static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol,
877 unsigned int val; 907 unsigned int val;
878 unsigned long flags; 908 unsigned long flags;
879 909
910 /* Limit: emu->spdif_bits */
911 if (idx >= 3)
912 return -EINVAL;
880 val = (ucontrol->value.iec958.status[0] << 0) | 913 val = (ucontrol->value.iec958.status[0] << 0) |
881 (ucontrol->value.iec958.status[1] << 8) | 914 (ucontrol->value.iec958.status[1] << 8) |
882 (ucontrol->value.iec958.status[2] << 16) | 915 (ucontrol->value.iec958.status[2] << 16) |
@@ -1050,6 +1083,7 @@ static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol,
1050{ 1083{
1051 unsigned long flags; 1084 unsigned long flags;
1052 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1085 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1086 /* FIXME: Check limits */
1053 struct snd_emu10k1_pcm_mixer *mix = 1087 struct snd_emu10k1_pcm_mixer *mix =
1054 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1088 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1055 int change = 0, idx, val; 1089 int change = 0, idx, val;
@@ -1102,6 +1136,7 @@ static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol,
1102 struct snd_ctl_elem_value *ucontrol) 1136 struct snd_ctl_elem_value *ucontrol)
1103{ 1137{
1104 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1138 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1139 /* FIXME: Check limits */
1105 struct snd_emu10k1_pcm_mixer *mix = 1140 struct snd_emu10k1_pcm_mixer *mix =
1106 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1141 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1107 unsigned long flags; 1142 unsigned long flags;
@@ -1119,6 +1154,7 @@ static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol,
1119{ 1154{
1120 unsigned long flags; 1155 unsigned long flags;
1121 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1156 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1157 /* FIXME: Check limits */
1122 struct snd_emu10k1_pcm_mixer *mix = 1158 struct snd_emu10k1_pcm_mixer *mix =
1123 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1159 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1124 int change = 0, idx, val; 1160 int change = 0, idx, val;
@@ -1171,6 +1207,7 @@ static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol,
1171{ 1207{
1172 unsigned long flags; 1208 unsigned long flags;
1173 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1209 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1210 /* FIXME: Check limits */
1174 struct snd_emu10k1_pcm_mixer *mix = 1211 struct snd_emu10k1_pcm_mixer *mix =
1175 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1212 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1176 int idx; 1213 int idx;
@@ -1190,6 +1227,7 @@ static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol,
1190{ 1227{
1191 unsigned long flags; 1228 unsigned long flags;
1192 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1229 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1230 /* FIXME: Check limits */
1193 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1231 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1194 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; 1232 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1195 int change = 0, idx, val; 1233 int change = 0, idx, val;
@@ -1241,6 +1279,7 @@ static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol,
1241{ 1279{
1242 unsigned long flags; 1280 unsigned long flags;
1243 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1281 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1282 /* FIXME: Check limits */
1244 struct snd_emu10k1_pcm_mixer *mix = 1283 struct snd_emu10k1_pcm_mixer *mix =
1245 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1284 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1246 int idx; 1285 int idx;
@@ -1258,6 +1297,7 @@ static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol,
1258{ 1297{
1259 unsigned long flags; 1298 unsigned long flags;
1260 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1299 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1300 /* FIXME: Check limits */
1261 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1301 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1262 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; 1302 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1263 int change = 0, idx, val; 1303 int change = 0, idx, val;
@@ -1306,6 +1346,7 @@ static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol,
1306 struct snd_ctl_elem_value *ucontrol) 1346 struct snd_ctl_elem_value *ucontrol)
1307{ 1347{
1308 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1348 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1349 /* FIXME: Check limits */
1309 struct snd_emu10k1_pcm_mixer *mix = 1350 struct snd_emu10k1_pcm_mixer *mix =
1310 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; 1351 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)];
1311 unsigned long flags; 1352 unsigned long flags;
@@ -1321,6 +1362,7 @@ static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol,
1321{ 1362{
1322 unsigned long flags; 1363 unsigned long flags;
1323 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); 1364 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1365 /* FIXME: Check limits */
1324 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1366 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1325 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; 1367 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1326 int change = 0, val; 1368 int change = 0, val;