maple.h revision 1.3 1 /* $NetBSD: maple.h,v 1.3 2001/05/26 19:04:39 marcus Exp $ */
2 /*-
3 * Copyright (c) 2001 Marcus Comstedt
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Marcus Comstedt.
17 * 4. Neither the name of The NetBSD Foundation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef _DREAMCAST_DEV_MAPLE_MAPLE_H_
35 #define _DREAMCAST_DEV_MAPLE_MAPLE_H_
36
37 #include <sys/device.h>
38
39 #define MAPLE_PORTS 4
40 #define MAPLE_SUBUNITS 6
41
42 /* Maple Bus command and response codes */
43
44 #define MAPLE_RESPONSE_FILEERR -5
45 #define MAPLE_RESPONSE_AGAIN -4 /* request should be retransmitted */
46 #define MAPLE_RESPONSE_BADCMD -3
47 #define MAPLE_RESPONSE_BADFUNC -2
48 #define MAPLE_RESPONSE_NONE -1 /* unit didn't respond at all */
49 #define MAPLE_COMMAND_DEVINFO 1
50 #define MAPLE_COMMAND_ALLINFO 2
51 #define MAPLE_COMMAND_RESET 3
52 #define MAPLE_COMMAND_KILL 4
53 #define MAPLE_RESPONSE_DEVINFO 5
54 #define MAPLE_RESPONSE_ALLINFO 6
55 #define MAPLE_RESPONSE_OK 7
56 #define MAPLE_RESPONSE_DATATRF 8
57 #define MAPLE_COMMAND_GETCOND 9
58 #define MAPLE_COMMAND_GETMINFO 10
59 #define MAPLE_COMMAND_BREAD 11
60 #define MAPLE_COMMAND_BWRITE 12
61 #define MAPLE_COMMAND_SETCOND 14
62
63
64 /* Function codes */
65
66 #define MAPLE_FUNC_CONTROLLER 0x001
67 #define MAPLE_FUNC_MEMCARD 0x002
68 #define MAPLE_FUNC_LCD 0x004
69 #define MAPLE_FUNC_CLOCK 0x008
70 #define MAPLE_FUNC_MICROPHONE 0x010
71 #define MAPLE_FUNC_ARGUN 0x020
72 #define MAPLE_FUNC_KEYBOARD 0x040
73 #define MAPLE_FUNC_LIGHTGUN 0x080
74 #define MAPLE_FUNC_PURUPURU 0x100
75 #define MAPLE_FUNC_MOUSE 0x200
76
77 struct maple_devinfo {
78 u_int32_t di_func; /* function code */
79 u_int32_t di_function_data[3]; /* function data */
80 u_int8_t di_area_code; /* region settings */
81 u_int8_t di_connector_direction; /* ? */
82 char di_product_name[30]; /* name of the device */
83 char di_product_license[60]; /* manufacturer info */
84 u_int16_t di_standby_power; /* standby power consumption */
85 u_int16_t di_max_power; /* maximum power consumption */
86 };
87
88 struct maple_unit {
89 int port, subunit;
90 int status;
91 u_int32_t getcond_func;
92 void (*getcond_callback)(void *, void *, int);
93 void *getcond_data;
94 struct maple_devinfo devinfo;
95 };
96
97 extern void maple_set_condition_callback __P((struct device *, int, int, u_int32_t, void (*)(void *, void *, int), void *));
98 extern u_int32_t maple_get_function_data __P((struct maple_devinfo *, u_int32_t));
99 extern void maple_run_polling __P((struct device *));
100
101 #endif /* _DREAMCAST_DEV_MAPLE_MAPLE_H_ */
102
103