[Bugfix][API-534][ecall] bug fix in lab certification test 10: perfect mtk patch error 2
Change-Id: I09e0a0e79fee5a6b5b01efd4dfb7e8ef3a85103d
diff --git a/src/kernel/linux/v4.19/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/src/kernel/linux/v4.19/sound/soc/mediatek/common/mtk-afe-platform-driver.c
index d4f04eb..82140ff 100755
--- a/src/kernel/linux/v4.19/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+++ b/src/kernel/linux/v4.19/sound/soc/mediatek/common/mtk-afe-platform-driver.c
@@ -93,8 +93,8 @@
static snd_pcm_uframes_t mtk_afe_pcm_pointer
(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
+ struct snd_soc_pcm_runtime *rtd;
+ struct snd_soc_component *component;
struct mtk_base_afe *afe;
struct mtk_base_afe_memif *memif;
const struct mtk_base_memif_data *memif_data;
@@ -105,19 +105,44 @@
unsigned int hw_ptr = 0, hw_base = 0;
int ret, pcm_ptr_bytes;
- if (component == NULL) {
-// dev_err(dev, "%s component NULL\n", __func__);
+ if(substream == NULL)
+ {
+ dev_err(NULL, "%s substream is NULL\n", __func__);
return -EINVAL;
}
+
+ rtd = substream->private_data;
+
+ if(rtd == NULL)
+ {
+ dev_err(NULL, "%s rtd is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
+
+ if (component == NULL) {
+ dev_err(NULL, "%s component NULL\n", __func__);
+ return -EINVAL;
+ }
afe = snd_soc_component_get_drvdata(component);
if (afe == NULL) {
-// dev_err(dev, "%s afe NULL\n", __func__);
+ dev_err(NULL, "%s afe NULL\n", __func__);
return -EINVAL;
}
dev = afe->dev;
if(dev == NULL){
- return -EINVAL;
+ dev_err(NULL, "%s dev is NULL\n", __func__);
+ // return -EINVAL;
+ }
+
+ if (rtd->cpu_dai->id >= 0 && rtd->cpu_dai->id < afe->memif_size) {
+ memif = &afe->memif[rtd->cpu_dai->id];
+ }
+ else {
+ dev_err(dev, "%s rtd->cpu_dai->id %d is error\n", __func__ , rtd->cpu_dai->id);
+ return -EINVAL;
}
memif = &afe->memif[rtd->cpu_dai->id];
if (memif == NULL) {
@@ -131,7 +156,7 @@
}
regmap = afe->regmap;
if (regmap == NULL) {
- dev_err(dev, "%s regmap NULL\n", __func__);
+ dev_err(dev, "%s regmap 2 NULL\n", __func__);
return -EINVAL;
}
@@ -154,6 +179,11 @@
pcm_ptr_bytes = hw_ptr - hw_base;
+ if(pcm_ptr_bytes <0)
+ {
+ dev_err(dev, "%s pcm_ptr_bytes < 0 hw_ptr is %d, hw_base is %d \n", __func__ , hw_ptr, hw_base);
+ }
+
POINTER_RETURN_FRAMES:
pcm_ptr_bytes = word_size_align(pcm_ptr_bytes);
return bytes_to_frames(substream->runtime, pcm_ptr_bytes);