示例#1
0
文件: cs4231.c 项目: 274914765/C
static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
{
    struct snd_card *card;
    struct snd_cs4231 *chip;
    struct snd_pcm *pcm;
    int error;

    card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
    if (!card)
        return -EINVAL;

    error = snd_cs4231_create(card, port[n], -1, irq[n], dma1[n], dma2[n],
            CS4231_HW_DETECT, 0, &chip);
    if (error < 0)
        goto out;

    card->private_data = chip;

    error = snd_cs4231_pcm(chip, 0, &pcm);
    if (error < 0)
        goto out;

    strcpy(card->driver, "CS4231");
    strcpy(card->shortname, pcm->name);

    sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
        pcm->name, chip->port, irq[n], dma1[n]);
    if (dma2[n] >= 0)
        sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);

    error = snd_cs4231_mixer(chip);
    if (error < 0)
        goto out;

    error = snd_cs4231_timer(chip, 0, NULL);
    if (error < 0)
        goto out;

    if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) {
        if (mpu_irq[n] == SNDRV_AUTO_IRQ)
            mpu_irq[n] = -1;
        if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
                    mpu_port[n], 0, mpu_irq[n],
                    mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
                    NULL) < 0)
            printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id);
    }

    snd_card_set_dev(card, dev);

    error = snd_card_register(card);
    if (error < 0)
        goto out;

    dev_set_drvdata(dev, card);
    return 0;

out:    snd_card_free(card);
    return error;
}
示例#2
0
static int snd_mpu401_create(int dev, struct snd_card **rcard)
{
	struct snd_card *card;
	int err;

	*rcard = NULL;
	card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
	if (card == NULL)
		return -ENOMEM;
	strcpy(card->driver, "MPU-401 UART");
	strcpy(card->shortname, card->driver);
	sprintf(card->longname, "%s at %#lx, ", card->shortname, port[dev]);
	if (irq[dev] >= 0) {
		sprintf(card->longname + strlen(card->longname), "irq %d", irq[dev]);
	} else {
		strcat(card->longname, "polled");
	}

	if ((err = snd_mpu401_uart_new(card, 0,
				       MPU401_HW_MPU401,
				       port[dev], 0,
				       irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) {
		printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
		goto _err;
	}

	*rcard = card;
	return 0;

 _err:
	snd_card_free(card);
	return err;
}
示例#3
0
static int hda_tegra_probe(struct platform_device *pdev)
{
	const unsigned int driver_flags = AZX_DCAPS_CORBRP_SELF_CLEAR;
	struct snd_card *card;
	struct azx *chip;
	struct hda_tegra *hda;
	int err;

	hda = devm_kzalloc(&pdev->dev, sizeof(*hda), GFP_KERNEL);
	if (!hda)
		return -ENOMEM;
	hda->dev = &pdev->dev;
	chip = &hda->chip;

	err = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
			   THIS_MODULE, 0, &card);
	if (err < 0) {
		dev_err(&pdev->dev, "Error creating card!\n");
		return err;
	}

	err = hda_tegra_create(card, driver_flags, hda);
	if (err < 0)
		goto out_free;
	card->private_data = chip;

	dev_set_drvdata(&pdev->dev, card);
	schedule_work(&hda->probe_work);

	return 0;

out_free:
	snd_card_free(card);
	return err;
}
static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
{
	struct snd_card *card;
	struct snd_es1688 *chip;
	struct snd_opl3 *opl3;
	struct snd_pcm *pcm;
	int error;

	card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
	if (!card)
		return -EINVAL;

	error = snd_es1688_legacy_create(card, dev, n, &chip);
	if (error < 0)
		goto out;

	error = snd_es1688_pcm(chip, 0, &pcm);
	if (error < 0)
		goto out;

	error = snd_es1688_mixer(chip);
	if (error < 0)
		goto out;

	strcpy(card->driver, "ES1688");
	strcpy(card->shortname, pcm->name);
	sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
		chip->port, chip->irq, chip->dma8);

	if (snd_opl3_create(card, chip->port, chip->port + 2,
			OPL3_HW_OPL3, 0, &opl3) < 0)
		printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n",
			dev->bus_id, chip->port);
	else {
		error =	snd_opl3_hwdep_new(opl3, 0, 1, NULL);
		if (error < 0)
			goto out;
	}

	if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ &&
			chip->mpu_port > 0) {
		error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
				chip->mpu_port, 0,
				mpu_irq[n], IRQF_DISABLED, NULL);
		if (error < 0)
			goto out;
	}

	snd_card_set_dev(card, dev);

	error = snd_card_register(card);
	if (error < 0)
		goto out;

	dev_set_drvdata(dev, card);
	return 0;

out:	snd_card_free(card);
	return error;
}
示例#5
0
int poseidon_audio_init(struct poseidon *p)
{
	struct poseidon_audio *pa = &p->audio;
	struct snd_card *card;
	struct snd_pcm *pcm;
	int ret;

	ret = snd_card_new(&p->interface->dev, -1, "Telegent",
			   THIS_MODULE, 0, &card);
	if (ret != 0)
		return ret;

	ret = snd_pcm_new(card, "poseidon audio", 0, 0, 1, &pcm);
	if (ret < 0) {
		snd_card_free(card);
		return ret;
	}
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops);
	pcm->info_flags   = 0;
	pcm->private_data = p;
	strcpy(pcm->name, "poseidon audio capture");

	strcpy(card->driver, "ALSA driver");
	strcpy(card->shortname, "poseidon Audio");
	strcpy(card->longname, "poseidon ALSA Audio");

	if (snd_card_register(card)) {
		snd_card_free(card);
		return -ENOMEM;
	}
	pa->card = card;
	return 0;
}
示例#6
0
static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
{
	struct snd_card *card;
	struct soundscape *sscape;
	int ret;

	card = snd_card_new(index[dev], id[dev], THIS_MODULE,
			    sizeof(struct soundscape));
	if (!card)
		return -ENOMEM;

	sscape = get_card_soundscape(card);
	sscape->type = SSCAPE;

	dma[dev] &= 0x03;
	ret = create_sscape(dev, card);
	if (ret < 0)
		goto _release_card;

	snd_card_set_dev(card, pdev);
	if ((ret = snd_card_register(card)) < 0) {
		printk(KERN_ERR "sscape: Failed to register sound card\n");
		goto _release_card;
	}
	dev_set_drvdata(pdev, card);
	return 0;

_release_card:
	snd_card_free(card);
	return ret;
}
示例#7
0
static int __devinit snd_atiixp_probe(struct pci_dev *pci,
                                      const struct pci_device_id *pci_id)
{
    static int dev;
    snd_card_t *card;
    atiixp_t *chip;
    unsigned char revision;
    int err;

    if (dev >= SNDRV_CARDS)
        return -ENODEV;
    if (!enable[dev]) {
        dev++;
        return -ENOENT;
    }

    card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
    if (card == NULL)
        return -ENOMEM;

    pci_read_config_byte(pci, PCI_REVISION_ID, &revision);

    strcpy(card->driver, spdif_aclink[dev] ? "ATIIXP" : "ATIIXP-SPDMA");
    strcpy(card->shortname, "ATI IXP");
    if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
        goto __error;

    if ((err = snd_atiixp_aclink_reset(chip)) < 0)
        goto __error;

    chip->spdif_over_aclink = spdif_aclink[dev];

    if ((err = snd_atiixp_mixer_new(chip, ac97_clock[dev], ac97_quirk[dev])) < 0)
        goto __error;

    if ((err = snd_atiixp_pcm_new(chip)) < 0)
        goto __error;

    snd_atiixp_proc_init(chip);

    snd_atiixp_chip_start(chip);

    snprintf(card->longname, sizeof(card->longname),
             "%s rev %x with %s at %#lx, irq %i", card->shortname, revision,
             chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
             chip->addr, chip->irq);

    snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip);

    if ((err = snd_card_register(card)) < 0)
        goto __error;

    pci_set_drvdata(pci, card);
    dev++;
    return 0;

__error:
    snd_card_free(card);
    return err;
}
示例#8
0
static struct snd_card* create_card(struct usb_device* usb_dev)
{
	int devnum;
	struct snd_card *card;
	struct snd_usb_caiaqdev *dev;

	for (devnum = 0; devnum < SNDRV_CARDS; devnum++)
		if (enable[devnum] && !snd_card_used[devnum])
			break;

	if (devnum >= SNDRV_CARDS)
		return NULL;

	card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, 
					sizeof(struct snd_usb_caiaqdev));
	if (!card)
		return NULL;

	dev = caiaqdev(card);
	dev->chip.dev = usb_dev;
	dev->chip.card = card;
	dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
				  le16_to_cpu(usb_dev->descriptor.idProduct));
	spin_lock_init(&dev->spinlock);
	snd_card_set_dev(card, &usb_dev->dev);

	return card;
}
示例#9
0
文件: motu.c 项目: asmalldev/linux
static void do_registration(struct work_struct *work)
{
	struct snd_motu *motu = container_of(work, struct snd_motu, dwork.work);
	int err;

	if (motu->registered)
		return;

	err = snd_card_new(&motu->unit->device, -1, NULL, THIS_MODULE, 0,
			   &motu->card);
	if (err < 0)
		return;

	name_card(motu);

	err = snd_motu_transaction_register(motu);
	if (err < 0)
		goto error;

	err = snd_motu_stream_init_duplex(motu);
	if (err < 0)
		goto error;

	snd_motu_proc_init(motu);

	err = snd_motu_create_pcm_devices(motu);
	if (err < 0)
		goto error;

	if (motu->spec->flags & SND_MOTU_SPEC_HAS_MIDI) {
		err = snd_motu_create_midi_devices(motu);
		if (err < 0)
			goto error;
	}

	err = snd_motu_create_hwdep_device(motu);
	if (err < 0)
		goto error;

	err = snd_card_register(motu->card);
	if (err < 0)
		goto error;

	/*
	 * After registered, motu instance can be released corresponding to
	 * releasing the sound card instance.
	 */
	motu->card->private_free = motu_card_free;
	motu->card->private_data = motu;
	motu->registered = true;

	return;
error:
	snd_motu_transaction_unregister(motu);
	snd_card_free(motu->card);
	dev_info(&motu->unit->device,
		 "Sound card registration failed: %d\n", err);
}
示例#10
0
static int __devinit snd_vx222_probe(struct pci_dev *pci,
				     const struct pci_device_id *pci_id)
{
	static int dev;
	snd_card_t *card;
	struct snd_vx_hardware *hw;
	struct snd_vx222 *vx;
	int err;

	if (dev >= SNDRV_CARDS)
		return -ENODEV;
	if (!enable[dev]) {
		dev++;
		return -ENOENT;
	}

	card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
	if (card == NULL)
		return -ENOMEM;

	switch ((int)pci_id->driver_data) {
	case VX_PCI_VX222_OLD:
		hw = &vx222_old_hw;
		break;
	case VX_PCI_VX222_NEW:
	default:
		if (mic[dev])
			hw = &vx222_mic_hw;
		else
			hw = &vx222_v2_hw;
		break;
	}
	if ((err = snd_vx222_create(card, pci, hw, &vx)) < 0) {
		snd_card_free(card);
		return err;
	}
	vx->core.ibl.size = ibl[dev];

	sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i",
		card->shortname, vx->port[0], vx->port[1], vx->core.irq);
	snd_printdd("%s at 0x%lx & 0x%lx, irq %i\n",
		    card->shortname, vx->port[0], vx->port[1], vx->core.irq);

	if ((err = snd_vx_hwdep_new(&vx->core)) < 0) {
		snd_card_free(card);
		return err;
	}

	if ((err = snd_card_register(card)) < 0) {
		snd_card_free(card);
		return err;
	}

	pci_set_drvdata(pci, card);
	dev++;
	return 0;
}
示例#11
0
文件: cs4231.c 项目: 383530895/linux
static int snd_cs4231_probe(struct device *dev, unsigned int n)
{
	struct snd_card *card;
	struct snd_wss *chip;
	struct snd_pcm *pcm;
	int error;

	error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
	if (error < 0)
		return error;

	error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], dma2[n],
			WSS_HW_DETECT, 0, &chip);
	if (error < 0)
		goto out;

	card->private_data = chip;

	error = snd_wss_pcm(chip, 0, &pcm);
	if (error < 0)
		goto out;

	strcpy(card->driver, "CS4231");
	strcpy(card->shortname, pcm->name);

	sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
		pcm->name, chip->port, irq[n], dma1[n]);
	if (dma2[n] >= 0)
		sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);

	error = snd_wss_mixer(chip);
	if (error < 0)
		goto out;

	error = snd_wss_timer(chip, 0, NULL);
	if (error < 0)
		goto out;

	if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) {
		if (mpu_irq[n] == SNDRV_AUTO_IRQ)
			mpu_irq[n] = -1;
		if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
					mpu_port[n], 0, mpu_irq[n],
					NULL) < 0)
			dev_warn(dev, "MPU401 not detected\n");
	}

	error = snd_card_register(card);
	if (error < 0)
		goto out;

	dev_set_drvdata(dev, card);
	return 0;

out:	snd_card_free(card);
	return error;
}
示例#12
0
文件: digi00x.c 项目: 513855417/linux
static void do_registration(struct work_struct *work)
{
	struct snd_dg00x *dg00x =
			container_of(work, struct snd_dg00x, dwork.work);
	int err;

	if (dg00x->registered)
		return;

	err = snd_card_new(&dg00x->unit->device, -1, NULL, THIS_MODULE, 0,
			   &dg00x->card);
	if (err < 0)
		return;

	err = name_card(dg00x);
	if (err < 0)
		goto error;

	err = snd_dg00x_stream_init_duplex(dg00x);
	if (err < 0)
		goto error;

	snd_dg00x_proc_init(dg00x);

	err = snd_dg00x_create_pcm_devices(dg00x);
	if (err < 0)
		goto error;

	err = snd_dg00x_create_midi_devices(dg00x);
	if (err < 0)
		goto error;

	err = snd_dg00x_create_hwdep_device(dg00x);
	if (err < 0)
		goto error;

	err = snd_dg00x_transaction_register(dg00x);
	if (err < 0)
		goto error;

	err = snd_card_register(dg00x->card);
	if (err < 0)
		goto error;

	dg00x->card->private_free = dg00x_card_free;
	dg00x->card->private_data = dg00x;
	dg00x->registered = true;

	return;
error:
	snd_dg00x_transaction_unregister(dg00x);
	snd_dg00x_stream_destroy_duplex(dg00x);
	snd_card_free(dg00x->card);
	dev_info(&dg00x->unit->device,
		 "Sound card registration failed: %d\n", err);
}
示例#13
0
文件: motu.c 项目: Anjali05/linux
static void do_registration(struct work_struct *work)
{
	struct snd_motu *motu = container_of(work, struct snd_motu, dwork.work);
	int err;

	if (motu->registered)
		return;

	err = snd_card_new(&motu->unit->device, -1, NULL, THIS_MODULE, 0,
			   &motu->card);
	if (err < 0)
		return;
	motu->card->private_free = motu_card_free;
	motu->card->private_data = motu;

	name_card(motu);

	err = snd_motu_transaction_register(motu);
	if (err < 0)
		goto error;

	err = snd_motu_stream_init_duplex(motu);
	if (err < 0)
		goto error;

	snd_motu_proc_init(motu);

	err = snd_motu_create_pcm_devices(motu);
	if (err < 0)
		goto error;

	if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) ||
	    (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q) ||
	    (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) ||
	    (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) {
		err = snd_motu_create_midi_devices(motu);
		if (err < 0)
			goto error;
	}

	err = snd_motu_create_hwdep_device(motu);
	if (err < 0)
		goto error;

	err = snd_card_register(motu->card);
	if (err < 0)
		goto error;

	motu->registered = true;

	return;
error:
	snd_card_free(motu->card);
	dev_info(&motu->unit->device,
		 "Sound card registration failed: %d\n", err);
}
示例#14
0
文件: tascam.c 项目: Lyude/linux
static void do_registration(struct work_struct *work)
{
	struct snd_tscm *tscm = container_of(work, struct snd_tscm, dwork.work);
	int err;

	err = snd_card_new(&tscm->unit->device, -1, NULL, THIS_MODULE, 0,
			   &tscm->card);
	if (err < 0)
		return;

	err = identify_model(tscm);
	if (err < 0)
		goto error;

	err = snd_tscm_transaction_register(tscm);
	if (err < 0)
		goto error;

	err = snd_tscm_stream_init_duplex(tscm);
	if (err < 0)
		goto error;

	snd_tscm_proc_init(tscm);

	err = snd_tscm_create_pcm_devices(tscm);
	if (err < 0)
		goto error;

	err = snd_tscm_create_midi_devices(tscm);
	if (err < 0)
		goto error;

	err = snd_tscm_create_hwdep_device(tscm);
	if (err < 0)
		goto error;

	err = snd_card_register(tscm->card);
	if (err < 0)
		goto error;

	/*
	 * After registered, tscm instance can be released corresponding to
	 * releasing the sound card instance.
	 */
	tscm->card->private_free = tscm_card_free;
	tscm->card->private_data = tscm;
	tscm->registered = true;

	return;
error:
	snd_tscm_transaction_unregister(tscm);
	snd_tscm_stream_destroy_duplex(tscm);
	snd_card_free(tscm->card);
	dev_info(&tscm->unit->device,
		 "Sound card registration failed: %d\n", err);
}
示例#15
0
static int __devinit brcm_alsa_omx_probe(struct platform_device *pdev)
{
    struct snd_card *card;
    int err;

    DEBUG("\n %lx:probe \n",jiffies);

    err = -ENODEV;
    if (!enable)
        return err;

    err = -ENOMEM;
    card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
                        THIS_MODULE, sizeof(brcm_alsa_chip_t));
    if (!card)
        goto err;

    g_brcm_alsa_chip = (brcm_alsa_chip_t*)card->private_data;
    g_brcm_alsa_chip->card = card;

    card->dev = &pdev->dev;
    strncpy(card->driver, pdev->dev.driver->name, sizeof(card->driver));

    //PCM interface
    err = brcm_alsa_omx_pcm_new(card);
    if (err)
        goto err;

    //CTRL interface
    err = brcm_alsa_omx_ctl_new(card);
    if (err)
        goto err;

    //TODO: other interface


    strcpy(card->driver, "Broadcom");
    strcpy(card->shortname, "Broadcom ALSA");
    sprintf(card->longname, "Broadcom ALSA PCM %i", 0);


    err = snd_card_register(card);
    if (err==0)
    {
        platform_set_drvdata(pdev, card);
        return 0;
    }

err:
    DEBUG("\n probe failed =%d\n",err);
    if (card)
        snd_card_free(card);

    g_brcm_alsa_chip=NULL;
    return err;
}
示例#16
0
static int snd_via82xx_probe(struct pci_dev *pci,
			     const struct pci_device_id *pci_id)
{
	struct snd_card *card;
	struct via82xx_modem *chip;
	int chip_type = 0, card_type;
	unsigned int i;
	int err;

	err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
	if (err < 0)
		return err;

	card_type = pci_id->driver_data;
	switch (card_type) {
	case TYPE_CARD_VIA82XX_MODEM:
		strcpy(card->driver, "VIA82XX-MODEM");
		sprintf(card->shortname, "VIA 82XX modem");
		break;
	default:
		dev_err(card->dev, "invalid card type %d\n", card_type);
		err = -EINVAL;
		goto __error;
	}
		
	if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision,
				      ac97_clock, &chip)) < 0)
		goto __error;
	card->private_data = chip;
	if ((err = snd_via82xx_mixer_new(chip)) < 0)
		goto __error;

	if ((err = snd_via686_pcm_new(chip)) < 0 )
		goto __error;

	/* disable interrupts */
	for (i = 0; i < chip->num_devs; i++)
		snd_via82xx_channel_reset(chip, &chip->devs[i]);

	sprintf(card->longname, "%s at 0x%lx, irq %d",
		card->shortname, chip->port, chip->irq);

	snd_via82xx_proc_init(chip);

	if ((err = snd_card_register(card)) < 0) {
		snd_card_free(card);
		return err;
	}
	pci_set_drvdata(pci, card);
	return 0;

 __error:
	snd_card_free(card);
	return err;
}
示例#17
0
static struct snd_card *snd_bcm2835_card_new(struct device *dev)
{
	struct snd_card *card;
	int ret;

	ret = snd_card_new(dev, -1, NULL, THIS_MODULE, 0, &card);
	if (ret)
		return ERR_PTR(ret);

	return card;
}
示例#18
0
static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
{
	struct snd_card *card;
	struct snd_ac97_bus *ac97_bus;
	struct snd_ac97_template ac97_template;
	int ret;

	ret = -ENOMEM;
	card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
			    THIS_MODULE, 0);
	if (!card)
		goto err;

	card->dev = &dev->dev;
	strncpy(card->driver, dev->dev.driver->name, sizeof(card->driver));

	ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);
	if (ret)
		goto err;

	ret = pxa2xx_ac97_hw_probe(dev);
	if (ret)
		goto err;

	ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus);
	if (ret)
		goto err_remove;
	memset(&ac97_template, 0, sizeof(ac97_template));
	ret = snd_ac97_mixer(ac97_bus, &ac97_template, &pxa2xx_ac97_ac97);
	if (ret)
		goto err_remove;

	snprintf(card->shortname, sizeof(card->shortname),
		 "%s", snd_ac97_get_short_name(pxa2xx_ac97_ac97));
	snprintf(card->longname, sizeof(card->longname),
		 "%s (%s)", dev->dev.driver->name, card->mixername);

	snd_card_set_dev(card, &dev->dev);
	ret = snd_card_register(card);
	if (ret == 0) {
		platform_set_drvdata(dev, card);
		return 0;
	}

err_remove:
	pxa2xx_ac97_hw_remove(dev);
err:
	if (card)
		snd_card_free(card);
	return ret;
}
示例#19
0
static void do_registration(struct work_struct *work)
{
	struct snd_ff *ff = container_of(work, struct snd_ff, dwork.work);
	int err;

	if (ff->registered)
		return;

	err = snd_card_new(&ff->unit->device, -1, NULL, THIS_MODULE, 0,
			   &ff->card);
	if (err < 0)
		return;
	ff->card->private_free = ff_card_free;
	ff->card->private_data = ff;

	err = snd_ff_transaction_register(ff);
	if (err < 0)
		goto error;

	name_card(ff);

	err = snd_ff_stream_init_duplex(ff);
	if (err < 0)
		goto error;

	snd_ff_proc_init(ff);

	err = snd_ff_create_midi_devices(ff);
	if (err < 0)
		goto error;

	err = snd_ff_create_pcm_devices(ff);
	if (err < 0)
		goto error;

	err = snd_ff_create_hwdep_devices(ff);
	if (err < 0)
		goto error;

	err = snd_card_register(ff->card);
	if (err < 0)
		goto error;

	ff->registered = true;

	return;
error:
	snd_card_free(ff->card);
	dev_info(&ff->unit->device,
		 "Sound card registration failed: %d\n", err);
}
示例#20
0
struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
{
	struct snd_card *card;
	struct cx23885_audio_dev *chip;
	int err;

	if (disable_analog_audio)
		return NULL;

	if (dev->sram_channels[AUDIO_SRAM_CHANNEL].cmds_start == 0) {
		printk(KERN_WARNING "%s(): Missing SRAM channel configuration "
			"for analog TV Audio\n", __func__);
		return NULL;
	}

	err = snd_card_new(&dev->pci->dev,
			   SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
			THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);
	if (err < 0)
		goto error;

	chip = (struct cx23885_audio_dev *) card->private_data;
	chip->dev = dev;
	chip->pci = dev->pci;
	chip->card = card;
	spin_lock_init(&chip->lock);

	err = snd_cx23885_pcm(chip, 0, "CX23885 Digital");
	if (err < 0)
		goto error;

	strcpy(card->driver, "CX23885");
	sprintf(card->shortname, "Conexant CX23885");
	sprintf(card->longname, "%s at %s", card->shortname, dev->name);

	err = snd_card_register(card);
	if (err < 0)
		goto error;

	dprintk(0, "registered ALSA audio device\n");

	return chip;

error:
	snd_card_free(card);
	printk(KERN_ERR "%s(): Failed to register analog "
			"audio adapter\n", __func__);

	return NULL;
}
示例#21
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;
}
示例#22
0
static int snd_als300_probe(struct pci_dev *pci,
                             const struct pci_device_id *pci_id)
{
	static int dev;
	struct snd_card *card;
	struct snd_als300 *chip;
	int err, chip_type;

	if (dev >= SNDRV_CARDS)
		return -ENODEV;
	if (!enable[dev]) {
		dev++;
		return -ENOENT;
	}

	err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
			   0, &card);

	if (err < 0)
		return err;

	chip_type = pci_id->driver_data;

	if ((err = snd_als300_create(card, pci, chip_type, &chip)) < 0) {
		snd_card_free(card);
		return err;
	}
	card->private_data = chip;

	strcpy(card->driver, "ALS300");
	if (chip->chip_type == DEVICE_ALS300_PLUS)
		/* don't know much about ALS300+ yet
		 * print revision number for now */
		sprintf(card->shortname, "ALS300+ (Rev. %d)", chip->revision);
	else
		sprintf(card->shortname, "ALS300 (Rev. %c)", 'A' +
							chip->revision - 1);
	sprintf(card->longname, "%s at 0x%lx irq %i",
				card->shortname, chip->port, chip->irq);

	if ((err = snd_card_register(card)) < 0) {
		snd_card_free(card);
		return err;
	}
	pci_set_drvdata(pci, card);
	dev++;
	return 0;
}
示例#23
0
文件: atiixp.c 项目: 3null/linux
static int snd_atiixp_probe(struct pci_dev *pci,
			    const struct pci_device_id *pci_id)
{
	struct snd_card *card;
	struct atiixp *chip;
	int err;

	err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
	if (err < 0)
		return err;

	strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
	strcpy(card->shortname, "ATI IXP");
	if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
		goto __error;
	card->private_data = chip;

	if ((err = snd_atiixp_aclink_reset(chip)) < 0)
		goto __error;

	chip->spdif_over_aclink = spdif_aclink;

	if ((err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk)) < 0)
		goto __error;

	if ((err = snd_atiixp_pcm_new(chip)) < 0)
		goto __error;
	
	snd_atiixp_proc_init(chip);

	snd_atiixp_chip_start(chip);

	snprintf(card->longname, sizeof(card->longname),
		 "%s rev %x with %s at %#lx, irq %i", card->shortname,
		 pci->revision,
		 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
		 chip->addr, chip->irq);

	if ((err = snd_card_register(card)) < 0)
		goto __error;

	pci_set_drvdata(pci, card);
	return 0;

 __error:
	snd_card_free(card);
	return err;
}
示例#24
0
static int snd_adlib_probe(struct device *dev, unsigned int n)
{
	struct snd_card *card;
	struct snd_opl3 *opl3;
	int error;

	error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
	if (error < 0) {
		dev_err(dev, "could not create card\n");
		return error;
	}

	card->private_data = request_region(port[n], 4, CRD_NAME);
	if (!card->private_data) {
		dev_err(dev, "could not grab ports\n");
		error = -EBUSY;
		goto out;
	}
	card->private_free = snd_adlib_free;

	strcpy(card->driver, DEV_NAME);
	strcpy(card->shortname, CRD_NAME);
	sprintf(card->longname, CRD_NAME " at %#lx", port[n]);

	error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
	if (error < 0) {
		dev_err(dev, "could not create OPL\n");
		goto out;
	}

	error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
	if (error < 0) {
		dev_err(dev, "could not create FM\n");
		goto out;
	}

	error = snd_card_register(card);
	if (error < 0) {
		dev_err(dev, "could not register card\n");
		goto out;
	}

	dev_set_drvdata(dev, card);
	return 0;

out:	snd_card_free(card);
	return error;
}
示例#25
0
static int pxa3xx_snd_probe(struct device *dev)
{
	snd_card_t *card;
	int ret;

	ret = pxa3xx_wm9713l_snd_init();
	if (ret)
		return ret;

	ret = -ENOMEM;
	card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
			    THIS_MODULE, 0);
	if (!card)
		goto err;

	card->dev = dev;
	strncpy(card->driver, dev->driver->name, sizeof(card->driver));

	ret = pxa2xx_pcm_new(card, &pxa3xx_wm9713l_pcm_client, &pxa3xx_wm9713l_pcm);
	if (ret)
		goto err;

	ret = pxa3xx_wm9713l_snd_mixer(card);
	if (ret)
		goto err;

	snprintf(card->shortname, sizeof(card->shortname),
		 "%s", "WM9713L");
	snprintf(card->longname, sizeof(card->longname),
		 "%s (%s)", dev->driver->name, card->mixername);

	snd_card_set_pm_callback(card, pxa3xx_snd_do_suspend,
				 pxa3xx_snd_do_resume, NULL);
	ret = snd_card_register(card);
	if (ret == 0) {
		dev_set_drvdata(dev, card);
		return 0;
	}

err:
	if (card)
		snd_card_free(card);

	pxa3xx_wm9713l_snd_exit();

	return ret;
}
示例#26
0
static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
{
	struct snd_card *card;
	int err;

	if (devnum != 0)
		return -EINVAL;

	hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	pcsp_chip.timer.cb_mode = HRTIMER_CB_SOFTIRQ;
	pcsp_chip.timer.function = pcsp_do_timer;

	card = snd_card_new(index, id, THIS_MODULE, 0);
	if (!card)
		return -ENOMEM;

	err = snd_pcsp_create(card);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}
	err = snd_pcsp_new_pcm(&pcsp_chip);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}
	err = snd_pcsp_new_mixer(&pcsp_chip);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}

	snd_card_set_dev(pcsp_chip.card, dev);

	strcpy(card->driver, "PC-Speaker");
	strcpy(card->shortname, "pcsp");
	sprintf(card->longname, "Internal PC-Speaker at port 0x%x",
		pcsp_chip.port);

	err = snd_card_register(card);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}

	return 0;
}
示例#27
0
static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
{
	struct snd_card *card;
	struct snd_wss *chip;
	struct snd_pcm *pcm;
	int error;

	card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
	if (!card)
		return -EINVAL;

	error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], -1,
			thinkpad[n] ? WSS_HW_THINKPAD : WSS_HW_DETECT,
			0, &chip);
	if (error < 0)
		goto out;

	card->private_data = chip;

	error = snd_wss_pcm(chip, 0, &pcm);
	if (error < 0)
		goto out;

	error = snd_wss_mixer(chip);
	if (error < 0)
		goto out;

	strcpy(card->driver, "AD1848");
	strcpy(card->shortname, pcm->name);

	sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
		pcm->name, chip->port, irq[n], dma1[n]);
	if (thinkpad[n])
		strcat(card->longname, " [Thinkpad]");

	snd_card_set_dev(card, dev);

	error = snd_card_register(card);
	if (error < 0)
		goto out;

	dev_set_drvdata(dev, card);
	return 0;

out:	snd_card_free(card);
	return error;
}
示例#28
0
文件: pcsp.c 项目: 19Dan01/linux
static int snd_card_pcsp_probe(int devnum, struct device *dev)
{
	struct snd_card *card;
	int err;

	if (devnum != 0)
		return -EINVAL;

	hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	pcsp_chip.timer.function = pcsp_do_timer;

	err = snd_card_new(dev, index, id, THIS_MODULE, 0, &card);
	if (err < 0)
		return err;

	err = snd_pcsp_create(card);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}
	if (!nopcm) {
		err = snd_pcsp_new_pcm(&pcsp_chip);
		if (err < 0) {
			snd_card_free(card);
			return err;
		}
	}
	err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}

	strcpy(card->driver, "PC-Speaker");
	strcpy(card->shortname, "pcsp");
	sprintf(card->longname, "Internal PC-Speaker at port 0x%x",
		pcsp_chip.port);

	err = snd_card_register(card);
	if (err < 0) {
		snd_card_free(card);
		return err;
	}

	return 0;
}
示例#29
0
static int __devinit snd_aica_probe(struct platform_device *devptr)
{
	int err;
	struct snd_card_aica *dreamcastcard;
	dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
	if (unlikely(!dreamcastcard))
		return -ENOMEM;
	dreamcastcard->card =
	    snd_card_new(index, SND_AICA_DRIVER, THIS_MODULE, 0);
	if (unlikely(!dreamcastcard->card)) {
		kfree(dreamcastcard);
		return -ENODEV;
	}
	strcpy(dreamcastcard->card->driver, "snd_aica");
	strcpy(dreamcastcard->card->shortname, SND_AICA_DRIVER);
	strcpy(dreamcastcard->card->longname,
	       "Yamaha AICA Super Intelligent Sound Processor for SEGA Dreamcast");
	/* Prepare to use the queue */
	INIT_WORK(&(dreamcastcard->spu_dma_work), run_spu_dma);
	/* Load the PCM 'chip' */
	err = snd_aicapcmchip(dreamcastcard, 0);
	if (unlikely(err < 0))
		goto freedreamcast;
	snd_card_set_dev(dreamcastcard->card, &devptr->dev);
	dreamcastcard->timer.data = 0;
	dreamcastcard->channel = NULL;
	/* Add basic controls */
	err = add_aicamixer_controls(dreamcastcard);
	if (unlikely(err < 0))
		goto freedreamcast;
	/* Register the card with ALSA subsystem */
	err = snd_card_register(dreamcastcard->card);
	if (unlikely(err < 0))
		goto freedreamcast;
	platform_set_drvdata(devptr, dreamcastcard);
	aica_queue = create_workqueue(CARD_NAME);
	if (unlikely(!aica_queue))
		goto freedreamcast;
	snd_printk
	    ("ALSA Driver for Yamaha AICA Super Intelligent Sound Processor\n");
	return 0;
      freedreamcast:
	snd_card_free(dreamcastcard->card);
	kfree(dreamcastcard);
	return err;
}
int fm_mixer_init(struct fmdrv_ops *fmdev)
{
	int idx;
	int ret;

	FMDRV_API_START();

	/* Allocate new card for FM driver */
	fmdev->card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
				   THIS_MODULE, 0);
	if (!fmdev->card) {
		FM_DRV_ERR("No memory to allocate new card");
		FMDRV_API_EXIT(-ENOMEM);
		return -ENOMEM;
	}
	fmdev->card->private_data = fmdev;

	/* Add FM mixer controls to the card */
	strcpy(fmdev->card->mixername, FM_DRV_MIXER_NAME);
	for (idx = 0; idx < ARRAY_SIZE(snd_fm_controls); idx++) {
		ret = snd_ctl_add(fmdev->card,
				  snd_ctl_new1(&snd_fm_controls[idx], fmdev));
		if (ret < 0) {
			snd_card_free(fmdev->card);
			FM_DRV_ERR("Failed to add mixer controls");
			FMDRV_API_EXIT(ret);
			return ret;
		}
	}

	/* Register FM card with ALSA */
	ret = snd_card_register(fmdev->card);
	if (ret) {
		snd_card_free(fmdev->card);
		FM_DRV_ERR("Failed to register new card");
		FMDRV_API_EXIT(ret);
		return ret;
	}

	strcpy(fmdev->card->driver, FM_DRV_NAME);
	strcpy(fmdev->card->shortname, FM_DRV_CARD_SHORT_NAME);
	sprintf(fmdev->card->longname, FM_DRV_CARD_LONG_NAME);

	FMDRV_API_EXIT(0);
	return 0;
}