ASoC: Allow mulitple usage of codec and cpu dai
RFC 1/1 ASoC: Allow mulitple usage of codec and cpu dai
We can have a snd_soc_dai i.e, cpu_dai and codec_dai, shared among two or more dai_links by avoiding shutting-down/powering-up if the dai is already in an appropriate state.
For that, we change semantics of the snd_soc_dai.active flag from indicator to reference counter.
This patch only attempts to block duplicate startup/shutdown and the mute callbacks, presuming currently no dai driver anticipates 'dai reuse'.
--- include/sound/soc.h | 2 +- sound/soc/soc-core.c | 47 ++++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 20 deletions(-)
The codec->active can also be deducted by codec_dai->capture/playback.active So, we can get rid of snd_soc_codec.active field as well to reduce number of variables we have to manage in future while making delicate changes in ASoC.
include/sound/soc.h +1 -1
@@ -375,7 +375,7 @@ struct snd_soc_pcm_stream {unsigned int rate_max;/* max rate */ unsigned int channels_min;/* min channels */ unsigned int channels_max;/* max channels */ - unsigned int active:1; /* stream is in use */ +unsigned int active;/* num of active users of the stream */ };/* SoC audio ops */
sound/soc/soc-core.c +28 -19
93 lines not on this page · raw message
Signature · 1 line
1.6.2.5
sound/soc/soc-core.c static int soc_pcm_open(struct snd_pcm_substream *substream) · line 355
Quoted 3 lines · Jassi Brar
sound/soc/soc-core.c +1
-1/* startup the audio subsystem */ -if (cpu_dai->ops->startup) { +if (cpu_dai->active ==0 && cpu_dai->ops->startup) {
I thought I'd been fairly clear last time that the drivers need to have an option to do stuff on startup(). As I said then a separate callback which is called only on the transitions into and out of active would be fine.
Quoted 10 lines · Mark Brown
Quoted 3 lines · Jassi Brar
/* startup the audio subsystem */
- if (cpu_dai->ops->startup) {
+ if (cpu_dai->active== 0 &&cpu_dai->ops->startup) {I thought I'd been fairly clear last time that the drivers need to have an option to do stuff on
startup(). As I said then a separate callback which is called only on the transitions into and out of active would be fine.
This is simply the patch, that you asked me to dig out from samsung-git and post to the list, adapted to for-2.6.35
I could drop startup,shutdown,mute-on/off as well, but no codec driver would work with that as such. If that's ok, i'll resend the patch.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 9 lines · jassi brar
On Thu, Feb 25, 2010 at 7:03 PM, Mark Brown
Quoted 4 lines
I thought I'd been fairly clear last time that the drivers need to have an option to do stuff on
startup(). As I said then a separate callback which is called only on the transitions into and out of active would be fine.This is simply the patch, that you asked me to dig out from samsung-git and post to the list, adapted to for-2.6.35
I asked you to pull out the bits that maintain active.
Quoted 2 lines
I could drop startup,shutdown,mute-on/off as well, but no codec driver would work with that as such. If that's ok, i'll resend the patch.
Honestly I didn't read the rest of the patch after I saw the change to remove the startup() callback. Clearly fiddling around with the active count isn't going to make every possible system work, and it may not be any use at all, but so long as it doesn't interfere with other users it's not really a problem.
As I said previously this should really be being done by showing the mixer as a device within ASoC rather than this way. Trying to pretend the mixer isn't there is going to cause problems, the confusion about when the stream is live being just one of them.
Quoted 8 lines · Mark Brown
Quoted 6 lines · jassi brar
On Thu, Feb 25, 2010 at 7:03 PM, Mark Brown
Quoted 4 lines
I thought I'd been fairly clear last time that the drivers need to have an option to do stuff on
startup(). As I said then a separate callback which is called only on the transitions into and out of active would be fine.
Quoted 4 lines
Quoted 2 lines
This is simply the patch, that you asked me to dig out from samsung-git and post to the list, adapted to for-2.6.35
I asked you to pull out the bits that maintain active.
hmm... i misread ur reply. Just submitted refreshed patch for just that.
Quoted 8 lines
Quoted 2 lines
I could drop startup,shutdown,mute-on/off as well, but no codec driver would work with that as such. If that's ok, i'll resend the patch.
Honestly I didn't read the rest of the patch after I saw the change to remove the
startup()callback. Clearly fiddling around with the active count isn't going to make every possible system work, and it may not be any use at all, but so long as it doesn't interfere with other users it's not really a problem.
Also, I think we should look into if we can do without snd_soc_codec.active when we have snd_soc_dai.playback/capture.active counters.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 2 lines · jassi brar
Also, I think we should look into if we can do without snd_soc_codec.active when we have snd_soc_dai.playback/capture.active counters.
Yes, the CODEC active counter has been pretty redundant for a long time since the mute is a DAI-specific operation and all the CODEC active counter is used for is muting on free. I believe it's a hangover from pre-DAPM days.