Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / kernel / drivers / char / sound / es1370.c
bloba712ddbc3f2048c557fcd272f1577ff740ec4311
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <config.h>
22 #include <build.h>
24 #ifdef ARCH_i386
26 #include <system.h>
27 #include <dev.h>
28 #include <arch/io.h>
29 #include <pci.h>
31 #define ES1370_VENDORID 0x1274
32 #define ES1370_DEVICEID 0x5000
34 typedef struct {
35 unsigned addr_io;
36 int irq;
37 } es1370_t;
39 int es1370_inb (es1370_t *dev, int port)
41 int value = -1;
43 if ((value = inb (dev->addr_io+port)) != 0)
44 DPRINT (DBG_DRIVER | DBG_SOUND, "es1370DSP: inb () failed - %d", value);
46 return value;
49 void es1370_outb (es1370_t *dev, int port, int value)
51 int s;
53 outb (dev->addr_io+port, value);
56 /* detect es1370 device in PC */
57 pcidev_t *es1370_detect ()
59 /* First detect sound card - is connected to PCI bus ?*/
60 pcidev_t *pcidev = pcidev_find (ES1370_VENDORID, ES1370_DEVICEID);
62 if (!pcidev)
63 return 0;
65 return pcidev;
68 unsigned init_es1370 ()
70 pcidev_t *pcidev = es1370_detect ();
72 if (!pcidev)
73 return 0;
75 es1370_t *dev = (es1370_t *) kmalloc (sizeof (es1370_t));
77 if (!dev)
78 return 0;
80 /* get irq id */
81 dev->irq = pcidev->u.h0.interrupt_line;
82 dev->addr_io = pcidev->u.h0.base_registers[0];
84 kprintf ("es1370 -> found at 0x%x, irq: %d\n", dev->addr_io, dev->irq);
86 unsigned char *c = (unsigned char *) dev->addr_io;
88 //es1370_outb (dev, 0x0, 1);
90 //kprintf ("Prvni znak: 0x%x\n", c[0]);
92 return 1;
95 bool es1370_acthandler (unsigned act, unsigned freq)
97 switch (act) {
98 case DEV_ACT_INIT:
100 //init_es1370 ();
102 return 1;
104 break;
105 case DEV_ACT_STOP:
109 return 1;
111 break;
112 case DEV_ACT_WRITE:
116 return 1;
118 break;
121 return 0;
123 #endif