Lines Matching refs:ichdev
331 struct ichdev {
374 struct ichdev ichd[6];
657 static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev)
660 __le32 *bdbar = ichdev->bdbar;
661 unsigned long port = ichdev->reg_offset;
663 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
664 if (ichdev->size == ichdev->fragsize) {
665 ichdev->ack_reload = ichdev->ack = 2;
666 ichdev->fragsize1 = ichdev->fragsize >> 1;
668 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf);
670 ichdev->fragsize1 >> ichdev->pos_shift);
671 bdbar[idx + 2] = cpu_to_le32(ichdev->physbuf + (ichdev->size >> 1));
673 ichdev->fragsize1 >> ichdev->pos_shift);
675 ichdev->frags = 2;
677 ichdev->ack_reload = ichdev->ack = 1;
678 ichdev->fragsize1 = ichdev->fragsize;
680 bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf +
681 (((idx >> 1) * ichdev->fragsize) %
682 ichdev->size));
684 ichdev->fragsize >> ichdev->pos_shift);
690 ichdev->frags = ichdev->size / ichdev->fragsize;
692 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi = ICH_REG_LVI_MASK);
693 ichdev->civ = 0;
695 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
696 ichdev->position = 0;
700 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
701 ichdev->fragsize1);
704 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
711 static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ichdev)
713 unsigned long port = ichdev->reg_offset;
718 if (!(ichdev->prepared || chip->in_measurement) || ichdev->suspended)
722 status = igetbyte(chip, port + ichdev->roff_sr);
726 } else if (civ == ichdev->civ) {
729 ichdev->civ++;
730 ichdev->civ &= ICH_REG_LVI_MASK;
732 step = civ - ichdev->civ;
736 // snd_printd("step = %d, %d -> %d\n", step, ichdev->civ, civ);
737 ichdev->civ = civ;
740 ichdev->position += step * ichdev->fragsize1;
742 ichdev->position %= ichdev->size;
743 ichdev->lvi += step;
744 ichdev->lvi &= ICH_REG_LVI_MASK;
745 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
747 ichdev->lvi_frag++;
748 ichdev->lvi_frag %= ichdev->frags;
749 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
753 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
754 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
757 if (--ichdev->ack == 0) {
758 ichdev->ack = ichdev->ack_reload;
763 if (ack && ichdev->substream) {
764 snd_pcm_period_elapsed(ichdev->substream);
766 iputbyte(chip, port + ichdev->roff_sr,
773 struct ichdev *ichdev;
792 ichdev = &chip->ichd[i];
793 if (status & ichdev->int_sta_mask)
794 snd_intel8x0_update(chip, ichdev);
810 struct ichdev *ichdev = get_ichdev(substream);
812 unsigned long port = ichdev->reg_offset;
816 ichdev->suspended = 0;
821 ichdev->last_pos = ichdev->position;
824 ichdev->suspended = 1;
838 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH)) ;
848 struct ichdev *ichdev = get_ichdev(substream);
849 unsigned long port = ichdev->reg_offset;
858 ichdev->suspended = 0;
864 fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]);
865 fifo &= ~(0xff << (ichdev->ali_slot % 4));
866 fifo |= 0x83 << (ichdev->ali_slot % 4);
867 iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo);
870 val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */
872 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot));
875 ichdev->suspended = 1;
880 iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16)));
892 igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask);
904 struct ichdev *ichdev = get_ichdev(substream);
908 if (ichdev->pcm_open_flag) {
909 snd_ac97_pcm_close(ichdev->pcm);
910 ichdev->pcm_open_flag = 0;
911 ichdev->prepared = 0;
913 err = snd_ac97_pcm_open(ichdev->pcm, params_rate(hw_params),
915 ichdev->pcm->r[dbl].slots);
917 ichdev->pcm_open_flag = 1;
919 if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0)
920 snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF,
928 struct ichdev *ichdev = get_ichdev(substream);
930 if (ichdev->pcm_open_flag) {
931 snd_ac97_pcm_close(ichdev->pcm);
932 ichdev->pcm_open_flag = 0;
933 ichdev->prepared = 0;
997 struct ichdev *ichdev = get_ichdev(substream);
999 ichdev->physbuf = runtime->dma_addr;
1000 ichdev->size = snd_pcm_lib_buffer_bytes(substream);
1001 ichdev->fragsize = snd_pcm_lib_period_bytes(substream);
1002 if (ichdev->ichd == ICHD_PCMOUT) {
1005 ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
1007 snd_intel8x0_setup_periods(chip, ichdev);
1008 ichdev->prepared = 1;
1015 struct ichdev *ichdev = get_ichdev(substream);
1022 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
1023 ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
1024 position = ichdev->position;
1029 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV))
1040 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
1043 ptr = ichdev->last_pos;
1045 ptr1 <<= ichdev->pos_shift;
1046 ptr = ichdev->fragsize1 - ptr1;
1048 if (ptr < ichdev->last_pos) {
1050 pos_base = position / ichdev->fragsize1;
1051 last_base = ichdev->last_pos / ichdev->fragsize1;
1056 ptr = ichdev->last_pos;
1059 ichdev->last_pos = ptr;
1061 if (ptr >= ichdev->size)
1117 static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
1123 ichdev->substream = substream;
1125 runtime->hw.rates = ichdev->pcm->rates;
1133 runtime->private_data = ichdev;
2640 struct ichdev *ichdev = &chip->ichd[i];
2641 unsigned long port = ichdev->reg_offset;
2642 if (! ichdev->substream || ! ichdev->suspended)
2644 if (ichdev->ichd == ICHD_PCMOUT)
2645 snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime);
2646 iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
2647 iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
2648 iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ);
2649 iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
2667 struct ichdev *ichdev;
2683 ichdev = &chip->ichd[ICHD_PCMOUT];
2684 ichdev->physbuf = subs->dma_buffer.addr;
2685 ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE;
2686 ichdev->substream = NULL; /* don't process interrupts */
2694 snd_intel8x0_setup_periods(chip, ichdev);
2695 port = ichdev->reg_offset;
2703 iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
2711 civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV);
2712 pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb);
2717 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
2718 pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
2724 pos = ichdev->fragsize1;
2725 pos -= pos1 << ichdev->pos_shift;
2726 pos += ichdev->position;
2732 iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16));
2738 while (!(igetbyte(chip, port + ichdev->roff_sr) & ICH_DCH))
2906 struct ichdev *ichdev;
3023 ichdev = &chip->ichd[i];
3024 ichdev->ichd = i;
3025 ichdev->reg_offset = tbl[i].offset;
3026 ichdev->int_sta_mask = tbl[i].int_sta_mask;
3029 ichdev->roff_sr = ICH_REG_OFF_PICB;
3030 ichdev->roff_picb = ICH_REG_OFF_SR;
3032 ichdev->roff_sr = ICH_REG_OFF_SR;
3033 ichdev->roff_picb = ICH_REG_OFF_PICB;
3036 ichdev->ali_slot = (ichdev->reg_offset - 0x40) / 0x10;
3038 ichdev->pos_shift = (device_type == DEVICE_SIS) ? 0 : 1;
3054 ichdev = &chip->ichd[i];
3055 ichdev->bdbar = ((__le32 *)chip->bdbars.area) +
3057 ichdev->bdbar_addr = chip->bdbars.addr +
3059 int_sta_masks |= ichdev->int_sta_mask;