Lines Matching refs:devc
217 static void ess_show_mixerregs (sb_devc *devc);
219 static int ess_read (sb_devc * devc, unsigned char reg);
220 static int ess_write (sb_devc * devc, unsigned char reg, unsigned char data);
222 (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val);
264 (sb_devc *devc, struct ess_command *cmdtab[]) in ess_exec_commands() argument
268 cmd = cmdtab [ ((devc->channels != 1) << 1) + (devc->bits != AFMT_U8) ]; in ess_exec_commands()
271 ess_write (devc, cmd->cmd, cmd->data); in ess_exec_commands()
277 (sb_devc *devc, unsigned int reg, unsigned int mask, unsigned int val) in ess_change() argument
281 value = ess_read (devc, reg); in ess_change()
283 ess_write (devc, reg, value); in ess_change()
289 sb_devc *devc = audio_devs[dev]->devc; in ess_set_output_parms() local
291 if (devc->duplex) { in ess_set_output_parms()
292 devc->trg_buf_16 = buf; in ess_set_output_parms()
293 devc->trg_bytes_16 = nr_bytes; in ess_set_output_parms()
294 devc->trg_intrflag_16 = intrflag; in ess_set_output_parms()
295 devc->irq_mode_16 = IMODE_OUTPUT; in ess_set_output_parms()
297 devc->trg_buf = buf; in ess_set_output_parms()
298 devc->trg_bytes = nr_bytes; in ess_set_output_parms()
299 devc->trg_intrflag = intrflag; in ess_set_output_parms()
300 devc->irq_mode = IMODE_OUTPUT; in ess_set_output_parms()
307 sb_devc *devc = audio_devs[dev]->devc; in ess_set_input_parms() local
309 devc->trg_buf = buf; in ess_set_input_parms()
310 devc->trg_bytes = count; in ess_set_input_parms()
311 devc->trg_intrflag = intrflag; in ess_set_input_parms()
312 devc->irq_mode = IMODE_INPUT; in ess_set_input_parms()
373 static void ess_common_speed (sb_devc *devc, int *speedp, int *divp) in ess_common_speed() argument
377 if (devc->duplex) { in ess_common_speed()
381 if (devc->submodel == SUBMDL_ES1888) { in ess_common_speed()
386 } else if(devc->caps & SB_CAP_ES18XX_RATE) { in ess_common_speed()
387 if (devc->submodel == SUBMDL_ES1888) { in ess_common_speed()
404 static void ess_speed (sb_devc *devc, int audionum) in ess_speed() argument
409 ess_common_speed (devc, &(devc->speed), &div); in ess_speed()
412 printk (KERN_INFO "FKS: ess_speed (%d) b speed = %d, div=%x\n", audionum, devc->speed, div); in ess_speed()
416 speed = (devc->speed * 9) / 20; in ess_speed()
420 if (!devc->duplex) audionum = 1; in ess_speed()
426 ess_write (devc, 0xa1, div); in ess_speed()
427 ess_write (devc, 0xa2, div2); in ess_speed()
429 ess_setmixer (devc, 0x70, div); in ess_speed()
433 ess_write (devc, 0xa2, div2); in ess_speed()
434 ess_setmixer (devc, 0x72, div2); in ess_speed()
440 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_input() local
442 ess_speed(devc, 1); in ess_audio_prepare_for_input()
444 sb_dsp_command(devc, DSP_CMD_SPKOFF); in ess_audio_prepare_for_input()
446 ess_write (devc, 0xb8, 0x0e); /* Auto init DMA mode */ in ess_audio_prepare_for_input()
447 ess_change (devc, 0xa8, 0x03, 3 - devc->channels); /* Mono/stereo */ in ess_audio_prepare_for_input()
448 ess_write (devc, 0xb9, 2); /* Demand mode (4 bytes/DMA request) */ in ess_audio_prepare_for_input()
450 ess_exec_commands (devc, ess_inp_cmds); in ess_audio_prepare_for_input()
452 ess_change (devc, 0xb1, 0xf0, 0x50); in ess_audio_prepare_for_input()
453 ess_change (devc, 0xb2, 0xf0, 0x50); in ess_audio_prepare_for_input()
455 devc->trigger_bits = 0; in ess_audio_prepare_for_input()
461 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output_audio1() local
463 sb_dsp_reset(devc); in ess_audio_prepare_for_output_audio1()
464 ess_speed(devc, 1); in ess_audio_prepare_for_output_audio1()
465 ess_write (devc, 0xb8, 4); /* Auto init DMA mode */ in ess_audio_prepare_for_output_audio1()
466 ess_change (devc, 0xa8, 0x03, 3 - devc->channels); /* Mono/stereo */ in ess_audio_prepare_for_output_audio1()
467 ess_write (devc, 0xb9, 2); /* Demand mode (4 bytes/request) */ in ess_audio_prepare_for_output_audio1()
469 ess_exec_commands (devc, ess_out_cmds); in ess_audio_prepare_for_output_audio1()
471 ess_change (devc, 0xb1, 0xf0, 0x50); /* Enable DMA */ in ess_audio_prepare_for_output_audio1()
472 ess_change (devc, 0xb2, 0xf0, 0x50); /* Enable IRQ */ in ess_audio_prepare_for_output_audio1()
474 sb_dsp_command(devc, DSP_CMD_SPKON); /* There be sound! */ in ess_audio_prepare_for_output_audio1()
476 devc->trigger_bits = 0; in ess_audio_prepare_for_output_audio1()
482 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output_audio2() local
494 ess_chgmixer (devc, 0x78, 0xd0, 0xd0); in ess_audio_prepare_for_output_audio2()
496 ess_speed(devc, 2); in ess_audio_prepare_for_output_audio2()
499 bits = ess_getmixer (devc, 0x7a) & 0x18; in ess_audio_prepare_for_output_audio2()
502 if (devc->channels != 1) bits |= 0x02; in ess_audio_prepare_for_output_audio2()
505 if (devc->bits != AFMT_U8) bits |= 0x05; /* 16 bit */ in ess_audio_prepare_for_output_audio2()
510 ess_setmixer (devc, 0x7a, bits); in ess_audio_prepare_for_output_audio2()
512 ess_mixer_reload (devc, SOUND_MIXER_PCM); /* There be sound! */ in ess_audio_prepare_for_output_audio2()
514 devc->trigger_bits = 0; in ess_audio_prepare_for_output_audio2()
520 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_prepare_for_output() local
527 if (devc->duplex) { in ess_audio_prepare_for_output()
537 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_halt_xfer() local
539 spin_lock_irqsave(&devc->lock, flags); in ess_audio_halt_xfer()
540 sb_dsp_reset(devc); in ess_audio_halt_xfer()
541 spin_unlock_irqrestore(&devc->lock, flags); in ess_audio_halt_xfer()
546 if (devc->duplex) ess_chgmixer(devc, 0x78, 0x03, 0x00); in ess_audio_halt_xfer()
553 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_start_input() local
563 devc->irq_mode = IMODE_INPUT; in ess_audio_start_input()
565 ess_write (devc, 0xa4, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_start_input()
566 ess_write (devc, 0xa5, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_start_input()
568 ess_change (devc, 0xb8, 0x0f, 0x0f); /* Go */ in ess_audio_start_input()
569 devc->intr_active = 1; in ess_audio_start_input()
576 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block_audio1() local
583 devc->irq_mode = IMODE_OUTPUT; in ess_audio_output_block_audio1()
585 ess_write (devc, 0xa4, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_output_block_audio1()
586 ess_write (devc, 0xa5, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_output_block_audio1()
588 ess_change (devc, 0xb8, 0x05, 0x05); /* Go */ in ess_audio_output_block_audio1()
589 devc->intr_active = 1; in ess_audio_output_block_audio1()
596 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block_audio2() local
602 ess_setmixer (devc, 0x74, (unsigned char) ((unsigned short) c & 0xff)); in ess_audio_output_block_audio2()
603 ess_setmixer (devc, 0x76, (unsigned char) (((unsigned short) c >> 8) & 0xff)); in ess_audio_output_block_audio2()
604 ess_chgmixer (devc, 0x78, 0x03, 0x03); /* Go */ in ess_audio_output_block_audio2()
606 devc->irq_mode_16 = IMODE_OUTPUT; in ess_audio_output_block_audio2()
607 devc->intr_active_16 = 1; in ess_audio_output_block_audio2()
613 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_output_block() local
615 if (devc->duplex) { in ess_audio_output_block()
628 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_trigger() local
630 int bits_16 = bits & devc->irq_mode_16; in ess_audio_trigger()
631 bits &= devc->irq_mode; in ess_audio_trigger()
635 sb_dsp_command(devc, 0xd0); /* Halt DMA */ in ess_audio_trigger()
639 switch (devc->irq_mode) in ess_audio_trigger()
642 ess_audio_start_input(dev, devc->trg_buf, devc->trg_bytes, in ess_audio_trigger()
643 devc->trg_intrflag); in ess_audio_trigger()
647 ess_audio_output_block(dev, devc->trg_buf, devc->trg_bytes, in ess_audio_trigger()
648 devc->trg_intrflag); in ess_audio_trigger()
654 switch (devc->irq_mode_16) { in ess_audio_trigger()
656 ess_audio_start_input(dev, devc->trg_buf_16, devc->trg_bytes_16, in ess_audio_trigger()
657 devc->trg_intrflag_16); in ess_audio_trigger()
661 ess_audio_output_block(dev, devc->trg_buf_16, devc->trg_bytes_16, in ess_audio_trigger()
662 devc->trg_intrflag_16); in ess_audio_trigger()
667 devc->trigger_bits = bits | bits_16; in ess_audio_trigger()
672 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_speed() local
676 minspeed = (devc->duplex ? 6215 : 5000 ); in ess_audio_set_speed()
677 maxspeed = (devc->duplex ? 44100 : 48000); in ess_audio_set_speed()
681 ess_common_speed (devc, &speed, &dummydiv); in ess_audio_set_speed()
683 devc->speed = speed; in ess_audio_set_speed()
685 return devc->speed; in ess_audio_set_speed()
693 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_bits() local
697 devc->bits = bits; in ess_audio_set_bits()
699 devc->bits = AFMT_U8; in ess_audio_set_bits()
703 return devc->bits; in ess_audio_set_bits()
712 sb_devc *devc = audio_devs[dev]->devc; in ess_audio_set_channels() local
714 if (channels == 1 || channels == 2) devc->channels = channels; in ess_audio_set_channels()
716 return devc->channels; in ess_audio_set_channels()
739 (sb_devc *devc, int *audio_flags, int *format_mask) in ess_audio_init() argument
744 if (devc->duplex) { in ess_audio_init()
750 tmp_dma = devc->dma16; in ess_audio_init()
751 devc->dma16 = devc->dma8; in ess_audio_init()
752 devc->dma8 = tmp_dma; in ess_audio_init()
795 void ess_intr (sb_devc *devc) in ess_intr() argument
800 if (devc->submodel == SUBMDL_ES1887) { in ess_intr()
801 src = ess_getmixer (devc, 0x7f) >> 4; in ess_intr()
811 , devc->dev, devc->intr_active , src & 0x01, devc->irq_mode ); in ess_intr()
814 , devc->dev, devc->intr_active_16, src & 0x02, devc->irq_mode_16); in ess_intr()
818 if (devc->submodel == SUBMDL_ES1887 && (src & 0x02)) { in ess_intr()
819 ess_chgmixer (devc, 0x7a, 0x80, 0x00); in ess_intr()
827 static void ess_extended (sb_devc * devc) in ess_extended() argument
831 sb_dsp_command(devc, 0xc6); in ess_extended()
834 static int ess_write (sb_devc * devc, unsigned char reg, unsigned char data) in ess_write() argument
841 if (!sb_dsp_command(devc, reg)) in ess_write()
844 return sb_dsp_command(devc, data); in ess_write()
847 static int ess_read (sb_devc * devc, unsigned char reg) in ess_read() argument
852 if (!sb_dsp_command(devc, 0xc0)) return -1; in ess_read()
854 if (!sb_dsp_command(devc, reg )) return -1; in ess_read()
856 return sb_dsp_get_byte(devc); in ess_read()
859 int ess_dsp_reset(sb_devc * devc) in ess_dsp_reset() argument
865 ess_show_mixerregs (devc); in ess_dsp_reset()
880 ess_extended (devc); in ess_dsp_reset()
884 ess_show_mixerregs (devc); in ess_dsp_reset()
915 static int ess_common_set_irq_hw (sb_devc * devc) in ess_common_set_irq_hw() argument
919 if ((irq_bits = ess_irq_bits (devc->irq)) == -1) return 0; in ess_common_set_irq_hw()
921 if (!ess_write (devc, 0xb1, 0x50 | (irq_bits << 2))) { in ess_common_set_irq_hw()
935 static void ess_es1887_set_irq_hw (sb_devc * devc) in ess_es1887_set_irq_hw() argument
939 if ((irq_bits = ess_irq_bits (devc->irq)) == -1) return; in ess_es1887_set_irq_hw()
941 ess_chgmixer (devc, 0x7f, 0x0f, 0x01 | ((irq_bits + 1) << 1)); in ess_es1887_set_irq_hw()
944 static int ess_set_irq_hw (sb_devc * devc) in ess_set_irq_hw() argument
946 if (devc->submodel == SUBMDL_ES1887) ess_es1887_set_irq_hw (devc); in ess_set_irq_hw()
948 return ess_common_set_irq_hw (devc); in ess_set_irq_hw()
962 static void FKS_test (sb_devc * devc) in FKS_test() argument
965 val1 = ess_getmixer (devc, 0x64); in FKS_test()
966 ess_setmixer (devc, 0x64, ~val1); in FKS_test()
967 val2 = ess_getmixer (devc, 0x64) ^ ~val1; in FKS_test()
968 ess_setmixer (devc, 0x64, val1); in FKS_test()
969 val1 ^= ess_getmixer (devc, 0x64); in FKS_test()
974 static unsigned int ess_identify (sb_devc * devc) in ess_identify() argument
979 spin_lock_irqsave(&devc->lock, flags); in ess_identify()
987 spin_unlock_irqrestore(&devc->lock, flags); in ess_identify()
1000 static int ess_probe (sb_devc * devc, int reg, int xorval) in ess_probe() argument
1004 val1 = ess_getmixer (devc, reg); in ess_probe()
1006 ess_setmixer (devc, reg, val2); in ess_probe()
1007 val3 = ess_getmixer (devc, reg); in ess_probe()
1008 ess_setmixer (devc, reg, val1); in ess_probe()
1013 int ess_init(sb_devc * devc, struct address_info *hw_config) argument
1024 sb_dsp_command(devc, 0xe7); /* Return identification */
1043 devc->model = MDL_SBPRO;
1062 devc->model = MDL_ESS;
1063 devc->submodel = ess_minor & 0x0f;
1069 switch (devc->sbmo.esstype) {
1101 printk (KERN_ERR "Invalid esstype=%d specified\n", devc->sbmo.esstype);
1105 devc->submodel = submodel;
1106 sprintf (modelname, "ES%d", devc->sbmo.esstype);
1113 FKS_test (devc);
1119 if (chip == NULL && devc->sbmo.esstype == ESSTYPE_LIKE20) {
1126 type = ess_identify (devc);
1131 devc->submodel = SUBMDL_ES1868;
1135 devc->submodel = SUBMDL_ES1869;
1139 devc->submodel = SUBMDL_ES1878;
1143 devc->submodel = SUBMDL_ES1879;
1160 if (chip == NULL && !ess_probe(devc, 0x64, (1 << 4))) {
1168 if (chip == NULL && ess_probe(devc, 0x64, (1 << 2))) {
1169 if (ess_probe (devc, 0x70, 0x7f)) {
1170 if (ess_probe (devc, 0x64, (1 << 5))) {
1172 devc->submodel = SUBMDL_ES1887;
1175 devc->submodel = SUBMDL_ES1888;
1179 devc->submodel = SUBMDL_ES1788;
1187 (devc->sbmo.esstype == ESSTYPE_DETECT ||
1188 devc->sbmo.esstype == ESSTYPE_LIKE20) ?
1190 devc->sbmo.esstype == ESSTYPE_LIKE20 ?
1199 switch(devc->submodel) {
1205 devc->caps |= SB_CAP_ES18XX_RATE;
1211 sb_dsp_reset(devc); /* Turn on extended mode */
1216 cfg = ess_getmixer (devc, 0x40);
1217 ess_setmixer (devc, 0x40, cfg | 0x03);
1218 if (devc->submodel >= 8) { /* ES1688 */
1219 devc->caps |= SB_NO_MIDI; /* ES1688 uses MPU401 MIDI mode */
1221 sb_dsp_reset (devc);
1227 return ess_set_irq_hw (devc);
1230 static int ess_set_dma_hw(sb_devc * devc) argument
1237 , devc->dma8, devc->dma16, devc->duplex);
1243 dma = devc->dma8;
1260 if (!ess_write (devc, 0xb2, cfg | (dma_bits << 2))) {
1265 if (devc->duplex) {
1266 dma = devc->dma16;
1288 ess_chgmixer (devc, 0x78, 0x20, dma16_bits);
1289 ess_chgmixer (devc, 0x7d, 0x07, dma_bits);
1302 int ess_dsp_init (sb_devc *devc, struct address_info *hw_config) argument
1307 if (devc->model != MDL_ESS) {
1320 if (devc->submodel == SUBMDL_ES1887) {
1322 devc->dma16 = hw_config->dma2;
1328 if (devc->dma8 != devc->dma16 && devc->dma16 != -1) {
1329 devc->duplex = 1;
1332 if (!ess_set_dma_hw (devc)) {
1333 free_irq(devc->irq, devc);
1548 static void ess_show_mixerregs (sb_devc *devc) argument
1555 printk (KERN_INFO "res (%x)=%x\n", *mp, (int)(ess_getmixer (devc, *mp)));
1561 void ess_setmixer (sb_devc * devc, unsigned int port, unsigned int value) argument
1569 spin_lock_irqsave(&devc->lock, flags);
1571 ess_write (devc, port, value);
1579 spin_unlock_irqrestore(&devc->lock, flags);
1582 unsigned int ess_getmixer (sb_devc * devc, unsigned int port) argument
1587 spin_lock_irqsave(&devc->lock, flags);
1590 val = ess_read (devc, port);
1598 spin_unlock_irqrestore(&devc->lock, flags);
1604 (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val) argument
1608 value = ess_getmixer (devc, reg);
1610 ess_setmixer (devc, reg, value);
1616 void ess_mixer_init (sb_devc * devc) argument
1618 devc->mixer_caps = SOUND_CAP_EXCL_INPUT;
1623 switch (devc->submodel) {
1625 devc->supported_devices = ES1887_MIXER_DEVICES;
1626 devc->supported_rec_devices = ES1887_RECORDING_DEVICES;
1628 printk (KERN_INFO "FKS: ess_mixer_init dup = %d\n", devc->duplex);
1630 if (devc->duplex) {
1631 devc->iomap = &es1887_mix;
1632 devc->iomap_sz = ARRAY_SIZE(es1887_mix);
1634 devc->iomap = &es_rec_mix;
1635 devc->iomap_sz = ARRAY_SIZE(es_rec_mix);
1639 if (devc->submodel < 8) {
1640 devc->supported_devices = ES688_MIXER_DEVICES;
1641 devc->supported_rec_devices = ES688_RECORDING_DEVICES;
1642 devc->iomap = &es688_mix;
1643 devc->iomap_sz = ARRAY_SIZE(es688_mix);
1649 devc->supported_devices = ES1688_MIXER_DEVICES;
1650 devc->supported_rec_devices = ES1688_RECORDING_DEVICES;
1651 if (devc->submodel < 0x10) {
1652 devc->iomap = &es1688_mix;
1653 devc->iomap_sz = ARRAY_SIZE(es688_mix);
1655 devc->iomap = &es1688later_mix;
1656 devc->iomap_sz = ARRAY_SIZE(es1688later_mix);
1666 int ess_mixer_set(sb_devc *devc, int dev, int left, int right) argument
1668 if (ess_has_rec_mixer (devc->submodel) && (devc->recmask & (1 << dev))) {
1669 sb_common_mixer_set (devc, dev + ES_REC_MIXER_RECDIFF, left, right);
1671 return sb_common_mixer_set (devc, dev, left, right);
1679 void ess_mixer_reload (sb_devc *devc, int dev) argument
1683 value = devc->levels[dev];
1687 sb_common_mixer_set(devc, dev, left, right);
1690 static int es_rec_set_recmask(sb_devc * devc, int mask) argument
1704 cur_mask = devc->recmask;
1711 value = devc->levels[i];
1718 sb_common_mixer_set(devc, i + ES_REC_MIXER_RECDIFF, left, right);
1724 int ess_set_recmask(sb_devc * devc, int *mask) argument
1728 if (ess_has_rec_mixer (devc->submodel)) {
1729 *mask = es_rec_set_recmask (devc, *mask);
1739 int ess_mixer_reset (sb_devc * devc) argument
1744 if (ess_has_rec_mixer (devc->submodel)) {
1745 switch (devc->submodel) {
1752 ess_chgmixer(devc, 0x7a, 0x18, 0x08);
1753 ess_chgmixer(devc, 0x1c, 0x07, 0x07);
1759 devc->recmask = devc->supported_rec_devices;
1760 es_rec_set_recmask(devc, 0);
1761 devc->recmask = 0;
1778 int ess_midi_init(sb_devc * devc, struct address_info *hw_config) argument
1782 cfg = ess_getmixer (devc, 0x40) & 0x03;
1784 if (devc->submodel < 8) {
1785 ess_setmixer (devc, 0x40, cfg | 0x03); /* Enable OPL3 & joystick */
1791 ess_setmixer (devc, 0x40, cfg);
1818 ess_setmixer (devc, 0x40, cfg | 0x03);