35#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/module.h>
39#include <machine/resource.h>
40#include <machine/bus.h>
43#ifdef HAVE_KERNEL_OPTION_HEADERS
60#define CS4610_PCI_ID 0x60011013
61#define CS4614_PCI_ID 0x60031013
62#define CS4615_PCI_ID 0x60041013
86 rman_res_t start, rman_res_t end,
87 rman_res_t
count, u_int flags);
91 struct resource *irq,
int flags,
92 driver_filter_t *filter,
93 driver_intr_t *
intr,
void *arg,
void **cookiep);
95 struct resource *irq,
void *cookie);
117 devclass_t pci_devclass;
118 device_t *pci_devices, *pci_children, *busp, *childp;
119 int pci_count = 0, pci_childcount = 0;
122 bus_space_tag_t btag;
124 if ((pci_devclass = devclass_find(
"pci")) == NULL) {
128 devclass_get_devices(pci_devclass, &pci_devices, &pci_count);
130 for (i = 0, busp = pci_devices; i < pci_count; i++, busp++) {
132 if (device_get_children(*busp, &pci_children, &pci_childcount))
134 for (j = 0, childp = pci_children; j < pci_childcount; j++, childp++) {
135 if (pci_get_vendor(*childp) == 0x8086 && pci_get_device(*childp) == 0x7113) {
136 port = (pci_read_config(*childp, 0x41, 1) << 8) + 0x10;
138 btag = X86_BUS_SPACE_IO;
140 control = bus_space_read_2(btag, 0x0, port);
142 control |= run? 0 : 0x2000;
143 bus_space_write_2(btag, 0x0, port, control);
144 free(pci_devices, M_TEMP);
145 free(pci_children, M_TEMP);
149 free(pci_children, M_TEMP);
152 free(pci_devices, M_TEMP);
160 {0, 0,
"Unknown/invalid SSID (CS4610)", NULL, NULL, NULL, 0},
164 {0x1489, 0x7001,
"Genius Soundmaker 128 value",
amp_none, NULL, NULL, 0},
165 {0x5053, 0x3357,
"Turtle Beach Santa Cruz",
amp_voyetra, NULL, NULL, 1},
166 {0x1071, 0x6003,
"Mitac MI6020/21",
amp_voyetra, NULL, NULL, 0},
167 {0x14AF, 0x0050,
"Hercules Game Theatre XP", NULL, NULL, NULL, 0},
168 {0x1681, 0x0050,
"Hercules Game Theatre XP", NULL, NULL, NULL, 0},
169 {0x1014, 0x0132,
"Thinkpad 570",
amp_none, NULL, NULL, 0},
171 {0x1014, 0x1010,
"Thinkpad 600E (unsupported)", NULL, NULL, NULL, 0},
172 {0x153b, 0x1136,
"Terratec SiXPack 5.1+", NULL, NULL, NULL, 0},
173 {0, 0,
"Unknown/invalid SSID (CS4614)", NULL, NULL, NULL, 0},
177 {0, 0,
"Unknown/invalid SSID (CS4615)", NULL, NULL, NULL, 0},
219 subcard = card->
cards;
238 device_set_desc(
dev, card->
name);
239 return BUS_PROBE_DEFAULT;
252 scp = device_get_softc(
dev);
255 bzero(scp,
sizeof(*scp));
258 pci_enable_busmaster(
dev);
263 scp->binfo.card = scp->card;
264 printf(
"csa: card is %s\n", scp->card->name);
266 resp->io = bus_alloc_resource_any(
dev, SYS_RES_MEMORY,
267 &
resp->io_rid, RF_ACTIVE);
268 if (
resp->io == NULL)
271 resp->mem = bus_alloc_resource_any(
dev, SYS_RES_MEMORY,
272 &
resp->mem_rid, RF_ACTIVE);
273 if (
resp->mem == NULL)
276 resp->irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ,
277 &
resp->irq_rid, RF_ACTIVE | RF_SHAREABLE);
278 if (
resp->irq == NULL)
308 func->varinfo = &scp->binfo;
310 scp->pcm = device_add_child(
dev,
"pcm", -1);
311 device_set_ivars(scp->pcm,
func);
319 func->varinfo = &scp->binfo;
321 scp->midi = device_add_child(
dev,
"midi", -1);
322 device_set_ivars(scp->midi,
func);
324 bus_generic_attach(
dev);
329 bus_teardown_intr(
dev,
resp->irq, scp->ih);
331 bus_release_resource(
dev, SYS_RES_IRQ,
resp->irq_rid,
resp->irq);
333 bus_release_resource(
dev, SYS_RES_MEMORY,
resp->mem_rid,
resp->mem);
335 bus_release_resource(
dev, SYS_RES_MEMORY,
resp->io_rid,
resp->io);
347 scp = device_get_softc(
dev);
350 if (scp->midi != NULL) {
351 func = device_get_ivars(scp->midi);
352 err = device_delete_child(
dev, scp->midi);
360 if (scp->pcm != NULL) {
361 func = device_get_ivars(scp->pcm);
362 err = device_delete_child(
dev, scp->pcm);
370 bus_teardown_intr(
dev,
resp->irq, scp->ih);
371 bus_release_resource(
dev, SYS_RES_IRQ,
resp->irq_rid,
resp->irq);
372 bus_release_resource(
dev, SYS_RES_MEMORY,
resp->mem_rid,
resp->mem);
373 bus_release_resource(
dev, SYS_RES_MEMORY,
resp->io_rid,
resp->io);
375 return bus_generic_detach(
dev);
384 scp = device_get_softc(
dev);
398 return (bus_generic_resume(
dev));
401static struct resource *
403 rman_res_t start, rman_res_t end, rman_res_t
count, u_int flags)
407 struct resource *res;
409 scp = device_get_softc(
bus);
454 struct resource *irq,
int flags,
455 driver_filter_t *filter,
456 driver_intr_t *
intr,
void *arg,
void **cookiep)
462 if (filter != NULL) {
463 printf(
"ata-csa.c: we cannot use a filter here\n");
466 scp = device_get_softc(
bus);
477 switch (
func->func) {
480 scp->pcmintr_arg = arg;
484 scp->midiintr =
intr;
485 scp->midiintr_arg = arg;
500 struct resource *irq,
void *cookie)
506 scp = device_get_softc(
bus);
514 if (
func == NULL ||
irq !=
resp->irq || cookie != scp)
517 switch (
func->func) {
520 scp->pcmintr_arg = NULL;
524 scp->midiintr = NULL;
525 scp->midiintr_arg = NULL;
547 if ((hisr & 0x7fffffff) == 0) {
557 scp->binfo.hisr = hisr;
561 scp->pcmintr(scp->pcmintr_arg);
564 if ((hisr &
HISR_MIDI) != 0 && scp->midiintr != NULL) {
565 scp->midiintr(scp->midiintr_arg);
577 u_int32_t acsts, acisv;
681 for (i = 0 ; i < 1000 ; i++) {
714 for (i = 0 ; i < 2000 ; i++) {
776 u_int8_t clkcr1, serbst;
798 for (i = 0 ; i < 256 ; i++) {
800 for (j = 0 ; j < 5 ; j++) {
841 for (i = 0 ; i < 8 ; i++) {
886 if ((
len & 0x3) != 0)
890 if ((dest & 0x3) != 0)
894 for (ul = 0 ; ul <
len ; ul += 4)
903 u_int32_t acctl, acsts;
935 for (i = 0 ; i < 10 ; i++) {
960 for (i = 0 ; i < 10 ; i++) {
1022 for (i = 0 ; i < 10 ; i++) {
1052 return bus_space_read_4(rman_get_bustag(
resp->io), rman_get_bushandle(
resp->io),
offset) & 0xffffffff;
1064 bus_space_write_4(rman_get_bustag(
resp->io), rman_get_bushandle(
resp->io),
offset,
data);
1072 return bus_space_read_4(rman_get_bustag(
resp->mem), rman_get_bushandle(
resp->mem),
offset);
1078 bus_space_write_4(rman_get_bustag(
resp->mem), rman_get_bushandle(
resp->mem),
offset,
data);
1086 DEVMETHOD(device_shutdown, bus_generic_shutdown),
1087 DEVMETHOD(device_suspend, bus_generic_suspend),
1093 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
1094 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
struct cs461x_firmware_struct cs461x_firmware
static driver_t csa_driver
u_int32_t csa_readmem(csa_res *resp, u_long offset)
struct csa_card * csa_findsubcard(device_t dev)
void csa_writemem(csa_res *resp, u_long offset, u_int32_t data)
static int csa_teardown_intr(device_t bus, device_t child, struct resource *irq, void *cookie)
void csa_writeio(csa_res *resp, u_long offset, u_int32_t data)
static int csa_setup_intr(device_t bus, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep)
static int csa_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r)
static struct csa_card cards_4614[]
void csa_resetdsp(csa_res *resp)
int csa_writecodec(csa_res *resp, u_long offset, u_int32_t data)
u_int32_t csa_readio(csa_res *resp, u_long offset)
static driver_intr_t csa_intr
static int csa_downloadimage(csa_res *resp)
static int clkrun_hack(int run)
static struct csa_card nocard
void csa_clearserialfifos(csa_res *resp)
static struct card_type cards[]
static device_method_t csa_methods[]
static int csa_probe(device_t dev)
SND_DECLARE_FILE("$FreeBSD$")
int csa_readcodec(csa_res *resp, u_long offset, u_int32_t *data)
static void amp_voyetra(void)
MODULE_DEPEND(snd_csa, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
static int csa_detach(device_t dev)
static void amp_none(void)
static struct csa_card cards_4610[]
static int csa_attach(device_t dev)
static struct card_type * csa_findcard(device_t dev)
DRIVER_MODULE(snd_csa, pci, csa_driver, csa_devclass, 0, 0)
static struct resource * csa_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
static struct csa_card cards_4615[]
MODULE_VERSION(snd_csa, 1)
static int csa_transferimage(csa_res *resp, u_int32_t *src, u_long dest, u_long len)
static int csa_resume(device_t dev)
static devclass_t csa_devclass
static int csa_initialize(sc_p scp)
#define SERACC_CODEC_TYPE_2_0
#define PLLCC_CDR_73_104_MHZ
#define BA0_AC97_POWERDOWN
#define PLLCC_LPF_1050_2780_KHZ
#define DREG_REGID_TRAP_SELECT
#define SERACC_CODEC_TYPE_1_03
#define INKY_MEMORY_COUNT
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
u_int32_t BA1Array[INKY_BA1_DWORD_SIZE]
struct cs461x_firmware_struct::@4 MemoryStat[INKY_MEMORY_COUNT]
struct csa_bridgeinfo binfo