ALSA: compress: Add procfs info file for compressed nodes
Subsystems (3)
v2 cover ALSA: compress: Add procfs info file for compressed nodes
This updates the compress core code to create an 'info' file under procfs for each compressed node, like the PCM core does for PCM nodes.
Based off Takashi's for-next
Richard Fitzgerald (2):
ALSA: compress: Add procfs info file for compressed nodes
ALSA: compress: Pass id string to snd_compress_new
include/sound/compress_driver.h | 7 +++- sound/core/compress_offload.c | 81 ++++++++++++++++++++++++++++++++++++++++- sound/soc/soc-compress.c | 8 +++- 3 files changed, 92 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/2 ALSA: compress: Add procfs info file for compressed nodes
This patch implements a procfs info file for compr nodes when SND_VERBOSE_PROCFS is enabled. This is equivalent to what the PCM core already does for pcm nodes.
--- include/sound/compress_driver.h | 5 +++ sound/core/compress_offload.c | 75 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-)
include/sound/compress_driver.h +5 -0
@@ -152,6 +152,11 @@ struct snd_compr {unsigned int direction;struct mutex lock;int device; +#ifdef CONFIG_SND_VERBOSE_PROCFS +char id[64 ]; +struct snd_info_entry *proc_root; +struct snd_info_entry *proc_info_entry; +#endif };/* compress device register APIs */
sound/core/compress_offload.c +74 -1
104 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 2/2 ALSA: compress: Pass id string to snd_compress_new
In reply to Richard FitzgeraldMake snd_compress_new take an id string (like snd_pcm_new). This string can be included in the procfs info.
This patch also updates soc_new_compress() to create an ID based on the stream and dai name, as done for PCM streams.
--- include/sound/compress_driver.h | 2 +- sound/core/compress_offload.c | 6 +++++- sound/soc/soc-compress.c | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-)
include/sound/compress_driver.h +1 -1
@@ -163,7 +163,7 @@ struct snd_compr {int snd_compress_register (struct snd_compr *device);int snd_compress_deregister (struct snd_compr *device);int snd_compress_new (struct snd_card *card,int device, -int type,struct snd_compr *compr); +int type,const char *id,struct snd_compr *compr);/* dsp driver callback apis * For playback: driver should call snd_compress_fragment_elapsed() to let the
sound/core/compress_offload.c +5 -1
@@ -976,7 +976,7 @@ static int snd_compress_dev_free(struct snd_device *device)* @compr: compress device pointer */ int snd_compress_new (struct snd_card *card,int device, -int dirn,struct snd_compr *compr) +int dirn,const char *id,struct snd_compr *compr) {static struct snd_device_ops ops = { .dev_free = snd_compress_dev_free,
@@ -989,6 +989,10 @@ int snd_compress_new(struct snd_card *card, int device, compr->device = device; compr->direction = dirn; +if (IS_ENABLED (CONFIG_SND_VERBOSE_PROCFS )) +if (id) +strlcpy (compr->id, id,sizeof (compr->id)); +snd_device_initialize (&compr->dev, card);dev_set_name (&compr->dev,"comprC%iD%i" , card->number, device);
sound/soc/soc-compress.c +7 -1
@@ -689,7 +689,13 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) compr->ops->copy = soc_compr_copy;mutex_init (&compr->lock); - ret =snd_compress_new (rtd->card->snd_card, num, direction, compr); + +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, + rtd->codec_dai->name, num); + + ret =snd_compress_new (rtd->card->snd_card, num, direction, + new_name, compr);if (ret <0 ) {pr_err ("compress asoc: can't create compress for codec %s\n" , codec->component.name);
Signature · 1 line
1.9.1
Re: [PATCH v2 2/2] ALSA: compress: Pass id string to snd_compress_new
Quoted 41 lines · Richard Fitzgerald
Make
snd_compress_newtake an id string (likesnd_pcm_new). This string can be included in the procfs info.This patch also updates
soc_new_compress()to create an ID based on the stream and dai name, as done for PCM streams.Signed-off-by Richard Fitzgerald <[email protected]>--- include/sound/compress_driver.h | 2 +- sound/core/compress_offload.c | 6 +++++- sound/soc/soc-compress.c | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-)include/sound/compress_driver.h +1
-1@@ -163,7 +163,7 @@ struct snd_compr {int snd_compress_register (struct snd_compr *device);int snd_compress_deregister (struct snd_compr *device);int snd_compress_new (struct snd_card *card,int device, -int type,struct snd_compr *compr); +int type,const char *id,struct snd_compr *compr);/* dsp driver callback apis * For playback: driver should call snd_compress_fragment_elapsed() to let the sound/core/compress_offload.c +1
-1@@ -976,7 +976,7 @@ static int snd_compress_dev_free(struct snd_device *device)* @compr: compress device pointer */ int snd_compress_new (struct snd_card *card,int device, -int dirn,struct snd_compr *compr) +int dirn,const char *id,struct snd_compr *compr) {static struct snd_device_ops ops = { .dev_free = snd_compress_dev_free,
sound/core/compress_offload.c int snd_compress_new(struct snd_card *card, int device, · line 992
Quoted 4 lines
sound/core/compress_offload.c +1
-0@@ -989,6 +989,10 @@ int snd_compress_new(struct snd_card *card, int device, compr->device = device; compr->direction = dirn; +if (IS_ENABLED (CONFIG_SND_VERBOSE_PROCFS ))
This should be #if. Otherwise the compile would fail (as already kbuild bot spotted).
Takashi
Quoted 29 lines
sound/core/compress_offload.c +3
-0+if (id) +strlcpy (compr->id, id,sizeof (compr->id)); +snd_device_initialize (&compr->dev, card);dev_set_name (&compr->dev,"comprC%iD%i" , card->number, device);sound/soc/soc-compress.c +7
-1@@ -689,7 +689,13 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) compr->ops->copy = soc_compr_copy;mutex_init (&compr->lock); - ret =snd_compress_new (rtd->card->snd_card, num, direction, compr); + +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, + rtd->codec_dai->name, num); + + ret =snd_compress_new (rtd->card->snd_card, num, direction, + new_name, compr);if (ret <0 ) {pr_err ("compress asoc: can't create compress for codec %s\n" , codec->component.name);Signature · 1 line
1.9.1
Re: [PATCH v2 2/2] ALSA: compress: Pass id string to snd_compress_new
Quoted 46 lines · Takashi Iwai
Quoted 44 lines · Richard Fitzgerald
Make
snd_compress_newtake an id string (likesnd_pcm_new). This string can be included in the procfs info.This patch also updates
soc_new_compress()to create an ID based on the stream and dai name, as done for PCM streams.Signed-off-by Richard Fitzgerald <[email protected]>--- include/sound/compress_driver.h | 2 +- sound/core/compress_offload.c | 6 +++++- sound/soc/soc-compress.c | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-)include/sound/compress_driver.h +1
-1@@ -163,7 +163,7 @@ struct snd_compr {int snd_compress_register (struct snd_compr *device);int snd_compress_deregister (struct snd_compr *device);int snd_compress_new (struct snd_card *card,int device, -int type,struct snd_compr *compr); +int type,const char *id,struct snd_compr *compr);/* dsp driver callback apis * For playback: driver should call snd_compress_fragment_elapsed() to let the sound/core/compress_offload.c +1
-1@@ -976,7 +976,7 @@ static int snd_compress_dev_free(struct snd_device *device)* @compr: compress device pointer */ int snd_compress_new (struct snd_card *card,int device, -int dirn,struct snd_compr *compr) +int dirn,const char *id,struct snd_compr *compr) {static struct snd_device_ops ops = { .dev_free = snd_compress_dev_free,@@ -989,6 +989,10 @@ int snd_compress_new(struct snd_card *card, int device, compr->device = device; compr->direction = dirn;
Quoted 8 lines
sound/core/compress_offload.c int snd_compress_new(struct snd_card *card, int device, · line 992
Quoted 1 line
sound/core/compress_offload.c +1
-0+if (IS_ENABLED (CONFIG_SND_VERBOSE_PROCFS ))This should be #if. Otherwise the compile would fail (as already kbuild bot spotted).
Takashi
Builds ok for me, this will become if(false) if it's not enabled so the compiler will strip it out - some maintainers prefer that to #if and I'm used to being told to use this style instead of #if, so who knows what today's coding style is :) The build bot failure was for a different reason.
Anyway, I can change to #if if you prefer that.
Quoted 29 lines
Quoted 29 lines
sound/core/compress_offload.c +3
-0+if (id) +strlcpy (compr->id, id,sizeof (compr->id)); +snd_device_initialize (&compr->dev, card);dev_set_name (&compr->dev,"comprC%iD%i" , card->number, device);sound/soc/soc-compress.c +7
-1@@ -689,7 +689,13 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) compr->ops->copy = soc_compr_copy;mutex_init (&compr->lock); - ret =snd_compress_new (rtd->card->snd_card, num, direction, compr); + +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, + rtd->codec_dai->name, num); + + ret =snd_compress_new (rtd->card->snd_card, num, direction, + new_name, compr);if (ret <0 ) {pr_err ("compress asoc: can't create compress for codec %s\n" , codec->component.name);Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH v2 2/2] ALSA: compress: Pass id string to snd_compress_new
Quoted 11 lines · Richard Fitzgerald
Quoted 3 lines · Takashi Iwai
sound/core/compress_offload.c int snd_compress_new(struct snd_card *card, int device, · line 992
Quoted 1 line
sound/core/compress_offload.c +1
-0+if (IS_ENABLED (CONFIG_SND_VERBOSE_PROCFS ))This should be #if. Otherwise the compile would fail (as already
Builds ok for me, this will become if(false) if it's not enabled so the compiler will strip it out - some maintainers prefer that to #if and I'm used to being told to use this style instead of #if, so who knows what today's coding style is :) The build bot failure was for a different reason.
The compiler will still spot syntax errors and similar in an if (false) section.
Re: [PATCH v2 2/2] ALSA: compress: Pass id string to snd_compress_new
In reply to Richard FitzgeraldQuoted 54 lines · Richard Fitzgerald
Quoted 52 lines · Takashi Iwai
Quoted 41 lines · Richard Fitzgerald
Make
snd_compress_newtake an id string (likesnd_pcm_new). This string can be included in the procfs info.This patch also updates
soc_new_compress()to create an ID based on the stream and dai name, as done for PCM streams.Signed-off-by Richard Fitzgerald <[email protected]>--- include/sound/compress_driver.h | 2 +- sound/core/compress_offload.c | 6 +++++- sound/soc/soc-compress.c | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-)include/sound/compress_driver.h +1
-1@@ -163,7 +163,7 @@ struct snd_compr {int snd_compress_register (struct snd_compr *device);int snd_compress_deregister (struct snd_compr *device);int snd_compress_new (struct snd_card *card,int device, -int type,struct snd_compr *compr); +int type,const char *id,struct snd_compr *compr);/* dsp driver callback apis * For playback: driver should call snd_compress_fragment_elapsed() to let the sound/core/compress_offload.c +1
-1@@ -976,7 +976,7 @@ static int snd_compress_dev_free(struct snd_device *device)* @compr: compress device pointer */ int snd_compress_new (struct snd_card *card,int device, -int dirn,struct snd_compr *compr) +int dirn,const char *id,struct snd_compr *compr) {static struct snd_device_ops ops = { .dev_free = snd_compress_dev_free,sound/core/compress_offload.c int snd_compress_new(struct snd_card *card, int device, · line 992
Quoted 4 lines
sound/core/compress_offload.c +1
-0@@ -989,6 +989,10 @@ int snd_compress_new(struct snd_card *card, int device, compr->device = device; compr->direction = dirn; +if (IS_ENABLED (CONFIG_SND_VERBOSE_PROCFS ))This should be #if. Otherwise the compile would fail (as already kbuild bot spotted).
Quoted 5 lines
Quoted 2 lines
Takashi
Builds ok for me, this will become if(false) if it's not enabled so the compiler will strip it out
It will be dropped, but the code is still parsed by the compiler, thus it shall fail. It's the difference from the preprocessor and the normal if block.
Quoted 4 lines
- some maintainers prefer that to #if and I'm
used to being told to use this style instead of #if, so who knows what today's coding style is :) The build bot failure was for a different reason.
Depends. For a case like this, where the access itself becoming invalid, we must not make the code path parsed. Instead, it has to be disabled by preprocessor.
OTOH, having a disabled if block often helps to avoid the compile warnings for unused variables or functions. So it's case-by-case.
Takashi
Quoted 34 lines
Anyway, I can change to #if if you prefer that.
Quoted 29 lines
Quoted 29 lines
sound/core/compress_offload.c +3
-0+if (id) +strlcpy (compr->id, id,sizeof (compr->id)); +snd_device_initialize (&compr->dev, card);dev_set_name (&compr->dev,"comprC%iD%i" , card->number, device);sound/soc/soc-compress.c +7
-1@@ -689,7 +689,13 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) compr->ops->copy = soc_compr_copy;mutex_init (&compr->lock); - ret =snd_compress_new (rtd->card->snd_card, num, direction, compr); + +snprintf (new_name,sizeof (new_name),"%s %s-%d" , + rtd->dai_link->stream_name, + rtd->codec_dai->name, num); + + ret =snd_compress_new (rtd->card->snd_card, num, direction, + new_name, compr);if (ret <0 ) {pr_err ("compress asoc: can't create compress for codec %s\n" , codec->component.name);Signature · 1 line
1.9.1