From 1fc4c9fdf9bd9dac8f8765f24498751e35c98ab4 Mon Sep 17 00:00:00 2001 From: Jacob Meuser Date: Sun, 30 Nov 2008 03:50:30 +0000 Subject: - don't access nonexistent converter goups - don't try to create formats for converter groups that don't exist - don't allow playback or recording if there is no corresponding converter group - don't try to set audio processing parameters on converter groups that don't exist allows playback (or record) only devices to work, such as the azalias found on ATI graphics devices. note, the ATI devices generally attach before the onboard devices do. that means they will be audio0 and onboard devices will be audio1. don't forget to make sure the /dev/{audio[ctl],mixer,sound} links point to the nodes of the device you want to be the default. tested by naddy@, thanks --- sys/dev/pci/azalia_codec.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'sys/dev/pci/azalia_codec.c') diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index 0ed4acd20a5..3de3d109700 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.75 2008/11/28 21:50:05 jakemsr Exp $ */ +/* $OpenBSD: azalia_codec.c,v 1.76 2008/11/30 03:50:29 jakemsr Exp $ */ /* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */ /*- @@ -333,15 +333,18 @@ azalia_generic_codec_add_convgroup(codec_t *this, convgroupset_t *group, digital ? "digital" : "analog", (type == COP_AWTYPE_AUDIO_OUTPUT) ? "DACs" : "ADCs")); + nconvs = 0; nall_convs = 0; + FOR_EACH_WIDGET(this, i) { if (this->w[i].type == type && (this->w[i].widgetcap & COP_AWCAP_DIGITAL) == digital && nall_convs < HDA_MAX_CHANNELS) all_convs[nall_convs++] = this->w[i].nid; } + if (nall_convs == 0) + goto done; - nconvs = 0; for (assoc = 0; assoc <= CORB_CD_ASSOCIATION_MAX; assoc++) { for (seq = 0; seq <= CORB_CD_SEQUENCE_MAX; seq++) { FOR_EACH_WIDGET(this, i) { @@ -523,17 +526,18 @@ azalia_generic_mixer_init(codec_t *this) continue; /* usable adcs - connections should be in AZ_CLASS_RECORD */ - if (w->type == COP_AWTYPE_AUDIO_INPUT) { + if (w->type == COP_AWTYPE_AUDIO_INPUT && + this->adcs.ngroups > 0) { const convgroupset_t *group; group = &this->adcs; + k = 0; for (j = 0; j < group->groups[group->cur].nconv; j++) if (group->groups[group->cur].conv[j] == w->nid) break; - if (j == group->groups[group->cur].nconv) - continue; - - for (j = 0; j < w->nconnections && naconns < 32; j++) { + if (j < group->groups[group->cur].nconv) + k = w->nconnections; + for (j = 0; j < k && naconns < 32; j++) { k = azalia_nid_to_index(this, w->connections[j]); if (k == -1) @@ -1038,10 +1042,15 @@ azalia_generic_mixer_create_virtual(codec_t *this, int pdac, int padc) { mixer_item_t *m; mixer_devinfo_t *d; - convgroup_t *cgdac = &this->dacs.groups[0]; - convgroup_t *cgadc = &this->adcs.groups[0]; + convgroup_t *cgdac; + convgroup_t *cgadc; int i, err, madc, mmaster; + if (this->dacs.ngroups > 0) + cgdac = &this->dacs.groups[0]; + if (this->adcs.ngroups > 0) + cgadc = &this->adcs.groups[0]; + /* Clear mixer indexes, to make generic_mixer_fix_index happy */ for (i = 0; i < this->nmixers; i++) { d = &this->mixers[i].devinfo; -- cgit v1.2.3