ASoC: qcom: Add four speaker support on MI2S secondary
Subsystems (4)
PATCH v2 1/1 ASoC: qcom: Add four speaker support on MI2S secondary
Add four speaker support on MI2S secondary block by using I2S SD1 line on gpio52 pin, and add channel map control support in the lpass-cpu audio driver.
---
Changes Since V1:
-- removed set_channel_map/get_channel_map implementation as default kcontrols
added in pcm_new API.
sound/soc/qcom/lpass-cpu.c | 32 ++++++++++++++++++++++++++++++++ sound/soc/qcom/lpass-sc7180.c | 1 + sound/soc/qcom/lpass.h | 2 ++ 3 files changed, 35 insertions(+)
sound/soc/qcom/lpass-cpu.c +32 -0
@@ -29,6 +29,14 @@#define LPASS_CPU_I2S_SD0_1_2_MASK GENMASK(2, 0)#define LPASS_CPU_I2S_SD0_1_2_3_MASK GENMASK(3, 0) +/* +* Channel maps for Quad channel playbacks on MI2S Secondary +*/ +static struct snd_pcm_chmap_elem lpass_quad_chmaps = { + .channels =4 , + .map = {SNDRV_CHMAP_FL ,SNDRV_CHMAP_RL , +SNDRV_CHMAP_FR ,SNDRV_CHMAP_RR } +};static int lpass_cpu_init_i2sctl_bitfields (struct device *dev,struct lpaif_i2sctl *i2sctl,struct regmap *map) {
@@ -324,6 +332,25 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { };EXPORT_SYMBOL_GPL (asoc_qcom_lpass_cpu_dai_ops); +int lpass_cpu_pcm_new (struct snd_soc_pcm_runtime *rtd, +struct snd_soc_dai *dai) +{ +int ret; +struct snd_soc_dai_driver *drv = dai->driver; +struct lpass_data *drvdata =snd_soc_dai_get_drvdata (dai); + +if (drvdata->mi2s_playback_sd_mode[dai->id] ==LPAIF_I2SCTL_MODE_QUAD01 ) { + ret =snd_pcm_add_chmap_ctls (rtd->pcm,SNDRV_PCM_STREAM_PLAYBACK , + &lpass_quad_chmaps, drv->playback.channels_max,0 , +NULL ); +if (ret <0 ) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (lpass_cpu_pcm_new); +int asoc_qcom_lpass_cpu_dai_probe (struct snd_soc_dai *dai) {struct lpass_data *drvdata =snd_soc_dai_get_drvdata (dai);
@@ -856,6 +883,11 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) PTR_ERR(drvdata->mi2s_bit_clk[dai_id]));return PTR_ERR (drvdata->mi2s_bit_clk[dai_id]); } +if (drvdata->mi2s_playback_sd_mode[dai_id] == +LPAIF_I2SCTL_MODE_QUAD01 ) { + variant->dai_driver[dai_id].playback.channels_min =4 ; + variant->dai_driver[dai_id].playback.channels_max =4 ; + } }/* Allocation for i2sctl regmap fields */
sound/soc/qcom/lpass-sc7180.c +1 -0
@@ -58,6 +58,7 @@ static struct snd_soc_dai_driver sc7180_lpass_cpu_dai_driver[] = { }, .probe = &asoc_qcom_lpass_cpu_dai_probe, .ops = &asoc_qcom_lpass_cpu_dai_ops, + .pcm_new = lpass_cpu_pcm_new, }, { .id = LPASS_DP_RX, .name = "Hdmi",
sound/soc/qcom/lpass.h +2 -0
@@ -259,5 +259,7 @@ void asoc_qcom_lpass_cpu_platform_shutdown(struct platform_device *pdev);int asoc_qcom_lpass_cpu_platform_probe (struct platform_device *pdev);int asoc_qcom_lpass_cpu_dai_probe (struct snd_soc_dai *dai);extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops; +int lpass_cpu_pcm_new (struct snd_soc_pcm_runtime *rtd, +struct snd_soc_dai *dai);#endif /* __LPASS_H__ */
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 20 lines · Srinivasa Rao Mandadapu
Add four speaker support on MI2S secondary block by using I2S SD1 line on gpio52 pin, and add channel map control support in the lpass-cpu audio driver.
Signed-off-by Srinivasa Rao Mandadapu <[email protected]>---
Changes Since V1:
-- removed set_channel_map/get_channel_map implementation as default kcontrols
added inpcm_newAPI.sound/soc/qcom/lpass-cpu.c | 32 ++++++++++++++++++++++++++++++++ sound/soc/qcom/lpass-sc7180.c | 1 + sound/soc/qcom/lpass.h | 2 ++ 3 files changed, 35 insertions(+)sound/soc/qcom/lpass-cpu.c +0
-0
sound/soc/qcom/lpass-cpu.c line 38
Quoted 10 lines
sound/soc/qcom/lpass-cpu.c +7
-0@@ -29,6 +29,14 @@#define LPASS_CPU_I2S_SD0_1_2_MASK GENMASK(2, 0)#define LPASS_CPU_I2S_SD0_1_2_3_MASK GENMASK(3, 0) +/* +* Channel maps for Quad channel playbacks on MI2S Secondary +*/ +static struct snd_pcm_chmap_elem lpass_quad_chmaps = { + .channels =4 , + .map = {SNDRV_CHMAP_FL ,SNDRV_CHMAP_RL , +SNDRV_CHMAP_FR ,SNDRV_CHMAP_RR }
AFAIU, You would need an empty entry at the end of this list if not we will endup in a dereferencing memory sitting right next to this array which will lead to random memory corruptions...
Have a look at some of the examples in existing codec drivers.
Other than that patch looks good.
--srini
Quoted 67 lines
sound/soc/qcom/lpass-cpu.c +25
-0+};static int lpass_cpu_init_i2sctl_bitfields (struct device *dev,struct lpaif_i2sctl *i2sctl,struct regmap *map) {@@ -324,6 +332,25 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { };EXPORT_SYMBOL_GPL (asoc_qcom_lpass_cpu_dai_ops); +int lpass_cpu_pcm_new (struct snd_soc_pcm_runtime *rtd, +struct snd_soc_dai *dai) +{ +int ret; +struct snd_soc_dai_driver *drv = dai->driver; +struct lpass_data *drvdata =snd_soc_dai_get_drvdata (dai); + +if (drvdata->mi2s_playback_sd_mode[dai->id] ==LPAIF_I2SCTL_MODE_QUAD01 ) { + ret =snd_pcm_add_chmap_ctls (rtd->pcm,SNDRV_PCM_STREAM_PLAYBACK , + &lpass_quad_chmaps, drv->playback.channels_max,0 , +NULL ); +if (ret <0 ) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (lpass_cpu_pcm_new); +int asoc_qcom_lpass_cpu_dai_probe (struct snd_soc_dai *dai) {struct lpass_data *drvdata =snd_soc_dai_get_drvdata (dai);@@ -856,6 +883,11 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) PTR_ERR(drvdata->mi2s_bit_clk[dai_id]));return PTR_ERR (drvdata->mi2s_bit_clk[dai_id]); } +if (drvdata->mi2s_playback_sd_mode[dai_id] == +LPAIF_I2SCTL_MODE_QUAD01 ) { + variant->dai_driver[dai_id].playback.channels_min =4 ; + variant->dai_driver[dai_id].playback.channels_max =4 ; + } }/* Allocation for i2sctl regmap fields */ sound/soc/qcom/lpass-sc7180.c +1
-0@@ -58,6 +58,7 @@ static struct snd_soc_dai_driver sc7180_lpass_cpu_dai_driver[] = { }, .probe = &asoc_qcom_lpass_cpu_dai_probe, .ops = &asoc_qcom_lpass_cpu_dai_ops, + .pcm_new = lpass_cpu_pcm_new, }, { .id = LPASS_DP_RX, .name = "Hdmi",sound/soc/qcom/lpass.h +2
-0@@ -259,5 +259,7 @@ void asoc_qcom_lpass_cpu_platform_shutdown(struct platform_device *pdev);int asoc_qcom_lpass_cpu_platform_probe (struct platform_device *pdev);int asoc_qcom_lpass_cpu_dai_probe (struct snd_soc_dai *dai);extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops; +int lpass_cpu_pcm_new (struct snd_soc_pcm_runtime *rtd, +struct snd_soc_dai *dai);#endif /* __LPASS_H__ */
Hi Srini,
Thanks for your Time!!!
Quoted 35 lines · Srinivas Kandagatla
Quoted 22 lines · Srinivasa Rao Mandadapu
Add four speaker support on MI2S secondary block by using I2S SD1 line on gpio52 pin, and add channel map control support in the lpass-cpu audio driver.
Signed-off-by Srinivasa Rao Mandadapu <[email protected]>---
Changes Since V1:
-- removed set_channel_map/get_channel_map implementation as default kcontrols added inpcm_newAPI.sound/soc/qcom/lpass-cpu.c | 32 ++++++++++++++++++++++++++++++++
sound/soc/qcom/lpass-sc7180.c| 1 + sound/soc/qcom/lpass.h | 2 ++3 files changed, 35 insertions(+)sound/soc/qcom/lpass-cpu.c +0
-0@@ -29,6 +29,14 @@ #define LPASS_CPU_I2S_SD0_1_2_MASK GENMASK(2, 0) #define LPASS_CPU_I2S_SD0_1_2_3_MASK GENMASK(3, 0)Quoted 7 lines
+/*
+ * Channel maps for Quad channel playbacks on MI2S Secondary
+ */
+static structsnd_pcm_chmap_elemlpass_quad_chmaps= { + .channels = 4,
+ .map = {SNDRV_CHMAP_FL,SNDRV_CHMAP_RL,
+SNDRV_CHMAP_FR,SNDRV_CHMAP_RR}AFAIU, You would need an empty entry at the end of this list if not we will endup in a dereferencing memory sitting right next to this array which will lead to random memory corruptions...
Quoted 5 lines
Have a look at some of the examples in existing codec drivers.
Other than that patch looks good.
--srini
Okay. Will change accordingly.
Quoted 72 lines
Quoted 72 lines
+};
static intlpass_cpu_init_i2sctl_bitfields(struct device *dev, struct lpaif_i2sctl *i2sctl, struct regmap *map){sound/soc/qcom/lpass-cpu.c +18
-0@@ -324,6 +332,25 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { }; EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); +int lpass_cpu_pcm_new(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai) +{ + int ret; + struct snd_soc_dai_driver *drv = dai->driver; + struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); + + if (drvdata->mi2s_playback_sd_mode[dai->id] ==LPAIF_I2SCTL_MODE_QUAD01 ) { + ret = snd_pcm_add_chmap_ctls(rtd->pcm,SNDRV_PCM_STREAM_PLAYBACK , + &lpass_quad_chmaps, drv->playback.channels_max, 0, + NULL); + if (ret < 0) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL (lpass_cpu_pcm_new); +int
asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai){
structlpass_data*drvdata =snd_soc_dai_get_drvdata(dai);sound/soc/qcom/lpass-cpu.c +5
-0@@ -856,6 +883,11 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) PTR_ERR(drvdata->mi2s_bit_clk[dai_id])); return PTR_ERR(drvdata->mi2s_bit_clk[dai_id]); } + if (drvdata->mi2s_playback_sd_mode[dai_id] == + LPAIF_I2SCTL_MODE_QUAD01) { + variant->dai_driver[dai_id].playback.channels_min =4 ; + variant->dai_driver[dai_id].playback.channels_max =4 ; + } } /* Allocation for i2sctl regmap fields */sound/soc/qcom/lpass-sc7180.c +1
-0@@ -58,6 +58,7 @@ static struct snd_soc_dai_driver sc7180_lpass_cpu_dai_driver[] = { }, .probe = &asoc_qcom_lpass_cpu_dai_probe, .ops = &asoc_qcom_lpass_cpu_dai_ops, + .pcm_new = lpass_cpu_pcm_new, }, { .id = LPASS_DP_RX,.name = "Hdmi",
sound/soc/qcom/lpass.h +2
-0@@ -259,5 +259,7 @@ void asoc_qcom_lpass_cpu_platform_shutdown(struct platform_device *pdev); int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev); int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai); extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops; +int lpass_cpu_pcm_new (struct snd_soc_pcm_runtime *rtd, + struct snd_soc_dai *dai); #endif /* __LPASS_H__ */
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.