Beispiel #1
0
static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
	snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
{
	int rc = 1;
	int fbytes = 0;

	struct snd_pcm_runtime *runtime = substream->runtime;
	struct msm_audio *prtd = runtime->private_data;

	fbytes = frames_to_bytes(runtime, frames);
	rc = alsa_send_buffer(prtd, buf, fbytes, NULL);
	++copy_count;
	prtd->pcm_buf_pos += fbytes;
	if (copy_count == 1) {
		mutex_lock(&the_locks.lock);
		alsa_audio_configure(prtd);
		mutex_unlock(&the_locks.lock);
	}
	if ((prtd->running) && (msm_vol_ctl.update)) {
		rc = msm_audio_volume_update(PCMPLAYBACK_DECODERID,
				msm_vol_ctl.volume, msm_vol_ctl.pan);
		msm_vol_ctl.update = 0;
	}

	return  rc;
}
static int msm_pcm_open(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct msm_audio *prtd;
	int ret = 0;

	prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL);
	if (prtd == NULL) {
		ret = -ENOMEM;
		return ret;
	}
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		runtime->hw = msm_pcm_playback_hardware;
		prtd->dir = SNDRV_PCM_STREAM_PLAYBACK;
		prtd->playback_substream = substream;
		prtd->eos_ack = 0;
		ret = msm_audio_volume_update(PCMPLAYBACK_DECODERID,
			msm_vol_ctl.volume, msm_vol_ctl.pan);
	} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
		runtime->hw = msm_pcm_capture_hardware;
		prtd->dir = SNDRV_PCM_STREAM_CAPTURE;
		prtd->capture_substream = substream;
	}
	ret = snd_pcm_hw_constraint_list(runtime, 0,
						SNDRV_PCM_HW_PARAM_RATE,
						&constraints_sample_rates);
	if (ret < 0)
		goto out;
	/* Ensure that buffer size is a multiple of period size */
	ret = snd_pcm_hw_constraint_integer(runtime,
					    SNDRV_PCM_HW_PARAM_PERIODS);
	if (ret < 0)
		goto out;

	prtd->ops = &snd_msm_audio_ops;
	prtd->out[0].used = BUF_INVALID_LEN;
	prtd->out_head = 1; /* point to second buffer on startup */
	runtime->private_data = prtd;

	ret = alsa_adsp_configure(prtd);
	if (ret)
		goto out;
	copy_count = 0;
	return 0;

 out:
	kfree(prtd);
	return ret;
}
Beispiel #3
0
static int snd_msm_volume_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	int change;
	int volume;

	volume = ucontrol->value.integer.value[0];
	spin_lock_irq(&the_locks.mixer_lock);
	change = (msm_vol_ctl.volume != volume);
	if (change) {
		msm_vol_ctl.volume = volume;
		msm_audio_volume_update(PCMPLAYBACK_DECODERID,
				msm_vol_ctl.volume, msm_vol_ctl.pan);
	}
	spin_unlock_irq(&the_locks.mixer_lock);
	return 0;
}