Пример #1
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");
}
Пример #2
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");
}