Пример #1
0
/* TO DO: set up to handle more than one pcm instance */
static int __init snd_aicapcmchip(struct snd_card_aica
				  *dreamcastcard, int pcm_index)
{
	struct snd_pcm *pcm;
	int err;
	/* AICA has no capture ability */
	err =
	    snd_pcm_new(dreamcastcard->card, "AICA PCM", pcm_index, 1, 0,
			&pcm);
	if (unlikely(err < 0))
		return err;
	pcm->private_data = dreamcastcard;
	strcpy(pcm->name, "AICA PCM");
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_aicapcm_playback_ops);
	/* Allocate the DMA buffers */
	err =
	    snd_pcm_lib_preallocate_pages_for_all(pcm,
						  SNDRV_DMA_TYPE_CONTINUOUS,
						  snd_dma_continuous_data
						  (GFP_KERNEL),
						  AICA_BUFFER_SIZE,
						  AICA_BUFFER_SIZE);
	return err;
}
Пример #2
0
static int __devinit snd_card_capture_allocate(pcm_hw_t *snd_card, int device,char* name)
{
	int err;
	snd_pcm_t *pcm;

	err = snd_pcm_new(snd_card->card,name,device, 0, 1, &pcm);
	if (err < 0)
		return err;

	
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_capture_ops_pcm);


	pcm->private_data = snd_card;
	pcm->private_free = snd_card_pcm_free;
	pcm->info_flags   = 0;
	snd_card->pcm = pcm;
	strcpy(pcm->name, name);

	snd_pcm_lib_preallocate_pages_for_all(pcm,
					SNDRV_DMA_TYPE_CONTINUOUS,
					snd_dma_continuous_data(GFP_KERNEL),
					PCM_PREALLOC_SIZE,
					PCM_PREALLOC_MAX);
	return 0;
}
Пример #3
0
/* create a PCM device */
static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
{
	struct snd_pcm *pcm;
	int err;

	err = snd_pcm_new(line6pcm->line6->card,
			  (char *)line6pcm->line6->properties->name,
			  0, 1, 1, &pcm);
	if (err < 0)
		return err;

	pcm->private_data = line6pcm;
	pcm->private_free = line6_cleanup_pcm;
	line6pcm->pcm = pcm;
	strcpy(pcm->name, line6pcm->line6->properties->name);

	/* set operators */
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_line6_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_line6_capture_ops);

	/* pre-allocation of buffers */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
					      snd_dma_continuous_data
					      (GFP_KERNEL), 64 * 1024,
					      128 * 1024);

	return 0;
}
Пример #4
0
int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535au)
{
	struct snd_pcm *pcm;
	int err;

	err = snd_pcm_new(cs5535au->card, "CS5535 Audio", 0, 1, 1, &pcm);
	if (err < 0)
		return err;

	cs5535au->dmas[CS5535AUDIO_DMA_PLAYBACK].ops =
					&snd_cs5535audio_playback_dma_ops;
	cs5535au->dmas[CS5535AUDIO_DMA_CAPTURE].ops =
					&snd_cs5535audio_capture_dma_ops;
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
					&snd_cs5535audio_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
					&snd_cs5535audio_capture_ops);

	pcm->private_data = cs5535au;
	pcm->info_flags = 0;
	strcpy(pcm->name, "CS5535 Audio");

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					snd_dma_pci_data(cs5535au->pci),
					64*1024, 128*1024);
	cs5535au->pcm = pcm;

	return 0;
}
Пример #5
0
static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_dai *dai = rtd->cpu_dai;
	struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev);
	struct snd_pcm *pcm = rtd->pcm;
	unsigned int size;
	int retval = 0;
	struct skl *skl = ebus_to_skl(ebus);

	if (dai->driver->playback.channels_min ||
		dai->driver->capture.channels_min) {
		/* buffer pre-allocation */
		size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
		if (size > MAX_PREALLOC_SIZE)
			size = MAX_PREALLOC_SIZE;
		retval = snd_pcm_lib_preallocate_pages_for_all(pcm,
						SNDRV_DMA_TYPE_DEV_SG,
						snd_dma_pci_data(skl->pci),
						size, MAX_PREALLOC_SIZE);
		if (retval) {
			dev_err(dai->dev, "dma buffer allocationf fail\n");
			return retval;
		}
	}

	return retval;
}
Пример #6
0
static int hi3620_digital_new(struct snd_card *card,
        struct snd_soc_dai *dai, struct snd_pcm *pcm)
{
    int ret = 0;

    IN_FUNCTION;

    if (!card->dev->dma_mask) {
        logi("%s : dev->dma_mask not set\n", __FUNCTION__);
        card->dev->dma_mask = &hi3620_digital_dmamask;
    }

    if (!card->dev->coherent_dma_mask) {
        logi("%s : dev->coherent_dma_mask not set\n", __FUNCTION__);
        card->dev->coherent_dma_mask = hi3620_digital_dmamask;
    }
    ret = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
            pcm->card->dev, HI3620_MAX_BUFFER_SIZE, HI3620_MAX_BUFFER_SIZE);
    if (ret) {
        loge("snd_pcm_lib_preallocate_pages_for_all error : %d\n", ret);
        return ret;
    }
    logi("%s: pcm->device = 0\n", __FUNCTION__);
    ret = request_irq(g_hi3620_asp_irq_line, hi3620_intr_handle_digital,
            IRQF_SHARED, "ASP", pcm);

    if (ret) {
        loge("request_irq error : %d\n", ret);
        snd_pcm_lib_preallocate_free_for_all(pcm);
    }

    OUT_FUNCTION;

    return ret;
}
int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm)
{
	int error;
	struct snd_pcm *pcm;

	if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm)))
		return error;

	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1816a_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1816a_capture_ops);

	pcm->private_data = chip;
	pcm->info_flags = (chip->dma1 == chip->dma2 ) ? SNDRV_PCM_INFO_JOINT_DUPLEX : 0;

	strcpy(pcm->name, snd_ad1816a_chip_id(chip));
	snd_ad1816a_init(chip);

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					      snd_dma_isa_data(),
					      64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);

	chip->pcm = pcm;
	if (rpcm)
		*rpcm = pcm;
	return 0;
}
Пример #8
0
static int snd_em8300_pcm_digital(em8300_alsa_t *em8300_alsa)
{
	struct em8300_s *em = em8300_alsa->em;
	struct snd_pcm *pcm;
	int ret;

	ret = snd_pcm_new(em8300_alsa->card, "EM8300 PCM Digital",
			EM8300_ALSA_DIGITAL_DEVICENUM,
			1, /* 1 playback substream */
			0, /* 0 capture substream */
			&pcm);

	if (ret) {
		printk(KERN_ERR "em8300-alsa: snd_em8300_pcm_digital failed with err %d\n", ret);
		return ret;
	}

	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_em8300_playback_ops);

	pcm->private_data = em8300_alsa;
	pcm->private_free = snd_em8300_pcm_digital_free;
	pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;

	strcpy(pcm->name, "EM8300 IEC958");

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					      snd_dma_pci_data(em->pci_dev),
					      0,
					      EM8300_MID_BUFFER_SIZE);

	return 0;
}
Пример #9
0
static int
snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
{
	int err;
	struct snd_pcm *pcm;

	err = snd_pcm_new(chip->card, chip->card->driver, device, 1, 1, &pcm);
	if (err < 0)
		return err;

	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 
			&snd_ad1889_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
			&snd_ad1889_capture_ops);

	pcm->private_data = chip;
	pcm->info_flags = 0;
	strcpy(pcm->name, chip->card->shortname);
	
	chip->pcm = pcm;
	chip->psubs = NULL;
	chip->csubs = NULL;

	err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						snd_dma_pci_data(chip->pci),
						BUFFER_BYTES_MAX / 2,
						BUFFER_BYTES_MAX);

	if (err < 0) {
		dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
		return err;
	}
	
	return 0;
}
Пример #10
0
/*
 * SSP Platform functions
 */
static int ssp_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
{
	int retval = 0;
	struct snd_soc_dai *dai;
	struct snd_pcm *pcm;

	pr_debug("SSP DAI: FCT %s enters\n",
			__func__);
	/*
	 * Do pre-allocation to all substreams of the given pcm for the
	 * specified DMA type.
	 *
	 */
	dai = soc_runtime->cpu_dai;
	pcm = soc_runtime->pcm;

	if (dai->driver->playback.channels_min ||
			dai->driver->capture.channels_min) {
		retval =  snd_pcm_lib_preallocate_pages_for_all(pcm,
			SNDRV_DMA_TYPE_CONTINUOUS,
			snd_dma_continuous_data(GFP_KERNEL),
			SSP_MIN_BUFFER, SSP_MAX_BUFFER);

		if (retval) {
			pr_err("DMA buffer allocation fail\n");
			return retval;
		}
	}
	return retval;
} /* ssp_platform_pcm_new */
Пример #11
0
int __devinit lola_create_pcm(struct lola *chip)
{
	struct snd_pcm *pcm;
	int i, err;

	for (i = 0; i < 2; i++) {
		err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
					  snd_dma_pci_data(chip->pci),
					  PAGE_SIZE, &chip->pcm[i].bdl);
		if (err < 0)
			return err;
	}

	err = snd_pcm_new(chip->card, "Digigram Lola", 0,
			  chip->pcm[SNDRV_PCM_STREAM_PLAYBACK].num_streams,
			  chip->pcm[SNDRV_PCM_STREAM_CAPTURE].num_streams,
			  &pcm);
	if (err < 0)
		return err;
	strlcpy(pcm->name, "Digigram Lola", sizeof(pcm->name));
	pcm->private_data = chip;
	for (i = 0; i < 2; i++) {
		if (chip->pcm[i].num_streams)
			snd_pcm_set_ops(pcm, i, &lola_pcm_ops);
	}
	/* buffer pre-allocation */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
					      snd_dma_pci_data(chip->pci),
					      1024 * 64, 32 * 1024 * 1024);
	return 0;
}
Пример #12
0
static int __devinit snd_als300_new_pcm(struct snd_als300 *chip)
{
	struct snd_pcm *pcm;
	int err;

	snd_als300_dbgcallenter();
	err = snd_pcm_new(chip->card, "ALS300", 0, 1, 1, &pcm);
	if (err < 0)
		return err;
	pcm->private_data = chip;
	strcpy(pcm->name, "ALS300");
	chip->pcm = pcm;

	/* set operators */
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
				&snd_als300_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
				&snd_als300_capture_ops);

	/* pre-allocation of buffers */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
	snd_dma_pci_data(chip->pci), 64*1024, 64*1024);
	snd_als300_dbgcallleave();
	return 0;
}
Пример #13
0
static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_pcm *pcm = rtd->pcm;
	int ret = 0;

	ret = dma_coerce_mask_and_coherent(rtd->card->dev, DMA_BIT_MASK(32));
	if (ret)
		return ret;

	if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
			pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
		ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
			SNDRV_DMA_TYPE_DEV,
			rtd->card->dev,
			hsw_pcm_hardware.buffer_bytes_max,
			hsw_pcm_hardware.buffer_bytes_max);
		if (ret) {
			dev_err(rtd->dev, "dma buffer allocation failed %d\n",
				ret);
			return ret;
		}
	}

	return ret;
}
Пример #14
0
/*
 * create a pcm instance for via686a/b
 */
static int __devinit snd_via686_pcm_new(struct via82xx_modem *chip)
{
	struct snd_pcm *pcm;
	int err;

	chip->playback_devno = 0;
	chip->capture_devno = 1;
	chip->num_devs = 2;
	chip->intr_mask = 0x330000; /* FLAGS | EOL for MR, MW */

	err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm);
	if (err < 0)
		return err;
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops);
	pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
	pcm->private_data = chip;
	strcpy(pcm->name, chip->card->shortname);
	chip->pcms[0] = pcm;
	init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
	init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);

	if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
							 snd_dma_pci_data(chip->pci),
							 64*1024, 128*1024)) < 0)
		return err;

	return 0;
}
Пример #15
0
int snd_bcm2835_new_spdif_pcm(struct bcm2835_chip *chip)
{
	struct snd_pcm *pcm;
	int err;

	audio_info(" .. IN\n");
	if (mutex_lock_interruptible(&chip->audio_mutex)) {
		audio_error("Interrupted whilst waiting for lock\n");
		return -EINTR;
	}
	err = snd_pcm_new(chip->card, "bcm2835 ALSA", 1, 1, 0, &pcm);
	if (err < 0)
		goto out;

	pcm->private_data = chip;
	strcpy(pcm->name, "bcm2835 IEC958/HDMI");
	chip->pcm_spdif = pcm;
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_bcm2835_playback_spdif_ops);

	/* pre-allocation of buffers */
	/* NOTE: this may fail */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
		snd_dma_continuous_data(GFP_KERNEL),
		snd_bcm2835_playback_spdif_hw.buffer_bytes_max, snd_bcm2835_playback_spdif_hw.buffer_bytes_max);
out:
	mutex_unlock(&chip->audio_mutex);
	audio_info(" .. OUT\n");

	return 0;
}
Пример #16
0
/* create a pcm device */
int __devinit snd_bcm2835_new_pcm(bcm2835_chip_t * chip)
{
	struct snd_pcm *pcm;
	int err;

	audio_info(" .. IN\n");
	err =
	    snd_pcm_new(chip->card, "bcm2835 ALSA", 0, MAX_SUBSTREAMS, 0, &pcm);
	if (err < 0)
		return err;
	pcm->private_data = chip;
	strcpy(pcm->name, "bcm2835 ALSA");
	chip->pcm = pcm;
	chip->dest = AUDIO_DEST_AUTO;
	chip->volume = 100;
	/* set operators */
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_bcm2835_playback_ops);

	/* pre-allocation of buffers */
	/* NOTE: this may fail */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
					      snd_dma_continuous_data
					      (GFP_KERNEL), 64 * 1024,
					      64 * 1024);

	audio_info(" .. OUT\n");

	return 0;
}
Пример #17
0
static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device,
					int substreams)
{
	struct snd_pcm *pcm;
	struct snd_pcm_ops *ops;
	int err;

	err = snd_pcm_new(dummy->card, "Dummy PCM", device,
			       substreams, substreams, &pcm);
	if (err < 0)
		return err;
	dummy->pcm = pcm;
	if (fake_buffer)
		ops = &dummy_pcm_ops_no_buf;
	else
		ops = &dummy_pcm_ops;
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, ops);
	pcm->private_data = dummy;
	pcm->info_flags = 0;
	strcpy(pcm->name, "Dummy PCM");
	if (!fake_buffer) {
		snd_pcm_lib_preallocate_pages_for_all(pcm,
			SNDRV_DMA_TYPE_CONTINUOUS,
			snd_dma_continuous_data(GFP_KERNEL),
			0, 64*1024);
	}
	return 0;
}
Пример #18
0
static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
	return snd_pcm_lib_preallocate_pages_for_all(
		rtd->pcm,
		SNDRV_DMA_TYPE_DEV,
		rtd->card->snd_card->dev,
		PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
}
Пример #19
0
static int dw_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
    size_t size = dw_pcm_hardware.buffer_bytes_max;

    return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
            SNDRV_DMA_TYPE_CONTINUOUS,
            snd_dma_continuous_data(GFP_KERNEL), size, size);
}
/*
 * intel_alsa_create_pcm_device : to setup pcm for the card
 *
 * Input parameters
 *		@card : pointer to the sound card structure
 *		@p_alsa_ssp_snd_card : pointer to internal context
 *
 * Output parameters
 *		@ret_val : status, 0 ==> OK
 *
 */
static int intel_alsa_create_pcm_device(struct snd_card *card,
                                        struct intel_alsa_ssp_card_info *p_alsa_ssp_snd_card)
{
    struct snd_pcm *pl_pcm;
    int i, ret_val = 0;

    WARN(!card, "ALSA_SSP: ERROR NULL card\n");
    if (!card)
        return -EINVAL;

    WARN(!p_alsa_ssp_snd_card,
         "ALSA_SSP: ERROR NULL p_alsa_ssp_snd_card\n");
    if (!p_alsa_ssp_snd_card)
        return -EINVAL;

    /*
     * The alsa_ssp driver handles provide 2 PCM devices :
     * device 0 ==> BT with 1 capture sub-stream + 1 play sub-stream
     * device 1 ==> FM with 1 capture sub-stream + 0 play sub-stream
     * These 2 devices are exclusive
     */
    for (i = 0; i < INTEL_ALSA_SSP_SND_CARD_MAX_DEVICES; i++) {

        ret_val = snd_pcm_new(card, s_dev_info[i].dev_name, i,
                              s_dev_info[i].nb_play_stream,
                              s_dev_info[i].nb_capt_stream,
                              &pl_pcm);

        if (ret_val)
            return ret_val;

        /* setup the ops for playback and capture streams */
        snd_pcm_set_ops(pl_pcm, SNDRV_PCM_STREAM_PLAYBACK,
                        &s_alsa_ssp_playback_ops);
        snd_pcm_set_ops(pl_pcm, SNDRV_PCM_STREAM_CAPTURE,
                        &s_alsa_ssp_capture_ops);

        /* setup private data which can be retrieved when required */
        pl_pcm->private_data = p_alsa_ssp_snd_card;
        pl_pcm->info_flags = 0;

        strncpy(pl_pcm->name, card->shortname, strlen(card->shortname));

        /*
         * allocate DMA pages for ALSA stream operations pre-allocation
         * to all substreams of the given pcm for the specified DMA type
         */
        snd_pcm_lib_preallocate_pages_for_all(pl_pcm,
                                              SNDRV_DMA_TYPE_CONTINUOUS,
                                              snd_dma_continuous_data
                                              (GFP_KERNEL),
                                              s_dev_info[i].stream_hw_param->buffer_bytes_max,
                                              s_dev_info[i].stream_hw_param->buffer_bytes_max);
    }

    return ret_val;
}
Пример #21
0
static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
	size_t size;
	struct snd_card *card = rtd->card->snd_card;
	struct snd_pcm *pcm = rtd->pcm;
	struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);

	size = afe->mtk_afe_hardware->buffer_bytes_max;
	return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						     card->dev, size, size);
}
static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
	size_t size;
	struct snd_card *card = rtd->card->snd_card;
	struct snd_pcm *pcm = rtd->pcm;
	struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
	struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);

	size = afe->mtk_afe_hardware->buffer_bytes_max;
	return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						     card->dev, size, size);
}
Пример #23
0
static int nuc900_dma_new(struct snd_card *card,
                          struct snd_soc_dai *dai, struct snd_pcm *pcm)
{
    if (!card->dev->dma_mask)
        card->dev->dma_mask = &nuc900_pcm_dmamask;
    if (!card->dev->coherent_dma_mask)
        card->dev->coherent_dma_mask = DMA_BIT_MASK(32);

    snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
                                          card->dev, 4 * 1024, (4 * 1024) - 1);

    return 0;
}
static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_card *card = rtd->card->snd_card;
	size_t size = bf5xx_pcm_hardware.buffer_bytes_max;
	int ret;

	pr_debug("%s enter\n", __func__);
	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
	if (ret)
		return ret;

	return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
				SNDRV_DMA_TYPE_DEV, card->dev, size, size);
}
Пример #25
0
/* create a pcm device */
static int __devinit snd_vortex_new_pcm(vortex_t *chip, int idx, int nr)
{
	struct snd_pcm *pcm;
	struct snd_kcontrol *kctl;
	int i;
	int err, nr_capt;

	if (!chip || idx < 0 || idx >= VORTEX_PCM_LAST)
		return -ENODEV;

	/* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the 
	 * same dma engine. WT uses it own separate dma engine which can't capture. */
	if (idx == VORTEX_PCM_ADB)
		nr_capt = nr;
	else
		nr_capt = 0;
	err = snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr,
			  nr_capt, &pcm);
	if (err < 0)
		return err;
	snprintf(pcm->name, sizeof(pcm->name),
		"%s %s", CARD_NAME_SHORT, vortex_pcm_name[idx]);
	chip->pcm[idx] = pcm;
	// This is an evil hack, but it saves a lot of duplicated code.
	VORTEX_PCM_TYPE(pcm) = idx;
	pcm->private_data = chip;
	/* set operators */
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
			&snd_vortex_playback_ops);
	if (idx == VORTEX_PCM_ADB)
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
				&snd_vortex_playback_ops);
	
	/* pre-allocation of Scatter-Gather buffers */
	
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
					      snd_dma_pci_data(chip->pci_dev),
					      0x10000, 0x10000);

	if (VORTEX_PCM_TYPE(pcm) == VORTEX_PCM_SPDIF) {
		for (i = 0; i < ARRAY_SIZE(snd_vortex_mixer_spdif); i++) {
			kctl = snd_ctl_new1(&snd_vortex_mixer_spdif[i], chip);
			if (!kctl)
				return -ENOMEM;
			if ((err = snd_ctl_add(chip->card, kctl)) < 0)
				return err;
		}
	}
	return 0;
}
Пример #26
0
int usbtv_audio_init(struct usbtv *usbtv)
{
	int rv;
	struct snd_card *card;
	struct snd_pcm *pcm;

	INIT_WORK(&usbtv->snd_trigger, snd_usbtv_trigger);
	atomic_set(&usbtv->snd_stream, 0);

	rv = snd_card_new(&usbtv->udev->dev, SNDRV_DEFAULT_IDX1, "usbtv",
		THIS_MODULE, 0, &card);
	if (rv < 0)
		return rv;

	strlcpy(card->driver, usbtv->dev->driver->name, sizeof(card->driver));
	strlcpy(card->shortname, "usbtv", sizeof(card->shortname));
	snprintf(card->longname, sizeof(card->longname),
		"USBTV Audio at bus %d device %d", usbtv->udev->bus->busnum,
		usbtv->udev->devnum);

	snd_card_set_dev(card, usbtv->dev);

	usbtv->snd = card;

	rv = snd_pcm_new(card, "USBTV Audio", 0, 0, 1, &pcm);
	if (rv < 0)
		goto err;

	strlcpy(pcm->name, "USBTV Audio Input", sizeof(pcm->name));
	pcm->info_flags = 0;
	pcm->private_data = usbtv;

	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usbtv_pcm_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
		snd_dma_continuous_data(GFP_KERNEL), USBTV_AUDIO_BUFFER,
		USBTV_AUDIO_BUFFER);

	rv = snd_card_register(card);
	if (rv)
		goto err;

	return 0;

err:
	usbtv->snd = NULL;
	snd_card_free(card);

	return rv;
}
Пример #27
0
static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_card *card = rtd->card->snd_card;
	struct snd_pcm *pcm = rtd->pcm;
	int ret;

	ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
	if (ret)
		return ret;

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
		card->dev, 4 * 1024, (4 * 1024) - 1);

	return 0;
}
Пример #28
0
/**
 * snd_intelmad_pcm_new - to setup pcm for the card
 *
 * @card:  pointer to the sound card structure
 * @intelmaddata: pointer to internal context
 * @pb: playback count for this card
 * @cap: capture count for this card
 * @index: device index
 *
 * This function is called from probe function to set up pcm params
 * and functions
 */
static int __devinit snd_intelmad_pcm_new(struct snd_card *card,
			struct snd_intelmad *intelmaddata,
			unsigned int pb, unsigned int cap, unsigned int index)
{
	int ret_val = 0;
	struct snd_pcm *pcm;
	char name[32] = INTEL_MAD;
	struct snd_pcm_ops *pb_ops = NULL, *cap_ops = NULL;

	pr_debug("called for pb %d, cp %d, idx %d\n", pb, cap, index);
	ret_val = snd_pcm_new(card, name, index, pb, cap, &pcm);
	if (ret_val)
		return ret_val;
	/* setup the ops for playback and capture streams */
	switch (index) {
	case 0:
		pb_ops = &snd_intelmad_headset_ops;
		cap_ops = &snd_intelmad_capture_ops;
		break;
	case 1:
		pb_ops = &snd_intelmad_ihf_ops;
		cap_ops = &snd_intelmad_capture_ops;
		break;
	case 2:
		pb_ops = &snd_intelmad_vibra_ops;
		cap_ops = &snd_intelmad_capture_ops;
		break;
	case 3:
		pb_ops = &snd_intelmad_haptic_ops;
		cap_ops = &snd_intelmad_capture_ops;
		break;
	}
	if (pb)
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, pb_ops);
	if (cap)
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, cap_ops);
	/* setup private data which can be retrieved when required */
	pcm->private_data = intelmaddata;
	pcm->private_free = snd_intelmad_page_free;
	pcm->info_flags = 0;
	strncpy(pcm->name, card->shortname, strlen(card->shortname));
	/* allocate dma pages for ALSA stream operations */
	snd_pcm_lib_preallocate_pages_for_all(pcm,
			SNDRV_DMA_TYPE_CONTINUOUS,
			snd_dma_continuous_data(GFP_KERNEL),
			MIN_BUFFER, MAX_BUFFER);
	return ret_val;
}
Пример #29
0
static int mxs_pcm_new(struct snd_card *card,
			    struct snd_soc_dai *dai, struct snd_pcm *pcm)
{
	size_t size = mxs_pcm_hardware.buffer_bytes_max;

	if (!card->dev->dma_mask)
		card->dev->dma_mask = &mxs_pcm_dma_mask;

	if (!card->dev->coherent_dma_mask)
		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, NULL,
					      size, size);

	return 0;
}
Пример #30
0
static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_card *card = rtd->card->snd_card;
	struct snd_soc_dai *dai = rtd->cpu_dai;
	struct snd_pcm *pcm = rtd->pcm;

	if (!card->dev->dma_mask)
		card->dev->dma_mask = &nuc900_pcm_dmamask;
	if (!card->dev->coherent_dma_mask)
		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
		card->dev, 4 * 1024, (4 * 1024) - 1);

	return 0;
}