On Sat, Jun 20, 2009 at 11:18:44AM +0000, Jacob Meuser wrote: > for codecs with multiple line out jacks, this patch would use the > color of the jack (according to the codec) in the name instead > of enumerating the jacks, if all the line out jack have different > colors. for example: > > outputs.line -> outputs.line-grn > outputs.line2 -> outputs.line-org > outputs.line3 -> outputs.line-blk > outputs.line4 -> outputs.line-gry > > unfortunately, there isn't enough room in mixer names for the color > to be spelled out fully. the abbreviations are as follows: > > blk -> black > gry -> grey > blu -> blue > grn -> green > red -> red > org -> orange > yel -> yellow > pur -> purple > pnk -> pink > whi -> white > oth -> other > > I would be surprised to see colors other than grn, org, blk, gry being > used for line out jacks. the others are usually used for inputs or > digital connections. > > comments?
forgot to initialize a variable. please try this diff instead. -- [email protected] SDF Public Access UNIX System - http://sdf.lonestar.org Index: azalia.c =================================================================== RCS file: /cvs/src/sys/dev/pci/azalia.c,v retrieving revision 1.140 diff -u -p azalia.c --- azalia.c 18 Jun 2009 08:19:03 -0000 1.140 +++ azalia.c 20 Jun 2009 23:57:27 -0000 @@ -311,6 +311,9 @@ static const char *wtypes[16] = { "dac", "adc", "mix", "sel", "pin", "pow", "volume", "beep", "wid08", "wid09", "wid0a", "wid0b", "wid0c", "wid0d", "wid0e", "vendor"}; +static const char *pin_colors[11] = { + "blk", "gry", "blu", "grn", "red", "org", "yel", + "pur", "pnk", "whi", "oth"}; /* ================================================================ * PCI functions @@ -1319,11 +1322,13 @@ azalia_codec_init(codec_t *this) switch (this->w[i].d.pin.device) { case CORB_CD_SPEAKER: this->speaker = i; - this->spkr_dac = azalia_codec_find_defdac(this, i, 0); + this->spkr_dac = + azalia_codec_find_defdac(this, i, 0); break; case CORB_CD_MICIN: this->mic = i; - this->mic_adc = azalia_codec_find_defadc(this, i, 0); + this->mic_adc = + azalia_codec_find_defadc(this, i, 0); break; } break; @@ -2636,11 +2641,29 @@ azalia_widget_label_widgets(codec_t *codec) widget_t *w; int types[16]; int pins[16]; + int colors_used, use_colors; int i, j; bzero(&pins, sizeof(pins)); bzero(&types, sizeof(types)); + /* If codec has more than one line-out jack, check if the jacks + * have unique colors. If so, use the colors in the mixer names. + */ + use_colors = 1; + colors_used = 0; + if (codec->nout_jacks < 2) + use_colors = 0; + for (i = 0; use_colors && i < codec->nopins; i++) { + w = &codec->w[codec->opins[i].nid]; + if (w->d.pin.device != CORB_CD_LINEOUT) + continue; + if (colors_used & (1 << w->d.pin.color)) + use_colors = 0; + else + colors_used |= (1 << w->d.pin.color); + } + FOR_EACH_WIDGET(codec, i) { w = &codec->w[i]; /* default for disabled/unused widgets */ @@ -2650,13 +2673,18 @@ azalia_widget_label_widgets(codec_t *codec) switch (w->type) { case COP_AWTYPE_PIN_COMPLEX: pins[w->d.pin.device]++; - if (pins[w->d.pin.device] > 1) + if (use_colors && w->d.pin.device == CORB_CD_LINEOUT) { + snprintf(w->name, sizeof(w->name), "%s-%s", + pin_devices[w->d.pin.device], + pin_colors[w->d.pin.color]); + } else if (pins[w->d.pin.device] > 1) { snprintf(w->name, sizeof(w->name), "%s%d", pin_devices[w->d.pin.device], pins[w->d.pin.device]); - else + } else { snprintf(w->name, sizeof(w->name), "%s", pin_devices[w->d.pin.device]); + } break; case COP_AWTYPE_AUDIO_OUTPUT: if (codec->dacs.ngroups < 1)
