On Fri, 2016-12-23 at 16:08 +0800, Mengdong Lin wrote:
On 12/22/2016 11:35 PM, Liam Girdwood wrote:
> +/* This function will find the best device-specific configuration > +file based > + * on the sound card long name. > + * Different devices may share the same sound driver and thus the > +same sound > + * card name (short name), but they may still need different > +device-specific > + * configurations. For user space to differentiate them, kernel > +drivers may > + * include the DMI info (vendor, product and board) in the card > +long name. > + * And user space can define configuration file names appending > +DMI keywords > + * to the card name, like: > + * bytcr-rt5640.ASUS.T100 > + * bytcr-rt5651.MinnowBoard > + * > + * When being asked to load the configuration file for a card, > +this function > + * will try to find the card long name from the local machine, > +and then scan > + * all available configuration file names, search every field of > +the config > + * file name in the card long name. The more characters match, > +the higher > + * score the file has. Finally, the file with the highest score will be
loaded.
> + */
Id' expect this function to try and open card longname and then card name if longname is not found. So providing we use the exact same names as the DMI name we wont need any string formatting or scoring (i.e. file open("longname/longname.conf") will either succeed or fail)
Liam
I feel we cannot use the exact same names for the configuration file and card long name. The DMI info in the card long name can be lengthy, including '.' , SPACE, meaningless info like "Corp." and sometime duplicated info for some OEMs.I hope developers can just extract key words from the messy DMI info to make a simple configuration file name, and UCM automatically do the matching and give each configuration file a score. Then the file with highest score will be used for the card.
Providing the DMI name does not use invalid filename characters we are ok. Extracting key words and matching is prone to many problems and painful to debug....
May I revise the UCM code like this? It will try to open the file with DMI name at first. And only if that file is not available, fall back to key words matching.
I hope to keep the possibility that user can use a simple configuration file for a product family, without generating too many card directories and files.
If the DMI names are too complex for directory names, then you could add an alias file at the top level that would list the DMI name and the shortened name i.e.
# DMI name # UCM directory name "Dell blah Corp. XPS, 13 blah" "Dell XPS13 BDW"
So the alias file could be searched for the DMI name, before the legacy name was tried.
The alias method above also allows for reuse of configs on machines that are similar, but with different DMI names. So this would also keep the number of configs low.
Liam
I'll try to use the alias file. But it seems we need to maintain a lot of entries in the file :-(
In addition, I found we cannot use paths with SPACE as the UCM directory name. Autoconf cannot support this. It complains although I tried \ or " to escape. We need something like "Dell.XPS13.BDW" as the UCM directory names.
Gah, it looks like autoconf may have defeated this ! Autoconf has special uses for some chars in names.
So you may want to "fix" the DMI name to exclude any special chars when creating your longname (maybe also set a shorter length too). I still dont want any scoring, we just want to open the "longname.conf" then "drivername.conf"
Liam