Browse Source

ASoC: update snd_pcm_ops copy interface in platform drivers

snd_pcm_ops copy interface used by msm platform drivers is replaced
with copy_user in msm-4.14. Unit of two input variables is changed
from frame count to byte.
Update all the related msm platform drivers to adapt to this change.

Change-Id: Icecd0454c7a80e5ee90407c64aaf1ca76d2d9815
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 7 years ago
parent
commit
ac147b705e

+ 3 - 5
asoc/msm-cpe-lsm.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -3132,7 +3132,7 @@ static snd_pcm_uframes_t msm_cpe_lsm_pointer(
 }
 
 static int msm_cpe_lsm_copy(struct snd_pcm_substream *substream, int a,
-	 snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
+	 unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	struct cpe_lsm_data *lsm_d = cpe_get_lsm_data(substream);
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -3140,10 +3140,8 @@ static int msm_cpe_lsm_copy(struct snd_pcm_substream *substream, int a,
 	struct cpe_lsm_session *session;
 	struct cpe_lsm_lab *lab_d = &lsm_d->lab;
 	char *pcm_buf;
-	int fbytes = 0;
 	int rc = 0;
 
-	fbytes = frames_to_bytes(runtime, frames);
 	if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
 	   runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
 		pr_err("%s: XRUN ignore for now\n", __func__);
@@ -3286,7 +3284,7 @@ static const struct snd_pcm_ops msm_cpe_lsm_ops = {
 	.prepare = msm_cpe_lsm_prepare,
 	.trigger = msm_cpe_lsm_trigger,
 	.pointer = msm_cpe_lsm_pointer,
-	.copy = msm_cpe_lsm_copy,
+	.copy_user = msm_cpe_lsm_copy,
 	.hw_params = msm_cpe_lsm_hwparams,
 	.compat_ioctl = msm_cpe_lsm_ioctl_compat,
 };

+ 6 - 7
asoc/msm-lsm-client.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -2176,12 +2176,12 @@ static snd_pcm_uframes_t msm_lsm_pcm_pointer(
 }
 
 static int msm_lsm_pcm_copy(struct snd_pcm_substream *substream, int ch,
-	snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames)
+	unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct lsm_priv *prtd = runtime->private_data;
 	char *pcm_buf = NULL;
-	int fbytes = 0, rc = 0;
+	int rc = 0;
 	struct snd_soc_pcm_runtime *rtd;
 
 	if (!substream->private_data) {
@@ -2196,7 +2196,6 @@ static int msm_lsm_pcm_copy(struct snd_pcm_substream *substream, int ch,
 		return -EINVAL;
 	}
 
-	fbytes = frames_to_bytes(runtime, frames);
 	if (runtime->status->state == SNDRV_PCM_STATE_XRUN ||
 	    runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
 		dev_err(rtd->dev,
@@ -2221,12 +2220,12 @@ static int msm_lsm_pcm_copy(struct snd_pcm_substream *substream, int ch,
 		prtd->lsm_client->hw_params.period_count;
 	pcm_buf = prtd->lsm_client->lab_buffer[prtd->appl_cnt].data;
 	dev_dbg(rtd->dev,
-		"%s: copy the pcm data size %d\n",
+		"%s: copy the pcm data size %lu\n",
 		__func__, fbytes);
 	if (pcm_buf) {
 		if (copy_to_user(buf, pcm_buf, fbytes)) {
 			dev_err(rtd->dev,
-				"%s: failed to copy bytes %d\n",
+				"%s: failed to copy bytes %lu\n",
 				__func__, fbytes);
 			return -EINVAL;
 		}
@@ -2341,7 +2340,7 @@ static const struct snd_pcm_ops msm_lsm_ops = {
 	.prepare	= msm_lsm_prepare,
 	.compat_ioctl   = msm_lsm_ioctl_compat,
 	.hw_params      = msm_lsm_hw_params,
-	.copy           = msm_lsm_pcm_copy,
+	.copy_user      = msm_lsm_pcm_copy,
 	.pointer        = msm_lsm_pcm_pointer,
 };
 

+ 14 - 14
asoc/msm-pcm-afe-v2.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -489,20 +489,20 @@ static int msm_afe_open(struct snd_pcm_substream *substream)
 }
 
 static int msm_afe_playback_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
+				int channel, unsigned long hwoff,
+				void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct pcm_afe_info *prtd = runtime->private_data;
-	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
+	char *hwbuf = runtime->dma_area + hwoff;
 	u32 mem_map_handle = 0;
 
 	pr_debug("%s : appl_ptr 0x%lx hw_ptr 0x%lx dest_to_copy 0x%pK\n",
 		__func__,
 		runtime->control->appl_ptr, runtime->status->hw_ptr, hwbuf);
 
-	if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) {
+	if (copy_from_user(hwbuf, buf, fbytes)) {
 		pr_err("%s :Failed to copy audio from user buffer\n",
 			__func__);
 
@@ -542,13 +542,13 @@ fail:
 }
 
 static int msm_afe_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
+				int channel, unsigned long hwoff,
+				void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct pcm_afe_info *prtd = runtime->private_data;
-	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
+	char *hwbuf = runtime->dma_area + hwoff;
 	u32 mem_map_handle = 0;
 
 	if (!prtd->mmap_flag) {
@@ -590,7 +590,7 @@ static int msm_afe_capture_copy(struct snd_pcm_substream *substream,
 			__func__, runtime->control->appl_ptr,
 			runtime->status->hw_ptr, hwbuf);
 
-	if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) {
+	if (copy_to_user(buf, hwbuf, fbytes)) {
 		pr_err("%s: copy to user failed\n", __func__);
 
 		goto fail;
@@ -602,8 +602,8 @@ fail:
 }
 
 static int msm_afe_copy(struct snd_pcm_substream *substream, int channel,
-			snd_pcm_uframes_t hwoff, void __user *buf,
-			snd_pcm_uframes_t frames)
+			unsigned long hwoff, void __user *buf,
+			unsigned long fbytes)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct pcm_afe_info *prtd = runtime->private_data;
@@ -618,10 +618,10 @@ static int msm_afe_copy(struct snd_pcm_substream *substream, int channel,
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 		ret = msm_afe_playback_copy(substream, channel, hwoff,
-					buf, frames);
+					buf, fbytes);
 	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
 		ret = msm_afe_capture_copy(substream, channel, hwoff,
-					buf, frames);
+					buf, fbytes);
 	return ret;
 }
 
@@ -841,7 +841,7 @@ static snd_pcm_uframes_t msm_afe_pointer(struct snd_pcm_substream *substream)
 
 static const struct snd_pcm_ops msm_afe_ops = {
 	.open           = msm_afe_open,
-	.copy           = msm_afe_copy,
+	.copy_user      = msm_afe_copy,
 	.hw_params	= msm_afe_hw_params,
 	.trigger	= msm_afe_trigger,
 	.close          = msm_afe_close,

+ 10 - 13
asoc/msm-pcm-dtmf-v2.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2017-2018 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -217,24 +217,21 @@ static void dtmf_rx_detected_cb(uint8_t *pkt,
 }
 
 static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
+				int channel, unsigned long hwoff,
+				void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
-	int count = 0;
 	struct dtmf_buf_node *buf_node = NULL;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct dtmf_drv_info *prtd = runtime->private_data;
 	unsigned long dsp_flags;
 
-	count = frames_to_bytes(runtime, frames);
-
 	ret = wait_event_interruptible_timeout(prtd->out_wait,
 				(!list_empty(&prtd->out_queue)),
 				1 * HZ);
 
 	if (ret > 0) {
-		if (count <= DTMF_PKT_SIZE) {
+		if (fbytes <= DTMF_PKT_SIZE) {
 			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
 			buf_node = list_first_entry(&prtd->out_queue,
 					struct dtmf_buf_node, list);
@@ -242,7 +239,7 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
 			ret = copy_to_user(buf,
 					   &buf_node->dtmf_det_pkt,
-					   count);
+					   fbytes);
 			if (ret) {
 				pr_err("%s: Copy to user returned %d\n",
 					__func__, ret);
@@ -254,8 +251,8 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
 
 		} else {
-			pr_err("%s: Read count %d > DTMF_PKT_SIZE\n",
-				__func__, count);
+			pr_err("%s: Read count %lu > DTMF_PKT_SIZE\n",
+				__func__, fbytes);
 			ret = -ENOMEM;
 		}
 	} else if (ret == 0) {
@@ -269,14 +266,14 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 }
 
 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)
+	 unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 
 	pr_debug("%s() DTMF\n", __func__);
 
 	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
+		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, fbytes);
 
 	return ret;
 }
@@ -524,7 +521,7 @@ static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
 
 static const struct snd_pcm_ops msm_pcm_ops = {
 	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
+	.copy_user	= msm_pcm_copy,
 	.hw_params	= msm_pcm_hw_params,
 	.close          = msm_pcm_close,
 	.prepare        = msm_pcm_prepare,

+ 18 - 23
asoc/msm-pcm-host-voice-v2.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -1088,8 +1088,8 @@ done:
 }
 
 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)
+				 unsigned long hwoff, void __user *buf,
+				 unsigned long fbytes)
 {
 	int ret = 0;
 	struct hpcm_buf_node *buf_node = NULL;
@@ -1098,8 +1098,6 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 	struct dai_data *dai_data = hpcm_get_dai_data(substream->pcm->id, prtd);
 	unsigned long dsp_flags;
 
-	int count = frames_to_bytes(runtime, frames);
-
 	if (dai_data == NULL) {
 		pr_err("%s, dai_data is null\n", __func__);
 
@@ -1112,7 +1110,7 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 				dai_data->state == HPCM_STOPPED),
 				1 * HZ);
 	if (ret > 0) {
-		if (count <= HPCM_MAX_VOC_PKT_SIZE) {
+		if (fbytes <= HPCM_MAX_VOC_PKT_SIZE) {
 			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
 			buf_node =
 				list_first_entry(&dai_data->free_queue,
@@ -1120,14 +1118,14 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 			list_del(&buf_node->list);
 			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
 			ret = copy_from_user(&buf_node->frame.voc_pkt, buf,
-					     count);
-			buf_node->frame.len = count;
+					     fbytes);
+			buf_node->frame.len = fbytes;
 			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
 			list_add_tail(&buf_node->list, &dai_data->filled_queue);
 			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
 		} else {
-			pr_err("%s: Write cnt %d is > HPCM_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
+			pr_err("%s: Write cnt %lu is > HPCM_MAX_VOC_PKT_SIZE\n",
+				__func__, fbytes);
 			ret = -ENOMEM;
 		}
 	} else if (ret == 0) {
@@ -1142,11 +1140,10 @@ done:
 }
 
 static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-				int channel, snd_pcm_uframes_t hwoff,
-				void __user *buf, snd_pcm_uframes_t frames)
+				int channel, unsigned long hwoff,
+				void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
-	int count = 0;
 	struct hpcm_buf_node *buf_node = NULL;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct hpcm_drv *prtd = runtime->private_data;
@@ -1160,15 +1157,13 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 		goto done;
 	}
 
-	count = frames_to_bytes(runtime, frames);
-
 	ret = wait_event_interruptible_timeout(dai_data->queue_wait,
 				(!list_empty(&dai_data->filled_queue) ||
 				dai_data->state == HPCM_STOPPED),
 				1 * HZ);
 
 	if (ret > 0) {
-		if (count <= HPCM_MAX_VOC_PKT_SIZE) {
+		if (fbytes <= HPCM_MAX_VOC_PKT_SIZE) {
 			spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags);
 			buf_node = list_first_entry(&dai_data->filled_queue,
 					struct hpcm_buf_node, list);
@@ -1186,8 +1181,8 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
 
 		} else {
-			pr_err("%s: Read count %d > HPCM_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
+			pr_err("%s: Read count %lu > HPCM_MAX_VOC_PKT_SIZE\n",
+				__func__, fbytes);
 			ret = -ENOMEM;
 		}
 
@@ -1204,17 +1199,17 @@ done:
 }
 
 static int msm_pcm_copy(struct snd_pcm_substream *substream, int channel,
-			snd_pcm_uframes_t hwoff, void __user *buf,
-			snd_pcm_uframes_t frames)
+			unsigned long hwoff, void __user *buf,
+			unsigned long fbytes)
 {
 	int ret = 0;
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 		ret = msm_pcm_playback_copy(substream, channel,
-					    hwoff, buf, frames);
+					    hwoff, buf, fbytes);
 	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
 		ret = msm_pcm_capture_copy(substream, channel,
-					   hwoff, buf, frames);
+					   hwoff, buf, fbytes);
 
 	return ret;
 }
@@ -1446,7 +1441,7 @@ static const struct snd_pcm_ops msm_pcm_ops = {
 	.prepare        = msm_pcm_prepare,
 	.trigger        = msm_pcm_trigger,
 	.pointer        = msm_pcm_pointer,
-	.copy           = msm_pcm_copy,
+	.copy_user      = msm_pcm_copy,
 	.close          = msm_pcm_close,
 };
 

+ 3 - 3
asoc/msm-pcm-q6-noirq.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -530,7 +530,7 @@ static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream)
 }
 
 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)
+	 unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	return -EINVAL;
 }
@@ -1182,7 +1182,7 @@ exit:
 static const struct snd_pcm_ops msm_pcm_ops = {
 	.open           = msm_pcm_open,
 	.prepare        = msm_pcm_prepare,
-	.copy           = msm_pcm_copy,
+	.copy_user      = msm_pcm_copy,
 	.hw_params	= msm_pcm_hw_params,
 	.ioctl          = msm_pcm_ioctl,
 #ifdef CONFIG_COMPAT

+ 14 - 18
asoc/msm-pcm-q6-v2.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -714,10 +714,9 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
 }
 
 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)
+	unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
-	int fbytes = 0;
 	int xfer = 0;
 	char *bufptr = NULL;
 	void *data = NULL;
@@ -728,7 +727,6 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct msm_audio *prtd = runtime->private_data;
 
-	fbytes = frames_to_bytes(runtime, frames);
 	pr_debug("%s: prtd->out_count = %d\n",
 				__func__, atomic_read(&prtd->out_count));
 
@@ -775,8 +773,8 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 
 		bufptr = data;
 		if (bufptr) {
-			pr_debug("%s:fbytes =%d: xfer=%d size=%d\n",
-						__func__, fbytes, xfer, size);
+			pr_debug("%s:fbytes =%lu: xfer=%d size=%d\n",
+				 __func__, fbytes, xfer, size);
 			if (copy_from_user(bufptr, buf, xfer)) {
 				ret = -EFAULT;
 				pr_err("%s: copy_from_user failed\n",
@@ -786,8 +784,8 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 			}
 			buf += xfer;
 			fbytes -= xfer;
-			pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes,
-				xfer);
+			pr_debug("%s:fbytes = %lu: xfer=%d\n", __func__,
+				 fbytes, xfer);
 			if (atomic_read(&prtd->start)) {
 				pr_debug("%s:writing %d bytes of buffer to dsp\n",
 						__func__, xfer);
@@ -870,11 +868,10 @@ static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
 }
 
 static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-		 int channel, snd_pcm_uframes_t hwoff, void __user *buf,
-						 snd_pcm_uframes_t frames)
+		 int channel, unsigned long hwoff, void __user *buf,
+						 unsigned long fbytes)
 {
 	int ret = 0;
-	int fbytes = 0;
 	int xfer;
 	char *bufptr;
 	void *data = NULL;
@@ -886,7 +883,6 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 
 
 	pr_debug("%s\n", __func__);
-	fbytes = frames_to_bytes(runtime, frames);
 
 	pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr);
 	pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr);
@@ -915,7 +911,7 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 	data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx);
 	bufptr = data;
 	pr_debug("Size = %d\n", size);
-	pr_debug("fbytes = %d\n", fbytes);
+	pr_debug("fbytes = %lu\n", fbytes);
 	pr_debug("idx = %d\n", idx);
 	if (bufptr) {
 		xfer = fbytes;
@@ -932,7 +928,7 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 		fbytes -= xfer;
 		size -= xfer;
 		prtd->in_frame_info[idx].offset += xfer;
-		pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n",
+		pr_debug("%s:fbytes = %lu: size=%d: xfer=%d\n",
 					__func__, fbytes, size, xfer);
 		pr_debug(" Sending next buffer to dsp\n");
 		memset(&prtd->in_frame_info[idx], 0,
@@ -977,14 +973,14 @@ static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
 }
 
 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)
+	 unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames);
+		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, fbytes);
 	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
+		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, fbytes);
 	return ret;
 }
 
@@ -1086,7 +1082,7 @@ static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
 
 static const struct snd_pcm_ops msm_pcm_ops = {
 	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
+	.copy_user	= msm_pcm_copy,
 	.hw_params	= msm_pcm_hw_params,
 	.close          = msm_pcm_close,
 	.ioctl          = snd_pcm_lib_ioctl,

+ 21 - 26
asoc/msm-pcm-voip-v2.c

@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -778,7 +778,7 @@ err:
 }
 
 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)
+	unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 	struct voip_buf_node *buf_node = NULL;
@@ -786,9 +786,7 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 	struct voip_drv_info *prtd = runtime->private_data;
 	unsigned long dsp_flags;
 
-	int count = frames_to_bytes(runtime, frames);
-
-	pr_debug("%s: count = %d, frames=%d\n", __func__, count, (int)frames);
+	pr_debug("%s: fbytes=%lu\n", __func__, fbytes);
 
 	if (prtd->voip_reset) {
 		pr_debug("%s: RESET event happened during VoIP\n", __func__);
@@ -805,7 +803,7 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 	}
 
 	if (ret > 0) {
-		if (count <= VOIP_MAX_VOC_PKT_SIZE) {
+		if (fbytes <= VOIP_MAX_VOC_PKT_SIZE) {
 			spin_lock_irqsave(&prtd->dsp_lock, dsp_flags);
 			buf_node =
 				list_first_entry(&prtd->free_in_queue,
@@ -814,23 +812,23 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
 			if (prtd->mode == MODE_PCM) {
 				ret = copy_from_user(&buf_node->frame.voc_pkt,
-							buf, count);
+							buf, fbytes);
 				if (ret) {
 					pr_err("%s: copy from user failed %d\n",
 					       __func__, ret);
 					return -EFAULT;
 				}
-				buf_node->frame.pktlen = count;
+				buf_node->frame.pktlen = fbytes;
 			} else {
 				ret = copy_from_user(&buf_node->frame,
-							buf, count);
+							buf, fbytes);
 				if (ret) {
 					pr_err("%s: copy from user failed %d\n",
 					       __func__, ret);
 					return -EFAULT;
 				}
-				if (buf_node->frame.pktlen >= count)
-					buf_node->frame.pktlen = count -
+				if (buf_node->frame.pktlen >= fbytes)
+					buf_node->frame.pktlen = fbytes -
 					(sizeof(buf_node->frame.frm_hdr) +
 					 sizeof(buf_node->frame.pktlen));
 			}
@@ -838,8 +836,8 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 			list_add_tail(&buf_node->list, &prtd->in_queue);
 			spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags);
 		} else {
-			pr_err("%s: Write cnt %d is > VOIP_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
+			pr_err("%s: Write cnt %lu is > VOIP_MAX_VOC_PKT_SIZE\n",
+				__func__, fbytes);
 			ret = -ENOMEM;
 		}
 
@@ -853,20 +851,17 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
 	return  ret;
 }
 static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
-		int channel, snd_pcm_uframes_t hwoff, void __user *buf,
-						snd_pcm_uframes_t frames)
+		int channel, unsigned long hwoff, void __user *buf,
+						unsigned long fbytes)
 {
 	int ret = 0;
-	int count = 0;
 	struct voip_buf_node *buf_node = NULL;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct voip_drv_info *prtd = runtime->private_data;
 	unsigned long dsp_flags;
 	int size;
 
-	count = frames_to_bytes(runtime, frames);
-
-	pr_debug("%s: count = %d\n", __func__, count);
+	pr_debug("%s: fbytes = %lu\n", __func__, fbytes);
 
 	if (prtd->voip_reset) {
 		pr_debug("%s: RESET event happened during VoIP\n", __func__);
@@ -885,7 +880,7 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 
 	if (ret > 0) {
 
-		if (count <= VOIP_MAX_VOC_PKT_SIZE) {
+		if (fbytes <= VOIP_MAX_VOC_PKT_SIZE) {
 			spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags);
 			buf_node = list_first_entry(&prtd->out_queue,
 					struct voip_buf_node, list);
@@ -914,8 +909,8 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 						&prtd->free_out_queue);
 			spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags);
 		} else {
-			pr_err("%s: Read count %d > VOIP_MAX_VOC_PKT_SIZE\n",
-				__func__, count);
+			pr_err("%s: Read fbytes %lu > VOIP_MAX_VOC_PKT_SIZE\n",
+				__func__, fbytes);
 			ret = -ENOMEM;
 		}
 
@@ -930,14 +925,14 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
 	return ret;
 }
 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)
+	 unsigned long hwoff, void __user *buf, unsigned long fbytes)
 {
 	int ret = 0;
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames);
+		ret = msm_pcm_playback_copy(substream, a, hwoff, buf, fbytes);
 	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
-		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames);
+		ret = msm_pcm_capture_copy(substream, a, hwoff, buf, fbytes);
 
 	return ret;
 }
@@ -1598,7 +1593,7 @@ static int voip_get_media_type(uint32_t mode, uint32_t rate_type,
 
 static const struct snd_pcm_ops msm_pcm_ops = {
 	.open           = msm_pcm_open,
-	.copy		= msm_pcm_copy,
+	.copy_user	= msm_pcm_copy,
 	.hw_params	= msm_pcm_hw_params,
 	.close          = msm_pcm_close,
 	.prepare        = msm_pcm_prepare,