echoaudio.c (2040cf9f59037aa8aec749363e69ead165b67b43) echoaudio.c (11f63ca3995b8099aa9d6d039d729c91a9122112)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * ALSA driver for Echoaudio soundcards.
4 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
5 */
6
7#include <linux/module.h>
8

--- 533 unchanged lines hidden (view full) ---

542 }
543 spin_unlock_irq(&chip->lock);
544 dev_dbg(chip->card->dev, "allocate_pipes()=%d\n", pipe_index);
545
546 dev_dbg(chip->card->dev,
547 "pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n",
548 params_buffer_bytes(hw_params), params_periods(hw_params),
549 params_period_bytes(hw_params));
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * ALSA driver for Echoaudio soundcards.
4 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
5 */
6
7#include <linux/module.h>
8

--- 533 unchanged lines hidden (view full) ---

542 }
543 spin_unlock_irq(&chip->lock);
544 dev_dbg(chip->card->dev, "allocate_pipes()=%d\n", pipe_index);
545
546 dev_dbg(chip->card->dev,
547 "pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n",
548 params_buffer_bytes(hw_params), params_periods(hw_params),
549 params_period_bytes(hw_params));
550 err = snd_pcm_lib_malloc_pages(substream,
551 params_buffer_bytes(hw_params));
552 if (err < 0) {
553 dev_err(chip->card->dev, "malloc_pages err=%d\n", err);
554 spin_lock_irq(&chip->lock);
555 free_pipes(chip, pipe);
556 spin_unlock_irq(&chip->lock);
557 pipe->index = -1;
558 return err;
559 }
560
561 sglist_init(chip, pipe);
562 edge = PAGE_SIZE;
563 for (offs = page = per = 0; offs < params_buffer_bytes(hw_params);
564 per++) {
565 rest = params_period_bytes(hw_params);
566 if (offs + rest > params_buffer_bytes(hw_params))
567 rest = params_buffer_bytes(hw_params) - offs;

--- 98 unchanged lines hidden (view full) ---

666 if (pipe->index >= 0) {
667 dev_dbg(chip->card->dev, "pcm_hw_free(%d)\n", pipe->index);
668 free_pipes(chip, pipe);
669 chip->substream[pipe->index] = NULL;
670 pipe->index = -1;
671 }
672 spin_unlock_irq(&chip->lock);
673
550
551 sglist_init(chip, pipe);
552 edge = PAGE_SIZE;
553 for (offs = page = per = 0; offs < params_buffer_bytes(hw_params);
554 per++) {
555 rest = params_period_bytes(hw_params);
556 if (offs + rest > params_buffer_bytes(hw_params))
557 rest = params_buffer_bytes(hw_params) - offs;

--- 98 unchanged lines hidden (view full) ---

656 if (pipe->index >= 0) {
657 dev_dbg(chip->card->dev, "pcm_hw_free(%d)\n", pipe->index);
658 free_pipes(chip, pipe);
659 chip->substream[pipe->index] = NULL;
660 pipe->index = -1;
661 }
662 spin_unlock_irq(&chip->lock);
663
674 snd_pcm_lib_free_pages(substream);
675 return 0;
676}
677
678
679
680static int pcm_prepare(struct snd_pcm_substream *substream)
681{
682 struct echoaudio *chip = snd_pcm_substream_chip(substream);

--- 184 unchanged lines hidden (view full) ---

867 */
868static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
869{
870 struct snd_pcm_substream *ss;
871 int stream;
872
873 for (stream = 0; stream < 2; stream++)
874 for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
664 return 0;
665}
666
667
668
669static int pcm_prepare(struct snd_pcm_substream *substream)
670{
671 struct echoaudio *chip = snd_pcm_substream_chip(substream);

--- 184 unchanged lines hidden (view full) ---

856 */
857static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
858{
859 struct snd_pcm_substream *ss;
860 int stream;
861
862 for (stream = 0; stream < 2; stream++)
863 for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
875 snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
876 dev,
877 ss->number ? 0 : 128<<10,
878 256<<10);
864 snd_pcm_set_managed_buffer(ss, SNDRV_DMA_TYPE_DEV_SG,
865 dev,
866 ss->number ? 0 : 128<<10,
867 256<<10);
879}
880
881
882
883/*<--snd_echo_probe() */
884static int snd_echo_new_pcm(struct echoaudio *chip)
885{
886 struct snd_pcm *pcm;

--- 1381 unchanged lines hidden ---
868}
869
870
871
872/*<--snd_echo_probe() */
873static int snd_echo_new_pcm(struct echoaudio *chip)
874{
875 struct snd_pcm *pcm;

--- 1381 unchanged lines hidden ---