Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d55d7a1c authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela
Browse files

[ALSA] oxygen: add symbols for buffer/period size constraints



Introduce symbols for the buffer/period size constraints so that their
limits and relationships become clearer.

Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 4a4bc53b
Loading
Loading
Loading
Loading
+30 −16
Original line number Original line Diff line number Diff line
@@ -24,6 +24,16 @@
#include <sound/pcm_params.h>
#include <sound/pcm_params.h>
#include "oxygen.h"
#include "oxygen.h"


/* most DMA channels have a 16-bit counter for 32-bit words */
#define BUFFER_BYTES_MAX		((1 << 16) * 4)
/* the multichannel DMA channel has a 24-bit counter */
#define BUFFER_BYTES_MAX_MULTICH	((1 << 24) * 4)

#define PERIOD_BYTES_MIN		64

#define DEFAULT_BUFFER_BYTES		(BUFFER_BYTES_MAX / 2)
#define DEFAULT_BUFFER_BYTES_MULTICH	(1024 * 1024)

static const struct snd_pcm_hardware oxygen_stereo_hardware = {
static const struct snd_pcm_hardware oxygen_stereo_hardware = {
	.info = SNDRV_PCM_INFO_MMAP |
	.info = SNDRV_PCM_INFO_MMAP |
		SNDRV_PCM_INFO_MMAP_VALID |
		SNDRV_PCM_INFO_MMAP_VALID |
@@ -44,11 +54,11 @@ static const struct snd_pcm_hardware oxygen_stereo_hardware = {
	.rate_max = 192000,
	.rate_max = 192000,
	.channels_min = 2,
	.channels_min = 2,
	.channels_max = 2,
	.channels_max = 2,
	.buffer_bytes_max = 256 * 1024,
	.buffer_bytes_max = BUFFER_BYTES_MAX,
	.period_bytes_min = 128,
	.period_bytes_min = PERIOD_BYTES_MIN,
	.period_bytes_max = 128 * 1024,
	.period_bytes_max = BUFFER_BYTES_MAX / 2,
	.periods_min = 2,
	.periods_min = 2,
	.periods_max = 2048,
	.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
};
};
static const struct snd_pcm_hardware oxygen_multichannel_hardware = {
static const struct snd_pcm_hardware oxygen_multichannel_hardware = {
	.info = SNDRV_PCM_INFO_MMAP |
	.info = SNDRV_PCM_INFO_MMAP |
@@ -70,11 +80,11 @@ static const struct snd_pcm_hardware oxygen_multichannel_hardware = {
	.rate_max = 192000,
	.rate_max = 192000,
	.channels_min = 2,
	.channels_min = 2,
	.channels_max = 8,
	.channels_max = 8,
	.buffer_bytes_max = 2048 * 1024,
	.buffer_bytes_max = BUFFER_BYTES_MAX_MULTICH,
	.period_bytes_min = 128,
	.period_bytes_min = PERIOD_BYTES_MIN,
	.period_bytes_max = 256 * 1024,
	.period_bytes_max = BUFFER_BYTES_MAX_MULTICH / 2,
	.periods_min = 2,
	.periods_min = 2,
	.periods_max = 16384,
	.periods_max = BUFFER_BYTES_MAX_MULTICH / PERIOD_BYTES_MIN,
};
};
static const struct snd_pcm_hardware oxygen_ac97_hardware = {
static const struct snd_pcm_hardware oxygen_ac97_hardware = {
	.info = SNDRV_PCM_INFO_MMAP |
	.info = SNDRV_PCM_INFO_MMAP |
@@ -88,11 +98,11 @@ static const struct snd_pcm_hardware oxygen_ac97_hardware = {
	.rate_max = 48000,
	.rate_max = 48000,
	.channels_min = 2,
	.channels_min = 2,
	.channels_max = 2,
	.channels_max = 2,
	.buffer_bytes_max = 256 * 1024,
	.buffer_bytes_max = BUFFER_BYTES_MAX,
	.period_bytes_min = 128,
	.period_bytes_min = PERIOD_BYTES_MIN,
	.period_bytes_max = 128 * 1024,
	.period_bytes_max = BUFFER_BYTES_MAX / 2,
	.periods_min = 2,
	.periods_min = 2,
	.periods_max = 2048,
	.periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN,
};
};


static const struct snd_pcm_hardware *const oxygen_hardware[PCM_COUNT] = {
static const struct snd_pcm_hardware *const oxygen_hardware[PCM_COUNT] = {
@@ -664,12 +674,14 @@ int oxygen_pcm_init(struct oxygen *chip)
			snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
			snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
						      SNDRV_DMA_TYPE_DEV,
						      SNDRV_DMA_TYPE_DEV,
						      snd_dma_pci_data(chip->pci),
						      snd_dma_pci_data(chip->pci),
						      512 * 1024, 2048 * 1024);
						      DEFAULT_BUFFER_BYTES_MULTICH,
						      BUFFER_BYTES_MAX_MULTICH);
		if (ins)
		if (ins)
			snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
			snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
						      SNDRV_DMA_TYPE_DEV,
						      SNDRV_DMA_TYPE_DEV,
						      snd_dma_pci_data(chip->pci),
						      snd_dma_pci_data(chip->pci),
						      128 * 1024, 256 * 1024);
						      DEFAULT_BUFFER_BYTES,
						      BUFFER_BYTES_MAX);
	}
	}


	outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
	outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
@@ -689,7 +701,8 @@ int oxygen_pcm_init(struct oxygen *chip)
		strcpy(pcm->name, "Digital");
		strcpy(pcm->name, "Digital");
		snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
		snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						      snd_dma_pci_data(chip->pci),
						      snd_dma_pci_data(chip->pci),
						      128 * 1024, 256 * 1024);
						      DEFAULT_BUFFER_BYTES,
						      BUFFER_BYTES_MAX);
	}
	}


	if (chip->has_ac97_1) {
	if (chip->has_ac97_1) {
@@ -719,7 +732,8 @@ int oxygen_pcm_init(struct oxygen *chip)
		strcpy(pcm->name, outs ? "Front Panel" : "Analog 2");
		strcpy(pcm->name, outs ? "Front Panel" : "Analog 2");
		snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
		snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						      snd_dma_pci_data(chip->pci),
						      snd_dma_pci_data(chip->pci),
						      128 * 1024, 256 * 1024);
						      DEFAULT_BUFFER_BYTES,
						      BUFFER_BYTES_MAX);
	}
	}
	return 0;
	return 0;
}
}