158
#ifdef CONFIG_SND_HDA_POWER_SAVE
159
static ssize_t power_on_acct_show(struct device *dev,
160
struct device_attribute *attr,
163
struct snd_hwdep *hwdep = dev_get_drvdata(dev);
164
struct hda_codec *codec = hwdep->private_data;
165
snd_hda_update_power_acct(codec);
166
return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
169
static ssize_t power_off_acct_show(struct device *dev,
170
struct device_attribute *attr,
173
struct snd_hwdep *hwdep = dev_get_drvdata(dev);
174
struct hda_codec *codec = hwdep->private_data;
175
snd_hda_update_power_acct(codec);
176
return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
179
static struct device_attribute power_attrs[] = {
180
__ATTR_RO(power_on_acct),
181
__ATTR_RO(power_off_acct),
184
int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
186
struct snd_hwdep *hwdep = codec->hwdep;
189
for (i = 0; i < ARRAY_SIZE(power_attrs); i++)
190
snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
191
hwdep->device, &power_attrs[i]);
194
#endif /* CONFIG_SND_HDA_POWER_SAVE */
157
196
#ifdef CONFIG_SND_HDA_RECONFIG
616
662
/* parse the contents after the other command tags, [pincfg], [verb],
663
* [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model]
618
664
* just pass to the sysfs helper (only when any codec was specified)
620
666
static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
621
667
struct hda_codec **codecp)
625
669
parse_user_pin_configs(*codecp, buf);
628
672
static void parse_verb_mode(char *buf, struct hda_bus *bus,
629
673
struct hda_codec **codecp)
633
675
parse_init_verbs(*codecp, buf);
636
678
static void parse_hint_mode(char *buf, struct hda_bus *bus,
637
679
struct hda_codec **codecp)
641
681
parse_hints(*codecp, buf);
644
684
static void parse_model_mode(char *buf, struct hda_bus *bus,
645
685
struct hda_codec **codecp)
649
687
kfree((*codecp)->modelname);
650
688
(*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
691
static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
692
struct hda_codec **codecp)
694
kfree((*codecp)->chip_name);
695
(*codecp)->chip_name = kstrdup(buf, GFP_KERNEL);
698
#define DEFINE_PARSE_ID_MODE(name) \
699
static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
700
struct hda_codec **codecp) \
703
if (!strict_strtoul(buf, 0, &val)) \
704
(*codecp)->name = val; \
707
DEFINE_PARSE_ID_MODE(vendor_id);
708
DEFINE_PARSE_ID_MODE(subsystem_id);
709
DEFINE_PARSE_ID_MODE(revision_id);
653
712
struct hda_patch_item {
655
714
void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
658
718
static struct hda_patch_item patch_items[NUM_LINE_MODES] = {
659
[LINE_MODE_CODEC] = { "[codec]", parse_codec_mode },
660
[LINE_MODE_MODEL] = { "[model]", parse_model_mode },
661
[LINE_MODE_VERB] = { "[verb]", parse_verb_mode },
662
[LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode },
663
[LINE_MODE_HINT] = { "[hint]", parse_hint_mode },
719
[LINE_MODE_CODEC] = { "[codec]", parse_codec_mode, 0 },
720
[LINE_MODE_MODEL] = { "[model]", parse_model_mode, 1 },
721
[LINE_MODE_VERB] = { "[verb]", parse_verb_mode, 1 },
722
[LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode, 1 },
723
[LINE_MODE_HINT] = { "[hint]", parse_hint_mode, 1 },
724
[LINE_MODE_VENDOR_ID] = { "[vendor_id]", parse_vendor_id_mode, 1 },
725
[LINE_MODE_SUBSYSTEM_ID] = { "[subsystem_id]", parse_subsystem_id_mode, 1 },
726
[LINE_MODE_REVISION_ID] = { "[revision_id]", parse_revision_id_mode, 1 },
727
[LINE_MODE_CHIP_NAME] = { "[chip_name]", parse_chip_name_mode, 1 },
666
730
/* check the line starting with '[' -- change the parser mode accodingly */