2 * ES1370 Haiku Driver for ES1370 audio
4 * Copyright 2002-2007, Haiku, Inc.
5 * Distributed under the terms of the MIT License.
8 * Marcus Overhagen, marcus@overhagen.de
9 * Jerome Duval, jerome.duval@free.fr
11 #include <KernelExport.h>
14 #include "es1370reg.h"
18 extern pci_module_info
*pci
;
21 es1370_reg_read_8(device_config
*config
, int regno
)
24 return pci
->read_io_8(config
->base
+ regno
);
28 es1370_reg_read_16(device_config
*config
, int regno
)
31 return pci
->read_io_16(config
->base
+ regno
);
35 es1370_reg_read_32(device_config
*config
, int regno
)
38 return pci
->read_io_32(config
->base
+ regno
);
42 es1370_reg_write_8(device_config
*config
, int regno
, uint8 value
)
45 pci
->write_io_8(config
->base
+ regno
, value
);
49 es1370_reg_write_16(device_config
*config
, int regno
, uint16 value
)
52 pci
->write_io_16(config
->base
+ regno
, value
);
56 es1370_reg_write_32(device_config
*config
, int regno
, uint32 value
)
59 pci
->write_io_32(config
->base
+ regno
, value
);
64 es1370_codec_wait(device_config
*config
)
67 for (i
= 0; i
< 1100; i
++) {
68 if ((es1370_reg_read_32(config
, ES1370_REG_STATUS
) & STAT_CWRIP
) == 0)
77 es1370_codec_read(device_config
*config
, int regno
)
80 if(es1370_codec_wait(config
)!=B_OK
) {
81 PRINT(("codec busy (2)\n"));
85 return pci
->read_io_32(config
->base
+ ES1370_REG_CODEC
);
89 es1370_codec_write(device_config
*config
, int regno
, uint16 value
)
92 if(es1370_codec_wait(config
)!=B_OK
) {
93 PRINT(("codec busy (4)\n"));
96 pci
->write_io_32(config
->base
+ ES1370_REG_CODEC
, (regno
<< 8) | value
);