forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/emu10k1/emufx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
34 * Creative Labs, Inc.
....@@ -11,21 +12,6 @@
1112 *
1213 * TODO:
1314 * --
14
- *
15
- * This program is free software; you can redistribute it and/or modify
16
- * it under the terms of the GNU General Public License as published by
17
- * the Free Software Foundation; either version 2 of the License, or
18
- * (at your option) any later version.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License
26
- * along with this program; if not, write to the Free Software
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
- *
2915 */
3016
3117 #include <linux/pci.h>
....@@ -60,7 +46,7 @@
6046 * Tables
6147 */
6248
63
-static char *fxbuses[16] = {
49
+static const char * const fxbuses[16] = {
6450 /* 0x00 */ "PCM Left",
6551 /* 0x01 */ "PCM Right",
6652 /* 0x02 */ "PCM Surround Left",
....@@ -79,7 +65,7 @@
7965 /* 0x0f */ NULL
8066 };
8167
82
-static char *creative_ins[16] = {
68
+static const char * const creative_ins[16] = {
8369 /* 0x00 */ "AC97 Left",
8470 /* 0x01 */ "AC97 Right",
8571 /* 0x02 */ "TTL IEC958 Left",
....@@ -98,7 +84,7 @@
9884 /* 0x0f */ NULL
9985 };
10086
101
-static char *audigy_ins[16] = {
87
+static const char * const audigy_ins[16] = {
10288 /* 0x00 */ "AC97 Left",
10389 /* 0x01 */ "AC97 Right",
10490 /* 0x02 */ "Audigy CD Left",
....@@ -117,7 +103,7 @@
117103 /* 0x0f */ NULL
118104 };
119105
120
-static char *creative_outs[32] = {
106
+static const char * const creative_outs[32] = {
121107 /* 0x00 */ "AC97 Left",
122108 /* 0x01 */ "AC97 Right",
123109 /* 0x02 */ "Optical IEC958 Left",
....@@ -152,7 +138,7 @@
152138 /* 0x1f */ NULL,
153139 };
154140
155
-static char *audigy_outs[32] = {
141
+static const char * const audigy_outs[32] = {
156142 /* 0x00 */ "Digital Front Left",
157143 /* 0x01 */ "Digital Front Right",
158144 /* 0x02 */ "Digital Center",
....@@ -477,7 +463,7 @@
477463 u_int32_t *code;
478464 if (snd_BUG_ON(*ptr >= 512))
479465 return;
480
- code = (u_int32_t __force *)icode->code + (*ptr) * 2;
466
+ code = icode->code + (*ptr) * 2;
481467 set_bit(*ptr, icode->code_valid);
482468 code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
483469 code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
....@@ -494,7 +480,7 @@
494480 u_int32_t *code;
495481 if (snd_BUG_ON(*ptr >= 1024))
496482 return;
497
- code = (u_int32_t __force *)icode->code + (*ptr) * 2;
483
+ code = icode->code + (*ptr) * 2;
498484 set_bit(*ptr, icode->code_valid);
499485 code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
500486 code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
....@@ -527,8 +513,8 @@
527513 if (!test_bit(gpr, icode->gpr_valid))
528514 continue;
529515 if (in_kernel)
530
- val = *(__force u32 *)&icode->gpr_map[gpr];
531
- else if (get_user(val, &icode->gpr_map[gpr]))
516
+ val = icode->gpr_map[gpr];
517
+ else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr]))
532518 return -EFAULT;
533519 snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val);
534520 }
....@@ -544,7 +530,7 @@
544530 for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
545531 set_bit(gpr, icode->gpr_valid);
546532 val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0);
547
- if (put_user(val, &icode->gpr_map[gpr]))
533
+ if (put_user(val, (__user u32 *)&icode->gpr_map[gpr]))
548534 return -EFAULT;
549535 }
550536 return 0;
....@@ -561,11 +547,11 @@
561547 if (!test_bit(tram, icode->tram_valid))
562548 continue;
563549 if (in_kernel) {
564
- val = *(__force u32 *)&icode->tram_data_map[tram];
565
- addr = *(__force u32 *)&icode->tram_addr_map[tram];
550
+ val = icode->tram_data_map[tram];
551
+ addr = icode->tram_addr_map[tram];
566552 } else {
567
- if (get_user(val, &icode->tram_data_map[tram]) ||
568
- get_user(addr, &icode->tram_addr_map[tram]))
553
+ if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) ||
554
+ get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram]))
569555 return -EFAULT;
570556 }
571557 snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, val);
....@@ -595,8 +581,8 @@
595581 addr = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0) >> 12;
596582 addr |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20;
597583 }
598
- if (put_user(val, &icode->tram_data_map[tram]) ||
599
- put_user(addr, &icode->tram_addr_map[tram]))
584
+ if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) ||
585
+ put_user(addr, (__user u32 *)&icode->tram_addr_map[tram]))
600586 return -EFAULT;
601587 }
602588 return 0;
....@@ -612,11 +598,11 @@
612598 if (!test_bit(pc / 2, icode->code_valid))
613599 continue;
614600 if (in_kernel) {
615
- lo = *(__force u32 *)&icode->code[pc + 0];
616
- hi = *(__force u32 *)&icode->code[pc + 1];
601
+ lo = icode->code[pc + 0];
602
+ hi = icode->code[pc + 1];
617603 } else {
618
- if (get_user(lo, &icode->code[pc + 0]) ||
619
- get_user(hi, &icode->code[pc + 1]))
604
+ if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) ||
605
+ get_user(hi, (__user u32 *)&icode->code[pc + 1]))
620606 return -EFAULT;
621607 }
622608 snd_emu10k1_efx_write(emu, pc + 0, lo);
....@@ -633,17 +619,21 @@
633619 memset(icode->code_valid, 0, sizeof(icode->code_valid));
634620 for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) {
635621 set_bit(pc / 2, icode->code_valid);
636
- if (put_user(snd_emu10k1_efx_read(emu, pc + 0), &icode->code[pc + 0]))
622
+ if (put_user(snd_emu10k1_efx_read(emu, pc + 0),
623
+ (__user u32 *)&icode->code[pc + 0]))
637624 return -EFAULT;
638
- if (put_user(snd_emu10k1_efx_read(emu, pc + 1), &icode->code[pc + 1]))
625
+ if (put_user(snd_emu10k1_efx_read(emu, pc + 1),
626
+ (__user u32 *)&icode->code[pc + 1]))
639627 return -EFAULT;
640628 }
641629 return 0;
642630 }
643631
644632 static struct snd_emu10k1_fx8010_ctl *
645
-snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id)
633
+snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu,
634
+ struct emu10k1_ctl_elem_id *_id)
646635 {
636
+ struct snd_ctl_elem_id *id = (struct snd_ctl_elem_id *)_id;
647637 struct snd_emu10k1_fx8010_ctl *ctl;
648638 struct snd_kcontrol *kcontrol;
649639
....@@ -686,41 +676,60 @@
686676 }
687677
688678 static int copy_gctl(struct snd_emu10k1 *emu,
689
- struct snd_emu10k1_fx8010_control_gpr *gctl,
690
- struct snd_emu10k1_fx8010_control_gpr __user *_gctl,
679
+ struct snd_emu10k1_fx8010_control_gpr *dst,
680
+ struct snd_emu10k1_fx8010_control_gpr *src,
691681 int idx, bool in_kernel)
692682 {
693
- struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
683
+ struct snd_emu10k1_fx8010_control_gpr __user *_src;
684
+ struct snd_emu10k1_fx8010_control_old_gpr *octl;
685
+ struct snd_emu10k1_fx8010_control_old_gpr __user *_octl;
694686
687
+ _src = (struct snd_emu10k1_fx8010_control_gpr __user *)src;
695688 if (emu->support_tlv) {
696689 if (in_kernel)
697
- memcpy(gctl, (__force void *)&_gctl[idx], sizeof(*gctl));
698
- else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)))
690
+ *dst = src[idx];
691
+ else if (copy_from_user(dst, &_src[idx], sizeof(*src)))
699692 return -EFAULT;
700693 return 0;
701694 }
702695
703
- octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
696
+ octl = (struct snd_emu10k1_fx8010_control_old_gpr *)src;
697
+ _octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)octl;
704698 if (in_kernel)
705
- memcpy(gctl, (__force void *)&octl[idx], sizeof(*octl));
706
- else if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
699
+ memcpy(dst, &octl[idx], sizeof(*octl));
700
+ else if (copy_from_user(dst, &_octl[idx], sizeof(*octl)))
707701 return -EFAULT;
708
- gctl->tlv = NULL;
702
+ dst->tlv = NULL;
709703 return 0;
710704 }
711705
712706 static int copy_gctl_to_user(struct snd_emu10k1 *emu,
713
- struct snd_emu10k1_fx8010_control_gpr __user *_gctl,
714
- struct snd_emu10k1_fx8010_control_gpr *gctl,
707
+ struct snd_emu10k1_fx8010_control_gpr *dst,
708
+ struct snd_emu10k1_fx8010_control_gpr *src,
715709 int idx)
716710 {
711
+ struct snd_emu10k1_fx8010_control_gpr __user *_dst;
717712 struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
718713
714
+ _dst = (struct snd_emu10k1_fx8010_control_gpr __user *)dst;
719715 if (emu->support_tlv)
720
- return copy_to_user(&_gctl[idx], gctl, sizeof(*gctl));
716
+ return copy_to_user(&_dst[idx], src, sizeof(*src));
721717
722
- octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
723
- return copy_to_user(&octl[idx], gctl, sizeof(*octl));
718
+ octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)dst;
719
+ return copy_to_user(&octl[idx], src, sizeof(*octl));
720
+}
721
+
722
+static int copy_ctl_elem_id(const struct emu10k1_ctl_elem_id *list, int i,
723
+ struct emu10k1_ctl_elem_id *ret, bool in_kernel)
724
+{
725
+ struct emu10k1_ctl_elem_id __user *_id =
726
+ (struct emu10k1_ctl_elem_id __user *)&list[i];
727
+
728
+ if (in_kernel)
729
+ *ret = list[i];
730
+ else if (copy_from_user(ret, _id, sizeof(*ret)))
731
+ return -EFAULT;
732
+ return 0;
724733 }
725734
726735 static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
....@@ -728,17 +737,16 @@
728737 bool in_kernel)
729738 {
730739 unsigned int i;
731
- struct snd_ctl_elem_id __user *_id;
732
- struct snd_ctl_elem_id id;
740
+ struct emu10k1_ctl_elem_id id;
733741 struct snd_emu10k1_fx8010_control_gpr *gctl;
742
+ struct snd_ctl_elem_id *gctl_id;
734743 int err;
735744
736
- for (i = 0, _id = icode->gpr_del_controls;
737
- i < icode->gpr_del_control_count; i++, _id++) {
738
- if (in_kernel)
739
- id = *(__force struct snd_ctl_elem_id *)_id;
740
- else if (copy_from_user(&id, _id, sizeof(id)))
741
- return -EFAULT;
745
+ for (i = 0; i < icode->gpr_del_control_count; i++) {
746
+ err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id,
747
+ in_kernel);
748
+ if (err < 0)
749
+ return err;
742750 if (snd_emu10k1_look_for_ctl(emu, &id) == NULL)
743751 return -ENOENT;
744752 }
....@@ -754,15 +762,16 @@
754762 }
755763 if (snd_emu10k1_look_for_ctl(emu, &gctl->id))
756764 continue;
765
+ gctl_id = (struct snd_ctl_elem_id *)&gctl->id;
757766 down_read(&emu->card->controls_rwsem);
758
- if (snd_ctl_find_id(emu->card, &gctl->id) != NULL) {
767
+ if (snd_ctl_find_id(emu->card, gctl_id)) {
759768 up_read(&emu->card->controls_rwsem);
760769 err = -EEXIST;
761770 goto __error;
762771 }
763772 up_read(&emu->card->controls_rwsem);
764
- if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
765
- gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) {
773
+ if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
774
+ gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) {
766775 err = -EINVAL;
767776 goto __error;
768777 }
....@@ -797,6 +806,7 @@
797806 {
798807 unsigned int i, j;
799808 struct snd_emu10k1_fx8010_control_gpr *gctl;
809
+ struct snd_ctl_elem_id *gctl_id;
800810 struct snd_emu10k1_fx8010_ctl *ctl, *nctl;
801811 struct snd_kcontrol_new knew;
802812 struct snd_kcontrol *kctl;
....@@ -817,24 +827,25 @@
817827 err = -EFAULT;
818828 goto __error;
819829 }
820
- if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
821
- gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) {
830
+ gctl_id = (struct snd_ctl_elem_id *)&gctl->id;
831
+ if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
832
+ gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) {
822833 err = -EINVAL;
823834 goto __error;
824835 }
825
- if (! gctl->id.name[0]) {
836
+ if (!*gctl_id->name) {
826837 err = -EINVAL;
827838 goto __error;
828839 }
829840 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id);
830841 memset(&knew, 0, sizeof(knew));
831
- knew.iface = gctl->id.iface;
832
- knew.name = gctl->id.name;
833
- knew.index = gctl->id.index;
834
- knew.device = gctl->id.device;
835
- knew.subdevice = gctl->id.subdevice;
842
+ knew.iface = gctl_id->iface;
843
+ knew.name = gctl_id->name;
844
+ knew.index = gctl_id->index;
845
+ knew.device = gctl_id->device;
846
+ knew.subdevice = gctl_id->subdevice;
836847 knew.info = snd_emu10k1_gpr_ctl_info;
837
- knew.tlv.p = copy_tlv((__force const unsigned int __user *)gctl->tlv, in_kernel);
848
+ knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel);
838849 if (knew.tlv.p)
839850 knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
840851 SNDRV_CTL_ELEM_ACCESS_TLV_READ;
....@@ -890,17 +901,16 @@
890901 bool in_kernel)
891902 {
892903 unsigned int i;
893
- struct snd_ctl_elem_id id;
894
- struct snd_ctl_elem_id __user *_id;
904
+ struct emu10k1_ctl_elem_id id;
895905 struct snd_emu10k1_fx8010_ctl *ctl;
896906 struct snd_card *card = emu->card;
907
+ int err;
897908
898
- for (i = 0, _id = icode->gpr_del_controls;
899
- i < icode->gpr_del_control_count; i++, _id++) {
900
- if (in_kernel)
901
- id = *(__force struct snd_ctl_elem_id *)_id;
902
- else if (copy_from_user(&id, _id, sizeof(id)))
903
- return -EFAULT;
909
+ for (i = 0; i < icode->gpr_del_control_count; i++) {
910
+ err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id,
911
+ in_kernel);
912
+ if (err < 0)
913
+ return err;
904914 down_write(&card->controls_rwsem);
905915 ctl = snd_emu10k1_look_for_ctl(emu, &id);
906916 if (ctl)
....@@ -929,7 +939,7 @@
929939 i < icode->gpr_list_control_count) {
930940 memset(gctl, 0, sizeof(*gctl));
931941 id = &ctl->kcontrol->id;
932
- gctl->id.iface = id->iface;
942
+ gctl->id.iface = (__force int)id->iface;
933943 strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name));
934944 gctl->id.index = id->index;
935945 gctl->id.device = id->device;
....@@ -1107,7 +1117,7 @@
11071117 snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
11081118 const char *name, int gpr, int defval)
11091119 {
1110
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1120
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
11111121 strcpy(ctl->id.name, name);
11121122 ctl->vcount = ctl->count = 1;
11131123 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
....@@ -1128,7 +1138,7 @@
11281138 snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
11291139 const char *name, int gpr, int defval)
11301140 {
1131
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1141
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
11321142 strcpy(ctl->id.name, name);
11331143 ctl->vcount = ctl->count = 2;
11341144 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
....@@ -1150,7 +1160,7 @@
11501160 snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
11511161 const char *name, int gpr, int defval)
11521162 {
1153
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1163
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
11541164 strcpy(ctl->id.name, name);
11551165 ctl->vcount = ctl->count = 1;
11561166 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
....@@ -1163,7 +1173,7 @@
11631173 snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
11641174 const char *name, int gpr, int defval)
11651175 {
1166
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1176
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
11671177 strcpy(ctl->id.name, name);
11681178 ctl->vcount = ctl->count = 2;
11691179 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
....@@ -1216,8 +1226,8 @@
12161226 if (!icode)
12171227 return err;
12181228
1219
- icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024,
1220
- sizeof(u_int32_t), GFP_KERNEL);
1229
+ icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
1230
+ sizeof(u_int32_t), GFP_KERNEL);
12211231 if (!icode->gpr_map)
12221232 goto __err_gpr;
12231233 controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
....@@ -1225,7 +1235,7 @@
12251235 if (!controls)
12261236 goto __err_ctrls;
12271237
1228
- gpr_map = (u32 __force *)icode->gpr_map;
1238
+ gpr_map = icode->gpr_map;
12291239
12301240 icode->tram_data_map = icode->gpr_map + 512;
12311241 icode->tram_addr_map = icode->tram_data_map + 256;
....@@ -1480,7 +1490,7 @@
14801490
14811491
14821492 ctl = &controls[nctl + 0];
1483
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1493
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
14841494 strcpy(ctl->id.name, "Tone Control - Bass");
14851495 ctl->vcount = 2;
14861496 ctl->count = 10;
....@@ -1489,7 +1499,7 @@
14891499 ctl->value[0] = ctl->value[1] = 20;
14901500 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS;
14911501 ctl = &controls[nctl + 1];
1492
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1502
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
14931503 strcpy(ctl->id.name, "Tone Control - Treble");
14941504 ctl->vcount = 2;
14951505 ctl->count = 10;
....@@ -1550,14 +1560,8 @@
15501560 gpr += 2;
15511561
15521562 /* Master volume (will be renamed later) */
1553
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+0+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+0+SND_EMU10K1_PLAYBACK_CHANNELS));
1554
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+1+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+1+SND_EMU10K1_PLAYBACK_CHANNELS));
1555
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+2+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+2+SND_EMU10K1_PLAYBACK_CHANNELS));
1556
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+3+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+3+SND_EMU10K1_PLAYBACK_CHANNELS));
1557
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+4+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+4+SND_EMU10K1_PLAYBACK_CHANNELS));
1558
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+5+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+5+SND_EMU10K1_PLAYBACK_CHANNELS));
1559
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+6+SND_EMU10K1_PLAYBACK_CHANNELS));
1560
- A_OP(icode, &ptr, iMAC0, A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+7+SND_EMU10K1_PLAYBACK_CHANNELS));
1563
+ for (z = 0; z < 8; z++)
1564
+ A_OP(icode, &ptr, iMAC0, A_GPR(playback+z+SND_EMU10K1_PLAYBACK_CHANNELS), A_C_00000000, A_GPR(gpr), A_GPR(playback+z+SND_EMU10K1_PLAYBACK_CHANNELS));
15611565 snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);
15621566 gpr += 2;
15631567
....@@ -1641,102 +1645,14 @@
16411645 dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n",
16421646 gpr, tmp);
16431647 */
1644
- /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
1645
- /* A_P16VIN(0) is delayed by one sample,
1646
- * so all other A_P16VIN channels will need to also be delayed
1647
- */
1648
- /* Left ADC in. 1 of 2 */
16491648 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_P16VIN(0x0), A_FXBUS2(0) );
1650
- /* Right ADC in 1 of 2 */
1651
- gpr_map[gpr++] = 0x00000000;
1652
- /* Delaying by one sample: instead of copying the input
1653
- * value A_P16VIN to output A_FXBUS2 as in the first channel,
1654
- * we use an auxiliary register, delaying the value by one
1655
- * sample
1656
- */
1657
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(2) );
1658
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
1659
- gpr_map[gpr++] = 0x00000000;
1660
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(4) );
1661
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x2), A_C_00000000, A_C_00000000);
1662
- gpr_map[gpr++] = 0x00000000;
1663
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(6) );
1664
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x3), A_C_00000000, A_C_00000000);
1665
- /* For 96kHz mode */
1666
- /* Left ADC in. 2 of 2 */
1667
- gpr_map[gpr++] = 0x00000000;
1668
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0x8) );
1669
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x4), A_C_00000000, A_C_00000000);
1670
- /* Right ADC in 2 of 2 */
1671
- gpr_map[gpr++] = 0x00000000;
1672
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xa) );
1673
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x5), A_C_00000000, A_C_00000000);
1674
- gpr_map[gpr++] = 0x00000000;
1675
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xc) );
1676
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x6), A_C_00000000, A_C_00000000);
1677
- gpr_map[gpr++] = 0x00000000;
1678
- snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr - 1), A_FXBUS2(0xe) );
1679
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x7), A_C_00000000, A_C_00000000);
1680
- /* Pavel Hofman - we still have voices, A_FXBUS2s, and
1681
- * A_P16VINs available -
1682
- * let's add 8 more capture channels - total of 16
1683
- */
1684
- gpr_map[gpr++] = 0x00000000;
1685
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1686
- bit_shifter16,
1687
- A_GPR(gpr - 1),
1688
- A_FXBUS2(0x10));
1689
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x8),
1690
- A_C_00000000, A_C_00000000);
1691
- gpr_map[gpr++] = 0x00000000;
1692
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1693
- bit_shifter16,
1694
- A_GPR(gpr - 1),
1695
- A_FXBUS2(0x12));
1696
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0x9),
1697
- A_C_00000000, A_C_00000000);
1698
- gpr_map[gpr++] = 0x00000000;
1699
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1700
- bit_shifter16,
1701
- A_GPR(gpr - 1),
1702
- A_FXBUS2(0x14));
1703
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xa),
1704
- A_C_00000000, A_C_00000000);
1705
- gpr_map[gpr++] = 0x00000000;
1706
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1707
- bit_shifter16,
1708
- A_GPR(gpr - 1),
1709
- A_FXBUS2(0x16));
1710
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xb),
1711
- A_C_00000000, A_C_00000000);
1712
- gpr_map[gpr++] = 0x00000000;
1713
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1714
- bit_shifter16,
1715
- A_GPR(gpr - 1),
1716
- A_FXBUS2(0x18));
1717
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xc),
1718
- A_C_00000000, A_C_00000000);
1719
- gpr_map[gpr++] = 0x00000000;
1720
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1721
- bit_shifter16,
1722
- A_GPR(gpr - 1),
1723
- A_FXBUS2(0x1a));
1724
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xd),
1725
- A_C_00000000, A_C_00000000);
1726
- gpr_map[gpr++] = 0x00000000;
1727
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1728
- bit_shifter16,
1729
- A_GPR(gpr - 1),
1730
- A_FXBUS2(0x1c));
1731
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xe),
1732
- A_C_00000000, A_C_00000000);
1733
- gpr_map[gpr++] = 0x00000000;
1734
- snd_emu10k1_audigy_dsp_convert_32_to_2x16(icode, &ptr, tmp,
1735
- bit_shifter16,
1736
- A_GPR(gpr - 1),
1737
- A_FXBUS2(0x1e));
1738
- A_OP(icode, &ptr, iACC3, A_GPR(gpr - 1), A_P16VIN(0xf),
1739
- A_C_00000000, A_C_00000000);
1649
+ /* A_P16VIN(0) is delayed by one sample, so all other A_P16VIN channels
1650
+ * will need to also be delayed; we use an auxiliary register for that. */
1651
+ for (z = 1; z < 0x10; z++) {
1652
+ snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, bit_shifter16, A_GPR(gpr), A_FXBUS2(z * 2) );
1653
+ A_OP(icode, &ptr, iACC3, A_GPR(gpr), A_P16VIN(z), A_C_00000000, A_C_00000000);
1654
+ gpr_map[gpr++] = 0x00000000;
1655
+ }
17401656 }
17411657
17421658 #if 0
....@@ -1770,7 +1686,7 @@
17701686 A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0);
17711687
17721688 icode->gpr_add_control_count = nctl;
1773
- icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
1689
+ icode->gpr_add_controls = controls;
17741690 emu->support_tlv = 1; /* support TLV */
17751691 err = snd_emu10k1_icode_poke(emu, icode, true);
17761692 emu->support_tlv = 0; /* clear again */
....@@ -1778,7 +1694,7 @@
17781694 __err:
17791695 kfree(controls);
17801696 __err_ctrls:
1781
- kfree((void __force *)icode->gpr_map);
1697
+ kfree(icode->gpr_map);
17821698 __err_gpr:
17831699 kfree(icode);
17841700 return err;
....@@ -1851,8 +1767,8 @@
18511767 if (!icode)
18521768 return err;
18531769
1854
- icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512,
1855
- sizeof(u_int32_t), GFP_KERNEL);
1770
+ icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512,
1771
+ sizeof(u_int32_t), GFP_KERNEL);
18561772 if (!icode->gpr_map)
18571773 goto __err_gpr;
18581774
....@@ -1866,7 +1782,7 @@
18661782 if (!ipcm)
18671783 goto __err_ipcm;
18681784
1869
- gpr_map = (u32 __force *)icode->gpr_map;
1785
+ gpr_map = icode->gpr_map;
18701786
18711787 icode->tram_data_map = icode->gpr_map + 256;
18721788 icode->tram_addr_map = icode->tram_data_map + 160;
....@@ -2200,7 +2116,7 @@
22002116 OP(icode, &ptr, iACC3, GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), GPR(playback + 5), C_00000000, C_00000000); /* LFE */
22012117
22022118 ctl = &controls[i + 0];
2203
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2119
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
22042120 strcpy(ctl->id.name, "Tone Control - Bass");
22052121 ctl->vcount = 2;
22062122 ctl->count = 10;
....@@ -2210,7 +2126,7 @@
22102126 ctl->tlv = snd_emu10k1_bass_treble_db_scale;
22112127 ctl->translation = EMU10K1_GPR_TRANSLATION_BASS;
22122128 ctl = &controls[i + 1];
2213
- ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2129
+ ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
22142130 strcpy(ctl->id.name, "Tone Control - Treble");
22152131 ctl->vcount = 2;
22162132 ctl->count = 10;
....@@ -2396,7 +2312,7 @@
23962312 if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0)
23972313 goto __err;
23982314 icode->gpr_add_control_count = i;
2399
- icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls;
2315
+ icode->gpr_add_controls = controls;
24002316 emu->support_tlv = 1; /* support TLV */
24012317 err = snd_emu10k1_icode_poke(emu, icode, true);
24022318 emu->support_tlv = 0; /* clear again */
....@@ -2407,7 +2323,7 @@
24072323 __err_ipcm:
24082324 kfree(controls);
24092325 __err_ctrls:
2410
- kfree((void __force *)icode->gpr_map);
2326
+ kfree(icode->gpr_map);
24112327 __err_gpr:
24122328 kfree(icode);
24132329 return err;
....@@ -2478,7 +2394,7 @@
24782394 }
24792395
24802396 if (size > 0) {
2481
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
2397
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &emu->pci->dev,
24822398 size * 2, &emu->fx8010.etram_pages) < 0)
24832399 return -ENOMEM;
24842400 memset(emu->fx8010.etram_pages.area, 0, size * 2);
....@@ -2497,7 +2413,7 @@
24972413 return 0;
24982414 }
24992415
2500
-static void copy_string(char *dst, char *src, char *null, int idx)
2416
+static void copy_string(char *dst, const char *src, const char *null, int idx)
25012417 {
25022418 if (src == NULL)
25032419 sprintf(dst, "%s %02X", null, idx);
....@@ -2508,7 +2424,7 @@
25082424 static void snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu,
25092425 struct snd_emu10k1_fx8010_info *info)
25102426 {
2511
- char **fxbus, **extin, **extout;
2427
+ const char * const *fxbus, * const *extin, * const *extout;
25122428 unsigned short fxbus_mask, extin_mask, extout_mask;
25132429 int res;
25142430