diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-05-08 03:52:38 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-05-08 03:52:38 +0000 |
commit | 9b14c2412a705c63c0c3812d32c231530bfaf8d5 (patch) | |
tree | a277d4fb5f575d417798ec7af6247c5d2ccee1ae /sys/dev/pci | |
parent | a9dfbeb84a851f947455c476a3b89e2fe3d78518 (diff) |
- make this compile with AZALIA_DEBUG
- introduce WIDGET_CHANNELS macro
From NetBSD
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/azalia.c | 50 | ||||
-rw-r--r-- | sys/dev/pci/azalia.h | 1 |
2 files changed, 22 insertions, 29 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 8ed0519f958..4a5bd01c4c2 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.2 2006/05/08 03:28:46 brad Exp $ */ +/* $OpenBSD: azalia.c,v 1.3 2006/05/08 03:52:37 brad Exp $ */ /* $NetBSD: azalia.c,v 1.15 2005/09/29 04:14:03 kent Exp $ */ /*- @@ -37,7 +37,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define AZALIA_DEBUG /* * High Definition Audio Specification * ftp://download.intel.com/standards/hdaudio/pdf/HDAudio_03.pdf @@ -1082,11 +1081,11 @@ azalia_codec_init(codec_t *this) err = this->init_dacgroup(this); if (err) return err; -#ifdef AZALIA_DEBUGGGG +#ifdef AZALIA_DEBUG for (i = 0; i < this->ndacgroups; i++) { DPRINTF(("%s: dacgroup[%d]:", __func__, i)); - for (n = 0; n < this->dacgroups[group].nconv; n++) { - DPRINTF((" %2.2x", this->dacgroups[group].conv[n])); + for (n = 0; n < this->dacgroups[i].nconv; n++) { + DPRINTF((" %2.2x", this->dacgroups[i].conv[n])); } DPRINTF(("\n")); } @@ -1185,8 +1184,7 @@ azalia_codec_construct_format(codec_t *this) bits_rates = this->w[nid].d.audio.bits_rates; for (dac = 0; dac < group->nconv; dac++) { for (chan = 0, i = 0; i <= dac; i++) - chan += this->w[group->conv[dac]].widgetcap - & COP_AWCAP_STEREO ? 2 : 1; + chan += WIDGET_CHANNELS(&this->w[group->conv[dac]]); azalia_codec_add_bits(this, chan, bits_rates, AUMODE_PLAY); } /* print playback capability */ @@ -1202,7 +1200,7 @@ azalia_codec_construct_format(codec_t *this) /* register formats for recording */ nid = this->adcs[this->cur_adc]; - chan = this->w[nid].widgetcap & COP_AWCAP_STEREO ? 2 : 1; + chan = WIDGET_CHANNELS(&this->w[nid]); bits_rates = this->w[nid].d.audio.bits_rates; azalia_codec_add_bits(this, chan, bits_rates, AUMODE_RECORD); /* print recording capability */ @@ -1333,9 +1331,9 @@ azalia_codec_connect_stream(codec_t *this, int dir, uint16_t fmt, int number) } group = &this->dacgroups[this->cur_dac]; flag222 = group->nconv >= 3 && - (this->w[group->conv[0]].widgetcap & COP_AWCAP_STEREO) && - (this->w[group->conv[1]].widgetcap & COP_AWCAP_STEREO) && - (this->w[group->conv[2]].widgetcap & COP_AWCAP_STEREO); + (WIDGET_CHANNELS(&this->w[group->conv[0]]) == 2) && + (WIDGET_CHANNELS(&this->w[group->conv[1]]) == 2) && + (WIDGET_CHANNELS(&this->w[group->conv[2]]) == 2); nchan = (fmt & HDA_SD_FMT_CHAN) + 1; startchan = 0; for (i = 0; i < group->nconv; i++) { @@ -1355,7 +1353,7 @@ azalia_codec_connect_stream(codec_t *this, int dir, uint16_t fmt, int number) (number << 4) | startchan, NULL); if (err) goto exit; - startchan += this->w[nid].widgetcap & COP_AWCAP_STEREO ? 2 : 1; + startchan += WIDGET_CHANNELS(&this->w[nid]); } exit: @@ -1518,8 +1516,7 @@ azalia_mixer_init(codec_t *this) d->next = AUDIO_MIXER_LAST; d->prev = AUDIO_MIXER_LAST; m->target = MI_TARGET_OUTAMP; - d->un.v.num_channels = w->widgetcap & COP_AWCAP_STEREO - ? 2 : 1; + d->un.v.num_channels = WIDGET_CHANNELS(w); #ifdef MAX_VOLUME_255 d->un.v.units.name[0] = 0; d->un.v.delta = AUDIO_MAX_GAIN / @@ -1579,8 +1576,7 @@ azalia_mixer_init(codec_t *this) d->next = AUDIO_MIXER_LAST; d->prev = AUDIO_MIXER_LAST; m->target = j; - d->un.v.num_channels = - w->widgetcap & COP_AWCAP_STEREO ? 2 : 1; + d->un.v.num_channels = WIDGET_CHANNELS(w); #ifdef MAX_VOLUME_255 d->un.v.units.name[0] = 0; d->un.v.delta = AUDIO_MAX_GAIN / @@ -1756,7 +1752,7 @@ azalia_mixer_init(codec_t *this) mc.un.value.num_channels = 1; mc.un.value.level[0] = AUDIO_MAX_GAIN / 2; if (this->mixers[i].target != MI_TARGET_VOLUME && - this->w[this->mixers[i].nid].widgetcap & COP_AWCAP_STEREO) { + WIDGET_CHANNELS(&this->w[this->mixers[i].nid]) == 2) { mc.un.value.num_channels = 2; mc.un.value.level[1] = AUDIO_MAX_GAIN / 2; } @@ -1809,7 +1805,8 @@ azalia_mixer_get(const codec_t *this, mixer_ctrl_t *mc) return err; mc->un.value.level[0] = azalia_mixer_from_device_value(this, m, CORB_GAGM_GAIN(result)); - if (this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + mc->un.value.num_channels = WIDGET_CHANNELS(&this->w[m->nid]); + if (mc->un.value.num_channels == 2) { err = this->comresp(this, m->nid, CORB_GET_AMPLIFIER_GAIN_MUTE, CORB_GAGM_INPUT | CORB_GAGM_RIGHT | MI_TARGET_INAMP(m->target), @@ -1818,9 +1815,6 @@ azalia_mixer_get(const codec_t *this, mixer_ctrl_t *mc) return err; mc->un.value.level[1] = azalia_mixer_from_device_value (this, m, CORB_GAGM_GAIN(result)); - mc->un.value.num_channels = 2; - } else { - mc->un.value.num_channels = 1; } } @@ -1841,7 +1835,8 @@ azalia_mixer_get(const codec_t *this, mixer_ctrl_t *mc) return err; mc->un.value.level[0] = azalia_mixer_from_device_value(this, m, CORB_GAGM_GAIN(result)); - if (this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + mc->un.value.num_channels = WIDGET_CHANNELS(&this->w[m->nid]); + if (mc->un.value.num_channels == 2) { err = this->comresp(this, m->nid, CORB_GET_AMPLIFIER_GAIN_MUTE, CORB_GAGM_OUTPUT | CORB_GAGM_RIGHT | 0, &result); @@ -1849,9 +1844,6 @@ azalia_mixer_get(const codec_t *this, mixer_ctrl_t *mc) return err; mc->un.value.level[1] = azalia_mixer_from_device_value (this, m, CORB_GAGM_GAIN(result)); - mc->un.value.num_channels = 2; - } else { - mc->un.value.num_channels = 1; } } @@ -1943,7 +1935,7 @@ azalia_mixer_set(codec_t *this, const mixer_ctrl_t *mc) value, &result); if (err) return err; - if (this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + if (WIDGET_CHANNELS(&this->w[m->nid]) == 2) { err = this->comresp(this, m->nid, CORB_GET_AMPLIFIER_GAIN_MUTE, CORB_GAGM_INPUT | CORB_GAGM_RIGHT | MI_TARGET_INAMP(m->target), @@ -1984,7 +1976,7 @@ azalia_mixer_set(codec_t *this, const mixer_ctrl_t *mc) if (err) return err; if (mc->un.value.num_channels >= 2 && - this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + WIDGET_CHANNELS(&this->w[m->nid]) == 2) { if (!azalia_mixer_validate_value(this, m, mc->un.value.level[1])) return EINVAL; @@ -2020,7 +2012,7 @@ azalia_mixer_set(codec_t *this, const mixer_ctrl_t *mc) value, &result); if (err) return err; - if (this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + if (WIDGET_CHANNELS(&this->w[m->nid]) == 2) { err = this->comresp(this, m->nid, CORB_GET_AMPLIFIER_GAIN_MUTE, CORB_GAGM_OUTPUT | CORB_GAGM_RIGHT, &result); @@ -2057,7 +2049,7 @@ azalia_mixer_set(codec_t *this, const mixer_ctrl_t *mc) if (err) return err; if (mc->un.value.num_channels >= 2 && - this->w[m->nid].widgetcap & COP_AWCAP_STEREO) { + WIDGET_CHANNELS(&this->w[m->nid]) == 2) { if (!azalia_mixer_validate_value(this, m, mc->un.value.level[1])) return EINVAL; diff --git a/sys/dev/pci/azalia.h b/sys/dev/pci/azalia.h index 945383dc9a7..c22d478f663 100644 --- a/sys/dev/pci/azalia.h +++ b/sys/dev/pci/azalia.h @@ -490,6 +490,7 @@ typedef struct { } volume; } d; } widget_t; +#define WIDGET_CHANNELS(w) ((w)->widgetcap & COP_AWCAP_STEREO ? 2 : 1) typedef struct { mixer_devinfo_t devinfo; |