Lines Matching +full:codec +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysfs interface for HD-audio codec
33 struct hda_codec *codec = dev_get_drvdata(dev);
34 snd_hda_update_power_acct(codec);
35 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
42 struct hda_codec *codec = dev_get_drvdata(dev);
43 snd_hda_update_power_acct(codec);
44 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
55 struct hda_codec *codec = dev_get_drvdata(dev); \
56 return sysfs_emit(buf, "0x%x\n", codec->field); \
64 struct hda_codec *codec = dev_get_drvdata(dev); \
66 codec->field ? codec->field : ""); \
78 static ssize_t pin_configs_show(struct hda_codec *codec,
85 guard(mutex)(&codec->user_mutex);
88 pin->nid, pin->cfg);
97 struct hda_codec *codec = dev_get_drvdata(dev);
98 return pin_configs_show(codec, &codec->init_pins, buf);
105 struct hda_codec *codec = dev_get_drvdata(dev);
106 return pin_configs_show(codec, &codec->driver_pins, buf);
115 static int clear_codec(struct hda_codec *codec)
119 err = snd_hda_codec_reset(codec);
121 codec_err(codec, "The codec is being used, can't free.\n");
124 snd_hda_sysfs_clear(codec);
128 static int reconfig_codec(struct hda_codec *codec)
132 CLASS(snd_hda_power, pm)(codec);
133 codec_info(codec, "hda-codec: reconfiguring\n");
134 err = snd_hda_codec_reset(codec);
136 codec_err(codec,
137 "The codec is being used, can't reconfigure.\n");
140 err = device_reprobe(hda_codec_dev(codec));
143 return snd_card_register(codec->card);
166 struct hda_codec *codec = dev_get_drvdata(dev); \
171 codec->field = val; \
180 struct hda_codec *codec = dev_get_drvdata(dev); \
183 return -ENOMEM; \
184 kfree(codec->field); \
185 codec->field = s; \
201 struct hda_codec *codec = dev_get_drvdata(dev); \
204 err = type##_codec(codec); \
215 struct hda_codec *codec = dev_get_drvdata(dev);
219 guard(mutex)(&codec->user_mutex);
220 snd_array_for_each(&codec->init_verbs, i, v) {
222 v->nid, v->verb, v->param);
227 static int parse_init_verbs(struct hda_codec *codec, const char *buf)
233 return -EINVAL;
235 return -EINVAL;
236 guard(mutex)(&codec->user_mutex);
237 v = snd_array_new(&codec->init_verbs);
239 return -ENOMEM;
240 v->nid = nid;
241 v->verb = verb;
242 v->param = param;
250 struct hda_codec *codec = dev_get_drvdata(dev);
251 int err = parse_init_verbs(codec, buf);
261 struct hda_codec *codec = dev_get_drvdata(dev);
265 guard(mutex)(&codec->user_mutex);
266 snd_array_for_each(&codec->hints, i, hint) {
268 hint->key, hint->val);
273 static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
278 snd_array_for_each(&codec->hints, i, hint) {
279 if (!strcmp(hint->key, key))
290 p = str + strlen(str) - 1;
291 for (; isspace(*p); p--) {
300 static int parse_hints(struct hda_codec *codec, const char *buf)
310 return -EINVAL;
313 return -ENOMEM;
317 return -EINVAL;
322 guard(mutex)(&codec->user_mutex);
323 hint = get_hint(codec, key);
326 kfree(hint->key);
330 if (codec->hints.used >= MAX_HINTS)
331 return -ENOMEM;
332 hint = snd_array_new(&codec->hints);
334 return -ENOMEM;
336 hint->key = no_free_ptr(key);
337 hint->val = val;
345 struct hda_codec *codec = dev_get_drvdata(dev);
346 int err = parse_hints(codec, buf);
356 struct hda_codec *codec = dev_get_drvdata(dev);
357 return pin_configs_show(codec, &codec->user_pins, buf);
360 static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
365 return -EINVAL;
367 return -EINVAL;
368 guard(mutex)(&codec->user_mutex);
369 return snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
376 struct hda_codec *codec = dev_get_drvdata(dev);
377 int err = parse_user_pin_configs(codec, buf);
391 * snd_hda_get_hint - Look for hint string
392 * @codec: the HDA codec
398 const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
400 struct hda_hint *hint = get_hint(codec, key);
401 return hint ? hint->val : NULL;
406 * snd_hda_get_bool_hint - Get a boolean hint value
407 * @codec: the HDA codec
414 int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
418 guard(mutex)(&codec->user_mutex);
419 p = snd_hda_get_hint(codec, key);
421 return -ENOENT;
434 * snd_hda_get_int_hint - Get an integer hint value
435 * @codec: the HDA codec
443 int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
448 guard(mutex)(&codec->user_mutex);
449 p = snd_hda_get_hint(codec, key);
451 return -ENOENT;
453 return -EINVAL;
504 /* parse the contents after the line "[codec]"
505 * accept only the line with three numbers, and assign the current codec
511 struct hda_codec *codec;
515 list_for_each_codec(codec, bus) {
516 if ((vendorid <= 0 || codec->core.vendor_id == vendorid) &&
517 (subid <= 0 || codec->core.subsystem_id == subid) &&
518 codec->core.addr == caddr) {
519 *codecp = codec;
528 * just pass to the sysfs helper (only when any codec was specified)
551 kfree((*codecp)->modelname);
552 (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
567 (*codecp)->core.name = val; \
583 .tag = "[codec]",
623 /* check the line starting with '[' -- change the parser mode accordingly */
639 * return zero if it reaches to the end of the buffer, or non-zero
653 fw_size--;
670 *fw_size_p = fw_size - len;
677 * snd_hda_load_patch - load a "patch" firmware file and parse it
678 * @bus: HD-audio bus
685 struct hda_codec *codec;
689 codec = NULL;
690 while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
696 (codec || line_mode <= LINE_MODE_CODEC))
697 patch_items[line_mode].parser(buf, bus, &codec);
739 void snd_hda_sysfs_init(struct hda_codec *codec)
741 mutex_init(&codec->user_mutex);
743 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
744 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
745 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
749 void snd_hda_sysfs_clear(struct hda_codec *codec)
756 snd_array_free(&codec->init_verbs);
758 snd_array_for_each(&codec->hints, i, hint) {
759 kfree(hint->key); /* we don't need to free hint->val */
761 snd_array_free(&codec->hints);
762 snd_array_free(&codec->user_pins);