diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2008-11-14 21:58:12 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2008-11-14 21:58:12 +0000 |
commit | 05d2a017f9654979b401e7cbb3016f6d3e429bfc (patch) | |
tree | a8b667151d4459c367ea4d269c8bd05ea66739be /sys/dev | |
parent | ddb591ece60a81e22e93cca2e1d7804da7799288 (diff) |
* readability improvement in azalia_codec_connect_stream
* DEBUG cleanup
from Alexey Suslikov, thanks
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/azalia.c | 23 | ||||
-rw-r--r-- | sys/dev/pci/azalia_codec.c | 372 |
2 files changed, 32 insertions, 363 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 15b58b0aa0d..4d6921ed9ba 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.71 2008/11/05 04:08:24 brad Exp $ */ +/* $OpenBSD: azalia.c,v 1.72 2008/11/14 21:58:11 jakemsr Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -236,10 +236,12 @@ int azalia_codec_disconnect_stream(codec_t *, int); int azalia_widget_init(widget_t *, const codec_t *, int); int azalia_widget_label_widgets(codec_t *); int azalia_widget_init_audio(widget_t *, const codec_t *); -int azalia_widget_print_audio(const widget_t *, const char *); int azalia_widget_init_pin(widget_t *, const codec_t *); -int azalia_widget_print_pin(const widget_t *); int azalia_widget_init_connection(widget_t *, const codec_t *); +#ifdef AZALIA_DEBUG +int azalia_widget_print_audio(const widget_t *, const char *); +int azalia_widget_print_pin(const widget_t *); +#endif int azalia_stream_init(stream_t *, azalia_t *, int, int, int); int azalia_stream_delete(stream_t *, azalia_t *); @@ -1641,12 +1643,15 @@ azalia_codec_connect_stream(codec_t *this, int dir, uint16_t fmt, int number) nid = group->conv[1]; } - err = this->comresp(this, nid, CORB_SET_CONVERTER_FORMAT, fmt, NULL); - if (err) - goto exit; - stream_chan = (number << 4) | startchan; if (startchan >= nchan) stream_chan = 0; /* stream#0 */ + else + stream_chan = (number << 4) | startchan; + + err = this->comresp(this, nid, CORB_SET_CONVERTER_FORMAT, + fmt, NULL); + if (err) + goto exit; err = this->comresp(this, nid, CORB_SET_CONVERTER_STREAM_CHANNEL, stream_chan, NULL); if (err) @@ -1877,6 +1882,7 @@ azalia_widget_init_audio(widget_t *this, const codec_t *codec) "\x09""96kHz\x08""88.2kHz\x07""48kHz\x06""44.1kHz\x05""32kHz\x04" \ "22.05kHz\x03""16kHz\x02""11.025kHz\x01""8kHz" +#ifdef AZALIA_DEBUG int azalia_widget_print_audio(const widget_t *this, const char *lead) { @@ -1886,6 +1892,7 @@ azalia_widget_print_audio(const widget_t *this, const char *lead) BITSRATES_BITS); return 0; } +#endif int azalia_widget_init_pin(widget_t *this, const codec_t *codec) @@ -1939,6 +1946,7 @@ azalia_widget_init_pin(widget_t *this, const codec_t *codec) "\13VREFGND\12VREF50\11VREFHIZ\07BALANCE\06INPUT" \ "\05OUTPUT\04HEADPHONE\03PRESENCE\02TRIGGER\01IMPEDANCE" +#ifdef AZALIA_DEBUG int azalia_widget_print_pin(const widget_t *this) { @@ -1975,6 +1983,7 @@ azalia_widget_print_pin(const widget_t *this) return 0; } +#endif int azalia_widget_init_connection(widget_t *this, const codec_t *codec) diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index 27bee9549a5..732a6b41844 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.57 2008/11/05 01:14:01 jakemsr Exp $ */ +/* $OpenBSD: azalia_codec.c,v 1.58 2008/11/14 21:58:11 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 azalia_generic_mixer_create_virtual(codec_t *, int, int); 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,8 +102,6 @@ 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 *); @@ -167,16 +165,12 @@ 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"; @@ -987,7 +981,7 @@ azalia_generic_mixer_pin_sense(codec_t *this) } int -azalia_generic_mixer_create_virtual(codec_t *this) +azalia_generic_mixer_create_virtual(codec_t *this, int pdac, int padc) { mixer_item_t *m; mixer_devinfo_t *d; @@ -1002,13 +996,17 @@ azalia_generic_mixer_create_virtual(codec_t *this) } mdac = madc = mmaster = -1; - for (i = 0; i < this->nmixers; i++) { + for (i = 0; i < this->nmixers && (mdac < 0 || madc < 0); 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; @@ -1058,7 +1056,7 @@ int azalia_generic_mixer_autoinit(codec_t *this) { azalia_generic_mixer_init(this); - azalia_generic_mixer_create_virtual(this); + azalia_generic_mixer_create_virtual(this, -1, -1); azalia_generic_mixer_pin_sense(this); return 0; @@ -1935,160 +1933,6 @@ 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) { @@ -2108,73 +1952,15 @@ azalia_alc882_init_dacgroup(codec_t *this) } int -azalia_alc882_set_port(codec_t *this, mixer_ctrl_t *mc) +azalia_alc882_mixer_init(codec_t *this) { - const mixer_item_t *m; - mixer_ctrl_t mc2; - uint32_t mask, bit; - int i, err; + azalia_generic_mixer_init(this); + azalia_generic_mixer_create_virtual(this, 0x0c, 0x07); + azalia_generic_mixer_pin_sense(this); - 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); + return 0; } -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 @@ -2199,139 +1985,13 @@ 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) { - 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_init(this); + azalia_generic_mixer_create_virtual(this, 0x0c, 0x08); 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; } |