preps for marcans bt hax
[ppcskel.git] / usb / drivers / bt.c
1 /*
2         ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
3         bluetooth driver
4
5 Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
6 Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
7
8 # This code is licensed to you under the terms of the GNU GPL, version 2;
9 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
10 */
11
12 #include "../core/core.h"
13 #include "../core/usb.h"
14 #include "../usbspec/usb11spec.h"
15 #include "../../malloc.h"
16 #include "../../string.h"
17
18 #include "bt.h"
19
20 struct usb_driver btdriv = {
21         .name     = "bt",
22         .probe  = usb_bt_probe,
23         .check  = usb_bt_check,
24         .remove = usb_bt_remove,
25         .data     = NULL
26 };
27
28 u8 epi_it, epi_bk, epo_bk;
29
30
31 void usb_bt_init()
32 {
33         usb_register_driver(&btdriv);
34
35         usb_set_configuration(btdriv.data, btdriv.data->conf->bConfigurationValue);
36         printf("get_conf: %d\n", usb_get_configuration(btdriv.data));
37
38         u8 buf[8];
39         memset(buf, 0, 8);
40         usb_control_msg(btdriv.data, 0x01, SET_INTERFACE, 0, 1, 0, buf, 0);
41
42         epi_it = btdriv.data->conf->intf->endp->bEndpointAddress & 0x7F;
43         epi_bk = btdriv.data->conf->intf->endp->next->bEndpointAddress & 0x7F;
44         epo_bk = btdriv.data->conf->intf->endp->next->next->bEndpointAddress & 0x7F;
45
46         btdriv.data->epSize[1] = btdriv.data->conf->intf->endp->wMaxPacketSize;
47         btdriv.data->epSize[2] = btdriv.data->conf->intf->endp->next->wMaxPacketSize;
48         btdriv.data->epSize[3] = btdriv.data->conf->intf->endp->next->next->wMaxPacketSize;
49 }
50
51 void usb_bt_probe()
52 {
53         struct usb_device *dev;
54         struct element *iterator = core.devices->head;
55
56         while(iterator != NULL) {
57                 dev = (struct usb_device*) iterator->data;
58                 if(dev == NULL) {
59                         continue;
60                 }
61
62                 if(dev->idVendor == 0x057e && dev->idProduct == 0x0305) {
63                         btdriv.data = dev;
64                 }
65
66                 iterator=iterator->next;
67         }
68 }
69
70 void usb_bt_check()
71 {
72 }
73
74 u8 usb_bt_inuse()
75 {
76         return btdriv.data ? 1 : 0;
77 }
78
79 void usb_bt_remove()
80 {
81         btdriv.data = NULL;
82 }
83