Esempio n. 1
0
void audiohw_init(void)
{
    udacodec_reset();
     
    audiohw_set_bass (0);  
    audiohw_set_treble (0);  
    audiohw_set_master_vol (26, 26);    /* -25 dB */
}
Esempio n. 2
0
/*AS3543 mixer can go a little louder then the as3514, although 
 * it might be possible to go louder on the as3514 as well */
 
#if CONFIG_CPU == AS3525v2 
#define MIXER_MAX_VOLUME 0x1b
#else /* lets leave the AS3514 alone until its better tested*/
#define MIXER_MAX_VOLUME 0x16
#endif

    if (vol_r <= MIXER_MAX_VOLUME) {
        mix_r = vol_r;
        hph_r = 0;
    } else {
        mix_r = MIXER_MAX_VOLUME;
        hph_r = vol_r - MIXER_MAX_VOLUME;
    }

    if (vol_l <= MIXER_MAX_VOLUME) {
        mix_l = vol_l;
        hph_l = 0;
    } else {
        mix_l = MIXER_MAX_VOLUME;
        hph_l = vol_l - MIXER_MAX_VOLUME;
    }    


    as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK);
#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
    as3514_write_masked(AS3514_LINE_IN_R, mix_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_LINE_IN_L, mix_l, AS3514_VOL_MASK);
#endif
    as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK);

    audiohw_mute(false);
}

#if 0 /* unused */
void audiohw_set_lineout_vol(int vol_l, int vol_r)
{
#ifdef HAVE_AS3543
    /* line out volume is set in the same registers */
    audiohw_set_master_vol(vol_l, vol_r);
#else
    as3514_write_masked(AS3514_LINE_OUT_R, vol_r, AS3514_VOL_MASK);
    as3514_write_masked(AS3514_LINE_OUT_L, vol_l, AS3514_VOL_MASK);
#endif
}
Esempio n. 3
0
static void set_prescaled_volume(void)
{
    int prescale = 0;
    int l, r;

/* The codecs listed use HW tone controls but don't have suitable prescaler
 * functionality, so we let the prescaler stay at 0 for these, unless
 * SW tone controls are in use. This is to avoid needing the SW DSP just for
 * the prescaling.
 */
#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
    || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
    || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341))

#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
    prescale = MAX(current_bass, current_treble);
#endif
#if defined(AUDIOHW_HAVE_EQ)
    int i;
    for (i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
        prescale = MAX(current_eq_band_gain[i], prescale);
#endif

    if (prescale < 0)
        prescale = 0;  /* no need to prescale if we don't boost
                          bass, treble or eq band */

    /* Gain up the analog volume to compensate the prescale gain reduction,
     * but if this would push the volume over the top, reduce prescaling
     * instead (might cause clipping). */
    if (current_volume + prescale > VOLUME_MAX)
        prescale = VOLUME_MAX - current_volume;
#endif

#if defined(AUDIOHW_HAVE_PRESCALER)
    audiohw_set_prescaler(prescale);
#else
    dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale);
#endif

    if (current_volume == VOLUME_MIN)
        prescale = 0;  /* Make sure the chip gets muted at VOLUME_MIN */

    l = r = current_volume + prescale;

    /* Balance the channels scaled by the current volume and min volume. */
    /* Subtract a dB from VOLUME_MIN to get it to a mute level */
    if (current_balance > 0)
    {
        l -= ((l - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
    }
    else if (current_balance < 0)
    {
        r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
    }

#ifdef HAVE_SW_VOLUME_CONTROL
    dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
#endif

#ifndef HAVE_SDL_AUDIO
#if CONFIG_CODEC == MAS3507D
    dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
   || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
   || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
   || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341) \
   || defined(HAVE_CS42L55)
    audiohw_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
    || (defined(HAVE_WM8751) && defined(TOSHIBA_GIGABEAT_F)) \
    || defined(HAVE_WM8985) || defined(HAVE_CS42L55)
    audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
#endif

#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985)
    audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
#elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
    audiohw_set_volume(current_volume);
#endif
#else /* HAVE_SDL_AUDIO */
    audiohw_set_volume(current_volume);
#endif /* !HAVE_SDL_AUDIO */
}
Esempio n. 4
0
int i2s_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
	int x;
	unsigned long flags, data;
	i2s_config_type* ptri2s_config;
	
	ptri2s_config = filp->private_data;
	switch (cmd) {
	case I2S_SRATE:
		if((arg>MAX_SRATE_HZ)||(arg<MIN_SRATE_HZ))
		{
			MSG("audio sampling rate %d should be %d ~ %d Hz\n", arg, MIN_SRATE_HZ, MAX_SRATE_HZ);
			break;
		}	
		ptri2s_config->srate = arg;
		MSG("set audio sampling rate to %d Hz\n", ptri2s_config->srate);
		break;
	case I2S_VOL:
		if(((int)arg>MAX_VOL_DB)||((int)arg<MIN_VOL_DB))
		{
			MSG("audio volumn %d should be %d ~ %d dB\n", arg, MIN_VOL_DB, MAX_VOL_DB);
			
			break;
		}	
		ptri2s_config->vol = arg;
		x = 2*arg+255;
		audiohw_set_master_vol(x, x);
		MSG("set audio volumn to %d dB\n", ptri2s_config->vol);
		break;
	case I2S_ENABLE:
		ptri2s_config->isr_cnt = 0;	
		pi2s_status->buffer_unrun = 0;
		pi2s_status->buffer_ovrun = 0;
		pi2s_status->txdmafault = 0;
		pi2s_status->ovrun = 0;
		pi2s_status->unrun = 0;
		pi2s_status->thres = 0;
		pi2s_status->buffer_len = 0;
		data = i2s_inw(RALINK_REG_INTENA);
		//data |=0x0400;
		data &=0xFFBFF;
	    i2s_outw(RALINK_REG_INTENA, data);
		MSG("i2s audio enable\n");
		
		if(i2s_dev_open(ptri2s_config)!=I2S_OK)
		{
			i2s_release(inode, filp);
			return -1;
		}
		wake_up_interruptible(&(ptri2s_config->i2s_qh));
		
		break;
	case I2S_DISABLE:
		MSG("i2s audio disable\n");
		data = i2s_inw(RALINK_REG_INTENA);
		data &= 0xFFFFFBFF;
	    i2s_outw(RALINK_REG_INTENA, data);
		ptri2s_config->bDMAStart = 0;
		i2s_dev_close(ptri2s_config);
		wake_up_interruptible(&(ptri2s_config->i2s_qh));
		break;
	case I2S_GET_WBUF:
#ifdef I2S_FIFO_MODE	
		{
			int i,j;
			long* pBufPtr = pi2s_config->pMMAPBufPtr+(pi2s_config->w_idx)*I2S_PAGE_SIZE;
			for(i=0; i<I2S_PAGE_SIZE>>2; i++)
			{
				long status;
				i2s_outw(I2S_FIFO_WREG, bswap_32(pBufPtr[i]));	
				while(1)
				{
					status = i2s_inw(I2S_FF_STATUS);
					if(status&0x00F!=0)
						break;
				}	
			}
			ptri2s_config->w_idx = (ptri2s_config->w_idx+1)%MAX_I2S_PAGE;
			(int)(*(int*)arg) = (int)ptri2s_config->w_idx;
			break;
		}
#endif		
		if(ptri2s_config->bDMAStart==0)
		{
			GdmaI2sTx(ptri2s_config->page0buf8ptr, I2S_FIFO_WREG, 0, I2S_PAGE_SIZE, i2s_dma_handler, i2s_unmask_handler);
			GdmaI2sTx(ptri2s_config->page1buf8ptr, I2S_FIFO_WREG, 1, I2S_PAGE_SIZE, i2s_dma_handler, i2s_unmask_handler);
			ptri2s_config->bDMAStart=1;
			GdmaUnMaskChannel(GDMA_I2S_TX0);
		}
		
		do{
			spin_lock_irqsave(&ptri2s_config->lock, flags);
			
			if(((ptri2s_config->w_idx+1)%MAX_I2S_PAGE)!=ptri2s_config->r_idx)
			{
				ptri2s_config->w_idx = (ptri2s_config->w_idx+1)%MAX_I2S_PAGE;
				(int)(*(int*)arg) = (int)ptri2s_config->w_idx;
				pi2s_status->buffer_len++;
				spin_unlock_irqrestore(&ptri2s_config->lock, flags);
				break;
			}
			else
			{
				/* Buffer Full */
				//printk("BF w=%d, r=%d\n", ptri2s_config->w_idx, ptri2s_config->r_idx);
				pi2s_status->buffer_ovrun++;
				ptri2s_config->bSleep = 1;
				spin_unlock_irqrestore(&ptri2s_config->lock, flags);
				interruptible_sleep_on(&(ptri2s_config->i2s_qh));
				
			}
		}while(1);
		break;
						
	default :
		MSG("i2s_ioctl: command format error\n");
	}

	return 0;
}