Codebase list alsa-lib / 9c194a0
ucm: add _fboot / FixedBootSequence Actually, the BootSequence is executed only when the driver controls (identifiers or value types) are changed. It may be handy to have also a sequence which is executed at _each_ boot without any condition. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Jaroslav Kysela 3 years ago
5 changed file(s) with 59 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
417417 * \return Zero if success, otherwise a negative error code
418418 *
419419 * Known identifiers:
420 * - _fboot - execute the fixed boot sequence (value = NULL)
420421 * - _boot - execute the boot sequence (value = NULL)
422 * - only when driver controls identifiers are changed
423 * (otherwise the old control values are restored)
421424 * - _defaults - execute the 'defaults' sequence (value = NULL)
422425 * - _verb - set current verb = value
423426 * - _enadev - enable given device = value
593593 }
594594 if (!list_empty(&uc_mgr->verb_list))
595595 return 0;
596 if (!list_empty(&uc_mgr->fixedboot_list))
597 return 0;
596598 if (!list_empty(&uc_mgr->boot_list))
597599 return 0;
598600 return -ENXIO;
992994 if (mgr == NULL)
993995 return -ENOMEM;
994996 INIT_LIST_HEAD(&mgr->verb_list);
997 INIT_LIST_HEAD(&mgr->fixedboot_list);
995998 INIT_LIST_HEAD(&mgr->boot_list);
996999 INIT_LIST_HEAD(&mgr->default_list);
9971000 INIT_LIST_HEAD(&mgr->value_list);
18851888 return err;
18861889 }
18871890
1891 static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
1892 const char *value)
1893 {
1894 int err;
1895
1896 if (value != NULL && *value) {
1897 uc_error("error: wrong value for _fboot (%s)", value);
1898 return -EINVAL;
1899 }
1900 err = execute_sequence(uc_mgr, &uc_mgr->fixedboot_list,
1901 &uc_mgr->value_list, NULL, NULL);
1902 if (err < 0) {
1903 uc_error("Unable to execute force boot sequence");
1904 return err;
1905 }
1906 return err;
1907 }
1908
18881909 static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
18891910 const char *value)
18901911 {
21242145 int err = 0;
21252146
21262147 pthread_mutex_lock(&uc_mgr->mutex);
2127 if (strcmp(identifier, "_boot") == 0)
2148 if (strcmp(identifier, "_fboot") == 0)
2149 err = set_fixedboot_user(uc_mgr, value);
2150 else if (strcmp(identifier, "_boot") == 0)
21282151 err = set_boot_user(uc_mgr, value);
21292152 else if (strcmp(identifier, "_defaults") == 0)
21302153 err = set_defaults_user(uc_mgr, value);
17391739 }
17401740
17411741 /*
1742 * parse controls which should be run only at initial boot (forcefully)
1743 */
1744 static int parse_controls_fixedboot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
1745 {
1746 int err;
1747
1748 if (!list_empty(&uc_mgr->fixedboot_list)) {
1749 uc_error("FixedBoot list is not empty");
1750 return -EINVAL;
1751 }
1752 err = parse_sequence(uc_mgr, &uc_mgr->fixedboot_list, cfg);
1753 if (err < 0) {
1754 uc_error("Unable to parse FixedBootSequence");
1755 return err;
1756 }
1757
1758 return 0;
1759 }
1760
1761 /*
17421762 * parse controls which should be run only at initial boot
17431763 */
17441764 static int parse_controls_boot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
18851905 err = parse_compound(uc_mgr, n,
18861906 parse_master_section,
18871907 NULL, NULL);
1908 if (err < 0)
1909 return err;
1910 continue;
1911 }
1912
1913 /* find default control values section (force boot sequence only) */
1914 if (strcmp(id, "FixedBootSequence") == 0) {
1915 err = parse_controls_fixedboot(uc_mgr, n);
18881916 if (err < 0)
18891917 return err;
18901918 continue;
221221 /* use case verb, devices and modifier configs parsed from files */
222222 struct list_head verb_list;
223223
224 /* force boot settings - sequence */
225 struct list_head fixedboot_list;
226
224227 /* boot settings - sequence */
225228 struct list_head boot_list;
226229
691691 list_del(&verb->list);
692692 free(verb);
693693 }
694 uc_mgr_free_sequence(&uc_mgr->fixedboot_list);
694695 uc_mgr_free_sequence(&uc_mgr->boot_list);
695696 uc_mgr_free_sequence(&uc_mgr->default_list);
696697 uc_mgr_free_value(&uc_mgr->value_list);