diff mbox series

[v3,4/5] ASoC: qcom: Add support for audio over DP

Message ID 1598855964-1042-5-git-send-email-srivasam@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series Qualcomm's lpass-hdmi ASoC driver to support audio over dp port | expand

Commit Message

Srinivasa Rao Mandadapu Aug. 31, 2020, 6:39 a.m. UTC
From: V Sujith Kumar Reddy <vsujithk@codeaurora.org>

Add support for audio playback over DP in lpass sc7180 platform driver.
Add lpass_variant structure for hdmi data configuaration.

Signed-off-by: Srinivasa Rao <srivasam@codeaurora.org>
Signed-off-by: V Sujith Kumar Reddy <vsujithk@codeaurora.org>
---
 sound/soc/qcom/lpass-sc7180.c | 121 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 120 insertions(+), 1 deletion(-)

Comments

Stephen Boyd Sept. 1, 2020, 7:32 a.m. UTC | #1
Quoting Srinivasa Rao Mandadapu (2020-08-30 23:39:23)
> diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
> index 167bf2c..cea7ae7 100644
> --- a/sound/soc/qcom/lpass-sc7180.c
> +++ b/sound/soc/qcom/lpass-sc7180.c
> @@ -190,15 +232,92 @@ static struct lpass_variant sc7180_data = {
>                                    "mi2s-bit-clk0",
>                                    "mi2s-bit-clk1",
>                                 },
> +       .id                             = I2S_INTERFACE,
>         .init                   = sc7180_lpass_init,
>         .exit                   = sc7180_lpass_exit,
>         .alloc_dma_channel      = sc7180_lpass_alloc_dma_channel,
>         .free_dma_channel       = sc7180_lpass_free_dma_channel,
>  };
>  
> +static struct lpass_variant sc7180_hdmi_data = {

Can this be const?

> +       .hdmi_tx_ctl_addr       = 0x1000,
> +       .hdmi_legacy_addr       = 0x1008,
> +       .hdmi_vbit_addr         = 0x610c0,
> +       .hdmi_ch_lsb_addr       = 0x61048,
> +       .hdmi_ch_msb_addr       = 0x6104c,
> +       .ch_stride              = 0x8,
> +       .hdmi_parity_addr       = 0x61034,
> +       .hdmi_dmactl_addr       = 0x61038,
> +       .hdmi_dma_stride        = 0x4,
> +       .hdmi_DP_addr           = 0x610c8,
> +       .hdmi_sstream_addr      = 0x6101c,
> +       .irq_reg_base           = 0x63000,
> +       .irq_ports              = 1,
> +       .rdma_reg_base          = 0x64000,
> +       .rdma_reg_stride        = 0x1000,
> +       .rdma_channels          = 4,
> +
> +       .rdma_dyncclk           = REG_FIELD_ID(0x64000, 14, 14, 4, 0x1000),
> +       .rdma_bursten           = REG_FIELD_ID(0x64000, 13, 13, 4, 0x1000),
> +       .rdma_burst8            = REG_FIELD_ID(0x64000, 15, 15, 4, 0x1000),
> +       .rdma_burst16           = REG_FIELD_ID(0x64000, 16, 16, 4, 0x1000),
> +       .rdma_dynburst          = REG_FIELD_ID(0x64000, 18, 18, 4, 0x1000),
> +       .rdma_wpscnt            = REG_FIELD_ID(0x64000, 10, 12, 4, 0x1000),
> +       .rdma_fifowm            = REG_FIELD_ID(0x64000, 1, 5, 4, 0x1000),
> +       .rdma_enable            = REG_FIELD_ID(0x64000, 0, 0, 4, 0x1000),
> +
> +       .sstream_en             = REG_FIELD(0x6101c, 0, 0),
> +       .dma_sel                        = REG_FIELD(0x6101c, 1, 2),
> +       .auto_bbit_en   = REG_FIELD(0x6101c, 3, 3),
> +       .layout                 = REG_FIELD(0x6101c, 4, 4),
> +       .layout_sp              = REG_FIELD(0x6101c, 5, 8),
> +       .set_sp_on_en   = REG_FIELD(0x6101c, 10, 10),
> +       .dp_audio               = REG_FIELD(0x6101c, 11, 11),
> +       .dp_staffing_en = REG_FIELD(0x6101c, 12, 12),
> +       .dp_sp_b_hw_en  = REG_FIELD(0x6101c, 13, 13),
> +
> +       .mute                   = REG_FIELD(0x610c8, 0, 0),
> +       .as_sdp_cc              = REG_FIELD(0x610c8, 1, 3),
> +       .as_sdp_ct              = REG_FIELD(0x610c8, 4, 7),
> +       .aif_db4                        = REG_FIELD(0x610c8, 8, 15),
> +       .frequency              = REG_FIELD(0x610c8, 16, 21),
> +       .mst_index              = REG_FIELD(0x610c8, 28, 29),
> +       .dptx_index             = REG_FIELD(0x610c8, 30, 31),
> +
> +       .soft_reset             = REG_FIELD(0x1000, 31, 31),
> +       .force_reset    = REG_FIELD(0x1000, 30, 30),
> +
> +       .use_hw_chs             = REG_FIELD(0x61038, 0, 0),
> +       .use_hw_usr             = REG_FIELD(0x61038, 1, 1),
> +       .hw_chs_sel             = REG_FIELD(0x61038, 2, 4),
> +       .hw_usr_sel             = REG_FIELD(0x61038, 5, 6),
> +
> +       .replace_vbit   = REG_FIELD(0x610c0, 0, 0),
> +       .vbit_stream    = REG_FIELD(0x610c0, 1, 1),
> +
> +       .legacy_en              =  REG_FIELD(0x1008, 0, 0),
> +       .calc_en                =  REG_FIELD(0x61034, 0, 0),
> +       .lsb_bits               =  REG_FIELD(0x61048, 0, 31),
> +       .msb_bits               =  REG_FIELD(0x6104c, 0, 31),
> +
> +       .clk_name               = (const char*[]) {
> +                                       "pcnoc-sway-clk",
> +                                       "audio-core",
> +                                       "pcnoc-mport-clk",
> +                               },
> +       .num_clks               = 3,
> +       .id                     = HDMI_INTERFACE,
> +       .dai_driver             = sc7180_lpass_cpu_hdmi_dai_driver,
> +       .num_dai                = ARRAY_SIZE(sc7180_lpass_cpu_hdmi_dai_driver),
> +       .init                   = sc7180_lpass_init,
> +       .exit                   = sc7180_lpass_exit,
> +       .alloc_dma_channel = sc7180_lpass_alloc_hdmi_dma_channel,
> +       .free_dma_channel = sc7180_lpass_free_hdmi_dma_channel,
> +
> +};

Add a newline here?

>  static const struct of_device_id sc7180_lpass_cpu_device_id[] = {
>         {.compatible = "qcom,sc7180-lpass-cpu", .data = &sc7180_data},
> -       {}
> +       {.compatible = "qcom,sc7180-lpass-hdmi", .data = &sc7180_hdmi_data}

This most likely needs to keep the sentinel around so that a match can
be made or stop if nothing is found.

>  };
>
Srinivasa Rao Mandadapu Sept. 3, 2020, 9:23 a.m. UTC | #2
Thanks Stephen, for your time for review!!!

On 9/1/2020 1:02 PM, Stephen Boyd wrote:
> Quoting Srinivasa Rao Mandadapu (2020-08-30 23:39:23)
>> diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
>> index 167bf2c..cea7ae7 100644
>> --- a/sound/soc/qcom/lpass-sc7180.c
>> +++ b/sound/soc/qcom/lpass-sc7180.c
>> @@ -190,15 +232,92 @@ static struct lpass_variant sc7180_data = {
>>                                     "mi2s-bit-clk0",
>>                                     "mi2s-bit-clk1",
>>                                  },
>> +       .id                             = I2S_INTERFACE,
>>          .init                   = sc7180_lpass_init,
>>          .exit                   = sc7180_lpass_exit,
>>          .alloc_dma_channel      = sc7180_lpass_alloc_dma_channel,
>>          .free_dma_channel       = sc7180_lpass_free_dma_channel,
>>   };
>>   
>> +static struct lpass_variant sc7180_hdmi_data = {
> Can this be const?
Yes this can be constant. will change in next patch.
>
>> +       .hdmi_tx_ctl_addr       = 0x1000,
>> +       .hdmi_legacy_addr       = 0x1008,
>> +       .hdmi_vbit_addr         = 0x610c0,
>> +       .hdmi_ch_lsb_addr       = 0x61048,
>> +       .hdmi_ch_msb_addr       = 0x6104c,
>> +       .ch_stride              = 0x8,
>> +       .hdmi_parity_addr       = 0x61034,
>> +       .hdmi_dmactl_addr       = 0x61038,
>> +       .hdmi_dma_stride        = 0x4,
>> +       .hdmi_DP_addr           = 0x610c8,
>> +       .hdmi_sstream_addr      = 0x6101c,
>> +       .irq_reg_base           = 0x63000,
>> +       .irq_ports              = 1,
>> +       .rdma_reg_base          = 0x64000,
>> +       .rdma_reg_stride        = 0x1000,
>> +       .rdma_channels          = 4,
>> +
>> +       .rdma_dyncclk           = REG_FIELD_ID(0x64000, 14, 14, 4, 0x1000),
>> +       .rdma_bursten           = REG_FIELD_ID(0x64000, 13, 13, 4, 0x1000),
>> +       .rdma_burst8            = REG_FIELD_ID(0x64000, 15, 15, 4, 0x1000),
>> +       .rdma_burst16           = REG_FIELD_ID(0x64000, 16, 16, 4, 0x1000),
>> +       .rdma_dynburst          = REG_FIELD_ID(0x64000, 18, 18, 4, 0x1000),
>> +       .rdma_wpscnt            = REG_FIELD_ID(0x64000, 10, 12, 4, 0x1000),
>> +       .rdma_fifowm            = REG_FIELD_ID(0x64000, 1, 5, 4, 0x1000),
>> +       .rdma_enable            = REG_FIELD_ID(0x64000, 0, 0, 4, 0x1000),
>> +
>> +       .sstream_en             = REG_FIELD(0x6101c, 0, 0),
>> +       .dma_sel                        = REG_FIELD(0x6101c, 1, 2),
>> +       .auto_bbit_en   = REG_FIELD(0x6101c, 3, 3),
>> +       .layout                 = REG_FIELD(0x6101c, 4, 4),
>> +       .layout_sp              = REG_FIELD(0x6101c, 5, 8),
>> +       .set_sp_on_en   = REG_FIELD(0x6101c, 10, 10),
>> +       .dp_audio               = REG_FIELD(0x6101c, 11, 11),
>> +       .dp_staffing_en = REG_FIELD(0x6101c, 12, 12),
>> +       .dp_sp_b_hw_en  = REG_FIELD(0x6101c, 13, 13),
>> +
>> +       .mute                   = REG_FIELD(0x610c8, 0, 0),
>> +       .as_sdp_cc              = REG_FIELD(0x610c8, 1, 3),
>> +       .as_sdp_ct              = REG_FIELD(0x610c8, 4, 7),
>> +       .aif_db4                        = REG_FIELD(0x610c8, 8, 15),
>> +       .frequency              = REG_FIELD(0x610c8, 16, 21),
>> +       .mst_index              = REG_FIELD(0x610c8, 28, 29),
>> +       .dptx_index             = REG_FIELD(0x610c8, 30, 31),
>> +
>> +       .soft_reset             = REG_FIELD(0x1000, 31, 31),
>> +       .force_reset    = REG_FIELD(0x1000, 30, 30),
>> +
>> +       .use_hw_chs             = REG_FIELD(0x61038, 0, 0),
>> +       .use_hw_usr             = REG_FIELD(0x61038, 1, 1),
>> +       .hw_chs_sel             = REG_FIELD(0x61038, 2, 4),
>> +       .hw_usr_sel             = REG_FIELD(0x61038, 5, 6),
>> +
>> +       .replace_vbit   = REG_FIELD(0x610c0, 0, 0),
>> +       .vbit_stream    = REG_FIELD(0x610c0, 1, 1),
>> +
>> +       .legacy_en              =  REG_FIELD(0x1008, 0, 0),
>> +       .calc_en                =  REG_FIELD(0x61034, 0, 0),
>> +       .lsb_bits               =  REG_FIELD(0x61048, 0, 31),
>> +       .msb_bits               =  REG_FIELD(0x6104c, 0, 31),
>> +
>> +       .clk_name               = (const char*[]) {
>> +                                       "pcnoc-sway-clk",
>> +                                       "audio-core",
>> +                                       "pcnoc-mport-clk",
>> +                               },
>> +       .num_clks               = 3,
>> +       .id                     = HDMI_INTERFACE,
>> +       .dai_driver             = sc7180_lpass_cpu_hdmi_dai_driver,
>> +       .num_dai                = ARRAY_SIZE(sc7180_lpass_cpu_hdmi_dai_driver),
>> +       .init                   = sc7180_lpass_init,
>> +       .exit                   = sc7180_lpass_exit,
>> +       .alloc_dma_channel = sc7180_lpass_alloc_hdmi_dma_channel,
>> +       .free_dma_channel = sc7180_lpass_free_hdmi_dma_channel,
>> +
>> +};
> Add a newline here?
okay
>
>>   static const struct of_device_id sc7180_lpass_cpu_device_id[] = {
>>          {.compatible = "qcom,sc7180-lpass-cpu", .data = &sc7180_data},
>> -       {}
>> +       {.compatible = "qcom,sc7180-lpass-hdmi", .data = &sc7180_hdmi_data}
> This most likely needs to keep the sentinel around so that a match can
> be made or stop if nothing is found.
okay..
>
>>   };
>>
diff mbox series

Patch

diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
index 167bf2c..cea7ae7 100644
--- a/sound/soc/qcom/lpass-sc7180.c
+++ b/sound/soc/qcom/lpass-sc7180.c
@@ -62,6 +62,24 @@  static struct snd_soc_dai_driver sc7180_lpass_cpu_dai_driver[] = {
 	},
 };
 
+static struct snd_soc_dai_driver sc7180_lpass_cpu_hdmi_dai_driver[] = {
+	[0] = {
+		.id = HDMI,
+		.name = "Hdmi",
+		.playback = {
+			.stream_name = "Hdmi Playback",
+			.formats	= SNDRV_PCM_FMTBIT_S24_3LE |
+							SNDRV_PCM_FMTBIT_S24_LE,
+			.rates = SNDRV_PCM_RATE_48000,
+			.rate_min	= 48000,
+			.rate_max	= 48000,
+			.channels_min	= 2,
+			.channels_max	= 2,
+		},
+		.ops    = &asoc_qcom_lpass_hdmi_dai_ops,
+	},
+};
+
 static int sc7180_lpass_alloc_dma_channel(struct lpass_data *drvdata,
 					   int direction)
 {
@@ -88,13 +106,37 @@  static int sc7180_lpass_alloc_dma_channel(struct lpass_data *drvdata,
 
 	return chan;
 }
+static int sc7180_lpass_alloc_hdmi_dma_channel(struct lpass_data *drvdata,
+					   int direction)
+{
+	struct lpass_variant *v = drvdata->variant;
+	int chan = 0;
+
+	if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
+		chan = find_first_zero_bit(&drvdata->dma_ch_bit_map,
+					v->rdma_channels);
+
+		if (chan >= v->rdma_channels)
+			return -EBUSY;
+	}
+	set_bit(chan, &drvdata->dma_ch_bit_map);
+
+	return chan;
 
+}
 static int sc7180_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
 {
 	clear_bit(chan, &drvdata->dma_ch_bit_map);
 
 	return 0;
 }
+static int sc7180_lpass_free_hdmi_dma_channel(struct lpass_data *drvdata, int chan)
+{
+	clear_bit(chan, &drvdata->dma_ch_bit_map);
+
+	return 0;
+}
+
 
 static int sc7180_lpass_init(struct platform_device *pdev)
 {
@@ -190,15 +232,92 @@  static struct lpass_variant sc7180_data = {
 				   "mi2s-bit-clk0",
 				   "mi2s-bit-clk1",
 				},
+	.id				= I2S_INTERFACE,
 	.init			= sc7180_lpass_init,
 	.exit			= sc7180_lpass_exit,
 	.alloc_dma_channel	= sc7180_lpass_alloc_dma_channel,
 	.free_dma_channel	= sc7180_lpass_free_dma_channel,
 };
 
+static struct lpass_variant sc7180_hdmi_data = {
+	.hdmi_tx_ctl_addr	= 0x1000,
+	.hdmi_legacy_addr	= 0x1008,
+	.hdmi_vbit_addr		= 0x610c0,
+	.hdmi_ch_lsb_addr	= 0x61048,
+	.hdmi_ch_msb_addr	= 0x6104c,
+	.ch_stride		= 0x8,
+	.hdmi_parity_addr	= 0x61034,
+	.hdmi_dmactl_addr	= 0x61038,
+	.hdmi_dma_stride	= 0x4,
+	.hdmi_DP_addr		= 0x610c8,
+	.hdmi_sstream_addr	= 0x6101c,
+	.irq_reg_base		= 0x63000,
+	.irq_ports		= 1,
+	.rdma_reg_base		= 0x64000,
+	.rdma_reg_stride	= 0x1000,
+	.rdma_channels		= 4,
+
+	.rdma_dyncclk		= REG_FIELD_ID(0x64000, 14, 14, 4, 0x1000),
+	.rdma_bursten		= REG_FIELD_ID(0x64000, 13, 13, 4, 0x1000),
+	.rdma_burst8		= REG_FIELD_ID(0x64000, 15, 15, 4, 0x1000),
+	.rdma_burst16		= REG_FIELD_ID(0x64000, 16, 16, 4, 0x1000),
+	.rdma_dynburst		= REG_FIELD_ID(0x64000, 18, 18, 4, 0x1000),
+	.rdma_wpscnt		= REG_FIELD_ID(0x64000, 10, 12, 4, 0x1000),
+	.rdma_fifowm		= REG_FIELD_ID(0x64000, 1, 5, 4, 0x1000),
+	.rdma_enable		= REG_FIELD_ID(0x64000, 0, 0, 4, 0x1000),
+
+	.sstream_en		= REG_FIELD(0x6101c, 0, 0),
+	.dma_sel			= REG_FIELD(0x6101c, 1, 2),
+	.auto_bbit_en	= REG_FIELD(0x6101c, 3, 3),
+	.layout			= REG_FIELD(0x6101c, 4, 4),
+	.layout_sp		= REG_FIELD(0x6101c, 5, 8),
+	.set_sp_on_en	= REG_FIELD(0x6101c, 10, 10),
+	.dp_audio		= REG_FIELD(0x6101c, 11, 11),
+	.dp_staffing_en	= REG_FIELD(0x6101c, 12, 12),
+	.dp_sp_b_hw_en	= REG_FIELD(0x6101c, 13, 13),
+
+	.mute			= REG_FIELD(0x610c8, 0, 0),
+	.as_sdp_cc		= REG_FIELD(0x610c8, 1, 3),
+	.as_sdp_ct		= REG_FIELD(0x610c8, 4, 7),
+	.aif_db4			= REG_FIELD(0x610c8, 8, 15),
+	.frequency		= REG_FIELD(0x610c8, 16, 21),
+	.mst_index		= REG_FIELD(0x610c8, 28, 29),
+	.dptx_index		= REG_FIELD(0x610c8, 30, 31),
+
+	.soft_reset		= REG_FIELD(0x1000, 31, 31),
+	.force_reset	= REG_FIELD(0x1000, 30, 30),
+
+	.use_hw_chs		= REG_FIELD(0x61038, 0, 0),
+	.use_hw_usr		= REG_FIELD(0x61038, 1, 1),
+	.hw_chs_sel		= REG_FIELD(0x61038, 2, 4),
+	.hw_usr_sel		= REG_FIELD(0x61038, 5, 6),
+
+	.replace_vbit	= REG_FIELD(0x610c0, 0, 0),
+	.vbit_stream	= REG_FIELD(0x610c0, 1, 1),
+
+	.legacy_en		=  REG_FIELD(0x1008, 0, 0),
+	.calc_en		=  REG_FIELD(0x61034, 0, 0),
+	.lsb_bits		=  REG_FIELD(0x61048, 0, 31),
+	.msb_bits		=  REG_FIELD(0x6104c, 0, 31),
+
+	.clk_name		= (const char*[]) {
+					"pcnoc-sway-clk",
+					"audio-core",
+					"pcnoc-mport-clk",
+				},
+	.num_clks		= 3,
+	.id			= HDMI_INTERFACE,
+	.dai_driver		= sc7180_lpass_cpu_hdmi_dai_driver,
+	.num_dai		= ARRAY_SIZE(sc7180_lpass_cpu_hdmi_dai_driver),
+	.init			= sc7180_lpass_init,
+	.exit			= sc7180_lpass_exit,
+	.alloc_dma_channel = sc7180_lpass_alloc_hdmi_dma_channel,
+	.free_dma_channel = sc7180_lpass_free_hdmi_dma_channel,
+
+};
 static const struct of_device_id sc7180_lpass_cpu_device_id[] = {
 	{.compatible = "qcom,sc7180-lpass-cpu", .data = &sc7180_data},
-	{}
+	{.compatible = "qcom,sc7180-lpass-hdmi", .data = &sc7180_hdmi_data}
 };
 
 static struct platform_driver sc7180_lpass_cpu_platform_driver = {