Lines Matching refs:devc
206 static int ad_read(ad1848_info * devc, int reg) in ad_read() argument
211 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_read()
216 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
217 x = inb(io_Indexed_Data(devc)); in ad_read()
225 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
226 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_read()
227 x = inb(io_Indexed_Data(devc)); in ad_read()
233 static void ad_write(ad1848_info * devc, int reg, int data) in ad_write() argument
237 while (timeout > 0 && inb(devc->base) == 0x80) /* Are we initializing */ in ad_write()
242 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
243 outb(((unsigned char) (data & 0xff)), io_Indexed_Data(devc)); in ad_write()
251 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
252 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_write()
253 outb((unsigned char) (data & 0xff), io_Indexed_Data(devc)); in ad_write()
257 static void wait_for_calibration(ad1848_info * devc) in wait_for_calibration() argument
269 while (timeout > 0 && inb(devc->base) == 0x80) in wait_for_calibration()
271 if (inb(devc->base) & 0x80) in wait_for_calibration()
275 while (timeout > 0 && !(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
277 if (!(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
281 while (timeout > 0 && (ad_read(devc, 11) & 0x20)) in wait_for_calibration()
283 if (ad_read(devc, 11) & 0x20) in wait_for_calibration()
284 if ((devc->model != MD_1845) && (devc->model != MD_1845_SSCAPE)) in wait_for_calibration()
288 static void ad_mute(ad1848_info * devc) in ad_mute() argument
299 prev = devc->saved_regs[i] = ad_read(devc, i); in ad_mute()
304 static void ad_unmute(ad1848_info * devc) in ad_unmute() argument
308 static void ad_enter_MCE(ad1848_info * devc) in ad_enter_MCE() argument
313 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_enter_MCE()
316 devc->MCE_bit = 0x40; in ad_enter_MCE()
317 prev = inb(io_Index_Addr(devc)); in ad_enter_MCE()
322 outb((devc->MCE_bit), io_Index_Addr(devc)); in ad_enter_MCE()
325 static void ad_leave_MCE(ad1848_info * devc) in ad_leave_MCE() argument
330 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_leave_MCE()
333 acal = ad_read(devc, 9); in ad_leave_MCE()
335 devc->MCE_bit = 0x00; in ad_leave_MCE()
336 prev = inb(io_Index_Addr(devc)); in ad_leave_MCE()
337 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
343 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
345 wait_for_calibration(devc); in ad_leave_MCE()
348 static int ad1848_set_recmask(ad1848_info * devc, int mask) in ad1848_set_recmask() argument
354 mask &= devc->supported_rec_devices; in ad1848_set_recmask()
359 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
364 mask |= (1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
374 spin_lock_irqsave(&devc->lock,flags); in ad1848_set_recmask()
379 mask &= ~devc->recmask; /* Filter out active settings */ in ad1848_set_recmask()
414 ad_write(devc, 0, (ad_read(devc, 0) & 0x3f) | recdev); in ad1848_set_recmask()
415 ad_write(devc, 1, (ad_read(devc, 1) & 0x3f) | recdev); in ad1848_set_recmask()
422 if ((devc->supported_rec_devices & (1 << i)) == 0) in ad1848_set_recmask()
426 if (devc->mix_devices[i][j].nbits == 0) /* Inexistent channel */ in ad1848_set_recmask()
434 set_rec_bit = ((mask & (1 << i)) != 0) ^ devc->mix_devices[i][j].recpol; in ad1848_set_recmask()
436 val = ad_read(devc, devc->mix_devices[i][j].recreg); in ad1848_set_recmask()
437 val &= ~(1 << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
438 val |= (set_rec_bit << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
439 ad_write(devc, devc->mix_devices[i][j].recreg, val); in ad1848_set_recmask()
443 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_set_recmask()
448 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
450 if (mask & (1 << devc->mixer_reroute[i])) in ad1848_set_recmask()
452 mask &= ~(1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
457 devc->recmask = mask; in ad1848_set_recmask()
461 static void oss_change_bits(ad1848_info *devc, unsigned char *regval, in oss_change_bits() argument
470 set_mute_bit = (newval == 0) ^ devc->mix_devices[dev][chn].mutepol; in oss_change_bits()
472 if (devc->mix_devices[dev][chn].polarity == 1) /* Reverse */ in oss_change_bits()
475 mask = (1 << devc->mix_devices[dev][chn].nbits) - 1; in oss_change_bits()
476 shift = devc->mix_devices[dev][chn].bitpos; in oss_change_bits()
478 if (devc->mix_devices[dev][chn].mutepos == 8) in oss_change_bits()
485 mute = (set_mute_bit << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
486 mutemask = ~(1 << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
497 static int ad1848_mixer_get(ad1848_info * devc, int dev) in ad1848_mixer_get() argument
499 if (!((1 << dev) & devc->supported_devices)) in ad1848_mixer_get()
502 dev = devc->mixer_reroute[dev]; in ad1848_mixer_get()
504 return devc->levels[dev]; in ad1848_mixer_get()
507 static void ad1848_mixer_set_channel(ad1848_info *devc, int dev, int value, int channel) in ad1848_mixer_set_channel() argument
513 regoffs = devc->mix_devices[dev][channel].regno; in ad1848_mixer_set_channel()
514 muteregoffs = devc->mix_devices[dev][channel].mutereg; in ad1848_mixer_set_channel()
515 val = ad_read(devc, regoffs); in ad1848_mixer_set_channel()
518 muteval = ad_read(devc, muteregoffs); in ad1848_mixer_set_channel()
519 oss_change_bits(devc, &val, &muteval, dev, channel, value); in ad1848_mixer_set_channel()
522 oss_change_bits(devc, &val, &val, dev, channel, value); in ad1848_mixer_set_channel()
524 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_set_channel()
525 ad_write(devc, regoffs, val); in ad1848_mixer_set_channel()
526 devc->saved_regs[regoffs] = val; in ad1848_mixer_set_channel()
528 ad_write(devc, muteregoffs, muteval); in ad1848_mixer_set_channel()
529 devc->saved_regs[muteregoffs] = muteval; in ad1848_mixer_set_channel()
531 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_set_channel()
534 static int ad1848_mixer_set(ad1848_info * devc, int dev, int value) in ad1848_mixer_set() argument
543 if (!(devc->supported_devices & (1 << dev))) in ad1848_mixer_set()
546 dev = devc->mixer_reroute[dev]; in ad1848_mixer_set()
548 if (devc->mix_devices[dev][LEFT_CHN].nbits == 0) in ad1848_mixer_set()
556 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) /* Mono control */ in ad1848_mixer_set()
565 devc->levels[dev] = retvol; in ad1848_mixer_set()
570 ad1848_mixer_set_channel(devc, dev, left, LEFT_CHN); in ad1848_mixer_set()
575 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) in ad1848_mixer_set()
577 ad1848_mixer_set_channel(devc, dev, right, RIGHT_CHN); in ad1848_mixer_set()
583 static void ad1848_mixer_reset(ad1848_info * devc) in ad1848_mixer_reset() argument
589 devc->mix_devices = &(ad1848_mix_devices[0]); in ad1848_mixer_reset()
591 sprintf(name, "%s_%d", devc->chip_name, nr_ad1848_devs); in ad1848_mixer_reset()
594 devc->mixer_reroute[i] = i; in ad1848_mixer_reset()
596 devc->supported_rec_devices = MODE1_REC_DEVICES; in ad1848_mixer_reset()
598 switch (devc->model) in ad1848_mixer_reset()
604 devc->supported_devices = MODE2_MIXER_DEVICES; in ad1848_mixer_reset()
608 devc->supported_devices = C930_MIXER_DEVICES; in ad1848_mixer_reset()
609 devc->mix_devices = &(c930_mix_devices[0]); in ad1848_mixer_reset()
613 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
614 devc->mix_devices = &(iwave_mix_devices[0]); in ad1848_mixer_reset()
619 devc->mix_devices = &(cs42xb_mix_devices[0]); in ad1848_mixer_reset()
620 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
625 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
630 devc->supported_devices = SPRO_MIXER_DEVICES; in ad1848_mixer_reset()
631 devc->supported_rec_devices = SPRO_REC_DEVICES; in ad1848_mixer_reset()
632 devc->mix_devices = &(spro_mix_devices[0]); in ad1848_mixer_reset()
637 devc->supported_devices = MODE1_MIXER_DEVICES; in ad1848_mixer_reset()
640 devc->orig_devices = devc->supported_devices; in ad1848_mixer_reset()
641 devc->orig_rec_devices = devc->supported_rec_devices; in ad1848_mixer_reset()
643 devc->levels = load_mixer_volumes(name, default_mixer_levels, 1); in ad1848_mixer_reset()
647 if (devc->supported_devices & (1 << i)) in ad1848_mixer_reset()
648 ad1848_mixer_set(devc, i, devc->levels[i]); in ad1848_mixer_reset()
651 ad1848_set_recmask(devc, SOUND_MASK_MIC); in ad1848_mixer_reset()
653 devc->mixer_output_port = devc->levels[31] | AUDIO_HEADPHONE | AUDIO_LINE_OUT; in ad1848_mixer_reset()
655 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_reset()
657 if (devc->mixer_output_port & AUDIO_SPEAKER) in ad1848_mixer_reset()
658 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_reset()
660 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_reset()
667 ad_write(devc, 16, 0x60); in ad1848_mixer_reset()
669 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_reset()
674 ad1848_info *devc = mixer_devs[dev]->devc; in ad1848_mixer_ioctl() local
686 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
688 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
689 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_ioctl()
691 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_ioctl()
693 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_ioctl()
694 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_ioctl()
696 val = devc->mixer_output_port; in ad1848_mixer_ioctl()
714 val = ad1848_set_recmask(devc, val); in ad1848_mixer_ioctl()
720 val = ad1848_mixer_set(devc, cmd & 0xff, val); in ad1848_mixer_ioctl()
734 val = devc->recmask; in ad1848_mixer_ioctl()
738 val = devc->supported_devices; in ad1848_mixer_ioctl()
742 val = devc->supported_devices; in ad1848_mixer_ioctl()
743 if (devc->model != MD_C930) in ad1848_mixer_ioctl()
748 val = devc->supported_rec_devices; in ad1848_mixer_ioctl()
756 val = ad1848_mixer_get(devc, cmd & 0xff); in ad1848_mixer_ioctl()
768 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_speed() local
812 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* AD1845 has different timer than ot… in ad1848_set_speed()
868 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_bits() local
923 if (!(arg & ad_format_mask[devc->model])) in ad1848_set_bits()
969 ad1848_info *devc; in ad1848_open() local
976 devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_open()
980 spin_lock(&devc->lock); in ad1848_open()
981 if (portc->open_mode || (devc->open_mode & mode)) in ad1848_open()
983 spin_unlock(&devc->lock); in ad1848_open()
986 devc->dual_dma = 0; in ad1848_open()
990 devc->dual_dma = 1; in ad1848_open()
992 devc->intr_active = 0; in ad1848_open()
993 devc->audio_mode = 0; in ad1848_open()
994 devc->open_mode |= mode; in ad1848_open()
996 spin_unlock(&devc->lock); in ad1848_open()
1000 devc->record_dev = dev; in ad1848_open()
1002 devc->playback_dev = dev; in ad1848_open()
1006 spin_lock_irqsave(&devc->lock,flags); in ad1848_open()
1007 ad_mute(devc); in ad1848_open()
1008 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_open()
1016 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_close() local
1021 devc->intr_active = 0; in ad1848_close()
1024 spin_lock_irqsave(&devc->lock,flags); in ad1848_close()
1026 devc->audio_mode = 0; in ad1848_close()
1027 devc->open_mode &= ~portc->open_mode; in ad1848_close()
1030 ad_unmute(devc); in ad1848_close()
1031 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_close()
1037 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_output_block() local
1055 if ((devc->audio_mode & PCM_ENABLE_OUTPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_output_block()
1057 cnt == devc->xfer_count) in ad1848_output_block()
1059 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1060 devc->intr_active = 1; in ad1848_output_block()
1065 spin_lock_irqsave(&devc->lock,flags); in ad1848_output_block()
1067 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_output_block()
1068 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_output_block()
1070 devc->xfer_count = cnt; in ad1848_output_block()
1071 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1072 devc->intr_active = 1; in ad1848_output_block()
1073 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_output_block()
1079 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_start_input() local
1096 if ((devc->audio_mode & PCM_ENABLE_INPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_start_input()
1098 cnt == devc->xfer_count) in ad1848_start_input()
1100 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1101 devc->intr_active = 1; in ad1848_start_input()
1106 spin_lock_irqsave(&devc->lock,flags); in ad1848_start_input()
1108 if (devc->model == MD_1848) in ad1848_start_input()
1110 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1111 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1115 ad_write(devc, 31, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1116 ad_write(devc, 30, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1119 ad_unmute(devc); in ad1848_start_input()
1121 devc->xfer_count = cnt; in ad1848_start_input()
1122 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1123 devc->intr_active = 1; in ad1848_start_input()
1124 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_start_input()
1132 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_output() local
1135 ad_mute(devc); in ad1848_prepare_for_output()
1137 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_output()
1143 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_output()
1145 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* Use alternate speed select registe… in ad1848_prepare_for_output()
1149 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_output()
1150 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_output()
1152 old_fs = ad_read(devc, 8); in ad1848_prepare_for_output()
1154 if (devc->model == MD_4232 || devc->model >= MD_4236) in ad1848_prepare_for_output()
1156 tmp = ad_read(devc, 16); in ad1848_prepare_for_output()
1157 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_output()
1159 if (devc->model == MD_IWAVE) in ad1848_prepare_for_output()
1160 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_output()
1162 ad_write(devc, 8, fs); in ad1848_prepare_for_output()
1169 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_output()
1172 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_output()
1175 if (devc->model >= MD_4232) in ad1848_prepare_for_output()
1176 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_output()
1178 ad_leave_MCE(devc); /* in ad1848_prepare_for_output()
1181 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_output()
1182 devc->xfer_count = 0; in ad1848_prepare_for_output()
1185 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_output()
1200 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_input() local
1203 if (devc->audio_mode) in ad1848_prepare_for_input()
1206 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_input()
1212 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_input()
1214 …if ((devc->model == MD_1845) || (devc->model == MD_1845_SSCAPE)) /* Use alternate speed select reg… in ad1848_prepare_for_input()
1218 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_input()
1219 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_input()
1221 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1223 tmp = ad_read(devc, 16); in ad1848_prepare_for_input()
1224 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_input()
1226 if (devc->model == MD_IWAVE) in ad1848_prepare_for_input()
1227 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_input()
1233 if (devc->model != MD_1848) in ad1848_prepare_for_input()
1235 old_fs = ad_read(devc, 28); in ad1848_prepare_for_input()
1236 ad_write(devc, 28, fs); in ad1848_prepare_for_input()
1243 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1247 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1250 if (devc->model != MD_1848 && devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_prepare_for_input()
1257 unsigned char tmp = portc->speed_bits | (ad_read(devc, 8) & 0xf0); in ad1848_prepare_for_input()
1259 ad_write(devc, 8, tmp); in ad1848_prepare_for_input()
1264 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1268 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1275 old_fs = ad_read(devc, 8); in ad1848_prepare_for_input()
1276 ad_write(devc, 8, fs); in ad1848_prepare_for_input()
1281 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1284 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1288 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1289 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_input()
1291 ad_leave_MCE(devc); /* in ad1848_prepare_for_input()
1294 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_input()
1295 devc->xfer_count = 0; in ad1848_prepare_for_input()
1298 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_input()
1312 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt() local
1315 unsigned char bits = ad_read(devc, 9); in ad1848_halt()
1322 devc->audio_mode = 0; in ad1848_halt()
1327 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_input() local
1330 if (!(ad_read(devc, 9) & 0x02)) in ad1848_halt_input()
1333 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_input()
1335 ad_mute(devc); in ad1848_halt_input()
1344 if (ad_read(devc, 11) & 0x10) in ad1848_halt_input()
1346 ad_write(devc, 9, ad_read(devc, 9) & ~0x02); /* Stop capture */ in ad1848_halt_input()
1350 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1353 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1354 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1356 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1358 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_input()
1363 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_output() local
1366 if (!(ad_read(devc, 9) & 0x01)) in ad1848_halt_output()
1369 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_output()
1371 ad_mute(devc); in ad1848_halt_output()
1379 if (ad_read(devc, 11) & 0x10) in ad1848_halt_output()
1381 ad_write(devc, 9, ad_read(devc, 9) & ~0x01); /* Stop playback */ in ad1848_halt_output()
1386 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1389 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1390 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1392 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1394 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_output()
1399 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_trigger() local
1404 spin_lock_irqsave(&devc->lock,flags); in ad1848_trigger()
1405 state &= devc->audio_mode; in ad1848_trigger()
1407 tmp = old = ad_read(devc, 9); in ad1848_trigger()
1426 ad_write(devc, 9, tmp); in ad1848_trigger()
1427 ad_unmute(devc); in ad1848_trigger()
1429 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_trigger()
1432 static void ad1848_init_hw(ad1848_info * devc) in ad1848_init_hw() argument
1473 if(devc->model >= MD_4236) in ad1848_init_hw()
1477 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1480 ad_mute(devc); /* Initialize some variables */ in ad1848_init_hw()
1481 ad_unmute(devc); /* Leave it unmuted now */ in ad1848_init_hw()
1483 if (devc->model > MD_1848) in ad1848_init_hw()
1485 if (devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1486 ad_write(devc, 12, ad_read(devc, 12) | 0x50); in ad1848_init_hw()
1488 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1490 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1491 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1493 if (devc->model != MD_1845_SSCAPE) in ad1848_init_hw()
1495 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1497 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1498 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1500 if (devc->model > MD_1848) in ad1848_init_hw()
1502 if (devc->audio_flags & DMA_DUPLEX) in ad1848_init_hw()
1503 ad_write(devc, 9, ad_read(devc, 9) & ~0x04); /* Dual DMA mode */ in ad1848_init_hw()
1505 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1507 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1508 ad_write(devc, 27, ad_read(devc, 27) | 0x08); /* Alternate freq select enabled */ in ad1848_init_hw()
1510 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1512 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1513 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1514 ad_write(devc, 17, 0xc2); /* Alternate feature enable */ in ad1848_init_hw()
1519 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init_hw()
1520 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1522 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1525 outb((0), io_Status(devc)); /* Clear pending interrupts */ in ad1848_init_hw()
1531 ad_enter_MCE(devc); /* In case the bit was off */ in ad1848_init_hw()
1532 ad_leave_MCE(devc); in ad1848_init_hw()
1534 ad1848_mixer_reset(devc); in ad1848_init_hw()
1540 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_detect() local
1578 spin_lock_init(&devc->lock); in ad1848_detect()
1579 devc->base = io_base; in ad1848_detect()
1580 devc->irq_ok = 0; in ad1848_detect()
1581 devc->timer_running = 0; in ad1848_detect()
1582 devc->MCE_bit = 0x40; in ad1848_detect()
1583 devc->irq = 0; in ad1848_detect()
1584 devc->open_mode = 0; in ad1848_detect()
1585 devc->chip_name = devc->name = "AD1848"; in ad1848_detect()
1586 devc->model = MD_1848; /* AD1848 or CS4248 */ in ad1848_detect()
1587 devc->levels = NULL; in ad1848_detect()
1588 devc->debug_flag = 0; in ad1848_detect()
1600 if (inb(devc->base) == 0xff) in ad1848_detect()
1613 unsigned char x = inb(devc->base); in ad1848_detect()
1621 if (inb(devc->base) == 0x80) /* Not ready. Let's wait */ in ad1848_detect()
1622 ad_leave_MCE(devc); in ad1848_detect()
1624 if ((inb(devc->base) & 0x80) != 0x00) /* Not a AD1848 */ in ad1848_detect()
1626 DDB(printk("ad1848 detect error - step A (%02x)\n", (int) inb(devc->base))); in ad1848_detect()
1637 ad_write(devc, 0, 0xaa); in ad1848_detect()
1638 ad_write(devc, 1, 0x45); /* 0x55 with bit 0x10 clear */ in ad1848_detect()
1640 if ((tmp1 = ad_read(devc, 0)) != 0xaa || (tmp2 = ad_read(devc, 1)) != 0x45) in ad1848_detect()
1651 ad_write(devc, 0, 0x45); in ad1848_detect()
1652 ad_write(devc, 1, 0xaa); in ad1848_detect()
1654 if ((tmp1 = ad_read(devc, 0)) != 0x45 || (tmp2 = ad_read(devc, 1)) != 0xaa) in ad1848_detect()
1671 tmp = ad_read(devc, 12); in ad1848_detect()
1672 ad_write(devc, 12, (~tmp) & 0x0f); in ad1848_detect()
1674 if ((tmp & 0x0f) != ((tmp1 = ad_read(devc, 12)) & 0x0f)) in ad1848_detect()
1700 ad_write(devc, 12, 0); /* Mode2=disabled */ in ad1848_detect()
1704 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) in ad1848_detect()
1723 ad_write(devc, 12, 0x40); /* Set mode2, clear 0x80 */ in ad1848_detect()
1729 tmp1 = ad_read(devc, 12); in ad1848_detect()
1735 devc->chip_name = "CS4248"; /* Our best knowledge just now */ in ad1848_detect()
1746 ad_write(devc, 16, 0); /* Set I16 to known value */ in ad1848_detect()
1748 ad_write(devc, 0, 0x45); in ad1848_detect()
1749 if ((tmp1 = ad_read(devc, 16)) != 0x45) /* No change -> CS4231? */ in ad1848_detect()
1751 ad_write(devc, 0, 0xaa); in ad1848_detect()
1752 if ((tmp1 = ad_read(devc, 16)) == 0xaa) /* Rotten bits? */ in ad1848_detect()
1763 tmp1 = ad_read(devc, 25); /* Original bits */ in ad1848_detect()
1764 ad_write(devc, 25, ~tmp1); /* Invert all bits */ in ad1848_detect()
1765 if ((ad_read(devc, 25) & 0xe7) == (tmp1 & 0xe7)) in ad1848_detect()
1773 devc->chip_name = "CS4231"; in ad1848_detect()
1774 devc->model = MD_4231; in ad1848_detect()
1782 id = ad_read(devc, 25); in ad1848_detect()
1784 id = ad_read(devc, 25); in ad1848_detect()
1786 id = ad_read(devc, 25); in ad1848_detect()
1787 DDB(printk("ad1848_detect() - step J (%02x/%02x)\n", id, ad_read(devc, 25))); in ad1848_detect()
1797 unsigned char tmp = ad_read(devc, 23); in ad1848_detect()
1798 ad_write(devc, 23, ~tmp); in ad1848_detect()
1802 devc->model = MD_IWAVE; in ad1848_detect()
1803 devc->chip_name = "IWave"; in ad1848_detect()
1805 else if (ad_read(devc, 23) != tmp) /* AD1845 ? */ in ad1848_detect()
1807 devc->chip_name = "AD1845"; in ad1848_detect()
1808 devc->model = MD_1845; in ad1848_detect()
1814 devc->chip_name = "CS4248"; in ad1848_detect()
1815 devc->model = MD_1848; in ad1848_detect()
1816 ad_write(devc, 12, ad_read(devc, 12) & ~0x40); /* Mode2 off */ in ad1848_detect()
1818 ad_write(devc, 23, tmp); /* Restore */ in ad1848_detect()
1826 ad_write(devc, 12, ad_read(devc, 12) | 0x60); /* switch to mode 3 */ in ad1848_detect()
1827 ad_write(devc, 23, 0x9c); /* select extended register 25 */ in ad1848_detect()
1828 xid = inb(io_Indexed_Data(devc)); in ad1848_detect()
1829 ad_write(devc, 12, ad_read(devc, 12) & ~0x60); /* back to mode 0 */ in ad1848_detect()
1833 devc->chip_name = "CS4237B(B)"; in ad1848_detect()
1834 devc->model = MD_42xB; in ad1848_detect()
1838 devc->chip_name = "CS4238"; in ad1848_detect()
1839 devc->model = MD_42xB; in ad1848_detect()
1842 devc->chip_name = "CS4238B"; in ad1848_detect()
1843 devc->model = MD_42xB; in ad1848_detect()
1846 devc->chip_name = "CS4236B"; in ad1848_detect()
1847 devc->model = MD_4236; in ad1848_detect()
1850 devc->chip_name = "CS4237B"; in ad1848_detect()
1851 devc->model = MD_42xB; in ad1848_detect()
1854 devc->chip_name = "CS4235"; in ad1848_detect()
1855 devc->model = MD_4235; in ad1848_detect()
1858 devc->chip_name = "CS4239"; in ad1848_detect()
1859 devc->model = MD_4239; in ad1848_detect()
1863 devc->chip_name = "CS42xx"; in ad1848_detect()
1864 devc->model = MD_4232; in ad1848_detect()
1871 devc->chip_name = "CS4232"; in ad1848_detect()
1872 devc->model = MD_4232; in ad1848_detect()
1878 devc->chip_name = "CS4231A"; in ad1848_detect()
1879 devc->model = MD_4231A; in ad1848_detect()
1883 devc->chip_name = "CS4321"; in ad1848_detect()
1884 devc->model = MD_4231; in ad1848_detect()
1889 DDB(printk("ad1848: I25 = %02x/%02x\n", ad_read(devc, 25), ad_read(devc, 25) & 0xe7)); in ad1848_detect()
1892 devc->chip_name = "82C930"; in ad1848_detect()
1893 devc->model = MD_C930; in ad1848_detect()
1897 devc->chip_name = "CS4231"; in ad1848_detect()
1898 devc->model = MD_4231; in ad1848_detect()
1903 ad_write(devc, 25, tmp1); /* Restore bits */ in ad1848_detect()
1919 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) { in ad1848_detect()
1922 devc->chip_name = "SoundPro CMI 8330"; in ad1848_detect()
1931 if (devc->model != MD_1848) in ad1848_detect()
1936 if (devc->model == MD_1848 && ad1847_flag) in ad1848_detect()
1937 devc->chip_name = "AD1847"; in ad1848_detect()
1941 devc->model = MD_1845_SSCAPE; in ad1848_detect()
1959 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_init() local
1963 devc->irq = (irq > 0) ? irq : 0; in ad1848_init()
1964 devc->open_mode = 0; in ad1848_init()
1965 devc->timer_ticks = 0; in ad1848_init()
1966 devc->dma1 = dma_playback; in ad1848_init()
1967 devc->dma2 = dma_capture; in ad1848_init()
1968 devc->subtype = cfg.card_subtype; in ad1848_init()
1969 devc->audio_flags = DMA_AUTOMODE; in ad1848_init()
1970 devc->playback_dev = devc->record_dev = 0; in ad1848_init()
1972 devc->name = name; in ad1848_init()
1976 "%s (%s)", name, devc->chip_name); in ad1848_init()
1979 "Generic audio codec (%s)", devc->chip_name); in ad1848_init()
1981 rename_region(ports, devc->name); in ad1848_init()
1983 conf_printf2(dev_name, devc->base, devc->irq, dma_playback, dma_capture); in ad1848_init()
1985 if (devc->model == MD_1848 || devc->model == MD_C930) in ad1848_init()
1986 devc->audio_flags |= DMA_HARDSTOP; in ad1848_init()
1988 if (devc->model > MD_1848) in ad1848_init()
1990 if (devc->dma1 == devc->dma2 || devc->dma2 == -1 || devc->dma1 == -1) in ad1848_init()
1991 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init()
1993 devc->audio_flags |= DMA_DUPLEX; in ad1848_init()
1998 release_region(devc->base, 4); in ad1848_init()
2006 devc->audio_flags, in ad1848_init()
2007 ad_format_mask[devc->model], in ad1848_init()
2008 devc, in ad1848_init()
2012 release_region(devc->base, 4); in ad1848_init()
2025 ad1848_init_hw(devc); in ad1848_init()
2029 devc->dev_no = my_dev; in ad1848_init()
2030 if (request_irq(devc->irq, adintr, 0, devc->name, in ad1848_init()
2035 devc->irq = 0; in ad1848_init()
2037 if (capabilities[devc->model].flags & CAP_F_TIMER) in ad1848_init()
2041 unsigned char tmp = ad_read(devc, 16); in ad1848_init()
2044 devc->timer_ticks = 0; in ad1848_init()
2046 ad_write(devc, 21, 0x00); /* Timer MSB */ in ad1848_init()
2047 ad_write(devc, 20, 0x10); /* Timer LSB */ in ad1848_init()
2049 ad_write(devc, 16, tmp | 0x40); /* Enable timer */ in ad1848_init()
2050 for (x = 0; x < 100000 && devc->timer_ticks == 0; x++); in ad1848_init()
2051 ad_write(devc, 16, tmp & ~0x40); /* Disable timer */ in ad1848_init()
2053 if (devc->timer_ticks == 0) in ad1848_init()
2058 devc->irq_ok = 1; in ad1848_init()
2061 devc->irq_ok = 1; in ad1848_init()
2065 devc->irq_ok = 1; /* Couldn't test. assume it's OK */ in ad1848_init()
2067 irq2dev[-irq] = devc->dev_no = my_dev; in ad1848_init()
2070 if ((capabilities[devc->model].flags & CAP_F_TIMER) && in ad1848_init()
2071 devc->irq_ok) in ad1848_init()
2077 if (sound_alloc_dma(dma_playback, devc->name)) in ad1848_init()
2081 if (sound_alloc_dma(dma_capture, devc->name)) in ad1848_init()
2089 devc)) >= 0) in ad1848_init()
2100 ad1848_info *devc; in ad1848_control() local
2106 devc = &adev_info[nr_ad1848_devs - 1]; in ad1848_control()
2111 if (devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_control()
2113 spin_lock_irqsave(&devc->lock,flags); in ad1848_control()
2114 ad_enter_MCE(devc); in ad1848_control()
2115 ad_write(devc, 29, (ad_read(devc, 29) & 0x1f) | (arg << 5)); in ad1848_control()
2116 ad_leave_MCE(devc); in ad1848_control()
2117 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_control()
2128 if (!(devc->supported_devices & (1 << o)) && in ad1848_control()
2129 !(devc->supported_rec_devices & (1 << o))) in ad1848_control()
2134 ad1848_mixer_set(devc, o, 0); /* Shut up it */ in ad1848_control()
2135 devc->supported_devices &= ~(1 << o); in ad1848_control()
2136 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2144 devc->mixer_reroute[n] = o; /* Rename the control */ in ad1848_control()
2145 if (devc->supported_devices & (1 << o)) in ad1848_control()
2146 devc->supported_devices |= (1 << n); in ad1848_control()
2147 if (devc->supported_rec_devices & (1 << o)) in ad1848_control()
2148 devc->supported_rec_devices |= (1 << n); in ad1848_control()
2150 devc->supported_devices &= ~(1 << o); in ad1848_control()
2151 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2161 ad1848_info *devc = NULL; in ad1848_unload() local
2163 for (i = 0; devc == NULL && i < nr_ad1848_devs; i++) in ad1848_unload()
2167 devc = &adev_info[i]; in ad1848_unload()
2168 dev = devc->dev_no; in ad1848_unload()
2172 if (devc != NULL) in ad1848_unload()
2175 release_region(devc->base, 4); in ad1848_unload()
2179 if (devc->irq > 0) /* There is no point in freeing irq, if it wasn't allocated */ in ad1848_unload()
2180 free_irq(devc->irq, (void *)(long)devc->dev_no); in ad1848_unload()
2188 mixer = audio_devs[devc->dev_no]->mixer_dev; in ad1848_unload()
2203 ad1848_info *devc; in adintr() local
2210 devc = (ad1848_info *) audio_devs[dev]->devc; in adintr()
2214 status = inb(io_Status(devc)); in adintr()
2218 if (devc->model == MD_1848) in adintr()
2219 outb((0), io_Status(devc)); /* Clear interrupt status */ in adintr()
2223 if (devc->model == MD_C930) in adintr()
2226 spin_lock(&devc->lock); in adintr()
2235 spin_unlock(&devc->lock); in adintr()
2239 else if (devc->model != MD_1848) in adintr()
2241 spin_lock(&devc->lock); in adintr()
2242 alt_stat = ad_read(devc, 24); in adintr()
2243 ad_write(devc, 24, ad_read(devc, 24) & ~alt_stat); /* Selective ack */ in adintr()
2244 spin_unlock(&devc->lock); in adintr()
2247 if ((devc->open_mode & OPEN_READ) && (devc->audio_mode & PCM_ENABLE_INPUT) && (alt_stat & 0x20)) in adintr()
2249 DMAbuf_inputintr(devc->record_dev); in adintr()
2251 if ((devc->open_mode & OPEN_WRITE) && (devc->audio_mode & PCM_ENABLE_OUTPUT) && in adintr()
2254 DMAbuf_outputintr(devc->playback_dev, 1); in adintr()
2256 if (devc->model != MD_1848 && (alt_stat & 0x40)) /* Timer interrupt */ in adintr()
2258 devc->timer_ticks++; in adintr()
2260 if (timer_installed == dev && devc->timer_running) in adintr()
2271 if (inb(io_Status(devc)) & 0x01 && cnt++ < 4) in adintr()
2705 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_start() local
2709 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_start()
2722 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_tmr_start()
2724 else if (ad_read(devc, 8) & 0x01) in ad1848_tmr_start()
2737 ad_write(devc, 21, (divider >> 8) & 0xff); /* Set upper bits */ in ad1848_tmr_start()
2738 ad_write(devc, 20, divider & 0xff); /* Set lower bits */ in ad1848_tmr_start()
2739 ad_write(devc, 16, ad_read(devc, 16) | 0x40); /* Start the timer */ in ad1848_tmr_start()
2740 devc->timer_running = 1; in ad1848_tmr_start()
2741 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_start()
2760 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_disable() local
2762 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_disable()
2763 ad_write(devc, 16, ad_read(devc, 16) & ~0x40); in ad1848_tmr_disable()
2764 devc->timer_running = 0; in ad1848_tmr_disable()
2765 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_disable()
2771 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_restart() local
2776 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_restart()
2777 ad_write(devc, 16, ad_read(devc, 16) | 0x40); in ad1848_tmr_restart()
2778 devc->timer_running = 1; in ad1848_tmr_restart()
2779 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_restart()