Exemple #1
0
static void jz_pcm_stop_substream(struct snd_pcm_substream *substream,
		struct snd_soc_dai *dai)
{
	struct device *dev = dai->dev;
	PCM_DEBUG_MSG("enter %s, substream = %s\n",
			__func__,
			(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? "playback" : "capture");

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		if (__pcm_transmit_dma_is_enable(dev)) {
			__pcm_disable_transmit_dma(dev);
			__pcm_clear_tur(dev);
			/* Hrtimer mode: stop will be happen in any where, make sure there is
			 *	no data transfer on ahb bus before stop dma
			 * Harzard:
			 *	In pcm slave mode, the clk maybe stop before here, we will dead here
			 */
			while(!__pcm_test_tur(dev));
		}
		__pcm_disable_replay(dev);
		__pcm_clear_tur(dev);
	} else {
		if (__pcm_receive_dma_is_enable(dev)) {
			__pcm_disable_receive_dma(dev);
			__pcm_clear_ror(dev);
			while(!__pcm_test_ror(dev));
		}
		__pcm_disable_record(dev);
		__pcm_clear_ror(dev);
	}
	return;
}
Exemple #2
0
static int pcm_dma_disable(int mode)		//CHECK seq dma and func
{
	if (mode & CODEC_WMODE) {
		__pcm_disable_transmit_dma();
		__pcm_disable_replay();
	}
	if (mode & CODEC_RMODE) {
		__pcm_disable_receive_dma();
		__pcm_disable_record();
	}
	return 0;
}
Exemple #3
0
static int pcm_disable(int mode) {
	if (mode & CODEC_WMODE) {
		__pcm_disable_transmit_dma();
		__pcm_disable_replay();
	}
	if (mode & CODEC_RMODE) {
		__pcm_disable_receive_dma();
		__pcm_disable_record();
	}
	__pcm_disable();
	__pcm_clock_disable();
	return 0;
}
Exemple #4
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;
}
Exemple #5
0
static int pcm_init(struct platform_device *pdev)
{
	int ret = 0;
	struct resource *pcm_resource = NULL;
	struct dsp_pipe *pcm_pipe_out = NULL;
	struct dsp_pipe *pcm_pipe_in = NULL;

	/* map io address */
	pcm_resource = platform_get_resource(pdev,IORESOURCE_MEM,0);
	if (pcm_resource == NULL) {
		printk("pcm: platform_get_resource fail.\n");
		return -1;
	}
	if (!request_mem_region(pcm_resource->start, resource_size(pcm_resource), pdev->name)) {
		printk("pcm: mem region fail busy .\n");
		return -EBUSY;
	}

	pcm_iomem = ioremap(pcm_resource->start, resource_size(pcm_resource));
	if (!pcm_iomem) {
		printk ("pcm: ioremap fail.\n");
		ret =  -ENOMEM;
		goto __err_ioremap;
	}

	/*init pipe*/
	ret = pcm_init_pipe(&pcm_pipe_out,DMA_TO_DEVICE,pcm_resource->start);
	if (ret < 0)
		goto __err_init_pipeout;
	ret = pcm_init_pipe(&pcm_pipe_in,DMA_FROM_DEVICE,pcm_resource->start);
	if (ret < 0)
		goto __err_init_pipein;
	pcm_endpoints.out_endpoint = pcm_pipe_out;
	pcm_endpoints.in_endpoint = pcm_pipe_in;

	/*spin lock init*/
	spin_lock_init(&pcm_irq_lock);

	/* request irq */
	pcm_resource = platform_get_resource(pdev,IORESOURCE_IRQ,0);
	if (pcm_resource == NULL) {
		ret = -1;
		printk("pcm there is not irq resource\n");
		goto __err_irq;
	}
	pcm_priv->irq = pcm_resource->start;
	ret = request_irq(pcm_resource->start, pcm_irq_handler,
			IRQF_DISABLED, "pcm_irq", NULL);
	if (ret < 0) {
		printk("pcm:request irq fail\n");
		goto __err_irq;
	}

	ret = pcm_clk_init(pdev);
	if (ret < 0)
		goto __err_clk_init;

	__pcm_disable_receive_dma();
	__pcm_disable_transmit_dma();
	__pcm_disable_record();
	__pcm_disable_replay();
	__pcm_flush_fifo();
	__pcm_clear_ror();
	__pcm_clear_tur();
	__pcm_set_receive_trigger(7);
	__pcm_set_transmit_trigger(8);
	__pcm_disable_overrun_intr();
	__pcm_disable_underrun_intr();
	__pcm_disable_transmit_intr();
	__pcm_disable_receive_intr();
	/* play zero or last sample when underflow */
	__pcm_play_lastsample();
	//__pcm_enable();

	return 0;

__err_clk_init:
	free_irq(pcm_priv->irq,NULL);
__err_irq:
	vfree(pcm_pipe_in);
__err_init_pipein:
	vfree(pcm_pipe_out);
__err_init_pipeout:
	iounmap(pcm_iomem);
__err_ioremap:
	release_mem_region(pcm_resource->start,resource_size(pcm_resource));
	return ret;
}