Пример #1
0
/* 
 *Turn on or off the transmission path. 
 */
static void rockchip_snd_txctrl(struct rk30_i2s_info *i2s, int on)
{
	u32 opr, xfer, clr;
	unsigned long flags;
	bool is_need_delay = false;
	int clr_error_count = I2S_CLR_ERROR_COUNT;

	spin_lock_irqsave(&lock, flags);

	opr  = readl(&(pheadi2s->I2S_DMACR));
	xfer = readl(&(pheadi2s->I2S_XFER));
	clr  = readl(&(pheadi2s->I2S_CLR));

	I2S_DBG("rockchip_snd_txctrl: %s\n", on ? "on" : "off");

	if (on) {
		if ((opr & I2S_TRAN_DMA_ENABLE) == 0) {
			opr  |= I2S_TRAN_DMA_ENABLE;
			writel(opr, &(pheadi2s->I2S_DMACR));
		}

		if ((xfer & I2S_TX_TRAN_START) == 0 || (xfer & I2S_RX_TRAN_START) == 0) {
			xfer |= I2S_TX_TRAN_START;
			xfer |= I2S_RX_TRAN_START;
			writel(xfer, &(pheadi2s->I2S_XFER));
		}

		i2s->i2s_tx_status = 1;

	} else { //stop tx
		i2s->i2s_tx_status = 0;
		opr  &= ~I2S_TRAN_DMA_ENABLE;
		writel(opr, &(pheadi2s->I2S_DMACR));

		if (i2s->i2s_rx_status == 0 && hdmi_get_hotplug() == 0) {
			xfer &= ~I2S_TX_TRAN_START;
			xfer &= ~I2S_RX_TRAN_START;
			writel(xfer, &(pheadi2s->I2S_XFER));	

			clr |= I2S_TX_CLEAR;
			clr |= I2S_RX_CLEAR;
			writel(clr, &(pheadi2s->I2S_CLR));

			is_need_delay = true;

			I2S_DBG("rockchip_snd_txctrl: stop xfer\n");
		}
	}

	spin_unlock_irqrestore(&lock, flags);

	if (is_need_delay){
		while(readl(&(pheadi2s->I2S_CLR)) && clr_error_count){
			udelay(1);
			clr_error_count --;
			if(clr_error_count == 0)
				printk("%s: i2s clr reg warning =%d",__FUNCTION__,readl(&(pheadi2s->I2S_CLR)));
		}
	}	
}
Пример #2
0
static bool get_hdmi_state(void)
{
#ifdef CONFIG_HDMI
	if(hdmi_is_insert())
		return true;
#endif

#ifdef CONFIG_HDMI_RK30
	if(hdmi_get_hotplug() == 2/*HDMI_HPD_ACTIVED*/)
		return true;
#endif

			return false;
}
Пример #3
0
/*
 * Logic for a rt3261 as connected on a rockchip board.
 */
static int rk29_rt3261_init(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;

	DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);

	snd_soc_add_controls(codec, rk_controls,
			ARRAY_SIZE(rk_controls));

	/* Add specific widgets */
	snd_soc_dapm_new_controls(dapm, rt3261_dapm_widgets,
				  ARRAY_SIZE(rt3261_dapm_widgets));
	/* Set up specific audio path audio_mapnects */
	snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));

	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
	snd_soc_dapm_enable_pin(dapm, "Headset Jack");
	snd_soc_dapm_enable_pin(dapm, "Ext Spk");
	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
#ifdef CONFIG_HDMI
	extern int hdmi_is_insert(void);
	extern void codec_set_spk(bool on);         
	if(hdmi_is_insert())                 
		codec_set_spk(false);
#endif

#ifdef CONFIG_HDMI_RK30
	extern int hdmi_get_hotplug(void);
	if(hdmi_get_hotplug() == 2/*HDMI_HPD_ACTIVED*/)
		codec_set_spk(false);
#endif

	snd_soc_dapm_sync(dapm);

	return 0;
}