Lines Matching refs:X

452 X *
453 X * setdigital.c - sets the DIGITAL1 input for a mixer
454 X *
455 X * Copyright (C) 1998 Andrew Veliath
456 X *
457 X * This program is free software; you can redistribute it and/or modify
458 X * it under the terms of the GNU General Public License as published by
459 X * the Free Software Foundation; either version 2 of the License, or
460 X * (at your option) any later version.
461 X *
462 X * This program is distributed in the hope that it will be useful,
463 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
464 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
465 X * GNU General Public License for more details.
466 X *
467 X * You should have received a copy of the GNU General Public License
468 X * along with this program; if not, write to the Free Software
469 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
470 X *
471 X ********************************************************************/
472 X
481 X
484 X int fd;
485 X unsigned long recmask, recsrc;
486 X
487 X if (argc != 2) {
488 X fprintf(stderr, "usage: setdigital <mixer device>\n");
489 X exit(1);
490 X }
491 X
492 X if ((fd = open(argv[1], O_RDWR)) < 0) {
493 X perror(argv[1]);
494 X exit(1);
495 X }
496 X
497 X if (ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask) < 0) {
498 X fprintf(stderr, "error: ioctl read recording mask failed\n");
499 X perror("ioctl");
500 X close(fd);
501 X exit(1);
502 X }
503 X
504 X if (!(recmask & SOUND_MASK_DIGITAL1)) {
505 X fprintf(stderr, "error: cannot find DIGITAL1 device in mixer\n");
506 X close(fd);
507 X exit(1);
508 X }
509 X
510 X if (ioctl(fd, SOUND_MIXER_READ_RECSRC, &recsrc) < 0) {
511 X fprintf(stderr, "error: ioctl read recording source failed\n");
512 X perror("ioctl");
513 X close(fd);
514 X exit(1);
515 X }
516 X
517 X recsrc |= SOUND_MASK_DIGITAL1;
518 X
519 X if (ioctl(fd, SOUND_MIXER_WRITE_RECSRC, &recsrc) < 0) {
520 X fprintf(stderr, "error: ioctl write recording source failed\n");
521 X perror("ioctl");
522 X close(fd);
523 X exit(1);
524 X }
525 X
526 X close(fd);
527 X
528 X return 0;
553 X *
554 X * pinnaclecfg.c - Pinnacle/Fiji Device Configuration Program
555 X *
556 X * This is for NON-PnP mode only. For PnP mode, use isapnptools.
557 X *
558 X * This is Linux-specific, and must be run with root permissions.
559 X *
560 X * Part of the Turtle Beach MultiSound Sound Card Driver for Linux
561 X *
562 X * Copyright (C) 1998 Andrew Veliath
563 X *
564 X * This program is free software; you can redistribute it and/or modify
565 X * it under the terms of the GNU General Public License as published by
566 X * the Free Software Foundation; either version 2 of the License, or
567 X * (at your option) any later version.
568 X *
569 X * This program is distributed in the hope that it will be useful,
570 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
571 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
572 X * GNU General Public License for more details.
573 X *
574 X * You should have received a copy of the GNU General Public License
575 X * along with this program; if not, write to the Free Software
576 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
577 X *
578 X ********************************************************************/
579 X
587 X
612 X
616 X
620 X
622 X
625 X outb(reg, cfg);
626 X outb(value, cfg + 1);
627 X if (value != inb(cfg + 1)) {
628 X fprintf(stderr, "error: msnd_write_cfg: I/O error\n");
629 X return -EIO;
630 X }
631 X return 0;
633 X
636 X outb(reg, cfg);
637 X return inb(cfg + 1);
639 X
642 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
643 X return -EIO;
644 X if (msnd_write_cfg(cfg, IREG_IO0_BASEHI, HIBYTE(io)))
645 X return -EIO;
646 X if (msnd_write_cfg(cfg, IREG_IO0_BASELO, LOBYTE(io)))
647 X return -EIO;
648 X return 0;
650 X
653 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
654 X return -EIO;
655 X
656 X *io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO0_BASELO),
657 X msnd_read_cfg(cfg, IREG_IO0_BASEHI));
658 X
659 X return 0;
661 X
664 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
665 X return -EIO;
666 X if (msnd_write_cfg(cfg, IREG_IO1_BASEHI, HIBYTE(io)))
667 X return -EIO;
668 X if (msnd_write_cfg(cfg, IREG_IO1_BASELO, LOBYTE(io)))
669 X return -EIO;
670 X return 0;
672 X
675 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
676 X return -EIO;
677 X
678 X *io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO1_BASELO),
679 X msnd_read_cfg(cfg, IREG_IO1_BASEHI));
680 X
681 X return 0;
683 X
686 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
687 X return -EIO;
688 X if (msnd_write_cfg(cfg, IREG_IRQ_NUMBER, LOBYTE(irq)))
689 X return -EIO;
690 X if (msnd_write_cfg(cfg, IREG_IRQ_TYPE, IRQTYPE_EDGE))
691 X return -EIO;
692 X return 0;
694 X
697 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
698 X return -EIO;
699 X
700 X *irq = msnd_read_cfg(cfg, IREG_IRQ_NUMBER);
701 X
702 X return 0;
704 X
707 X WORD wmem;
708 X
709 X mem >>= 8;
710 X mem &= 0xfff;
711 X wmem = (WORD)mem;
712 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
713 X return -EIO;
714 X if (msnd_write_cfg(cfg, IREG_MEMBASEHI, HIBYTE(wmem)))
715 X return -EIO;
716 X if (msnd_write_cfg(cfg, IREG_MEMBASELO, LOBYTE(wmem)))
717 X return -EIO;
718 X if (wmem && msnd_write_cfg(cfg, IREG_MEMCONTROL, (MEMTYPE_HIADDR | MEMTYPE_16BIT)))
719 X return -EIO;
720 X return 0;
722 X
725 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
726 X return -EIO;
727 X
728 X *mem = MAKEWORD(msnd_read_cfg(cfg, IREG_MEMBASELO),
729 X msnd_read_cfg(cfg, IREG_MEMBASEHI));
730 X *mem <<= 8;
731 X
732 X return 0;
734 X
737 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
738 X return -EIO;
739 X if (msnd_write_cfg(cfg, IREG_ACTIVATE, LD_ACTIVATE))
740 X return -EIO;
741 X return 0;
743 X
746 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
747 X return -EIO;
748 X if (msnd_write_cfg_io0(cfg, num, io0))
749 X return -EIO;
750 X if (msnd_write_cfg_io1(cfg, num, io1))
751 X return -EIO;
752 X if (msnd_write_cfg_irq(cfg, num, irq))
753 X return -EIO;
754 X if (msnd_write_cfg_mem(cfg, num, mem))
755 X return -EIO;
756 X if (msnd_activate_logical(cfg, num))
757 X return -EIO;
758 X return 0;
760 X
763 X if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
764 X return -EIO;
765 X if (msnd_read_cfg_io0(cfg, num, io0))
766 X return -EIO;
767 X if (msnd_read_cfg_io1(cfg, num, io1))
768 X return -EIO;
769 X if (msnd_read_cfg_irq(cfg, num, irq))
770 X return -EIO;
771 X if (msnd_read_cfg_mem(cfg, num, mem))
772 X return -EIO;
773 X return 0;
775 X
778 X fprintf(stderr,
779 X "\n"
780 X "pinnaclecfg 1.0\n"
781 X "\n"
782 X "usage: pinnaclecfg <config port> [device config]\n"
783 X "\n"
784 X "This is for use with the card in NON-PnP mode only.\n"
785 X "\n"
786 X "Available devices (not all available for Fiji):\n"
787 X "\n"
788 X " Device Description\n"
789 X " -------------------------------------------------------------------\n"
790 X " reset Reset all devices (i.e. disable)\n"
791 X " show Display current device configurations\n"
792 X "\n"
793 X " dsp <io> <irq> <mem> Audio device\n"
794 X " mpu <io> <irq> Internal Kurzweil synth\n"
795 X " ide <io0> <io1> <irq> On-board IDE controller\n"
796 X " joystick <io> Joystick port\n"
797 X "\n");
798 X exit(1);
800 X
803 X int i;
804 X
805 X for (i = 0; i < 4; ++i)
806 X msnd_write_cfg_logical(config_port, i, 0, 0, 0, 0);
807 X
808 X return 0;
810 X
813 X int i;
814 X int count = 0;
815 X
816 X for (i = 0; i < 4; ++i) {
817 X WORD io0, io1, irq;
818 X int mem;
819 X msnd_read_cfg_logical(config_port, i, &io0, &io1, &irq, &mem);
820 X switch (i) {
821 X case 0:
822 X if (io0 || irq || mem) {
823 X printf("dsp 0x%x %d 0x%x\n", io0, irq, mem);
824 X ++count;
825 X }
826 X break;
827 X case 1:
828 X if (io0 || irq) {
829 X printf("mpu 0x%x %d\n", io0, irq);
830 X ++count;
831 X }
832 X break;
833 X case 2:
834 X if (io0 || io1 || irq) {
835 X printf("ide 0x%x 0x%x %d\n", io0, io1, irq);
836 X ++count;
837 X }
838 X break;
839 X case 3:
840 X if (io0) {
841 X printf("joystick 0x%x\n", io0);
842 X ++count;
843 X }
844 X break;
845 X }
846 X }
847 X
848 X if (count == 0)
849 X fprintf(stderr, "no devices configured\n");
850 X
851 X return 0;
853 X
856 X int io, irq, mem;
857 X
858 X if (argc < 3 ||
859 X sscanf(argv[0], "0x%x", &io) != 1 ||
860 X sscanf(argv[1], "%d", &irq) != 1 ||
861 X sscanf(argv[2], "0x%x", &mem) != 1)
862 X usage();
863 X
864 X if (!(io == 0x290 ||
865 X io == 0x260 ||
866 X io == 0x250 ||
867 X io == 0x240 ||
868 X io == 0x230 ||
869 X io == 0x220 ||
870 X io == 0x210 ||
871 X io == 0x3e0)) {
872 X fprintf(stderr, "error: io must be one of "
873 X "210, 220, 230, 240, 250, 260, 290, or 3E0\n");
874 X usage();
875 X }
876 X
877 X if (!(irq == 5 ||
878 X irq == 7 ||
879 X irq == 9 ||
880 X irq == 10 ||
881 X irq == 11 ||
882 X irq == 12)) {
883 X fprintf(stderr, "error: irq must be one of "
884 X "5, 7, 9, 10, 11 or 12\n");
885 X usage();
886 X }
887 X
888 X if (!(mem == 0xb0000 ||
889 X mem == 0xc8000 ||
890 X mem == 0xd0000 ||
891 X mem == 0xd8000 ||
892 X mem == 0xe0000 ||
893 X mem == 0xe8000)) {
894 X fprintf(stderr, "error: mem must be one of "
895 X "0xb0000, 0xc8000, 0xd0000, 0xd8000, 0xe0000 or 0xe8000\n");
896 X usage();
897 X }
898 X
899 X return msnd_write_cfg_logical(config_port, 0, io, 0, irq, mem);
901 X
904 X int io, irq;
905 X
906 X if (argc < 2 ||
907 X sscanf(argv[0], "0x%x", &io) != 1 ||
908 X sscanf(argv[1], "%d", &irq) != 1)
909 X usage();
910 X
911 X return msnd_write_cfg_logical(config_port, 1, io, 0, irq, 0);
913 X
916 X int io0, io1, irq;
917 X
918 X if (argc < 3 ||
919 X sscanf(argv[0], "0x%x", &io0) != 1 ||
920 X sscanf(argv[0], "0x%x", &io1) != 1 ||
921 X sscanf(argv[1], "%d", &irq) != 1)
922 X usage();
923 X
924 X return msnd_write_cfg_logical(config_port, 2, io0, io1, irq, 0);
926 X
929 X int io;
930 X
931 X if (argc < 1 ||
932 X sscanf(argv[0], "0x%x", &io) != 1)
933 X usage();
934 X
935 X return msnd_write_cfg_logical(config_port, 3, io, 0, 0, 0);
937 X
940 X char *device;
941 X int rv = 0;
942 X
943 X --argc; ++argv;
944 X
945 X if (argc < 2)
946 X usage();
947 X
948 X sscanf(argv[0], "0x%x", &config_port);
949 X if (config_port != 0x250 && config_port != 0x260 && config_port != 0x270) {
950 X fprintf(stderr, "error: <config port> must be 0x250, 0x260 or 0x270\n");
951 X exit(1);
952 X }
953 X if (ioperm(config_port, 2, 1)) {
954 X perror("ioperm");
955 X fprintf(stderr, "note: pinnaclecfg must be run as root\n");
956 X exit(1);
957 X }
958 X device = argv[1];
959 X
960 X argc -= 2; argv += 2;
961 X
962 X if (strcmp(device, "reset") == 0)
963 X rv = cfg_reset();
964 X else if (strcmp(device, "show") == 0)
965 X rv = cfg_show();
966 X else if (strcmp(device, "dsp") == 0)
967 X rv = cfg_dsp(argc, argv);
968 X else if (strcmp(device, "mpu") == 0)
969 X rv = cfg_mpu(argc, argv);
970 X else if (strcmp(device, "ide") == 0)
971 X rv = cfg_ide(argc, argv);
972 X else if (strcmp(device, "joystick") == 0)
973 X rv = cfg_joystick(argc, argv);
974 X else {
975 X fprintf(stderr, "error: unknown device %s\n", device);
976 X usage();
977 X }
978 X
979 X if (rv)
980 X fprintf(stderr, "error: device configuration failed\n");
981 X
982 X return 0;
1009 X
1011 X
1013 X rm -f $(PROGS)
1067 X *
1068 X * msndreset.c - resets the MultiSound card
1069 X *
1070 X * Copyright (C) 1998 Andrew Veliath
1071 X *
1072 X * This program is free software; you can redistribute it and/or modify
1073 X * it under the terms of the GNU General Public License as published by
1074 X * the Free Software Foundation; either version 2 of the License, or
1075 X * (at your option) any later version.
1076 X *
1077 X * This program is distributed in the hope that it will be useful,
1078 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
1079 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1080 X * GNU General Public License for more details.
1081 X *
1082 X * You should have received a copy of the GNU General Public License
1083 X * along with this program; if not, write to the Free Software
1084 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1085 X *
1086 X ********************************************************************/
1087 X
1096 X
1099 X int fd;
1100 X
1101 X if (argc != 2) {
1102 X fprintf(stderr, "usage: msndreset <mixer device>\n");
1103 X exit(1);
1104 X }
1105 X
1106 X if ((fd = open(argv[1], O_RDWR)) < 0) {
1107 X perror(argv[1]);
1108 X exit(1);
1109 X }
1110 X
1111 X if (ioctl(fd, SOUND_MIXER_PRIVATE1, 0) < 0) {
1112 X fprintf(stderr, "error: msnd ioctl reset failed\n");
1113 X perror("ioctl");
1114 X close(fd);
1115 X exit(1);
1116 X }
1117 X
1118 X close(fd);
1119 X
1120 X return 0;