static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) { int ret = 0; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); return ret; }
/************************************************************************************************ ** Functions *************************************************************************************************/ static ssize_t sky_direct_adsp_read(struct file *filp, char __user *buffer, size_t length, loff_t *offset) { int ret = 0; #if 0 char rec_ind; #endif if(!bUseSKYDirectADSP) return -1; if(voip_info.state != VOIP_STARTED) return -2; if(voip_info.capture_start != 1) return -3; #if 0 //navan - 2012.09.27 - for VoLTE Recording if(copy_from_user(&rec_ind, (void __user *)buffer, 1)) { rec_ind = 0; } if(rec_ind == 0xff) { int rx_record_size_retVal = 0; // 20130417 jmlee add volte recording noise fix if(length < record_size) return 0; if(record_size == 0) return 0; // 20130417 jmlee add volte recording noise fix spin_lock(&pcm_read_lock); if(copy_to_user((void __user *)buffer, rx_temp, record_size)) { spin_unlock(&pcm_read_lock); return 0; } memset(rx_temp, 0x0, sizeof(rx_temp)); //bRecordingFlag = true; spin_unlock(&pcm_read_lock); rx_record_size_retVal = record_size; // 20130417 jmlee add volte recording noise fix record_size = 0; //return record_size; return rx_record_size_retVal; // 20130417 jmlee add volte recording noise fix } //-->20130214 jhsong : volte rec tx buffer too small if(rec_ind == 0xfe) { int tx_record_size_retVal = 0; // jmlee add if(length < tx_record_size) return 0; if(tx_record_size == 0) return 0; // 20130417 jmlee add volte recording noise fix spin_lock(&pcm_read_lock); if(copy_to_user((void __user *)buffer, tx_temp, tx_record_size)) { spin_unlock(&pcm_read_lock); return 0; } memset(tx_temp, 0x0, sizeof(tx_temp)); //bRecordingFlag = true; tx_record_size_retVal = tx_record_size; // jmlee add tx_record_size = 0; spin_unlock(&pcm_read_lock); return tx_record_size_retVal; // jmlee add modify } //<--20130214 jhsong : volte rec tx buffer too small #endif if(voip_info.mode == MODE_PCM) { ret = msm_pcm_capture_copy(voip_info.capture_substream, 0, 0, (void __user *)buffer, length/2); } else if(voip_info.mode == MODE_AMR_WB) { ret = msm_pcm_capture_copy(voip_info.capture_substream, 0, 0, (void __user *)buffer, length); } else if(voip_info.mode == MODE_AMR) { ret = msm_pcm_capture_copy(voip_info.capture_substream, 0, 0, (void __user *)buffer, length); } else return -4; if(ret != 0) return -5; return length; }