forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/echoaudio/echoaudio.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ALSA driver for Echoaudio soundcards.
34 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; version 2 of the License.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5
+ * Copyright (C) 2020 Mark Hills <mark@xwax.org>
176 */
187
198 #include <linux/module.h>
....@@ -35,7 +24,7 @@
3524 module_param_array(enable, bool, NULL, 0444);
3625 MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
3726
38
-static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
27
+static const unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
3928 static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1);
4029
4130
....@@ -257,13 +246,20 @@
257246 SNDRV_PCM_HW_PARAM_RATE);
258247 struct echoaudio *chip = rule->private;
259248 struct snd_interval fixed;
249
+ int err;
260250
261
- if (!chip->can_set_rate) {
251
+ mutex_lock(&chip->mode_mutex);
252
+
253
+ if (chip->can_set_rate) {
254
+ err = 0;
255
+ } else {
262256 snd_interval_any(&fixed);
263257 fixed.min = fixed.max = chip->sample_rate;
264
- return snd_interval_refine(rate, &fixed);
258
+ err = snd_interval_refine(rate, &fixed);
265259 }
266
- return 0;
260
+
261
+ mutex_unlock(&chip->mode_mutex);
262
+ return err;
267263 }
268264
269265
....@@ -334,13 +330,24 @@
334330 SNDRV_PCM_HW_PARAM_RATE, -1)) < 0)
335331 return err;
336332
337
- /* Finally allocate a page for the scatter-gather list */
333
+ /* Allocate a page for the scatter-gather list */
338334 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
339
- snd_dma_pci_data(chip->pci),
335
+ &chip->pci->dev,
340336 PAGE_SIZE, &pipe->sgpage)) < 0) {
341337 dev_err(chip->card->dev, "s-g list allocation failed\n");
342338 return err;
343339 }
340
+
341
+ /*
342
+ * Sole ownership required to set the rate
343
+ */
344
+
345
+ dev_dbg(chip->card->dev, "pcm_open opencount=%d can_set_rate=%d, rate_set=%d",
346
+ chip->opencount, chip->can_set_rate, chip->rate_set);
347
+
348
+ chip->opencount++;
349
+ if (chip->opencount > 1 && chip->rate_set)
350
+ chip->can_set_rate = 0;
344351
345352 return 0;
346353 }
....@@ -365,12 +372,7 @@
365372 hw_rule_capture_format_by_channels, NULL,
366373 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
367374 return err;
368
- atomic_inc(&chip->opencount);
369
- if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
370
- chip->can_set_rate=0;
371
- dev_dbg(chip->card->dev, "pcm_analog_in_open cs=%d oc=%d r=%d\n",
372
- chip->can_set_rate, atomic_read(&chip->opencount),
373
- chip->sample_rate);
375
+
374376 return 0;
375377 }
376378
....@@ -400,12 +402,7 @@
400402 NULL,
401403 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
402404 return err;
403
- atomic_inc(&chip->opencount);
404
- if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
405
- chip->can_set_rate=0;
406
- dev_dbg(chip->card->dev, "pcm_analog_out_open cs=%d oc=%d r=%d\n",
407
- chip->can_set_rate, atomic_read(&chip->opencount),
408
- chip->sample_rate);
405
+
409406 return 0;
410407 }
411408
....@@ -440,10 +437,6 @@
440437 hw_rule_capture_format_by_channels, NULL,
441438 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
442439 goto din_exit;
443
-
444
- atomic_inc(&chip->opencount);
445
- if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
446
- chip->can_set_rate=0;
447440
448441 din_exit:
449442 mutex_unlock(&chip->mode_mutex);
....@@ -483,9 +476,7 @@
483476 NULL, SNDRV_PCM_HW_PARAM_CHANNELS,
484477 -1)) < 0)
485478 goto dout_exit;
486
- atomic_inc(&chip->opencount);
487
- if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
488
- chip->can_set_rate=0;
479
+
489480 dout_exit:
490481 mutex_unlock(&chip->mode_mutex);
491482 return err;
....@@ -500,23 +491,29 @@
500491 static int pcm_close(struct snd_pcm_substream *substream)
501492 {
502493 struct echoaudio *chip = snd_pcm_substream_chip(substream);
503
- int oc;
504494
505495 /* Nothing to do here. Audio is already off and pipe will be
506496 * freed by its callback
507497 */
508498
509
- atomic_dec(&chip->opencount);
510
- oc = atomic_read(&chip->opencount);
511
- dev_dbg(chip->card->dev, "pcm_close oc=%d cs=%d rs=%d\n", oc,
512
- chip->can_set_rate, chip->rate_set);
513
- if (oc < 2)
514
- chip->can_set_rate = 1;
515
- if (oc == 0)
516
- chip->rate_set = 0;
517
- dev_dbg(chip->card->dev, "pcm_close2 oc=%d cs=%d rs=%d\n", oc,
518
- chip->can_set_rate, chip->rate_set);
499
+ mutex_lock(&chip->mode_mutex);
519500
501
+ dev_dbg(chip->card->dev, "pcm_open opencount=%d can_set_rate=%d, rate_set=%d",
502
+ chip->opencount, chip->can_set_rate, chip->rate_set);
503
+
504
+ chip->opencount--;
505
+
506
+ switch (chip->opencount) {
507
+ case 1:
508
+ chip->can_set_rate = 1;
509
+ break;
510
+
511
+ case 0:
512
+ chip->rate_set = 0;
513
+ break;
514
+ }
515
+
516
+ mutex_unlock(&chip->mode_mutex);
520517 return 0;
521518 }
522519
....@@ -559,16 +556,6 @@
559556 "pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n",
560557 params_buffer_bytes(hw_params), params_periods(hw_params),
561558 params_period_bytes(hw_params));
562
- err = snd_pcm_lib_malloc_pages(substream,
563
- params_buffer_bytes(hw_params));
564
- if (err < 0) {
565
- dev_err(chip->card->dev, "malloc_pages err=%d\n", err);
566
- spin_lock_irq(&chip->lock);
567
- free_pipes(chip, pipe);
568
- spin_unlock_irq(&chip->lock);
569
- pipe->index = -1;
570
- return err;
571
- }
572559
573560 sglist_init(chip, pipe);
574561 edge = PAGE_SIZE;
....@@ -604,7 +591,7 @@
604591 /* This stuff is used by the irq handler, so it must be
605592 * initialized before chip->substream
606593 */
607
- chip->last_period[pipe_index] = 0;
594
+ pipe->last_period = 0;
608595 pipe->last_counter = 0;
609596 pipe->position = 0;
610597 smp_wmb();
....@@ -683,7 +670,6 @@
683670 }
684671 spin_unlock_irq(&chip->lock);
685672
686
- snd_pcm_lib_free_pages(substream);
687673 return 0;
688674 }
689675
....@@ -713,7 +699,7 @@
713699 break;
714700 case SNDRV_PCM_FORMAT_S32_BE:
715701 format.data_are_bigendian = 1;
716
- /* fall through */
702
+ fallthrough;
717703 case SNDRV_PCM_FORMAT_S32_LE:
718704 format.bits_per_sample = 32;
719705 break;
....@@ -726,9 +712,22 @@
726712
727713 if (snd_BUG_ON(pipe_index >= px_num(chip)))
728714 return -EINVAL;
729
- if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
715
+
716
+ /*
717
+ * We passed checks we can do independently; now take
718
+ * exclusive control
719
+ */
720
+
721
+ spin_lock_irq(&chip->lock);
722
+
723
+ if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) {
724
+ spin_unlock_irq(&chip->lock);
730725 return -EINVAL;
726
+ }
727
+
731728 set_audio_format(chip, pipe_index, &format);
729
+ spin_unlock_irq(&chip->lock);
730
+
732731 return 0;
733732 }
734733
....@@ -761,11 +760,11 @@
761760 pipe = chip->substream[i]->runtime->private_data;
762761 switch (pipe->state) {
763762 case PIPE_STATE_STOPPED:
764
- chip->last_period[i] = 0;
763
+ pipe->last_period = 0;
765764 pipe->last_counter = 0;
766765 pipe->position = 0;
767766 *pipe->dma_counter = 0;
768
- /* fall through */
767
+ fallthrough;
769768 case PIPE_STATE_PAUSED:
770769 pipe->state = PIPE_STATE_STARTED;
771770 break;
....@@ -809,19 +808,26 @@
809808 {
810809 struct snd_pcm_runtime *runtime = substream->runtime;
811810 struct audiopipe *pipe = runtime->private_data;
812
- size_t cnt, bufsize, pos;
811
+ u32 counter, step;
813812
814
- cnt = le32_to_cpu(*pipe->dma_counter);
815
- pipe->position += cnt - pipe->last_counter;
816
- pipe->last_counter = cnt;
817
- bufsize = substream->runtime->buffer_size;
818
- pos = bytes_to_frames(substream->runtime, pipe->position);
813
+ /*
814
+ * IRQ handling runs concurrently. Do not share tracking of
815
+ * counter with it, which would race or require locking
816
+ */
819817
820
- while (pos >= bufsize) {
821
- pipe->position -= frames_to_bytes(substream->runtime, bufsize);
822
- pos -= bufsize;
823
- }
824
- return pos;
818
+ counter = le32_to_cpu(*pipe->dma_counter); /* presumed atomic */
819
+
820
+ step = counter - pipe->last_counter; /* handles wrapping */
821
+ pipe->last_counter = counter;
822
+
823
+ /* counter doesn't neccessarily wrap on a multiple of
824
+ * buffer_size, so can't derive the position; must
825
+ * accumulate */
826
+
827
+ pipe->position += step;
828
+ pipe->position %= frames_to_bytes(runtime, runtime->buffer_size); /* wrap */
829
+
830
+ return bytes_to_frames(runtime, pipe->position);
825831 }
826832
827833
....@@ -830,49 +836,41 @@
830836 static const struct snd_pcm_ops analog_playback_ops = {
831837 .open = pcm_analog_out_open,
832838 .close = pcm_close,
833
- .ioctl = snd_pcm_lib_ioctl,
834839 .hw_params = pcm_analog_out_hw_params,
835840 .hw_free = pcm_hw_free,
836841 .prepare = pcm_prepare,
837842 .trigger = pcm_trigger,
838843 .pointer = pcm_pointer,
839
- .page = snd_pcm_sgbuf_ops_page,
840844 };
841845 static const struct snd_pcm_ops analog_capture_ops = {
842846 .open = pcm_analog_in_open,
843847 .close = pcm_close,
844
- .ioctl = snd_pcm_lib_ioctl,
845848 .hw_params = pcm_analog_in_hw_params,
846849 .hw_free = pcm_hw_free,
847850 .prepare = pcm_prepare,
848851 .trigger = pcm_trigger,
849852 .pointer = pcm_pointer,
850
- .page = snd_pcm_sgbuf_ops_page,
851853 };
852854 #ifdef ECHOCARD_HAS_DIGITAL_IO
853855 #ifndef ECHOCARD_HAS_VMIXER
854856 static const struct snd_pcm_ops digital_playback_ops = {
855857 .open = pcm_digital_out_open,
856858 .close = pcm_close,
857
- .ioctl = snd_pcm_lib_ioctl,
858859 .hw_params = pcm_digital_out_hw_params,
859860 .hw_free = pcm_hw_free,
860861 .prepare = pcm_prepare,
861862 .trigger = pcm_trigger,
862863 .pointer = pcm_pointer,
863
- .page = snd_pcm_sgbuf_ops_page,
864864 };
865865 #endif /* !ECHOCARD_HAS_VMIXER */
866866 static const struct snd_pcm_ops digital_capture_ops = {
867867 .open = pcm_digital_in_open,
868868 .close = pcm_close,
869
- .ioctl = snd_pcm_lib_ioctl,
870869 .hw_params = pcm_digital_in_hw_params,
871870 .hw_free = pcm_hw_free,
872871 .prepare = pcm_prepare,
873872 .trigger = pcm_trigger,
874873 .pointer = pcm_pointer,
875
- .page = snd_pcm_sgbuf_ops_page,
876874 };
877875 #endif /* ECHOCARD_HAS_DIGITAL_IO */
878876
....@@ -881,21 +879,17 @@
881879 /* Preallocate memory only for the first substream because it's the most
882880 * used one
883881 */
884
-static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
882
+static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
885883 {
886884 struct snd_pcm_substream *ss;
887
- int stream, err;
885
+ int stream;
888886
889887 for (stream = 0; stream < 2; stream++)
890
- for (ss = pcm->streams[stream].substream; ss; ss = ss->next) {
891
- err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
892
- dev,
893
- ss->number ? 0 : 128<<10,
894
- 256<<10);
895
- if (err < 0)
896
- return err;
897
- }
898
- return 0;
888
+ for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
889
+ snd_pcm_set_managed_buffer(ss, SNDRV_DMA_TYPE_DEV_SG,
890
+ dev,
891
+ ss->number ? 0 : 128<<10,
892
+ 256<<10);
899893 }
900894
901895
....@@ -922,8 +916,7 @@
922916 strcpy(pcm->name, chip->card->shortname);
923917 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
924918 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
925
- if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
926
- return err;
919
+ snd_echo_preallocate_pages(pcm, &chip->pci->dev);
927920
928921 #ifdef ECHOCARD_HAS_DIGITAL_IO
929922 /* PCM#1 Digital inputs, no outputs */
....@@ -934,8 +927,7 @@
934927 chip->digital_pcm = pcm;
935928 strcpy(pcm->name, chip->card->shortname);
936929 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
937
- if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
938
- return err;
930
+ snd_echo_preallocate_pages(pcm, &chip->pci->dev);
939931 #endif /* ECHOCARD_HAS_DIGITAL_IO */
940932
941933 #else /* ECHOCARD_HAS_VMIXER */
....@@ -955,8 +947,7 @@
955947 strcpy(pcm->name, chip->card->shortname);
956948 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
957949 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
958
- if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
959
- return err;
950
+ snd_echo_preallocate_pages(pcm, &chip->pci->dev);
960951
961952 #ifdef ECHOCARD_HAS_DIGITAL_IO
962953 /* PCM#1 Digital i/o */
....@@ -969,8 +960,7 @@
969960 strcpy(pcm->name, chip->card->shortname);
970961 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops);
971962 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
972
- if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
973
- return err;
963
+ snd_echo_preallocate_pages(pcm, &chip->pci->dev);
974964 #endif /* ECHOCARD_HAS_DIGITAL_IO */
975965
976966 #endif /* ECHOCARD_HAS_VMIXER */
....@@ -1269,15 +1259,10 @@
12691259 static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol,
12701260 struct snd_ctl_elem_info *uinfo)
12711261 {
1272
- struct echoaudio *chip;
1273
-
1274
- chip = snd_kcontrol_chip(kcontrol);
12751262 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
12761263 uinfo->count = 1;
12771264 uinfo->value.integer.min = ECHOGAIN_MINOUT;
12781265 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1279
- uinfo->dimen.d[0] = num_busses_out(chip);
1280
- uinfo->dimen.d[1] = num_busses_in(chip);
12811266 return 0;
12821267 }
12831268
....@@ -1341,15 +1326,10 @@
13411326 static int snd_echo_vmixer_info(struct snd_kcontrol *kcontrol,
13421327 struct snd_ctl_elem_info *uinfo)
13431328 {
1344
- struct echoaudio *chip;
1345
-
1346
- chip = snd_kcontrol_chip(kcontrol);
13471329 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
13481330 uinfo->count = 1;
13491331 uinfo->value.integer.min = ECHOGAIN_MINOUT;
13501332 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1351
- uinfo->dimen.d[0] = num_busses_out(chip);
1352
- uinfo->dimen.d[1] = num_pipes_out(chip);
13531333 return 0;
13541334 }
13551335
....@@ -1458,7 +1438,7 @@
14581438 /* Do not allow the user to change the digital mode when a pcm
14591439 device is open because it also changes the number of channels
14601440 and the allowed sample rates */
1461
- if (atomic_read(&chip->opencount)) {
1441
+ if (chip->opencount) {
14621442 changed = -EAGAIN;
14631443 } else {
14641444 changed = set_digital_mode(chip, dmode);
....@@ -1732,13 +1712,6 @@
17321712 uinfo->count = 96;
17331713 uinfo->value.integer.min = ECHOGAIN_MINOUT;
17341714 uinfo->value.integer.max = 0;
1735
-#ifdef ECHOCARD_HAS_VMIXER
1736
- uinfo->dimen.d[0] = 3; /* Out, In, Virt */
1737
-#else
1738
- uinfo->dimen.d[0] = 2; /* Out, In */
1739
-#endif
1740
- uinfo->dimen.d[1] = 16; /* 16 channels */
1741
- uinfo->dimen.d[2] = 2; /* 0=level, 1=peak */
17421715 return 0;
17431716 }
17441717
....@@ -1817,14 +1790,43 @@
18171790
18181791
18191792 /******************************************************************************
1820
- IRQ Handler
1793
+ IRQ Handling
18211794 ******************************************************************************/
1795
+/* Check if a period has elapsed since last interrupt
1796
+ *
1797
+ * Don't make any updates to state; PCM core handles this with the
1798
+ * correct locks.
1799
+ *
1800
+ * \return true if a period has elapsed, otherwise false
1801
+ */
1802
+static bool period_has_elapsed(struct snd_pcm_substream *substream)
1803
+{
1804
+ struct snd_pcm_runtime *runtime = substream->runtime;
1805
+ struct audiopipe *pipe = runtime->private_data;
1806
+ u32 counter, step;
1807
+ size_t period_bytes;
1808
+
1809
+ if (pipe->state != PIPE_STATE_STARTED)
1810
+ return false;
1811
+
1812
+ period_bytes = frames_to_bytes(runtime, runtime->period_size);
1813
+
1814
+ counter = le32_to_cpu(*pipe->dma_counter); /* presumed atomic */
1815
+
1816
+ step = counter - pipe->last_period; /* handles wrapping */
1817
+ step -= step % period_bytes; /* acknowledge whole periods only */
1818
+
1819
+ if (step == 0)
1820
+ return false; /* haven't advanced a whole period yet */
1821
+
1822
+ pipe->last_period += step; /* used exclusively by us */
1823
+ return true;
1824
+}
18221825
18231826 static irqreturn_t snd_echo_interrupt(int irq, void *dev_id)
18241827 {
18251828 struct echoaudio *chip = dev_id;
1826
- struct snd_pcm_substream *substream;
1827
- int period, ss, st;
1829
+ int ss, st;
18281830
18291831 spin_lock(&chip->lock);
18301832 st = service_irq(chip);
....@@ -1835,17 +1837,13 @@
18351837 /* The hardware doesn't tell us which substream caused the irq,
18361838 thus we have to check all running substreams. */
18371839 for (ss = 0; ss < DSP_MAXPIPES; ss++) {
1840
+ struct snd_pcm_substream *substream;
1841
+
18381842 substream = chip->substream[ss];
1839
- if (substream && ((struct audiopipe *)substream->runtime->
1840
- private_data)->state == PIPE_STATE_STARTED) {
1841
- period = pcm_pointer(substream) /
1842
- substream->runtime->period_size;
1843
- if (period != chip->last_period[ss]) {
1844
- chip->last_period[ss] = period;
1845
- spin_unlock(&chip->lock);
1846
- snd_pcm_period_elapsed(substream);
1847
- spin_lock(&chip->lock);
1848
- }
1843
+ if (substream && period_has_elapsed(substream)) {
1844
+ spin_unlock(&chip->lock);
1845
+ snd_pcm_period_elapsed(substream);
1846
+ spin_lock(&chip->lock);
18491847 }
18501848 }
18511849 spin_unlock(&chip->lock);
....@@ -1906,7 +1904,7 @@
19061904 struct echoaudio *chip;
19071905 int err;
19081906 size_t sz;
1909
- static struct snd_device_ops ops = {
1907
+ static const struct snd_device_ops ops = {
19101908 .dev_free = snd_echo_dev_free,
19111909 };
19121910
....@@ -1930,7 +1928,7 @@
19301928 chip->card = card;
19311929 chip->pci = pci;
19321930 chip->irq = -1;
1933
- atomic_set(&chip->opencount, 0);
1931
+ chip->opencount = 0;
19341932 mutex_init(&chip->mode_mutex);
19351933 chip->can_set_rate = 1;
19361934 } else {
....@@ -1952,8 +1950,7 @@
19521950 snd_echo_free(chip);
19531951 return -EBUSY;
19541952 }
1955
- chip->dsp_registers = (volatile u32 __iomem *)
1956
- ioremap_nocache(chip->dsp_registers_phys, sz);
1953
+ chip->dsp_registers = ioremap(chip->dsp_registers_phys, sz);
19571954 if (!chip->dsp_registers) {
19581955 dev_err(chip->card->dev, "ioremap failed\n");
19591956 snd_echo_free(chip);
....@@ -1967,12 +1964,13 @@
19671964 return -EBUSY;
19681965 }
19691966 chip->irq = pci->irq;
1967
+ card->sync_irq = chip->irq;
19701968 dev_dbg(card->dev, "pci=%p irq=%d subdev=%04x Init hardware...\n",
19711969 chip->pci, chip->irq, chip->pci->subsystem_device);
19721970
19731971 /* Create the DSP comm page - this is the area of memory used for most
19741972 of the communication with the DSP, which accesses it via bus mastering */
1975
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1973
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
19761974 sizeof(struct comm_page),
19771975 &chip->commpage_dma_buf) < 0) {
19781976 dev_err(chip->card->dev, "cannot allocate the comm page\n");
....@@ -2010,7 +2008,8 @@
20102008 struct snd_card *card;
20112009 struct echoaudio *chip;
20122010 char *dsp;
2013
- int i, err;
2011
+ __maybe_unused int i;
2012
+ int err;
20142013
20152014 if (dev >= SNDRV_CARDS)
20162015 return -ENODEV;
....@@ -2170,9 +2169,6 @@
21702169 {
21712170 struct echoaudio *chip = dev_get_drvdata(dev);
21722171
2173
- snd_pcm_suspend_all(chip->analog_pcm);
2174
- snd_pcm_suspend_all(chip->digital_pcm);
2175
-
21762172 #ifdef ECHOCARD_HAS_MIDI
21772173 /* This call can sleep */
21782174 if (chip->midi_out)
....@@ -2193,6 +2189,7 @@
21932189 chip->dsp_code = NULL;
21942190 free_irq(chip->irq, chip);
21952191 chip->irq = -1;
2192
+ chip->card->sync_irq = -1;
21962193 return 0;
21972194 }
21982195
....@@ -2206,11 +2203,10 @@
22062203 u32 pipe_alloc_mask;
22072204 int err;
22082205
2209
- commpage_bak = kmalloc(sizeof(*commpage), GFP_KERNEL);
2206
+ commpage = chip->comm_page;
2207
+ commpage_bak = kmemdup(commpage, sizeof(*commpage), GFP_KERNEL);
22102208 if (commpage_bak == NULL)
22112209 return -ENOMEM;
2212
- commpage = chip->comm_page;
2213
- memcpy(commpage_bak, commpage, sizeof(*commpage));
22142210
22152211 err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device);
22162212 if (err < 0) {
....@@ -2245,6 +2241,7 @@
22452241 return -EBUSY;
22462242 }
22472243 chip->irq = pci->irq;
2244
+ chip->card->sync_irq = chip->irq;
22482245 dev_dbg(dev, "resume irq=%d\n", chip->irq);
22492246
22502247 #ifdef ECHOCARD_HAS_MIDI