Lines Matching refs:ichdev
308 struct ichdev {
351 struct ichdev ichd[6];
636 static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev)
639 __le32 *bdbar = ichdev->bdbar;
640 unsigned long port = ichdev->reg_offset;
642 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
643 if (ichdev->size == ichdev->fragsize) {
644 ichdev->ack_reload = ichdev->ack = 2;
645 ichdev->fragsize1 = ichdev->fragsize >> 1;
647 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf);
649 ichdev->fragsize1 >> ichdev->pos_shift);
650 bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1));
652 ichdev->fragsize1 >> ichdev->pos_shift);
654 ichdev->frags = 2;
656 ichdev->ack_reload = ichdev->ack = 1;
657 ichdev->fragsize1 = ichdev->fragsize;
659 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf +
660 (((idx >> 1) * ichdev->fragsize) %
661 ichdev->size));
663 ichdev->fragsize >> ichdev->pos_shift);
669 ichdev->frags = ichdev->size / ichdev->fragsize;
671 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK);
672 ichdev->civ = 0;
674 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
675 ichdev->position = 0;
679 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
680 ichdev->fragsize1);
683 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
690 static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ichdev)
692 unsigned long port = ichdev->reg_offset;
697 if (!(ichdev->prepared || chip->in_measurement) || ichdev->suspended)
701 status = igetbyte(chip, port + ichdev->roff_sr);
705 } else if (civ == ichdev->civ) {
708 ichdev->civ++;
709 ichdev->civ &= ICH_REG_LVI_MASK;
711 step = civ - ichdev->civ;
715 // snd_printd("step = %d, %d -> %d\n", step, ichdev->civ, civ);
716 ichdev->civ = civ;
719 ichdev->position += step * ichdev->fragsize1;
721 ichdev->position %= ichdev->size;
722 ichdev->lvi += step;
723 ichdev->lvi &= ICH_REG_LVI_MASK;
724 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
726 ichdev->lvi_frag++;
727 ichdev->lvi_frag %= ichdev->frags;
728 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
732 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
733 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
736 if (--ichdev->ack == 0) {
737 ichdev->ack = ichdev->ack_reload;
742 if (ack && ichdev->substream) {
743 snd_pcm_period_elapsed(ichdev->substream);
745 iputbyte(chip, port + ichdev->roff_sr,
752 struct ichdev *ichdev;
771 ichdev = &chip->ichd[i];
772 if (status & ichdev->int_sta_mask)
773 snd_intel8x0_update(chip, ichdev);
789 struct ichdev *ichdev = get_ichdev(substream);
791 unsigned long port = ichdev->reg_offset;
795 ichdev->suspended = 0;
800 ichdev->last_pos = ichdev->position;
803 ichdev->suspended = 1;
817 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ;
827 struct ichdev *ichdev = get_ichdev(substream);
828 unsigned long port = ichdev->reg_offset;
837 ichdev->suspended = 0;
843 fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]);
844 fifo &= ~(0xff << (ichdev->ali_slot % 4));
845 fifo |= 0x83 << (ichdev->ali_slot % 4);
846 iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo);
849 val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */
851 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot));
854 ichdev->suspended = 1;
859 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16)));
871 igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask);
883 struct ichdev *ichdev = get_ichdev(substream);
887 if (ichdev->pcm_open_flag) {
888 snd_ac97_pcm_close(ichdev->pcm);
889 ichdev->pcm_open_flag = 0;
890 ichdev->prepared = 0;
892 err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params),
894 ichdev->pcm->r[dbl].slots);
896 ichdev->pcm_open_flag = 1;
898 if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0)
899 snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF,
907 struct ichdev *ichdev = get_ichdev(substream);
909 if (ichdev->pcm_open_flag) {
910 snd_ac97_pcm_close(ichdev->pcm);
911 ichdev->pcm_open_flag = 0;
912 ichdev->prepared = 0;
976 struct ichdev *ichdev = get_ichdev(substream);
978 ichdev->physbuf = runtime->dma_addr;
979 ichdev->size = snd_pcm_lib_buffer_bytes(substream);
980 ichdev->fragsize = snd_pcm_lib_period_bytes(substream);
981 if (ichdev->ichd == ICHD_PCMOUT) {
984 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
986 snd_intel8x0_setup_periods(chip, ichdev);
987 ichdev->prepared = 1;
994 struct ichdev *ichdev = get_ichdev(substream);
1001 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
1002 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
1003 position = ichdev->position;
1008 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV))
1019 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
1022 ptr = ichdev->last_pos;
1024 ptr1 <<= ichdev->pos_shift;
1025 ptr = ichdev->fragsize1 - ptr1;
1027 if (ptr < ichdev->last_pos) {
1029 pos_base = position / ichdev->fragsize1;
1030 last_base = ichdev->last_pos / ichdev->fragsize1;
1035 ptr = ichdev->last_pos;
1038 ichdev->last_pos = ptr;
1040 if (ptr >= ichdev->size)
1096 static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
1102 ichdev->substream = substream;
1104 runtime->hw.rates = ichdev->pcm->rates;
1113 runtime->private_data = ichdev;
2615 struct ichdev *ichdev = &chip->ichd[i];
2616 unsigned long port = ichdev->reg_offset;
2617 if (! ichdev->substream || ! ichdev->suspended)
2619 if (ichdev->ichd == ICHD_PCMOUT)
2620 snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime);
2621 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
2622 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
2623 iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ);
2624 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
2642 struct ichdev *ichdev;
2660 ichdev = &chip->ichd[ICHD_PCMOUT];
2661 ichdev->physbuf = subs->dma_buffer.addr;
2662 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE;
2663 ichdev->substream = NULL; /* don't process interrupts */
2671 snd_intel8x0_setup_periods(chip, ichdev);
2672 port = ichdev->reg_offset;
2680 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
2688 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
2689 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
2694 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
2695 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
2701 pos = ichdev->fragsize1;
2702 pos -= pos1 << ichdev->pos_shift;
2703 pos += ichdev->position;
2709 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16));
2715 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH))
2876 struct ichdev *ichdev;
2970 ichdev = &chip->ichd[i];
2971 ichdev->ichd = i;
2972 ichdev->reg_offset = tbl[i].offset;
2973 ichdev->int_sta_mask = tbl[i].int_sta_mask;
2976 ichdev->roff_sr = ICH_REG_OFF_PICB;
2977 ichdev->roff_picb = ICH_REG_OFF_SR;
2979 ichdev->roff_sr = ICH_REG_OFF_SR;
2980 ichdev->roff_picb = ICH_REG_OFF_PICB;
2983 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10;
2985 ichdev->pos_shift = (device_type == DEVICE_SIS) ? 0 : 1;
3000 ichdev = &chip->ichd[i];
3001 ichdev->bdbar = ((__le32 *)chip->bdbars->area) +
3003 ichdev->bdbar_addr = chip->bdbars->addr +
3005 int_sta_masks |= ichdev->int_sta_mask;