Skip to content

Commit

Permalink
ucm2: use private alsa-lib's configuration by default
Browse files Browse the repository at this point in the history
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
  • Loading branch information
perexg committed May 13, 2021
1 parent ec85b3e commit 1e6297b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ucm2/ucm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
# Syntax version is reset for the master configuration file.
#

Syntax 3
Syntax 4

Define.V1 "" # non-empty string to enable ucm v1 paths
Define.V2ConfD yes # empty string to disable
Define.V2Module yes # non-empty string to enable module name lookups (obsolete)
Define.V2Name yes # non-empty string to enable driver & card name lookups (obsolete)

Include.libgen.File "/lib/generic.conf" # private alsa-lib configuration

If.driver {
Condition {
Type String
Expand Down

7 comments on commit 1e6297b

@tongfei198591
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @perexg :

I found this change only expose hw device to application, while we create new device , and it will add _ucm0001. prefix for the new device, also the local config don`t have this device, and cause it is one "invalid ctl", how can we overcome it , can we revert this patch? many Thanks.

Best Regards
Fei

@perexg
Copy link
Member Author

@perexg perexg commented on 1e6297b Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this change only expose hw device to application, while we create new device , and it will add _ucm0001. prefix for the new device, also the local config don`t have this device, and cause it is one "invalid ctl", how can we overcome it , can we revert this patch? many Thanks.

If you have special requirements, create own ucm.conf file. The purpose of the private alsa-lib configuration for ucm is to have all things self-contained. If you look to the included file, it contains the alsa-lib configuration (but only a very little part).

I cannot judge your requirement without knowledge of your special device. Basically, UCM should describe everything and don't rely on something else. So you may think to define your special device inside UCM, too. Just look for LibraryConfig blocks in the current configuration files for examples.

@tongfei198591
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for you quick reply, so if "it contains the alsa-lib configuration (but only a very little part).", can I remove this line "Include.libgen.File "/lib/generic.conf" # private alsa-lib configuration", then there is no local_config. and it will always call "snd_config_update_ref(&top);" inside "snd_ctl_open/snd_pcm_open". or should I include another config file like add another line "" Include.libgen.File "/lib/pcmplugin.conf"".
btw, I don`t understand what is "_snd_is_ucm_device" mean, I understand the API, but what kind of device should be ucm_device ,then add prefix for it . it is very appreciate you can provide help .

Best Regards
Fei

@perexg
Copy link
Member Author

@perexg perexg commented on 1e6297b Jun 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device prefix determines the private UCM configuration for alsa-lib and the _snd_is_ucm_device() is a helper to detect this prefix. It means that the system-wide alsa-lib configurations are not parsed (used) at all when the application gets the devices through UCM. In other words, if you define your device in /etc/asound.conf or ~/.asoundrc, it won't be visible, because this configuration is not used. You should define this special device in the LibraryConfig block (UCM).

EDIT: For the completion: If at least one LibraryConfig block is in the UCM configuration, the private alsa-lib configuration (private to UCM application) is activated (special device prefixes).

@tongfei198591
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I summaries as below:

  1. there are globlal configuration and private configuration.
  2. when generic conf (contain LibraryConfig block ) is included , the special device prefixes is activated .
  3. when special device prefixes is activated , other pcm/control device is not visible except hw:0.
  4. To use ohter pcm device, we need add other pcm/control device config in LibraryConfig block and included in ucm.conf. " Include.libgen.File "/lib/pcmplugin.conf"".
  5. There are four method to include other LibraryConfig file
    LibraryConfig.a_label.SubstiConfig {
    # substituted library configuration like:
    usr_share_dir "${ConfLibDir}"
    }
    LibraryConfig.b_label.Config {
    # non-substituted library configuration like:
    usr_share_dir "/usr/share/alsa"
    }
    LibraryConfig.c_label.SubstiFile "/some/path"
    LibraryConfig.d_label.File "/some/path"
  6. OEM can customize the ucm.conf file to include other private configuration.

Best Regards
Fei

@perexg
Copy link
Member Author

@perexg perexg commented on 1e6297b Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I summaries as below:

1. there are globlal configuration and private configuration.

Yes, the private configuration is only for UCM.

2. when generic conf (contain LibraryConfig block ) is included , the special device prefixes is activated .

3. when special device prefixes is activated , other pcm/control device is not visible except hw:0.

It's not completely correct, if it's activated, only the configuration for alsa-lib defined in UCM configuration is used. By default, only hw:# devices are defined (see contents of the included file - Include.libgen.File "/lib/generic.conf"). Everything is configurable, you may start with an empty configuration for alsa-lib.

Note that the standard configuration has only one base file /usr/share/alsa/alsa.conf, too. It defines all devices (and does the dynamic inclusion of the other files like /etc/asound.conf etc.). Again, everything is configurable. The private configuration for UCM just does not use this file.

4. To use ohter pcm device, we need add other pcm/control device config in LibraryConfig block and included in ucm.conf. " Include.libgen.File "/lib/pcmplugin.conf"".

Yes. The LibraryConfig block must be used for this.

5. There are four method to include other LibraryConfig file
   LibraryConfig.a_label.SubstiConfig {
   # substituted library configuration like:
   usr_share_dir "${ConfLibDir}"
   }
   LibraryConfig.b_label.Config {
   # non-substituted library configuration like:
   usr_share_dir "/usr/share/alsa"
   }
   LibraryConfig.c_label.SubstiFile "/some/path"
   LibraryConfig.d_label.File "/some/path"

Correct.

6. OEM can customize the ucm.conf  file to include other private configuration.

Note that ucm2/ucm.conf is used as the root configuration file to define the configuration lookups and the global configuration for all hardware variants (including plug-and-play hardware like USB). The per-hardware (profile) configurations should be defined in the specific card / verb UCM configuration files - including the LibraryConfig blocks.

@tongfei198591
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much , it is really very helpful you provide so much detailed comment, Thanks again .

Please sign in to comment.