2 * Copyright 2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Jérôme Duval (korli@users.berlios.de)
13 int32 api_version
= B_CUR_DRIVER_API_VERSION
;
15 geode_controller gCards
[MAX_CARDS
];
17 pci_module_info
* gPci
;
26 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
) != B_OK
)
29 for (i
= 0; gPci
->get_nth_pci_info(i
, &info
) == B_OK
; i
++) {
30 if ((info
.vendor_id
== AMD_VENDOR_ID
31 && info
.device_id
== AMD_CS5536_AUDIO_DEVICE_ID
)
32 || (info
.vendor_id
== NS_VENDOR_ID
33 && info
.device_id
== NS_CS5535_AUDIO_DEVICE_ID
)) {
34 put_module(B_PCI_MODULE_NAME
);
39 put_module(B_PCI_MODULE_NAME
);
47 char path
[B_PATH_NAME_LENGTH
];
51 if (get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
) != B_OK
)
56 for (i
= 0; gPci
->get_nth_pci_info(i
, &info
) == B_OK
57 && gNumCards
< MAX_CARDS
; i
++) {
58 if ((info
.vendor_id
== AMD_VENDOR_ID
59 && info
.device_id
== AMD_CS5536_AUDIO_DEVICE_ID
)
60 || (info
.vendor_id
== NS_VENDOR_ID
61 && info
.device_id
== NS_CS5535_AUDIO_DEVICE_ID
)) {
62 memset(&gCards
[gNumCards
], 0, sizeof(geode_controller
));
63 gCards
[gNumCards
].pci_info
= info
;
64 gCards
[gNumCards
].opened
= 0;
65 sprintf(path
, DEVFS_PATH_FORMAT
, gNumCards
);
66 gCards
[gNumCards
++].devfs_path
= strdup(path
);
68 dprintf("geode: detected controller @ PCI:%d:%d:%d, IRQ:%d, type %04x/%04x\n",
69 info
.bus
, info
.device
, info
.function
,
70 info
.u
.h0
.interrupt_line
,
71 info
.vendor_id
, info
.device_id
);
76 put_module(B_PCI_MODULE_NAME
);
87 for (uint32 i
= 0; i
< gNumCards
; i
++) {
88 free((void*)gCards
[i
].devfs_path
);
89 gCards
[i
].devfs_path
= NULL
;
92 put_module(B_PCI_MODULE_NAME
);
96 extern "C" const char**
99 static const char* devs
[MAX_CARDS
+ 1];
102 for (i
= 0; i
< gNumCards
; i
++) {
103 devs
[i
] = gCards
[i
].devfs_path
;
112 extern "C" device_hooks
*
113 find_device(const char* name
)
115 return &gDriverHooks
;