1 | /* |
---|
2 | * RTEMS for Nintendo DS touchscreen driver. |
---|
3 | * |
---|
4 | * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.com/license/LICENSE |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdlib.h> |
---|
15 | #include <stdio.h> |
---|
16 | #include <errno.h> |
---|
17 | #include <sys/types.h> |
---|
18 | |
---|
19 | #include <bsp.h> |
---|
20 | #include <rtems/irq.h> |
---|
21 | #include <rtems/libio.h> |
---|
22 | #include <nds.h> |
---|
23 | |
---|
24 | #include <rtems/mw_uid.h> |
---|
25 | #include "touchscreen.h" |
---|
26 | |
---|
27 | /* |
---|
28 | * from parser.c |
---|
29 | */ |
---|
30 | |
---|
31 | void register_mou_msg_queue (char *q_name); |
---|
32 | void unregister_mou_msg_queue (void); |
---|
33 | void touchscreen_sethand (int); |
---|
34 | |
---|
35 | /* |
---|
36 | * touchscreen device driver initialize entry point. |
---|
37 | */ |
---|
38 | |
---|
39 | rtems_device_driver |
---|
40 | touchscreen_initialize (rtems_device_major_number major, |
---|
41 | rtems_device_minor_number minor, void *arg) |
---|
42 | { |
---|
43 | rtems_status_code status; |
---|
44 | |
---|
45 | printk ("[+] touchscreen started\n"); |
---|
46 | |
---|
47 | touchscreen_sethand (1); |
---|
48 | |
---|
49 | /* register the device */ |
---|
50 | status = rtems_io_register_name ("/dev/mouse", major, 0); |
---|
51 | if (status != RTEMS_SUCCESSFUL) { |
---|
52 | printk ("[!] error registering touchscreen\n"); |
---|
53 | rtems_fatal_error_occurred (status); |
---|
54 | } |
---|
55 | return RTEMS_SUCCESSFUL; |
---|
56 | } |
---|
57 | |
---|
58 | /* |
---|
59 | * touchscreen device driver open operation. |
---|
60 | */ |
---|
61 | |
---|
62 | rtems_device_driver |
---|
63 | touchscreen_open (rtems_device_major_number major, |
---|
64 | rtems_device_minor_number minor, void *arg) |
---|
65 | { |
---|
66 | return RTEMS_SUCCESSFUL; |
---|
67 | } |
---|
68 | |
---|
69 | /* |
---|
70 | * touchscreen device driver close operation. |
---|
71 | */ |
---|
72 | |
---|
73 | rtems_device_driver |
---|
74 | touchscreen_close (rtems_device_major_number major, |
---|
75 | rtems_device_minor_number minor, void *arg) |
---|
76 | { |
---|
77 | return RTEMS_SUCCESSFUL; |
---|
78 | } |
---|
79 | |
---|
80 | /* |
---|
81 | * touchscreen device driver read operation. |
---|
82 | */ |
---|
83 | |
---|
84 | rtems_device_driver |
---|
85 | touchscreen_read (rtems_device_major_number major, |
---|
86 | rtems_device_minor_number minor, void *arg) |
---|
87 | { |
---|
88 | rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; |
---|
89 | rw_args->bytes_moved = 0; |
---|
90 | |
---|
91 | return RTEMS_SUCCESSFUL; |
---|
92 | } |
---|
93 | |
---|
94 | /* |
---|
95 | * touchscreen device driver write operation. |
---|
96 | */ |
---|
97 | |
---|
98 | rtems_device_driver |
---|
99 | touchscreen_write (rtems_device_major_number major, |
---|
100 | rtems_device_minor_number minor, void *arg) |
---|
101 | { |
---|
102 | rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; |
---|
103 | rw_args->bytes_moved = 0; |
---|
104 | |
---|
105 | return RTEMS_SUCCESSFUL; |
---|
106 | } |
---|
107 | |
---|
108 | /* |
---|
109 | * ioctl entry point. |
---|
110 | */ |
---|
111 | |
---|
112 | rtems_device_driver |
---|
113 | touchscreen_control (rtems_device_major_number major, |
---|
114 | rtems_device_minor_number minor, void *arg) |
---|
115 | { |
---|
116 | rtems_libio_ioctl_args_t *args = arg; |
---|
117 | |
---|
118 | switch (args->command) { |
---|
119 | case MW_UID_REGISTER_DEVICE: |
---|
120 | register_mou_msg_queue (args->buffer); |
---|
121 | break; |
---|
122 | case MW_UID_UNREGISTER_DEVICE: |
---|
123 | unregister_mou_msg_queue (); |
---|
124 | break; |
---|
125 | case MW_UID_SET_LEFTHANDED: |
---|
126 | touchscreen_sethand (0); |
---|
127 | break; |
---|
128 | case MW_UID_SET_RIGHTHANDED: |
---|
129 | touchscreen_sethand (1); |
---|
130 | break; |
---|
131 | } |
---|
132 | args->ioctl_return = 0; |
---|
133 | |
---|
134 | return RTEMS_SUCCESSFUL; |
---|
135 | } |
---|