Lines Matching +full:adc +full:- +full:joystick

53   Copyright (C) 1998-2001, 2003 Thomas Sailer (t.sailer@alumni.ethz.ch)
82 #define DAC2_SRTODIV(x) (((1411200+(x)/2)/(x))-2)
85 #define CTRL_ADC_STOP 0x80000000 /* 1 = ADC stopped */
88 #define CTRL_PCLKDIV 0x1fff0000 /* ADC/DAC2 clock divider */
96 #define CTRL_M_CB 0x00000200 /* recording source: 0 = ADC, 1 = MPEG */
101 #define CTRL_ADC_EN 0x00000010 /* enable ADC */
103 #define CTRL_JYSTK_EN 0x00000004 /* enable Joystick port (presumably at address 0x200) */
111 #define STAT_VC 0x00000060 /* CCB int source, 0=DAC1, 1=DAC2, 2=ADC, 3=undef */
117 #define STAT_ADC 0x00000001 /* ADC int pending */
193 AUD_log("es1370", "ctl - PCLKDIV %d(DAC2 freq %d), freq %d,%s\n", in print_ctl()
311 s->status = new_status | STAT_INTR; in es1370_update_status()
313 s->status = new_status & ~STAT_INTR; in es1370_update_status()
315 pci_set_irq(&s->dev, !!level); in es1370_update_status()
322 s->ctl = 1; in es1370_reset()
323 s->status = 0x60; in es1370_reset()
324 s->mempage = 0; in es1370_reset()
325 s->codec = 0; in es1370_reset()
326 s->sctl = 0; in es1370_reset()
329 struct chan *d = &s->chan[i]; in es1370_reset()
330 d->scount = 0; in es1370_reset()
331 d->leftover = 0; in es1370_reset()
333 AUD_close_in (&s->card, s->adc_voice); in es1370_reset()
334 s->adc_voice = NULL; in es1370_reset()
336 AUD_close_out (&s->card, s->dac_voice[i]); in es1370_reset()
337 s->dac_voice[i] = NULL; in es1370_reset()
340 pci_irq_deassert(&s->dev); in es1370_reset()
345 uint32_t new_status = s->status; in es1370_maybe_lower_irq()
347 if (!(sctl & SCTRL_P1INTEN) && (s->sctl & SCTRL_P1INTEN)) { in es1370_maybe_lower_irq()
351 if (!(sctl & SCTRL_P2INTEN) && (s->sctl & SCTRL_P2INTEN)) { in es1370_maybe_lower_irq()
355 if (!(sctl & SCTRL_R1INTEN) && (s->sctl & SCTRL_R1INTEN)) { in es1370_maybe_lower_irq()
359 if (new_status != s->status) { in es1370_maybe_lower_irq()
368 *old_freq = dac1_samplerate[(s->ctl & CTRL_WTSRSEL) >> CTRL_SH_WTSRSEL]; in es1370_dac1_calc_freq()
380 old_pclkdiv = (s->ctl & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV; in es1370_dac2_and_adc_calc_freq()
391 struct chan *d = &s->chan[i]; in es1370_update_voices()
394 new_fmt = (sctl & b->sctl_fmt) >> b->sctl_sh_fmt; in es1370_update_voices()
395 old_fmt = (s->sctl & b->sctl_fmt) >> b->sctl_sh_fmt; in es1370_update_voices()
397 b->calc_freq (s, ctl, &old_freq, &new_freq); in es1370_update_voices()
400 d->shift = (new_fmt & 1) + (new_fmt >> 1); in es1370_update_voices()
403 d->shift); in es1370_update_voices()
413 s->adc_voice = in es1370_update_voices()
415 &s->card, in es1370_update_voices()
416 s->adc_voice, in es1370_update_voices()
417 "es1370.adc", in es1370_update_voices()
423 s->dac_voice[i] = in es1370_update_voices()
425 &s->card, in es1370_update_voices()
426 s->dac_voice[i], in es1370_update_voices()
436 if (((ctl ^ s->ctl) & b->ctl_en) in es1370_update_voices()
437 || ((sctl ^ s->sctl) & b->sctl_pause)) { in es1370_update_voices()
438 int on = (ctl & b->ctl_en) && !(sctl & b->sctl_pause); in es1370_update_voices()
441 AUD_set_active_in (s->adc_voice, on); in es1370_update_voices()
443 AUD_set_active_out (s->dac_voice[i], on); in es1370_update_voices()
448 s->ctl = ctl; in es1370_update_voices()
449 s->sctl = sctl; in es1370_update_voices()
456 addr |= s->mempage << 8; in es1370_fixup()
464 struct chan *d = &s->chan[0]; in es1370_write()
470 es1370_update_voices (s, val, s->sctl); in es1370_write()
475 s->mempage = val & 0xf; in es1370_write()
480 es1370_update_voices (s, s->ctl, val); in es1370_write()
487 d += (addr - ES1370_REG_DAC1_SCOUNT) >> 2; in es1370_write()
488 d->scount = (val & 0xffff) << 16 | (val & 0xffff); in es1370_write()
489 trace_es1370_sample_count_wr(d - &s->chan[0], in es1370_write()
490 d->scount >> 16, d->scount & 0xffff); in es1370_write()
498 d += (addr - ES1370_REG_DAC1_FRAMEADR) >> 3; in es1370_write()
500 d->frame_addr = val; in es1370_write()
501 trace_es1370_frame_address_wr(d - &s->chan[0], d->frame_addr); in es1370_write()
516 d += (addr - ES1370_REG_DAC1_FRAMECNT) >> 3; in es1370_write()
518 d->frame_cnt = val; in es1370_write()
519 d->leftover = 0; in es1370_write()
520 trace_es1370_frame_count_wr(d - &s->chan[0], in es1370_write()
521 d->frame_cnt >> 16, d->frame_cnt & 0xffff); in es1370_write()
525 lwarn("writel 0x%" PRIx64 " <- 0x%" PRIx64 "\n", addr, val); in es1370_write()
534 struct chan *d = &s->chan[0]; in es1370_read()
540 val = s->ctl; in es1370_read()
543 val = s->status; in es1370_read()
546 val = s->mempage; in es1370_read()
549 val = s->codec; in es1370_read()
552 val = s->sctl; in es1370_read()
558 d += (addr - ES1370_REG_DAC1_SCOUNT) >> 2; in es1370_read()
559 trace_es1370_sample_count_rd(d - &s->chan[0], in es1370_read()
560 d->scount >> 16, d->scount & 0xffff); in es1370_read()
561 val = d->scount; in es1370_read()
569 d += (addr - ES1370_REG_DAC1_FRAMECNT) >> 3; in es1370_read()
571 trace_es1370_frame_count_rd(d - &s->chan[0], in es1370_read()
572 d->frame_cnt >> 16, d->frame_cnt & 0xffff); in es1370_read()
573 val = d->frame_cnt; in es1370_read()
581 d += (addr - ES1370_REG_DAC1_FRAMEADR) >> 3; in es1370_read()
583 trace_es1370_frame_address_rd(d - &s->chan[0], d->frame_addr); in es1370_read()
584 val = d->frame_addr; in es1370_read()
598 lwarn("readl 0x%" PRIx64 " -> 0x%x\n", addr, val); in es1370_read()
609 uint32_t addr = d->frame_addr; in es1370_transfer_audio()
610 int sc = d->scount & 0xffff; in es1370_transfer_audio()
611 int csc = d->scount >> 16; in es1370_transfer_audio()
612 int csc_bytes = (csc + 1) << d->shift; in es1370_transfer_audio()
613 int cnt = d->frame_cnt >> 16; in es1370_transfer_audio()
614 int size = d->frame_cnt & 0xffff; in es1370_transfer_audio()
618 int left = ((size - cnt + 1) << 2) + d->leftover; in es1370_transfer_audio()
620 int index = d - &s->chan[0]; in es1370_transfer_audio()
623 addr += (cnt << 2) + d->leftover; in es1370_transfer_audio()
630 acquired = AUD_read (s->adc_voice, tmpbuf, to_copy); in es1370_transfer_audio()
635 pci_dma_write (&s->dev, addr, tmpbuf, acquired); in es1370_transfer_audio()
637 to_transfer -= acquired; in es1370_transfer_audio()
642 SWVoiceOut *voice = s->dac_voice[index]; in es1370_transfer_audio()
648 pci_dma_read (&s->dev, addr, tmpbuf, to_copy); in es1370_transfer_audio()
653 to_transfer -= copied; in es1370_transfer_audio()
664 d->scount = sc | (sc << 16); in es1370_transfer_audio()
667 d->scount = sc | (((csc_bytes - transferred - 1) >> d->shift) << 16); in es1370_transfer_audio()
670 cnt += (transferred + d->leftover) >> 2; in es1370_transfer_audio()
672 if (s->sctl & loop_sel) { in es1370_transfer_audio()
682 d->frame_cnt = size; in es1370_transfer_audio()
684 if ((uint32_t) cnt <= d->frame_cnt) { in es1370_transfer_audio()
685 d->frame_cnt |= cnt << 16; in es1370_transfer_audio()
689 d->leftover = (transferred + d->leftover) & 3; in es1370_transfer_audio()
691 d->frame_cnt >> 16, d->frame_cnt & 0xffff, in es1370_transfer_audio()
692 d->scount >> 16, d->scount & 0xffff, in es1370_transfer_audio()
693 d->leftover, *irq); in es1370_transfer_audio()
698 uint32_t new_status = s->status; in es1370_run_channel()
701 struct chan *d = &s->chan[chan]; in es1370_run_channel()
704 if (!(s->ctl & b->ctl_en) || (s->sctl & b->sctl_pause)) { in es1370_run_channel()
709 max_bytes &= ~((1 << d->shift) - 1); in es1370_run_channel()
714 irq = s->sctl & b->sctl_inten && s->status & b->stat_int; in es1370_run_channel()
716 es1370_transfer_audio (s, d, b->sctl_loopsel, max_bytes, &irq); in es1370_run_channel()
719 if (s->sctl & b->sctl_inten) { in es1370_run_channel()
720 new_status |= b->stat_int; in es1370_run_channel()
724 if (new_status != s->status) { in es1370_run_channel()
786 if (s->adc_voice) { in es1370_post_load()
787 AUD_close_in (&s->card, s->adc_voice); in es1370_post_load()
788 s->adc_voice = NULL; in es1370_post_load()
791 if (s->dac_voice[i]) { in es1370_post_load()
792 AUD_close_out (&s->card, s->dac_voice[i]); in es1370_post_load()
793 s->dac_voice[i] = NULL; in es1370_post_load()
798 ctl = s->ctl; in es1370_post_load()
799 sctl = s->sctl; in es1370_post_load()
800 s->ctl = 0; in es1370_post_load()
801 s->sctl = 0; in es1370_post_load()
834 uint8_t *c = s->dev.config; in es1370_realize()
836 if (!AUD_register_card ("es1370", &s->card, errp)) { in es1370_realize()
852 memory_region_init_io (&s->io, OBJECT(s), &es1370_io_ops, s, "es1370", 256); in es1370_realize()
853 pci_register_bar (&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io); in es1370_realize()
864 AUD_close_out(&s->card, s->dac_voice[i]); in es1370_exit()
867 AUD_close_in(&s->card, s->adc_voice); in es1370_exit()
868 AUD_remove_card(&s->card); in es1370_exit()
881 k->realize = es1370_realize; in es1370_class_init()
882 k->exit = es1370_exit; in es1370_class_init()
883 k->vendor_id = PCI_VENDOR_ID_ENSONIQ; in es1370_class_init()
884 k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370; in es1370_class_init()
885 k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO; in es1370_class_init()
886 k->subsystem_vendor_id = 0x4942; in es1370_class_init()
887 k->subsystem_id = 0x4c4c; in es1370_class_init()
888 set_bit(DEVICE_CATEGORY_SOUND, dc->categories); in es1370_class_init()
889 dc->desc = "ENSONIQ AudioPCI ES1370"; in es1370_class_init()
890 dc->vmsd = &vmstate_es1370; in es1370_class_init()