forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/emu10k1/emupcm.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.
....@@ -9,21 +10,6 @@
910 *
1011 * TODO:
1112 * --
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- *
2713 */
2814
2915 #include <linux/pci.h>
....@@ -137,7 +123,7 @@
137123 epcm->voices[0]->epcm = epcm;
138124 if (voices > 1) {
139125 for (i = 1; i < voices; i++) {
140
- epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i];
126
+ epcm->voices[i] = &epcm->emu->voices[(epcm->voices[0]->number + i) % NUM_G];
141127 epcm->voices[i]->epcm = epcm;
142128 }
143129 }
....@@ -583,17 +569,6 @@
583569 .fifo_size = 0,
584570 };
585571
586
-static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream,
587
- struct snd_pcm_hw_params *hw_params)
588
-{
589
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
590
-}
591
-
592
-static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream)
593
-{
594
- return snd_pcm_lib_free_pages(substream);
595
-}
596
-
597572 static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream)
598573 {
599574 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
....@@ -778,7 +753,7 @@
778753 case SNDRV_PCM_TRIGGER_START:
779754 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra); /* do we need this? */
780755 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]);
781
- /* fall through */
756
+ fallthrough;
782757 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
783758 case SNDRV_PCM_TRIGGER_RESUME:
784759 if (cmd == SNDRV_PCM_TRIGGER_PAUSE_RELEASE)
....@@ -927,8 +902,7 @@
927902 snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[i]);
928903 }
929904 snd_emu10k1_playback_invalidate_cache(emu, 1, epcm->extra);
930
-
931
- /* fall through */
905
+ fallthrough;
932906 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
933907 case SNDRV_PCM_TRIGGER_RESUME:
934908 snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL);
....@@ -1258,7 +1232,7 @@
12581232 {
12591233 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
12601234
1261
- emu->capture_interrupt = NULL;
1235
+ emu->capture_mic_interrupt = NULL;
12621236 emu->pcm_capture_mic_substream = NULL;
12631237 return 0;
12641238 }
....@@ -1366,7 +1340,7 @@
13661340 {
13671341 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
13681342
1369
- emu->capture_interrupt = NULL;
1343
+ emu->capture_efx_interrupt = NULL;
13701344 emu->pcm_capture_efx_substream = NULL;
13711345 return 0;
13721346 }
....@@ -1374,21 +1348,16 @@
13741348 static const struct snd_pcm_ops snd_emu10k1_playback_ops = {
13751349 .open = snd_emu10k1_playback_open,
13761350 .close = snd_emu10k1_playback_close,
1377
- .ioctl = snd_pcm_lib_ioctl,
13781351 .hw_params = snd_emu10k1_playback_hw_params,
13791352 .hw_free = snd_emu10k1_playback_hw_free,
13801353 .prepare = snd_emu10k1_playback_prepare,
13811354 .trigger = snd_emu10k1_playback_trigger,
13821355 .pointer = snd_emu10k1_playback_pointer,
1383
- .page = snd_pcm_sgbuf_ops_page,
13841356 };
13851357
13861358 static const struct snd_pcm_ops snd_emu10k1_capture_ops = {
13871359 .open = snd_emu10k1_capture_open,
13881360 .close = snd_emu10k1_capture_close,
1389
- .ioctl = snd_pcm_lib_ioctl,
1390
- .hw_params = snd_emu10k1_capture_hw_params,
1391
- .hw_free = snd_emu10k1_capture_hw_free,
13921361 .prepare = snd_emu10k1_capture_prepare,
13931362 .trigger = snd_emu10k1_capture_trigger,
13941363 .pointer = snd_emu10k1_capture_pointer,
....@@ -1398,13 +1367,11 @@
13981367 static const struct snd_pcm_ops snd_emu10k1_efx_playback_ops = {
13991368 .open = snd_emu10k1_efx_playback_open,
14001369 .close = snd_emu10k1_efx_playback_close,
1401
- .ioctl = snd_pcm_lib_ioctl,
14021370 .hw_params = snd_emu10k1_playback_hw_params,
14031371 .hw_free = snd_emu10k1_efx_playback_hw_free,
14041372 .prepare = snd_emu10k1_efx_playback_prepare,
14051373 .trigger = snd_emu10k1_efx_playback_trigger,
14061374 .pointer = snd_emu10k1_efx_playback_pointer,
1407
- .page = snd_pcm_sgbuf_ops_page,
14081375 };
14091376
14101377 int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)
....@@ -1426,12 +1393,15 @@
14261393 strcpy(pcm->name, "ADC Capture/Standard PCM Playback");
14271394 emu->pcm = pcm;
14281395
1396
+ /* playback substream can't use managed buffers due to alignment */
14291397 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1430
- if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0)
1431
- return err;
1398
+ snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1399
+ &emu->pci->dev,
1400
+ 64*1024, 64*1024);
14321401
14331402 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next)
1434
- snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
1403
+ snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV,
1404
+ &emu->pci->dev, 64*1024, 64*1024);
14351405
14361406 return 0;
14371407 }
....@@ -1455,8 +1425,9 @@
14551425 emu->pcm_multi = pcm;
14561426
14571427 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1458
- if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0)
1459
- return err;
1428
+ snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1429
+ &emu->pci->dev,
1430
+ 64*1024, 64*1024);
14601431
14611432 return 0;
14621433 }
....@@ -1465,9 +1436,6 @@
14651436 static const struct snd_pcm_ops snd_emu10k1_capture_mic_ops = {
14661437 .open = snd_emu10k1_capture_mic_open,
14671438 .close = snd_emu10k1_capture_mic_close,
1468
- .ioctl = snd_pcm_lib_ioctl,
1469
- .hw_params = snd_emu10k1_capture_hw_params,
1470
- .hw_free = snd_emu10k1_capture_hw_free,
14711439 .prepare = snd_emu10k1_capture_prepare,
14721440 .trigger = snd_emu10k1_capture_trigger,
14731441 .pointer = snd_emu10k1_capture_pointer,
....@@ -1489,7 +1457,8 @@
14891457 strcpy(pcm->name, "Mic Capture");
14901458 emu->pcm_mic = pcm;
14911459
1492
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
1460
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev,
1461
+ 64*1024, 64*1024);
14931462
14941463 return 0;
14951464 }
....@@ -1560,9 +1529,6 @@
15601529 static const struct snd_pcm_ops snd_emu10k1_capture_efx_ops = {
15611530 .open = snd_emu10k1_capture_efx_open,
15621531 .close = snd_emu10k1_capture_efx_close,
1563
- .ioctl = snd_pcm_lib_ioctl,
1564
- .hw_params = snd_emu10k1_capture_hw_params,
1565
- .hw_free = snd_emu10k1_capture_hw_free,
15661532 .prepare = snd_emu10k1_capture_prepare,
15671533 .trigger = snd_emu10k1_capture_trigger,
15681534 .pointer = snd_emu10k1_capture_pointer,
....@@ -1643,12 +1609,6 @@
16431609 fx8010_pb_trans_copy);
16441610 }
16451611
1646
-static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream,
1647
- struct snd_pcm_hw_params *hw_params)
1648
-{
1649
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1650
-}
1651
-
16521612 static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream)
16531613 {
16541614 struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream);
....@@ -1657,7 +1617,6 @@
16571617
16581618 for (i = 0; i < pcm->channels; i++)
16591619 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0);
1660
- snd_pcm_lib_free_pages(substream);
16611620 return 0;
16621621 }
16631622
....@@ -1753,7 +1712,8 @@
17531712 {
17541713 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
17551714 SNDRV_PCM_INFO_RESUME |
1756
- /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE),
1715
+ /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE |
1716
+ SNDRV_PCM_INFO_SYNC_APPLPTR),
17571717 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
17581718 .rates = SNDRV_PCM_RATE_48000,
17591719 .rate_min = 48000,
....@@ -1801,8 +1761,6 @@
18011761 static const struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = {
18021762 .open = snd_emu10k1_fx8010_playback_open,
18031763 .close = snd_emu10k1_fx8010_playback_close,
1804
- .ioctl = snd_pcm_lib_ioctl,
1805
- .hw_params = snd_emu10k1_fx8010_playback_hw_params,
18061764 .hw_free = snd_emu10k1_fx8010_playback_hw_free,
18071765 .prepare = snd_emu10k1_fx8010_playback_prepare,
18081766 .trigger = snd_emu10k1_fx8010_playback_trigger,
....@@ -1861,7 +1819,8 @@
18611819 if (err < 0)
18621820 return err;
18631821
1864
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
1822
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev,
1823
+ 64*1024, 64*1024);
18651824
18661825 return 0;
18671826 }