ASoC: Add core API to register and cleanup DMI names for card
Subsystems (3)
v7 cover ASoC: Add core API to register and cleanup DMI names for card
From: "Lu, Han" <[email protected]>
Share more product information, for user space utils such as PA and UCM to distinguish different products.
1. Add core APIs to register and cleanup DMI names for card.
2. Apply the APIs to bytcr-rt5640 driver.
changes on V7:
1. Remove inconsistent API description
changes on V6:
1. Use dynamic allocate and cleanup for card long name
2. Remove unneccessary arguments to simplify the API
changes on V5:
1. Use independent space to store card long_name, to avoid irrelavant info sharing from card component
2. Use letter ';' instead of ':' to separate strings in long name, in case name strings may also contain ':' and confuse user
3. Fix error that vendor name and firmware name were not optional
changes on V4:
1. Replace kmalloc() and snprintf() with ksaprintf() to simplify code
changes on V3:
1. Split the core API and the API call to two patches
2. Replace misused strcat() with snprintf()
3. Code and comment fix
Lu, Han (2):
ASoC: core: add API for registering and cleaning up DMI card names
ASoC: bytcr-rt5640: register DMI names for card
include/sound/soc.h | 3 ++ sound/soc/intel/boards/bytcr_rt5640.c | 18 ++++++++ sound/soc/soc-core.c | 85 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)
Signature · 1 line
2.5.0
PATCH v7 1/2 ASoC: core: add API for registering and cleaning up DMI card names
From: "Lu, Han" <[email protected]>
Add core API for registering and cleaning up DMI card names, so user space utils such as PA and UCM can distinguish various products. Previously on ASoC, the card short name, driver name and long name were all the same as the machine driver name.
The patch adds more board information:
card driver name ---> machine driver name card short name ---> DMI_BOARD_NAME or DMI_PRODUCT_NAME
card long name and
card component ---> short name;driver name;(DMI_SYS_VENDOR,
optional);(the firmware name, optional)
include/sound/soc.h +3 -0
@@ -486,6 +486,9 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);int snd_soc_runtime_set_dai_fmt (struct snd_soc_pcm_runtime *rtd,unsigned int dai_fmt); +int snd_soc_set_card_names (struct snd_soc_card *card,const char *firmware); +void snd_soc_cleanup_card_names (struct snd_soc_card *card); +/* Utility functions to get clock rates from various things */ int snd_soc_calc_frame_size (int sample_size,int channels,int tdm_slots);int snd_soc_params_to_frame_size (struct snd_pcm_hw_params *params);
sound/soc/soc-core.c +85 -0
97 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v7 2/2 ASoC: bytcr-rt5640: register DMI names for card
In reply to [email protected]From: "Lu, Han" <[email protected]>
Register DMI names for products using bytcr-rt5640 driver, such as ASUS T100TA and Dell Venue 8 Pro 5830, for user space utils to distinguish different products.
For example, previously on T100TA:
$ cat /proc/asound/cards
0 [bytcrrt5640 ]: bytcr-rt5640 - bytcr-rt5640
bytcr-rt5640
$ amixer -c0 info
Card hw:0 'bytcrrt5640'/'bytcr-rt5640'
Mixer name : ''
Components : ''
Controls : 256
Simple ctrls : 228After apply the patch:
$ cat /proc/asound/cards
0 [T100TA ]: bytcr-rt5640 - T100TA
T100TA;bytcr-rt5640;ASUSTek COMPUTER INC.;intel/fw_
sst_0f28.bin
$ amixer -c0 info
Card hw:0 'T100TA'/'T100TA;bytcr-rt5640;ASUSTek COMPUTER INC.;intel/fw_
sst_0f28.bin'
Mixer name : ''
Components : 'T100TA;bytcr-rt5640;ASUSTek COMPUTER INC.;intel/fw_s
st_0f28.bin'
Controls : 256
Simple ctrls : 228sound/soc/intel/boards/bytcr_rt5640.c +18 -0
@@ -152,6 +152,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { {} }; +static struct snd_soc_card byt_rt5640_card; +static int byt_rt5640_init (struct snd_soc_pcm_runtime *runtime) {int ret;
@@ -159,6 +161,13 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)struct snd_soc_card *card = runtime->card;const struct snd_soc_dapm_route *custom_map;int num_routes; +struct sst_acpi_mach *mach = byt_rt5640_card.dev->platform_data; + + ret =snd_soc_set_card_names (card, mach->fw_filename); +if (ret <0 ) { +dev_err (card->dev,"unable to register card names\n" ); +return ret; + } card->dapm.idle_bias_off = true;
@@ -380,12 +389,21 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)return ret_val; } +static int snd_byt_rt5640_mc_remove (struct platform_device *pdev) +{ +struct snd_soc_card *card = &byt_rt5640_card; + +snd_soc_cleanup_card_names (card); +return 0 ; +} +static struct platform_driver snd_byt_rt5640_mc_driver = { .driver = { .name ="bytcr_rt5640" , .pm = &snd_soc_pm_ops, }, .probe = snd_byt_rt5640_mc_probe, + .remove = snd_byt_rt5640_mc_remove, };module_platform_driver (snd_byt_rt5640_mc_driver);
Signature · 1 line
2.5.0
Quoted 7 lines · On Wed, 06 Apr 2016 09:29:17 +0200, [email protected] wrote:
From: "Lu, Han" <[email protected]>
Share more product information, for user space utils such as PA and UCM to distinguish different products.
1. Add core APIs to register and cleanup DMI names for card.
2. Apply the APIs to bytcr-rt5640 driver.
Han, one good advice is: be patient. This is no urgent fix, so there is no many reason to rush too much with a pile of newer patchset. Give some more time for other people to review.
About the patch: I still have a few concerns, and some are in the fundamental level:
- Is calling dmi_*() function in ASoC core is appropriate and preferred?
- When is this function supposed to be called? Since you're accessing card->snd_card, it must be after instantiation, that is, snd_soc_register_card(). If so, it should be documented. And, in that case, there is no need to allocate a buffer; you can set the strings directly in card->snd_card. (For snd_component_add(), you may pass the card->snd_card->longname[]).
OTOH, if the function may be called before instantiation, the code needs more rethink, including the string allocation and release.
- A semicolon is no taboo character, either. A firmware or vendor string may contain such a letter, too. You need to either escape or replace such a letter instead of praying the well-mannered firmware.
thanks,
Takashi
Quoted 40 lines
changes on V7:
1. Remove inconsistent API descriptionchanges on V6:
1. Use dynamic allocate and cleanup for card long name
2. Remove unneccessary arguments to simplify the APIchanges on V5:
1. Use independent space to store cardlong_name, to avoid irrelavant info sharing from card component
2. Use letter ';' instead of ':' to separate strings in long name, in case name strings may also contain ':' and confuse user
3. Fix error that vendor name and firmware name were not optionalchanges on V4:
1. Replacekmalloc()andsnprintf()withksaprintf()to simplify codechanges on V3:
1. Split the core API and the API call to two patches
2. Replace misusedstrcat()withsnprintf()
3. Code and comment fixLu, Han (2):
ASoC: core: add API for registering and cleaning up DMI card names
ASoC: bytcr-rt5640: register DMI names for cardinclude/sound/soc.h | 3 ++ sound/soc/intel/boards/bytcr_rt5640.c | 18 ++++++++ sound/soc/soc-core.c | 85 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)Signature · 6 lines
2.5.0 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH V7 1/2] ASoC: core: add API for registering and cleaning up DMI card names
In reply to [email protected]Hi,
Quoted 36 lines · On Apr 6 2016 16:29, [email protected] wrote:
From: "Lu, Han" <[email protected]>
Add core API for registering and cleaning up DMI card names, so user space utils such as PA and UCM can distinguish various products. Previously on ASoC, the card short name, driver name and long name were all the same as the machine driver name.
The patch adds more board information:card driver name ---> machine driver name card short name ---> DMI_BOARD_NAME or DMI_PRODUCT_NAMEcard long name and
card component ---> short name;driver name;(DMI_SYS_VENDOR,
optional);(the firmware name, optional)Signed-off-by Lu, Han <[email protected]>include/sound/soc.h +3
-0@@ -486,6 +486,9 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);int snd_soc_runtime_set_dai_fmt (struct snd_soc_pcm_runtime *rtd,unsigned int dai_fmt); +int snd_soc_set_card_names (struct snd_soc_card *card,const char *firmware); +void snd_soc_cleanup_card_names (struct snd_soc_card *card); +/* Utility functions to get clock rates from various things */ int snd_soc_calc_frame_size (int sample_size,int channels,int tdm_slots);int snd_soc_params_to_frame_size (struct snd_pcm_hw_params *params);sound/soc/soc-core.c +0
-0(omit)
sound/soc/soc-core.c +2
-0+/** +* snd_soc_cleanup_card_names() - cleanup registered DMI names
sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1915
Quoted 10 lines
sound/soc/soc-core.c +10
-0+* @card: The card to cleanup +* +* This function cleanup the registered DMI names from card +*/ +void snd_soc_cleanup_card_names (struct snd_soc_card *card) +{ +kfree (card->long_name); +} +EXPORT_SYMBOL_GPL (snd_soc_cleanup_card_names); +
In linux kernel development, such a function with a little statements tends to be 'static inline function' defined in a header, instead of maintaining more symbols. I think some APIs of Linux workqueue are good examples to you. See 'include/linux/workqueue.h'.
Regards
Takashi Sakamoto
Mark Brown
maintainerQuoted 3 lines · Takashi Iwai
Han, one good advice is: be patient. This is no urgent fix, so there is no many reason to rush too much with a pile of newer patchset. Give some more time for other people to review.
FWIW given that every one of the many versions of this series has got a bunch of review comments I've not looked at it yet...
Quoted 11 lines · Takashi Iwai
Quoted 6 lines · On Wed, 06 Apr 2016 09:29:17 +0200, [email protected] wrote:
From: "Lu, Han" <[email protected]>
Share more product information, for user space utils such as PA and UCM to distinguish different products.
1. Add core APIs to register and cleanup DMI names for card.
2. Apply the APIs to bytcr-rt5640 driver.Han, one good advice is: be patient. This is no urgent fix, so there is no many reason to rush too much with a pile of newer patchset. Give some more time for other people to review.
sorry, I was too hurry. I'll update patch after more review.
Quoted 6 lines
About the patch: I still have a few concerns, and some are in the fundamental level:
- Is calling dmi_*() function in ASoC core is appropriate and preferred?
I was intended to add a common function for each machine driver to call, and to add firmware name if necessary. I can move all dmi_*() functions to machine drivers too, only pass the name strings as arguments.
Quoted 10 lines
- When is this function supposed to be called? Since you're accessing
card->snd_card, it must be after instantiation, that is,snd_soc_register_card(). If so, it should be documented. And, in that case, there is no need to allocate a buffer; you can set the strings directly incard->snd_card. (Forsnd_component_add(), you may pass the card->snd_card->longname[]).OTOH, if the function may be called before instantiation, the code needs more rethink, including the string allocation and release.
the intention was to set the card->long_name, before the accessing to it in snd_soc_instantiate_card():
...
snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
"%s", card->long_name ? card->long_name : card->name);
...or it may be better to overwrite the card->snd_card->longname[] after instantiation, so no need to allocate and release at all?
Quoted 5 lines
- A semicolon is no taboo character, either. A firmware or vendor string may contain such a letter, too. You need to either escape or replace such a letter instead of praying the well-mannered firmware.
so any printable ASCII character may have the same risk, may I use a control code such as '\t', or a non ASCII value like 0x80?
BR,
Han
Quoted 49 lines
thanks,
Takashi
Quoted 22 lines
changes on V7:
1. Remove inconsistent API descriptionchanges on V6:
1. Use dynamic allocate and cleanup for card long name
2. Remove unneccessary arguments to simplify the APIchanges on V5:
1. Use independent space to store cardlong_name, to avoid irrelavant info sharing from card component
2. Use letter ';' instead of ':' to separate strings in long name, in case name strings may also contain ':' and confuse user
3. Fix error that vendor name and firmware name were not optionalchanges on V4:
1. Replacekmalloc()andsnprintf()withksaprintf()to simplify codechanges on V3:
1. Split the core API and the API call to two patches
2. Replace misusedstrcat()withsnprintf()
3. Code and comment fixQuoted 17 lines
Lu, Han (2):
ASoC: core: add API for registering and cleaning up DMI card names
ASoC: bytcr-rt5640: register DMI names for cardinclude/sound/soc.h | 3 ++ sound/soc/intel/boards/bytcr_rt5640.c | 18 ++++++++ sound/soc/soc-core.c | 85 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)Signature · 6 lines
2.5.0 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH V7 1/2] ASoC: core: add API for registering and cleaning up DMI card names
In reply to Takashi SakamotoQuoted 45 lines · Takashi Sakamoto
Hi,
Quoted 42 lines · On Apr 6 2016 16:29, [email protected] wrote:
From: "Lu, Han" <[email protected]>
Add core API for registering and cleaning up DMI card names, so user space utils such as PA and UCM can distinguish various products. Previously on ASoC, the card short name, driver name and long name were all the same as the machine driver name.
The patch adds more board information:card driver name ---> machine driver name card short name ---> DMI_BOARD_NAME or DMI_PRODUCT_NAMEcard long name and
card component ---> short name;driver name;(DMI_SYS_VENDOR,
optional);(the firmware name, optional)Signed-off-by Lu, Han <[email protected]>include/sound/soc.h +3
-0@@ -486,6 +486,9 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);int snd_soc_runtime_set_dai_fmt (struct snd_soc_pcm_runtime *rtd,unsigned int dai_fmt); +int snd_soc_set_card_names (struct snd_soc_card *card,const char *firmware); +void snd_soc_cleanup_card_names (struct snd_soc_card *card); +/* Utility functions to get clock rates from various things */ int snd_soc_calc_frame_size (int sample_size,int channels,int tdm_slots);int snd_soc_params_to_frame_size (struct snd_pcm_hw_params *params);sound/soc/soc-core.c +0
-0(omit)
sound/soc/soc-core.c +8
-0+/** +* snd_soc_cleanup_card_names() - cleanup registered DMI names +* @card: The card to cleanup +* +* This function cleanup the registered DMI names from card +*/ +void snd_soc_cleanup_card_names (struct snd_soc_card *card) +{
Quoted 8 lines
sound/soc/soc-core.c int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, · line 1915
Quoted 4 lines
sound/soc/soc-core.c +4
-0+kfree (card->long_name); +} +EXPORT_SYMBOL_GPL (snd_soc_cleanup_card_names); +In linux kernel development, such a function with a little statements tends to be 'static inline function' defined in a header, instead of maintaining more symbols. I think some APIs of Linux workqueue are good examples to you. See '
include/linux/workqueue.h'.
Thanks. Since we need to pass the string (firmware name) from machine driver to core anyway, I guess one API is a must, but the cleanup API may not necessary if there's no allocation. I'll rethink of it.
BR,
Han
Quoted 10 lines
Regards
Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 8 lines · Mark Brown
Quoted 3 lines · Takashi Iwai
Han, one good advice is: be patient. This is no urgent fix, so there is no many reason to rush too much with a pile of newer patchset. Give some more time for other people to review.
FWIW given that every one of the many versions of this series has got a bunch of review comments I've not looked at it yet...
Sorry, I'll slow down with more thinking.
BR,
Han
Quoted 6 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel