Lines Matching refs:devc
218 static void ess_show_mixerregs (sb_devc *devc);
220 static int ess_read (sb_devc * devc, unsigned char reg);
221 static int ess_write (sb_devc * devc, unsigned char reg, unsigned char data);
223 (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val);
265 (sb_devc *devc, struct ess_command *cmdtab[]) in ess_exec_commands() argument
269 cmd = cmdtab [ ((devc->channels != 1) << 1) + (devc->bits != AFMT_U8) ]; in ess_exec_commands()
272 ess_write (devc, cmd->cmd, cmd->data); in ess_exec_commands()
278 (sb_devc *devc, unsigned int reg, unsigned int mask, unsigned int val) in ess_change() argument
282 value = ess_read (devc, reg); in ess_change()
284 ess_write (devc, reg, value); in ess_change()
290 sb_devc *devc = audio_devs[dev]->devc; in ess_set_output_parms() local
292 if (devc->duplex) { in ess_set_output_parms()
293 devc->trg_buf_16 = buf; in ess_set_output_parms()
294 devc->trg_bytes_16 = nr_bytes; in ess_set_output_parms()
295 devc->trg_intrflag_16 = intrflag; in ess_set_output_parms()
296 devc->irq_mode_16 = IMODE_OUTPUT; in ess_set_output_parms()
298 devc->trg_buf = buf; in ess_set_output_parms()
299 devc->trg_bytes = nr_bytes; in ess_set_output_parms()
300 devc->trg_intrflag = intrflag; in ess_set_output_parms()
301 devc->irq_mode = IMODE_OUTPUT; in ess_set_output_parms()
308 sb_devc *devc = audio_devs[dev]->devc; in ess_set_input_parms() local
310 devc->trg_buf = buf; in ess_set_input_parms()
311 devc->trg_bytes = count; in ess_set_input_parms()
312 devc->trg_intrflag = intrflag; in ess_set_input_parms()
313 devc->irq_mode = IMODE_INPUT; in ess_set_input_parms()
374 static void ess_common_speed (sb_devc *devc, int *speedp, int *divp) in ess_common_speed() argument
378 if (devc->duplex) { in ess_common_speed()
382 if (devc->submodel == SUBMDL_ES1888) { in ess_common_speed()
387 } else if(devc->caps & SB_CAP_ES18XX_RATE) { in ess_common_speed()
388 if (devc->submodel == SUBMDL_ES1888) { in ess_common_speed()
405 static void ess_speed (sb_devc *devc, int audionum) in ess_speed() argument
410 ess_common_speed (devc, &(devc->speed), &div); in ess_speed()
413 printk (KERN_INFO "FKS: ess_speed (%d) b speed = %d, div=%x\n", audionum, devc->speed, div); in ess_speed()
417 speed = (devc->speed * 9) / 20; in ess_speed()
421 if (!devc->duplex) audionum = 1; in ess_speed()
427 ess_write (devc, 0xa1, div); in ess_speed()
428 ess_write (devc, 0xa2, div2); in ess_speed()
430 ess_setmixer (devc, 0x70, div); in ess_speed()
434 ess_write (devc, 0xa2, div2); in ess_speed()
435 ess_setmixer (devc, 0x72, div2); in ess_speed()
441 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_input() local
443 ess_speed(devc, 1); in ess_audio_prepare_for_input()
445 sb_dsp_command(devc, DSP_CMD_SPKOFF); in ess_audio_prepare_for_input()
447 ess_write (devc, 0xb8, 0x0e); /* Auto init DMA mode */ in ess_audio_prepare_for_input()
448 ess_change (devc, 0xa8, 0x03, 3 - devc->channels); /* Mono/stereo */ in ess_audio_prepare_for_input()
449 ess_write (devc, 0xb9, 2); /* Demand mode (4 bytes/DMA request) */ in ess_audio_prepare_for_input()
451 ess_exec_commands (devc, ess_inp_cmds); in ess_audio_prepare_for_input()
453 ess_change (devc, 0xb1, 0xf0, 0x50); in ess_audio_prepare_for_input()
454 ess_change (devc, 0xb2, 0xf0, 0x50); in ess_audio_prepare_for_input()
456 devc->trigger_bits = 0; in ess_audio_prepare_for_input()
462 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output_audio1() local
464 sb_dsp_reset(devc); in ess_audio_prepare_for_output_audio1()
465 ess_speed(devc, 1); in ess_audio_prepare_for_output_audio1()
466 ess_write (devc, 0xb8, 4); /* Auto init DMA mode */ in ess_audio_prepare_for_output_audio1()
467 ess_change (devc, 0xa8, 0x03, 3 - devc->channels); /* Mono/stereo */ in ess_audio_prepare_for_output_audio1()
468 ess_write (devc, 0xb9, 2); /* Demand mode (4 bytes/request) */ in ess_audio_prepare_for_output_audio1()
470 ess_exec_commands (devc, ess_out_cmds); in ess_audio_prepare_for_output_audio1()
472 ess_change (devc, 0xb1, 0xf0, 0x50); /* Enable DMA */ in ess_audio_prepare_for_output_audio1()
473 ess_change (devc, 0xb2, 0xf0, 0x50); /* Enable IRQ */ in ess_audio_prepare_for_output_audio1()
475 sb_dsp_command(devc, DSP_CMD_SPKON); /* There be sound! */ in ess_audio_prepare_for_output_audio1()
477 devc->trigger_bits = 0; in ess_audio_prepare_for_output_audio1()
483 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output_audio2() local
495 ess_chgmixer (devc, 0x78, 0xd0, 0xd0); in ess_audio_prepare_for_output_audio2()
497 ess_speed(devc, 2); in ess_audio_prepare_for_output_audio2()
500 bits = ess_getmixer (devc, 0x7a) & 0x18; in ess_audio_prepare_for_output_audio2()
503 if (devc->channels != 1) bits |= 0x02; in ess_audio_prepare_for_output_audio2()
506 if (devc->bits != AFMT_U8) bits |= 0x05; /* 16 bit */ in ess_audio_prepare_for_output_audio2()
511 ess_setmixer (devc, 0x7a, bits); in ess_audio_prepare_for_output_audio2()
513 ess_mixer_reload (devc, SOUND_MIXER_PCM); /* There be sound! */ in ess_audio_prepare_for_output_audio2()
515 devc->trigger_bits = 0; in ess_audio_prepare_for_output_audio2()
521 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output() local
528 if (devc->duplex) { in ess_audio_prepare_for_output()
538 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_halt_xfer() local
540 spin_lock_irqsave(&devc->lock, flags); in ess_audio_halt_xfer()
541 sb_dsp_reset(devc); in ess_audio_halt_xfer()
542 spin_unlock_irqrestore(&devc->lock, flags); in ess_audio_halt_xfer()
547 if (devc->duplex) ess_chgmixer(devc, 0x78, 0x03, 0x00); in ess_audio_halt_xfer()
554 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_start_input() local
564 devc->irq_mode = IMODE_INPUT; in ess_audio_start_input()
566 ess_write (devc, 0xa4, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_start_input()
567 ess_write (devc, 0xa5, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_start_input()
569 ess_change (devc, 0xb8, 0x0f, 0x0f); /* Go */ in ess_audio_start_input()
570 devc->intr_active = 1; in ess_audio_start_input()
577 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block_audio1() local
584 devc->irq_mode = IMODE_OUTPUT; in ess_audio_output_block_audio1()
586 ess_write (devc, 0xa4, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_output_block_audio1()
587 ess_write (devc, 0xa5, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_output_block_audio1()
589 ess_change (devc, 0xb8, 0x05, 0x05); /* Go */ in ess_audio_output_block_audio1()
590 devc->intr_active = 1; in ess_audio_output_block_audio1()
597 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block_audio2() local
603 ess_setmixer (devc, 0x74, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_output_block_audio2()
604 ess_setmixer (devc, 0x76, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_output_block_audio2()
605 ess_chgmixer (devc, 0x78, 0x03, 0x03); /* Go */ in ess_audio_output_block_audio2()
607 devc->irq_mode_16 = IMODE_OUTPUT; in ess_audio_output_block_audio2()
608 devc->intr_active_16 = 1; in ess_audio_output_block_audio2()
614 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block() local
616 if (devc->duplex) { in ess_audio_output_block()
629 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_trigger() local
631 int bits_16 = bits & devc->irq_mode_16; in ess_audio_trigger()
632 bits &= devc->irq_mode; in ess_audio_trigger()
636 sb_dsp_command(devc, 0xd0); /* Halt DMA */ in ess_audio_trigger()
640 switch (devc->irq_mode) in ess_audio_trigger()
643 ess_audio_start_input(dev, devc->trg_buf, devc->trg_bytes, in ess_audio_trigger()
644 devc->trg_intrflag); in ess_audio_trigger()
648 ess_audio_output_block(dev, devc->trg_buf, devc->trg_bytes, in ess_audio_trigger()
649 devc->trg_intrflag); in ess_audio_trigger()
655 switch (devc->irq_mode_16) { in ess_audio_trigger()
657 ess_audio_start_input(dev, devc->trg_buf_16, devc->trg_bytes_16, in ess_audio_trigger()
658 devc->trg_intrflag_16); in ess_audio_trigger()
662 ess_audio_output_block(dev, devc->trg_buf_16, devc->trg_bytes_16, in ess_audio_trigger()
663 devc->trg_intrflag_16); in ess_audio_trigger()
668 devc->trigger_bits = bits | bits_16; in ess_audio_trigger()
673 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_speed() local
677 minspeed = (devc->duplex ? 6215 : 5000 ); in ess_audio_set_speed()
678 maxspeed = (devc->duplex ? 44100 : 48000); in ess_audio_set_speed()
682 ess_common_speed (devc, &speed, &dummydiv); in ess_audio_set_speed()
684 devc->speed = speed; in ess_audio_set_speed()
686 return devc->speed; in ess_audio_set_speed()
694 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_bits() local
698 devc->bits = bits; in ess_audio_set_bits()
700 devc->bits = AFMT_U8; in ess_audio_set_bits()
704 return devc->bits; in ess_audio_set_bits()
713 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_channels() local
715 if (channels == 1 || channels == 2) devc->channels = channels; in ess_audio_set_channels()
717 return devc->channels; in ess_audio_set_channels()
740 (sb_devc *devc, int *audio_flags, int *format_mask) in ess_audio_init() argument
745 if (devc->duplex) { in ess_audio_init()
751 tmp_dma = devc->dma16; in ess_audio_init()
752 devc->dma16 = devc->dma8; in ess_audio_init()
753 devc->dma8 = tmp_dma; in ess_audio_init()
796 void ess_intr (sb_devc *devc) in ess_intr() argument
801 if (devc->submodel == SUBMDL_ES1887) { in ess_intr()
802 src = ess_getmixer (devc, 0x7f) >> 4; in ess_intr()
812 , devc->dev, devc->intr_active , src & 0x01, devc->irq_mode ); in ess_intr()
815 , devc->dev, devc->intr_active_16, src & 0x02, devc->irq_mode_16); in ess_intr()
819 if (devc->submodel == SUBMDL_ES1887 && (src & 0x02)) { in ess_intr()
820 ess_chgmixer (devc, 0x7a, 0x80, 0x00); in ess_intr()
828 static void ess_extended (sb_devc * devc) in ess_extended() argument
832 sb_dsp_command(devc, 0xc6); in ess_extended()
835 static int ess_write (sb_devc * devc, unsigned char reg, unsigned char data) in ess_write() argument
842 if (!sb_dsp_command(devc, reg)) in ess_write()
845 return sb_dsp_command(devc, data); in ess_write()
848 static int ess_read (sb_devc * devc, unsigned char reg) in ess_read() argument
853 if (!sb_dsp_command(devc, 0xc0)) return -1; in ess_read()
855 if (!sb_dsp_command(devc, reg )) return -1; in ess_read()
857 return sb_dsp_get_byte(devc); in ess_read()
860 int ess_dsp_reset(sb_devc * devc) in ess_dsp_reset() argument
866 ess_show_mixerregs (devc); in ess_dsp_reset()
881 ess_extended (devc); in ess_dsp_reset()
885 ess_show_mixerregs (devc); in ess_dsp_reset()
916 static int ess_common_set_irq_hw (sb_devc * devc) in ess_common_set_irq_hw() argument
920 if ((irq_bits = ess_irq_bits (devc->irq)) == -1) return 0; in ess_common_set_irq_hw()
922 if (!ess_write (devc, 0xb1, 0x50 | (irq_bits << 2))) { in ess_common_set_irq_hw()
936 static void ess_es1887_set_irq_hw (sb_devc * devc) in ess_es1887_set_irq_hw() argument
940 if ((irq_bits = ess_irq_bits (devc->irq)) == -1) return; in ess_es1887_set_irq_hw()
942 ess_chgmixer (devc, 0x7f, 0x0f, 0x01 | ((irq_bits + 1) << 1)); in ess_es1887_set_irq_hw()
945 static int ess_set_irq_hw (sb_devc * devc) in ess_set_irq_hw() argument
947 if (devc->submodel == SUBMDL_ES1887) ess_es1887_set_irq_hw (devc); in ess_set_irq_hw()
949 return ess_common_set_irq_hw (devc); in ess_set_irq_hw()
963 static void FKS_test (sb_devc * devc) in FKS_test() argument
966 val1 = ess_getmixer (devc, 0x64); in FKS_test()
967 ess_setmixer (devc, 0x64, ~val1); in FKS_test()
968 val2 = ess_getmixer (devc, 0x64) ^ ~val1; in FKS_test()
969 ess_setmixer (devc, 0x64, val1); in FKS_test()
970 val1 ^= ess_getmixer (devc, 0x64); in FKS_test()
975 static unsigned int ess_identify (sb_devc * devc) in ess_identify() argument
980 spin_lock_irqsave(&devc->lock, flags); in ess_identify()
988 spin_unlock_irqrestore(&devc->lock, flags); in ess_identify()
1001 static int ess_probe (sb_devc * devc, int reg, int xorval) in ess_probe() argument
1005 val1 = ess_getmixer (devc, reg); in ess_probe()
1007 ess_setmixer (devc, reg, val2); in ess_probe()
1008 val3 = ess_getmixer (devc, reg); in ess_probe()
1009 ess_setmixer (devc, reg, val1); in ess_probe()
1014 int ess_init(sb_devc * devc, struct address_info *hw_config) argument
1025 sb_dsp_command(devc, 0xe7); /* Return identification */
1044 devc->model = MDL_SBPRO;
1063 devc->model = MDL_ESS;
1064 devc->submodel = ess_minor & 0x0f;
1070 switch (devc->sbmo.esstype) {
1102 printk (KERN_ERR "Invalid esstype=%d specified\n", devc->sbmo.esstype);
1106 devc->submodel = submodel;
1107 sprintf (modelname, "ES%d", devc->sbmo.esstype);
1114 FKS_test (devc);
1120 if (chip == NULL && devc->sbmo.esstype == ESSTYPE_LIKE20) {
1127 type = ess_identify (devc);
1132 devc->submodel = SUBMDL_ES1868;
1136 devc->submodel = SUBMDL_ES1869;
1140 devc->submodel = SUBMDL_ES1878;
1144 devc->submodel = SUBMDL_ES1879;
1161 if (chip == NULL && !ess_probe(devc, 0x64, (1 << 4))) {
1169 if (chip == NULL && ess_probe(devc, 0x64, (1 << 2))) {
1170 if (ess_probe (devc, 0x70, 0x7f)) {
1171 if (ess_probe (devc, 0x64, (1 << 5))) {
1173 devc->submodel = SUBMDL_ES1887;
1176 devc->submodel = SUBMDL_ES1888;
1180 devc->submodel = SUBMDL_ES1788;
1188 (devc->sbmo.esstype == ESSTYPE_DETECT ||
1189 devc->sbmo.esstype == ESSTYPE_LIKE20) ?
1191 devc->sbmo.esstype == ESSTYPE_LIKE20 ?
1200 switch(devc->submodel) {
1206 devc->caps |= SB_CAP_ES18XX_RATE;
1212 sb_dsp_reset(devc); /* Turn on extended mode */
1217 cfg = ess_getmixer (devc, 0x40);
1218 ess_setmixer (devc, 0x40, cfg | 0x03);
1219 if (devc->submodel >= 8) { /* ES1688 */
1220 devc->caps |= SB_NO_MIDI; /* ES1688 uses MPU401 MIDI mode */
1222 sb_dsp_reset (devc);
1228 return ess_set_irq_hw (devc);
1231 static int ess_set_dma_hw(sb_devc * devc) argument
1238 , devc->dma8, devc->dma16, devc->duplex);
1244 dma = devc->dma8;
1261 if (!ess_write (devc, 0xb2, cfg | (dma_bits << 2))) {
1266 if (devc->duplex) {
1267 dma = devc->dma16;
1289 ess_chgmixer (devc, 0x78, 0x20, dma16_bits);
1290 ess_chgmixer (devc, 0x7d, 0x07, dma_bits);
1303 int ess_dsp_init (sb_devc *devc, struct address_info *hw_config) argument
1308 if (devc->model != MDL_ESS) {
1321 if (devc->submodel == SUBMDL_ES1887) {
1323 devc->dma16 = hw_config->dma2;
1329 if (devc->dma8 != devc->dma16 && devc->dma16 != -1) {
1330 devc->duplex = 1;
1333 if (!ess_set_dma_hw (devc)) {
1334 free_irq(devc->irq, devc);
1549 static void ess_show_mixerregs (sb_devc *devc) argument
1556 printk (KERN_INFO "res (%x)=%x\n", *mp, (int)(ess_getmixer (devc, *mp)));
1562 void ess_setmixer (sb_devc * devc, unsigned int port, unsigned int value) argument
1570 spin_lock_irqsave(&devc->lock, flags);
1572 ess_write (devc, port, value);
1580 spin_unlock_irqrestore(&devc->lock, flags);
1583 unsigned int ess_getmixer (sb_devc * devc, unsigned int port) argument
1588 spin_lock_irqsave(&devc->lock, flags);
1591 val = ess_read (devc, port);
1599 spin_unlock_irqrestore(&devc->lock, flags);
1605 (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val) argument
1609 value = ess_getmixer (devc, reg);
1611 ess_setmixer (devc, reg, value);
1617 void ess_mixer_init (sb_devc * devc) argument
1619 devc->mixer_caps = SOUND_CAP_EXCL_INPUT;
1624 switch (devc->submodel) {
1626 devc->supported_devices = ES1887_MIXER_DEVICES;
1627 devc->supported_rec_devices = ES1887_RECORDING_DEVICES;
1629 printk (KERN_INFO "FKS: ess_mixer_init dup = %d\n", devc->duplex);
1631 if (devc->duplex) {
1632 devc->iomap = &es1887_mix;
1633 devc->iomap_sz = ARRAY_SIZE(es1887_mix);
1635 devc->iomap = &es_rec_mix;
1636 devc->iomap_sz = ARRAY_SIZE(es_rec_mix);
1640 if (devc->submodel < 8) {
1641 devc->supported_devices = ES688_MIXER_DEVICES;
1642 devc->supported_rec_devices = ES688_RECORDING_DEVICES;
1643 devc->iomap = &es688_mix;
1644 devc->iomap_sz = ARRAY_SIZE(es688_mix);
1650 devc->supported_devices = ES1688_MIXER_DEVICES;
1651 devc->supported_rec_devices = ES1688_RECORDING_DEVICES;
1652 if (devc->submodel < 0x10) {
1653 devc->iomap = &es1688_mix;
1654 devc->iomap_sz = ARRAY_SIZE(es688_mix);
1656 devc->iomap = &es1688later_mix;
1657 devc->iomap_sz = ARRAY_SIZE(es1688later_mix);
1667 int ess_mixer_set(sb_devc *devc, int dev, int left, int right) argument
1669 if (ess_has_rec_mixer (devc->submodel) && (devc->recmask & (1 << dev))) {
1670 sb_common_mixer_set (devc, dev + ES_REC_MIXER_RECDIFF, left, right);
1672 return sb_common_mixer_set (devc, dev, left, right);
1680 void ess_mixer_reload (sb_devc *devc, int dev) argument
1684 value = devc->levels[dev];
1688 sb_common_mixer_set(devc, dev, left, right);
1691 static int es_rec_set_recmask(sb_devc * devc, int mask) argument
1705 cur_mask = devc->recmask;
1712 value = devc->levels[i];
1719 sb_common_mixer_set(devc, i + ES_REC_MIXER_RECDIFF, left, right);
1725 int ess_set_recmask(sb_devc * devc, int *mask) argument
1729 if (ess_has_rec_mixer (devc->submodel)) {
1730 *mask = es_rec_set_recmask (devc, *mask);
1740 int ess_mixer_reset (sb_devc * devc) argument
1745 if (ess_has_rec_mixer (devc->submodel)) {
1746 switch (devc->submodel) {
1753 ess_chgmixer(devc, 0x7a, 0x18, 0x08);
1754 ess_chgmixer(devc, 0x1c, 0x07, 0x07);
1760 devc->recmask = devc->supported_rec_devices;
1761 es_rec_set_recmask(devc, 0);
1762 devc->recmask = 0;
1779 int ess_midi_init(sb_devc * devc, struct address_info *hw_config) argument
1783 cfg = ess_getmixer (devc, 0x40) & 0x03;
1785 if (devc->submodel < 8) {
1786 ess_setmixer (devc, 0x40, cfg | 0x03); /* Enable OPL3 & joystick */
1792 ess_setmixer (devc, 0x40, cfg);
1819 ess_setmixer (devc, 0x40, cfg | 0x03);