Esempio n. 1
0
void pcm_init(void)
{
    pcm_playing = false;
    pcm_paused = false;

    BUSMASTER_CTRL = 0x81; /* PARK[1,0]=10 + BCR24BIT */
    DIVR0 = 54;            /* DMA0 is mapped into vector 54 in system.c */
    DMAROUTE = (DMAROUTE & 0xffffff00) | DMA0_REQ_AUDIO_1;
    DMACONFIG = 1;   /* DMA0Req = PDOR3 */

    /* Reset the audio FIFO */
    IIS2CONFIG = IIS_RESET;

    /* Enable interrupt at level 7, priority 0 */
    ICR4 = (ICR4 & 0xffff00ff) | 0x00001c00;
    IMR &= ~(1<<14);      /* bit 14 is DMA0 */

    pcm_set_frequency(44100);

    /* Prevent pops (resets DAC to zero point) */
    IIS2CONFIG = IIS_DEFPARM(pcm_freq) | IIS_RESET;
    
#if defined(HAVE_UDA1380)
    /* Initialize default register values. */
    uda1380_init();
    
    /* Sleep a while so the power can stabilize (especially a long
       delay is needed for the line out connector). */
    sleep(HZ);

    /* Power on FSDAC and HP amp. */
    uda1380_enable_output(true);

    /* Unmute the master channel (DAC should be at zero point now). */
    uda1380_mute(false);
    
#elif defined(HAVE_TLV320)
    tlv320_init();
    tlv320_enable_output(true);
    sleep(HZ/4);
    tlv320_mute(false);
#endif

    
    /* Call dma_stop to initialize everything. */
    dma_stop();
}
Esempio n. 2
0
void audio_init(void)
{
	int th;

	DCC_LOG(LOG_TRACE, "...");

	audio_drv.enabled = false;

	/* 50 ms jitter buffer */
	jitbuf_init(&audio_drv.jitbuf, SAMPLE_RATE,
				SAMPLE_RATE, 25);

	codec_hw_reset();

	tracef("%s(): initializing I2S...", __func__);
	i2s_slave_init();

	tracef("%s(): initializing TLV320...", __func__);
	tlv320_reset();

	tlv320_init();

	th = thinkos_thread_create((void *)net_rcv_task, (void *)NULL,
							   net_rcv_stack, 
							   sizeof(net_rcv_stack), 
							   THINKOS_OPT_PRIORITY(1) | 
							   THINKOS_OPT_ID(1));
	audio_drv.net_thread = th;

	th = thinkos_thread_create((void *)audio_io_task, (void *)NULL,
							   audio_io_stack, 
							   sizeof(audio_io_stack), 
							   THINKOS_OPT_PRIORITY(0) | 
							   THINKOS_OPT_ID(0));
	audio_drv.io_thread = th;

}
Esempio n. 3
0
void audio_reset(void)
{
	bool enable_stream;

	tracef("%s(): audio system reset ...", __func__);

	enable_stream = audio_drv.stream_enabled;

	audio_drv.stream_enabled = false;

	codec_hw_reset();
	
	tlv320_reset();

	if (audio_drv.enabled)
		i2s_disable();

	tlv320_init();

	if (audio_drv.enabled)
		i2s_enable();

	audio_drv.stream_enabled = enable_stream;
}
Esempio n. 4
0
static int tlv320_codec_probe(struct i2c_adapter *adap, int addr, int kind)
{
	struct snd_soc_device *socdev = tlv320_socdev;
	struct tlv320_setup_data *setup = socdev->codec_data;
	struct snd_soc_codec *codec = socdev->codec;
	struct i2c_client *i2c;
	int ret, len;
        const unsigned char *data;

	if (addr != setup->i2c_address)
		return -ENODEV;

	client_template.adapter = adap;
	client_template.addr = addr;

	i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
	if (i2c == NULL){
		kfree(codec);
		return -ENOMEM;
	}
	memcpy(i2c, &client_template, sizeof(struct i2c_client));
	i2c_set_clientdata(i2c, codec);
	codec->control_data = i2c;

	ret = i2c_attach_client(i2c);
	if (ret < 0) {
		err("failed to attach codec at addr %x\n", addr);
		goto err;
	}

	ret = tlv320_init(socdev);
	if (ret < 0) {
		err("failed to initialise TLV320\n");
		goto err;
	}

	switch(setting) {
	case 1:
		data = tlv320_reg_data_init_set1;
		len = sizeof(tlv320_reg_data_init_set1);
		break;
	case 2:
		data = tlv320_reg_data_init_set2;
		len = sizeof(tlv320_reg_data_init_set2);
		break;
	case 3:
		data = tlv320_reg_data_init_set3;
		len = sizeof(tlv320_reg_data_init_set3);
		break;
	default:
		data = tlv320_reg_data_init_set1;
		len = sizeof(tlv320_reg_data_init_set1);
		break;
	}

	ret = tlv320_write_block(codec, data, len);

	if (ret < 0) {
		err("attach error: init status %d\n", ret);
	} else {
		info("attach: chip tlv320 at address 0x%02x",
			tlv320_read(codec, 0x02) << 1);
	}

        //tlv320_write(codec, CODEC_REG6B, 0x80);
#if 0
	int value;
	int i;

	for (i=0; i<len; i++) {
		value = tlv320_read(codec, tlv320_reg_addr[i]);
		dbg("read addr = 0x%02x, data = 0x%02x", tlv320_reg_addr[i], value);
		mdelay(10);
	}

#endif


	return ret;

err:
	kfree(codec);
	kfree(i2c);
	return ret;
}