Lines Matching refs:devc
199 static int ad_read(ad1848_info * devc, int reg) in ad_read() argument
204 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_read()
209 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
210 x = inb(io_Indexed_Data(devc)); in ad_read()
218 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
219 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_read()
220 x = inb(io_Indexed_Data(devc)); in ad_read()
226 static void ad_write(ad1848_info * devc, int reg, int data) in ad_write() argument
230 while (timeout > 0 && inb(devc->base) == 0x80) /* Are we initializing */ in ad_write()
235 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
236 outb(((unsigned char) (data & 0xff)), io_Indexed_Data(devc)); in ad_write()
244 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
245 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_write()
246 outb((unsigned char) (data & 0xff), io_Indexed_Data(devc)); in ad_write()
250 static void wait_for_calibration(ad1848_info * devc) in wait_for_calibration() argument
262 while (timeout > 0 && inb(devc->base) == 0x80) in wait_for_calibration()
264 if (inb(devc->base) & 0x80) in wait_for_calibration()
268 while (timeout > 0 && !(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
270 if (!(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
274 while (timeout > 0 && (ad_read(devc, 11) & 0x20)) in wait_for_calibration()
276 if (ad_read(devc, 11) & 0x20) in wait_for_calibration()
277 if ((devc->model != MD_1845) && (devc->model != MD_1845_SSCAPE)) in wait_for_calibration()
281 static void ad_mute(ad1848_info * devc) in ad_mute() argument
292 prev = devc->saved_regs[i] = ad_read(devc, i); in ad_mute()
297 static void ad_unmute(ad1848_info * devc) in ad_unmute() argument
301 static void ad_enter_MCE(ad1848_info * devc) in ad_enter_MCE() argument
306 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_enter_MCE()
309 devc->MCE_bit = 0x40; in ad_enter_MCE()
310 prev = inb(io_Index_Addr(devc)); in ad_enter_MCE()
315 outb((devc->MCE_bit), io_Index_Addr(devc)); in ad_enter_MCE()
318 static void ad_leave_MCE(ad1848_info * devc) in ad_leave_MCE() argument
323 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_leave_MCE()
326 acal = ad_read(devc, 9); in ad_leave_MCE()
328 devc->MCE_bit = 0x00; in ad_leave_MCE()
329 prev = inb(io_Index_Addr(devc)); in ad_leave_MCE()
330 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
336 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
338 wait_for_calibration(devc); in ad_leave_MCE()
341 static int ad1848_set_recmask(ad1848_info * devc, int mask) in ad1848_set_recmask() argument
347 mask &= devc->supported_rec_devices; in ad1848_set_recmask()
352 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
357 mask |= (1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
367 spin_lock_irqsave(&devc->lock,flags); in ad1848_set_recmask()
372 mask &= ~devc->recmask; /* Filter out active settings */ in ad1848_set_recmask()
407 ad_write(devc, 0, (ad_read(devc, 0) & 0x3f) | recdev); in ad1848_set_recmask()
408 ad_write(devc, 1, (ad_read(devc, 1) & 0x3f) | recdev); in ad1848_set_recmask()
415 if ((devc->supported_rec_devices & (1 << i)) == 0) in ad1848_set_recmask()
419 if (devc->mix_devices[i][j].nbits == 0) /* Inexistent channel */ in ad1848_set_recmask()
427 set_rec_bit = ((mask & (1 << i)) != 0) ^ devc->mix_devices[i][j].recpol; in ad1848_set_recmask()
429 val = ad_read(devc, devc->mix_devices[i][j].recreg); in ad1848_set_recmask()
430 val &= ~(1 << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
431 val |= (set_rec_bit << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
432 ad_write(devc, devc->mix_devices[i][j].recreg, val); in ad1848_set_recmask()
436 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_set_recmask()
441 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
443 if (mask & (1 << devc->mixer_reroute[i])) in ad1848_set_recmask()
445 mask &= ~(1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
450 devc->recmask = mask; in ad1848_set_recmask()
454 static void oss_change_bits(ad1848_info *devc, unsigned char *regval, in oss_change_bits() argument
463 set_mute_bit = (newval == 0) ^ devc->mix_devices[dev][chn].mutepol; in oss_change_bits()
465 if (devc->mix_devices[dev][chn].polarity == 1) /* Reverse */ in oss_change_bits()
468 mask = (1 << devc->mix_devices[dev][chn].nbits) - 1; in oss_change_bits()
469 shift = devc->mix_devices[dev][chn].bitpos; in oss_change_bits()
471 if (devc->mix_devices[dev][chn].mutepos == 8) in oss_change_bits()
478 mute = (set_mute_bit << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
479 mutemask = ~(1 << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
490 static int ad1848_mixer_get(ad1848_info * devc, int dev) in ad1848_mixer_get() argument
492 if (!((1 << dev) & devc->supported_devices)) in ad1848_mixer_get()
495 dev = devc->mixer_reroute[dev]; in ad1848_mixer_get()
497 return devc->levels[dev]; in ad1848_mixer_get()
500 static void ad1848_mixer_set_channel(ad1848_info *devc, int dev, int value, int channel) in ad1848_mixer_set_channel() argument
506 regoffs = devc->mix_devices[dev][channel].regno; in ad1848_mixer_set_channel()
507 muteregoffs = devc->mix_devices[dev][channel].mutereg; in ad1848_mixer_set_channel()
508 val = ad_read(devc, regoffs); in ad1848_mixer_set_channel()
511 muteval = ad_read(devc, muteregoffs); in ad1848_mixer_set_channel()
512 oss_change_bits(devc, &val, &muteval, dev, channel, value); in ad1848_mixer_set_channel()
515 oss_change_bits(devc, &val, &val, dev, channel, value); in ad1848_mixer_set_channel()
517 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_set_channel()
518 ad_write(devc, regoffs, val); in ad1848_mixer_set_channel()
519 devc->saved_regs[regoffs] = val; in ad1848_mixer_set_channel()
521 ad_write(devc, muteregoffs, muteval); in ad1848_mixer_set_channel()
522 devc->saved_regs[muteregoffs] = muteval; in ad1848_mixer_set_channel()
524 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_set_channel()
527 static int ad1848_mixer_set(ad1848_info * devc, int dev, int value) in ad1848_mixer_set() argument
536 if (!(devc->supported_devices & (1 << dev))) in ad1848_mixer_set()
539 dev = devc->mixer_reroute[dev]; in ad1848_mixer_set()
541 if (devc->mix_devices[dev][LEFT_CHN].nbits == 0) in ad1848_mixer_set()
549 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) /* Mono control */ in ad1848_mixer_set()
558 devc->levels[dev] = retvol; in ad1848_mixer_set()
563 ad1848_mixer_set_channel(devc, dev, left, LEFT_CHN); in ad1848_mixer_set()
568 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) in ad1848_mixer_set()
570 ad1848_mixer_set_channel(devc, dev, right, RIGHT_CHN); in ad1848_mixer_set()
576 static void ad1848_mixer_reset(ad1848_info * devc) in ad1848_mixer_reset() argument
582 devc->mix_devices = &(ad1848_mix_devices[0]); in ad1848_mixer_reset()
584 sprintf(name, "%s_%d", devc->chip_name, nr_ad1848_devs); in ad1848_mixer_reset()
587 devc->mixer_reroute[i] = i; in ad1848_mixer_reset()
589 devc->supported_rec_devices = MODE1_REC_DEVICES; in ad1848_mixer_reset()
591 switch (devc->model) in ad1848_mixer_reset()
597 devc->supported_devices = MODE2_MIXER_DEVICES; in ad1848_mixer_reset()
601 devc->supported_devices = C930_MIXER_DEVICES; in ad1848_mixer_reset()
602 devc->mix_devices = &(c930_mix_devices[0]); in ad1848_mixer_reset()
606 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
607 devc->mix_devices = &(iwave_mix_devices[0]); in ad1848_mixer_reset()
612 devc->mix_devices = &(cs42xb_mix_devices[0]); in ad1848_mixer_reset()
613 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
618 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
623 devc->supported_devices = SPRO_MIXER_DEVICES; in ad1848_mixer_reset()
624 devc->supported_rec_devices = SPRO_REC_DEVICES; in ad1848_mixer_reset()
625 devc->mix_devices = &(spro_mix_devices[0]); in ad1848_mixer_reset()
630 devc->supported_devices = MODE1_MIXER_DEVICES; in ad1848_mixer_reset()
633 devc->orig_devices = devc->supported_devices; in ad1848_mixer_reset()
634 devc->orig_rec_devices = devc->supported_rec_devices; in ad1848_mixer_reset()
636 devc->levels = load_mixer_volumes(name, default_mixer_levels, 1); in ad1848_mixer_reset()
640 if (devc->supported_devices & (1 << i)) in ad1848_mixer_reset()
641 ad1848_mixer_set(devc, i, devc->levels[i]); in ad1848_mixer_reset()
644 ad1848_set_recmask(devc, SOUND_MASK_MIC); in ad1848_mixer_reset()
646 devc->mixer_output_port = devc->levels[31] | AUDIO_HEADPHONE | AUDIO_LINE_OUT; in ad1848_mixer_reset()
648 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_reset()
650 if (devc->mixer_output_port & AUDIO_SPEAKER) in ad1848_mixer_reset()
651 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_reset()
653 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_reset()
660 ad_write(devc, 16, 0x60); in ad1848_mixer_reset()
662 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_reset()
667 ad1848_info *devc = mixer_devs[dev]->devc; in ad1848_mixer_ioctl() local
679 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
681 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
682 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_ioctl()
684 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_ioctl()
686 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_ioctl()
687 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_ioctl()
689 val = devc->mixer_output_port; in ad1848_mixer_ioctl()
707 val = ad1848_set_recmask(devc, val); in ad1848_mixer_ioctl()
713 val = ad1848_mixer_set(devc, cmd & 0xff, val); in ad1848_mixer_ioctl()
727 val = devc->recmask; in ad1848_mixer_ioctl()
731 val = devc->supported_devices; in ad1848_mixer_ioctl()
735 val = devc->supported_devices; in ad1848_mixer_ioctl()
736 if (devc->model != MD_C930) in ad1848_mixer_ioctl()
741 val = devc->supported_rec_devices; in ad1848_mixer_ioctl()
749 val = ad1848_mixer_get(devc, cmd & 0xff); in ad1848_mixer_ioctl()
761 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_speed() local
805 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* AD1845 has different timer than ot… in ad1848_set_speed()
861 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_bits() local
916 if (!(arg & ad_format_mask[devc->model])) in ad1848_set_bits()
962 ad1848_info *devc; in ad1848_open() local
969 devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_open()
973 spin_lock(&devc->lock); in ad1848_open()
974 if (portc->open_mode || (devc->open_mode & mode)) in ad1848_open()
976 spin_unlock(&devc->lock); in ad1848_open()
979 devc->dual_dma = 0; in ad1848_open()
983 devc->dual_dma = 1; in ad1848_open()
985 devc->intr_active = 0; in ad1848_open()
986 devc->audio_mode = 0; in ad1848_open()
987 devc->open_mode |= mode; in ad1848_open()
989 spin_unlock(&devc->lock); in ad1848_open()
993 devc->record_dev = dev; in ad1848_open()
995 devc->playback_dev = dev; in ad1848_open()
999 spin_lock_irqsave(&devc->lock,flags); in ad1848_open()
1000 ad_mute(devc); in ad1848_open()
1001 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_open()
1009 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_close() local
1012 devc->intr_active = 0; in ad1848_close()
1015 spin_lock_irqsave(&devc->lock,flags); in ad1848_close()
1017 devc->audio_mode = 0; in ad1848_close()
1018 devc->open_mode &= ~portc->open_mode; in ad1848_close()
1021 ad_unmute(devc); in ad1848_close()
1022 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_close()
1028 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_output_block() local
1046 if ((devc->audio_mode & PCM_ENABLE_OUTPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_output_block()
1048 cnt == devc->xfer_count) in ad1848_output_block()
1050 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1051 devc->intr_active = 1; in ad1848_output_block()
1056 spin_lock_irqsave(&devc->lock,flags); in ad1848_output_block()
1058 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_output_block()
1059 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_output_block()
1061 devc->xfer_count = cnt; in ad1848_output_block()
1062 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1063 devc->intr_active = 1; in ad1848_output_block()
1064 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_output_block()
1070 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_start_input() local
1087 if ((devc->audio_mode & PCM_ENABLE_INPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_start_input()
1089 cnt == devc->xfer_count) in ad1848_start_input()
1091 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1092 devc->intr_active = 1; in ad1848_start_input()
1097 spin_lock_irqsave(&devc->lock,flags); in ad1848_start_input()
1099 if (devc->model == MD_1848) in ad1848_start_input()
1101 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1102 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1106 ad_write(devc, 31, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1107 ad_write(devc, 30, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1110 ad_unmute(devc); in ad1848_start_input()
1112 devc->xfer_count = cnt; in ad1848_start_input()
1113 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1114 devc->intr_active = 1; in ad1848_start_input()
1115 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_start_input()
1123 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_output() local
1126 ad_mute(devc); in ad1848_prepare_for_output()
1128 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_output()
1134 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_output()
1136 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* Use alternate speed select registe… in ad1848_prepare_for_output()
1140 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_output()
1141 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_output()
1143 old_fs = ad_read(devc, 8); in ad1848_prepare_for_output()
1145 if (devc->model == MD_4232 || devc->model >= MD_4236) in ad1848_prepare_for_output()
1147 tmp = ad_read(devc, 16); in ad1848_prepare_for_output()
1148 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_output()
1150 if (devc->model == MD_IWAVE) in ad1848_prepare_for_output()
1151 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_output()
1153 ad_write(devc, 8, fs); in ad1848_prepare_for_output()
1160 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_output()
1163 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_output()
1166 if (devc->model >= MD_4232) in ad1848_prepare_for_output()
1167 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_output()
1169 ad_leave_MCE(devc); /* in ad1848_prepare_for_output()
1172 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_output()
1173 devc->xfer_count = 0; in ad1848_prepare_for_output()
1176 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_output()
1191 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_input() local
1194 if (devc->audio_mode) in ad1848_prepare_for_input()
1197 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_input()
1203 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_input()
1205 …if ((devc->model == MD_1845) || (devc->model == MD_1845_SSCAPE)) /* Use alternate speed select reg… in ad1848_prepare_for_input()
1209 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_input()
1210 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_input()
1212 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1214 tmp = ad_read(devc, 16); in ad1848_prepare_for_input()
1215 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_input()
1217 if (devc->model == MD_IWAVE) in ad1848_prepare_for_input()
1218 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_input()
1224 if (devc->model != MD_1848) in ad1848_prepare_for_input()
1226 old_fs = ad_read(devc, 28); in ad1848_prepare_for_input()
1227 ad_write(devc, 28, fs); in ad1848_prepare_for_input()
1234 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1238 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1241 if (devc->model != MD_1848 && devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_prepare_for_input()
1248 unsigned char tmp = portc->speed_bits | (ad_read(devc, 8) & 0xf0); in ad1848_prepare_for_input()
1250 ad_write(devc, 8, tmp); in ad1848_prepare_for_input()
1255 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1259 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1266 old_fs = ad_read(devc, 8); in ad1848_prepare_for_input()
1267 ad_write(devc, 8, fs); in ad1848_prepare_for_input()
1272 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1275 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1279 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1280 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_input()
1282 ad_leave_MCE(devc); /* in ad1848_prepare_for_input()
1285 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_input()
1286 devc->xfer_count = 0; in ad1848_prepare_for_input()
1289 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_input()
1303 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt() local
1306 unsigned char bits = ad_read(devc, 9); in ad1848_halt()
1313 devc->audio_mode = 0; in ad1848_halt()
1318 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_input() local
1321 if (!(ad_read(devc, 9) & 0x02)) in ad1848_halt_input()
1324 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_input()
1326 ad_mute(devc); in ad1848_halt_input()
1335 if (ad_read(devc, 11) & 0x10) in ad1848_halt_input()
1337 ad_write(devc, 9, ad_read(devc, 9) & ~0x02); /* Stop capture */ in ad1848_halt_input()
1341 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1344 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1345 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1347 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1349 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_input()
1354 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_output() local
1357 if (!(ad_read(devc, 9) & 0x01)) in ad1848_halt_output()
1360 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_output()
1362 ad_mute(devc); in ad1848_halt_output()
1370 if (ad_read(devc, 11) & 0x10) in ad1848_halt_output()
1372 ad_write(devc, 9, ad_read(devc, 9) & ~0x01); /* Stop playback */ in ad1848_halt_output()
1377 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1380 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1381 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1383 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1385 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_output()
1390 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_trigger() local
1395 spin_lock_irqsave(&devc->lock,flags); in ad1848_trigger()
1396 state &= devc->audio_mode; in ad1848_trigger()
1398 tmp = old = ad_read(devc, 9); in ad1848_trigger()
1417 ad_write(devc, 9, tmp); in ad1848_trigger()
1418 ad_unmute(devc); in ad1848_trigger()
1420 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_trigger()
1423 static void ad1848_init_hw(ad1848_info * devc) in ad1848_init_hw() argument
1464 if(devc->model >= MD_4236) in ad1848_init_hw()
1468 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1471 ad_mute(devc); /* Initialize some variables */ in ad1848_init_hw()
1472 ad_unmute(devc); /* Leave it unmuted now */ in ad1848_init_hw()
1474 if (devc->model > MD_1848) in ad1848_init_hw()
1476 if (devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1477 ad_write(devc, 12, ad_read(devc, 12) | 0x50); in ad1848_init_hw()
1479 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1481 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1482 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1484 if (devc->model != MD_1845_SSCAPE) in ad1848_init_hw()
1486 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1488 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1489 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1491 if (devc->model > MD_1848) in ad1848_init_hw()
1493 if (devc->audio_flags & DMA_DUPLEX) in ad1848_init_hw()
1494 ad_write(devc, 9, ad_read(devc, 9) & ~0x04); /* Dual DMA mode */ in ad1848_init_hw()
1496 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1498 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1499 ad_write(devc, 27, ad_read(devc, 27) | 0x08); /* Alternate freq select enabled */ in ad1848_init_hw()
1501 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1503 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1504 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1505 ad_write(devc, 17, 0xc2); /* Alternate feature enable */ in ad1848_init_hw()
1510 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init_hw()
1511 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1513 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1516 outb((0), io_Status(devc)); /* Clear pending interrupts */ in ad1848_init_hw()
1522 ad_enter_MCE(devc); /* In case the bit was off */ in ad1848_init_hw()
1523 ad_leave_MCE(devc); in ad1848_init_hw()
1525 ad1848_mixer_reset(devc); in ad1848_init_hw()
1531 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_detect() local
1569 spin_lock_init(&devc->lock); in ad1848_detect()
1570 devc->base = io_base; in ad1848_detect()
1571 devc->irq_ok = 0; in ad1848_detect()
1572 devc->timer_running = 0; in ad1848_detect()
1573 devc->MCE_bit = 0x40; in ad1848_detect()
1574 devc->irq = 0; in ad1848_detect()
1575 devc->open_mode = 0; in ad1848_detect()
1576 devc->chip_name = devc->name = "AD1848"; in ad1848_detect()
1577 devc->model = MD_1848; /* AD1848 or CS4248 */ in ad1848_detect()
1578 devc->levels = NULL; in ad1848_detect()
1579 devc->debug_flag = 0; in ad1848_detect()
1591 if (inb(devc->base) == 0xff) in ad1848_detect()
1604 unsigned char x = inb(devc->base); in ad1848_detect()
1612 if (inb(devc->base) == 0x80) /* Not ready. Let's wait */ in ad1848_detect()
1613 ad_leave_MCE(devc); in ad1848_detect()
1615 if ((inb(devc->base) & 0x80) != 0x00) /* Not a AD1848 */ in ad1848_detect()
1617 DDB(printk("ad1848 detect error - step A (%02x)\n", (int) inb(devc->base))); in ad1848_detect()
1628 ad_write(devc, 0, 0xaa); in ad1848_detect()
1629 ad_write(devc, 1, 0x45); /* 0x55 with bit 0x10 clear */ in ad1848_detect()
1631 if ((tmp1 = ad_read(devc, 0)) != 0xaa || (tmp2 = ad_read(devc, 1)) != 0x45) in ad1848_detect()
1642 ad_write(devc, 0, 0x45); in ad1848_detect()
1643 ad_write(devc, 1, 0xaa); in ad1848_detect()
1645 if ((tmp1 = ad_read(devc, 0)) != 0x45 || (tmp2 = ad_read(devc, 1)) != 0xaa) in ad1848_detect()
1662 tmp = ad_read(devc, 12); in ad1848_detect()
1663 ad_write(devc, 12, (~tmp) & 0x0f); in ad1848_detect()
1665 if ((tmp & 0x0f) != ((tmp1 = ad_read(devc, 12)) & 0x0f)) in ad1848_detect()
1691 ad_write(devc, 12, 0); /* Mode2=disabled */ in ad1848_detect()
1695 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) in ad1848_detect()
1714 ad_write(devc, 12, 0x40); /* Set mode2, clear 0x80 */ in ad1848_detect()
1720 tmp1 = ad_read(devc, 12); in ad1848_detect()
1726 devc->chip_name = "CS4248"; /* Our best knowledge just now */ in ad1848_detect()
1737 ad_write(devc, 16, 0); /* Set I16 to known value */ in ad1848_detect()
1739 ad_write(devc, 0, 0x45); in ad1848_detect()
1740 if ((tmp1 = ad_read(devc, 16)) != 0x45) /* No change -> CS4231? */ in ad1848_detect()
1742 ad_write(devc, 0, 0xaa); in ad1848_detect()
1743 if ((tmp1 = ad_read(devc, 16)) == 0xaa) /* Rotten bits? */ in ad1848_detect()
1754 tmp1 = ad_read(devc, 25); /* Original bits */ in ad1848_detect()
1755 ad_write(devc, 25, ~tmp1); /* Invert all bits */ in ad1848_detect()
1756 if ((ad_read(devc, 25) & 0xe7) == (tmp1 & 0xe7)) in ad1848_detect()
1764 devc->chip_name = "CS4231"; in ad1848_detect()
1765 devc->model = MD_4231; in ad1848_detect()
1773 id = ad_read(devc, 25); in ad1848_detect()
1775 id = ad_read(devc, 25); in ad1848_detect()
1777 id = ad_read(devc, 25); in ad1848_detect()
1778 DDB(printk("ad1848_detect() - step J (%02x/%02x)\n", id, ad_read(devc, 25))); in ad1848_detect()
1788 unsigned char tmp = ad_read(devc, 23); in ad1848_detect()
1789 ad_write(devc, 23, ~tmp); in ad1848_detect()
1793 devc->model = MD_IWAVE; in ad1848_detect()
1794 devc->chip_name = "IWave"; in ad1848_detect()
1796 else if (ad_read(devc, 23) != tmp) /* AD1845 ? */ in ad1848_detect()
1798 devc->chip_name = "AD1845"; in ad1848_detect()
1799 devc->model = MD_1845; in ad1848_detect()
1805 devc->chip_name = "CS4248"; in ad1848_detect()
1806 devc->model = MD_1848; in ad1848_detect()
1807 ad_write(devc, 12, ad_read(devc, 12) & ~0x40); /* Mode2 off */ in ad1848_detect()
1809 ad_write(devc, 23, tmp); /* Restore */ in ad1848_detect()
1817 ad_write(devc, 12, ad_read(devc, 12) | 0x60); /* switch to mode 3 */ in ad1848_detect()
1818 ad_write(devc, 23, 0x9c); /* select extended register 25 */ in ad1848_detect()
1819 xid = inb(io_Indexed_Data(devc)); in ad1848_detect()
1820 ad_write(devc, 12, ad_read(devc, 12) & ~0x60); /* back to mode 0 */ in ad1848_detect()
1824 devc->chip_name = "CS4237B(B)"; in ad1848_detect()
1825 devc->model = MD_42xB; in ad1848_detect()
1829 devc->chip_name = "CS4238"; in ad1848_detect()
1830 devc->model = MD_42xB; in ad1848_detect()
1833 devc->chip_name = "CS4238B"; in ad1848_detect()
1834 devc->model = MD_42xB; in ad1848_detect()
1837 devc->chip_name = "CS4236B"; in ad1848_detect()
1838 devc->model = MD_4236; in ad1848_detect()
1841 devc->chip_name = "CS4237B"; in ad1848_detect()
1842 devc->model = MD_42xB; in ad1848_detect()
1845 devc->chip_name = "CS4235"; in ad1848_detect()
1846 devc->model = MD_4235; in ad1848_detect()
1849 devc->chip_name = "CS4239"; in ad1848_detect()
1850 devc->model = MD_4239; in ad1848_detect()
1854 devc->chip_name = "CS42xx"; in ad1848_detect()
1855 devc->model = MD_4232; in ad1848_detect()
1862 devc->chip_name = "CS4232"; in ad1848_detect()
1863 devc->model = MD_4232; in ad1848_detect()
1869 devc->chip_name = "CS4231A"; in ad1848_detect()
1870 devc->model = MD_4231A; in ad1848_detect()
1874 devc->chip_name = "CS4321"; in ad1848_detect()
1875 devc->model = MD_4231; in ad1848_detect()
1880 DDB(printk("ad1848: I25 = %02x/%02x\n", ad_read(devc, 25), ad_read(devc, 25) & 0xe7)); in ad1848_detect()
1883 devc->chip_name = "82C930"; in ad1848_detect()
1884 devc->model = MD_C930; in ad1848_detect()
1888 devc->chip_name = "CS4231"; in ad1848_detect()
1889 devc->model = MD_4231; in ad1848_detect()
1894 ad_write(devc, 25, tmp1); /* Restore bits */ in ad1848_detect()
1910 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) { in ad1848_detect()
1913 devc->chip_name = "SoundPro CMI 8330"; in ad1848_detect()
1922 if (devc->model != MD_1848) in ad1848_detect()
1927 if (devc->model == MD_1848 && ad1847_flag) in ad1848_detect()
1928 devc->chip_name = "AD1847"; in ad1848_detect()
1932 devc->model = MD_1845_SSCAPE; in ad1848_detect()
1950 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_init() local
1954 devc->irq = (irq > 0) ? irq : 0; in ad1848_init()
1955 devc->open_mode = 0; in ad1848_init()
1956 devc->timer_ticks = 0; in ad1848_init()
1957 devc->dma1 = dma_playback; in ad1848_init()
1958 devc->dma2 = dma_capture; in ad1848_init()
1959 devc->subtype = cfg.card_subtype; in ad1848_init()
1960 devc->audio_flags = DMA_AUTOMODE; in ad1848_init()
1961 devc->playback_dev = devc->record_dev = 0; in ad1848_init()
1963 devc->name = name; in ad1848_init()
1967 "%s (%s)", name, devc->chip_name); in ad1848_init()
1970 "Generic audio codec (%s)", devc->chip_name); in ad1848_init()
1972 rename_region(ports, devc->name); in ad1848_init()
1974 conf_printf2(dev_name, devc->base, devc->irq, dma_playback, dma_capture); in ad1848_init()
1976 if (devc->model == MD_1848 || devc->model == MD_C930) in ad1848_init()
1977 devc->audio_flags |= DMA_HARDSTOP; in ad1848_init()
1979 if (devc->model > MD_1848) in ad1848_init()
1981 if (devc->dma1 == devc->dma2 || devc->dma2 == -1 || devc->dma1 == -1) in ad1848_init()
1982 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init()
1984 devc->audio_flags |= DMA_DUPLEX; in ad1848_init()
1989 release_region(devc->base, 4); in ad1848_init()
1997 devc->audio_flags, in ad1848_init()
1998 ad_format_mask[devc->model], in ad1848_init()
1999 devc, in ad1848_init()
2003 release_region(devc->base, 4); in ad1848_init()
2016 ad1848_init_hw(devc); in ad1848_init()
2020 devc->dev_no = my_dev; in ad1848_init()
2021 if (request_irq(devc->irq, adintr, 0, devc->name, in ad1848_init()
2026 devc->irq = 0; in ad1848_init()
2028 if (capabilities[devc->model].flags & CAP_F_TIMER) in ad1848_init()
2032 unsigned char tmp = ad_read(devc, 16); in ad1848_init()
2035 devc->timer_ticks = 0; in ad1848_init()
2037 ad_write(devc, 21, 0x00); /* Timer MSB */ in ad1848_init()
2038 ad_write(devc, 20, 0x10); /* Timer LSB */ in ad1848_init()
2040 ad_write(devc, 16, tmp | 0x40); /* Enable timer */ in ad1848_init()
2041 for (x = 0; x < 100000 && devc->timer_ticks == 0; x++); in ad1848_init()
2042 ad_write(devc, 16, tmp & ~0x40); /* Disable timer */ in ad1848_init()
2044 if (devc->timer_ticks == 0) in ad1848_init()
2049 devc->irq_ok = 1; in ad1848_init()
2052 devc->irq_ok = 1; in ad1848_init()
2056 devc->irq_ok = 1; /* Couldn't test. assume it's OK */ in ad1848_init()
2058 devc->dev_no = my_dev; in ad1848_init()
2061 if ((capabilities[devc->model].flags & CAP_F_TIMER) && in ad1848_init()
2062 devc->irq_ok) in ad1848_init()
2068 if (sound_alloc_dma(dma_playback, devc->name)) in ad1848_init()
2072 if (sound_alloc_dma(dma_capture, devc->name)) in ad1848_init()
2080 devc)) >= 0) in ad1848_init()
2091 ad1848_info *devc; in ad1848_control() local
2097 devc = &adev_info[nr_ad1848_devs - 1]; in ad1848_control()
2102 if (devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_control()
2104 spin_lock_irqsave(&devc->lock,flags); in ad1848_control()
2105 ad_enter_MCE(devc); in ad1848_control()
2106 ad_write(devc, 29, (ad_read(devc, 29) & 0x1f) | (arg << 5)); in ad1848_control()
2107 ad_leave_MCE(devc); in ad1848_control()
2108 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_control()
2119 if (!(devc->supported_devices & (1 << o)) && in ad1848_control()
2120 !(devc->supported_rec_devices & (1 << o))) in ad1848_control()
2125 ad1848_mixer_set(devc, o, 0); /* Shut up it */ in ad1848_control()
2126 devc->supported_devices &= ~(1 << o); in ad1848_control()
2127 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2135 devc->mixer_reroute[n] = o; /* Rename the control */ in ad1848_control()
2136 if (devc->supported_devices & (1 << o)) in ad1848_control()
2137 devc->supported_devices |= (1 << n); in ad1848_control()
2138 if (devc->supported_rec_devices & (1 << o)) in ad1848_control()
2139 devc->supported_rec_devices |= (1 << n); in ad1848_control()
2141 devc->supported_devices &= ~(1 << o); in ad1848_control()
2142 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2152 ad1848_info *devc = NULL; in ad1848_unload() local
2154 for (i = 0; devc == NULL && i < nr_ad1848_devs; i++) in ad1848_unload()
2158 devc = &adev_info[i]; in ad1848_unload()
2159 dev = devc->dev_no; in ad1848_unload()
2163 if (devc != NULL) in ad1848_unload()
2166 release_region(devc->base, 4); in ad1848_unload()
2170 if (devc->irq > 0) /* There is no point in freeing irq, if it wasn't allocated */ in ad1848_unload()
2171 free_irq(devc->irq, (void *)(long)devc->dev_no); in ad1848_unload()
2179 mixer = audio_devs[devc->dev_no]->mixer_dev; in ad1848_unload()
2194 ad1848_info *devc; in adintr() local
2201 devc = (ad1848_info *) audio_devs[dev]->devc; in adintr()
2205 status = inb(io_Status(devc)); in adintr()
2209 if (devc->model == MD_1848) in adintr()
2210 outb((0), io_Status(devc)); /* Clear interrupt status */ in adintr()
2214 if (devc->model == MD_C930) in adintr()
2217 spin_lock(&devc->lock); in adintr()
2226 spin_unlock(&devc->lock); in adintr()
2230 else if (devc->model != MD_1848) in adintr()
2232 spin_lock(&devc->lock); in adintr()
2233 alt_stat = ad_read(devc, 24); in adintr()
2234 ad_write(devc, 24, ad_read(devc, 24) & ~alt_stat); /* Selective ack */ in adintr()
2235 spin_unlock(&devc->lock); in adintr()
2238 if ((devc->open_mode & OPEN_READ) && (devc->audio_mode & PCM_ENABLE_INPUT) && (alt_stat & 0x20)) in adintr()
2240 DMAbuf_inputintr(devc->record_dev); in adintr()
2242 if ((devc->open_mode & OPEN_WRITE) && (devc->audio_mode & PCM_ENABLE_OUTPUT) && in adintr()
2245 DMAbuf_outputintr(devc->playback_dev, 1); in adintr()
2247 if (devc->model != MD_1848 && (alt_stat & 0x40)) /* Timer interrupt */ in adintr()
2249 devc->timer_ticks++; in adintr()
2251 if (timer_installed == dev && devc->timer_running) in adintr()
2262 if (inb(io_Status(devc)) & 0x01 && cnt++ < 4) in adintr()
2696 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_start() local
2700 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_start()
2713 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_tmr_start()
2715 else if (ad_read(devc, 8) & 0x01) in ad1848_tmr_start()
2728 ad_write(devc, 21, (divider >> 8) & 0xff); /* Set upper bits */ in ad1848_tmr_start()
2729 ad_write(devc, 20, divider & 0xff); /* Set lower bits */ in ad1848_tmr_start()
2730 ad_write(devc, 16, ad_read(devc, 16) | 0x40); /* Start the timer */ in ad1848_tmr_start()
2731 devc->timer_running = 1; in ad1848_tmr_start()
2732 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_start()
2751 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_disable() local
2753 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_disable()
2754 ad_write(devc, 16, ad_read(devc, 16) & ~0x40); in ad1848_tmr_disable()
2755 devc->timer_running = 0; in ad1848_tmr_disable()
2756 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_disable()
2762 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_restart() local
2767 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_restart()
2768 ad_write(devc, 16, ad_read(devc, 16) | 0x40); in ad1848_tmr_restart()
2769 devc->timer_running = 1; in ad1848_tmr_restart()
2770 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_restart()