forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/rme9652/hdspm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA driver for RME Hammerfall DSP MADI audio interface(s)
34 *
....@@ -23,20 +24,8 @@
2324 *
2425 * Modified 2011-01-25 variable period sizes on RayDAT/AIO by Adrian Knoth
2526 *
26
- * This program is free software; you can redistribute it and/or modify
27
- * it under the terms of the GNU General Public License as published by
28
- * the Free Software Foundation; either version 2 of the License, or
29
- * (at your option) any later version.
30
- *
31
- * This program is distributed in the hope that it will be useful,
32
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
- * GNU General Public License for more details.
35
- *
36
- * You should have received a copy of the GNU General Public License
37
- * along with this program; if not, write to the Free Software
38
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39
- *
27
+ * Modified 2019-05-23 fix AIO single speed ADAT capture and playback
28
+ * by Philippe.Bekaert@uhasselt.be
4029 */
4130
4231 /* ************* Register Documentation *******************************************************
....@@ -648,7 +637,7 @@
648637 #define HDSPM_SPEED_QUAD 2
649638
650639 /* names for speed modes */
651
-static char *hdspm_speed_names[] = { "single", "double", "quad" };
640
+static const char * const hdspm_speed_names[] = { "single", "double", "quad" };
652641
653642 static const char *const texts_autosync_aes_tco[] = { "Word Clock",
654643 "AES1", "AES2", "AES3", "AES4",
....@@ -695,7 +684,7 @@
695684 "192 kHz"
696685 };
697686
698
-static char *texts_ports_madi[] = {
687
+static const char * const texts_ports_madi[] = {
699688 "MADI.1", "MADI.2", "MADI.3", "MADI.4", "MADI.5", "MADI.6",
700689 "MADI.7", "MADI.8", "MADI.9", "MADI.10", "MADI.11", "MADI.12",
701690 "MADI.13", "MADI.14", "MADI.15", "MADI.16", "MADI.17", "MADI.18",
....@@ -710,7 +699,7 @@
710699 };
711700
712701
713
-static char *texts_ports_raydat_ss[] = {
702
+static const char * const texts_ports_raydat_ss[] = {
714703 "ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4", "ADAT1.5", "ADAT1.6",
715704 "ADAT1.7", "ADAT1.8", "ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4",
716705 "ADAT2.5", "ADAT2.6", "ADAT2.7", "ADAT2.8", "ADAT3.1", "ADAT3.2",
....@@ -721,7 +710,7 @@
721710 "SPDIF.L", "SPDIF.R"
722711 };
723712
724
-static char *texts_ports_raydat_ds[] = {
713
+static const char * const texts_ports_raydat_ds[] = {
725714 "ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4",
726715 "ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4",
727716 "ADAT3.1", "ADAT3.2", "ADAT3.3", "ADAT3.4",
....@@ -730,7 +719,7 @@
730719 "SPDIF.L", "SPDIF.R"
731720 };
732721
733
-static char *texts_ports_raydat_qs[] = {
722
+static const char * const texts_ports_raydat_qs[] = {
734723 "ADAT1.1", "ADAT1.2",
735724 "ADAT2.1", "ADAT2.2",
736725 "ADAT3.1", "ADAT3.2",
....@@ -740,7 +729,7 @@
740729 };
741730
742731
743
-static char *texts_ports_aio_in_ss[] = {
732
+static const char * const texts_ports_aio_in_ss[] = {
744733 "Analogue.L", "Analogue.R",
745734 "AES.L", "AES.R",
746735 "SPDIF.L", "SPDIF.R",
....@@ -749,7 +738,7 @@
749738 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
750739 };
751740
752
-static char *texts_ports_aio_out_ss[] = {
741
+static const char * const texts_ports_aio_out_ss[] = {
753742 "Analogue.L", "Analogue.R",
754743 "AES.L", "AES.R",
755744 "SPDIF.L", "SPDIF.R",
....@@ -759,7 +748,7 @@
759748 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
760749 };
761750
762
-static char *texts_ports_aio_in_ds[] = {
751
+static const char * const texts_ports_aio_in_ds[] = {
763752 "Analogue.L", "Analogue.R",
764753 "AES.L", "AES.R",
765754 "SPDIF.L", "SPDIF.R",
....@@ -767,7 +756,7 @@
767756 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
768757 };
769758
770
-static char *texts_ports_aio_out_ds[] = {
759
+static const char * const texts_ports_aio_out_ds[] = {
771760 "Analogue.L", "Analogue.R",
772761 "AES.L", "AES.R",
773762 "SPDIF.L", "SPDIF.R",
....@@ -776,7 +765,7 @@
776765 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
777766 };
778767
779
-static char *texts_ports_aio_in_qs[] = {
768
+static const char * const texts_ports_aio_in_qs[] = {
780769 "Analogue.L", "Analogue.R",
781770 "AES.L", "AES.R",
782771 "SPDIF.L", "SPDIF.R",
....@@ -784,7 +773,7 @@
784773 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
785774 };
786775
787
-static char *texts_ports_aio_out_qs[] = {
776
+static const char * const texts_ports_aio_out_qs[] = {
788777 "Analogue.L", "Analogue.R",
789778 "AES.L", "AES.R",
790779 "SPDIF.L", "SPDIF.R",
....@@ -793,7 +782,7 @@
793782 "AEB.1", "AEB.2", "AEB.3", "AEB.4"
794783 };
795784
796
-static char *texts_ports_aes32[] = {
785
+static const char * const texts_ports_aes32[] = {
797786 "AES.1", "AES.2", "AES.3", "AES.4", "AES.5", "AES.6", "AES.7",
798787 "AES.8", "AES.9.", "AES.10", "AES.11", "AES.12", "AES.13", "AES.14",
799788 "AES.15", "AES.16"
....@@ -807,7 +796,7 @@
807796 where the data for that channel can be read/written from/to.
808797 */
809798
810
-static char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = {
799
+static const char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = {
811800 0, 1, 2, 3, 4, 5, 6, 7,
812801 8, 9, 10, 11, 12, 13, 14, 15,
813802 16, 17, 18, 19, 20, 21, 22, 23,
....@@ -818,7 +807,7 @@
818807 56, 57, 58, 59, 60, 61, 62, 63
819808 };
820809
821
-static char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = {
810
+static const char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = {
822811 4, 5, 6, 7, 8, 9, 10, 11, /* ADAT 1 */
823812 12, 13, 14, 15, 16, 17, 18, 19, /* ADAT 2 */
824813 20, 21, 22, 23, 24, 25, 26, 27, /* ADAT 3 */
....@@ -831,7 +820,7 @@
831820 -1, -1, -1, -1, -1, -1, -1, -1,
832821 };
833822
834
-static char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = {
823
+static const char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = {
835824 4, 5, 6, 7, /* ADAT 1 */
836825 8, 9, 10, 11, /* ADAT 2 */
837826 12, 13, 14, 15, /* ADAT 3 */
....@@ -846,7 +835,7 @@
846835 -1, -1, -1, -1, -1, -1, -1, -1,
847836 };
848837
849
-static char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = {
838
+static const char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = {
850839 4, 5, /* ADAT 1 */
851840 6, 7, /* ADAT 2 */
852841 8, 9, /* ADAT 3 */
....@@ -862,7 +851,7 @@
862851 -1, -1, -1, -1, -1, -1, -1, -1,
863852 };
864853
865
-static char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = {
854
+static const char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = {
866855 0, 1, /* line in */
867856 8, 9, /* aes in, */
868857 10, 11, /* spdif in */
....@@ -876,7 +865,7 @@
876865 -1, -1, -1, -1, -1, -1, -1, -1,
877866 };
878867
879
-static char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = {
868
+static const char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = {
880869 0, 1, /* line out */
881870 8, 9, /* aes out */
882871 10, 11, /* spdif out */
....@@ -891,7 +880,7 @@
891880 -1, -1, -1, -1, -1, -1, -1, -1,
892881 };
893882
894
-static char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = {
883
+static const char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = {
895884 0, 1, /* line in */
896885 8, 9, /* aes in */
897886 10, 11, /* spdif in */
....@@ -906,7 +895,7 @@
906895 -1, -1, -1, -1, -1, -1, -1, -1
907896 };
908897
909
-static char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = {
898
+static const char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = {
910899 0, 1, /* line out */
911900 8, 9, /* aes out */
912901 10, 11, /* spdif out */
....@@ -921,7 +910,7 @@
921910 -1, -1, -1, -1, -1, -1, -1, -1
922911 };
923912
924
-static char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = {
913
+static const char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = {
925914 0, 1, /* line in */
926915 8, 9, /* aes in */
927916 10, 11, /* spdif in */
....@@ -936,7 +925,7 @@
936925 -1, -1, -1, -1, -1, -1, -1, -1
937926 };
938927
939
-static char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = {
928
+static const char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = {
940929 0, 1, /* line out */
941930 8, 9, /* aes out */
942931 10, 11, /* spdif out */
....@@ -952,7 +941,7 @@
952941 -1, -1, -1, -1, -1, -1, -1, -1
953942 };
954943
955
-static char channel_map_aes32[HDSPM_MAX_CHANNELS] = {
944
+static const char channel_map_aes32[HDSPM_MAX_CHANNELS] = {
956945 0, 1, 2, 3, 4, 5, 6, 7,
957946 8, 9, 10, 11, 12, 13, 14, 15,
958947 -1, -1, -1, -1, -1, -1, -1, -1,
....@@ -1008,7 +997,7 @@
1008997 u32 settings_register; /* cached value for AIO / RayDat (sync reference, master/slave) */
1009998
1010999 struct hdspm_midi midi[4];
1011
- struct tasklet_struct midi_tasklet;
1000
+ struct work_struct midi_work;
10121001
10131002 size_t period_bytes;
10141003 unsigned char ss_in_channels;
....@@ -1021,17 +1010,21 @@
10211010 unsigned char max_channels_in;
10221011 unsigned char max_channels_out;
10231012
1024
- signed char *channel_map_in;
1025
- signed char *channel_map_out;
1013
+ const signed char *channel_map_in;
1014
+ const signed char *channel_map_out;
10261015
1027
- signed char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs;
1028
- signed char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs;
1016
+ const signed char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs;
1017
+ const signed char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs;
10291018
1030
- char **port_names_in;
1031
- char **port_names_out;
1019
+ const char * const *port_names_in;
1020
+ const char * const *port_names_out;
10321021
1033
- char **port_names_in_ss, **port_names_in_ds, **port_names_in_qs;
1034
- char **port_names_out_ss, **port_names_out_ds, **port_names_out_qs;
1022
+ const char * const *port_names_in_ss;
1023
+ const char * const *port_names_in_ds;
1024
+ const char * const *port_names_in_qs;
1025
+ const char * const *port_names_out_ss;
1026
+ const char * const *port_names_out_ds;
1027
+ const char * const *port_names_out_qs;
10351028
10361029 unsigned char *playback_buffer; /* suitably aligned address */
10371030 unsigned char *capture_buffer; /* suitably aligned address */
....@@ -1105,9 +1098,9 @@
11051098 static int hdspm_set_toggle_setting(struct hdspm *hdspm, u32 regmask, int out);
11061099 static int snd_hdspm_set_defaults(struct hdspm *hdspm);
11071100 static int hdspm_system_clock_mode(struct hdspm *hdspm);
1108
-static void hdspm_set_sgbuf(struct hdspm *hdspm,
1109
- struct snd_pcm_substream *substream,
1110
- unsigned int reg, int channels);
1101
+static void hdspm_set_channel_dma_addr(struct hdspm *hdspm,
1102
+ struct snd_pcm_substream *substream,
1103
+ unsigned int reg, int channels);
11111104
11121105 static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx);
11131106 static int hdspm_wc_sync_check(struct hdspm *hdspm);
....@@ -1224,7 +1217,7 @@
12241217 return ret;
12251218 }
12261219
1227
-/* round arbitary sample rates to commonly known rates */
1220
+/* round arbitrary sample rates to commonly known rates */
12281221 static int hdspm_round_frequency(int rate)
12291222 {
12301223 if (rate < 38050)
....@@ -2176,9 +2169,9 @@
21762169 }
21772170
21782171
2179
-static void hdspm_midi_tasklet(unsigned long arg)
2172
+static void hdspm_midi_work(struct work_struct *work)
21802173 {
2181
- struct hdspm *hdspm = (struct hdspm *)arg;
2174
+ struct hdspm *hdspm = container_of(work, struct hdspm, midi_work);
21822175 int i = 0;
21832176
21842177 while (i < hdspm->midiPorts) {
....@@ -3034,8 +3027,8 @@
30343027
30353028 unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
30363029 unsigned int syncref = (status >> HDSPM_AES32_syncref_bit) & 0xF;
3037
- if ((syncref >= HDSPM_AES32_AUTOSYNC_FROM_WORD) &&
3038
- (syncref <= HDSPM_AES32_AUTOSYNC_FROM_SYNC_IN)) {
3030
+ /* syncref >= HDSPM_AES32_AUTOSYNC_FROM_WORD is always true */
3031
+ if (syncref <= HDSPM_AES32_AUTOSYNC_FROM_SYNC_IN) {
30393032 return syncref;
30403033 }
30413034 return HDSPM_AES32_AUTOSYNC_FROM_NONE;
....@@ -4489,7 +4482,7 @@
44894482
44904483
44914484
4492
-static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
4485
+static const struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
44934486 HDSPM_MIXER("Mixer", 0),
44944487 HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
44954488 HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
....@@ -4511,7 +4504,7 @@
45114504 };
45124505
45134506
4514
-static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = {
4507
+static const struct snd_kcontrol_new snd_hdspm_controls_madiface[] = {
45154508 HDSPM_MIXER("Mixer", 0),
45164509 HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
45174510 HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
....@@ -4524,7 +4517,7 @@
45244517 HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0)
45254518 };
45264519
4527
-static struct snd_kcontrol_new snd_hdspm_controls_aio[] = {
4520
+static const struct snd_kcontrol_new snd_hdspm_controls_aio[] = {
45284521 HDSPM_MIXER("Mixer", 0),
45294522 HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
45304523 HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
....@@ -4565,7 +4558,7 @@
45654558 */
45664559 };
45674560
4568
-static struct snd_kcontrol_new snd_hdspm_controls_raydat[] = {
4561
+static const struct snd_kcontrol_new snd_hdspm_controls_raydat[] = {
45694562 HDSPM_MIXER("Mixer", 0),
45704563 HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
45714564 HDSPM_SYSTEM_CLOCK_MODE("Clock Mode", 0),
....@@ -4593,7 +4586,7 @@
45934586 HDSPM_TOGGLE_SETTING("Single Speed WordClock Out", HDSPM_c0_Wck48)
45944587 };
45954588
4596
-static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = {
4589
+static const struct snd_kcontrol_new snd_hdspm_controls_aes32[] = {
45974590 HDSPM_MIXER("Mixer", 0),
45984591 HDSPM_INTERNAL_CLOCK("Internal Clock", 0),
45994592 HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
....@@ -4635,7 +4628,7 @@
46354628
46364629
46374630 /* Control elements for the optional TCO module */
4638
-static struct snd_kcontrol_new snd_hdspm_controls_tco[] = {
4631
+static const struct snd_kcontrol_new snd_hdspm_controls_tco[] = {
46394632 HDSPM_TCO_SAMPLE_RATE("TCO Sample Rate", 0),
46404633 HDSPM_TCO_PULL("TCO Pull", 0),
46414634 HDSPM_TCO_WCK_CONVERSION("TCO WCK Conversion", 0),
....@@ -4682,7 +4675,7 @@
46824675 unsigned int idx, limit;
46834676 int err;
46844677 struct snd_kcontrol *kctl;
4685
- struct snd_kcontrol_new *list = NULL;
4678
+ const struct snd_kcontrol_new *list = NULL;
46864679
46874680 switch (hdspm->io_type) {
46884681 case MADI:
....@@ -5287,44 +5280,35 @@
52875280
52885281 static void snd_hdspm_proc_init(struct hdspm *hdspm)
52895282 {
5290
- struct snd_info_entry *entry;
5283
+ void (*read)(struct snd_info_entry *, struct snd_info_buffer *) = NULL;
52915284
5292
- if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) {
5293
- switch (hdspm->io_type) {
5294
- case AES32:
5295
- snd_info_set_text_ops(entry, hdspm,
5296
- snd_hdspm_proc_read_aes32);
5297
- break;
5298
- case MADI:
5299
- snd_info_set_text_ops(entry, hdspm,
5300
- snd_hdspm_proc_read_madi);
5301
- break;
5302
- case MADIface:
5303
- /* snd_info_set_text_ops(entry, hdspm,
5304
- snd_hdspm_proc_read_madiface); */
5305
- break;
5306
- case RayDAT:
5307
- snd_info_set_text_ops(entry, hdspm,
5308
- snd_hdspm_proc_read_raydat);
5309
- break;
5310
- case AIO:
5311
- break;
5312
- }
5285
+ switch (hdspm->io_type) {
5286
+ case AES32:
5287
+ read = snd_hdspm_proc_read_aes32;
5288
+ break;
5289
+ case MADI:
5290
+ read = snd_hdspm_proc_read_madi;
5291
+ break;
5292
+ case MADIface:
5293
+ /* read = snd_hdspm_proc_read_madiface; */
5294
+ break;
5295
+ case RayDAT:
5296
+ read = snd_hdspm_proc_read_raydat;
5297
+ break;
5298
+ case AIO:
5299
+ break;
53135300 }
53145301
5315
- if (!snd_card_proc_new(hdspm->card, "ports.in", &entry)) {
5316
- snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_in);
5317
- }
5318
-
5319
- if (!snd_card_proc_new(hdspm->card, "ports.out", &entry)) {
5320
- snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_out);
5321
- }
5302
+ snd_card_ro_proc_new(hdspm->card, "hdspm", hdspm, read);
5303
+ snd_card_ro_proc_new(hdspm->card, "ports.in", hdspm,
5304
+ snd_hdspm_proc_ports_in);
5305
+ snd_card_ro_proc_new(hdspm->card, "ports.out", hdspm,
5306
+ snd_hdspm_proc_ports_out);
53225307
53235308 #ifdef CONFIG_SND_DEBUG
53245309 /* debug file to read all hdspm registers */
5325
- if (!snd_card_proc_new(hdspm->card, "debug", &entry))
5326
- snd_info_set_text_ops(entry, hdspm,
5327
- snd_hdspm_proc_read_debug);
5310
+ snd_card_ro_proc_new(hdspm->card, "debug", hdspm,
5311
+ snd_hdspm_proc_read_debug);
53285312 #endif
53295313 }
53305314
....@@ -5465,7 +5449,7 @@
54655449 }
54665450
54675451 if (schedule)
5468
- tasklet_hi_schedule(&hdspm->midi_tasklet);
5452
+ queue_work(system_highpri_wq, &hdspm->midi_work);
54695453 }
54705454
54715455 return IRQ_HANDLED;
....@@ -5597,11 +5581,16 @@
55975581
55985582 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
55995583
5600
- hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferOut,
5601
- params_channels(params));
5584
+ for (i = 0; i < params_channels(params); ++i) {
5585
+ int c = hdspm->channel_map_out[i];
56025586
5603
- for (i = 0; i < params_channels(params); ++i)
5604
- snd_hdspm_enable_out(hdspm, i, 1);
5587
+ if (c < 0)
5588
+ continue; /* just make sure */
5589
+ hdspm_set_channel_dma_addr(hdspm, substream,
5590
+ HDSPM_pageAddressBufferOut,
5591
+ c);
5592
+ snd_hdspm_enable_out(hdspm, c, 1);
5593
+ }
56055594
56065595 hdspm->playback_buffer =
56075596 (unsigned char *) substream->runtime->dma_area;
....@@ -5609,11 +5598,16 @@
56095598 "Allocated sample buffer for playback at %p\n",
56105599 hdspm->playback_buffer);
56115600 } else {
5612
- hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferIn,
5613
- params_channels(params));
5601
+ for (i = 0; i < params_channels(params); ++i) {
5602
+ int c = hdspm->channel_map_in[i];
56145603
5615
- for (i = 0; i < params_channels(params); ++i)
5616
- snd_hdspm_enable_in(hdspm, i, 1);
5604
+ if (c < 0)
5605
+ continue;
5606
+ hdspm_set_channel_dma_addr(hdspm, substream,
5607
+ HDSPM_pageAddressBufferIn,
5608
+ c);
5609
+ snd_hdspm_enable_in(hdspm, c, 1);
5610
+ }
56175611
56185612 hdspm->capture_buffer =
56195613 (unsigned char *) substream->runtime->dma_area;
....@@ -5674,19 +5668,17 @@
56745668 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
56755669
56765670 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
5677
-
5678
- /* params_channels(params) should be enough,
5679
- but to get sure in case of error */
5680
- for (i = 0; i < hdspm->max_channels_out; ++i)
5671
+ /* Just disable all channels. The saving when disabling a */
5672
+ /* smaller set is not worth the trouble. */
5673
+ for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
56815674 snd_hdspm_enable_out(hdspm, i, 0);
56825675
56835676 hdspm->playback_buffer = NULL;
56845677 } else {
5685
- for (i = 0; i < hdspm->max_channels_in; ++i)
5678
+ for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
56865679 snd_hdspm_enable_in(hdspm, i, 0);
56875680
56885681 hdspm->capture_buffer = NULL;
5689
-
56905682 }
56915683
56925684 snd_pcm_lib_free_pages(substream);
....@@ -5832,7 +5824,7 @@
58325824 return 0;
58335825 }
58345826
5835
-static struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
5827
+static const struct snd_pcm_hardware snd_hdspm_playback_subinfo = {
58365828 .info = (SNDRV_PCM_INFO_MMAP |
58375829 SNDRV_PCM_INFO_MMAP_VALID |
58385830 SNDRV_PCM_INFO_NONINTERLEAVED |
....@@ -5857,7 +5849,7 @@
58575849 .fifo_size = 0
58585850 };
58595851
5860
-static struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
5852
+static const struct snd_pcm_hardware snd_hdspm_capture_subinfo = {
58615853 .info = (SNDRV_PCM_INFO_MMAP |
58625854 SNDRV_PCM_INFO_MMAP_VALID |
58635855 SNDRV_PCM_INFO_NONINTERLEAVED |
....@@ -6380,7 +6372,6 @@
63806372 .prepare = snd_hdspm_prepare,
63816373 .trigger = snd_hdspm_trigger,
63826374 .pointer = snd_hdspm_hw_pointer,
6383
- .page = snd_pcm_sgbuf_ops_page,
63846375 };
63856376
63866377 static int snd_hdspm_create_hwdep(struct snd_card *card,
....@@ -6411,7 +6402,6 @@
64116402 ------------------------------------------------------------*/
64126403 static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
64136404 {
6414
- int err;
64156405 struct snd_pcm *pcm;
64166406 size_t wanted;
64176407
....@@ -6419,35 +6409,24 @@
64196409
64206410 wanted = HDSPM_DMA_AREA_BYTES;
64216411
6422
- err =
6423
- snd_pcm_lib_preallocate_pages_for_all(pcm,
6424
- SNDRV_DMA_TYPE_DEV_SG,
6425
- snd_dma_pci_data(hdspm->pci),
6426
- wanted,
6427
- wanted);
6428
- if (err < 0) {
6429
- dev_dbg(hdspm->card->dev,
6430
- "Could not preallocate %zd Bytes\n", wanted);
6431
-
6432
- return err;
6433
- } else
6434
- dev_dbg(hdspm->card->dev,
6435
- " Preallocated %zd Bytes\n", wanted);
6436
-
6412
+ snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
6413
+ &hdspm->pci->dev,
6414
+ wanted, wanted);
6415
+ dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted);
64376416 return 0;
64386417 }
64396418
6440
-
6441
-static void hdspm_set_sgbuf(struct hdspm *hdspm,
6442
- struct snd_pcm_substream *substream,
6443
- unsigned int reg, int channels)
6419
+/* Inform the card what DMA addresses to use for the indicated channel. */
6420
+/* Each channel got 16 4K pages allocated for DMA transfers. */
6421
+static void hdspm_set_channel_dma_addr(struct hdspm *hdspm,
6422
+ struct snd_pcm_substream *substream,
6423
+ unsigned int reg, int channel)
64446424 {
64456425 int i;
64466426
6447
- /* continuous memory segment */
6448
- for (i = 0; i < (channels * 16); i++)
6427
+ for (i = channel * 16; i < channel * 16 + 16; i++)
64496428 hdspm_write(hdspm, reg + 4 * i,
6450
- snd_pcm_sgbuf_get_addr(substream, 4096 * i));
6429
+ snd_pcm_sgbuf_get_addr(substream, 4096 * i));
64516430 }
64526431
64536432
....@@ -6534,7 +6513,7 @@
65346513 dev_dbg(card->dev, "Update mixer controls...\n");
65356514 hdspm_update_simple_mixer_controls(hdspm);
65366515
6537
- dev_dbg(card->dev, "Initializeing complete ???\n");
6516
+ dev_dbg(card->dev, "Initializing complete?\n");
65386517
65396518 err = snd_card_register(card);
65406519 if (err < 0) {
....@@ -6559,6 +6538,7 @@
65596538 hdspm->card = card;
65606539
65616540 spin_lock_init(&hdspm->lock);
6541
+ INIT_WORK(&hdspm->midi_work, hdspm_midi_work);
65626542
65636543 pci_read_config_word(hdspm->pci,
65646544 PCI_CLASS_REVISION, &hdspm->firmware_rev);
....@@ -6619,7 +6599,7 @@
66196599 dev_dbg(card->dev, "grabbed memory region 0x%lx-0x%lx\n",
66206600 hdspm->port, hdspm->port + io_extent - 1);
66216601
6622
- hdspm->iobase = ioremap_nocache(hdspm->port, io_extent);
6602
+ hdspm->iobase = ioremap(hdspm->port, io_extent);
66236603 if (!hdspm->iobase) {
66246604 dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n",
66256605 hdspm->port, hdspm->port + io_extent - 1);
....@@ -6638,6 +6618,7 @@
66386618 dev_dbg(card->dev, "use IRQ %d\n", pci->irq);
66396619
66406620 hdspm->irq = pci->irq;
6621
+ card->sync_irq = hdspm->irq;
66416622
66426623 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n",
66436624 sizeof(*hdspm->mixer));
....@@ -6856,10 +6837,6 @@
68566837
68576838 }
68586839
6859
- tasklet_init(&hdspm->midi_tasklet,
6860
- hdspm_midi_tasklet, (unsigned long) hdspm);
6861
-
6862
-
68636840 if (hdspm->io_type != MADIface) {
68646841 hdspm->serial = (hdspm_read(hdspm,
68656842 HDSPM_midiStatusIn0)>>8) & 0xFFFFFF;
....@@ -6894,6 +6871,7 @@
68946871 {
68956872
68966873 if (hdspm->port) {
6874
+ cancel_work_sync(&hdspm->midi_work);
68976875
68986876 /* stop th audio, and cancel all interrupts */
68996877 hdspm->control_register &=