static int hi3630_pcm_hdmi_trigger(struct snd_pcm_substream *substream, int cmd)
{
	struct hi3630_hdmi_runtime_data *prtd = substream->runtime->private_data;
	struct hi3630_hdmi_data *pdata = prtd->pdata;
	int ret = 0;

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
			k3_hdmi_audio_set_power(true);
			prtd->status = STATUS_HDMI_RUNNING;
			hi3630_hdmi_enable_dma(pdata, HDMI_DMA_A);
			hi3630_hdmi_enable_dma(pdata, HDMI_DMA_B);

			/*hdmi ch int en*/
			hi3630_hdmi_set_bit(pdata, HI3630_ASP_INT_EN, HDMI_A_INT_EN_BIT);
			hi3630_hdmi_set_bit(pdata, HI3630_ASP_INT_EN, HDMI_B_INT_EN_BIT);
		}
		break;

	case SNDRV_PCM_TRIGGER_STOP:
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
		if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
			k3_hdmi_audio_set_power(false);
			prtd->status = STATUS_HDMI_STOP;

			/*int disable*/
			hi3630_hdmi_clr_bit(pdata, HI3630_ASP_INT_EN, HDMI_A_INT_EN_BIT);
			hi3630_hdmi_clr_bit(pdata, HI3630_ASP_INT_EN, HDMI_B_INT_EN_BIT);
		}
		break;

	default:
		loge("error!");
		ret = -EINVAL;
		break;
	}

	return ret;
}
Ejemplo n.º 2
0
static int hi3620_digital_trigger(struct snd_pcm_substream *substream, int cmd)
{
    unsigned long flags = 0;
    struct snd_pcm_runtime *runtime = substream->runtime;
    struct hi3620_runtime_data *prtd = substream->runtime->private_data;
    unsigned int num_periods = runtime->periods;
    unsigned int period_size = prtd->period_size;
    int ret = 0;

    logd("%s entry : %s,cmd: %d\n", __FUNCTION__,
            substream->stream == SNDRV_PCM_STREAM_PLAYBACK
            ? "PLAYBACK" : "CAPTURE", cmd);

#ifdef HDMI_DISPLAY
    switch (cmd) {
    case SNDRV_PCM_TRIGGER_START:
    case SNDRV_PCM_TRIGGER_RESUME:
    case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
        if (g_digitaloutStatus != 0) {
            k3_hdmi_audio_set_power(true);
        }
        break;

    case SNDRV_PCM_TRIGGER_STOP:
    case SNDRV_PCM_TRIGGER_SUSPEND:
    case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
        if (g_digitaloutStatus != 0) {
            k3_hdmi_audio_set_power(false);
        }
        break;
    }
#endif

    spin_lock_irqsave(&prtd->lock, flags);

    switch (cmd) {
    case SNDRV_PCM_TRIGGER_START:
    case SNDRV_PCM_TRIGGER_RESUME:
    case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
        prtd->status = STATUS_RUNNING;
        prtd->two_dma_flag = true;
        if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) {
            /*enable tx[0]*/
            prtd->tx[0].two_dma_flag = true;
            enable_dma(prtd->tx[0].dmaa, runtime->dma_addr, prtd->tx[0].period_next, period_size);
            prtd->tx[0].period_next = (prtd->tx[0].period_next + 1) % num_periods;
            enable_dma(prtd->tx[0].dmab, runtime->dma_addr, prtd->tx[0].period_next, period_size);
            prtd->tx[0].period_next = (prtd->tx[0].period_next + 1) % num_periods;
        }
        break;

    case SNDRV_PCM_TRIGGER_STOP:
    case SNDRV_PCM_TRIGGER_SUSPEND:
    case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
        prtd->status = STATUS_STOP;
        break;

    default:
        loge("%s cmd error : %d", __FUNCTION__, cmd);
        ret = -EINVAL;
        break;
    }

    spin_unlock_irqrestore(&prtd->lock, flags);

    return ret;
}