Esempio n. 1
0
			   __LINE__);
		
aout_notifier_call_chain(AOUT_EVENT_IEC_60958_PCM, substream);
	
}
	return 0;
}

static int aml_dai_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
			       struct snd_soc_dai *dai)
{
	struct snd_pcm_runtime *rtd = substream->runtime;
	int *ppp = NULL;
	ALSA_TRACE();
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		/* TODO */
		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
			ALSA_PRINT("aiu i2s playback enable\n\n");
			audio_out_i2s_enable(1);
			if (IEC958_mode_codec == 0) {
				ALSA_PRINT("audio_hw_958_enable  1\n");
				audio_hw_958_enable(1);
			}
		} else {
			audio_in_i2s_enable(1);
			ppp = (int *)(rtd->dma_area + rtd->dma_bytes * 2 - 8);
			ppp[0] = 0x78787878;
			ppp[1] = 0x78787878;
		}
		break;
	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
			ALSA_PRINT("aiu i2s playback disable\n\n");
			audio_out_i2s_enable(0);
			if (IEC958_mode_codec == 0) {
				
ALSA_PRINT("audio_hw_958_enable  0\n");
				audio_hw_958_enable(0);
			}
		} else {
Esempio n. 2
0
static int aml_pcm_trigger(struct snd_pcm_substream *substream,
	int cmd)
{
	struct snd_pcm_runtime *rtd = substream->runtime;
	struct aml_runtime_data *prtd = rtd->private_data;
	audio_stream_t *s = &prtd->s;
	int ret = 0;

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6
	 //witch_mod_gate_by_type(MOD_AUDIO, 1);
#endif

#if USE_HRTIMER == 0
	  del_timer_sync(&prtd->timer);
#endif
	  spin_lock(&s->lock);
#if USE_HRTIMER == 0
	  prtd->timer.expires = jiffies + 1;
	  del_timer(&prtd->timer);
	  add_timer(&prtd->timer);
#endif
	  // TODO
	  if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
	        //printk("aml_pcm_trigger: playback start\n");
			//clock_gating_status |= clock_gating_playback;
			//aml_clock_gating(clock_gating_status);
			//codec_power_switch(substream, clock_gating_status);
		    audio_enable_ouput(1);
	  }else{
			//printk("aml_pcm_trigger: capture start\n");
			//clock_gating_status |= clock_gating_capture;
			//aml_clock_gating(clock_gating_status);
			//codec_power_switch(substream, clock_gating_status);
			audio_in_i2s_enable(1);
	      {
		  int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
		  ppp[0] = 0x78787878;
		  ppp[1] = 0x78787878;
	      }

	  }

	  s->active = 1;
	  s->xrun_num = 0;
	  spin_unlock(&s->lock);
	  break;		/* SNDRV_PCM_TRIGGER_START */
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
	case SNDRV_PCM_TRIGGER_STOP:
		// TODO
	    spin_lock(&s->lock);
	    s->active = 0;
		s->xrun_num = 0;
	    if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
            //printk("aml_pcm_trigger: playback stop\n");
			audio_enable_ouput(0);
		//	clock_gating_status &= ~clock_gating_playback;
			//aml_clock_gating(clock_gating_status);
			//codec_power_switch(substream, clock_gating_status);
	    }else{
            //printk("aml_pcm_trigger: capture stop\n");
		//	clock_gating_status &= ~clock_gating_capture;

			audio_in_i2s_enable(0);
	    }
#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6
	//  switch_mod_gate_by_type(MOD_AUDIO, 0);
#endif

	    spin_unlock(&s->lock);
	    break;

	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		// TODO
	    spin_lock(&s->lock);
#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6
	  //switch_mod_gate_by_type(MOD_AUDIO, 1);
#endif
	    s->active = 1;
		s->xrun_num = 0;
	    if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
            //printk("aml_pcm_trigger: playback resume\n");
			audio_enable_ouput(1);
		//	clock_gating_status |= clock_gating_playback;
			//aml_clock_gating(clock_gating_status);
			//codec_power_switch(substream, clock_gating_status);
	    }else{
            //printk("aml_pcm_trigger: capture resume\n");
	        audio_in_i2s_enable(1);
		//	clock_gating_status |= clock_gating_capture;
			//aml_clock_gating(clock_gating_status);
			//codec_power_switch(substream, clock_gating_status);
		{
		    int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
		    ppp[0] = 0x78787878;
		    ppp[1] = 0x78787878;
	        }
	    }
	    spin_unlock(&s->lock);
	    break;
	default:
		ret = -EINVAL;
	}
/*	if(clock_gating_status&clock_gating_playback){
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
			aml_pcm_work.substream = substream;
	}
	else
		aml_pcm_work.substream = substream;


	if(clock_gating_status)
	{
		schedule_work(&aml_pcm_work.aml_codec_workqueue);
	}
	*/
	//schedule_work(&aml_pcm_work.aml_codec_workqueue);
	return ret;
}
static int aml_pcm_trigger(struct snd_pcm_substream *substream,
	int cmd)
{
	struct snd_pcm_runtime *rtd = substream->runtime;
	struct aml_runtime_data *prtd = rtd->private_data;
	audio_stream_t *s = &prtd->s;
	int ret = 0;
	
	spin_lock(&s->lock);
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
		
		del_timer_sync(&prtd->timer);
		
		prtd->timer.expires = jiffies + 1;
    del_timer(&prtd->timer);
    add_timer(&prtd->timer);
        
		// TODO
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
		//    printk("aml_pcm_trigger: playback start\n");
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status |= clock_gating_playback;
			aml_clock_gating(clock_gating_status);
#endif
			audio_enable_ouput(1);
		}else{
		//	printk("aml_pcm_trigger: capture start\n");
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status |= clock_gating_capture;
			aml_clock_gating(clock_gating_status);
#endif
			audio_in_i2s_enable(1);
            {
              int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
			  ppp[0] = 0x78787878;
			  ppp[1] = 0x78787878;
            }

		}
		
		s->active = 1;
		
		break;		/* SNDRV_PCM_TRIGGER_START */
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
	case SNDRV_PCM_TRIGGER_STOP:
		// TODO
		s->active = 0;
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
        //    printk("aml_pcm_trigger: playback stop\n");
				audio_enable_ouput(0);
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status &= clock_gating_capture;
			aml_clock_gating(clock_gating_status);
#endif
		}else{
        //    printk("aml_pcm_trigger: capture stop\n");
				audio_in_i2s_enable(0);
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status &= clock_gating_playback;
			//aml_clock_gating(clock_gating_status);
#endif
		}
		break;

	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		// TODO
		s->active = 1;
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
        //    printk("aml_pcm_trigger: playback resume\n");
				audio_enable_ouput(1);
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status |= clock_gating_playback;
			aml_clock_gating(clock_gating_status);
#endif
		}else{
        //    printk("aml_pcm_trigger: capture resume\n");
			  audio_in_i2s_enable(1);
#if defined(CONFIG_SND_AML_M3)
			clock_gating_status |= clock_gating_capture;
			aml_clock_gating(clock_gating_status);
#endif
              {
                int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
			    ppp[0] = 0x78787878;
			    ppp[1] = 0x78787878;
              }
		}
		
		break;

	default:
		ret = -EINVAL;
	}
	spin_unlock(&s->lock);
	return ret;
}