Jesse Keating 2f82dda
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
Jesse Keating 2f82dda
index c8d9178..7d3bb15 100644
Jesse Keating 2f82dda
--- a/sound/pci/hda/hda_intel.c
Jesse Keating 2f82dda
+++ b/sound/pci/hda/hda_intel.c
Jesse Keating 2f82dda
@@ -1774,6 +1774,7 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
Jesse Keating 2f82dda
 	struct azx_pcm *apcm;
Jesse Keating 2f82dda
 	int pcm_dev = cpcm->device;
Jesse Keating 2f82dda
 	int s, err;
Jesse Keating 2f82dda
+	size_t prealloc_min = 64*1024;	/* 64KB */
Jesse Keating 2f82dda
 
Jesse Keating 2f82dda
 	if (pcm_dev >= AZX_MAX_PCMS) {
Jesse Keating 2f82dda
 		snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n",
Jesse Keating 2f82dda
@@ -1807,10 +1808,21 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
Jesse Keating 2f82dda
 		if (cpcm->stream[s].substreams)
Jesse Keating 2f82dda
 			snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
Jesse Keating 2f82dda
 	}
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
 	/* buffer pre-allocation */
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
+	/* subtle, don't allocate a big buffer for modems...
Jesse Keating 2f82dda
+	 * also, don't just test 32BIT_MASK, since azx supports
Jesse Keating 2f82dda
+	 * 64-bit DMA in some cases.
Jesse Keating 2f82dda
+	 */
Jesse Keating 2f82dda
+	/* lennart wants a 2.2MB buffer for 2sec of 48khz */
Jesse Keating 2f82dda
+	if (pcm->dev_class == SNDRV_PCM_CLASS_GENERIC &&
Jesse Keating 2f82dda
+	    chip->pci->dma_mask >= DMA_32BIT_MASK)
Jesse Keating 2f82dda
+		prealloc_min = 4 * 1024 * 1024;	/* 4MB */
Jesse Keating 2f82dda
+
Jesse Keating 2f82dda
 	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
Jesse Keating 2f82dda
 					      snd_dma_pci_data(chip->pci),
Jesse Keating 2f82dda
-					      1024 * 64, 32 * 1024 * 1024);
Jesse Keating 2f82dda
+					      prealloc_min, 32 * 1024 * 1024);
Jesse Keating 2f82dda
 	return 0;
Jesse Keating 2f82dda
 }
Jesse Keating 2f82dda