diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-01-07 16:34:07 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-01-07 16:34:07 +0100 |
commit | 8588227e28bfaebb1bace53e46c97fb6610b505b (patch) | |
tree | dde599c9ad55d97f43984d822fe2c6a9be956519 | |
parent | 064fed40f1ede0c7ce0e5e65f1974f0c5cfc5a48 (diff) | |
download | hda-emu-8588227e28bfaebb1bace53e46c97fb6610b505b.tar.gz |
Add -U option for providing the initial user-pincfgs
The option -P allows to set only the initial pin configs which may be
overridden by the driver's own setup. We want to provide sometimes
the pin configs corresponding to user_pin_configs sysfs. The new
option, -U, serves for that purpose.
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | hda-emu.c | 33 |
2 files changed, 31 insertions, 8 deletions
@@ -423,6 +423,12 @@ register and pin-config value in each line just like in *_pin_configs sysfs files. Also, you can pass a pin config directly via -P optoin, e.g. -P 0x0a=0x12345678. +For providing the user-defined pin configurations, use -U instead of +-P option. The difference between these two options is that the pin +configuration set via -P option may be overridden by the driver's own +setup while the pin configuration set via -U remains over the driver's +setup. + Similarly, you can give the initial hints strings either from sysfs file in alsa-info.sh output or an external file via -H option. Also, you can pass a hint directrly via -H option, e.g. -H "jack_detect=0". @@ -1080,9 +1080,17 @@ static struct xhda_node *find_node(struct xhda_codec *codec, int nid) return NULL; } -static void set_pincfg(struct xhda_codec *codec, int nid, int val) +static void set_pincfg(struct xhda_codec *codec, int nid, int val, int user) { - struct xhda_node *node = find_node(codec, nid); + struct xhda_node *node; + + if (user) { + hda_log_set_user_pin_configs(nid, val); + hda_log(HDA_LOG_INFO, " User Pin 0x%02x to 0x%08x\n", nid, val); + return; + } + + node = find_node(codec, nid); if (node) { node->pin_default = val; hda_log(HDA_LOG_INFO, " Pin 0x%02x to 0x%08x\n", nid, val); @@ -1090,7 +1098,7 @@ static void set_pincfg(struct xhda_codec *codec, int nid, int val) } } -static int override_pincfg(struct xhda_codec *codec, char *pincfg) +static int override_pincfg(struct xhda_codec *codec, char *pincfg, int user) { FILE *fp; char buf[256]; @@ -1104,7 +1112,7 @@ static int override_pincfg(struct xhda_codec *codec, char *pincfg) hda_log(HDA_LOG_ERR, "Invalid pincfg %s\n", pincfg); return -EINVAL; } - set_pincfg(codec, reg, val); + set_pincfg(codec, reg, val, user); return 0; } @@ -1114,7 +1122,7 @@ static int override_pincfg(struct xhda_codec *codec, char *pincfg) struct xhda_sysfs_value *val; hda_log(HDA_LOG_INFO, "Overriding pin-configs via %s\n", pincfg); for (val = sys->entry.vals; val; val = val->next) - set_pincfg(codec, val->val[0], val->val[1]); + set_pincfg(codec, val->val[0], val->val[1], user); return 0; } } @@ -1149,7 +1157,7 @@ static int override_pincfg(struct xhda_codec *codec, char *pincfg) } if (sscanf(buf, "%i %i", ®, &val) != 2) break; - set_pincfg(codec, reg, val); + set_pincfg(codec, reg, val, user); } fclose (fp); return 0; @@ -1238,6 +1246,7 @@ static void usage(void) fprintf(stderr, " -a issues SIGTRAP at codec errors\n"); fprintf(stderr, " -n don't configure codec at start\n"); fprintf(stderr, " -P pincfg initialize pin-configuration from sysfs entry\n"); + fprintf(stderr, " -U pincfg initialize user pincfg overrides\n"); fprintf(stderr, " -H hints add initial hints from sysfs entry or file\n"); fprintf(stderr, " -j NID turn on the initial jack-state of the given pin\n"); } @@ -1282,12 +1291,13 @@ int main(int argc, char **argv) struct hda_bus_template temp; struct hda_codec *codec; char *init_pincfg = NULL; + char *user_pincfg = NULL; char *init_hints = NULL; int num_active_jacks = 0; int no_configure = 0; unsigned int active_jacks[16]; - while ((c = getopt(argc, argv, "al:i:p:m:do:qCMFP:H:j:n")) != -1) { + while ((c = getopt(argc, argv, "al:i:p:m:do:qCMFP:U:H:j:n")) != -1) { switch (c) { case 'a': hda_log_trap_on_error = 1; @@ -1326,6 +1336,9 @@ int main(int argc, char **argv) case 'P': init_pincfg = optarg; break; + case 'U': + user_pincfg = optarg; + break; case 'H': init_hints = optarg; break; @@ -1371,7 +1384,7 @@ int main(int argc, char **argv) } if (init_pincfg) { - if (override_pincfg(&proc, init_pincfg) < 0) + if (override_pincfg(&proc, init_pincfg, 0) < 0) return 1; } if (num_active_jacks) { @@ -1461,6 +1474,10 @@ int main(int argc, char **argv) if (load_init_hints(&proc, init_hints) < 0) return 1; } + if (user_pincfg) { + if (override_pincfg(&proc, user_pincfg, 1) < 0) + return 1; + } #ifdef HAVE_HDA_PATCH_LOADER if (!no_configure) |