Esempio n. 1
0
static int jz_pcm_startup(struct snd_pcm_substream *substream,
		struct snd_soc_dai *dai)
{
	struct device *dev = dai->dev;
	struct jz_pcm *jz_pcm = dev_get_drvdata(dai->dev);

	PCM_DEBUG_MSG("enter %s, substream = %s\n",
			__func__,
			(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? "playback" : "capture");

	if (!jz_pcm->pcm_mode) {
		clk_enable(jz_pcm->clk_gate);
#if 1
		__pcm_as_slaver(dev);
#else
		clk_set_rate(jz_pcm->clk, 9600000);
		clk_enable(jz_pcm->clk);
		__pcm_as_master(dev);
		__pcm_set_clkdiv(dev, 9600000/20/8000 - 1);
		__pcm_set_syndiv(dev, 20 - 1);
#endif
		__pcm_set_msb_one_shift_in(dev);
		__pcm_set_msb_one_shift_out(dev);
		__pcm_play_lastsample(dev);
		__pcm_enable(dev);
		__pcm_clock_enable(dev);
	}

	if (substream->stream ==
			SNDRV_PCM_STREAM_PLAYBACK) {
		__pcm_disable_transmit_dma(dev);
		__pcm_disable_replay(dev);
		__pcm_clear_tur(dev);
		jz_pcm->pcm_mode |= PCM_WRITE;
	} else {
		__pcm_disable_receive_dma(dev);
		__pcm_disable_record(dev);
		__pcm_clear_ror(dev);
		jz_pcm->pcm_mode |= PCM_READ;
	}
	printk("start set PCM register....\n");
	return 0;
}
Esempio n. 2
0
static int pcm_enable(int mode)
{
	unsigned long rate = 8000;
	unsigned long replay_format = 16;
	unsigned long record_format = 16;
	int replay_channel = 1;
	int record_channel = 1;
	struct dsp_pipe *dp_other = NULL;

	if (!pcm_priv)
			return -ENODEV;

	if (pcm_priv->replay_format != 0)
		replay_format = pcm_priv->replay_format;
	if (pcm_priv->record_format != 0)
		record_format = pcm_priv->record_format;
	if (pcm_priv->rate != 0)
		rate = pcm_priv->rate;

	if (mode & CODEC_WMODE) {
		dp_other = pcm_priv->endpoint->in_endpoint;
		pcm_set_fmt(&replay_format,mode);
		pcm_set_channel(&replay_channel,mode);
		pcm_set_trigger(mode);
	}
	if (mode & CODEC_RMODE) {
		dp_other = pcm_priv->endpoint->out_endpoint;
		pcm_set_fmt(&record_format,mode);
		pcm_set_channel(&record_channel,mode);
		pcm_set_trigger(mode);
	}
	pcm_set_rate(&rate);

	if (!dp_other->is_used) {
		if (mode & CODEC_WMODE)
			__pcm_flush_fifo();
		__pcm_enable();
		__pcm_clock_enable();
	}
	return 0;
}