Skip to content

Commit

Permalink
ALSA: hda - Add Kconfig for the default buffer size
Browse files Browse the repository at this point in the history
Add a Kconfig entry to specify the default buffer size.
Distros using PulseAudio can choose a larger value here.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Jul 12, 2011
1 parent 30b4503 commit acfa634
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions sound/pci/hda/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ menuconfig SND_HDA_INTEL

if SND_HDA_INTEL

config SND_HDA_PREALLOC_SIZE
int "Pre-allocated buffer size for HD-audio driver"
range 0 32768
default 64
help
Speficies the default pre-allocated buffer-size in kB for
HD-audio driver. A larger buffer (e.g. 2048) is preferred
for systems with PulseAudio. The default 64 is chosen just
from the compatibility reason.

Note that the pre-allocation size can be changed dynamically
via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too.

config SND_HDA_HWDEP
bool "Build hwdep interface for HD-audio driver"
select SND_HWDEP
Expand Down
8 changes: 7 additions & 1 deletion sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,8 @@ static void azx_pcm_free(struct snd_pcm *pcm)
}
}

#define MAX_PREALLOC_SIZE (32 * 1024 * 1024)

static int
azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
struct hda_pcm *cpcm)
Expand All @@ -2083,6 +2085,7 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
struct snd_pcm *pcm;
struct azx_pcm *apcm;
int pcm_dev = cpcm->device;
unsigned int size;
int s, err;

if (pcm_dev >= HDA_MAX_PCMS) {
Expand Down Expand Up @@ -2118,9 +2121,12 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
}
/* buffer pre-allocation */
size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
if (size > MAX_PREALLOC_SIZE)
size = MAX_PREALLOC_SIZE;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci),
1024 * 64, 32 * 1024 * 1024);
size, MAX_PREALLOC_SIZE);
return 0;
}

Expand Down

0 comments on commit acfa634

Please sign in to comment.