Ejemplo n.º 1
0
static int __devinit atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
{
	struct snd_pcm		*pcm;
	struct snd_pcm_hardware	hw = atmel_ac97c_hw;
	int			capture, playback, retval, err;

	capture = test_bit(DMA_RX_CHAN_PRESENT, &chip->flags);
	playback = test_bit(DMA_TX_CHAN_PRESENT, &chip->flags);

	if (!cpu_is_at32ap7000()) {
		err = snd_ac97_pcm_assign(chip->ac97_bus,
				ARRAY_SIZE(at91_ac97_pcm_defs),
				at91_ac97_pcm_defs);
		if (err)
			return err;
	}
	retval = snd_pcm_new(chip->card, chip->card->shortname,
			chip->pdev->id, playback, capture, &pcm);
	if (retval)
		return retval;

	if (capture)
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
				&atmel_ac97_capture_ops);
	if (playback)
		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
				&atmel_ac97_playback_ops);

	retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
			&chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
			hw.buffer_bytes_max);
	if (retval)
		return retval;

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

	return 0;
}
Ejemplo n.º 2
0
static int __devinit snd_atiixp_pcm_new(atiixp_t *chip)
{
    snd_pcm_t *pcm;
    ac97_bus_t *pbus = chip->ac97_bus;
    int err, i, num_pcms;

    /* initialize constants */
    chip->dmas[ATI_DMA_PLAYBACK].ops = &snd_atiixp_playback_dma_ops;
    chip->dmas[ATI_DMA_CAPTURE].ops = &snd_atiixp_capture_dma_ops;
    if (! chip->spdif_over_aclink)
        chip->dmas[ATI_DMA_SPDIF].ops = &snd_atiixp_spdif_dma_ops;

    /* assign AC97 pcm */
    if (chip->spdif_over_aclink)
        num_pcms = 3;
    else
        num_pcms = 2;
    err = snd_ac97_pcm_assign(pbus, num_pcms, atiixp_pcm_defs);
    if (err < 0)
        return err;
    for (i = 0; i < num_pcms; i++)
        chip->pcms[i] = &pbus->pcms[i];

    chip->max_channels = 2;
    if (pbus->pcms[ATI_PCM_OUT].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) {
        if (pbus->pcms[ATI_PCM_OUT].r[0].slots & (1 << AC97_SLOT_LFE))
            chip->max_channels = 6;
        else
            chip->max_channels = 4;
    }

    /* PCM #0: analog I/O */
    err = snd_pcm_new(chip->card, "ATI IXP AC97", ATI_PCMDEV_ANALOG, 1, 1, &pcm);
    if (err < 0)
        return err;
    snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_atiixp_playback_ops);
    snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_atiixp_capture_ops);
    pcm->private_data = chip;
    strcpy(pcm->name, "ATI IXP AC97");
    chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm;

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

    /* no SPDIF support on codec? */
    if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates)
        return 0;

    /* FIXME: non-48k sample rate doesn't work on my test machine with AD1888 */
    if (chip->pcms[ATI_PCM_SPDIF])
        chip->pcms[ATI_PCM_SPDIF]->rates = SNDRV_PCM_RATE_48000;

    /* PCM #1: spdif playback */
    err = snd_pcm_new(chip->card, "ATI IXP IEC958", ATI_PCMDEV_DIGITAL, 1, 0, &pcm);
    if (err < 0)
        return err;
    snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_atiixp_spdif_ops);
    pcm->private_data = chip;
    if (chip->spdif_over_aclink)
        strcpy(pcm->name, "ATI IXP IEC958 (AC97)");
    else
        strcpy(pcm->name, "ATI IXP IEC958 (Direct)");
    chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm;

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

    /* pre-select AC97 SPDIF slots 10/11 */
    for (i = 0; i < NUM_ATI_CODECS; i++) {
        if (chip->ac97[i])
            snd_ac97_update_bits(chip->ac97[i], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4);
    }

    return 0;
}