alsa-card: add dynamic priority bonus base for alsa profiles
After applying the commit 0d50e787 ("alsa-card: improve the profile availability logic"), we met an new issue. when system selects the initial profile, the profile off is selected instead of a profile with a valid output device on it. That is the issue we met: Profiles: HiFi: Default (sinks: 2, sources: 2, priority: 8000, available: no) off: Off (sinks: 0, sources: 0, priority: 0, available: yes) Active Profile: off Ports: [Out] Headphones: Headphones (priority: 300, latency offset: 0 usec, not available) Part of profile(s): HiFi [Out] Speaker: Speaker (priority: 100, latency offset: 0 usec) Part of profile(s): HiFi ... I know the commit 0d50e787 really fixed something, but we still need to fix the new issue, to do so, this patch introduces a priority bonus for alsa profiles and separate the alsa profiles to 3 groups: group a (will be granted priority bonus dynamically): a profile has only output ports and at least one port is not unavailable a profile has only input ports and at least one port is not unavailable a profile has both input and output ports, and at least one output and one input ports are not unavailable group b (will be marked unavailable) a profile has only output ports and all ports are unavailable a profile has only input ports and all ports are unavailable a profile has both output and input ports, and all ports are unavailable group c the rest profiles, their priority and availability is not changed. With this change, the profile HiFi will become avaialbe:yes, and will not be granted priority bonus if no input port is plugged. The priority bonus provides a higher priority base to profiles, this guarantees this patch doesn't break the fix of 0d50e787. #927 Signed-off-by:Hui Wang <hui.wang@canonical.com> Part-of: <!355>