diff options
Diffstat (limited to 'sys/dev/pci/azalia_codec.c')
-rw-r--r-- | sys/dev/pci/azalia_codec.c | 372 |
1 files changed, 356 insertions, 16 deletions
diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index 732a6b41844..73b9a452715 100644 --- a/sys/dev/pci/azalia_codec.c +++ b/sys/dev/pci/azalia_codec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia_codec.c,v 1.58 2008/11/14 21:58:11 jakemsr Exp $ */ +/* $OpenBSD: azalia_codec.c,v 1.59 2008/11/14 22:03:39 jakemsr Exp $ */ /* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */ /*- @@ -81,7 +81,7 @@ int azalia_generic_mixer_autoinit(codec_t *); int azalia_generic_mixer_fix_indexes(codec_t *); int azalia_generic_mixer_default(codec_t *); int azalia_generic_mixer_pin_sense(codec_t *); -int azalia_generic_mixer_create_virtual(codec_t *, int, int); +int azalia_generic_mixer_create_virtual(codec_t *); int azalia_generic_mixer_delete(codec_t *); int azalia_generic_mixer_ensure_capacity(codec_t *, size_t); int azalia_generic_mixer_get(const codec_t *, nid_t, int, mixer_ctrl_t *); @@ -102,6 +102,8 @@ int azalia_alc861_init_dacgroup(codec_t *); int azalia_alc880_init_dacgroup(codec_t *); int azalia_alc882_init_dacgroup(codec_t *); int azalia_alc882_mixer_init(codec_t *); +int azalia_alc882_set_port(codec_t *, mixer_ctrl_t *); +int azalia_alc882_get_port(codec_t *, mixer_ctrl_t *); int azalia_alc883_init_dacgroup(codec_t *); int azalia_alc883_mixer_init(codec_t *); int azalia_alc885_init_dacgroup(codec_t *); @@ -165,12 +167,16 @@ azalia_codec_init_vtbl(codec_t *this) this->name = "Realtek ALC882"; this->init_dacgroup = azalia_alc882_init_dacgroup; this->mixer_init = azalia_alc882_mixer_init; + this->get_port = azalia_alc882_get_port; + this->set_port = azalia_alc882_set_port; break; case 0x10ec0883: /* ftp://209.216.61.149/pc/audio/ALC883_DataSheet_1.3.pdf */ this->name = "Realtek ALC883"; this->init_dacgroup = azalia_alc883_init_dacgroup; this->mixer_init = azalia_alc883_mixer_init; + this->get_port = azalia_alc882_get_port; + this->set_port = azalia_alc882_set_port; break; case 0x10ec0885: this->name = "Realtek ALC885"; @@ -981,7 +987,7 @@ azalia_generic_mixer_pin_sense(codec_t *this) } int -azalia_generic_mixer_create_virtual(codec_t *this, int pdac, int padc) +azalia_generic_mixer_create_virtual(codec_t *this) { mixer_item_t *m; mixer_devinfo_t *d; @@ -996,17 +1002,13 @@ azalia_generic_mixer_create_virtual(codec_t *this, int pdac, int padc) } mdac = madc = mmaster = -1; - for (i = 0; i < this->nmixers && (mdac < 0 || madc < 0); i++) { + for (i = 0; i < this->nmixers; i++) { if (this->mixers[i].devinfo.type != AUDIO_MIXER_VALUE) continue; - if (pdac >= 0 && this->mixers[i].nid == pdac) - mdac = mmaster = i; if (mdac < 0 && this->dacs.ngroups > 0 && cgdac->nconv > 0) { if (this->mixers[i].nid == cgdac->conv[0]) mdac = mmaster = i; } - if (padc >= 0 && this->mixers[i].nid == padc) - madc = i; if (madc < 0 && this->adcs.ngroups > 0 && cgadc->nconv > 0) { if (this->mixers[i].nid == cgadc->conv[0]) madc = i; @@ -1056,7 +1058,7 @@ int azalia_generic_mixer_autoinit(codec_t *this) { azalia_generic_mixer_init(this); - azalia_generic_mixer_create_virtual(this, -1, -1); + azalia_generic_mixer_create_virtual(this); azalia_generic_mixer_pin_sense(this); return 0; @@ -1933,6 +1935,160 @@ azalia_alc880_init_dacgroup(codec_t *this) * Realtek ALC882 * ---------------------------------------------------------------- */ +static const mixer_item_t alc882_mixer_items[] = { + {{AZ_CLASS_INPUT, {AudioCinputs}, AUDIO_MIXER_CLASS, AZ_CLASS_INPUT, 0, 0}, 0}, + {{AZ_CLASS_OUTPUT, {AudioCoutputs}, AUDIO_MIXER_CLASS, AZ_CLASS_OUTPUT, 0, 0}, 0}, + {{AZ_CLASS_RECORD, {AudioCrecord}, AUDIO_MIXER_CLASS, AZ_CLASS_RECORD, 0, 0}, 0}, + + /* 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x14,0x15,0x16,0x17 */ + {{0, {"mic1."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(0)}, + {{0, {"mic1"}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(0)}, + {{0, {"mic2."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(1)}, + {{0, {"mic2"}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(1)}, + {{0, {AudioNline"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(2)}, + {{0, {AudioNline}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(2)}, + {{0, {AudioNcd"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(4)}, + {{0, {AudioNcd}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(4)}, + {{0, {AudioNspeaker"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(5)}, + {{0, {AudioNspeaker}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 1, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(5)}, + + {{0, {AudioNmaster}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0c, MI_TARGET_OUTAMP}, + {{0, {AudioNmaster"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x14, MI_TARGET_OUTAMP}, + {{0, {AudioNmaster".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x14, MI_TARGET_PINBOOST}, + {{0, {AudioNheadphone"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x1b, MI_TARGET_OUTAMP}, + {{0, {AudioNheadphone".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x1b, MI_TARGET_PINBOOST}, + {{0, {AzaliaNfront".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0c, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNfront".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0c, MI_TARGET_INAMP(1)}, + + {{0, {AudioNsurround}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0d, MI_TARGET_OUTAMP}, + {{0, {AudioNsurround"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x15, MI_TARGET_OUTAMP}, + {{0, {AudioNsurround".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x15, MI_TARGET_PINBOOST}, + {{0, {AudioNsurround".dac.mut"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0d, MI_TARGET_INAMP(0)}, + {{0, {AudioNsurround".mixer.m"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0d, MI_TARGET_INAMP(1)}, + + {{0, {AzaliaNclfe}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0e, MI_TARGET_OUTAMP}, + {{0, {AzaliaNclfe"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x16, MI_TARGET_OUTAMP}, + {{0, {AzaliaNclfe".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x16, MI_TARGET_PINBOOST}, + {{0, {AzaliaNclfe".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0e, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNclfe".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0e, MI_TARGET_INAMP(1)}, + + {{0, {AzaliaNside}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0f, MI_TARGET_OUTAMP}, + {{0, {AzaliaNside"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x17, MI_TARGET_OUTAMP}, + {{0, {AzaliaNside".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x17, MI_TARGET_PINBOOST}, + {{0, {AzaliaNside".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0f, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNside".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0f, MI_TARGET_INAMP(1)}, + + /* 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x14,0x15,0x16,0x17,0xb */ +#define ALC882_MIC1 0x001 +#define ALC882_MIC2 0x002 +#define ALC882_LINE 0x004 +#define ALC882_CD 0x010 +#define ALC882_BEEP 0x020 +#define ALC882_MIX 0x400 +#define ALC882_MASK 0x437 + {{0, {AzaliaNfront"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, + 0, 0, ENUM_OFFON}, 0x07, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNfront}, AUDIO_MIXER_VALUE, AZ_CLASS_RECORD, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x07, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNfront"."AudioNsource}, AUDIO_MIXER_SET, AZ_CLASS_RECORD, + 0, 0, .un.s={6, {{{"mic1"}, ALC882_MIC1}, {{"mic2"}, ALC882_MIC2}, + {{AudioNline}, ALC882_LINE}, {{AudioNcd}, ALC882_CD}, + {{AudioNspeaker}, ALC882_BEEP}, + {{AudioNmixerout}, ALC882_MIX}}}}, 0x24, -1}, + {{0, {AudioNsurround"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, + 0, 0, ENUM_OFFON}, 0x08, MI_TARGET_INAMP(0)}, + {{0, {AudioNsurround}, AUDIO_MIXER_VALUE, AZ_CLASS_RECORD, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x08, MI_TARGET_INAMP(0)}, + {{0, {AudioNsurround"."AudioNsource}, AUDIO_MIXER_SET, AZ_CLASS_RECORD, + 0, 0, .un.s={6, {{{"mic1"}, ALC882_MIC1}, {{"mic2"}, ALC882_MIC2}, + {{AudioNline}, ALC882_LINE}, {{AudioNcd}, ALC882_CD}, + {{AudioNspeaker}, ALC882_BEEP}, + {{AudioNmixerout}, ALC882_MIX}}}}, 0x23, -1}, + {{0, {AzaliaNclfe"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, + 0, 0, ENUM_OFFON}, 0x09, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNclfe}, AUDIO_MIXER_VALUE, AZ_CLASS_RECORD, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x09, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNclfe"."AudioNsource}, AUDIO_MIXER_SET, AZ_CLASS_RECORD, + 0, 0, .un.s={6, {{{"mic1"}, ALC882_MIC1}, {{"mic2"}, ALC882_MIC2}, + {{AudioNline}, ALC882_LINE}, {{AudioNcd}, ALC882_CD}, + {{AudioNspeaker}, ALC882_BEEP}, + {{AudioNmixerout}, ALC882_MIX}}}}, 0x22, -1}, + + {{0, {"usingdac"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, 0, 0, + .un.e={2, {{{"analog"}, 0}, {{"digital"}, 1}}}}, 0, MI_TARGET_DAC}, + {{0, {"usingadc"}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, 0, 0, + .un.e={2, {{{"analog"}, 0}, {{"digital"}, 1}}}}, 0, MI_TARGET_ADC}, +}; + +int +azalia_alc882_mixer_init(codec_t *this) +{ + mixer_ctrl_t mc; + + this->nmixers = sizeof(alc882_mixer_items) / sizeof(mixer_item_t); + this->mixers = malloc(sizeof(mixer_item_t) * this->nmixers, + M_DEVBUF, M_NOWAIT | M_ZERO); + if (this->mixers == NULL) { + printf("%s: out of memory in %s\n", XNAME(this), __func__); + return ENOMEM; + } + memcpy(this->mixers, alc882_mixer_items, + sizeof(mixer_item_t) * this->nmixers); + azalia_generic_mixer_fix_indexes(this); + azalia_generic_mixer_default(this); + + azalia_generic_mixer_pin_sense(this); + + mc.dev = -1; + mc.type = AUDIO_MIXER_ENUM; + mc.un.ord = 0; /* [0] 0x0c */ + azalia_generic_mixer_set(this, 0x14, MI_TARGET_CONNLIST, &mc); + azalia_generic_mixer_set(this, 0x1b, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 1; /* [1] 0x0d */ + azalia_generic_mixer_set(this, 0x15, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 2; /* [2] 0x0e */ + azalia_generic_mixer_set(this, 0x16, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 2; /* [3] 0x0fb */ + azalia_generic_mixer_set(this, 0x17, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 0; /* unmute */ + azalia_generic_mixer_set(this, 0x24, MI_TARGET_INAMP(0), &mc); + azalia_generic_mixer_set(this, 0x23, MI_TARGET_INAMP(1), &mc); + azalia_generic_mixer_set(this, 0x22, MI_TARGET_INAMP(2), &mc); + return 0; +} + int azalia_alc882_init_dacgroup(codec_t *this) { @@ -1952,15 +2108,73 @@ azalia_alc882_init_dacgroup(codec_t *this) } int -azalia_alc882_mixer_init(codec_t *this) +azalia_alc882_set_port(codec_t *this, mixer_ctrl_t *mc) { - azalia_generic_mixer_init(this); - azalia_generic_mixer_create_virtual(this, 0x0c, 0x07); - azalia_generic_mixer_pin_sense(this); + const mixer_item_t *m; + mixer_ctrl_t mc2; + uint32_t mask, bit; + int i, err; - return 0; + if (mc->dev >= this->nmixers) + return ENXIO; + m = &this->mixers[mc->dev]; + if (mc->type != m->devinfo.type) + return EINVAL; + if (mc->type == AUDIO_MIXER_CLASS) + return 0; + if ((m->nid == 0x22 || m->nid == 0x23 || m->nid == 0x24) + && m->target == -1) { + DPRINTF(("%s: hook for record.*.source\n", __func__)); + mc2.dev = -1; + mc2.type = AUDIO_MIXER_ENUM; + bit = 1; + mask = mc->un.mask & ALC882_MASK; + for (i = 0; i < this->w[m->nid].nconnections && i < 32; i++) { + mc2.un.ord = (mask & bit) ? 0 : 1; + err = azalia_generic_mixer_set(this, m->nid, + MI_TARGET_INAMP(i), &mc2); + if (err) + return err; + bit = bit << 1; + } + return 0; + } + return azalia_generic_mixer_set(this, m->nid, m->target, mc); } +int +azalia_alc882_get_port(codec_t *this, mixer_ctrl_t *mc) +{ + const mixer_item_t *m; + uint32_t mask, bit, result; + int i, err; + + if (mc->dev >= this->nmixers) + return ENXIO; + m = &this->mixers[mc->dev]; + mc->type = m->devinfo.type; + if (mc->type == AUDIO_MIXER_CLASS) + return 0; + if ((m->nid == 0x22 || m->nid == 0x23 || m->nid == 0x24) + && m->target == -1) { + DPRINTF(("%s: hook for record.*.source\n", __func__)); + mask = 0; + bit = 1; + for (i = 0; i < this->w[m->nid].nconnections && i < 32; i++) { + err = this->comresp(this, m->nid, CORB_GET_AMPLIFIER_GAIN_MUTE, + CORB_GAGM_INPUT | CORB_GAGM_LEFT | + i, &result); + if (err) + return err; + if ((result & CORB_GAGM_MUTE) == 0) + mask |= bit; + bit = bit << 1; + } + mc->un.mask = mask & ALC882_MASK; + return 0; + } + return azalia_generic_mixer_get(this, m->nid, m->target, mc); +} /* ---------------------------------------------------------------- * Realtek ALC883 @@ -1985,13 +2199,139 @@ azalia_alc883_init_dacgroup(codec_t *this) return 0; } +static const mixer_item_t alc883_mixer_items[] = { + {{AZ_CLASS_INPUT, {AudioCinputs}, AUDIO_MIXER_CLASS, AZ_CLASS_INPUT, 0, 0}, 0}, + {{AZ_CLASS_OUTPUT, {AudioCoutputs}, AUDIO_MIXER_CLASS, AZ_CLASS_OUTPUT, 0, 0}, 0}, + {{AZ_CLASS_RECORD, {AudioCrecord}, AUDIO_MIXER_CLASS, AZ_CLASS_RECORD, 0, 0}, 0}, + + {{0, {AudioNmaster}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 4, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0c, MI_TARGET_OUTAMP}, + {{0, {AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 3, ENUM_OFFON}, 0x14, MI_TARGET_OUTAMP}, + + /* 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x14,0x15,0x16,0x17 */ + {{0, {AudioNmicrophone"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(0)}, + {{0, {AudioNmicrophone}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(0)}, + {{0, {"mic2."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(1)}, + {{0, {"mic2"}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(1)}, + {{0, {AudioNline"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(2)}, + {{0, {AudioNline}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(2)}, + {{0, {AudioNcd"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(4)}, + {{0, {AudioNcd}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(4)}, + {{0, {AudioNspeaker"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0b, MI_TARGET_INAMP(5)}, + {{0, {AudioNspeaker}, AUDIO_MIXER_VALUE, AZ_CLASS_INPUT, + 0, 0, .un.v={{""}, 1, MIXER_DELTA(31)}}, 0x0b, MI_TARGET_INAMP(5)}, + {{0, {AudioNmaster".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x14, MI_TARGET_PINBOOST}, + {{0, {AudioNheadphone"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x1b, MI_TARGET_OUTAMP}, + {{0, {AudioNheadphone".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x1b, MI_TARGET_PINBOOST}, + {{0, {AzaliaNfront".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0c, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNfront".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0c, MI_TARGET_INAMP(1)}, + {{0, {AudioNsurround}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0d, MI_TARGET_OUTAMP}, + {{0, {AudioNsurround"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x15, MI_TARGET_OUTAMP}, + {{0, {AudioNsurround".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x15, MI_TARGET_PINBOOST}, + {{0, {AudioNsurround".dac.mut"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0d, MI_TARGET_INAMP(0)}, + {{0, {AudioNsurround".mixer.m"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0d, MI_TARGET_INAMP(1)}, + + {{0, {AzaliaNclfe}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0e, MI_TARGET_OUTAMP}, + {{0, {AzaliaNclfe"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x16, MI_TARGET_OUTAMP}, + {{0, {AzaliaNclfe".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x16, MI_TARGET_PINBOOST}, + {{0, {AzaliaNclfe".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0e, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNclfe".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0e, MI_TARGET_INAMP(1)}, + + {{0, {AzaliaNside}, AUDIO_MIXER_VALUE, AZ_CLASS_OUTPUT, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x0f, MI_TARGET_OUTAMP}, + {{0, {AzaliaNside"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x17, MI_TARGET_OUTAMP}, + {{0, {AzaliaNside".boost"}, AUDIO_MIXER_ENUM, AZ_CLASS_OUTPUT, + 0, 0, ENUM_OFFON}, 0x17, MI_TARGET_PINBOOST}, + {{0, {AzaliaNside".dac.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0f, MI_TARGET_INAMP(0)}, + {{0, {AzaliaNside".mixer.mute"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, + 0, 0, ENUM_OFFON}, 0x0f, MI_TARGET_INAMP(1)}, + + {{0, {AudioNvolume"."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, + 0, 0, ENUM_OFFON}, 0x08, MI_TARGET_INAMP(0)}, + {{0, {AudioNvolume}, AUDIO_MIXER_VALUE, AZ_CLASS_RECORD, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x08, MI_TARGET_INAMP(0)}, + {{0, {AudioNsource}, AUDIO_MIXER_SET, AZ_CLASS_RECORD, + 0, 0, .un.s={6, {{{AudioNmicrophone}, ALC882_MIC1}, {{"mic2"}, ALC882_MIC2}, + {{AudioNline}, ALC882_LINE}, {{AudioNcd}, ALC882_CD}, + {{AudioNspeaker}, ALC882_BEEP}, + {{AudioNmixerout}, ALC882_MIX}}}}, 0x23, -1}, + + {{0, {AudioNsource"2."AudioNmute}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, + 0, 0, ENUM_OFFON}, 0x09, MI_TARGET_INAMP(0)}, + {{0, {AudioNvolume"2"}, AUDIO_MIXER_VALUE, AZ_CLASS_RECORD, + 0, 0, .un.v={{""}, 2, MIXER_DELTA(31)}}, 0x09, MI_TARGET_INAMP(0)}, + {{0, {AudioNsource"2"}, AUDIO_MIXER_SET, AZ_CLASS_RECORD, + 0, 0, .un.s={6, {{{AudioNmicrophone}, ALC882_MIC1}, {{"mic2"}, ALC882_MIC2}, + {{AudioNline}, ALC882_LINE}, {{AudioNcd}, ALC882_CD}, + {{AudioNspeaker}, ALC882_BEEP}, + {{AudioNmixerout}, ALC882_MIX}}}}, 0x22, -1}, + + {{0, {"usingdac"}, AUDIO_MIXER_ENUM, AZ_CLASS_INPUT, 0, 0, + .un.e={2, {{{"analog"}, 0}, {{"digital"}, 1}}}}, 0, MI_TARGET_DAC}, + {{0, {"usingadc"}, AUDIO_MIXER_ENUM, AZ_CLASS_RECORD, 0, 0, + .un.e={2, {{{"analog"}, 0}, {{"digital"}, 1}}}}, 0, MI_TARGET_ADC}, +}; + int azalia_alc883_mixer_init(codec_t *this) { - azalia_generic_mixer_init(this); - azalia_generic_mixer_create_virtual(this, 0x0c, 0x08); + mixer_ctrl_t mc; + + this->nmixers = sizeof(alc883_mixer_items) / sizeof(mixer_item_t); + this->mixers = malloc(sizeof(mixer_item_t) * this->nmixers, + M_DEVBUF, M_NOWAIT | M_ZERO); + if (this->mixers == NULL) { + printf("%s: out of memory in %s\n", XNAME(this), __func__); + return ENOMEM; + } + memcpy(this->mixers, alc883_mixer_items, + sizeof(mixer_item_t) * this->nmixers); + azalia_generic_mixer_fix_indexes(this); + azalia_generic_mixer_default(this); + azalia_generic_mixer_pin_sense(this); + mc.dev = -1; + mc.type = AUDIO_MIXER_ENUM; + mc.un.ord = 0; /* [0] 0x0c */ + azalia_generic_mixer_set(this, 0x14, MI_TARGET_CONNLIST, &mc); + azalia_generic_mixer_set(this, 0x1b, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 1; /* [1] 0x0d */ + azalia_generic_mixer_set(this, 0x15, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 2; /* [2] 0x0e */ + azalia_generic_mixer_set(this, 0x16, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 2; /* [3] 0x0fb */ + azalia_generic_mixer_set(this, 0x17, MI_TARGET_CONNLIST, &mc); + mc.un.ord = 0; /* unmute */ + azalia_generic_mixer_set(this, 0x23, MI_TARGET_INAMP(1), &mc); + azalia_generic_mixer_set(this, 0x22, MI_TARGET_INAMP(2), &mc); return 0; } |