Lines Matching refs:devc
204 static int ad_read(ad1848_info * devc, int reg) in ad_read() argument
209 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_read()
214 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
215 x = inb(io_Indexed_Data(devc)); in ad_read()
223 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_read()
224 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_read()
225 x = inb(io_Indexed_Data(devc)); in ad_read()
231 static void ad_write(ad1848_info * devc, int reg, int data) in ad_write() argument
235 while (timeout > 0 && inb(devc->base) == 0x80) /* Are we initializing */ in ad_write()
240 outb(((unsigned char) (reg & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
241 outb(((unsigned char) (data & 0xff)), io_Indexed_Data(devc)); in ad_write()
249 outb(((unsigned char) (23 & 0xff) | devc->MCE_bit), io_Index_Addr(devc)); in ad_write()
250 outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc)); in ad_write()
251 outb((unsigned char) (data & 0xff), io_Indexed_Data(devc)); in ad_write()
255 static void wait_for_calibration(ad1848_info * devc) in wait_for_calibration() argument
267 while (timeout > 0 && inb(devc->base) == 0x80) in wait_for_calibration()
269 if (inb(devc->base) & 0x80) in wait_for_calibration()
273 while (timeout > 0 && !(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
275 if (!(ad_read(devc, 11) & 0x20)) in wait_for_calibration()
279 while (timeout > 0 && (ad_read(devc, 11) & 0x20)) in wait_for_calibration()
281 if (ad_read(devc, 11) & 0x20) in wait_for_calibration()
282 if ((devc->model != MD_1845) && (devc->model != MD_1845_SSCAPE)) in wait_for_calibration()
286 static void ad_mute(ad1848_info * devc) in ad_mute() argument
297 prev = devc->saved_regs[i] = ad_read(devc, i); in ad_mute()
302 static void ad_unmute(ad1848_info * devc) in ad_unmute() argument
306 static void ad_enter_MCE(ad1848_info * devc) in ad_enter_MCE() argument
311 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_enter_MCE()
314 devc->MCE_bit = 0x40; in ad_enter_MCE()
315 prev = inb(io_Index_Addr(devc)); in ad_enter_MCE()
320 outb((devc->MCE_bit), io_Index_Addr(devc)); in ad_enter_MCE()
323 static void ad_leave_MCE(ad1848_info * devc) in ad_leave_MCE() argument
328 while (timeout > 0 && inb(devc->base) == 0x80) /*Are we initializing */ in ad_leave_MCE()
331 acal = ad_read(devc, 9); in ad_leave_MCE()
333 devc->MCE_bit = 0x00; in ad_leave_MCE()
334 prev = inb(io_Index_Addr(devc)); in ad_leave_MCE()
335 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
341 outb((0x00), io_Index_Addr(devc)); /* Clear the MCE bit */ in ad_leave_MCE()
343 wait_for_calibration(devc); in ad_leave_MCE()
346 static int ad1848_set_recmask(ad1848_info * devc, int mask) in ad1848_set_recmask() argument
352 mask &= devc->supported_rec_devices; in ad1848_set_recmask()
357 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
362 mask |= (1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
372 spin_lock_irqsave(&devc->lock,flags); in ad1848_set_recmask()
377 mask &= ~devc->recmask; /* Filter out active settings */ in ad1848_set_recmask()
412 ad_write(devc, 0, (ad_read(devc, 0) & 0x3f) | recdev); in ad1848_set_recmask()
413 ad_write(devc, 1, (ad_read(devc, 1) & 0x3f) | recdev); in ad1848_set_recmask()
420 if ((devc->supported_rec_devices & (1 << i)) == 0) in ad1848_set_recmask()
424 if (devc->mix_devices[i][j].nbits == 0) /* Inexistent channel */ in ad1848_set_recmask()
432 set_rec_bit = ((mask & (1 << i)) != 0) ^ devc->mix_devices[i][j].recpol; in ad1848_set_recmask()
434 val = ad_read(devc, devc->mix_devices[i][j].recreg); in ad1848_set_recmask()
435 val &= ~(1 << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
436 val |= (set_rec_bit << devc->mix_devices[i][j].recpos); in ad1848_set_recmask()
437 ad_write(devc, devc->mix_devices[i][j].recreg, val); in ad1848_set_recmask()
441 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_set_recmask()
446 if (devc->mixer_reroute[i] != i) in ad1848_set_recmask()
448 if (mask & (1 << devc->mixer_reroute[i])) in ad1848_set_recmask()
450 mask &= ~(1 << devc->mixer_reroute[i]); in ad1848_set_recmask()
455 devc->recmask = mask; in ad1848_set_recmask()
459 static void oss_change_bits(ad1848_info *devc, unsigned char *regval, in oss_change_bits() argument
468 set_mute_bit = (newval == 0) ^ devc->mix_devices[dev][chn].mutepol; in oss_change_bits()
470 if (devc->mix_devices[dev][chn].polarity == 1) /* Reverse */ in oss_change_bits()
473 mask = (1 << devc->mix_devices[dev][chn].nbits) - 1; in oss_change_bits()
474 shift = devc->mix_devices[dev][chn].bitpos; in oss_change_bits()
476 if (devc->mix_devices[dev][chn].mutepos == 8) in oss_change_bits()
483 mute = (set_mute_bit << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
484 mutemask = ~(1 << devc->mix_devices[dev][chn].mutepos); in oss_change_bits()
495 static int ad1848_mixer_get(ad1848_info * devc, int dev) in ad1848_mixer_get() argument
497 if (!((1 << dev) & devc->supported_devices)) in ad1848_mixer_get()
500 dev = devc->mixer_reroute[dev]; in ad1848_mixer_get()
502 return devc->levels[dev]; in ad1848_mixer_get()
505 static void ad1848_mixer_set_channel(ad1848_info *devc, int dev, int value, int channel) in ad1848_mixer_set_channel() argument
511 regoffs = devc->mix_devices[dev][channel].regno; in ad1848_mixer_set_channel()
512 muteregoffs = devc->mix_devices[dev][channel].mutereg; in ad1848_mixer_set_channel()
513 val = ad_read(devc, regoffs); in ad1848_mixer_set_channel()
516 muteval = ad_read(devc, muteregoffs); in ad1848_mixer_set_channel()
517 oss_change_bits(devc, &val, &muteval, dev, channel, value); in ad1848_mixer_set_channel()
520 oss_change_bits(devc, &val, &val, dev, channel, value); in ad1848_mixer_set_channel()
522 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_set_channel()
523 ad_write(devc, regoffs, val); in ad1848_mixer_set_channel()
524 devc->saved_regs[regoffs] = val; in ad1848_mixer_set_channel()
526 ad_write(devc, muteregoffs, muteval); in ad1848_mixer_set_channel()
527 devc->saved_regs[muteregoffs] = muteval; in ad1848_mixer_set_channel()
529 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_set_channel()
532 static int ad1848_mixer_set(ad1848_info * devc, int dev, int value) in ad1848_mixer_set() argument
541 if (!(devc->supported_devices & (1 << dev))) in ad1848_mixer_set()
544 dev = devc->mixer_reroute[dev]; in ad1848_mixer_set()
546 if (devc->mix_devices[dev][LEFT_CHN].nbits == 0) in ad1848_mixer_set()
554 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) /* Mono control */ in ad1848_mixer_set()
563 devc->levels[dev] = retvol; in ad1848_mixer_set()
568 ad1848_mixer_set_channel(devc, dev, left, LEFT_CHN); in ad1848_mixer_set()
573 if (devc->mix_devices[dev][RIGHT_CHN].nbits == 0) in ad1848_mixer_set()
575 ad1848_mixer_set_channel(devc, dev, right, RIGHT_CHN); in ad1848_mixer_set()
581 static void ad1848_mixer_reset(ad1848_info * devc) in ad1848_mixer_reset() argument
587 devc->mix_devices = &(ad1848_mix_devices[0]); in ad1848_mixer_reset()
589 sprintf(name, "%s_%d", devc->chip_name, nr_ad1848_devs); in ad1848_mixer_reset()
592 devc->mixer_reroute[i] = i; in ad1848_mixer_reset()
594 devc->supported_rec_devices = MODE1_REC_DEVICES; in ad1848_mixer_reset()
596 switch (devc->model) in ad1848_mixer_reset()
602 devc->supported_devices = MODE2_MIXER_DEVICES; in ad1848_mixer_reset()
606 devc->supported_devices = C930_MIXER_DEVICES; in ad1848_mixer_reset()
607 devc->mix_devices = &(c930_mix_devices[0]); in ad1848_mixer_reset()
611 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
612 devc->mix_devices = &(iwave_mix_devices[0]); in ad1848_mixer_reset()
617 devc->mix_devices = &(cs42xb_mix_devices[0]); in ad1848_mixer_reset()
618 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
623 devc->supported_devices = MODE3_MIXER_DEVICES; in ad1848_mixer_reset()
628 devc->supported_devices = SPRO_MIXER_DEVICES; in ad1848_mixer_reset()
629 devc->supported_rec_devices = SPRO_REC_DEVICES; in ad1848_mixer_reset()
630 devc->mix_devices = &(spro_mix_devices[0]); in ad1848_mixer_reset()
635 devc->supported_devices = MODE1_MIXER_DEVICES; in ad1848_mixer_reset()
638 devc->orig_devices = devc->supported_devices; in ad1848_mixer_reset()
639 devc->orig_rec_devices = devc->supported_rec_devices; in ad1848_mixer_reset()
641 devc->levels = load_mixer_volumes(name, default_mixer_levels, 1); in ad1848_mixer_reset()
645 if (devc->supported_devices & (1 << i)) in ad1848_mixer_reset()
646 ad1848_mixer_set(devc, i, devc->levels[i]); in ad1848_mixer_reset()
649 ad1848_set_recmask(devc, SOUND_MASK_MIC); in ad1848_mixer_reset()
651 devc->mixer_output_port = devc->levels[31] | AUDIO_HEADPHONE | AUDIO_LINE_OUT; in ad1848_mixer_reset()
653 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_reset()
655 if (devc->mixer_output_port & AUDIO_SPEAKER) in ad1848_mixer_reset()
656 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_reset()
658 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_reset()
665 ad_write(devc, 16, 0x60); in ad1848_mixer_reset()
667 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_reset()
672 ad1848_info *devc = mixer_devs[dev]->devc; in ad1848_mixer_ioctl() local
684 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
686 devc->mixer_output_port = val; in ad1848_mixer_ioctl()
687 spin_lock_irqsave(&devc->lock,flags); in ad1848_mixer_ioctl()
689 ad_write(devc, 26, ad_read(devc, 26) & ~0x40); /* Unmute mono out */ in ad1848_mixer_ioctl()
691 ad_write(devc, 26, ad_read(devc, 26) | 0x40); /* Mute mono out */ in ad1848_mixer_ioctl()
692 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_mixer_ioctl()
694 val = devc->mixer_output_port; in ad1848_mixer_ioctl()
712 val = ad1848_set_recmask(devc, val); in ad1848_mixer_ioctl()
718 val = ad1848_mixer_set(devc, cmd & 0xff, val); in ad1848_mixer_ioctl()
732 val = devc->recmask; in ad1848_mixer_ioctl()
736 val = devc->supported_devices; in ad1848_mixer_ioctl()
740 val = devc->supported_devices; in ad1848_mixer_ioctl()
741 if (devc->model != MD_C930) in ad1848_mixer_ioctl()
746 val = devc->supported_rec_devices; in ad1848_mixer_ioctl()
754 val = ad1848_mixer_get(devc, cmd & 0xff); in ad1848_mixer_ioctl()
766 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_speed() local
810 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* AD1845 has different timer than ot… in ad1848_set_speed()
866 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_set_bits() local
921 if (!(arg & ad_format_mask[devc->model])) in ad1848_set_bits()
967 ad1848_info *devc; in ad1848_open() local
974 devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_open()
978 spin_lock(&devc->lock); in ad1848_open()
979 if (portc->open_mode || (devc->open_mode & mode)) in ad1848_open()
981 spin_unlock(&devc->lock); in ad1848_open()
984 devc->dual_dma = 0; in ad1848_open()
988 devc->dual_dma = 1; in ad1848_open()
990 devc->intr_active = 0; in ad1848_open()
991 devc->audio_mode = 0; in ad1848_open()
992 devc->open_mode |= mode; in ad1848_open()
994 spin_unlock(&devc->lock); in ad1848_open()
998 devc->record_dev = dev; in ad1848_open()
1000 devc->playback_dev = dev; in ad1848_open()
1004 spin_lock_irqsave(&devc->lock,flags); in ad1848_open()
1005 ad_mute(devc); in ad1848_open()
1006 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_open()
1014 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_close() local
1017 devc->intr_active = 0; in ad1848_close()
1020 spin_lock_irqsave(&devc->lock,flags); in ad1848_close()
1022 devc->audio_mode = 0; in ad1848_close()
1023 devc->open_mode &= ~portc->open_mode; in ad1848_close()
1026 ad_unmute(devc); in ad1848_close()
1027 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_close()
1033 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_output_block() local
1051 if ((devc->audio_mode & PCM_ENABLE_OUTPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_output_block()
1053 cnt == devc->xfer_count) in ad1848_output_block()
1055 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1056 devc->intr_active = 1; in ad1848_output_block()
1061 spin_lock_irqsave(&devc->lock,flags); in ad1848_output_block()
1063 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_output_block()
1064 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_output_block()
1066 devc->xfer_count = cnt; in ad1848_output_block()
1067 devc->audio_mode |= PCM_ENABLE_OUTPUT; in ad1848_output_block()
1068 devc->intr_active = 1; in ad1848_output_block()
1069 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_output_block()
1075 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_start_input() local
1092 if ((devc->audio_mode & PCM_ENABLE_INPUT) && (audio_devs[dev]->flags & DMA_AUTOMODE) && in ad1848_start_input()
1094 cnt == devc->xfer_count) in ad1848_start_input()
1096 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1097 devc->intr_active = 1; in ad1848_start_input()
1102 spin_lock_irqsave(&devc->lock,flags); in ad1848_start_input()
1104 if (devc->model == MD_1848) in ad1848_start_input()
1106 ad_write(devc, 15, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1107 ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1111 ad_write(devc, 31, (unsigned char) (cnt & 0xff)); in ad1848_start_input()
1112 ad_write(devc, 30, (unsigned char) ((cnt >> 8) & 0xff)); in ad1848_start_input()
1115 ad_unmute(devc); in ad1848_start_input()
1117 devc->xfer_count = cnt; in ad1848_start_input()
1118 devc->audio_mode |= PCM_ENABLE_INPUT; in ad1848_start_input()
1119 devc->intr_active = 1; in ad1848_start_input()
1120 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_start_input()
1128 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_output() local
1131 ad_mute(devc); in ad1848_prepare_for_output()
1133 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_output()
1139 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_output()
1141 …if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) /* Use alternate speed select registe… in ad1848_prepare_for_output()
1145 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_output()
1146 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_output()
1148 old_fs = ad_read(devc, 8); in ad1848_prepare_for_output()
1150 if (devc->model == MD_4232 || devc->model >= MD_4236) in ad1848_prepare_for_output()
1152 tmp = ad_read(devc, 16); in ad1848_prepare_for_output()
1153 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_output()
1155 if (devc->model == MD_IWAVE) in ad1848_prepare_for_output()
1156 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_output()
1158 ad_write(devc, 8, fs); in ad1848_prepare_for_output()
1165 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_output()
1168 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_output()
1171 if (devc->model >= MD_4232) in ad1848_prepare_for_output()
1172 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_output()
1174 ad_leave_MCE(devc); /* in ad1848_prepare_for_output()
1177 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_output()
1178 devc->xfer_count = 0; in ad1848_prepare_for_output()
1181 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_output()
1196 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_prepare_for_input() local
1199 if (devc->audio_mode) in ad1848_prepare_for_input()
1202 spin_lock_irqsave(&devc->lock,flags); in ad1848_prepare_for_input()
1208 ad_enter_MCE(devc); /* Enables changes to the format select reg */ in ad1848_prepare_for_input()
1210 …if ((devc->model == MD_1845) || (devc->model == MD_1845_SSCAPE)) /* Use alternate speed select reg… in ad1848_prepare_for_input()
1214 ad_write(devc, 22, (portc->speed >> 8) & 0xff); /* Speed MSB */ in ad1848_prepare_for_input()
1215 ad_write(devc, 23, portc->speed & 0xff); /* Speed LSB */ in ad1848_prepare_for_input()
1217 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1219 tmp = ad_read(devc, 16); in ad1848_prepare_for_input()
1220 ad_write(devc, 16, tmp | 0x30); in ad1848_prepare_for_input()
1222 if (devc->model == MD_IWAVE) in ad1848_prepare_for_input()
1223 ad_write(devc, 17, 0xc2); /* Disable variable frequency select */ in ad1848_prepare_for_input()
1229 if (devc->model != MD_1848) in ad1848_prepare_for_input()
1231 old_fs = ad_read(devc, 28); in ad1848_prepare_for_input()
1232 ad_write(devc, 28, fs); in ad1848_prepare_for_input()
1239 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1243 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1246 if (devc->model != MD_1848 && devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_prepare_for_input()
1253 unsigned char tmp = portc->speed_bits | (ad_read(devc, 8) & 0xf0); in ad1848_prepare_for_input()
1255 ad_write(devc, 8, tmp); in ad1848_prepare_for_input()
1260 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1264 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1271 old_fs = ad_read(devc, 8); in ad1848_prepare_for_input()
1272 ad_write(devc, 8, fs); in ad1848_prepare_for_input()
1277 while (timeout < 100 && inb(devc->base) != 0x80) in ad1848_prepare_for_input()
1280 while (timeout < 10000 && inb(devc->base) == 0x80) in ad1848_prepare_for_input()
1284 if (devc->model == MD_4232) in ad1848_prepare_for_input()
1285 ad_write(devc, 16, tmp & ~0x30); in ad1848_prepare_for_input()
1287 ad_leave_MCE(devc); /* in ad1848_prepare_for_input()
1290 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_prepare_for_input()
1291 devc->xfer_count = 0; in ad1848_prepare_for_input()
1294 if (dev == timer_installed && devc->timer_running) in ad1848_prepare_for_input()
1308 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt() local
1311 unsigned char bits = ad_read(devc, 9); in ad1848_halt()
1318 devc->audio_mode = 0; in ad1848_halt()
1323 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_input() local
1326 if (!(ad_read(devc, 9) & 0x02)) in ad1848_halt_input()
1329 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_input()
1331 ad_mute(devc); in ad1848_halt_input()
1340 if (ad_read(devc, 11) & 0x10) in ad1848_halt_input()
1342 ad_write(devc, 9, ad_read(devc, 9) & ~0x02); /* Stop capture */ in ad1848_halt_input()
1346 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1349 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1350 outb(0, io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_input()
1352 devc->audio_mode &= ~PCM_ENABLE_INPUT; in ad1848_halt_input()
1354 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_input()
1359 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_halt_output() local
1362 if (!(ad_read(devc, 9) & 0x01)) in ad1848_halt_output()
1365 spin_lock_irqsave(&devc->lock,flags); in ad1848_halt_output()
1367 ad_mute(devc); in ad1848_halt_output()
1375 if (ad_read(devc, 11) & 0x10) in ad1848_halt_output()
1377 ad_write(devc, 9, ad_read(devc, 9) & ~0x01); /* Stop playback */ in ad1848_halt_output()
1382 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1385 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1386 outb((0), io_Status(devc)); /* Clear interrupt status */ in ad1848_halt_output()
1388 devc->audio_mode &= ~PCM_ENABLE_OUTPUT; in ad1848_halt_output()
1390 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_halt_output()
1395 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_trigger() local
1400 spin_lock_irqsave(&devc->lock,flags); in ad1848_trigger()
1401 state &= devc->audio_mode; in ad1848_trigger()
1403 tmp = old = ad_read(devc, 9); in ad1848_trigger()
1422 ad_write(devc, 9, tmp); in ad1848_trigger()
1423 ad_unmute(devc); in ad1848_trigger()
1425 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_trigger()
1428 static void ad1848_init_hw(ad1848_info * devc) in ad1848_init_hw() argument
1469 if(devc->model >= MD_4236) in ad1848_init_hw()
1473 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1476 ad_mute(devc); /* Initialize some variables */ in ad1848_init_hw()
1477 ad_unmute(devc); /* Leave it unmuted now */ in ad1848_init_hw()
1479 if (devc->model > MD_1848) in ad1848_init_hw()
1481 if (devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1482 ad_write(devc, 12, ad_read(devc, 12) | 0x50); in ad1848_init_hw()
1484 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1486 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1487 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1489 if (devc->model != MD_1845_SSCAPE) in ad1848_init_hw()
1491 ad_write(devc, i, init_values[i]); in ad1848_init_hw()
1493 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1494 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1496 if (devc->model > MD_1848) in ad1848_init_hw()
1498 if (devc->audio_flags & DMA_DUPLEX) in ad1848_init_hw()
1499 ad_write(devc, 9, ad_read(devc, 9) & ~0x04); /* Dual DMA mode */ in ad1848_init_hw()
1501 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1503 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_init_hw()
1504 ad_write(devc, 27, ad_read(devc, 27) | 0x08); /* Alternate freq select enabled */ in ad1848_init_hw()
1506 if (devc->model == MD_IWAVE) in ad1848_init_hw()
1508 ad_write(devc, 12, 0x6c); /* Select codec mode 3 */ in ad1848_init_hw()
1509 ad_write(devc, 16, 0x30); /* Playback and capture counters enabled */ in ad1848_init_hw()
1510 ad_write(devc, 17, 0xc2); /* Alternate feature enable */ in ad1848_init_hw()
1515 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init_hw()
1516 ad_write(devc, 9, ad_read(devc, 9) | 0x04); /* Single DMA mode */ in ad1848_init_hw()
1518 ad_write(devc, 12, ad_read(devc, 12) | 0x40); /* Mode2 = enabled */ in ad1848_init_hw()
1521 outb((0), io_Status(devc)); /* Clear pending interrupts */ in ad1848_init_hw()
1527 ad_enter_MCE(devc); /* In case the bit was off */ in ad1848_init_hw()
1528 ad_leave_MCE(devc); in ad1848_init_hw()
1530 ad1848_mixer_reset(devc); in ad1848_init_hw()
1536 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_detect() local
1574 spin_lock_init(&devc->lock); in ad1848_detect()
1575 devc->base = io_base; in ad1848_detect()
1576 devc->irq_ok = 0; in ad1848_detect()
1577 devc->timer_running = 0; in ad1848_detect()
1578 devc->MCE_bit = 0x40; in ad1848_detect()
1579 devc->irq = 0; in ad1848_detect()
1580 devc->open_mode = 0; in ad1848_detect()
1581 devc->chip_name = devc->name = "AD1848"; in ad1848_detect()
1582 devc->model = MD_1848; /* AD1848 or CS4248 */ in ad1848_detect()
1583 devc->levels = NULL; in ad1848_detect()
1584 devc->debug_flag = 0; in ad1848_detect()
1596 if (inb(devc->base) == 0xff) in ad1848_detect()
1609 unsigned char x = inb(devc->base); in ad1848_detect()
1617 if (inb(devc->base) == 0x80) /* Not ready. Let's wait */ in ad1848_detect()
1618 ad_leave_MCE(devc); in ad1848_detect()
1620 if ((inb(devc->base) & 0x80) != 0x00) /* Not a AD1848 */ in ad1848_detect()
1622 DDB(printk("ad1848 detect error - step A (%02x)\n", (int) inb(devc->base))); in ad1848_detect()
1633 ad_write(devc, 0, 0xaa); in ad1848_detect()
1634 ad_write(devc, 1, 0x45); /* 0x55 with bit 0x10 clear */ in ad1848_detect()
1636 if ((tmp1 = ad_read(devc, 0)) != 0xaa || (tmp2 = ad_read(devc, 1)) != 0x45) in ad1848_detect()
1647 ad_write(devc, 0, 0x45); in ad1848_detect()
1648 ad_write(devc, 1, 0xaa); in ad1848_detect()
1650 if ((tmp1 = ad_read(devc, 0)) != 0x45 || (tmp2 = ad_read(devc, 1)) != 0xaa) in ad1848_detect()
1667 tmp = ad_read(devc, 12); in ad1848_detect()
1668 ad_write(devc, 12, (~tmp) & 0x0f); in ad1848_detect()
1670 if ((tmp & 0x0f) != ((tmp1 = ad_read(devc, 12)) & 0x0f)) in ad1848_detect()
1696 ad_write(devc, 12, 0); /* Mode2=disabled */ in ad1848_detect()
1700 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) in ad1848_detect()
1719 ad_write(devc, 12, 0x40); /* Set mode2, clear 0x80 */ in ad1848_detect()
1725 tmp1 = ad_read(devc, 12); in ad1848_detect()
1731 devc->chip_name = "CS4248"; /* Our best knowledge just now */ in ad1848_detect()
1742 ad_write(devc, 16, 0); /* Set I16 to known value */ in ad1848_detect()
1744 ad_write(devc, 0, 0x45); in ad1848_detect()
1745 if ((tmp1 = ad_read(devc, 16)) != 0x45) /* No change -> CS4231? */ in ad1848_detect()
1747 ad_write(devc, 0, 0xaa); in ad1848_detect()
1748 if ((tmp1 = ad_read(devc, 16)) == 0xaa) /* Rotten bits? */ in ad1848_detect()
1759 tmp1 = ad_read(devc, 25); /* Original bits */ in ad1848_detect()
1760 ad_write(devc, 25, ~tmp1); /* Invert all bits */ in ad1848_detect()
1761 if ((ad_read(devc, 25) & 0xe7) == (tmp1 & 0xe7)) in ad1848_detect()
1769 devc->chip_name = "CS4231"; in ad1848_detect()
1770 devc->model = MD_4231; in ad1848_detect()
1778 id = ad_read(devc, 25); in ad1848_detect()
1780 id = ad_read(devc, 25); in ad1848_detect()
1782 id = ad_read(devc, 25); in ad1848_detect()
1783 DDB(printk("ad1848_detect() - step J (%02x/%02x)\n", id, ad_read(devc, 25))); in ad1848_detect()
1793 unsigned char tmp = ad_read(devc, 23); in ad1848_detect()
1794 ad_write(devc, 23, ~tmp); in ad1848_detect()
1798 devc->model = MD_IWAVE; in ad1848_detect()
1799 devc->chip_name = "IWave"; in ad1848_detect()
1801 else if (ad_read(devc, 23) != tmp) /* AD1845 ? */ in ad1848_detect()
1803 devc->chip_name = "AD1845"; in ad1848_detect()
1804 devc->model = MD_1845; in ad1848_detect()
1810 devc->chip_name = "CS4248"; in ad1848_detect()
1811 devc->model = MD_1848; in ad1848_detect()
1812 ad_write(devc, 12, ad_read(devc, 12) & ~0x40); /* Mode2 off */ in ad1848_detect()
1814 ad_write(devc, 23, tmp); /* Restore */ in ad1848_detect()
1822 ad_write(devc, 12, ad_read(devc, 12) | 0x60); /* switch to mode 3 */ in ad1848_detect()
1823 ad_write(devc, 23, 0x9c); /* select extended register 25 */ in ad1848_detect()
1824 xid = inb(io_Indexed_Data(devc)); in ad1848_detect()
1825 ad_write(devc, 12, ad_read(devc, 12) & ~0x60); /* back to mode 0 */ in ad1848_detect()
1829 devc->chip_name = "CS4237B(B)"; in ad1848_detect()
1830 devc->model = MD_42xB; in ad1848_detect()
1834 devc->chip_name = "CS4238"; in ad1848_detect()
1835 devc->model = MD_42xB; in ad1848_detect()
1838 devc->chip_name = "CS4238B"; in ad1848_detect()
1839 devc->model = MD_42xB; in ad1848_detect()
1842 devc->chip_name = "CS4236B"; in ad1848_detect()
1843 devc->model = MD_4236; in ad1848_detect()
1846 devc->chip_name = "CS4237B"; in ad1848_detect()
1847 devc->model = MD_42xB; in ad1848_detect()
1850 devc->chip_name = "CS4235"; in ad1848_detect()
1851 devc->model = MD_4235; in ad1848_detect()
1854 devc->chip_name = "CS4239"; in ad1848_detect()
1855 devc->model = MD_4239; in ad1848_detect()
1859 devc->chip_name = "CS42xx"; in ad1848_detect()
1860 devc->model = MD_4232; in ad1848_detect()
1867 devc->chip_name = "CS4232"; in ad1848_detect()
1868 devc->model = MD_4232; in ad1848_detect()
1874 devc->chip_name = "CS4231A"; in ad1848_detect()
1875 devc->model = MD_4231A; in ad1848_detect()
1879 devc->chip_name = "CS4321"; in ad1848_detect()
1880 devc->model = MD_4231; in ad1848_detect()
1885 DDB(printk("ad1848: I25 = %02x/%02x\n", ad_read(devc, 25), ad_read(devc, 25) & 0xe7)); in ad1848_detect()
1888 devc->chip_name = "82C930"; in ad1848_detect()
1889 devc->model = MD_C930; in ad1848_detect()
1893 devc->chip_name = "CS4231"; in ad1848_detect()
1894 devc->model = MD_4231; in ad1848_detect()
1899 ad_write(devc, 25, tmp1); /* Restore bits */ in ad1848_detect()
1915 if ((tmp1 = ad_read(devc, i)) != (tmp2 = ad_read(devc, i + 16))) { in ad1848_detect()
1918 devc->chip_name = "SoundPro CMI 8330"; in ad1848_detect()
1927 if (devc->model != MD_1848) in ad1848_detect()
1932 if (devc->model == MD_1848 && ad1847_flag) in ad1848_detect()
1933 devc->chip_name = "AD1847"; in ad1848_detect()
1937 devc->model = MD_1845_SSCAPE; in ad1848_detect()
1955 ad1848_info *devc = &adev_info[nr_ad1848_devs]; in ad1848_init() local
1959 devc->irq = (irq > 0) ? irq : 0; in ad1848_init()
1960 devc->open_mode = 0; in ad1848_init()
1961 devc->timer_ticks = 0; in ad1848_init()
1962 devc->dma1 = dma_playback; in ad1848_init()
1963 devc->dma2 = dma_capture; in ad1848_init()
1964 devc->subtype = cfg.card_subtype; in ad1848_init()
1965 devc->audio_flags = DMA_AUTOMODE; in ad1848_init()
1966 devc->playback_dev = devc->record_dev = 0; in ad1848_init()
1968 devc->name = name; in ad1848_init()
1972 "%s (%s)", name, devc->chip_name); in ad1848_init()
1975 "Generic audio codec (%s)", devc->chip_name); in ad1848_init()
1977 rename_region(ports, devc->name); in ad1848_init()
1979 conf_printf2(dev_name, devc->base, devc->irq, dma_playback, dma_capture); in ad1848_init()
1981 if (devc->model == MD_1848 || devc->model == MD_C930) in ad1848_init()
1982 devc->audio_flags |= DMA_HARDSTOP; in ad1848_init()
1984 if (devc->model > MD_1848) in ad1848_init()
1986 if (devc->dma1 == devc->dma2 || devc->dma2 == -1 || devc->dma1 == -1) in ad1848_init()
1987 devc->audio_flags &= ~DMA_DUPLEX; in ad1848_init()
1989 devc->audio_flags |= DMA_DUPLEX; in ad1848_init()
1994 release_region(devc->base, 4); in ad1848_init()
2002 devc->audio_flags, in ad1848_init()
2003 ad_format_mask[devc->model], in ad1848_init()
2004 devc, in ad1848_init()
2008 release_region(devc->base, 4); in ad1848_init()
2021 ad1848_init_hw(devc); in ad1848_init()
2025 devc->dev_no = my_dev; in ad1848_init()
2026 if (request_irq(devc->irq, adintr, 0, devc->name, in ad1848_init()
2031 devc->irq = 0; in ad1848_init()
2033 if (capabilities[devc->model].flags & CAP_F_TIMER) in ad1848_init()
2037 unsigned char tmp = ad_read(devc, 16); in ad1848_init()
2040 devc->timer_ticks = 0; in ad1848_init()
2042 ad_write(devc, 21, 0x00); /* Timer MSB */ in ad1848_init()
2043 ad_write(devc, 20, 0x10); /* Timer LSB */ in ad1848_init()
2045 ad_write(devc, 16, tmp | 0x40); /* Enable timer */ in ad1848_init()
2046 for (x = 0; x < 100000 && devc->timer_ticks == 0; x++); in ad1848_init()
2047 ad_write(devc, 16, tmp & ~0x40); /* Disable timer */ in ad1848_init()
2049 if (devc->timer_ticks == 0) in ad1848_init()
2054 devc->irq_ok = 1; in ad1848_init()
2057 devc->irq_ok = 1; in ad1848_init()
2061 devc->irq_ok = 1; /* Couldn't test. assume it's OK */ in ad1848_init()
2063 irq2dev[-irq] = devc->dev_no = my_dev; in ad1848_init()
2066 if ((capabilities[devc->model].flags & CAP_F_TIMER) && in ad1848_init()
2067 devc->irq_ok) in ad1848_init()
2073 if (sound_alloc_dma(dma_playback, devc->name)) in ad1848_init()
2077 if (sound_alloc_dma(dma_capture, devc->name)) in ad1848_init()
2085 devc)) >= 0) in ad1848_init()
2096 ad1848_info *devc; in ad1848_control() local
2102 devc = &adev_info[nr_ad1848_devs - 1]; in ad1848_control()
2107 if (devc->model != MD_1845 && devc->model != MD_1845_SSCAPE) in ad1848_control()
2109 spin_lock_irqsave(&devc->lock,flags); in ad1848_control()
2110 ad_enter_MCE(devc); in ad1848_control()
2111 ad_write(devc, 29, (ad_read(devc, 29) & 0x1f) | (arg << 5)); in ad1848_control()
2112 ad_leave_MCE(devc); in ad1848_control()
2113 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_control()
2124 if (!(devc->supported_devices & (1 << o)) && in ad1848_control()
2125 !(devc->supported_rec_devices & (1 << o))) in ad1848_control()
2130 ad1848_mixer_set(devc, o, 0); /* Shut up it */ in ad1848_control()
2131 devc->supported_devices &= ~(1 << o); in ad1848_control()
2132 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2140 devc->mixer_reroute[n] = o; /* Rename the control */ in ad1848_control()
2141 if (devc->supported_devices & (1 << o)) in ad1848_control()
2142 devc->supported_devices |= (1 << n); in ad1848_control()
2143 if (devc->supported_rec_devices & (1 << o)) in ad1848_control()
2144 devc->supported_rec_devices |= (1 << n); in ad1848_control()
2146 devc->supported_devices &= ~(1 << o); in ad1848_control()
2147 devc->supported_rec_devices &= ~(1 << o); in ad1848_control()
2157 ad1848_info *devc = NULL; in ad1848_unload() local
2159 for (i = 0; devc == NULL && i < nr_ad1848_devs; i++) in ad1848_unload()
2163 devc = &adev_info[i]; in ad1848_unload()
2164 dev = devc->dev_no; in ad1848_unload()
2168 if (devc != NULL) in ad1848_unload()
2171 release_region(devc->base, 4); in ad1848_unload()
2175 if (devc->irq > 0) /* There is no point in freeing irq, if it wasn't allocated */ in ad1848_unload()
2176 free_irq(devc->irq, (void *)(long)devc->dev_no); in ad1848_unload()
2184 mixer = audio_devs[devc->dev_no]->mixer_dev; in ad1848_unload()
2199 ad1848_info *devc; in adintr() local
2206 devc = (ad1848_info *) audio_devs[dev]->devc; in adintr()
2210 status = inb(io_Status(devc)); in adintr()
2214 if (devc->model == MD_1848) in adintr()
2215 outb((0), io_Status(devc)); /* Clear interrupt status */ in adintr()
2219 if (devc->model == MD_C930) in adintr()
2222 spin_lock(&devc->lock); in adintr()
2231 spin_unlock(&devc->lock); in adintr()
2235 else if (devc->model != MD_1848) in adintr()
2237 spin_lock(&devc->lock); in adintr()
2238 alt_stat = ad_read(devc, 24); in adintr()
2239 ad_write(devc, 24, ad_read(devc, 24) & ~alt_stat); /* Selective ack */ in adintr()
2240 spin_unlock(&devc->lock); in adintr()
2243 if ((devc->open_mode & OPEN_READ) && (devc->audio_mode & PCM_ENABLE_INPUT) && (alt_stat & 0x20)) in adintr()
2245 DMAbuf_inputintr(devc->record_dev); in adintr()
2247 if ((devc->open_mode & OPEN_WRITE) && (devc->audio_mode & PCM_ENABLE_OUTPUT) && in adintr()
2250 DMAbuf_outputintr(devc->playback_dev, 1); in adintr()
2252 if (devc->model != MD_1848 && (alt_stat & 0x40)) /* Timer interrupt */ in adintr()
2254 devc->timer_ticks++; in adintr()
2256 if (timer_installed == dev && devc->timer_running) in adintr()
2267 if (inb(io_Status(devc)) & 0x01 && cnt++ < 4) in adintr()
2701 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_start() local
2705 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_start()
2718 if (devc->model == MD_1845 || devc->model == MD_1845_SSCAPE) in ad1848_tmr_start()
2720 else if (ad_read(devc, 8) & 0x01) in ad1848_tmr_start()
2733 ad_write(devc, 21, (divider >> 8) & 0xff); /* Set upper bits */ in ad1848_tmr_start()
2734 ad_write(devc, 20, divider & 0xff); /* Set lower bits */ in ad1848_tmr_start()
2735 ad_write(devc, 16, ad_read(devc, 16) | 0x40); /* Start the timer */ in ad1848_tmr_start()
2736 devc->timer_running = 1; in ad1848_tmr_start()
2737 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_start()
2756 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_disable() local
2758 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_disable()
2759 ad_write(devc, 16, ad_read(devc, 16) & ~0x40); in ad1848_tmr_disable()
2760 devc->timer_running = 0; in ad1848_tmr_disable()
2761 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_disable()
2767 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; in ad1848_tmr_restart() local
2772 spin_lock_irqsave(&devc->lock,flags); in ad1848_tmr_restart()
2773 ad_write(devc, 16, ad_read(devc, 16) | 0x40); in ad1848_tmr_restart()
2774 devc->timer_running = 1; in ad1848_tmr_restart()
2775 spin_unlock_irqrestore(&devc->lock,flags); in ad1848_tmr_restart()