Ejemplo n.º 1
0
static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream,
				   struct snd_pcm_hw_params *hw_params)
{
	struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
	struct atiixp_dma *dma = substream->runtime->private_data;
	int err;
	int i;

	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;
	dma->buf_addr = substream->runtime->dma_addr;
	dma->buf_bytes = params_buffer_bytes(hw_params);

	err = atiixp_build_dma_packets(chip, dma, substream,
				       params_periods(hw_params),
				       params_period_bytes(hw_params));
	if (err < 0)
		return err;

	/*                   */
	for (i = 0; i < NUM_ATI_CODECS; i++) {
		if (! chip->ac97[i])
			continue;
		snd_ac97_write(chip->ac97[i], AC97_LINE1_RATE, params_rate(hw_params));
		snd_ac97_write(chip->ac97[i], AC97_LINE1_LEVEL, 0);
	}

	return err;
}
Ejemplo n.º 2
0
void snd_init()
{
    unsigned int codec_id;
    unsigned int mask;

    snd_cr_request = 0;
    snd_cr_reply = 0;
    CSR_AC97_DCTL = 0;
    CSR_AC97_UCTL = 0;

    mask = irq_getmask();
    mask |= IRQ_AC97CRREQUEST|IRQ_AC97CRREPLY|IRQ_AC97DMAR|IRQ_AC97DMAW;
    irq_setmask(mask);

    codec_id = snd_ac97_read(0x00);
    if(codec_id == 0x0d50)
        printf("SND: found LM4550 AC'97 codec\n");
    else
        printf("SND: warning, unknown codec found (ID:%04x)\n", codec_id);

    /* Unmute and set volumes */
    /* TODO: API for this */
    snd_ac97_write(0x02, 0x0000);
    snd_ac97_write(0x04, 0x0f0f);
    snd_ac97_write(0x18, 0x0000);
    snd_ac97_write(0x0e, 0x0000);
    snd_ac97_write(0x1c, 0x0f0f);

    snd_play_empty();
    snd_record_empty();

    printf("SND: initialization complete\n");
}
Ejemplo n.º 3
0
/*
 * hw_params callback:
 * allocate the buffer and build up the buffer description table
 */
static int snd_via82xx_hw_params(struct snd_pcm_substream *substream,
				 struct snd_pcm_hw_params *hw_params)
{
	struct via82xx_modem *chip = snd_pcm_substream_chip(substream);
	struct viadev *viadev = substream->runtime->private_data;
	int err;

	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;
	err = build_via_table(viadev, substream, chip->pci,
			      params_periods(hw_params),
			      params_period_bytes(hw_params));
	if (err < 0)
		return err;

	snd_ac97_write(chip->ac97, AC97_LINE1_RATE, params_rate(hw_params));
	snd_ac97_write(chip->ac97, AC97_LINE1_LEVEL, 0);

	return 0;
}
Ejemplo n.º 4
0
void snd_init()
{
	unsigned int codec_id;
	unsigned int mask;
	
	if(!(CSR_CAPABILITIES & CAP_AC97)) {
		printf("SND: not supported by SoC, giving up.\n");
		return;
	}
	
	snd_cr_request = 0;
	snd_cr_reply = 0;

	/* Reset AC'97 controller */
	CSR_AC97_CRCTL = 0;
	CSR_AC97_DCTL = 0;
	CSR_AC97_UCTL = 0;
	irq_ack(IRQ_AC97CRREQUEST|IRQ_AC97CRREPLY|IRQ_AC97DMAR|IRQ_AC97DMAW);
	
	mask = irq_getmask();
	mask |= IRQ_AC97CRREQUEST|IRQ_AC97CRREPLY|IRQ_AC97DMAR|IRQ_AC97DMAW;
	irq_setmask(mask);
	
	codec_id = snd_ac97_read(0x00);
	if(codec_id == 0x0d50)
		printf("SND: found LM4550 AC'97 codec\n");
	else if(codec_id == 0x6150)
		printf("SND: found WM9707 AC'97 codec\n");
	else
		printf("SND: warning, unknown codec found (ID:%04x)\n", codec_id);
	
	/* Unmute and set volumes */
	/* TODO: API for this */
	snd_ac97_write(0x02, 0x0000); /* master volume */
	snd_ac97_write(0x04, 0x0f0f); /* headphones volume */
	snd_ac97_write(0x18, 0x0000); /* PCM out volume */
	snd_ac97_write(0x1c, 0x0f0f); /* record gain */

	snd_ac97_write(0x0e, 0x0000); /* mic volume: max */
	snd_ac97_write(0x10, 0x0000); /* line in volume: max */
	snd_ac97_write(0x1a, 0x0505); /* record select: stero mix */

	snd_play_empty();
	snd_record_empty();
	
	printf("SND: initialization complete\n");
}