diff mbox

[v4,08/13] ASoC: Add SoundWire stream programming interface

Message ID 1524049146-8725-9-git-send-email-vinod.koul@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vinod Koul April 18, 2018, 10:59 a.m. UTC
From: Shreyas NC <shreyas.nc@intel.com>

SoundWire stream needs to be propagated to all the DAIs(cpu, codec).
So, add a snd_soc_dai_set_sdw_stream() API for the same.

Signed-off-by: Shreyas NC <shreyas.nc@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 include/sound/soc-dai.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Pierre-Louis Bossart April 21, 2018, 1:59 p.m. UTC | #1
> +/**
> + * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
> + * @dai: DAI
> + * @stream: STREAM
> + * @direction: Stream direction(Playback/Capture)
> + * SoundWire subsystem doesn't have a notion of direction and we reuse
> + * the ASoC stream direction to configure sink/source ports.
> + * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.

this is just confusing...

This should be something like
"use Playback for source ports and Capture for sink ports".
Vinod Koul April 21, 2018, 3:58 p.m. UTC | #2
On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
> 
> >+/**
> >+ * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
> >+ * @dai: DAI
> >+ * @stream: STREAM
> >+ * @direction: Stream direction(Playback/Capture)
> >+ * SoundWire subsystem doesn't have a notion of direction and we reuse
> >+ * the ASoC stream direction to configure sink/source ports.
> >+ * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
> 
> this is just confusing...
> 
> This should be something like
> "use Playback for source ports and Capture for sink ports".

Source port on ...? This is also confusing to me!

For playback there are two ports, one on transmitter aka
TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
ports. I should probably add port to make people really figure out we are
talking about ports!

So:

Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.

Do you agree to above statement?
Pierre-Louis Bossart April 23, 2018, 1:33 p.m. UTC | #3
On 4/21/18 10:58 AM, Vinod Koul wrote:
> On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
>>
>>> +/**
>>> + * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
>>> + * @dai: DAI
>>> + * @stream: STREAM
>>> + * @direction: Stream direction(Playback/Capture)
>>> + * SoundWire subsystem doesn't have a notion of direction and we reuse
>>> + * the ASoC stream direction to configure sink/source ports.
>>> + * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
>>
>> this is just confusing...
>>
>> This should be something like
>> "use Playback for source ports and Capture for sink ports".
> 
> Source port on ...? This is also confusing to me!
> 
> For playback there are two ports, one on transmitter aka
> TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
> ports. I should probably add port to make people really figure out we are
> talking about ports!
> 
> So:
> 
> Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.
> 
> Do you agree to above statement?

No. Source port and TX are redundant definitions, and your wording isn't 
clear: is the PLAYBACK/CAPTURE qualifier for the stream or the DAI used 
by the stream?
Vinod Koul April 24, 2018, 9:06 a.m. UTC | #4
On Mon, Apr 23, 2018 at 08:33:08AM -0500, Pierre-Louis Bossart wrote:
> On 4/21/18 10:58 AM, Vinod Koul wrote:
> >On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
> >>
> >>>+/**
> >>>+ * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
> >>>+ * @dai: DAI
> >>>+ * @stream: STREAM
> >>>+ * @direction: Stream direction(Playback/Capture)
> >>>+ * SoundWire subsystem doesn't have a notion of direction and we reuse
> >>>+ * the ASoC stream direction to configure sink/source ports.
> >>>+ * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
> >>
> >>this is just confusing...
> >>
> >>This should be something like
> >>"use Playback for source ports and Capture for sink ports".
> >
> >Source port on ...? This is also confusing to me!
> >
> >For playback there are two ports, one on transmitter aka
> >TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
> >ports. I should probably add port to make people really figure out we are
> >talking about ports!
> >
> >So:
> >
> >Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.
> >
> >Do you agree to above statement?
> 
> No. Source port and TX are redundant definitions, and your wording isn't
> clear: is the PLAYBACK/CAPTURE qualifier for the stream or the DAI used by
> the stream?

Yes they are redundant, will update. PLAYBACK/CAPTURE qualifier is for stream.
Pierre-Louis Bossart April 24, 2018, 11:40 p.m. UTC | #5
On 4/24/18 4:06 AM, Vinod Koul wrote:
> On Mon, Apr 23, 2018 at 08:33:08AM -0500, Pierre-Louis Bossart wrote:
>> On 4/21/18 10:58 AM, Vinod Koul wrote:
>>> On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
>>>>
>>>>> +/**
>>>>> + * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
>>>>> + * @dai: DAI
>>>>> + * @stream: STREAM
>>>>> + * @direction: Stream direction(Playback/Capture)
>>>>> + * SoundWire subsystem doesn't have a notion of direction and we reuse
>>>>> + * the ASoC stream direction to configure sink/source ports.
>>>>> + * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
>>>>
>>>> this is just confusing...
>>>>
>>>> This should be something like
>>>> "use Playback for source ports and Capture for sink ports".
>>>
>>> Source port on ...? This is also confusing to me!
>>>
>>> For playback there are two ports, one on transmitter aka
>>> TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
>>> ports. I should probably add port to make people really figure out we are
>>> talking about ports!
>>>
>>> So:
>>>
>>> Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.
>>>
>>> Do you agree to above statement?
>>
>> No. Source port and TX are redundant definitions, and your wording isn't
>> clear: is the PLAYBACK/CAPTURE qualifier for the stream or the DAI used by
>> the stream?
> 
> Yes they are redundant, will update. PLAYBACK/CAPTURE qualifier is for stream.

Let me try again.
let's say in point-to-point mode you have dai1 as the source and dai2 as 
the sink.

Which sequence are the higher layers supposed to use:

a.

snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
snd_soc_dai_set_sdw_stream(dai2, stream, PLAYBACK);

b.

snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
snd_soc_dai_set_sdw_stream(dai2, stream, CAPTURE);
Vinod Koul April 25, 2018, 2:49 a.m. UTC | #6
On Tue, Apr 24, 2018 at 06:40:54PM -0500, Pierre-Louis Bossart wrote:
> On 4/24/18 4:06 AM, Vinod Koul wrote:
> >On Mon, Apr 23, 2018 at 08:33:08AM -0500, Pierre-Louis Bossart wrote:
> >>On 4/21/18 10:58 AM, Vinod Koul wrote:
> >>>On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
> >>>>
> >>>>>+/**
> >>>>>+ * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
> >>>>>+ * @dai: DAI
> >>>>>+ * @stream: STREAM
> >>>>>+ * @direction: Stream direction(Playback/Capture)
> >>>>>+ * SoundWire subsystem doesn't have a notion of direction and we reuse
> >>>>>+ * the ASoC stream direction to configure sink/source ports.
> >>>>>+ * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
> >>>>
> >>>>this is just confusing...
> >>>>
> >>>>This should be something like
> >>>>"use Playback for source ports and Capture for sink ports".
> >>>
> >>>Source port on ...? This is also confusing to me!
> >>>
> >>>For playback there are two ports, one on transmitter aka
> >>>TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
> >>>ports. I should probably add port to make people really figure out we are
> >>>talking about ports!
> >>>
> >>>So:
> >>>
> >>>Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.
> >>>
> >>>Do you agree to above statement?
> >>
> >>No. Source port and TX are redundant definitions, and your wording isn't
> >>clear: is the PLAYBACK/CAPTURE qualifier for the stream or the DAI used by
> >>the stream?
> >
> >Yes they are redundant, will update. PLAYBACK/CAPTURE qualifier is for stream.
> 
> Let me try again.
> let's say in point-to-point mode you have dai1 as the source and dai2 as the
> sink.
> 
> Which sequence are the higher layers supposed to use:
> 
> a.
> 
> snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
> snd_soc_dai_set_sdw_stream(dai2, stream, PLAYBACK);
> 
> b.
> 
> snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
> snd_soc_dai_set_sdw_stream(dai2, stream, CAPTURE);

I believe this.
Pierre-Louis Bossart April 25, 2018, 3:08 p.m. UTC | #7
On 4/24/18 9:49 PM, Vinod Koul wrote:
> On Tue, Apr 24, 2018 at 06:40:54PM -0500, Pierre-Louis Bossart wrote:
>> On 4/24/18 4:06 AM, Vinod Koul wrote:
>>> On Mon, Apr 23, 2018 at 08:33:08AM -0500, Pierre-Louis Bossart wrote:
>>>> On 4/21/18 10:58 AM, Vinod Koul wrote:
>>>>> On Sat, Apr 21, 2018 at 06:59:49AM -0700, Pierre-Louis Bossart wrote:
>>>>>>
>>>>>>> +/**
>>>>>>> + * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
>>>>>>> + * @dai: DAI
>>>>>>> + * @stream: STREAM
>>>>>>> + * @direction: Stream direction(Playback/Capture)
>>>>>>> + * SoundWire subsystem doesn't have a notion of direction and we reuse
>>>>>>> + * the ASoC stream direction to configure sink/source ports.
>>>>>>> + * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
>>>>>>
>>>>>> this is just confusing...
>>>>>>
>>>>>> This should be something like
>>>>>> "use Playback for source ports and Capture for sink ports".
>>>>>
>>>>> Source port on ...? This is also confusing to me!
>>>>>
>>>>> For playback there are two ports, one on transmitter aka
>>>>> TX and one on receiver aka RX. For Tx we use source port, and Rx uses sink
>>>>> ports. I should probably add port to make people really figure out we are
>>>>> talking about ports!
>>>>>
>>>>> So:
>>>>>
>>>>> Playback maps to source port on the TX and sink port on Rx. Vice-versa for Capture.
>>>>>
>>>>> Do you agree to above statement?
>>>>
>>>> No. Source port and TX are redundant definitions, and your wording isn't
>>>> clear: is the PLAYBACK/CAPTURE qualifier for the stream or the DAI used by
>>>> the stream?
>>>
>>> Yes they are redundant, will update. PLAYBACK/CAPTURE qualifier is for stream.
>>
>> Let me try again.
>> let's say in point-to-point mode you have dai1 as the source and dai2 as the
>> sink.
>>
>> Which sequence are the higher layers supposed to use:
>>
>> a.
>>
>> snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
>> snd_soc_dai_set_sdw_stream(dai2, stream, PLAYBACK);
>>
>> b.
>>
>> snd_soc_dai_set_sdw_stream(dai1, stream, PLAYBACK);
>> snd_soc_dai_set_sdw_stream(dai2, stream, CAPTURE);
> 
> I believe this.

For clarity, did you mean b) ?
If yes, Playback == Source and Capture == sink.
diff mbox

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 8ad11669e4d8..e654427b6885 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -170,6 +170,8 @@  struct snd_soc_dai_ops {
 		unsigned int rx_num, unsigned int *rx_slot);
 	int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
 
+	int (*set_sdw_stream)(struct snd_soc_dai *dai,
+			void *stream, int direction);
 	/*
 	 * DAI digital mute - optional.
 	 * Called by soc-core to minimise any pops.
@@ -358,4 +360,25 @@  static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai)
 	return dev_get_drvdata(dai->dev);
 }
 
+/**
+ * snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
+ * @dai: DAI
+ * @stream: STREAM
+ * @direction: Stream direction(Playback/Capture)
+ * SoundWire subsystem doesn't have a notion of direction and we reuse
+ * the ASoC stream direction to configure sink/source ports.
+ * Playback maps to source on the TX and sink on Rx. Vice-versa for Capture.
+ *
+ * This should be invoked with NULL to clear the stream set previously.
+ * Returns 0 on success, a negative error code otherwise.
+ */
+static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,
+				void *stream, int direction)
+{
+	if (dai->driver->ops->set_sdw_stream)
+		return dai->driver->ops->set_sdw_stream(dai, stream, direction);
+	else
+		return -ENOTSUPP;
+}
+
 #endif