diff mbox series

[v2,3/5] ASoC: core: add support to snd_soc_dai_get_sdw_stream()

Message ID 20190813083550.5877-4-srinivas.kandagatla@linaro.org
State New
Headers show
Series None | expand

Commit Message

Srinivas Kandagatla Aug. 13, 2019, 8:35 a.m. UTC
On platforms which have smart speaker amplifiers connected via
soundwire and modeled as aux devices in ASoC, in such usecases machine
driver should be able to get sdw master stream from dai so that it can
use the runtime stream to setup slave streams.

soundwire already as a set function, get function would provide more
flexibility to above configurations.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

---
 include/sound/soc-dai.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.21.0

Comments

Pierre-Louis Bossart Aug. 13, 2019, 2:44 p.m. UTC | #1
On 8/13/19 3:35 AM, Srinivas Kandagatla wrote:
> On platforms which have smart speaker amplifiers connected via

> soundwire and modeled as aux devices in ASoC, in such usecases machine

> driver should be able to get sdw master stream from dai so that it can

> use the runtime stream to setup slave streams.


using the _set_sdw_stream? I don't fully get the sequence with the 
wording above.

> 

> soundwire already as a set function, get function would provide more

> flexibility to above configurations.


I am not clear if you are asking for both to be used, or get only or set 
only?

> 

> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

> ---

>   include/sound/soc-dai.h | 10 ++++++++++

>   1 file changed, 10 insertions(+)

> 

> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h

> index dc48fe081a20..1e01f4a302e0 100644

> --- a/include/sound/soc-dai.h

> +++ b/include/sound/soc-dai.h

> @@ -202,6 +202,7 @@ struct snd_soc_dai_ops {

>   

>   	int (*set_sdw_stream)(struct snd_soc_dai *dai,

>   			void *stream, int direction);

> +	void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);

>   	/*

>   	 * DAI digital mute - optional.

>   	 * Called by soc-core to minimise any pops.

> @@ -410,4 +411,13 @@ static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,

>   		return -ENOTSUPP;

>   }

>   

> +static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,

> +					       int direction)

> +{

> +	if (dai->driver->ops->get_sdw_stream)

> +		return dai->driver->ops->get_sdw_stream(dai, direction);

> +	else

> +		return ERR_PTR(-ENOTSUPP);

> +}

> +

>   #endif

>
Srinivas Kandagatla Aug. 13, 2019, 4:50 p.m. UTC | #2
Thanks for the review,

On 13/08/2019 15:44, Pierre-Louis Bossart wrote:
> On 8/13/19 3:35 AM, Srinivas Kandagatla wrote:

>> On platforms which have smart speaker amplifiers connected via

>> soundwire and modeled as aux devices in ASoC, in such usecases machine

>> driver should be able to get sdw master stream from dai so that it can

>> use the runtime stream to setup slave streams.

> 

> using the _set_sdw_stream? I don't fully get the sequence with the 

> wording above.


Yes, using set_sdw_stream().

> 

>>

>> soundwire already as a set function, get function would provide more

>> flexibility to above configurations.

> 

> I am not clear if you are asking for both to be used, or get only or set 

> only?


It depends on the usecase, in db845c usecase  [1] as Aux device is dai 
less, machine driver is using get function to get hold of master stream 
so that it can setup slave port config.


Looks like there is a typo in above like

This was supposed to be "soundwire already has a set function, get 
function would provide more flexibility to above configurations"

[1] 
https://git.linaro.org/landing-teams/working/qualcomm/kernel.git/tree/sound/soc/qcom/db845c.c?h=integration-linux-qcomlt

thanks,
srini

> 

>>

>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

>> ---

>>   include/sound/soc-dai.h | 10 ++++++++++

>>   1 file changed, 10 insertions(+)

>>

>> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h

>> index dc48fe081a20..1e01f4a302e0 100644

>> --- a/include/sound/soc-dai.h

>> +++ b/include/sound/soc-dai.h

>> @@ -202,6 +202,7 @@ struct snd_soc_dai_ops {

>>       int (*set_sdw_stream)(struct snd_soc_dai *dai,

>>               void *stream, int direction);

>> +    void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);

>>       /*

>>        * DAI digital mute - optional.

>>        * Called by soc-core to minimise any pops.

>> @@ -410,4 +411,13 @@ static inline int 

>> snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,

>>           return -ENOTSUPP;

>>   }

>> +static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,

>> +                           int direction)

>> +{

>> +    if (dai->driver->ops->get_sdw_stream)

>> +        return dai->driver->ops->get_sdw_stream(dai, direction);

>> +    else

>> +        return ERR_PTR(-ENOTSUPP);

>> +}

>> +

>>   #endif

>>

>
Mark Brown Aug. 13, 2019, 7:18 p.m. UTC | #3
On Tue, Aug 13, 2019 at 02:15:18PM -0500, Pierre-Louis Bossart wrote:
> On 8/13/19 1:06 PM, Srinivas Kandagatla wrote:


> > sorry for the confusion. It was too quick reply. :-)

> > I was suppose to say sdw_stream_add_slave() instead of set_sdw_stream().


> ok, so get_sdw_stream() and set_sdw_stream() are not meant to be mirrors or

> both implemented. It's just a helper to respectively get a context or set a

> context but a get-modify-set type of operation is not expected.


> Do I get this right?


This seems like it's going to be confusing...
Mark Brown Aug. 13, 2019, 7:19 p.m. UTC | #4
On Tue, Aug 13, 2019 at 07:29:50PM +0200, Cezary Rojewski wrote:
> On 2019-08-13 18:52, Srinivas Kandagatla wrote:

> > On 13/08/2019 17:03, Cezary Rojewski wrote:

> > > On 2019-08-13 10:35, Srinivas Kandagatla wrote:


> > > > +    if (dai->driver->ops->get_sdw_stream)

> > > > +        return dai->driver->ops->get_sdw_stream(dai, direction);

> > > > +    else

> > > > +        return ERR_PTR(-ENOTSUPP);


> > > Drop redundant else.


> > Not all the dai drivers would implement this function, I guess else is

> > not redundant here!


> Eh. By that I meant dropping "else" keyword and reducing indentation for

> "return ERR_PTR(-ENOTSUPP);"


The above is the idiom used throughout the rest of the file.
Charles Keepax Oct. 10, 2019, 12:03 p.m. UTC | #5
On Thu, Oct 10, 2019 at 09:50:22AM +0100, Srinivas Kandagatla wrote:
> On 09/10/2019 19:53, Pierre-Louis Bossart wrote:

> >On 10/9/19 11:01 AM, Srinivas Kandagatla wrote:

> >>On 09/10/2019 15:29, Pierre-Louis Bossart wrote:

> >>>On 10/9/19 3:32 AM, Srinivas Kandagatla wrote:

> >>>>On 14/08/2019 15:09, Pierre-Louis Bossart wrote:

> >>>>>On 8/13/19 11:11 PM, Vinod Koul wrote:

> >>>>>>On 13-08-19, 20:58, Mark Brown wrote:

> >>>>>>>On Tue, Aug 13, 2019 at 02:38:53PM -0500, Pierre-Louis

> >>>>>>>>Indeed. I don't have a full understanding of that

> >>>>>>>>part to be honest, nor why

> >>>>>>>>we need something SoundWire-specific. We already

> >>>>>>>>abused the set_tdm_slot API

> >>>>>>>>to store an HDaudio stream, now we have a rather confusing stream

> >>>>>>>>information for SoundWire and I have about 3 other

> >>>>>>>>'stream' contexts in

> >>>>>>>>SOF... I am still doing basic cleanups but this has

> >>>>>>>>been on my radar for a

> >>>>>>>>while.

> >>>>>>>

> >>>>>>>There is something to be said for not abusing the TDM

> >>>>>>>slot API if it can

> >>>>>>>make things clearer by using bus-idiomatic mechanisms,

> >>>>>>>but it does mean

> >>>>>>>everything needs to know about each individual bus :/ .

> >>>>>>

> >>>>>>Here ASoC doesn't need to know about sdw bus. As Srini

> >>>>>>explained, this

> >>>>>>helps in the case for him to get the stream context and

> >>>>>>set the stream

> >>>>>>context from the machine driver.

> >>>>>>

> >>>>>>Nothing else is expected to be done from this API. We

> >>>>>>already do a set

> >>>>>>using snd_soc_dai_set_sdw_stream(). Here we add the

> >>>>>>snd_soc_dai_get_sdw_stream() to query

> >>>>>

> >>>>>I didn't see a call to snd_soc_dai_set_sdw_stream() in Srini's code?

> >>>>

> >>>>

> >>>>There is a snd_soc_dai_get_sdw_stream() to get stream

> >>>>context and we add slave streams(amplifier in this case) to

> >>>>that context using sdw_stream_add_slave() in machine

> >>>>driver[1].

> >>>>

> >>>>Without this helper there is no way to link slave streams to

> >>>>stream context in non dai based setup like smart speaker

> >>>>amplifiers.

> >>>>

> >>>>Currently this driver is blocked on this patch, If you think

> >>>>there are other ways to do this, am happy to try them out.

> >>>

> >>>So to be clear, you are *not* using snd_soc_dai_set_sdw_stream?

> >>Yes, am not using snd_soc_dai_set_sdw_stream().

> >

> >It's been a while since this thread started, and I still don't

> >quite get the concepts or logic.

> >

> >First, I don't understand what the problem with "aux" devices is.

> >All the SoundWire stuff is based on the concept of DAI, so I guess

> >I am

> 

> That is the actual problem! Some aux devices does not have dais.

> 


Usually aux devices are used for things like analog amplifiers that
clearly don't have a digital interface, thus it really makes no sense
to have a DAI link connecting them. So I guess my question here
would be what is the thinking on making the "smart amplifier" dailess?
It feels like having a CODEC to CODEC DAI between the CODEC and
the AMP would be a more obvious way to connect the two devices
and would presumably avoid the issues being discussed around the
patch.

Thanks,
Charles
Mark Brown Oct. 10, 2019, 1:51 p.m. UTC | #6
On Thu, Oct 10, 2019 at 12:03:37PM +0000, Charles Keepax wrote:

> Usually aux devices are used for things like analog amplifiers that

> clearly don't have a digital interface, thus it really makes no sense

> to have a DAI link connecting them. So I guess my question here

> would be what is the thinking on making the "smart amplifier" dailess?

> It feels like having a CODEC to CODEC DAI between the CODEC and

> the AMP would be a more obvious way to connect the two devices

> and would presumably avoid the issues being discussed around the

> patch.


Or is this a device where for some reason (consistency?) there
really is no DAI and someone has decided to make an analogue
amplifier with a soundwire control interface?
diff mbox series

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index dc48fe081a20..1e01f4a302e0 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -202,6 +202,7 @@  struct snd_soc_dai_ops {
 
 	int (*set_sdw_stream)(struct snd_soc_dai *dai,
 			void *stream, int direction);
+	void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);
 	/*
 	 * DAI digital mute - optional.
 	 * Called by soc-core to minimise any pops.
@@ -410,4 +411,13 @@  static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,
 		return -ENOTSUPP;
 }
 
+static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,
+					       int direction)
+{
+	if (dai->driver->ops->get_sdw_stream)
+		return dai->driver->ops->get_sdw_stream(dai, direction);
+	else
+		return ERR_PTR(-ENOTSUPP);
+}
+
 #endif