1 /*
2 * Advanced Linux Sound Architecture Control Program - UCM Initialization
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #include "aconfig.h"
23 #include <stddef.h>
24 #include "alsactl.h"
25
26 #ifdef HAVE_ALSA_USE_CASE_H
27
28 #include <alsa/use-case.h>
29
30 /*
31 * Keep it as simple as possible. Execute commands from the
32 * FixedBootSequence and BootSequence only.
33 */
init_ucm(int flags,int cardno)34 int init_ucm(int flags, int cardno)
35 {
36 snd_use_case_mgr_t *uc_mgr;
37 char id[32], *nodev;
38 int err;
39
40 if (flags & FLAG_UCM_DISABLED)
41 return -ENXIO;
42
43 nodev = (flags & FLAG_UCM_NODEV) ? "" : "-";
44 snprintf(id, sizeof(id), "%shw:%d", nodev, cardno);
45 err = snd_use_case_mgr_open(&uc_mgr, id);
46 if (err < 0)
47 return err;
48 if (flags & FLAG_UCM_FBOOT) {
49 err = snd_use_case_set(uc_mgr, "_fboot", NULL);
50 if (err == -ENOENT && (flags & FLAG_UCM_BOOT) != 0) {
51 /* nothing */
52 } else if (err < 0) {
53 goto _error;
54 }
55 }
56 if (flags & FLAG_UCM_BOOT) {
57 err = snd_use_case_set(uc_mgr, "_boot", NULL);
58 if (err < 0)
59 goto _error;
60 if ((flags & FLAG_UCM_DEFAULTS) != 0)
61 err = snd_use_case_set(uc_mgr, "_defaults", NULL);
62 }
63 _error:
64 snd_use_case_mgr_close(uc_mgr);
65 return err;
66 }
67
68 #else
69
init_ucm(int flags,int cardno)70 int init_ucm(int flags, int cardno)
71 {
72 return -ENXIO;
73 }
74
75 #endif
76