/* * Attach hardware to driver, attach hardware driver to audio * pseudo-device driver . */ void ad1848_attach(struct ad1848_softc *sc) { static struct ad1848_volume vol_mid = {220, 220}; static struct ad1848_volume vol_0 = {0, 0}; int i; int timeout; /* Initialize the ad1848... */ for (i = 0; i < 0x10; i++) { ad_write(sc, i, ad1848_init_values[i]); timeout = 100000; while (timeout > 0 && ADREAD(sc, AD1848_IADDR) & SP_IN_INIT) timeout--; } /* ...and additional CS4231 stuff too */ if (sc->mode >= 2) { ad_write(sc, SP_INTERFACE_CONFIG, 0); /* disable SINGLE_DMA */ for (i = 0x10; i < 0x20; i++) if (ad1848_init_values[i] != 0) { ad_write(sc, i, ad1848_init_values[i]); timeout = 100000; while (timeout > 0 && ADREAD(sc, AD1848_IADDR) & SP_IN_INIT) timeout--; } } ad1848_reset(sc); /* Set default gains */ ad1848_set_rec_gain(sc, &vol_mid); ad1848_set_channel_gain(sc, AD1848_DAC_CHANNEL, &vol_mid); ad1848_set_channel_gain(sc, AD1848_MONITOR_CHANNEL, &vol_0); ad1848_set_channel_gain(sc, AD1848_AUX1_CHANNEL, &vol_mid); /* CD volume */ sc->mute[AD1848_MONITOR_CHANNEL] = MUTE_ALL; if (sc->mode >= 2 #if AD1845_HACK && sc->is_ad1845 == 0 #endif ) { ad1848_set_channel_gain(sc, AD1848_AUX2_CHANNEL, &vol_mid); /* CD volume */ ad1848_set_channel_gain(sc, AD1848_LINE_CHANNEL, &vol_mid); ad1848_set_channel_gain(sc, AD1848_MONO_CHANNEL, &vol_0); sc->mute[AD1848_MONO_CHANNEL] = MUTE_ALL; } else ad1848_set_channel_gain(sc, AD1848_AUX2_CHANNEL, &vol_0); /* Set default port */ ad1848_set_rec_port(sc, MIC_IN_PORT); printf(": %s", sc->chip_name); }
int ad1848_mixer_set_port(struct ad1848_softc *ac, struct ad1848_devmap *map, int cnt, mixer_ctrl_t *cp) { ad1848_devmap_t *entry; struct ad1848_volume vol; int error = EINVAL; int dev; if (!(entry = ad1848_mixer_find_dev(map, cnt, cp))) return (ENXIO); dev = entry->dev; switch (entry->kind) { case AD1848_KIND_LVL: if (cp->type != AUDIO_MIXER_VALUE) break; if (dev < AD1848_AUX2_CHANNEL || dev > AD1848_MONITOR_CHANNEL) break; if (cp->un.value.num_channels != 1 && mixer_channel_info[dev].right_reg == 0) break; ad1848_to_vol(cp, &vol); error = ad1848_set_channel_gain(ac, dev, &vol); break; case AD1848_KIND_MUTE: if (cp->type != AUDIO_MIXER_ENUM) break; ac->mute[dev] = (cp->un.ord ? MUTE_ALL : 0); ad1848_mute_channel(ac, dev, ac->mute[dev]); error = 0; break; case AD1848_KIND_RECORDGAIN: if (cp->type != AUDIO_MIXER_VALUE) break; ad1848_to_vol(cp, &vol); error = ad1848_set_rec_gain(ac, &vol); break; case AD1848_KIND_MICGAIN: if (cp->type != AUDIO_MIXER_VALUE) break; ad1848_to_vol(cp, &vol); error = ad1848_set_mic_gain(ac, &vol); break; case AD1848_KIND_RECORDSOURCE: if (cp->type != AUDIO_MIXER_ENUM) break; error = ad1848_set_rec_port(ac, cp->un.ord); break; default: printf("Invalid kind\n"); break; } return (error); }
/* * Attach hardware to driver, attach hardware driver to audio * pseudo-device driver . */ void ad1848_attach(struct ad1848_softc *sc) { int i; struct ad1848_volume vol_mid = {220, 220}; struct ad1848_volume vol_0 = {0, 0}; struct audio_params pparams, rparams; int timeout; sc->sc_playrun = 0; sc->sc_recrun = 0; if (sc->sc_drq != -1) { if (isa_dmamap_create(sc->sc_isa, sc->sc_drq, MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { printf("ad1848_attach: can't create map for drq %d\n", sc->sc_drq); return; } } if (sc->sc_recdrq != -1 && sc->sc_recdrq != sc->sc_drq) { if (isa_dmamap_create(sc->sc_isa, sc->sc_recdrq, MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { printf("ad1848_attach: can't create map for second drq %d\n", sc->sc_recdrq); return; } } /* Initialize the ad1848... */ for (i = 0; i < 0x10; i++) { ad_write(sc, i, ad1848_init_values[i]); timeout = AD1848_TIMO; while (timeout > 0 && ADREAD(sc, AD1848_IADDR) & SP_IN_INIT) timeout--; } /* need 2 separate drqs for mode 2 */ if ((sc->mode == 2) && ((sc->sc_recdrq == -1) || (sc->sc_recdrq == sc->sc_drq))) { ad_write(sc, SP_MISC_INFO, ad_read(sc, SP_MISC_INFO) & ~MODE2); if (!(ad_read(sc, SP_MISC_INFO) & MODE2)) sc->mode = 1; } /* ...and additional CS4231 stuff too */ if (sc->mode == 2) { ad_write(sc, SP_INTERFACE_CONFIG, 0); /* disable SINGLE_DMA */ for (i = 0x10; i < 0x20; i++) { if (ad1848_init_values[i] != 0) { ad_write(sc, i, ad1848_init_values[i]); timeout = AD1848_TIMO; while (timeout > 0 && ADREAD(sc, AD1848_IADDR) & SP_IN_INIT) timeout--; } } } ad1848_reset(sc); pparams = audio_default; rparams = audio_default; (void) ad1848_set_params(sc, AUMODE_RECORD|AUMODE_PLAY, 0, &pparams, &rparams); /* Set default gains */ (void) ad1848_set_rec_gain(sc, &vol_mid); (void) ad1848_set_channel_gain(sc, AD1848_DAC_CHANNEL, &vol_mid); (void) ad1848_set_channel_gain(sc, AD1848_MONITOR_CHANNEL, &vol_0); /* CD volume */ (void) ad1848_set_channel_gain(sc, AD1848_AUX1_CHANNEL, &vol_mid); if (sc->mode == 2) { /* CD volume */ (void) ad1848_set_channel_gain(sc, AD1848_AUX2_CHANNEL, &vol_mid); (void) ad1848_set_channel_gain(sc, AD1848_LINE_CHANNEL, &vol_mid); (void) ad1848_set_channel_gain(sc, AD1848_MONO_CHANNEL, &vol_0); sc->mute[AD1848_MONO_CHANNEL] = MUTE_ALL; } else (void) ad1848_set_channel_gain(sc, AD1848_AUX2_CHANNEL, &vol_0); /* Set default port */ (void) ad1848_set_rec_port(sc, MIC_IN_PORT); if (sc->chip_name) printf(": %s", sc->chip_name); }