Commit 7639a06c authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Move a part of hda_codec stuff into hdac_device

Now some codes and functionalities of hda_codec struct are moved to
hdac_device struct.  A few basic attributes like the codec address,
vendor ID number, FG numbers, etc are moved to hdac_device, and they
are accessed like codec->core.addr.  The basic verb exec functions are
moved, too.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d068ebc2
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include <linux/device.h> #include <linux/device.h>
#include <sound/hda_verbs.h> #include <sound/hda_verbs.h>
/* codec node id */
typedef u16 hda_nid_t;
struct hdac_bus; struct hdac_bus;
struct hdac_device; struct hdac_device;
struct hdac_driver; struct hdac_driver;
...@@ -26,6 +29,30 @@ struct hdac_device { ...@@ -26,6 +29,30 @@ struct hdac_device {
struct hdac_bus *bus; struct hdac_bus *bus;
unsigned int addr; /* codec address */ unsigned int addr; /* codec address */
struct list_head list; /* list point for bus codec_list */ struct list_head list; /* list point for bus codec_list */
hda_nid_t afg; /* AFG node id */
hda_nid_t mfg; /* MFG node id */
/* ids */
unsigned int vendor_id;
unsigned int subsystem_id;
unsigned int revision_id;
unsigned int afg_function_id;
unsigned int mfg_function_id;
unsigned int afg_unsol:1;
unsigned int mfg_unsol:1;
unsigned int power_caps; /* FG power caps */
const char *vendor_name; /* codec vendor name */
const char *chip_name; /* codec chip name */
/* widgets */
unsigned int num_nodes;
hda_nid_t start_nid, end_nid;
/* misc flags */
atomic_t in_pm; /* suspend/resume being performed */
}; };
/* device/driver type used for matching */ /* device/driver type used for matching */
...@@ -34,8 +61,37 @@ enum { ...@@ -34,8 +61,37 @@ enum {
HDA_DEV_LEGACY, HDA_DEV_LEGACY,
}; };
/* direction */
enum {
HDA_INPUT, HDA_OUTPUT
};
#define dev_to_hdac_dev(_dev) container_of(_dev, struct hdac_device, dev) #define dev_to_hdac_dev(_dev) container_of(_dev, struct hdac_device, dev)
int snd_hdac_device_init(struct hdac_device *dev, struct hdac_bus *bus,
const char *name, unsigned int addr);
void snd_hdac_device_exit(struct hdac_device *dev);
int snd_hdac_refresh_widgets(struct hdac_device *codec);
unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid,
unsigned int verb, unsigned int parm);
int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid,
unsigned int verb, unsigned int parm, unsigned int *res);
int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm);
int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid,
hda_nid_t *conn_list, int max_conns);
int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid,
hda_nid_t *start_id);
#ifdef CONFIG_PM
void snd_hdac_power_up(struct hdac_device *codec);
void snd_hdac_power_down(struct hdac_device *codec);
#else
static inline void snd_hdac_power_up(struct hdac_device *codec) {}
static inline void snd_hdac_power_down(struct hdac_device *codec) {}
#endif
/* /*
* HD-audio codec base driver * HD-audio codec base driver
*/ */
...@@ -100,4 +156,14 @@ int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec); ...@@ -100,4 +156,14 @@ int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec);
void snd_hdac_bus_remove_device(struct hdac_bus *bus, void snd_hdac_bus_remove_device(struct hdac_bus *bus,
struct hdac_device *codec); struct hdac_device *codec);
static inline void snd_hdac_codec_link_up(struct hdac_device *codec)
{
set_bit(codec->addr, &codec->bus->codec_powered);
}
static inline void snd_hdac_codec_link_down(struct hdac_device *codec)
{
clear_bit(codec->addr, &codec->bus->codec_powered);
}
#endif /* __SOUND_HDAUDIO_H */ #endif /* __SOUND_HDAUDIO_H */
snd-hda-core-objs := hda_bus_type.o hdac_bus.o snd-hda-core-objs := hda_bus_type.o hdac_bus.o hdac_device.o
obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
This diff is collapsed.
/*
* Local helper macros and functions for HD-audio core drivers
*/
#ifndef __HDAC_LOCAL_H
#define __HDAC_LOCAL_H
#define get_wcaps(codec, nid) \
snd_hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
/* get the widget type from widget capability bits */
static inline int get_wcaps_type(unsigned int wcaps)
{
if (!wcaps)
return -1; /* invalid type */
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
}
#endif /* __HDAC_LOCAL_H */
...@@ -172,7 +172,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, ...@@ -172,7 +172,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
const hda_nid_t *ignore_nids, const hda_nid_t *ignore_nids,
unsigned int cond_flags) unsigned int cond_flags)
{ {
hda_nid_t nid, end_nid; hda_nid_t nid;
short seq, assoc_line_out; short seq, assoc_line_out;
struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)]; struct auto_out_pin line_out[ARRAY_SIZE(cfg->line_out_pins)];
struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)]; struct auto_out_pin speaker_out[ARRAY_SIZE(cfg->speaker_pins)];
...@@ -189,8 +189,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, ...@@ -189,8 +189,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
memset(hp_out, 0, sizeof(hp_out)); memset(hp_out, 0, sizeof(hp_out));
assoc_line_out = 0; assoc_line_out = 0;
end_nid = codec->start_nid + codec->num_nodes; for_each_hda_codec_node(nid, codec) {
for (nid = codec->start_nid; nid < end_nid; nid++) {
unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_caps = get_wcaps(codec, nid);
unsigned int wid_type = get_wcaps_type(wid_caps); unsigned int wid_type = get_wcaps_type(wid_caps);
unsigned int def_conf; unsigned int def_conf;
...@@ -410,7 +409,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, ...@@ -410,7 +409,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
* debug prints of the parsed results * debug prints of the parsed results
*/ */
codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", codec_info(codec, "autoconfig for %s: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
codec->chip_name, cfg->line_outs, cfg->line_out_pins[0], codec->core.chip_name, cfg->line_outs, cfg->line_out_pins[0],
cfg->line_out_pins[1], cfg->line_out_pins[2], cfg->line_out_pins[1], cfg->line_out_pins[2],
cfg->line_out_pins[3], cfg->line_out_pins[4], cfg->line_out_pins[3], cfg->line_out_pins[4],
cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" :
...@@ -836,33 +835,33 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth) ...@@ -836,33 +835,33 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins)
break; break;
codec_dbg(codec, "%s: Apply pincfg for %s\n", codec_dbg(codec, "%s: Apply pincfg for %s\n",
codec->chip_name, modelname); codec->core.chip_name, modelname);
snd_hda_apply_pincfgs(codec, fix->v.pins); snd_hda_apply_pincfgs(codec, fix->v.pins);
break; break;
case HDA_FIXUP_VERBS: case HDA_FIXUP_VERBS:
if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs)
break; break;
codec_dbg(codec, "%s: Apply fix-verbs for %s\n", codec_dbg(codec, "%s: Apply fix-verbs for %s\n",
codec->chip_name, modelname); codec->core.chip_name, modelname);
snd_hda_add_verbs(codec, fix->v.verbs); snd_hda_add_verbs(codec, fix->v.verbs);
break; break;
case HDA_FIXUP_FUNC: case HDA_FIXUP_FUNC:
if (!fix->v.func) if (!fix->v.func)
break; break;
codec_dbg(codec, "%s: Apply fix-func for %s\n", codec_dbg(codec, "%s: Apply fix-func for %s\n",
codec->chip_name, modelname); codec->core.chip_name, modelname);
fix->v.func(codec, fix, action); fix->v.func(codec, fix, action);
break; break;
case HDA_FIXUP_PINCTLS: case HDA_FIXUP_PINCTLS:
if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins) if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins)
break; break;
codec_dbg(codec, "%s: Apply pinctl for %s\n", codec_dbg(codec, "%s: Apply pinctl for %s\n",
codec->chip_name, modelname); codec->core.chip_name, modelname);
set_pin_targets(codec, fix->v.pins); set_pin_targets(codec, fix->v.pins);
break; break;
default: default:
codec_err(codec, "%s: Invalid fixup type %d\n", codec_err(codec, "%s: Invalid fixup type %d\n",
codec->chip_name, fix->type); codec->core.chip_name, fix->type);
break; break;
} }
if (!fix->chained || fix->chained_before) if (!fix->chained || fix->chained_before)
...@@ -912,16 +911,16 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec, ...@@ -912,16 +911,16 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
return; return;
for (pq = pin_quirk; pq->subvendor; pq++) { for (pq = pin_quirk; pq->subvendor; pq++) {
if ((codec->subsystem_id & 0xffff0000) != (pq->subvendor << 16)) if ((codec->core.subsystem_id & 0xffff0000) != (pq->subvendor << 16))
continue; continue;
if (codec->vendor_id != pq->codec) if (codec->core.vendor_id != pq->codec)
continue; continue;
if (pin_config_match(codec, pq->pins)) { if (pin_config_match(codec, pq->pins)) {
codec->fixup_id = pq->value; codec->fixup_id = pq->value;
#ifdef CONFIG_SND_DEBUG_VERBOSE #ifdef CONFIG_SND_DEBUG_VERBOSE
codec->fixup_name = pq->name; codec->fixup_name = pq->name;
codec_dbg(codec, "%s: picked fixup %s (pin match)\n", codec_dbg(codec, "%s: picked fixup %s (pin match)\n",
codec->chip_name, codec->fixup_name); codec->core.chip_name, codec->fixup_name);
#endif #endif
codec->fixup_list = fixlist; codec->fixup_list = fixlist;
return; return;
...@@ -963,7 +962,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -963,7 +962,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
codec->fixup_name = NULL; codec->fixup_name = NULL;
codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP; codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP;
codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n",
codec->chip_name); codec->core.chip_name);
return; return;
} }
...@@ -974,7 +973,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -974,7 +973,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
codec->fixup_name = models->name; codec->fixup_name = models->name;
codec->fixup_list = fixlist; codec->fixup_list = fixlist;
codec_dbg(codec, "%s: picked fixup %s (model specified)\n", codec_dbg(codec, "%s: picked fixup %s (model specified)\n",
codec->chip_name, codec->fixup_name); codec->core.chip_name, codec->fixup_name);
return; return;
} }
models++; models++;
...@@ -987,7 +986,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -987,7 +986,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
#ifdef CONFIG_SND_DEBUG_VERBOSE #ifdef CONFIG_SND_DEBUG_VERBOSE
name = q->name; name = q->name;
codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n", codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n",
codec->chip_name, name, q->subdevice_mask ? "" : " - vendor generic"); codec->core.chip_name, name, q->subdevice_mask ? "" : " - vendor generic");
#endif #endif
} }
} }
...@@ -996,12 +995,12 @@ void snd_hda_pick_fixup(struct hda_codec *codec, ...@@ -996,12 +995,12 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
unsigned int vendorid = unsigned int vendorid =
q->subdevice | (q->subvendor << 16); q->subdevice | (q->subvendor << 16);
unsigned int mask = 0xffff0000 | q->subdevice_mask; unsigned int mask = 0xffff0000 | q->subdevice_mask;
if ((codec->subsystem_id & mask) == (vendorid & mask)) { if ((codec->core.subsystem_id & mask) == (vendorid & mask)) {
id = q->value; id = q->value;
#ifdef CONFIG_SND_DEBUG_VERBOSE #ifdef CONFIG_SND_DEBUG_VERBOSE
name = q->name; name = q->name;
codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n", codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n",
codec->chip_name, name); codec->core.chip_name, name);
#endif #endif
break; break;
} }
......
...@@ -165,8 +165,8 @@ static int snd_hda_do_attach(struct hda_beep *beep) ...@@ -165,8 +165,8 @@ static int snd_hda_do_attach(struct hda_beep *beep)
input_dev->id.bustype = BUS_PCI; input_dev->id.bustype = BUS_PCI;
input_dev->dev.parent = &codec->card->card_dev; input_dev->dev.parent = &codec->card->card_dev;
input_dev->id.vendor = codec->vendor_id >> 16; input_dev->id.vendor = codec->core.vendor_id >> 16;
input_dev->id.product = codec->vendor_id & 0xffff; input_dev->id.product = codec->core.vendor_id & 0xffff;
input_dev->id.version = 0x01; input_dev->id.version = 0x01;
input_dev->evbit[0] = BIT_MASK(EV_SND); input_dev->evbit[0] = BIT_MASK(EV_SND);
......
...@@ -14,36 +14,6 @@ ...@@ -14,36 +14,6 @@
#include "hda_codec.h" #include "hda_codec.h"
#include "hda_local.h" #include "hda_local.h"
/* codec vendor labels */
struct hda_vendor_id {
unsigned int id;
const char *name;
};
static struct hda_vendor_id hda_vendor_ids[] = {
{ 0x1002, "ATI" },
{ 0x1013, "Cirrus Logic" },
{ 0x1057, "Motorola" },
{ 0x1095, "Silicon Image" },
{ 0x10de, "Nvidia" },
{ 0x10ec, "Realtek" },
{ 0x1102, "Creative" },
{ 0x1106, "VIA" },
{ 0x111d, "IDT" },
{ 0x11c1, "LSI" },
{ 0x11d4, "Analog Devices" },
{ 0x13f6, "C-Media" },
{ 0x14f1, "Conexant" },
{ 0x17e8, "Chrontel" },
{ 0x1854, "LG" },
{ 0x1aec, "Wolfson Microelectronics" },
{ 0x1af4, "QEMU" },
{ 0x434d, "C-Media" },
{ 0x8086, "Intel" },
{ 0x8384, "SigmaTel" },
{} /* terminator */
};
/* /*
* find a matching codec preset * find a matching codec preset
*/ */
...@@ -54,19 +24,19 @@ static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv) ...@@ -54,19 +24,19 @@ static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
container_of(drv, struct hda_codec_driver, core); container_of(drv, struct hda_codec_driver, core);
const struct hda_codec_preset *preset; const struct hda_codec_preset *preset;
/* check probe_id instead of vendor_id if set */ /* check probe_id instead of vendor_id if set */
u32 id = codec->probe_id ? codec->probe_id : codec->vendor_id; u32 id = codec->probe_id ? codec->probe_id : codec->core.vendor_id;
for (preset = driver->preset; preset->id; preset++) { for (preset = driver->preset; preset->id; preset++) {
u32 mask = preset->mask; u32 mask = preset->mask;
if (preset->afg && preset->afg != codec->afg) if (preset->afg && preset->afg != codec->core.afg)
continue; continue;
if (preset->mfg && preset->mfg != codec->mfg) if (preset->mfg && preset->mfg != codec->core.mfg)
continue; continue;
if (!mask) if (!mask)
mask = ~0; mask = ~0;
if (preset->id == (id & mask) && if (preset->id == (id & mask) &&
(!preset->rev || preset->rev == codec->revision_id)) { (!preset->rev || preset->rev == codec->core.revision_id)) {
codec->preset = preset; codec->preset = preset;
return 1; return 1;
} }
...@@ -86,15 +56,11 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev) ...@@ -86,15 +56,11 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)
/* reset the codec name from the preset */ /* reset the codec name from the preset */
static int codec_refresh_name(struct hda_codec *codec, const char *name) static int codec_refresh_name(struct hda_codec *codec, const char *name)
{ {
char tmp[16]; if (name) {
kfree(codec->core.chip_name);
kfree(codec->chip_name); codec->core.chip_name = kstrdup(name, GFP_KERNEL);
if (!name) {
sprintf(tmp, "ID %x", codec->vendor_id & 0xffff);
name = tmp;
} }
codec->chip_name = kstrdup(name, GFP_KERNEL); return codec->core.chip_name ? 0 : -ENOMEM;
return codec->chip_name ? 0 : -ENOMEM;
} }
static int hda_codec_driver_probe(struct device *dev) static int hda_codec_driver_probe(struct device *dev)
...@@ -192,48 +158,23 @@ static inline bool codec_probed(struct hda_codec *codec) ...@@ -192,48 +158,23 @@ static inline bool codec_probed(struct hda_codec *codec)
static void codec_bind_module(struct hda_codec *codec) static void codec_bind_module(struct hda_codec *codec)
{ {
#ifdef MODULE #ifdef MODULE
request_module("snd-hda-codec-id:%08x", codec->vendor_id); request_module("snd-hda-codec-id:%08x", codec->core.vendor_id);
if (codec_probed(codec)) if (codec_probed(codec))
return; return;
request_module("snd-hda-codec-id:%04x*", request_module("snd-hda-codec-id:%04x*",
(codec->vendor_id >> 16) & 0xffff); (codec->core.vendor_id >> 16) & 0xffff);
if (codec_probed(codec)) if (codec_probed(codec))
return; return;
#endif #endif
} }
/* store the codec vendor name */
static int get_codec_vendor_name(struct hda_codec *codec)
{
const struct hda_vendor_id *c;
const char *vendor = NULL;
u16 vendor_id = codec->vendor_id >> 16;
char tmp[16];
for (c = hda_vendor_ids; c->id; c++) {
if (c->id == vendor_id) {
vendor = c->name;
break;
}
}
if (!vendor) {
sprintf(tmp, "Generic %04x", vendor_id);
vendor = tmp;
}
codec->vendor_name = kstrdup(vendor, GFP_KERNEL);
if (!codec->vendor_name)
return -ENOMEM;
return 0;
}
#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) #if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */ /* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
static bool is_likely_hdmi_codec(struct hda_codec *codec) static bool is_likely_hdmi_codec(struct hda_codec *codec)
{ {
hda_nid_t nid = codec->start_nid; hda_nid_t nid;
int i;
for (i = 0; i < codec->num_nodes; i++, nid++) { for_each_hda_codec_node(nid, codec) {
unsigned int wcaps = get_wcaps(codec, nid); unsigned int wcaps = get_wcaps(codec, nid);
switch (get_wcaps_type(wcaps)) { switch (get_wcaps_type(wcaps)) {
case AC_WID_AUD_IN: case AC_WID_AUD_IN:
...@@ -294,12 +235,6 @@ int snd_hda_codec_configure(struct hda_codec *codec) ...@@ -294,12 +235,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
{ {
int err; int err;
if (!codec->vendor_name) {
err = get_codec_vendor_name(codec);
if (err < 0)
return err;
}
if (is_generic_config(codec)) if (is_generic_config(codec))
codec->probe_id = HDA_CODEC_ID_GENERIC; codec->probe_id = HDA_CODEC_ID_GENERIC;
else else
...@@ -320,10 +255,10 @@ int snd_hda_codec_configure(struct hda_codec *codec) ...@@ -320,10 +255,10 @@ int snd_hda_codec_configure(struct hda_codec *codec)
} }
/* audio codec should override the mixer name */ /* audio codec should override the mixer name */
if (codec->afg || !*codec->card->mixername) if (codec->core.afg || !*codec->card->mixername)
snprintf(codec->card->mixername, snprintf(codec->card->mixername,
sizeof(codec->card->mixername), sizeof(codec->card->mixername), "%s %s",
"%s %s", codec->vendor_name, codec->chip_name); codec->core.vendor_name, codec->core.chip_name);
return 0; return 0;
error: error:
......
This diff is collapsed.
...@@ -261,24 +261,10 @@ struct hda_codec { ...@@ -261,24 +261,10 @@ struct hda_codec {
struct hda_bus *bus; struct hda_bus *bus;
struct snd_card *card; struct snd_card *card;
unsigned int addr; /* codec addr*/ unsigned int addr; /* codec addr*/
hda_nid_t afg; /* AFG node id */
hda_nid_t mfg; /* MFG node id */
/* ids */
u8 afg_function_id;
u8 mfg_function_id;
u8 afg_unsol;
u8 mfg_unsol;
u32 vendor_id;
u32 subsystem_id;
u32 revision_id;
u32 probe_id; /* overridden id for probing */ u32 probe_id; /* overridden id for probing */
/* detected preset */ /* detected preset */
const struct hda_codec_preset *preset; const struct hda_codec_preset *preset;
const char *vendor_name; /* codec vendor name */
const char *chip_name; /* codec chip name */
const char *modelname; /* model name for preset */ const char *modelname; /* model name for preset */
/* set by patch */ /* set by patch */
...@@ -295,8 +281,6 @@ struct hda_codec { ...@@ -295,8 +281,6 @@ struct hda_codec {
unsigned int beep_mode; unsigned int beep_mode;
/* widget capabilities cache */ /* widget capabilities cache */
unsigned int num_nodes;
hda_nid_t start_nid;
u32 *wcaps; u32 *wcaps;
struct snd_array mixers; /* list of assigned mixer elements */ struct snd_array mixers; /* list of assigned mixer elements */
...@@ -347,14 +331,11 @@ struct hda_codec { ...@@ -347,14 +331,11 @@ struct hda_codec {
unsigned int inv_eapd:1; /* broken h/w: inverted EAPD control */ unsigned int inv_eapd:1; /* broken h/w: inverted EAPD control */
unsigned int inv_jack_detect:1; /* broken h/w: inverted detection bit */ unsigned int inv_jack_detect:1; /* broken h/w: inverted detection bit */
unsigned int pcm_format_first:1; /* PCM format must be set first */ unsigned int pcm_format_first:1; /* PCM format must be set first */
unsigned int epss:1; /* supporting EPSS? */
unsigned int cached_write:1; /* write only to caches */ unsigned int cached_write:1; /* write only to caches */
unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */ unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */
unsigned int dump_coef:1; /* dump processing coefs in codec proc file */ unsigned int dump_coef:1; /* dump processing coefs in codec proc file */
unsigned int power_save_node:1; /* advanced PM for each widget */ unsigned int power_save_node:1; /* advanced PM for each widget */
#ifdef CONFIG_PM #ifdef CONFIG_PM
unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
atomic_t in_pm; /* suspend/resume being performed */
unsigned long power_on_acct; unsigned long power_on_acct;
unsigned long power_off_acct; unsigned long power_off_acct;
unsigned long power_jiffies; unsigned long power_jiffies;
...@@ -395,11 +376,6 @@ struct hda_codec { ...@@ -395,11 +376,6 @@ struct hda_codec {
#define list_for_each_codec(c, bus) \ #define list_for_each_codec(c, bus) \
list_for_each_entry(c, &(bus)->core.codec_list, core.list) list_for_each_entry(c, &(bus)->core.codec_list, core.list)
/* direction */
enum {
HDA_INPUT, HDA_OUTPUT
};
/* snd_hda_codec_read/write optional flags */ /* snd_hda_codec_read/write optional flags */
#define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0) #define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0)
...@@ -422,8 +398,8 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, ...@@ -422,8 +398,8 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
unsigned int verb, unsigned int parm); unsigned int verb, unsigned int parm);
#define snd_hda_param_read(codec, nid, param) \ #define snd_hda_param_read(codec, nid, param) \
snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param) snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)
int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, #define snd_hda_get_sub_nodes(codec, nid, start_nid) \
hda_nid_t *start_id); snd_hdac_get_sub_nodes(&(codec)->core, nid, start_nid)
int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
hda_nid_t *conn_list, int max_conns); hda_nid_t *conn_list, int max_conns);
static inline int static inline int
...@@ -431,9 +407,12 @@ snd_hda_get_num_conns(struct hda_codec *codec, hda_nid_t nid) ...@@ -431,9 +407,12 @@ snd_hda_get_num_conns(struct hda_codec *codec, hda_nid_t nid)
{ {
return snd_hda_get_connections(codec, nid, NULL, 0); return snd_hda_get_connections(codec, nid, NULL, 0);
} }
int snd_hda_get_num_raw_conns(struct hda_codec *codec, hda_nid_t nid);
int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid, #define snd_hda_get_raw_connections(codec, nid, list, max_conns) \
hda_nid_t *conn_list, int max_conns); snd_hdac_get_connections(&(codec)->core, nid, list, max_conns)
#define snd_hda_get_num_raw_conns(codec, nid) \
snd_hdac_get_connections(&(codec)->core, nid, NULL, 0);
int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid, int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid,
const hda_nid_t **listp); const hda_nid_t **listp);
int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums, int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums,
...@@ -582,14 +561,12 @@ const char *snd_hda_get_jack_location(u32 cfg); ...@@ -582,14 +561,12 @@ const char *snd_hda_get_jack_location(u32 cfg);
/* /*
* power saving * power saving
*/ */
#define snd_hda_power_up(codec) snd_hdac_power_up(&(codec)->core)
#define snd_hda_power_down(codec) snd_hdac_power_down(&(codec)->core)
#ifdef CONFIG_PM #ifdef CONFIG_PM
void snd_hda_power_up(struct hda_codec *codec);
void snd_hda_power_down(struct hda_codec *codec);
void snd_hda_set_power_save(struct hda_bus *bus, int delay); void snd_hda_set_power_save(struct hda_bus *bus, int delay);
void snd_hda_update_power_acct(struct hda_codec *codec); void snd_hda_update_power_acct(struct hda_codec *codec);
#else #else
static inline void snd_hda_power_up(struct hda_codec *codec) {}
static inline void snd_hda_power_down(struct hda_codec *codec) {}
static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {} static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
#endif #endif
......
...@@ -654,7 +654,7 @@ static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, ...@@ -654,7 +654,7 @@ static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid,
int type = get_wcaps_type(get_wcaps(codec, nid)); int type = get_wcaps_type(get_wcaps(codec, nid));
int i, n; int i, n;
if (nid == codec->afg) if (nid == codec->core.afg)
return true; return true;
for (n = 0; n < spec->paths.used; n++) { for (n = 0; n < spec->paths.used; n++) {
...@@ -832,7 +832,7 @@ static hda_nid_t path_power_update(struct hda_codec *codec, ...@@ -832,7 +832,7 @@ static hda_nid_t path_power_update(struct hda_codec *codec,
for (i = 0; i < path->depth; i++) { for (i = 0; i < path->depth; i++) {
nid = path->path[i]; nid = path->path[i];
if (nid == codec->afg) if (nid == codec->core.afg)
continue; continue;
if (!allow_powerdown || is_active_nid_for_any(codec, nid)) if (!allow_powerdown || is_active_nid_for_any(codec, nid))
state = AC_PWRST_D0; state = AC_PWRST_D0;
...@@ -1897,12 +1897,11 @@ static void debug_show_configs(struct hda_codec *codec, ...@@ -1897,12 +1897,11 @@ static void debug_show_configs(struct hda_codec *codec,
static void fill_all_dac_nids(struct hda_codec *codec) static void fill_all_dac_nids(struct hda_codec *codec)
{ {
struct hda_gen_spec *spec = codec->spec; struct hda_gen_spec *spec = codec->spec;
int i; hda_nid_t nid;
hda_nid_t nid = codec->start_nid;
spec->num_all_dacs = 0; spec->num_all_dacs = 0;
memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); memset(spec->all_dacs, 0, sizeof(spec->all_dacs));
for (i = 0; i < codec->num_nodes; i++, nid++) { for_each_hda_codec_node(nid, codec) {
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT)
continue; continue;
if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) {
...@@ -3067,10 +3066,9 @@ static int fill_adc_nids(struct hda_codec *codec) ...@@ -3067,10 +3066,9 @@ static int fill_adc_nids(struct hda_codec *codec)
hda_nid_t nid; hda_nid_t nid;
hda_nid_t *adc_nids = spec->adc_nids; hda_nid_t *adc_nids = spec->adc_nids;
int max_nums = ARRAY_SIZE(spec->adc_nids); int max_nums = ARRAY_SIZE(spec->adc_nids);
int i, nums = 0; int nums = 0;
nid = codec->start_nid; for_each_hda_codec_node(nid, codec) {
for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int caps = get_wcaps(codec, nid); unsigned int caps = get_wcaps(codec, nid);
int type = get_wcaps_type(caps); int type = get_wcaps_type(caps);
...@@ -3864,8 +3862,7 @@ static void parse_digital(struct hda_codec *codec) ...@@ -3864,8 +3862,7 @@ static void parse_digital(struct hda_codec *codec)
if (spec->autocfg.dig_in_pin) { if (spec->autocfg.dig_in_pin) {
pin = spec->autocfg.dig_in_pin; pin = spec->autocfg.dig_in_pin;
dig_nid = codec->start_nid; for_each_hda_codec_node(dig_nid, codec) {
for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
unsigned int wcaps = get_wcaps(codec, dig_nid); unsigned int wcaps = get_wcaps(codec, dig_nid);
if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
continue; continue;
...@@ -4706,7 +4703,7 @@ unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec, ...@@ -4706,7 +4703,7 @@ unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
hda_nid_t nid, hda_nid_t nid,
unsigned int power_state) unsigned int power_state)
{ {
if (power_state != AC_PWRST_D0 || nid == codec->afg) if (power_state != AC_PWRST_D0 || nid == codec->core.afg)
return power_state; return power_state;
if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER) if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER)
return power_state; return power_state;
...@@ -5478,7 +5475,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec) ...@@ -5478,7 +5475,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
fill_pcm_stream_name(spec->stream_name_analog, fill_pcm_stream_name(spec->stream_name_analog,
sizeof(spec->stream_name_analog), sizeof(spec->stream_name_analog),
" Analog", codec->chip_name); " Analog", codec->core.chip_name);
info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
...@@ -5509,7 +5506,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec) ...@@ -5509,7 +5506,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
if (spec->multiout.dig_out_nid || spec->dig_in_nid) { if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
fill_pcm_stream_name(spec->stream_name_digital, fill_pcm_stream_name(spec->stream_name_digital,
sizeof(spec->stream_name_digital), sizeof(spec->stream_name_digital),
" Digital", codec->chip_name); " Digital", codec->core.chip_name);
info = snd_hda_codec_pcm_new(codec, "%s", info = snd_hda_codec_pcm_new(codec, "%s",
spec->stream_name_digital); spec->stream_name_digital);
if (!info) if (!info)
...@@ -5544,7 +5541,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec) ...@@ -5544,7 +5541,7 @@ int snd_hda_gen_build_pcms(struct hda_codec *codec)
if (spec->alt_dac_nid || have_multi_adcs) { if (spec->alt_dac_nid || have_multi_adcs) {
fill_pcm_stream_name(spec->stream_name_alt_analog, fill_pcm_stream_name(spec->stream_name_alt_analog,
sizeof(spec->stream_name_alt_analog), sizeof(spec->stream_name_alt_analog),
" Alt Analog", codec->chip_name); " Alt Analog", codec->core.chip_name);
info = snd_hda_codec_pcm_new(codec, "%s", info = snd_hda_codec_pcm_new(codec, "%s",
spec->stream_name_alt_analog); spec->stream_name_alt_analog);
if (!info) if (!info)
......
...@@ -515,15 +515,18 @@ int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid); ...@@ -515,15 +515,18 @@ int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid);
int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
unsigned int val); unsigned int val);
#define for_each_hda_codec_node(nid, codec) \
for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++)
/* /*
* get widget capabilities * get widget capabilities
*/ */
static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
{ {
if (nid < codec->start_nid || if (nid < codec->core.start_nid ||
nid >= codec->start_nid + codec->num_nodes) nid >= codec->core.start_nid + codec->core.num_nodes)
return 0; return 0;
return codec->wcaps[nid - codec->start_nid]; return codec->wcaps[nid - codec->core.start_nid];
} }
/* get the widget type from widget capability bits */ /* get the widget type from widget capability bits */
...@@ -547,9 +550,9 @@ static inline unsigned int get_wcaps_channels(u32 wcaps) ...@@ -547,9 +550,9 @@ static inline unsigned int get_wcaps_channels(u32 wcaps)
static inline void snd_hda_override_wcaps(struct hda_codec *codec, static inline void snd_hda_override_wcaps(struct hda_codec *codec,
hda_nid_t nid, u32 val) hda_nid_t nid, u32 val)
{ {
if (nid >= codec->start_nid && if (nid >= codec->core.start_nid &&
nid < codec->start_nid + codec->num_nodes) nid < codec->core.start_nid + codec->core.num_nodes)
codec->wcaps[nid - codec->start_nid] = val; codec->wcaps[nid - codec->core.start_nid] = val;
} }
u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
......
...@@ -289,7 +289,7 @@ static void print_pin_caps(struct snd_info_buffer *buffer, ...@@ -289,7 +289,7 @@ static void print_pin_caps(struct snd_info_buffer *buffer,
snd_iprintf(buffer, " Balanced"); snd_iprintf(buffer, " Balanced");
if (caps & AC_PINCAP_HDMI) { if (caps & AC_PINCAP_HDMI) {
/* Realtek uses this bit as a different meaning */ /* Realtek uses this bit as a different meaning */
if ((codec->vendor_id >> 16) == 0x10ec) if ((codec->core.vendor_id >> 16) == 0x10ec)
snd_iprintf(buffer, " R/L"); snd_iprintf(buffer, " R/L");
else { else {
if (caps & AC_PINCAP_HBR) if (caps & AC_PINCAP_HBR)
...@@ -597,7 +597,7 @@ static void print_gpio(struct snd_info_buffer *buffer, ...@@ -597,7 +597,7 @@ static void print_gpio(struct snd_info_buffer *buffer,
struct hda_codec *codec, hda_nid_t nid) struct hda_codec *codec, hda_nid_t nid)
{ {
unsigned int gpio = unsigned int gpio =
snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); snd_hda_param_read(codec, codec->core.afg, AC_PAR_GPIO_CAP);
unsigned int enable, direction, wake, unsol, sticky, data; unsigned int enable, direction, wake, unsol, sticky, data;
int i, max; int i, max;
snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, " snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
...@@ -667,13 +667,9 @@ static void print_device_list(struct snd_info_buffer *buffer, ...@@ -667,13 +667,9 @@ static void print_device_list(struct snd_info_buffer *buffer,
} }
} }
static void print_codec_info(struct snd_info_entry *entry, static void print_codec_core_info(struct hdac_device *codec,
struct snd_info_buffer *buffer) struct snd_info_buffer *buffer)
{ {
struct hda_codec *codec = entry->private_data;
hda_nid_t nid;
int i, nodes;
snd_iprintf(buffer, "Codec: "); snd_iprintf(buffer, "Codec: ");
if (codec->vendor_name && codec->chip_name) if (codec->vendor_name && codec->chip_name)
snd_iprintf(buffer, "%s %s\n", snd_iprintf(buffer, "%s %s\n",
...@@ -695,29 +691,39 @@ static void print_codec_info(struct snd_info_entry *entry, ...@@ -695,29 +691,39 @@ static void print_codec_info(struct snd_info_entry *entry,
snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg); snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
else else
snd_iprintf(buffer, "No Modem Function Group found\n"); snd_iprintf(buffer, "No Modem Function Group found\n");
}
static void print_codec_info(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
struct hda_codec *codec = entry->private_data;
hda_nid_t nid, fg;
int i, nodes;
if (! codec->afg) print_codec_core_info(&codec->core, buffer);
fg = codec->core.afg;
if (!fg)
return; return;
snd_hda_power_up(codec); snd_hda_power_up(codec);
snd_iprintf(buffer, "Default PCM:\n"); snd_iprintf(buffer, "Default PCM:\n");
print_pcm_caps(buffer, codec, codec->afg); print_pcm_caps(buffer, codec, fg);
snd_iprintf(buffer, "Default Amp-In caps: "); snd_iprintf(buffer, "Default Amp-In caps: ");
print_amp_caps(buffer, codec, codec->afg, HDA_INPUT); print_amp_caps(buffer, codec, fg, HDA_INPUT);
snd_iprintf(buffer, "Default Amp-Out caps: "); snd_iprintf(buffer, "Default Amp-Out caps: ");
print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT); print_amp_caps(buffer, codec, fg, HDA_OUTPUT);
snd_iprintf(buffer, "State of AFG node 0x%02x:\n", codec->afg); snd_iprintf(buffer, "State of AFG node 0x%02x:\n", fg);
print_power_state(buffer, codec, codec->afg); print_power_state(buffer, codec, fg);
nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); nodes = snd_hda_get_sub_nodes(codec, fg, &nid);
if (! nid || nodes < 0) { if (! nid || nodes < 0) {
snd_iprintf(buffer, "Invalid AFG subtree\n"); snd_iprintf(buffer, "Invalid AFG subtree\n");
snd_hda_power_down(codec); snd_hda_power_down(codec);
return; return;
} }
print_gpio(buffer, codec, codec->afg); print_gpio(buffer, codec, fg);
if (codec->proc_widget_hook) if (codec->proc_widget_hook)
codec->proc_widget_hook(buffer, codec, codec->afg); codec->proc_widget_hook(buffer, codec, fg);
for (i = 0; i < nodes; i++, nid++) { for (i = 0; i < nodes; i++, nid++) {
unsigned int wid_caps = unsigned int wid_caps =
...@@ -860,7 +866,7 @@ int snd_hda_codec_proc_new(struct hda_codec *codec) ...@@ -860,7 +866,7 @@ int snd_hda_codec_proc_new(struct hda_codec *codec)
struct snd_info_entry *entry; struct snd_info_entry *entry;
int err; int err;
snprintf(name, sizeof(name), "codec#%d", codec->addr); snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
err = snd_card_proc_new(codec->card, name, &entry); err = snd_card_proc_new(codec->card, name, &entry);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -48,33 +48,33 @@ static DEVICE_ATTR_RO(power_on_acct); ...@@ -48,33 +48,33 @@ static DEVICE_ATTR_RO(power_on_acct);
static DEVICE_ATTR_RO(power_off_acct); static DEVICE_ATTR_RO(power_off_acct);
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
#define CODEC_INFO_SHOW(type) \ #define CODEC_INFO_SHOW(type, field) \
static ssize_t type##_show(struct device *dev, \ static ssize_t type##_show(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
struct hda_codec *codec = dev_get_drvdata(dev); \ struct hda_codec *codec = dev_get_drvdata(dev); \
return sprintf(buf, "0x%x\n", codec->type); \ return sprintf(buf, "0x%x\n", codec->field); \
} }
#define CODEC_INFO_STR_SHOW(type) \ #define CODEC_INFO_STR_SHOW(type, field) \
static ssize_t type##_show(struct device *dev, \ static ssize_t type##_show(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
struct hda_codec *codec = dev_get_drvdata(dev); \ struct hda_codec *codec = dev_get_drvdata(dev); \
return sprintf(buf, "%s\n", \ return sprintf(buf, "%s\n", \
codec->type ? codec->type : ""); \ codec->field ? codec->field : ""); \
} }
CODEC_INFO_SHOW(vendor_id); CODEC_INFO_SHOW(vendor_id, core.vendor_id);
CODEC_INFO_SHOW(subsystem_id); CODEC_INFO_SHOW(subsystem_id, core.subsystem_id);
CODEC_INFO_SHOW(revision_id); CODEC_INFO_SHOW(revision_id, core.revision_id);
CODEC_INFO_SHOW(afg); CODEC_INFO_SHOW(afg, core.afg);
CODEC_INFO_SHOW(mfg); CODEC_INFO_SHOW(mfg, core.mfg);
CODEC_INFO_STR_SHOW(vendor_name); CODEC_INFO_STR_SHOW(vendor_name, core.vendor_name);
CODEC_INFO_STR_SHOW(chip_name); CODEC_INFO_STR_SHOW(chip_name, core.chip_name);
CODEC_INFO_STR_SHOW(modelname); CODEC_INFO_STR_SHOW(modelname, modelname);
static ssize_t pin_configs_show(struct hda_codec *codec, static ssize_t pin_configs_show(struct hda_codec *codec,
struct snd_array *list, struct snd_array *list,
...@@ -170,7 +170,7 @@ static char *kstrndup_noeol(const char *src, size_t len) ...@@ -170,7 +170,7 @@ static char *kstrndup_noeol(const char *src, size_t len)
return s; return s;
} }
#define CODEC_INFO_STORE(type) \ #define CODEC_INFO_STORE(type, field) \
static ssize_t type##_store(struct device *dev, \ static ssize_t type##_store(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
const char *buf, size_t count) \ const char *buf, size_t count) \
...@@ -180,11 +180,11 @@ static ssize_t type##_store(struct device *dev, \ ...@@ -180,11 +180,11 @@ static ssize_t type##_store(struct device *dev, \
int err = kstrtoul(buf, 0, &val); \ int err = kstrtoul(buf, 0, &val); \
if (err < 0) \ if (err < 0) \
return err; \ return err; \
codec->type = val; \ codec->field = val; \
return count; \ return count; \
} }
#define CODEC_INFO_STR_STORE(type) \ #define CODEC_INFO_STR_STORE(type, field) \
static ssize_t type##_store(struct device *dev, \ static ssize_t type##_store(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
const char *buf, size_t count) \ const char *buf, size_t count) \
...@@ -193,17 +193,17 @@ static ssize_t type##_store(struct device *dev, \ ...@@ -193,17 +193,17 @@ static ssize_t type##_store(struct device *dev, \
char *s = kstrndup_noeol(buf, 64); \ char *s = kstrndup_noeol(buf, 64); \
if (!s) \ if (!s) \
return -ENOMEM; \ return -ENOMEM; \
kfree(codec->type); \ kfree(codec->field); \
codec->type = s; \ codec->field = s; \
return count; \ return count; \
} }
CODEC_INFO_STORE(vendor_id); CODEC_INFO_STORE(vendor_id, core.vendor_id);
CODEC_INFO_STORE(subsystem_id); CODEC_INFO_STORE(subsystem_id, core.subsystem_id);
CODEC_INFO_STORE(revision_id); CODEC_INFO_STORE(revision_id, core.revision_id);
CODEC_INFO_STR_STORE(vendor_name); CODEC_INFO_STR_STORE(vendor_name, core.vendor_name);
CODEC_INFO_STR_STORE(chip_name); CODEC_INFO_STR_STORE(chip_name, core.chip_name);
CODEC_INFO_STR_STORE(modelname); CODEC_INFO_STR_STORE(modelname, modelname);
#define CODEC_ACTION_STORE(type) \ #define CODEC_ACTION_STORE(type) \
static ssize_t type##_store(struct device *dev, \ static ssize_t type##_store(struct device *dev, \
...@@ -553,9 +553,9 @@ static void parse_codec_mode(char *buf, struct hda_bus *bus, ...@@ -553,9 +553,9 @@ static void parse_codec_mode(char *buf, struct hda_bus *bus,
*codecp = NULL; *codecp = NULL;
if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
list_for_each_codec(codec, bus) { list_for_each_codec(codec, bus) {
if ((vendorid <= 0 || codec->vendor_id == vendorid) && if ((vendorid <= 0 || codec->core.vendor_id == vendorid) &&
(subid <= 0 || codec->subsystem_id == subid) && (subid <= 0 || codec->core.subsystem_id == subid) &&
codec->addr == caddr) { codec->core.addr == caddr) {
*codecp = codec; *codecp = codec;
break; break;
} }
...@@ -595,8 +595,8 @@ static void parse_model_mode(char *buf, struct hda_bus *bus, ...@@ -595,8 +595,8 @@ static void parse_model_mode(char *buf, struct hda_bus *bus,
static void parse_chip_name_mode(char *buf, struct hda_bus *bus, static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
struct hda_codec **codecp) struct hda_codec **codecp)
{ {
kfree((*codecp)->chip_name); kfree((*codecp)->core.chip_name);
(*codecp)->chip_name = kstrdup(buf, GFP_KERNEL); (*codecp)->core.chip_name = kstrdup(buf, GFP_KERNEL);
} }
#define DEFINE_PARSE_ID_MODE(name) \ #define DEFINE_PARSE_ID_MODE(name) \
...@@ -605,7 +605,7 @@ static void parse_##name##_mode(char *buf, struct hda_bus *bus, \ ...@@ -605,7 +605,7 @@ static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
{ \ { \
unsigned long val; \ unsigned long val; \
if (!kstrtoul(buf, 0, &val)) \ if (!kstrtoul(buf, 0, &val)) \
(*codecp)->name = val; \ (*codecp)->core.name = val; \
} }
DEFINE_PARSE_ID_MODE(vendor_id); DEFINE_PARSE_ID_MODE(vendor_id);
......
/*
*/
#ifndef __HDAC_LOCAL_H
#define __HDAC_LOCAL_H
int hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm);
#define get_wcaps(codec, nid) \
hdac_read_parm(codec, nid, AC_PAR_AUDIO_WIDGET_CAP)
/* get the widget type from widget capability bits */
static inline int get_wcaps_type(unsigned int wcaps)
{
if (!wcaps)
return -1; /* invalid type */
return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
}
#define get_pin_caps(codec, nid) \
hdac_read_parm(codec, nid, AC_PAR_PIN_CAP)
static inline
unsigned int get_pin_cfg(struct hdac_device *codec, hda_nid_t nid)
{
unsigned int val;
if (snd_hdac_read(codec, nid, AC_VERB_GET_CONFIG_DEFAULT, 0, &val))
return -1;
return val;
}
#define get_amp_caps(codec, nid, dir) \
hdac_read_parm(codec, nid, (dir) == HDA_OUTPUT ? \
AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP)
#define get_power_caps(codec, nid) \
hdac_read_parm(codec, nid, AC_PAR_POWER_STATE)
#endif /* __HDAC_LOCAL_H */
...@@ -99,7 +99,7 @@ static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, ...@@ -99,7 +99,7 @@ static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
static void ad198x_power_eapd(struct hda_codec *codec) static void ad198x_power_eapd(struct hda_codec *codec)
{ {
/* We currently only handle front, HP */ /* We currently only handle front, HP */
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x11d41882: case 0x11d41882:
case 0x11d4882a: case 0x11d4882a:
case 0x11d41884: case 0x11d41884:
......
...@@ -4243,13 +4243,9 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec) ...@@ -4243,13 +4243,9 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec)
{ {
struct ca0132_spec *spec = codec->spec; struct ca0132_spec *spec = codec->spec;
int i; int i;
hda_nid_t nid;
codec_dbg(codec, "ca0132_refresh_widget_caps.\n"); codec_dbg(codec, "ca0132_refresh_widget_caps.\n");
nid = codec->start_nid; snd_hda_codec_update_widgets(codec);
for (i = 0; i < codec->num_nodes; i++, nid++)
codec->wcaps[i] = snd_hda_param_read(codec, nid,
AC_PAR_AUDIO_WIDGET_CAP);
for (i = 0; i < spec->multiout.num_dacs; i++) for (i = 0; i < spec->multiout.num_dacs; i++)
refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT); refresh_amp_caps(codec, spec->dacs[i], HDA_OUTPUT);
......
...@@ -103,10 +103,9 @@ static int add_beep_ctls(struct hda_codec *codec) ...@@ -103,10 +103,9 @@ static int add_beep_ctls(struct hda_codec *codec)
static void cx_auto_parse_beep(struct hda_codec *codec) static void cx_auto_parse_beep(struct hda_codec *codec)
{ {
struct conexant_spec *spec = codec->spec; struct conexant_spec *spec = codec->spec;
hda_nid_t nid, end_nid; hda_nid_t nid;
end_nid = codec->start_nid + codec->num_nodes; for_each_hda_codec_node(nid, codec)
for (nid = codec->start_nid; nid < end_nid; nid++)
if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
set_beep_amp(spec, nid, 0, HDA_OUTPUT); set_beep_amp(spec, nid, 0, HDA_OUTPUT);
break; break;
...@@ -120,10 +119,9 @@ static void cx_auto_parse_beep(struct hda_codec *codec) ...@@ -120,10 +119,9 @@ static void cx_auto_parse_beep(struct hda_codec *codec)
static void cx_auto_parse_eapd(struct hda_codec *codec) static void cx_auto_parse_eapd(struct hda_codec *codec)
{ {
struct conexant_spec *spec = codec->spec; struct conexant_spec *spec = codec->spec;
hda_nid_t nid, end_nid; hda_nid_t nid;
end_nid = codec->start_nid + codec->num_nodes; for_each_hda_codec_node(nid, codec) {
for (nid = codec->start_nid; nid < end_nid; nid++) {
if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
continue; continue;
if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
...@@ -848,7 +846,7 @@ static int patch_conexant_auto(struct hda_codec *codec) ...@@ -848,7 +846,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
struct conexant_spec *spec; struct conexant_spec *spec;
int err; int err;
codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name); codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
spec = kzalloc(sizeof(*spec), GFP_KERNEL); spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec) if (!spec)
...@@ -862,7 +860,7 @@ static int patch_conexant_auto(struct hda_codec *codec) ...@@ -862,7 +860,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
if (spec->dynamic_eapd) if (spec->dynamic_eapd)
spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook; spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x14f15045: case 0x14f15045:
codec->single_adc_amp = 1; codec->single_adc_amp = 1;
spec->gen.mixer_nid = 0x17; spec->gen.mixer_nid = 0x17;
...@@ -896,7 +894,7 @@ static int patch_conexant_auto(struct hda_codec *codec) ...@@ -896,7 +894,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
* others may use EAPD really as an amp switch, so it might be * others may use EAPD really as an amp switch, so it might be
* not good to expose it blindly. * not good to expose it blindly.
*/ */
switch (codec->subsystem_id >> 16) { switch (codec->core.subsystem_id >> 16) {
case 0x103c: case 0x103c:
spec->gen.vmaster_mute_enum = 1; spec->gen.vmaster_mute_enum = 1;
break; break;
......
...@@ -45,14 +45,14 @@ static bool static_hdmi_pcm; ...@@ -45,14 +45,14 @@ static bool static_hdmi_pcm;
module_param(static_hdmi_pcm, bool, 0644); module_param(static_hdmi_pcm, bool, 0644);
MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
#define is_haswell(codec) ((codec)->vendor_id == 0x80862807) #define is_haswell(codec) ((codec)->core.vendor_id == 0x80862807)
#define is_broadwell(codec) ((codec)->vendor_id == 0x80862808) #define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808)
#define is_skylake(codec) ((codec)->vendor_id == 0x80862809) #define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809)
#define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ #define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \
|| is_skylake(codec)) || is_skylake(codec))
#define is_valleyview(codec) ((codec)->vendor_id == 0x80862882) #define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882)
#define is_cherryview(codec) ((codec)->vendor_id == 0x80862883) #define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883)
#define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec)) #define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec))
struct hdmi_spec_per_cvt { struct hdmi_spec_per_cvt {
...@@ -1391,13 +1391,12 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec, ...@@ -1391,13 +1391,12 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec,
hda_nid_t pin_nid, int mux_idx) hda_nid_t pin_nid, int mux_idx)
{ {
struct hdmi_spec *spec = codec->spec; struct hdmi_spec *spec = codec->spec;
hda_nid_t nid, end_nid; hda_nid_t nid;
int cvt_idx, curr; int cvt_idx, curr;
struct hdmi_spec_per_cvt *per_cvt; struct hdmi_spec_per_cvt *per_cvt;
/* configure all pins, including "no physical connection" ones */ /* configure all pins, including "no physical connection" ones */
end_nid = codec->start_nid + codec->num_nodes; for_each_hda_codec_node(nid, codec) {
for (nid = codec->start_nid; nid < end_nid; nid++) {
unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_caps = get_wcaps(codec, nid);
unsigned int wid_type = get_wcaps_type(wid_caps); unsigned int wid_type = get_wcaps_type(wid_caps);
...@@ -1728,7 +1727,7 @@ static int hdmi_parse_codec(struct hda_codec *codec) ...@@ -1728,7 +1727,7 @@ static int hdmi_parse_codec(struct hda_codec *codec)
hda_nid_t nid; hda_nid_t nid;
int i, nodes; int i, nodes;
nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid);
if (!nid || nodes < 0) { if (!nid || nodes < 0) {
codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
return -EINVAL; return -EINVAL;
...@@ -2928,7 +2927,8 @@ static int patch_nvhdmi(struct hda_codec *codec) ...@@ -2928,7 +2927,8 @@ static int patch_nvhdmi(struct hda_codec *codec)
*/ */
#define is_amdhdmi_rev3_or_later(codec) \ #define is_amdhdmi_rev3_or_later(codec) \
((codec)->vendor_id == 0x1002aa01 && ((codec)->revision_id & 0xff00) >= 0x0300) ((codec)->core.vendor_id == 0x1002aa01 && \
((codec)->core.revision_id & 0xff00) >= 0x0300)
#define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec)
/* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */ /* ATI/AMD specific HDA pin verbs, see the AMD HDA Verbs specification */
......
...@@ -299,7 +299,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec) ...@@ -299,7 +299,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
coef = alc_get_coef0(codec); coef = alc_get_coef0(codec);
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0262: case 0x10ec0262:
alc_update_coef_idx(codec, 0x7, 0, 1<<5); alc_update_coef_idx(codec, 0x7, 0, 1<<5);
break; break;
...@@ -432,7 +432,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) ...@@ -432,7 +432,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
snd_hda_sequence_write(codec, alc_gpio3_init_verbs); snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
break; break;
case ALC_INIT_DEFAULT: case ALC_INIT_DEFAULT:
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0260: case 0x10ec0260:
alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010); alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
break; break;
...@@ -498,18 +498,18 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec) ...@@ -498,18 +498,18 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
if (!codec->bus->pci) if (!codec->bus->pci)
return -1; return -1;
ass = codec->subsystem_id & 0xffff; ass = codec->core.subsystem_id & 0xffff;
if (ass != codec->bus->pci->subsystem_device && (ass & 1)) if (ass != codec->bus->pci->subsystem_device && (ass & 1))
goto do_sku; goto do_sku;
nid = 0x1d; nid = 0x1d;
if (codec->vendor_id == 0x10ec0260) if (codec->core.vendor_id == 0x10ec0260)
nid = 0x17; nid = 0x17;
ass = snd_hda_codec_get_pincfg(codec, nid); ass = snd_hda_codec_get_pincfg(codec, nid);
if (!(ass & 1)) { if (!(ass & 1)) {
codec_info(codec, "%s: SKU not ready 0x%08x\n", codec_info(codec, "%s: SKU not ready 0x%08x\n",
codec->chip_name, ass); codec->core.chip_name, ass);
return -1; return -1;
} }
...@@ -585,7 +585,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports) ...@@ -585,7 +585,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
goto do_sku; goto do_sku;
} }
ass = codec->subsystem_id & 0xffff; ass = codec->core.subsystem_id & 0xffff;
if (codec->bus->pci && if (codec->bus->pci &&
ass != codec->bus->pci->subsystem_device && (ass & 1)) ass != codec->bus->pci->subsystem_device && (ass & 1))
goto do_sku; goto do_sku;
...@@ -600,7 +600,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports) ...@@ -600,7 +600,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
* 0 : override * 0 : override
*/ */
nid = 0x1d; nid = 0x1d;
if (codec->vendor_id == 0x10ec0260) if (codec->core.vendor_id == 0x10ec0260)
nid = 0x17; nid = 0x17;
ass = snd_hda_codec_get_pincfg(codec, nid); ass = snd_hda_codec_get_pincfg(codec, nid);
codec_dbg(codec, codec_dbg(codec,
...@@ -621,7 +621,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports) ...@@ -621,7 +621,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
return 0; return 0;
do_sku: do_sku:
codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
ass & 0xffff, codec->vendor_id); ass & 0xffff, codec->core.vendor_id);
/* /*
* 0 : override * 0 : override
* 1 : Swap Jack * 1 : Swap Jack
...@@ -826,9 +826,9 @@ static const struct hda_codec_ops alc_patch_ops = { ...@@ -826,9 +826,9 @@ static const struct hda_codec_ops alc_patch_ops = {
/* replace the codec chip_name with the given string */ /* replace the codec chip_name with the given string */
static int alc_codec_rename(struct hda_codec *codec, const char *name) static int alc_codec_rename(struct hda_codec *codec, const char *name)
{ {
kfree(codec->chip_name); kfree(codec->core.chip_name);
codec->chip_name = kstrdup(name, GFP_KERNEL); codec->core.chip_name = kstrdup(name, GFP_KERNEL);
if (!codec->chip_name) { if (!codec->core.chip_name) {
alc_free(codec); alc_free(codec);
return -ENOMEM; return -ENOMEM;
} }
...@@ -904,7 +904,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec) ...@@ -904,7 +904,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
const struct alc_codec_rename_pci_table *q; const struct alc_codec_rename_pci_table *q;
for (p = rename_tbl; p->vendor_id; p++) { for (p = rename_tbl; p->vendor_id; p++) {
if (p->vendor_id != codec->vendor_id) if (p->vendor_id != codec->core.vendor_id)
continue; continue;
if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
return alc_codec_rename(codec, p->name); return alc_codec_rename(codec, p->name);
...@@ -913,7 +913,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec) ...@@ -913,7 +913,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
if (!codec->bus->pci) if (!codec->bus->pci)
return 0; return 0;
for (q = rename_pci_tbl; q->codec_vendor_id; q++) { for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
if (q->codec_vendor_id != codec->vendor_id) if (q->codec_vendor_id != codec->core.vendor_id)
continue; continue;
if (q->pci_subvendor != codec->bus->pci->subsystem_vendor) if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
continue; continue;
...@@ -1785,7 +1785,7 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) ...@@ -1785,7 +1785,7 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
{ {
unsigned int gpiostate, gpiomask, gpiodir; unsigned int gpiostate, gpiomask, gpiodir;
gpiostate = snd_hda_codec_read(codec, codec->afg, 0, gpiostate = snd_hda_codec_read(codec, codec->core.afg, 0,
AC_VERB_GET_GPIO_DATA, 0); AC_VERB_GET_GPIO_DATA, 0);
if (!muted) if (!muted)
...@@ -1793,23 +1793,23 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) ...@@ -1793,23 +1793,23 @@ static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
else else
gpiostate &= ~(1 << pin); gpiostate &= ~(1 << pin);
gpiomask = snd_hda_codec_read(codec, codec->afg, 0, gpiomask = snd_hda_codec_read(codec, codec->core.afg, 0,
AC_VERB_GET_GPIO_MASK, 0); AC_VERB_GET_GPIO_MASK, 0);
gpiomask |= (1 << pin); gpiomask |= (1 << pin);
gpiodir = snd_hda_codec_read(codec, codec->afg, 0, gpiodir = snd_hda_codec_read(codec, codec->core.afg, 0,
AC_VERB_GET_GPIO_DIRECTION, 0); AC_VERB_GET_GPIO_DIRECTION, 0);
gpiodir |= (1 << pin); gpiodir |= (1 << pin);
snd_hda_codec_write(codec, codec->afg, 0, snd_hda_codec_write(codec, codec->core.afg, 0,
AC_VERB_SET_GPIO_MASK, gpiomask); AC_VERB_SET_GPIO_MASK, gpiomask);
snd_hda_codec_write(codec, codec->afg, 0, snd_hda_codec_write(codec, codec->core.afg, 0,
AC_VERB_SET_GPIO_DIRECTION, gpiodir); AC_VERB_SET_GPIO_DIRECTION, gpiodir);
msleep(1); msleep(1);
snd_hda_codec_write(codec, codec->afg, 0, snd_hda_codec_write(codec, codec->core.afg, 0,
AC_VERB_SET_GPIO_DATA, gpiostate); AC_VERB_SET_GPIO_DATA, gpiostate);
} }
...@@ -2269,7 +2269,7 @@ static int patch_alc882(struct hda_codec *codec) ...@@ -2269,7 +2269,7 @@ static int patch_alc882(struct hda_codec *codec)
spec = codec->spec; spec = codec->spec;
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0882: case 0x10ec0882:
case 0x10ec0885: case 0x10ec0885:
case 0x10ec0900: case 0x10ec0900:
...@@ -3067,7 +3067,7 @@ static int alc269_resume(struct hda_codec *codec) ...@@ -3067,7 +3067,7 @@ static int alc269_resume(struct hda_codec *codec)
* in the driver. * in the driver.
*/ */
if (spec->gpio_led) if (spec->gpio_led)
snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA, snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA,
spec->gpio_led); spec->gpio_led);
if (spec->has_alc5505_dsp) if (spec->has_alc5505_dsp)
...@@ -3112,8 +3112,8 @@ static void alc271_fixup_dmic(struct hda_codec *codec, ...@@ -3112,8 +3112,8 @@ static void alc271_fixup_dmic(struct hda_codec *codec,
}; };
unsigned int cfg; unsigned int cfg;
if (strcmp(codec->chip_name, "ALC271X") && if (strcmp(codec->core.chip_name, "ALC271X") &&
strcmp(codec->chip_name, "ALC269VB")) strcmp(codec->core.chip_name, "ALC269VB"))
return; return;
cfg = snd_hda_codec_get_pincfg(codec, 0x12); cfg = snd_hda_codec_get_pincfg(codec, 0x12);
if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
...@@ -3479,9 +3479,9 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, ...@@ -3479,9 +3479,9 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
} }
snd_hda_add_verbs(codec, gpio_init); snd_hda_add_verbs(codec, gpio_init);
snd_hda_codec_write_cache(codec, codec->afg, 0, snd_hda_codec_write_cache(codec, codec->core.afg, 0,
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04); AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
snd_hda_jack_detect_enable_callback(codec, codec->afg, snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
gpio2_mic_hotkey_event); gpio2_mic_hotkey_event);
spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook; spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
...@@ -3564,7 +3564,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) ...@@ -3564,7 +3564,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_process_coef_fw(codec, coef0255); alc_process_coef_fw(codec, coef0255);
break; break;
...@@ -3619,7 +3619,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, ...@@ -3619,7 +3619,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_write_coef_idx(codec, 0x45, 0xc489); alc_write_coef_idx(codec, 0x45, 0xc489);
snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
...@@ -3688,7 +3688,7 @@ static void alc_headset_mode_default(struct hda_codec *codec) ...@@ -3688,7 +3688,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_process_coef_fw(codec, coef0255); alc_process_coef_fw(codec, coef0255);
break; break;
...@@ -3742,7 +3742,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) ...@@ -3742,7 +3742,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_process_coef_fw(codec, coef0255); alc_process_coef_fw(codec, coef0255);
break; break;
...@@ -3796,7 +3796,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec) ...@@ -3796,7 +3796,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_process_coef_fw(codec, coef0255); alc_process_coef_fw(codec, coef0255);
break; break;
...@@ -3841,7 +3841,7 @@ static void alc_determine_headset_type(struct hda_codec *codec) ...@@ -3841,7 +3841,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
{} {}
}; };
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0255: case 0x10ec0255:
alc_process_coef_fw(codec, coef0255); alc_process_coef_fw(codec, coef0255);
msleep(300); msleep(300);
...@@ -4078,7 +4078,7 @@ static unsigned int alc_power_filter_xps13(struct hda_codec *codec, ...@@ -4078,7 +4078,7 @@ static unsigned int alc_power_filter_xps13(struct hda_codec *codec,
/* Avoid pop noises when headphones are plugged in */ /* Avoid pop noises when headphones are plugged in */
if (spec->gen.hp_jack_present) if (spec->gen.hp_jack_present)
if (nid == codec->afg || nid == 0x02 || nid == 0x15) if (nid == codec->core.afg || nid == 0x02 || nid == 0x15)
return AC_PWRST_D0; return AC_PWRST_D0;
return power_state; return power_state;
} }
...@@ -5428,7 +5428,7 @@ static int patch_alc269(struct hda_codec *codec) ...@@ -5428,7 +5428,7 @@ static int patch_alc269(struct hda_codec *codec)
if (has_cdefine_beep(codec)) if (has_cdefine_beep(codec))
spec->gen.beep_nid = 0x01; spec->gen.beep_nid = 0x01;
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0269: case 0x10ec0269:
spec->codec_variant = ALC269_TYPE_ALC269VA; spec->codec_variant = ALC269_TYPE_ALC269VA;
switch (alc_get_coef0(codec) & 0x00f0) { switch (alc_get_coef0(codec) & 0x00f0) {
...@@ -5772,9 +5772,9 @@ static int alc662_parse_auto_config(struct hda_codec *codec) ...@@ -5772,9 +5772,9 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
const hda_nid_t *ssids; const hda_nid_t *ssids;
if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 || codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
codec->vendor_id == 0x10ec0671) codec->core.vendor_id == 0x10ec0671)
ssids = alc663_ssids; ssids = alc663_ssids;
else else
ssids = alc662_ssids; ssids = alc662_ssids;
...@@ -5819,7 +5819,7 @@ static unsigned int gpio_led_power_filter(struct hda_codec *codec, ...@@ -5819,7 +5819,7 @@ static unsigned int gpio_led_power_filter(struct hda_codec *codec,
unsigned int power_state) unsigned int power_state)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led) if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_led)
return AC_PWRST_D0; return AC_PWRST_D0;
return power_state; return power_state;
} }
...@@ -6317,7 +6317,7 @@ static int patch_alc662(struct hda_codec *codec) ...@@ -6317,7 +6317,7 @@ static int patch_alc662(struct hda_codec *codec)
alc_fix_pll_init(codec, 0x20, 0x04, 15); alc_fix_pll_init(codec, 0x20, 0x04, 15);
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0668: case 0x10ec0668:
spec->init_hook = alc668_restore_default_value; spec->init_hook = alc668_restore_default_value;
break; break;
...@@ -6347,7 +6347,7 @@ static int patch_alc662(struct hda_codec *codec) ...@@ -6347,7 +6347,7 @@ static int patch_alc662(struct hda_codec *codec)
goto error; goto error;
if (!spec->gen.no_analog && spec->gen.beep_nid) { if (!spec->gen.no_analog && spec->gen.beep_nid) {
switch (codec->vendor_id) { switch (codec->core.vendor_id) {
case 0x10ec0662: case 0x10ec0662:
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
break; break;
......
...@@ -205,8 +205,8 @@ static int si3054_build_pcms(struct hda_codec *codec) ...@@ -205,8 +205,8 @@ static int si3054_build_pcms(struct hda_codec *codec)
return -ENOMEM; return -ENOMEM;
info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm;
info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = codec->mfg; info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = codec->core.mfg;
info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = codec->mfg; info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = codec->core.mfg;
info->pcm_type = HDA_PCM_TYPE_MODEM; info->pcm_type = HDA_PCM_TYPE_MODEM;
return 0; return 0;
} }
...@@ -223,7 +223,7 @@ static int si3054_init(struct hda_codec *codec) ...@@ -223,7 +223,7 @@ static int si3054_init(struct hda_codec *codec)
u16 val; u16 val;
snd_hda_codec_write(codec, AC_NODE_ROOT, 0, AC_VERB_SET_CODEC_RESET, 0); snd_hda_codec_write(codec, AC_NODE_ROOT, 0, AC_VERB_SET_CODEC_RESET, 0);
snd_hda_codec_write(codec, codec->mfg, 0, AC_VERB_SET_STREAM_FORMAT, 0); snd_hda_codec_write(codec, codec->core.mfg, 0, AC_VERB_SET_STREAM_FORMAT, 0);
SET_REG(codec, SI3054_LINE_RATE, 9600); SET_REG(codec, SI3054_LINE_RATE, 9600);
SET_REG(codec, SI3054_LINE_LEVEL, SI3054_DTAG_MASK|SI3054_ATAG_MASK); SET_REG(codec, SI3054_LINE_LEVEL, SI3054_DTAG_MASK|SI3054_ATAG_MASK);
SET_REG(codec, SI3054_EXTENDED_MID, 0); SET_REG(codec, SI3054_EXTENDED_MID, 0);
......
This diff is collapsed.
...@@ -140,7 +140,7 @@ static struct via_spec *via_new_spec(struct hda_codec *codec) ...@@ -140,7 +140,7 @@ static struct via_spec *via_new_spec(struct hda_codec *codec)
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
{ {
u32 vendor_id = codec->vendor_id; u32 vendor_id = codec->core.vendor_id;
u16 ven_id = vendor_id >> 16; u16 ven_id = vendor_id >> 16;
u16 dev_id = vendor_id & 0xffff; u16 dev_id = vendor_id & 0xffff;
enum VIA_HDA_CODEC codec_type; enum VIA_HDA_CODEC codec_type;
...@@ -335,7 +335,7 @@ static void __analog_low_current_mode(struct hda_codec *codec, bool force) ...@@ -335,7 +335,7 @@ static void __analog_low_current_mode(struct hda_codec *codec, bool force)
return; /* other codecs are not supported */ return; /* other codecs are not supported */
} }
/* send verb */ /* send verb */
snd_hda_codec_write(codec, codec->afg, 0, verb, parm); snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm);
} }
static void analog_low_current_mode(struct hda_codec *codec) static void analog_low_current_mode(struct hda_codec *codec)
...@@ -558,7 +558,7 @@ static int vt1708_build_pcms(struct hda_codec *codec) ...@@ -558,7 +558,7 @@ static int vt1708_build_pcms(struct hda_codec *codec)
int i, err; int i, err;
err = snd_hda_gen_build_pcms(codec); err = snd_hda_gen_build_pcms(codec);
if (err < 0 || codec->vendor_id != 0x11061708) if (err < 0 || codec->core.vendor_id != 0x11061708)
return err; return err;
/* We got noisy outputs on the right channel on VT1708 when /* We got noisy outputs on the right channel on VT1708 when
...@@ -714,19 +714,19 @@ static int patch_vt1708S(struct hda_codec *codec) ...@@ -714,19 +714,19 @@ static int patch_vt1708S(struct hda_codec *codec)
/* correct names for VT1708BCE */ /* correct names for VT1708BCE */
if (get_codec_type(codec) == VT1708BCE) { if (get_codec_type(codec) == VT1708BCE) {
kfree(codec->chip_name); kfree(codec->core.chip_name);
codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL); codec->core.chip_name = kstrdup("VT1708BCE", GFP_KERNEL);
snprintf(codec->card->mixername, snprintf(codec->card->mixername,
sizeof(codec->card->mixername), sizeof(codec->card->mixername),
"%s %s", codec->vendor_name, codec->chip_name); "%s %s", codec->core.vendor_name, codec->core.chip_name);
} }
/* correct names for VT1705 */ /* correct names for VT1705 */
if (codec->vendor_id == 0x11064397) { if (codec->core.vendor_id == 0x11064397) {
kfree(codec->chip_name); kfree(codec->core.chip_name);
codec->chip_name = kstrdup("VT1705", GFP_KERNEL); codec->core.chip_name = kstrdup("VT1705", GFP_KERNEL);
snprintf(codec->card->mixername, snprintf(codec->card->mixername,
sizeof(codec->card->mixername), sizeof(codec->card->mixername),
"%s %s", codec->vendor_name, codec->chip_name); "%s %s", codec->core.vendor_name, codec->core.chip_name);
} }
/* automatic parse from the BIOS config */ /* automatic parse from the BIOS config */
...@@ -815,8 +815,7 @@ static int add_secret_dac_path(struct hda_codec *codec) ...@@ -815,8 +815,7 @@ static int add_secret_dac_path(struct hda_codec *codec)
} }
/* find the primary DAC and add to the connection list */ /* find the primary DAC and add to the connection list */
nid = codec->start_nid; for_each_hda_codec_node(nid, codec) {
for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int caps = get_wcaps(codec, nid); unsigned int caps = get_wcaps(codec, nid);
if (get_wcaps_type(caps) == AC_WID_AUD_OUT && if (get_wcaps_type(caps) == AC_WID_AUD_OUT &&
!(caps & AC_WCAP_DIGITAL)) { !(caps & AC_WCAP_DIGITAL)) {
......
...@@ -21,7 +21,7 @@ static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context, ...@@ -21,7 +21,7 @@ static acpi_status acpi_check_cb(acpi_handle handle, u32 lvl, void *context,
static bool is_thinkpad(struct hda_codec *codec) static bool is_thinkpad(struct hda_codec *codec)
{ {
bool found = false; bool found = false;
if (codec->subsystem_id >> 16 != 0x17aa) if (codec->core.subsystem_id >> 16 != 0x17aa)
return false; return false;
if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found) if (ACPI_SUCCESS(acpi_get_devices("LEN0068", acpi_check_cb, &found, NULL)) && found)
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment