0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/init.h>
0011 #include <linux/slab.h>
0012 #include <linux/compat.h>
0013 #include <linux/mutex.h>
0014 #include <linux/ctype.h>
0015 #include <linux/string.h>
0016 #include <linux/export.h>
0017 #include <sound/core.h>
0018 #include <sound/hda_codec.h>
0019 #include "hda_local.h"
0020 #include <sound/hda_hwdep.h>
0021 #include <sound/minors.h>
0022
0023
0024 struct hda_hint {
0025 const char *key;
0026 const char *val;
0027 };
0028
0029 #ifdef CONFIG_PM
0030 static ssize_t power_on_acct_show(struct device *dev,
0031 struct device_attribute *attr,
0032 char *buf)
0033 {
0034 struct hda_codec *codec = dev_get_drvdata(dev);
0035 snd_hda_update_power_acct(codec);
0036 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
0037 }
0038
0039 static ssize_t power_off_acct_show(struct device *dev,
0040 struct device_attribute *attr,
0041 char *buf)
0042 {
0043 struct hda_codec *codec = dev_get_drvdata(dev);
0044 snd_hda_update_power_acct(codec);
0045 return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
0046 }
0047
0048 static DEVICE_ATTR_RO(power_on_acct);
0049 static DEVICE_ATTR_RO(power_off_acct);
0050 #endif
0051
0052 #define CODEC_INFO_SHOW(type, field) \
0053 static ssize_t type##_show(struct device *dev, \
0054 struct device_attribute *attr, \
0055 char *buf) \
0056 { \
0057 struct hda_codec *codec = dev_get_drvdata(dev); \
0058 return sysfs_emit(buf, "0x%x\n", codec->field); \
0059 }
0060
0061 #define CODEC_INFO_STR_SHOW(type, field) \
0062 static ssize_t type##_show(struct device *dev, \
0063 struct device_attribute *attr, \
0064 char *buf) \
0065 { \
0066 struct hda_codec *codec = dev_get_drvdata(dev); \
0067 return sysfs_emit(buf, "%s\n", \
0068 codec->field ? codec->field : ""); \
0069 }
0070
0071 CODEC_INFO_SHOW(vendor_id, core.vendor_id);
0072 CODEC_INFO_SHOW(subsystem_id, core.subsystem_id);
0073 CODEC_INFO_SHOW(revision_id, core.revision_id);
0074 CODEC_INFO_SHOW(afg, core.afg);
0075 CODEC_INFO_SHOW(mfg, core.mfg);
0076 CODEC_INFO_STR_SHOW(vendor_name, core.vendor_name);
0077 CODEC_INFO_STR_SHOW(chip_name, core.chip_name);
0078 CODEC_INFO_STR_SHOW(modelname, modelname);
0079
0080 static ssize_t pin_configs_show(struct hda_codec *codec,
0081 struct snd_array *list,
0082 char *buf)
0083 {
0084 const struct hda_pincfg *pin;
0085 int i, len = 0;
0086 mutex_lock(&codec->user_mutex);
0087 snd_array_for_each(list, i, pin) {
0088 len += sysfs_emit_at(buf, len, "0x%02x 0x%08x\n",
0089 pin->nid, pin->cfg);
0090 }
0091 mutex_unlock(&codec->user_mutex);
0092 return len;
0093 }
0094
0095 static ssize_t init_pin_configs_show(struct device *dev,
0096 struct device_attribute *attr,
0097 char *buf)
0098 {
0099 struct hda_codec *codec = dev_get_drvdata(dev);
0100 return pin_configs_show(codec, &codec->init_pins, buf);
0101 }
0102
0103 static ssize_t driver_pin_configs_show(struct device *dev,
0104 struct device_attribute *attr,
0105 char *buf)
0106 {
0107 struct hda_codec *codec = dev_get_drvdata(dev);
0108 return pin_configs_show(codec, &codec->driver_pins, buf);
0109 }
0110
0111 #ifdef CONFIG_SND_HDA_RECONFIG
0112
0113
0114
0115
0116
0117 static int clear_codec(struct hda_codec *codec)
0118 {
0119 int err;
0120
0121 err = snd_hda_codec_reset(codec);
0122 if (err < 0) {
0123 codec_err(codec, "The codec is being used, can't free.\n");
0124 return err;
0125 }
0126 snd_hda_sysfs_clear(codec);
0127 return 0;
0128 }
0129
0130 static int reconfig_codec(struct hda_codec *codec)
0131 {
0132 int err;
0133
0134 snd_hda_power_up(codec);
0135 codec_info(codec, "hda-codec: reconfiguring\n");
0136 err = snd_hda_codec_reset(codec);
0137 if (err < 0) {
0138 codec_err(codec,
0139 "The codec is being used, can't reconfigure.\n");
0140 goto error;
0141 }
0142 err = device_reprobe(hda_codec_dev(codec));
0143 if (err < 0)
0144 goto error;
0145 err = snd_card_register(codec->card);
0146 error:
0147 snd_hda_power_down(codec);
0148 return err;
0149 }
0150
0151
0152
0153
0154 static char *kstrndup_noeol(const char *src, size_t len)
0155 {
0156 char *s = kstrndup(src, len, GFP_KERNEL);
0157 char *p;
0158 if (!s)
0159 return NULL;
0160 p = strchr(s, '\n');
0161 if (p)
0162 *p = 0;
0163 return s;
0164 }
0165
0166 #define CODEC_INFO_STORE(type, field) \
0167 static ssize_t type##_store(struct device *dev, \
0168 struct device_attribute *attr, \
0169 const char *buf, size_t count) \
0170 { \
0171 struct hda_codec *codec = dev_get_drvdata(dev); \
0172 unsigned long val; \
0173 int err = kstrtoul(buf, 0, &val); \
0174 if (err < 0) \
0175 return err; \
0176 codec->field = val; \
0177 return count; \
0178 }
0179
0180 #define CODEC_INFO_STR_STORE(type, field) \
0181 static ssize_t type##_store(struct device *dev, \
0182 struct device_attribute *attr, \
0183 const char *buf, size_t count) \
0184 { \
0185 struct hda_codec *codec = dev_get_drvdata(dev); \
0186 char *s = kstrndup_noeol(buf, 64); \
0187 if (!s) \
0188 return -ENOMEM; \
0189 kfree(codec->field); \
0190 codec->field = s; \
0191 return count; \
0192 }
0193
0194 CODEC_INFO_STORE(vendor_id, core.vendor_id);
0195 CODEC_INFO_STORE(subsystem_id, core.subsystem_id);
0196 CODEC_INFO_STORE(revision_id, core.revision_id);
0197 CODEC_INFO_STR_STORE(vendor_name, core.vendor_name);
0198 CODEC_INFO_STR_STORE(chip_name, core.chip_name);
0199 CODEC_INFO_STR_STORE(modelname, modelname);
0200
0201 #define CODEC_ACTION_STORE(type) \
0202 static ssize_t type##_store(struct device *dev, \
0203 struct device_attribute *attr, \
0204 const char *buf, size_t count) \
0205 { \
0206 struct hda_codec *codec = dev_get_drvdata(dev); \
0207 int err = 0; \
0208 if (*buf) \
0209 err = type##_codec(codec); \
0210 return err < 0 ? err : count; \
0211 }
0212
0213 CODEC_ACTION_STORE(reconfig);
0214 CODEC_ACTION_STORE(clear);
0215
0216 static ssize_t init_verbs_show(struct device *dev,
0217 struct device_attribute *attr,
0218 char *buf)
0219 {
0220 struct hda_codec *codec = dev_get_drvdata(dev);
0221 const struct hda_verb *v;
0222 int i, len = 0;
0223 mutex_lock(&codec->user_mutex);
0224 snd_array_for_each(&codec->init_verbs, i, v) {
0225 len += sysfs_emit_at(buf, len, "0x%02x 0x%03x 0x%04x\n",
0226 v->nid, v->verb, v->param);
0227 }
0228 mutex_unlock(&codec->user_mutex);
0229 return len;
0230 }
0231
0232 static int parse_init_verbs(struct hda_codec *codec, const char *buf)
0233 {
0234 struct hda_verb *v;
0235 int nid, verb, param;
0236
0237 if (sscanf(buf, "%i %i %i", &nid, &verb, ¶m) != 3)
0238 return -EINVAL;
0239 if (!nid || !verb)
0240 return -EINVAL;
0241 mutex_lock(&codec->user_mutex);
0242 v = snd_array_new(&codec->init_verbs);
0243 if (!v) {
0244 mutex_unlock(&codec->user_mutex);
0245 return -ENOMEM;
0246 }
0247 v->nid = nid;
0248 v->verb = verb;
0249 v->param = param;
0250 mutex_unlock(&codec->user_mutex);
0251 return 0;
0252 }
0253
0254 static ssize_t init_verbs_store(struct device *dev,
0255 struct device_attribute *attr,
0256 const char *buf, size_t count)
0257 {
0258 struct hda_codec *codec = dev_get_drvdata(dev);
0259 int err = parse_init_verbs(codec, buf);
0260 if (err < 0)
0261 return err;
0262 return count;
0263 }
0264
0265 static ssize_t hints_show(struct device *dev,
0266 struct device_attribute *attr,
0267 char *buf)
0268 {
0269 struct hda_codec *codec = dev_get_drvdata(dev);
0270 const struct hda_hint *hint;
0271 int i, len = 0;
0272 mutex_lock(&codec->user_mutex);
0273 snd_array_for_each(&codec->hints, i, hint) {
0274 len += sysfs_emit_at(buf, len, "%s = %s\n",
0275 hint->key, hint->val);
0276 }
0277 mutex_unlock(&codec->user_mutex);
0278 return len;
0279 }
0280
0281 static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
0282 {
0283 struct hda_hint *hint;
0284 int i;
0285
0286 snd_array_for_each(&codec->hints, i, hint) {
0287 if (!strcmp(hint->key, key))
0288 return hint;
0289 }
0290 return NULL;
0291 }
0292
0293 static void remove_trail_spaces(char *str)
0294 {
0295 char *p;
0296 if (!*str)
0297 return;
0298 p = str + strlen(str) - 1;
0299 for (; isspace(*p); p--) {
0300 *p = 0;
0301 if (p == str)
0302 return;
0303 }
0304 }
0305
0306 #define MAX_HINTS 1024
0307
0308 static int parse_hints(struct hda_codec *codec, const char *buf)
0309 {
0310 char *key, *val;
0311 struct hda_hint *hint;
0312 int err = 0;
0313
0314 buf = skip_spaces(buf);
0315 if (!*buf || *buf == '#' || *buf == '\n')
0316 return 0;
0317 if (*buf == '=')
0318 return -EINVAL;
0319 key = kstrndup_noeol(buf, 1024);
0320 if (!key)
0321 return -ENOMEM;
0322
0323 val = strchr(key, '=');
0324 if (!val) {
0325 kfree(key);
0326 return -EINVAL;
0327 }
0328 *val++ = 0;
0329 val = skip_spaces(val);
0330 remove_trail_spaces(key);
0331 remove_trail_spaces(val);
0332 mutex_lock(&codec->user_mutex);
0333 hint = get_hint(codec, key);
0334 if (hint) {
0335
0336 kfree(hint->key);
0337 hint->key = key;
0338 hint->val = val;
0339 goto unlock;
0340 }
0341
0342 if (codec->hints.used >= MAX_HINTS)
0343 hint = NULL;
0344 else
0345 hint = snd_array_new(&codec->hints);
0346 if (hint) {
0347 hint->key = key;
0348 hint->val = val;
0349 } else {
0350 err = -ENOMEM;
0351 }
0352 unlock:
0353 mutex_unlock(&codec->user_mutex);
0354 if (err)
0355 kfree(key);
0356 return err;
0357 }
0358
0359 static ssize_t hints_store(struct device *dev,
0360 struct device_attribute *attr,
0361 const char *buf, size_t count)
0362 {
0363 struct hda_codec *codec = dev_get_drvdata(dev);
0364 int err = parse_hints(codec, buf);
0365 if (err < 0)
0366 return err;
0367 return count;
0368 }
0369
0370 static ssize_t user_pin_configs_show(struct device *dev,
0371 struct device_attribute *attr,
0372 char *buf)
0373 {
0374 struct hda_codec *codec = dev_get_drvdata(dev);
0375 return pin_configs_show(codec, &codec->user_pins, buf);
0376 }
0377
0378 #define MAX_PIN_CONFIGS 32
0379
0380 static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
0381 {
0382 int nid, cfg, err;
0383
0384 if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
0385 return -EINVAL;
0386 if (!nid)
0387 return -EINVAL;
0388 mutex_lock(&codec->user_mutex);
0389 err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
0390 mutex_unlock(&codec->user_mutex);
0391 return err;
0392 }
0393
0394 static ssize_t user_pin_configs_store(struct device *dev,
0395 struct device_attribute *attr,
0396 const char *buf, size_t count)
0397 {
0398 struct hda_codec *codec = dev_get_drvdata(dev);
0399 int err = parse_user_pin_configs(codec, buf);
0400 if (err < 0)
0401 return err;
0402 return count;
0403 }
0404
0405
0406 static DEVICE_ATTR_RW(init_verbs);
0407 static DEVICE_ATTR_RW(hints);
0408 static DEVICE_ATTR_RW(user_pin_configs);
0409 static DEVICE_ATTR_WO(reconfig);
0410 static DEVICE_ATTR_WO(clear);
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420 const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
0421 {
0422 struct hda_hint *hint = get_hint(codec, key);
0423 return hint ? hint->val : NULL;
0424 }
0425 EXPORT_SYMBOL_GPL(snd_hda_get_hint);
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436 int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
0437 {
0438 const char *p;
0439 int ret;
0440
0441 mutex_lock(&codec->user_mutex);
0442 p = snd_hda_get_hint(codec, key);
0443 if (!p || !*p)
0444 ret = -ENOENT;
0445 else {
0446 switch (toupper(*p)) {
0447 case 'T':
0448 case 'Y':
0449 case '1':
0450 ret = 1;
0451 break;
0452 default:
0453 ret = 0;
0454 break;
0455 }
0456 }
0457 mutex_unlock(&codec->user_mutex);
0458 return ret;
0459 }
0460 EXPORT_SYMBOL_GPL(snd_hda_get_bool_hint);
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472 int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
0473 {
0474 const char *p;
0475 unsigned long val;
0476 int ret;
0477
0478 mutex_lock(&codec->user_mutex);
0479 p = snd_hda_get_hint(codec, key);
0480 if (!p)
0481 ret = -ENOENT;
0482 else if (kstrtoul(p, 0, &val))
0483 ret = -EINVAL;
0484 else {
0485 *valp = val;
0486 ret = 0;
0487 }
0488 mutex_unlock(&codec->user_mutex);
0489 return ret;
0490 }
0491 EXPORT_SYMBOL_GPL(snd_hda_get_int_hint);
0492 #endif
0493
0494
0495
0496
0497 #ifdef CONFIG_SND_HDA_RECONFIG
0498 #define RECONFIG_DEVICE_ATTR(name) DEVICE_ATTR_RW(name)
0499 #else
0500 #define RECONFIG_DEVICE_ATTR(name) DEVICE_ATTR_RO(name)
0501 #endif
0502 static RECONFIG_DEVICE_ATTR(vendor_id);
0503 static RECONFIG_DEVICE_ATTR(subsystem_id);
0504 static RECONFIG_DEVICE_ATTR(revision_id);
0505 static DEVICE_ATTR_RO(afg);
0506 static DEVICE_ATTR_RO(mfg);
0507 static RECONFIG_DEVICE_ATTR(vendor_name);
0508 static RECONFIG_DEVICE_ATTR(chip_name);
0509 static RECONFIG_DEVICE_ATTR(modelname);
0510 static DEVICE_ATTR_RO(init_pin_configs);
0511 static DEVICE_ATTR_RO(driver_pin_configs);
0512
0513
0514 #ifdef CONFIG_SND_HDA_PATCH_LOADER
0515
0516
0517 enum {
0518 LINE_MODE_NONE,
0519 LINE_MODE_CODEC,
0520 LINE_MODE_MODEL,
0521 LINE_MODE_PINCFG,
0522 LINE_MODE_VERB,
0523 LINE_MODE_HINT,
0524 LINE_MODE_VENDOR_ID,
0525 LINE_MODE_SUBSYSTEM_ID,
0526 LINE_MODE_REVISION_ID,
0527 LINE_MODE_CHIP_NAME,
0528 NUM_LINE_MODES,
0529 };
0530
0531 static inline int strmatch(const char *a, const char *b)
0532 {
0533 return strncasecmp(a, b, strlen(b)) == 0;
0534 }
0535
0536
0537
0538
0539 static void parse_codec_mode(char *buf, struct hda_bus *bus,
0540 struct hda_codec **codecp)
0541 {
0542 int vendorid, subid, caddr;
0543 struct hda_codec *codec;
0544
0545 *codecp = NULL;
0546 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
0547 list_for_each_codec(codec, bus) {
0548 if ((vendorid <= 0 || codec->core.vendor_id == vendorid) &&
0549 (subid <= 0 || codec->core.subsystem_id == subid) &&
0550 codec->core.addr == caddr) {
0551 *codecp = codec;
0552 break;
0553 }
0554 }
0555 }
0556 }
0557
0558
0559
0560
0561
0562 static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
0563 struct hda_codec **codecp)
0564 {
0565 parse_user_pin_configs(*codecp, buf);
0566 }
0567
0568 static void parse_verb_mode(char *buf, struct hda_bus *bus,
0569 struct hda_codec **codecp)
0570 {
0571 parse_init_verbs(*codecp, buf);
0572 }
0573
0574 static void parse_hint_mode(char *buf, struct hda_bus *bus,
0575 struct hda_codec **codecp)
0576 {
0577 parse_hints(*codecp, buf);
0578 }
0579
0580 static void parse_model_mode(char *buf, struct hda_bus *bus,
0581 struct hda_codec **codecp)
0582 {
0583 kfree((*codecp)->modelname);
0584 (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
0585 }
0586
0587 static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
0588 struct hda_codec **codecp)
0589 {
0590 snd_hda_codec_set_name(*codecp, buf);
0591 }
0592
0593 #define DEFINE_PARSE_ID_MODE(name) \
0594 static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
0595 struct hda_codec **codecp) \
0596 { \
0597 unsigned long val; \
0598 if (!kstrtoul(buf, 0, &val)) \
0599 (*codecp)->core.name = val; \
0600 }
0601
0602 DEFINE_PARSE_ID_MODE(vendor_id);
0603 DEFINE_PARSE_ID_MODE(subsystem_id);
0604 DEFINE_PARSE_ID_MODE(revision_id);
0605
0606
0607 struct hda_patch_item {
0608 const char *tag;
0609 const char *alias;
0610 void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
0611 };
0612
0613 static const struct hda_patch_item patch_items[NUM_LINE_MODES] = {
0614 [LINE_MODE_CODEC] = {
0615 .tag = "[codec]",
0616 .parser = parse_codec_mode,
0617 },
0618 [LINE_MODE_MODEL] = {
0619 .tag = "[model]",
0620 .parser = parse_model_mode,
0621 },
0622 [LINE_MODE_VERB] = {
0623 .tag = "[verb]",
0624 .alias = "[init_verbs]",
0625 .parser = parse_verb_mode,
0626 },
0627 [LINE_MODE_PINCFG] = {
0628 .tag = "[pincfg]",
0629 .alias = "[user_pin_configs]",
0630 .parser = parse_pincfg_mode,
0631 },
0632 [LINE_MODE_HINT] = {
0633 .tag = "[hint]",
0634 .alias = "[hints]",
0635 .parser = parse_hint_mode
0636 },
0637 [LINE_MODE_VENDOR_ID] = {
0638 .tag = "[vendor_id]",
0639 .parser = parse_vendor_id_mode,
0640 },
0641 [LINE_MODE_SUBSYSTEM_ID] = {
0642 .tag = "[subsystem_id]",
0643 .parser = parse_subsystem_id_mode,
0644 },
0645 [LINE_MODE_REVISION_ID] = {
0646 .tag = "[revision_id]",
0647 .parser = parse_revision_id_mode,
0648 },
0649 [LINE_MODE_CHIP_NAME] = {
0650 .tag = "[chip_name]",
0651 .parser = parse_chip_name_mode,
0652 },
0653 };
0654
0655
0656 static int parse_line_mode(char *buf, struct hda_bus *bus)
0657 {
0658 int i;
0659 for (i = 0; i < ARRAY_SIZE(patch_items); i++) {
0660 if (!patch_items[i].tag)
0661 continue;
0662 if (strmatch(buf, patch_items[i].tag))
0663 return i;
0664 if (patch_items[i].alias && strmatch(buf, patch_items[i].alias))
0665 return i;
0666 }
0667 return LINE_MODE_NONE;
0668 }
0669
0670
0671
0672
0673
0674
0675
0676 static int get_line_from_fw(char *buf, int size, size_t *fw_size_p,
0677 const void **fw_data_p)
0678 {
0679 int len;
0680 size_t fw_size = *fw_size_p;
0681 const char *p = *fw_data_p;
0682
0683 while (isspace(*p) && fw_size) {
0684 p++;
0685 fw_size--;
0686 }
0687 if (!fw_size)
0688 return 0;
0689
0690 for (len = 0; len < fw_size; len++) {
0691 if (!*p)
0692 break;
0693 if (*p == '\n') {
0694 p++;
0695 len++;
0696 break;
0697 }
0698 if (len < size)
0699 *buf++ = *p++;
0700 }
0701 *buf = 0;
0702 *fw_size_p = fw_size - len;
0703 *fw_data_p = p;
0704 remove_trail_spaces(buf);
0705 return 1;
0706 }
0707
0708
0709
0710
0711
0712
0713
0714 int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
0715 {
0716 char buf[128];
0717 struct hda_codec *codec;
0718 int line_mode;
0719
0720 line_mode = LINE_MODE_NONE;
0721 codec = NULL;
0722 while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
0723 if (!*buf || *buf == '#' || *buf == '\n')
0724 continue;
0725 if (*buf == '[')
0726 line_mode = parse_line_mode(buf, bus);
0727 else if (patch_items[line_mode].parser &&
0728 (codec || line_mode <= LINE_MODE_CODEC))
0729 patch_items[line_mode].parser(buf, bus, &codec);
0730 }
0731 return 0;
0732 }
0733 EXPORT_SYMBOL_GPL(snd_hda_load_patch);
0734 #endif
0735
0736
0737
0738
0739 static struct attribute *hda_dev_attrs[] = {
0740 &dev_attr_vendor_id.attr,
0741 &dev_attr_subsystem_id.attr,
0742 &dev_attr_revision_id.attr,
0743 &dev_attr_afg.attr,
0744 &dev_attr_mfg.attr,
0745 &dev_attr_vendor_name.attr,
0746 &dev_attr_chip_name.attr,
0747 &dev_attr_modelname.attr,
0748 &dev_attr_init_pin_configs.attr,
0749 &dev_attr_driver_pin_configs.attr,
0750 #ifdef CONFIG_PM
0751 &dev_attr_power_on_acct.attr,
0752 &dev_attr_power_off_acct.attr,
0753 #endif
0754 #ifdef CONFIG_SND_HDA_RECONFIG
0755 &dev_attr_init_verbs.attr,
0756 &dev_attr_hints.attr,
0757 &dev_attr_user_pin_configs.attr,
0758 &dev_attr_reconfig.attr,
0759 &dev_attr_clear.attr,
0760 #endif
0761 NULL
0762 };
0763
0764 static const struct attribute_group hda_dev_attr_group = {
0765 .attrs = hda_dev_attrs,
0766 };
0767
0768 const struct attribute_group *snd_hda_dev_attr_groups[] = {
0769 &hda_dev_attr_group,
0770 NULL
0771 };
0772
0773 void snd_hda_sysfs_init(struct hda_codec *codec)
0774 {
0775 mutex_init(&codec->user_mutex);
0776 #ifdef CONFIG_SND_HDA_RECONFIG
0777 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
0778 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
0779 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
0780 #endif
0781 }
0782
0783 void snd_hda_sysfs_clear(struct hda_codec *codec)
0784 {
0785 #ifdef CONFIG_SND_HDA_RECONFIG
0786 struct hda_hint *hint;
0787 int i;
0788
0789
0790 snd_array_free(&codec->init_verbs);
0791
0792 snd_array_for_each(&codec->hints, i, hint) {
0793 kfree(hint->key);
0794 }
0795 snd_array_free(&codec->hints);
0796 snd_array_free(&codec->user_pins);
0797 #endif
0798 }