Lines Matching refs:ac

65 #define	SHADOW(ac, reg)	((ac)->shadow[((reg) / sizeof (uint16_t))])  argument
270 ac_get_dev(ac97_t *ac) in ac_get_dev() argument
272 return (ac->d); in ac_get_dev()
276 ac_get_prop(ac97_t *ac, char *prop, int defval) in ac_get_prop() argument
280 rv = ddi_prop_get_int(DDI_DEV_T_ANY, ac->dip, DDI_PROP_DONTPASS, in ac_get_prop()
289 #define WR(r, v) (ac)->wr((ac)->private, (r), (v))
290 #define RD(r) (ac)->rd((ac)->private, (r))
312 ac_probe_reg(ac97_t *ac, uint8_t reg) in ac_probe_reg() argument
332 ac_probe_tone(ac97_t *ac) in ac_probe_tone() argument
335 if (ac->caps & RR_BASS_TREBLE) in ac_probe_tone()
345 ac_probe_loud(ac97_t *ac) in ac_probe_loud() argument
348 if (ac->caps & RR_LOUDNESS_SUPPORT) in ac_probe_loud()
358 ac_probe_mmic(ac97_t *ac) in ac_probe_mmic() argument
361 if (ac->caps & RR_DEDICATED_MIC) in ac_probe_mmic()
371 ac_probe_stsim(ac97_t *ac) in ac_probe_stsim() argument
374 if (ac->caps & RR_PSEUDO_STEREO) in ac_probe_stsim()
384 ac_probe_pcbeep(ac97_t *ac) in ac_probe_pcbeep() argument
386 return (ac_probe_reg(ac, AC97_PC_BEEP_REGISTER)); in ac_probe_pcbeep()
393 ac_probe_rear(ac97_t *ac) in ac_probe_rear() argument
395 if (ac->flags & AC97_FLAG_AUX_4CH) in ac_probe_rear()
406 ac_probe_mic(ac97_t *ac) in ac_probe_mic() argument
408 if ((!(ac->flags & AC97_FLAG_NO_MIC)) && in ac_probe_mic()
409 (ac_probe_reg(ac, AC97_MIC_VOLUME_REGISTER))) { in ac_probe_mic()
410 ac->inputs |= (1U << INPUT_MIC); in ac_probe_mic()
420 ac_probe_headphone(ac97_t *ac) in ac_probe_headphone() argument
423 if ((ac->flags & AC97_FLAG_AUX_HP) && in ac_probe_headphone()
424 !(ac->flags & AC97_FLAG_NO_HEADPHONE)) { in ac_probe_headphone()
434 ac_probe_auxout(ac97_t *ac) in ac_probe_auxout() argument
437 if ((ac->flags & AC97_FLAG_AUX_LVL) && in ac_probe_auxout()
438 !(ac->flags & AC97_FLAG_NO_AUXOUT)) { in ac_probe_auxout()
448 ac_probe_auxin(ac97_t *ac) in ac_probe_auxin() argument
450 if ((!(ac->flags & AC97_FLAG_NO_AUXIN)) && in ac_probe_auxin()
451 (ac_probe_reg(ac, AC97_AUX_VOLUME_REGISTER))) { in ac_probe_auxin()
452 ac->inputs |= (1U << INPUT_AUXIN); in ac_probe_auxin()
462 ac_probe_phone(ac97_t *ac) in ac_probe_phone() argument
464 if ((!(ac->flags & AC97_FLAG_NO_PHONE)) && in ac_probe_phone()
465 (ac_probe_reg(ac, AC97_PHONE_VOLUME_REGISTER))) { in ac_probe_phone()
466 ac->inputs |= (1U << INPUT_PHONE); in ac_probe_phone()
476 ac_probe_mono(ac97_t *ac) in ac_probe_mono() argument
478 if (!(ac->flags & AC97_FLAG_SPEAKER_OK)) { in ac_probe_mono()
481 if (ac_probe_reg(ac, AC97_MONO_MASTER_VOLUME_REGISTER)) { in ac_probe_mono()
491 ac_probe_linein(ac97_t *ac) in ac_probe_linein() argument
493 if ((!(ac->flags & AC97_FLAG_NO_LINEIN)) && in ac_probe_linein()
494 (ac_probe_reg(ac, AC97_LINE_IN_VOLUME_REGISTER))) { in ac_probe_linein()
495 ac->inputs |= (1U << INPUT_LINEIN); in ac_probe_linein()
505 ac_probe_cdrom(ac97_t *ac) in ac_probe_cdrom() argument
507 if ((!(ac->flags & AC97_FLAG_NO_CDROM)) && in ac_probe_cdrom()
508 (ac_probe_reg(ac, AC97_CD_VOLUME_REGISTER))) { in ac_probe_cdrom()
509 ac->inputs |= (1U << INPUT_CD); in ac_probe_cdrom()
519 ac_probe_video(ac97_t *ac) in ac_probe_video() argument
521 if ((!(ac->flags & AC97_FLAG_NO_VIDEO)) && in ac_probe_video()
522 (ac_probe_reg(ac, AC97_VIDEO_VOLUME_REGISTER))) { in ac_probe_video()
523 ac->inputs |= (1U << INPUT_VIDEO); in ac_probe_video()
533 ac_probe_3d(ac97_t *ac) in ac_probe_3d() argument
536 if (ac->caps & RR_3D_STEREO_ENHANCE_MASK) in ac_probe_3d()
543 ac_probe_3d_impl(ac97_t *ac, uint16_t mask) in ac_probe_3d_impl() argument
548 if ((ac->caps & RR_3D_STEREO_ENHANCE_MASK) == 0) in ac_probe_3d_impl()
563 ac_probe_3d_depth(ac97_t *ac) in ac_probe_3d_depth() argument
565 return (ac_probe_3d_impl(ac, TDCR_DEPTH_MASK)); in ac_probe_3d_depth()
569 ac_probe_3d_center(ac97_t *ac) in ac_probe_3d_center() argument
571 return (ac_probe_3d_impl(ac, TDCR_CENTER_MASK)); in ac_probe_3d_center()
578 ac_probe_center(ac97_t *ac) in ac_probe_center() argument
596 ac_probe_lfe(ac97_t *ac) in ac_probe_lfe() argument
614 ac_probe_front(ac97_t *ac) in ac_probe_front() argument
628 ac_probe_lineout(ac97_t *ac) in ac_probe_lineout() argument
631 return (!ac_probe_front(ac)); in ac_probe_lineout()
651 ac_wr(ac97_t *ac, uint8_t reg, uint16_t val) in ac_wr() argument
654 SHADOW(ac, reg) = val; in ac_wr()
657 ac->wr(ac->private, reg, val); in ac_wr()
667 ac_rd(ac97_t *ac, uint8_t reg) in ac_rd() argument
670 return (SHADOW(ac, reg)); in ac_rd()
672 return (ac->rd(ac->private, reg)); in ac_rd()
680 ac_set(ac97_t *ac, uint8_t reg, uint16_t val) in ac_set() argument
682 ac_wr(ac, reg, ac->rd(ac->private, reg) | val); in ac_set()
690 ac_clr(ac97_t *ac, uint8_t reg, uint16_t val) in ac_clr() argument
692 ac_wr(ac, reg, ac->rd(ac->private, reg) & ~val); in ac_clr()
703 ac97_control_find(ac97_t *ac, const char *name) in ac97_control_find() argument
706 list_t *l = &ac->ctrls; in ac97_control_find()
721 ac_restore(ac97_t *ac) in ac_restore() argument
728 ac->wr(ac->private, i, SHADOW(ac, i)); in ac_restore()
737 ac_init_values(ac97_t *ac) in ac_init_values() argument
741 for (ctrl = list_head(&ac->ctrls); ctrl; in ac_init_values()
742 ctrl = list_next(&ac->ctrls, ctrl)) { in ac_init_values()
755 ac97_t *ac = ctrl->actrl_ac97; in ac_insrc_set() local
761 ac_wr(ac, AC97_RECORD_SELECT_CTRL_REGISTER, in ac_insrc_set()
769 ac97_t *ac = ctrl->actrl_ac97; in ac_gpr_toggle() local
772 v = SHADOW(ac, AC97_GENERAL_PURPOSE_REGISTER); in ac_gpr_toggle()
778 ac_wr(ac, AC97_GENERAL_PURPOSE_REGISTER, v); in ac_gpr_toggle()
829 ac97_t *ac = ctrl->actrl_ac97; in ac_stereo_set() local
837 ac_wr(ac, reg, ac_val_scale(left, right, ctrl->actrl_bits) | mute); in ac_stereo_set()
843 ac97_t *ac = ctrl->actrl_ac97; in ac_mono_set() local
854 v = SHADOW(ac, reg); in ac_mono_set()
861 ac_wr(ac, reg, v); in ac_mono_set()
1009 ac97_t *ac = ctrl->actrl_ac97; in ac97_micboost_set() local
1012 v = SHADOW(ac, AC97_MIC_VOLUME_REGISTER); in ac97_micboost_set()
1018 ac_wr(ac, AC97_MIC_VOLUME_REGISTER, v); in ac97_micboost_set()
1099 ac_analog_reset(ac97_t *ac) in ac_analog_reset() argument
1121 SHADOW(ac, AC97_POWERDOWN_CTRL_STAT_REGISTER) = tmp; in ac_analog_reset()
1127 audio_dev_warn(ac->d, "AC'97 analog power up timed out"); in ac_analog_reset()
1143 ac_hw_reset(ac97_t *ac) in ac_hw_reset() argument
1148 if (ac->flags & AC97_FLAG_AMPLIFIER) { in ac_hw_reset()
1150 ac_wr(ac, AC97_POWERDOWN_CTRL_STAT_REGISTER, 0); in ac_hw_reset()
1153 ac_wr(ac, AC97_POWERDOWN_CTRL_STAT_REGISTER, PCSR_EAPD); in ac_hw_reset()
1156 ac_wr(ac, AC97_GENERAL_PURPOSE_REGISTER, 0); in ac_hw_reset()
1158 switch (ac->vid) { in ac_hw_reset()
1178 ac_wr(ac, AC97_HEADPHONE_VOLUME_REGISTER, 0x0808); in ac_hw_reset()
1204 ac_clr(ac, AC97_EXTENDED_AUDIO_STAT_CTRL_REGISTER, in ac_hw_reset()
1219 if (ac->codec_reset != NULL) { in ac_hw_reset()
1220 ac->codec_reset(ac); in ac_hw_reset()
1224 ac_clr(ac, AC97_EXTENDED_AUDIO_STAT_CTRL_REGISTER, EASCR_VRA); in ac_hw_reset()
1232 ac97_reset(ac97_t *ac) in ac97_reset() argument
1234 ac_analog_reset(ac); in ac97_reset()
1235 ac_hw_reset(ac); in ac97_reset()
1236 ac_restore(ac); in ac97_reset()
1243 ac97_num_channels(ac97_t *ac) in ac97_num_channels() argument
1245 return (ac->nchan); in ac97_num_channels()
1256 ac97_t *ac = ctrl->actrl_ac97; in ac97_control_register() local
1257 ASSERT(ac->d != NULL); in ac97_control_register()
1262 ctrl->actrl_ctrl = audio_dev_add_control(ac->d, &ctrl->actrl_desc, in ac97_control_register()
1265 audio_dev_warn(ac->d, "AC97 %s alloc failed", in ac97_control_register()
1294 ac97_register_controls(ac97_t *ac) in ac97_register_controls() argument
1298 for (ctrl = list_head(&ac->ctrls); ctrl; in ac97_register_controls()
1299 ctrl = list_next(&ac->ctrls, ctrl)) { in ac97_register_controls()
1307 ac97_walk_controls(ac97_t *ac, ac97_ctrl_walk_t walker, void *arg) in ac97_walk_controls() argument
1311 for (ctrl = list_head(&ac->ctrls); ctrl; in ac97_walk_controls()
1312 ctrl = list_next(&ac->ctrls, ctrl)) { in ac97_walk_controls()
1320 ac_add_control(ac97_t *ac, ac97_ctrl_probe_t *cpt) in ac_add_control() argument
1325 ASSERT(ac); in ac_add_control()
1326 ASSERT(ac->d); in ac_add_control()
1328 ctrl = ac97_control_find(ac, cpt->cp_name); in ac_add_control()
1335 ctrl->actrl_ac97 = ac; in ac_add_control()
1364 list_insert_tail(&ac->ctrls, ctrl); in ac_add_control()
1373 ac97_t *ac = ctrl->actrl_ac97; in ac97_control_remove() local
1375 list_remove(&ac->ctrls, ctrl); in ac97_control_remove()
1540 ac_probeinit_ctrls(ac97_t *ac, int vol_bits, int enh_bits) in ac_probeinit_ctrls() argument
1545 ASSERT(ac); in ac_probeinit_ctrls()
1550 ac->inputs = (1U << INPUT_STEREOMIX) | (1U << INPUT_MONOMIX); in ac_probeinit_ctrls()
1555 my_cpt.cp_minval |= ac->inputs; in ac_probeinit_ctrls()
1556 my_cpt.cp_maxval |= ac->inputs; in ac_probeinit_ctrls()
1560 if (ac->flags & AC97_FLAG_MICBOOST) in ac_probeinit_ctrls()
1576 if (!my_cpt.cp_probe || my_cpt.cp_probe(ac)) { in ac_probeinit_ctrls()
1577 ac_add_control(ac, &my_cpt); in ac_probeinit_ctrls()
1581 if (ac->codec_init != NULL) { in ac_probeinit_ctrls()
1582 ac->codec_init(ac); in ac_probeinit_ctrls()
1594 ac97_t *ac; in ac97_alloc() local
1596 ac = kmem_zalloc(sizeof (ac97_t), KM_SLEEP); in ac97_alloc()
1597 ac->dip = dip; in ac97_alloc()
1598 ac->rd = rd; in ac97_alloc()
1599 ac->wr = wr; in ac97_alloc()
1600 ac->private = priv; in ac97_alloc()
1602 list_create(&ac->ctrls, sizeof (struct ac97_ctrl), in ac97_alloc()
1608 ac->flags |= (flag); \ in ac97_alloc()
1610 ac->flags &= ~(flag); \ in ac97_alloc()
1663 ac->flags |= AC97_FLAG_SPEAKER_OK; in ac97_alloc()
1668 ac->flags |= AC97_FLAG_SPEAKER_OK; in ac97_alloc()
1678 return (ac); in ac97_alloc()
1689 ac97_t *ac; in ac97_allocate() local
1691 ac = ac97_alloc(dip, rd, wr, priv); in ac97_allocate()
1692 if (ac != NULL) { in ac97_allocate()
1693 ac->d = adev; in ac97_allocate()
1695 return (ac); in ac97_allocate()
1702 ac97_free(ac97_t *ac) in ac97_free() argument
1707 while ((ctrl = list_head(&ac->ctrls)) != NULL) { in ac97_free()
1711 list_destroy(&ac->ctrls); in ac97_free()
1712 kmem_free(ac, sizeof (ac97_t)); in ac97_free()
1748 void (*init)(ac97_t *ac);
1749 void (*reset)(ac97_t *ac);
1825 ac97_probe_controls(ac97_t *ac) in ac97_probe_controls() argument
1838 ASSERT(ac->d); in ac97_probe_controls()
1840 ac_analog_reset(ac); in ac97_probe_controls()
1846 audio_dev_warn(ac->d, "AC'97 codec unresponsive"); in ac97_probe_controls()
1850 ac->vid = (vid1 << 16) | vid2; in ac97_probe_controls()
1857 if (ac->vid == codecs[i].id) { in ac97_probe_controls()
1860 ac->codec_init = codecs[i].init; in ac97_probe_controls()
1865 if ((ac->vid & 0xffffff00) == vendors[i].id) { in ac97_probe_controls()
1883 SHADOW(ac, i) = RD(i); in ac97_probe_controls()
1886 ac->caps = RD(AC97_RESET_REGISTER); in ac97_probe_controls()
1903 if (ac->caps & RR_HEADPHONE_SUPPORT) { in ac97_probe_controls()
1905 if (ac_probe_reg(ac, AC97_HEADPHONE_VOLUME_REGISTER)) { in ac97_probe_controls()
1907 ac->flags |= AC97_FLAG_AUX_HP; in ac97_probe_controls()
1917 if ((!(ac->flags & AC97_FLAG_AUX_HP)) && (ear & EAR_SDAC)) { in ac97_probe_controls()
1918 if (ac_probe_reg(ac, AC97_EXTENDED_LRS_VOLUME_REGISTER)) { in ac97_probe_controls()
1919 ac->flags |= AC97_FLAG_AUX_4CH; in ac97_probe_controls()
1926 if (!(ac->flags & (AC97_FLAG_AUX_HP | AC97_FLAG_AUX_4CH))) { in ac97_probe_controls()
1927 if (ac_probe_reg(ac, AC97_HEADPHONE_VOLUME_REGISTER)) { in ac97_probe_controls()
1928 ac->flags |= AC97_FLAG_AUX_LVL; in ac97_probe_controls()
1935 ac->nchan = 2; in ac97_probe_controls()
1937 ac->nchan += 2; in ac97_probe_controls()
1940 ac->nchan++; in ac97_probe_controls()
1943 ac->nchan++; in ac97_probe_controls()
1946 ac->flags |= flags; in ac97_probe_controls()
1947 (void) snprintf(ac->name, sizeof (ac->name), "%s %s", vendor, name); in ac97_probe_controls()
1949 (void) snprintf(buf, sizeof (buf), "AC'97 codec: %s", ac->name); in ac97_probe_controls()
1950 audio_dev_add_info(ac->d, buf); in ac97_probe_controls()
1954 ddi_driver_name(ac->dip), ddi_get_instance(ac->dip), in ac97_probe_controls()
1955 ac->name, ac->vid, ac->nchan, ac->caps); in ac97_probe_controls()
1960 ac_probeinit_ctrls(ac, vol_bits, enh_bits); in ac97_probe_controls()
1962 ac_hw_reset(ac); in ac97_probe_controls()
1963 ac_init_values(ac); in ac97_probe_controls()
1974 ac97_init(ac97_t *ac, struct audio_dev *d) in ac97_init() argument
1977 ASSERT(ac->d == NULL); in ac97_init()
1980 ac->d = d; in ac97_init()
1982 ac97_probe_controls(ac); in ac97_init()
1983 ac97_register_controls(ac); in ac97_init()