Lines Matching +full:xps +full:- +full:timer +full:- +full:1
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause
11 * 1. Redistributions of source code must retain the above copyright
30 /*-
38 * 1. Redistributions of source code must retain the above copyright
119 /* 2 DAC for playback, 1 ADC for record */
121 #define ES_DAC2 1
128 #define ES_BLK_ALIGN (~(ES_BLK_MIN - 1))
148 * 32bit Ensoniq Configuration (es->escfg).
149 * ----------------------------------------
151 * +-------+--------+------+------+---------+--------+---------+---------+
152 * len | 16 | 1 | 1 | 1 | 2 | 2 | 1 | 8 |
153 * +-------+--------+------+------+---------+--------+---------+---------+
157 * +-------+--------+------+------+---------+--------+---------+---------+
166 (((cfgv) & ~0x8000) | (((nv) ? 1 : 0) << 15))
186 (((cfgv) & ~0x100) | (((nv) ? 1 : 0) << 8))
193 (ES_NUMPLAY(cfgv) > 1 || \
194 (ES_NUMPLAY(cfgv) == 1 && ES_DAC_FIRST(cfgv) == ES_DAC1))
196 (ES_NUMPLAY(cfgv) > 1 || \
197 (ES_NUMPLAY(cfgv) == 1 && ES_DAC_FIRST(cfgv) == ES_DAC2))
200 * DAC 1/2 configuration through kernel hint - hint.pcm.<unit>.dac="val"
202 * 0 = Enable both DACs - Default
203 * 1 = Enable single DAC (DAC1)
232 #define ES_LOCK(sc) snd_mtxlock((sc)->lock)
233 #define ES_UNLOCK(sc) snd_mtxunlock((sc)->lock)
234 #define ES_LOCK_ASSERT(sc) snd_mtxassert((sc)->lock)
248 SND_FORMAT(AFMT_U8, 1, 0),
250 SND_FORMAT(AFMT_S16_LE, 1, 0),
260 unsigned stereo:1;
262 unsigned avail:1;
264 [SOUND_MIXER_VOLUME] = { 0, 0x0, 0x1, 1, 0x1f7f, 1 },
265 [SOUND_MIXER_PCM] = { 1, 0x2, 0x3, 1, 0x0400, 1 },
266 [SOUND_MIXER_SYNTH] = { 2, 0x4, 0x5, 1, 0x0060, 1 },
267 [SOUND_MIXER_CD] = { 3, 0x6, 0x7, 1, 0x0006, 1 },
268 [SOUND_MIXER_LINE] = { 4, 0x8, 0x9, 1, 0x0018, 1 },
269 [SOUND_MIXER_LINE1] = { 5, 0xa, 0xb, 1, 0x1800, 1 },
270 [SOUND_MIXER_LINE2] = { 6, 0xc, 0x0, 0, 0x0100, 1 },
271 [SOUND_MIXER_LINE3] = { 7, 0xd, 0x0, 0, 0x0200, 1 },
272 [SOUND_MIXER_MIC] = { 8, 0xe, 0x0, 0, 0x0001, 1 },
273 [SOUND_MIXER_OGAIN] = { 9, 0xf, 0x0, 0, 0x0000, 1 }
280 case 1: in es_rd()
281 return (bus_space_read_1(es->st, es->sh, regno)); in es_rd()
283 return (bus_space_read_2(es->st, es->sh, regno)); in es_rd()
285 return (bus_space_read_4(es->st, es->sh, regno)); in es_rd()
296 case 1: in es_wr()
297 bus_space_write_1(es->st, es->sh, regno, data); in es_wr()
300 bus_space_write_2(es->st, es->sh, regno, data); in es_wr()
303 bus_space_write_4(es->st, es->sh, regno, data); in es_wr()
308 /* -------------------------------------------------------------------- */
322 v |= (1 << i); in es1370_mixinit()
331 if (ES_SINGLE_PCM_MIX(es->escfg)) in es1370_mixinit()
332 v &= ~(1 << SOUND_MIXER_SYNTH); in es1370_mixinit()
337 v |= (1 << i); in es1370_mixinit()
339 if (ES_SINGLE_PCM_MIX(es->escfg)) /* ditto */ in es1370_mixinit()
340 v &= ~(1 << SOUND_MIXER_SYNTH); in es1370_mixinit()
352 return (-1); in es1370_mixset()
356 rl = (l < 2) ? 0x80 : 7 - (l - 2) / 14; in es1370_mixset()
358 rl = (l < 7) ? 0x80 : 31 - (l - 7) / 3; in es1370_mixset()
361 if (dev == SOUND_MIXER_PCM && (ES_SINGLE_PCM_MIX(es->escfg)) && in es1370_mixset()
362 ES_DAC1_ENABLED(es->escfg)) in es1370_mixset()
363 set_dac1 = 1; in es1370_mixset()
367 rr = (r < 7) ? 0x80 : 31 - (r - 7) / 3; in es1370_mixset()
388 if (src == 0) src = 1 << SOUND_MIXER_MIC; in es1370_mixsetrecsrc()
391 if ((src & (1 << i)) != 0) j |= mixtable[i].recmask; in es1370_mixsetrecsrc()
394 if ((src & (1 << SOUND_MIXER_PCM)) && ES_SINGLE_PCM_MIX(es->escfg) && in es1370_mixsetrecsrc()
395 ES_DAC1_ENABLED(es->escfg)) in es1370_mixsetrecsrc()
416 /* -------------------------------------------------------------------- */
432 DELAY(1); in es1370_wrcodec()
434 device_printf(es->dev, "%s: timed out\n", __func__); in es1370_wrcodec()
435 return (-1); in es1370_wrcodec()
438 /* -------------------------------------------------------------------- */
452 index = ES_GP(es->escfg); in eschan_init()
453 es->escfg = ES_SET_GP(es->escfg, index + 1); in eschan_init()
455 index = ES_DAC_FIRST(es->escfg); in eschan_init()
456 else if (index == 1) in eschan_init()
457 index = ES_DAC_SECOND(es->escfg); in eschan_init()
459 device_printf(es->dev, in eschan_init()
465 device_printf(es->dev, "Unknown DAC: %d\n", index + 1); in eschan_init()
469 if (es->ch[index].channel != NULL) { in eschan_init()
470 device_printf(es->dev, "DAC%d already initialized!\n", in eschan_init()
471 index + 1); in eschan_init()
478 ch = &es->ch[index]; in eschan_init()
479 ch->index = index; in eschan_init()
480 ch->num = es->num++; in eschan_init()
481 ch->caps = es_caps; in eschan_init()
482 if (ES_IS_ES1370(es->escfg)) { in eschan_init()
483 if (ch->index == ES_DAC1) { in eschan_init()
484 ch->caps.maxspeed = ES1370_DAC1_MAXSPEED; in eschan_init()
485 ch->caps.minspeed = ES1370_DAC1_MINSPEED; in eschan_init()
487 uint32_t fixed_rate = ES_FIXED_RATE(es->escfg); in eschan_init()
490 ch->caps.maxspeed = fixed_rate; in eschan_init()
491 ch->caps.minspeed = fixed_rate; in eschan_init()
495 ch->parent = es; in eschan_init()
496 ch->channel = c; in eschan_init()
497 ch->buffer = b; in eschan_init()
498 ch->bufsz = es->bufsz; in eschan_init()
499 ch->blkcnt = es->blkcnt; in eschan_init()
500 ch->blksz = ch->bufsz / ch->blkcnt; in eschan_init()
501 ch->dir = dir; in eschan_init()
503 if (sndbuf_alloc(ch->buffer, es->parent_dmat, 0, ch->bufsz) != 0) in eschan_init()
507 if (ch->index == ES_DAC1) { in eschan_init()
509 ES1370_REG_DAC1_FRAMEADR >> 8, 1); in eschan_init()
511 sndbuf_getbufaddr(ch->buffer), 4); in eschan_init()
513 (ch->bufsz >> 2) - 1, 4); in eschan_init()
516 ES1370_REG_DAC2_FRAMEADR >> 8, 1); in eschan_init()
518 sndbuf_getbufaddr(ch->buffer), 4); in eschan_init()
520 (ch->bufsz >> 2) - 1, 4); in eschan_init()
523 es_wr(es, ES1370_REG_MEMPAGE, ES1370_REG_ADC_FRAMEADR >> 8, 1); in eschan_init()
525 sndbuf_getbufaddr(ch->buffer), 4); in eschan_init()
527 (ch->bufsz >> 2) - 1, 4); in eschan_init()
537 struct es_info *es = ch->parent; in eschan_setformat()
540 if (ch->dir == PCMDIR_PLAY) { in eschan_setformat()
541 if (ch->index == ES_DAC1) { in eschan_setformat()
542 es->sctrl &= ~SCTRL_P1FMT; in eschan_setformat()
544 es->sctrl |= SCTRL_P1SEB; in eschan_setformat()
545 if (AFMT_CHANNEL(format) > 1) in eschan_setformat()
546 es->sctrl |= SCTRL_P1SMB; in eschan_setformat()
548 es->sctrl &= ~SCTRL_P2FMT; in eschan_setformat()
550 es->sctrl |= SCTRL_P2SEB; in eschan_setformat()
551 if (AFMT_CHANNEL(format) > 1) in eschan_setformat()
552 es->sctrl |= SCTRL_P2SMB; in eschan_setformat()
555 es->sctrl &= ~SCTRL_R1FMT; in eschan_setformat()
557 es->sctrl |= SCTRL_R1SEB; in eschan_setformat()
558 if (AFMT_CHANNEL(format) > 1) in eschan_setformat()
559 es->sctrl |= SCTRL_R1SMB; in eschan_setformat()
561 es_wr(es, ES1370_REG_SERIAL_CONTROL, es->sctrl, 4); in eschan_setformat()
563 ch->fmt = format; in eschan_setformat()
571 struct es_info *es = ch->parent; in eschan1370_setspeed()
575 if (ch->caps.minspeed == ch->caps.maxspeed) { in eschan1370_setspeed()
577 return (ch->caps.maxspeed); in eschan1370_setspeed()
579 if (speed < ch->caps.minspeed) in eschan1370_setspeed()
580 speed = ch->caps.minspeed; in eschan1370_setspeed()
581 if (speed > ch->caps.maxspeed) in eschan1370_setspeed()
582 speed = ch->caps.maxspeed; in eschan1370_setspeed()
583 if (ch->index == ES_DAC1) { in eschan1370_setspeed()
589 es->ctrl &= ~CTRL_WTSRSEL; in eschan1370_setspeed()
592 es->ctrl |= 0 << CTRL_SH_WTSRSEL; in eschan1370_setspeed()
595 es->ctrl |= 1 << CTRL_SH_WTSRSEL; in eschan1370_setspeed()
598 es->ctrl |= 2 << CTRL_SH_WTSRSEL; in eschan1370_setspeed()
601 es->ctrl |= 3 << CTRL_SH_WTSRSEL; in eschan1370_setspeed()
604 es->ctrl &= ~CTRL_PCLKDIV; in eschan1370_setspeed()
605 es->ctrl |= DAC2_SRTODIV(speed) << CTRL_SH_PCLKDIV; in eschan1370_setspeed()
607 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in eschan1370_setspeed()
616 struct es_info *es = ch->parent; in eschan1371_setspeed()
621 if (ch->dir == PCMDIR_PLAY) in eschan1371_setspeed()
622 i = es1371_dac_rate(es, speed, ch->index); /* play */ in eschan1371_setspeed()
624 i = es1371_adc_rate(es, speed, ch->index); /* record */ in eschan1371_setspeed()
626 delta = (speed > i) ? (speed - i) : (i - speed); in eschan1371_setspeed()
636 struct es_info *es = ch->parent; in eschan_setfragments()
640 if (blksz > (sndbuf_getmaxsize(ch->buffer) / ES_DMA_SEGS_MIN)) in eschan_setfragments()
641 blksz = sndbuf_getmaxsize(ch->buffer) / ES_DMA_SEGS_MIN; in eschan_setfragments()
649 while ((blksz * blkcnt) > sndbuf_getmaxsize(ch->buffer)) { in eschan_setfragments()
650 if ((blkcnt >> 1) >= ES_DMA_SEGS_MIN) in eschan_setfragments()
651 blkcnt >>= 1; in eschan_setfragments()
652 else if ((blksz >> 1) >= ES_BLK_MIN) in eschan_setfragments()
653 blksz >>= 1; in eschan_setfragments()
658 if ((sndbuf_getblksz(ch->buffer) != blksz || in eschan_setfragments()
659 sndbuf_getblkcnt(ch->buffer) != blkcnt) && in eschan_setfragments()
660 sndbuf_resize(ch->buffer, blkcnt, blksz) != 0) in eschan_setfragments()
661 device_printf(es->dev, "%s: failed blksz=%u blkcnt=%u\n", in eschan_setfragments()
664 ch->bufsz = sndbuf_getsize(ch->buffer); in eschan_setfragments()
665 ch->blksz = sndbuf_getblksz(ch->buffer); in eschan_setfragments()
666 ch->blkcnt = sndbuf_getblkcnt(ch->buffer); in eschan_setfragments()
675 struct es_info *es = ch->parent; in eschan_setblocksize()
677 eschan_setfragments(obj, data, blksz, es->blkcnt); in eschan_setblocksize()
679 return (ch->blksz); in eschan_setblocksize()
682 #define es_chan_active(es) ((es)->ch[ES_DAC1].active + \
683 (es)->ch[ES_DAC2].active + \
684 (es)->ch[ES_ADC].active)
693 if (ch == NULL || ch->channel == NULL || ch->active == 0) in es_poll_channel()
696 es = ch->parent; in es_poll_channel()
697 if (ch->dir == PCMDIR_PLAY) { in es_poll_channel()
698 if (ch->index == ES_DAC1) in es_poll_channel()
704 sz = ch->blksz * ch->blkcnt; in es_poll_channel()
708 ch->ptr = ptr; in es_poll_channel()
710 ptr &= ~(ch->blksz - 1); in es_poll_channel()
711 delta = (sz + ptr - ch->prevptr) % sz; in es_poll_channel()
713 if (delta < ch->blksz) in es_poll_channel()
716 ch->prevptr = ptr; in es_poll_channel()
718 return (1); in es_poll_channel()
732 if (es->polling == 0 || es_chan_active(es) == 0) { in es_poll_callback()
738 if (es_poll_channel(&es->ch[i]) != 0) in es_poll_callback()
739 trigger |= 1 << i; in es_poll_callback()
743 callout_reset(&es->poll_timer, 1/*es->poll_ticks*/, in es_poll_callback()
749 if (trigger & (1 << i)) in es_poll_callback()
750 chn_intr(es->ch[i].channel); in es_poll_callback()
758 struct es_info *es = ch->parent; in eschan_trigger()
765 cnt = (ch->blksz / sndbuf_getalign(ch->buffer)) - 1; in eschan_trigger()
766 if (ch->fmt & AFMT_16BIT) in eschan_trigger()
768 if (AFMT_CHANNEL(ch->fmt) > 1) in eschan_trigger()
770 if (ch->dir == PCMDIR_PLAY) { in eschan_trigger()
772 if (ch->index == ES_DAC1) { in eschan_trigger()
773 es->ctrl |= CTRL_DAC1_EN; in eschan_trigger()
774 es->sctrl &= ~(SCTRL_P1LOOPSEL | in eschan_trigger()
776 if (es->polling == 0) in eschan_trigger()
777 es->sctrl |= SCTRL_P1INTEN; in eschan_trigger()
779 es->sctrl &= ~SCTRL_P1INTEN; in eschan_trigger()
780 es->sctrl |= b; in eschan_trigger()
786 (ch->bufsz >> 2) - 1, 4); in eschan_trigger()
788 es->ctrl |= CTRL_DAC2_EN; in eschan_trigger()
789 es->sctrl &= ~(SCTRL_P2ENDINC | SCTRL_P2STINC | in eschan_trigger()
792 if (es->polling == 0) in eschan_trigger()
793 es->sctrl |= SCTRL_P2INTEN; in eschan_trigger()
795 es->sctrl &= ~SCTRL_P2INTEN; in eschan_trigger()
796 es->sctrl |= (b << 2) | in eschan_trigger()
797 ((((b >> 1) & 1) + 1) << SCTRL_SH_P2ENDINC); in eschan_trigger()
803 (ch->bufsz >> 2) - 1, 4); in eschan_trigger()
806 es->ctrl &= ~((ch->index == ES_DAC1) ? in eschan_trigger()
810 es->ctrl |= CTRL_ADC_EN; in eschan_trigger()
811 es->sctrl &= ~SCTRL_R1LOOPSEL; in eschan_trigger()
812 if (es->polling == 0) in eschan_trigger()
813 es->sctrl |= SCTRL_R1INTEN; in eschan_trigger()
815 es->sctrl &= ~SCTRL_R1INTEN; in eschan_trigger()
816 es->sctrl |= b << 4; in eschan_trigger()
822 (ch->bufsz >> 2) - 1, 4); in eschan_trigger()
824 es->ctrl &= ~CTRL_ADC_EN; in eschan_trigger()
826 es_wr(es, ES1370_REG_SERIAL_CONTROL, es->sctrl, 4); in eschan_trigger()
827 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in eschan_trigger()
829 if (es->polling != 0) { in eschan_trigger()
830 ch->ptr = 0; in eschan_trigger()
831 ch->prevptr = 0; in eschan_trigger()
833 es->poll_ticks = 1; in eschan_trigger()
834 callout_reset(&es->poll_timer, 1, in eschan_trigger()
838 ch->active = 1; in eschan_trigger()
840 ch->active = 0; in eschan_trigger()
841 if (es->polling != 0) { in eschan_trigger()
843 callout_stop(&es->poll_timer); in eschan_trigger()
844 es->poll_ticks = 1; in eschan_trigger()
856 struct es_info *es = ch->parent; in eschan_getptr()
860 if (es->polling != 0) in eschan_getptr()
861 cnt = ch->ptr; in eschan_getptr()
863 if (ch->dir == PCMDIR_PLAY) { in eschan_getptr()
864 if (ch->index == ES_DAC1) in eschan_getptr()
887 return (&ch->caps); in eschan_getcaps()
916 /* -------------------------------------------------------------------- */
925 if (es->polling != 0) { in es_intr()
935 sctrl = es->sctrl; in es_intr()
944 es_wr(es, ES1370_REG_SERIAL_CONTROL, es->sctrl, 4); in es_intr()
948 chn_intr(es->ch[ES_ADC].channel); in es_intr()
950 chn_intr(es->ch[ES_DAC1].channel); in es_intr()
952 chn_intr(es->ch[ES_DAC2].channel); in es_intr()
963 if (resource_int_value(device_get_name(es->dev), in es1370_init()
964 device_get_unit(es->dev), "fixed_rate", &r) == 0) { in es1370_init()
975 if (resource_int_value(device_get_name(es->dev), in es1370_init()
976 device_get_unit(es->dev), "single_pcm_mixer", &r) == 0) in es1370_init()
977 single_pcm = (r != 0) ? 1 : 0; in es1370_init()
979 single_pcm = 1; in es1370_init()
982 if (ES_NUMPLAY(es->escfg) == 1) in es1370_init()
983 single_pcm = 1; in es1370_init()
985 es->escfg = ES_SET_IS_ES1370(es->escfg, 1); in es1370_init()
987 es->escfg = ES_SET_FIXED_RATE(es->escfg, fixed_rate); in es1370_init()
989 es->escfg = ES_SET_FIXED_RATE(es->escfg, 0); in es1370_init()
993 es->escfg = ES_SET_SINGLE_PCM_MIX(es->escfg, 1); in es1370_init()
995 es->escfg = ES_SET_SINGLE_PCM_MIX(es->escfg, 0); in es1370_init()
996 es->ctrl = CTRL_CDC_EN | CTRL_JYSTK_EN | CTRL_SERR_DIS | in es1370_init()
998 es->ctrl |= 3 << CTRL_SH_WTSRSEL; in es1370_init()
999 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in es1370_init()
1001 es->sctrl = 0; in es1370_init()
1002 es_wr(es, ES1370_REG_SERIAL_CONTROL, es->sctrl, 4); in es1370_init()
1029 es->escfg = ES_SET_IS_ES1370(es->escfg, 0); in es1371_init()
1030 es->num = 0; in es1371_init()
1031 es->sctrl = 0; in es1371_init()
1033 devid = pci_get_devid(es->dev); in es1371_init()
1034 revid = pci_get_revid(es->dev); in es1371_init()
1035 subdev = (pci_get_subdevice(es->dev) << 16) | in es1371_init()
1036 pci_get_subvendor(es->dev); in es1371_init()
1044 es->ctrl = 0; in es1371_init()
1047 es->ctrl = CTRL_JYSTK_EN; in es1371_init()
1052 es->ctrl |= (1 << 16); in es1371_init()
1055 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in es1371_init()
1056 es_wr(es, ES1370_REG_SERIAL_CONTROL, es->sctrl, 4); in es1371_init()
1063 cssr = 1 << 29; in es1371_init()
1068 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in es1371_init()
1071 es_wr(es, ES1370_REG_CONTROL, es->sctrl, 4); in es1371_init()
1081 es1371_src_write(es, ES_SMPREG_VOL_ADC, 1 << 12); in es1371_init()
1082 es1371_src_write(es, ES_SMPREG_VOL_ADC + 1, 1 << 12); in es1371_init()
1083 es1371_src_write(es, ES_SMPREG_VOL_DAC1, 1 << 12); in es1371_init()
1084 es1371_src_write(es, ES_SMPREG_VOL_DAC1 + 1, 1 << 12); in es1371_init()
1085 es1371_src_write(es, ES_SMPREG_VOL_DAC2, 1 << 12); in es1371_init()
1086 es1371_src_write(es, ES_SMPREG_VOL_DAC2 + 1, 1 << 12); in es1371_init()
1107 /* -------------------------------------------------------------------- */
1199 /* -------------------------------------------------------------------- */
1236 if ((1 << n) & ((1 << 15) | (1 << 13) | (1 << 11) | (1 << 9))) in es1371_adc_rate()
1237 n--; in es1371_adc_rate()
1238 truncm = (21 * n - 1) | 1; in es1371_adc_rate()
1246 (((239 - truncm) >> 1) << 9) | (n << 4)); in es1371_adc_rate()
1251 0x8000 | (((119 - truncm) >> 1) << 9) | (n << 4)); in es1371_adc_rate()
1259 es1371_src_write(es, ES_SMPREG_VOL_ADC + 1, n << 8); in es1371_adc_rate()
1302 DELAY(1); in es1371_wait_src_ready()
1304 device_printf(es->dev, "%s: timed out 0x%x [0x%x]\n", __func__, in es1371_wait_src_ready()
1309 /* -------------------------------------------------------------------- */
1325 device_set_desc(dev, "AudioPCI ES1371-A"); in es_pci_probe()
1328 device_set_desc(dev, "AudioPCI ES1371-B"); in es_pci_probe()
1331 device_set_desc(dev, "AudioPCI ES1373-A"); in es_pci_probe()
1334 device_set_desc(dev, "AudioPCI ES1373-B"); in es_pci_probe()
1337 device_set_desc(dev, "AudioPCI ES1373-8"); in es_pci_probe()
1340 device_set_desc(dev, "Creative CT5880-A"); in es_pci_probe()
1343 device_set_desc(dev, "AudioPCI ES1371-?"); in es_pci_probe()
1345 "unknown revision %d -- please report to " in es_pci_probe()
1346 "freebsd-multimedia@freebsd.org\n", in es_pci_probe()
1351 device_set_desc(dev, "Strange AudioPCI ES1371-? (vid=3274)"); in es_pci_probe()
1353 "unknown revision %d -- please report to " in es_pci_probe()
1354 "freebsd-multimedia@freebsd.org\n", pci_get_revid(dev)); in es_pci_probe()
1363 device_set_desc(dev, "Creative SB AudioPCI CT4730-?"); in es_pci_probe()
1365 "unknown revision %d -- please report to " in es_pci_probe()
1366 "freebsd-multimedia@freebsd.org\n", in es_pci_probe()
1373 device_set_desc(dev, "Creative CT5880-C"); in es_pci_probe()
1376 device_set_desc(dev, "Creative CT5880-D"); in es_pci_probe()
1379 device_set_desc(dev, "Creative CT5880-E"); in es_pci_probe()
1382 device_set_desc(dev, "Creative CT5880-?"); in es_pci_probe()
1384 "unknown revision %d -- please report to " in es_pci_probe()
1385 "freebsd-multimedia@freebsd.org\n", in es_pci_probe()
1402 dev = oidp->oid_arg1; in sysctl_es137x_spdif_enable()
1407 new_en = (r & ENABLE_SPDIF) ? 1 : 0; in sysctl_es137x_spdif_enable()
1410 if (err || req->newptr == NULL) in sysctl_es137x_spdif_enable()
1412 if (new_en < 0 || new_en > 1) in sysctl_es137x_spdif_enable()
1418 es->ctrl |= SPDIFEN_B; in sysctl_es137x_spdif_enable()
1419 es->ctrl |= RECEN_B; in sysctl_es137x_spdif_enable()
1422 es->ctrl &= ~SPDIFEN_B; in sysctl_es137x_spdif_enable()
1423 es->ctrl &= ~RECEN_B; in sysctl_es137x_spdif_enable()
1425 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in sysctl_es137x_spdif_enable()
1440 dev = oidp->oid_arg1; in sysctl_es137x_latency_timer()
1443 val = pci_read_config(dev, PCIR_LATTIMER, 1); in sysctl_es137x_latency_timer()
1447 if (err || req->newptr == NULL) in sysctl_es137x_latency_timer()
1453 pci_write_config(dev, PCIR_LATTIMER, val, 1); in sysctl_es137x_latency_timer()
1467 dev = oidp->oid_arg1; in sysctl_es137x_fixed_rate()
1470 val = ES_FIXED_RATE(es->escfg); in sysctl_es137x_fixed_rate()
1476 if (err || req->newptr == NULL) in sysctl_es137x_fixed_rate()
1482 if (es->ctrl & (CTRL_DAC2_EN|CTRL_ADC_EN)) { in sysctl_es137x_fixed_rate()
1487 if (val != ES_FIXED_RATE(es->escfg)) { in sysctl_es137x_fixed_rate()
1488 es->escfg = ES_SET_FIXED_RATE(es->escfg, val); in sysctl_es137x_fixed_rate()
1489 es->ch[ES_DAC2].caps.maxspeed = val; in sysctl_es137x_fixed_rate()
1490 es->ch[ES_DAC2].caps.minspeed = val; in sysctl_es137x_fixed_rate()
1491 es->ch[ES_ADC].caps.maxspeed = val; in sysctl_es137x_fixed_rate()
1492 es->ch[ES_ADC].caps.minspeed = val; in sysctl_es137x_fixed_rate()
1493 es->ctrl &= ~CTRL_PCLKDIV; in sysctl_es137x_fixed_rate()
1494 es->ctrl |= DAC2_SRTODIV(val) << CTRL_SH_PCLKDIV; in sysctl_es137x_fixed_rate()
1495 es_wr(es, ES1370_REG_CONTROL, es->ctrl, 4); in sysctl_es137x_fixed_rate()
1498 es->escfg = ES_SET_FIXED_RATE(es->escfg, 0); in sysctl_es137x_fixed_rate()
1499 es->ch[ES_DAC2].caps = es_caps; in sysctl_es137x_fixed_rate()
1500 es->ch[ES_ADC].caps = es_caps; in sysctl_es137x_fixed_rate()
1517 dev = oidp->oid_arg1; in sysctl_es137x_single_pcm_mixer()
1519 if (!PCM_REGISTERED(d) || d->mixer_dev == NULL || in sysctl_es137x_single_pcm_mixer()
1520 d->mixer_dev->si_drv1 == NULL) in sysctl_es137x_single_pcm_mixer()
1522 es = d->devinfo; in sysctl_es137x_single_pcm_mixer()
1526 set = ES_SINGLE_PCM_MIX(es->escfg); in sysctl_es137x_single_pcm_mixer()
1531 if (err || req->newptr == NULL) in sysctl_es137x_single_pcm_mixer()
1533 if (!(val == 0 || val == 1)) in sysctl_es137x_single_pcm_mixer()
1538 m = (d->mixer_dev != NULL) ? d->mixer_dev->si_drv1 : NULL; in sysctl_es137x_single_pcm_mixer()
1555 if (es->ctrl & (CTRL_ADC_EN | CTRL_DAC1_EN | CTRL_DAC2_EN)) { in sysctl_es137x_single_pcm_mixer()
1561 es->escfg = ES_SET_SINGLE_PCM_MIX(es->escfg, 1); in sysctl_es137x_single_pcm_mixer()
1563 es->escfg = ES_SET_SINGLE_PCM_MIX(es->escfg, 0); in sysctl_es137x_single_pcm_mixer()
1566 mix_setdevs(m, mix_getdevs(m) | (1 << SOUND_MIXER_SYNTH)); in sysctl_es137x_single_pcm_mixer()
1567 mix_setrecdevs(m, mix_getrecdevs(m) | (1 << SOUND_MIXER_SYNTH)); in sysctl_es137x_single_pcm_mixer()
1573 mix_setdevs(m, mix_getdevs(m) & ~(1 << SOUND_MIXER_SYNTH)); in sysctl_es137x_single_pcm_mixer()
1575 ~(1 << SOUND_MIXER_SYNTH)); in sysctl_es137x_single_pcm_mixer()
1579 if (recsrc & (1 << SOUND_MIXER_PCM)) in sysctl_es137x_single_pcm_mixer()
1580 recsrc |= 1 << SOUND_MIXER_SYNTH; in sysctl_es137x_single_pcm_mixer()
1581 else if (recsrc & (1 << SOUND_MIXER_SYNTH)) in sysctl_es137x_single_pcm_mixer()
1582 recsrc |= 1 << SOUND_MIXER_PCM; in sysctl_es137x_single_pcm_mixer()
1599 dev = oidp->oid_arg1; in sysctl_es_polling()
1604 val = es->polling; in sysctl_es_polling()
1608 if (err || req->newptr == NULL) in sysctl_es_polling()
1610 if (val < 0 || val > 1) in sysctl_es_polling()
1614 if (val != es->polling) { in sysctl_es_polling()
1618 es->polling = 0; in sysctl_es_polling()
1620 es->polling = 1; in sysctl_es_polling()
1642 if not done before 7.0-RELEASE, this needs to be converted in es_init_sysctls()
1644 device_get_sysctl_*() as discussed on multimedia@ in msg-id in es_init_sysctls()
1645 <861wujij2q.fsf@xps.des.no> */ in es_init_sysctls()
1655 if (es->ch[ES_DAC2].channel != NULL && in es_init_sysctls()
1656 es->ch[ES_ADC].channel != NULL) { in es_init_sysctls()
1658 if not done before 7.0-RELEASE, this needs to be converted in es_init_sysctls()
1660 device_get_sysctl_*() as discussed on multimedia@ in msg-id in es_init_sysctls()
1661 <861wujij2q.fsf@xps.des.no> */ in es_init_sysctls()
1672 if (es->ch[ES_DAC1].channel != NULL && in es_init_sysctls()
1673 es->ch[ES_DAC2].channel != NULL) { in es_init_sysctls()
1675 if not done before 7.0-RELEASE, this needs to be converted in es_init_sysctls()
1677 device_get_sysctl_*() as discussed on multimedia@ in msg-id in es_init_sysctls()
1678 <861wujij2q.fsf@xps.des.no> */ in es_init_sysctls()
1689 pci_write_config(dev, PCIR_LATTIMER, r, 1); in es_init_sysctls()
1692 multimedia@ in msg-id <861wujij2q.fsf@xps.des.no> */ in es_init_sysctls()
1697 "PCI Latency Timer configuration"); in es_init_sysctls()
1715 es->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_es137x softc"); in es_pci_attach()
1716 es->dev = dev; in es_pci_attach()
1717 es->escfg = 0; in es_pci_attach()
1722 es->regid = MEM_MAP_REG; in es_pci_attach()
1723 es->regtype = SYS_RES_MEMORY; in es_pci_attach()
1724 es->reg = bus_alloc_resource_any(dev, es->regtype, &es->regid, in es_pci_attach()
1726 if (es->reg) in es_pci_attach()
1730 es->regid = PCIR_BAR(0); in es_pci_attach()
1731 es->regtype = SYS_RES_IOPORT; in es_pci_attach()
1732 es->reg = bus_alloc_resource_any(dev, es->regtype, &es->regid, in es_pci_attach()
1734 if (es->reg) in es_pci_attach()
1742 es->st = rman_get_bustag(es->reg); in es_pci_attach()
1743 es->sh = rman_get_bushandle(es->reg); in es_pci_attach()
1744 callout_init(&es->poll_timer, 1); in es_pci_attach()
1745 es->poll_ticks = 1; in es_pci_attach()
1749 es->polling = 1; in es_pci_attach()
1751 es->polling = 0; in es_pci_attach()
1753 es->bufsz = pcm_getbuffersize(dev, 4096, ES_DEFAULT_BUFSZ, 65536); in es_pci_attach()
1759 es->blkcnt = es->bufsz / i; in es_pci_attach()
1761 while (es->blkcnt >> i) in es_pci_attach()
1763 es->blkcnt = 1 << (i - 1); in es_pci_attach()
1764 if (es->blkcnt < ES_DMA_SEGS_MIN) in es_pci_attach()
1765 es->blkcnt = ES_DMA_SEGS_MIN; in es_pci_attach()
1766 else if (es->blkcnt > ES_DMA_SEGS_MAX) in es_pci_attach()
1767 es->blkcnt = ES_DMA_SEGS_MAX; in es_pci_attach()
1770 es->blkcnt = 2; in es_pci_attach()
1782 es->escfg = ES_SET_DAC_FIRST(es->escfg, ES_DAC1); in es_pci_attach()
1783 es->escfg = ES_SET_DAC_SECOND(es->escfg, ES_DAC2); in es_pci_attach()
1785 case 1: /* Only DAC1 */ in es_pci_attach()
1786 numplay = 1; in es_pci_attach()
1787 es->escfg = ES_SET_DAC_FIRST(es->escfg, ES_DAC1); in es_pci_attach()
1791 es->escfg = ES_SET_DAC_FIRST(es->escfg, ES_DAC2); in es_pci_attach()
1792 es->escfg = ES_SET_DAC_SECOND(es->escfg, ES_DAC1); in es_pci_attach()
1796 numplay = 1; in es_pci_attach()
1797 es->escfg = ES_SET_DAC_FIRST(es->escfg, ES_DAC2); in es_pci_attach()
1800 es->escfg = ES_SET_NUMPLAY(es->escfg, numplay); in es_pci_attach()
1801 es->escfg = ES_SET_NUMREC(es->escfg, 1); in es_pci_attach()
1827 if (!ES_DAC2_ENABLED(es->escfg)) in es_pci_attach()
1828 es->escfg = ES_SET_FIXED_RATE(es->escfg, 0); in es_pci_attach()
1838 es->irqid = 0; in es_pci_attach()
1839 es->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &es->irqid, in es_pci_attach()
1841 if (!es->irq || snd_setup_intr(dev, es->irq, INTR_MPSAFE, es_intr, in es_pci_attach()
1842 es, &es->ih)) { in es_pci_attach()
1852 /*maxsize*/es->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, in es_pci_attach()
1854 /*lockarg*/NULL, &es->parent_dmat) != 0) { in es_pci_attach()
1860 (es->regtype == SYS_RES_IOPORT)? "port" : "mem", in es_pci_attach()
1861 rman_get_start(es->reg), rman_get_start(es->irq), in es_pci_attach()
1871 es->escfg = ES_SET_GP(es->escfg, 0); in es_pci_attach()
1872 if (numplay == 1) in es_pci_attach()
1874 ES_DAC_FIRST(es->escfg) + 1); in es_pci_attach()
1877 ES_DAC_FIRST(es->escfg) + 1, ES_DAC_SECOND(es->escfg) + 1); in es_pci_attach()
1881 if (es->parent_dmat) in es_pci_attach()
1882 bus_dma_tag_destroy(es->parent_dmat); in es_pci_attach()
1883 if (es->ih) in es_pci_attach()
1884 bus_teardown_intr(dev, es->irq, es->ih); in es_pci_attach()
1885 if (es->irq) in es_pci_attach()
1886 bus_release_resource(dev, SYS_RES_IRQ, es->irqid, es->irq); in es_pci_attach()
1889 if (es->reg) in es_pci_attach()
1890 bus_release_resource(dev, es->regtype, es->regid, es->reg); in es_pci_attach()
1891 if (es->lock) in es_pci_attach()
1892 snd_mtxfree(es->lock); in es_pci_attach()
1910 if (es != NULL && es->num != 0) { in es_pci_detach()
1912 es->polling = 0; in es_pci_detach()
1913 callout_stop(&es->poll_timer); in es_pci_detach()
1915 callout_drain(&es->poll_timer); in es_pci_detach()
1918 bus_teardown_intr(dev, es->irq, es->ih); in es_pci_detach()
1919 bus_release_resource(dev, SYS_RES_IRQ, es->irqid, es->irq); in es_pci_detach()
1920 bus_release_resource(dev, es->regtype, es->regid, es->reg); in es_pci_detach()
1921 bus_dma_tag_destroy(es->parent_dmat); in es_pci_detach()
1922 snd_mtxfree(es->lock); in es_pci_detach()
1944 MODULE_VERSION(snd_es137x, 1);