Changeset 56ad818 in mainline
- Timestamp:
- 2011-06-11T20:29:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9be360ee
- Parents:
- b1bdc7a4
- Location:
- uspace/srv/hid/kbd
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/Makefile
rb1bdc7a4 r56ad818 61 61 port/ski.c \ 62 62 port/sun.c \ 63 port/z8530.c 64 65 66 ifeq ($(UARCH),amd64) 67 SOURCES += \ 68 ctl/pc.c 69 endif 70 71 ifeq ($(UARCH),arm32) 72 ifeq ($(MACHINE),gta02) 73 SOURCES += \ 74 ctl/stty.c 75 endif 76 ifeq ($(MACHINE),testarm) 77 ifeq ($(CONFIG_FB),y) 78 SOURCES += \ 79 ctl/gxe_fb.c 80 else 81 SOURCES += \ 82 ctl/stty.c 83 endif 84 endif 85 ifeq ($(MACHINE),integratorcp) 86 SOURCES += \ 87 ctl/pc.c 88 endif 89 endif 90 91 ifeq ($(UARCH),ia32) 92 SOURCES += \ 93 ctl/pc.c 94 endif 95 96 ifeq ($(MACHINE),i460GX) 97 SOURCES += \ 98 ctl/pc.c 99 endif 100 101 ifeq ($(MACHINE),ski) 102 SOURCES += \ 103 ctl/stty.c 104 endif 105 106 ifeq ($(MACHINE),msim) 107 SOURCES += \ 108 ctl/stty.c 109 endif 110 111 ifeq ($(MACHINE),lgxemul) 112 ifeq ($(CONFIG_FB),y) 113 SOURCES += \ 114 ctl/gxe_fb.c 115 else 116 SOURCES += \ 117 ctl/stty.c 118 endif 119 endif 120 121 ifeq ($(MACHINE),bgxemul) 122 ifeq ($(CONFIG_FB),y) 123 SOURCES += \ 124 ctl/gxe_fb.c 125 else 126 SOURCES += \ 127 ctl/stty.c 128 endif 129 endif 130 131 ifeq ($(UARCH),ppc32) 132 SOURCES += \ 133 ctl/apple.c 134 endif 135 136 ifeq ($(UARCH),sparc64) 137 ifeq ($(PROCESSOR),sun4v) 138 SOURCES += \ 139 ctl/stty.c 140 else 141 ifeq ($(MACHINE),serengeti) 142 SOURCES += \ 143 ctl/stty.c 144 endif 145 ifeq ($(MACHINE),generic) 146 SOURCES += \ 147 ctl/sun.c 148 endif 149 endif 150 endif 151 152 ifeq ($(UARCH),abs32le) 153 SOURCES += \ 154 ctl/pc.c 155 endif 63 port/z8530.c \ 64 ctl/apple.c \ 65 ctl/gxe_fb.c \ 66 ctl/pc.c \ 67 ctl/stty.c \ 68 ctl/sun.c 156 69 157 70 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/kbd/ctl/apple.c
rb1bdc7a4 r56ad818 42 42 #include <kbd_port.h> 43 43 44 static void apple_ctl_parse_scancode(int scancode); 45 static int apple_ctl_init(kbd_port_ops_t *kbd_port); 46 static void apple_ctl_set_ind(unsigned mods); 47 48 kbd_ctl_ops_t apple_ctl = { 49 .parse_scancode = apple_ctl_parse_scancode, 50 .init = apple_ctl_init, 51 .set_ind = apple_ctl_set_ind 52 }; 53 44 54 #define KBD_KEY_RELEASE 0x80 45 55 46 56 static int scanmap[]; 47 57 48 int kbd_ctl_init(kbd_port_ops_t *kbd_port)58 static int apple_ctl_init(kbd_port_ops_t *kbd_port) 49 59 { 50 60 (void) kbd_port; … … 52 62 } 53 63 54 void kbd_ctl_parse_scancode(int scancode)64 static void apple_ctl_parse_scancode(int scancode) 55 65 { 56 66 kbd_event_type_t type; … … 72 82 } 73 83 74 void kbd_ctl_set_ind(unsigned mods)84 static void apple_ctl_set_ind(unsigned mods) 75 85 { 76 86 (void) mods; -
uspace/srv/hid/kbd/ctl/gxe_fb.c
rb1bdc7a4 r56ad818 44 44 #include <stroke.h> 45 45 46 static void gxe_fb_ctl_parse_scancode(int scancode); 47 static int gxe_fb_ctl_init(kbd_port_ops_t *kbd_port); 48 static void gxe_fb_ctl_set_ind(unsigned mods); 49 50 kbd_ctl_ops_t gxe_fb_ctl = { 51 .parse_scancode = gxe_fb_ctl_parse_scancode, 52 .init = gxe_fb_ctl_init, 53 .set_ind = gxe_fb_ctl_set_ind 54 }; 55 46 56 /** Scancode parser */ 47 57 static gsp_t sp; … … 52 62 #include <stdio.h> 53 63 54 int seq_defs[] = {64 static int seq_defs[] = { 55 65 /* Not shifted */ 56 66 … … 208 218 }; 209 219 210 int kbd_ctl_init(kbd_port_ops_t *kbd_port)220 static int gxe_fb_ctl_init(kbd_port_ops_t *kbd_port) 211 221 { 212 222 (void) kbd_port; … … 217 227 } 218 228 219 void kbd_ctl_parse_scancode(int scancode)229 static void gxe_fb_ctl_parse_scancode(int scancode) 220 230 { 221 231 unsigned mods, key; … … 227 237 } 228 238 229 void kbd_ctl_set_ind(unsigned mods)239 static void gxe_fb_ctl_set_ind(unsigned mods) 230 240 { 231 241 (void) mods; -
uspace/srv/hid/kbd/ctl/pc.c
rb1bdc7a4 r56ad818 43 43 #include <gsp.h> 44 44 45 static void pc_ctl_parse_scancode(int scancode); 46 static int pc_ctl_init(kbd_port_ops_t *kbd_port); 47 static void pc_ctl_set_ind(unsigned mods); 48 49 kbd_ctl_ops_t pc_ctl = { 50 .parse_scancode = pc_ctl_parse_scancode, 51 .init = pc_ctl_init, 52 .set_ind = pc_ctl_set_ind 53 }; 54 45 55 enum dec_state { 46 56 ds_s, … … 198 208 }; 199 209 200 int kbd_ctl_init(kbd_port_ops_t *kbd_p)210 static int pc_ctl_init(kbd_port_ops_t *kbd_p) 201 211 { 202 212 kbd_port = kbd_p; … … 205 215 } 206 216 207 void kbd_ctl_parse_scancode(int scancode)217 static void pc_ctl_parse_scancode(int scancode) 208 218 { 209 219 kbd_event_type_t type; … … 255 265 } 256 266 257 void kbd_ctl_set_ind(unsigned mods)267 static void pc_ctl_set_ind(unsigned mods) 258 268 { 259 269 uint8_t b; -
uspace/srv/hid/kbd/ctl/stty.c
rb1bdc7a4 r56ad818 43 43 #include <stroke.h> 44 44 45 static void stty_ctl_parse_scancode(int scancode); 46 static int stty_ctl_init(kbd_port_ops_t *kbd_port); 47 static void stty_ctl_set_ind(unsigned mods); 48 49 kbd_ctl_ops_t stty_ctl = { 50 .parse_scancode = stty_ctl_parse_scancode, 51 .init = stty_ctl_init, 52 .set_ind = stty_ctl_set_ind 53 }; 54 45 55 /** Scancode parser */ 46 56 static gsp_t sp; … … 51 61 #include <stdio.h> 52 62 53 int seq_defs[] = {63 static int seq_defs[] = { 54 64 /* Not shifted */ 55 65 … … 207 217 }; 208 218 209 int kbd_ctl_init(kbd_port_ops_t *kbd_port)219 static int stty_ctl_init(kbd_port_ops_t *kbd_port) 210 220 { 211 221 (void) kbd_port; … … 216 226 } 217 227 218 void kbd_ctl_parse_scancode(int scancode)228 static void stty_ctl_parse_scancode(int scancode) 219 229 { 220 230 unsigned mods, key; … … 226 236 } 227 237 228 void kbd_ctl_set_ind(unsigned mods)238 static void stty_ctl_set_ind(unsigned mods) 229 239 { 230 240 (void) mods; -
uspace/srv/hid/kbd/ctl/sun.c
rb1bdc7a4 r56ad818 42 42 #include <kbd_port.h> 43 43 44 static void sun_ctl_parse_scancode(int scancode); 45 static int sun_ctl_init(kbd_port_ops_t *kbd_port); 46 static void sun_ctl_set_ind(unsigned mods); 47 48 kbd_ctl_ops_t sun_ctl = { 49 .parse_scancode = sun_ctl_parse_scancode, 50 .init = sun_ctl_init, 51 .set_ind = sun_ctl_set_ind 52 }; 53 44 54 #define KBD_KEY_RELEASE 0x80 45 55 #define KBD_ALL_KEYS_UP 0x7f … … 47 57 static int scanmap_simple[]; 48 58 49 int kbd_ctl_init(kbd_port_ops_t *kbd_port)59 static int sun_ctl_init(kbd_port_ops_t *kbd_port) 50 60 { 51 61 return 0; 52 62 } 53 63 54 void kbd_ctl_parse_scancode(int scancode)64 static void sun_ctl_parse_scancode(int scancode) 55 65 { 56 66 kbd_event_type_t type; … … 75 85 } 76 86 77 void kbd_ctl_set_ind(unsigned mods)87 static void sun_ctl_set_ind(unsigned mods) 78 88 { 79 89 (void) mods; -
uspace/srv/hid/kbd/generic/kbd.c
rb1bdc7a4 r56ad818 72 72 73 73 static kbd_port_ops_t *kbd_port; 74 static kbd_ctl_ops_t *kbd_ctl; 74 75 75 76 bool irc_service = false; … … 89 90 { 90 91 /* printf("scancode: 0x%x\n", scancode);*/ 91 kbd_ctl_parse_scancode(scancode);92 (*kbd_ctl->parse_scancode)(scancode); 92 93 } 93 94 … … 132 133 133 134 /* Update keyboard lock indicator lights. */ 134 kbd_ctl_set_ind(mods);135 (*kbd_ctl->set_ind)(mods); 135 136 } else { 136 137 lock_keys = lock_keys & ~mod_mask; … … 217 218 } 218 219 219 static kbd_port_ops_t *kbd_select_port(void) 220 { 221 kbd_port_ops_t *kbd_port; 222 220 static void kbd_select_drivers(kbd_port_ops_t **port, kbd_ctl_ops_t **ctl) 221 { 223 222 #if defined(UARCH_amd64) 224 kbd_port = &chardev_port; 223 *port = &chardev_port; 224 *ctl = &pc_ctl; 225 225 #elif defined(UARCH_arm32) && defined(MACHINE_gta02) 226 kbd_port = &chardev_port; 226 *port = &chardev_port; 227 *ctl = &stty_ctl; 227 228 #elif defined(UARCH_arm32) && defined(MACHINE_testarm) 228 kbd_port = &gxemul_port; 229 *port = &gxemul_port; 230 #ifdef CONFIG_FB 231 *ctl = &gxe_fb_ctl; 232 #else 233 *ctl = &stty_ctl; 234 #endif 229 235 #elif defined(UARCH_arm32) && defined(MACHINE_integratorcp) 230 kbd_port = &pl050_port; 236 *port = &pl050_port; 237 *ctl = &pc_ctl; 231 238 #elif defined(UARCH_ia32) 232 kbd_port = &chardev_port; 239 *port = &chardev_port; 240 *ctl = &pc_ctl; 233 241 #elif defined(MACHINE_i460GX) 234 kbd_port = &chardev_port; 242 *port = &chardev_port; 243 *ctl = &pc_ctl; 235 244 #elif defined(MACHINE_ski) 236 kbd_port = &ski_port; 245 *port = &ski_port; 246 *ctl = &stty_ctl; 237 247 #elif defined(MACHINE_msim) 238 kbd_port = &msim_port; 248 *port = &msim_port; 249 *ctl = &stty_ctl; 239 250 #elif defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) 240 kbd_port = &gxemul_port; 251 *port = &gxemul_port; 252 #ifdef CONFIG_FB 253 *ctl = &gxe_fb_ctl; 254 #else 255 *ctl = &stty_ctl; 256 #endif 241 257 #elif defined(UARCH_ppc32) 242 kbd_port = &adb_port; 258 *port = &adb_port; 259 *ctl = &apple_ctl; 243 260 #elif defined(UARCH_sparc64) && defined(PROCESSOR_sun4v) 244 kbd_port = &niagara_port; 261 *port = &niagara_port; 262 *ctl = &stty_ctl; 245 263 #elif defined(UARCH_sparc64) && defined(MACHINE_serengeti) 246 kbd_port = &sgcn_port; 264 *port = &sgcn_port; 265 *ctl = &stty_ctl; 247 266 #elif defined(UARCH_sparc64) && defined(MACHINE_generic) 248 kbd_port = &sun_port; 267 *port = &sun_port; 268 *ctl = &sun_ctl; 249 269 #else 250 kbd_port = &dummy_port; 270 *port = &dummy_port; 271 *ctl = &pc_ctl; 251 272 #endif 252 return kbd_port;253 273 } 254 274 … … 269 289 } 270 290 271 /* Select port driver. */272 kbd_ port = kbd_select_port();291 /* Select port and controller drivers. */ 292 kbd_select_drivers(&kbd_port, &kbd_ctl); 273 293 274 294 /* Initialize port driver. */ … … 277 297 278 298 /* Initialize controller driver. */ 279 if ( kbd_ctl_init(kbd_port) != 0)299 if ((*kbd_ctl->init)(kbd_port) != 0) 280 300 return -1; 281 301 -
uspace/srv/hid/kbd/include/kbd_ctl.h
rb1bdc7a4 r56ad818 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 #include <kbd_port.h> 41 41 42 extern void kbd_ctl_parse_scancode(int); 43 extern int kbd_ctl_init(kbd_port_ops_t *); 44 extern void kbd_ctl_set_ind(unsigned); 42 typedef struct { 43 void (*parse_scancode)(int); 44 int (*init)(kbd_port_ops_t *); 45 void (*set_ind)(unsigned); 46 } kbd_ctl_ops_t; 47 48 extern kbd_ctl_ops_t apple_ctl; 49 extern kbd_ctl_ops_t gxe_fb_ctl; 50 extern kbd_ctl_ops_t pc_ctl; 51 extern kbd_ctl_ops_t stty_ctl; 52 extern kbd_ctl_ops_t sun_ctl; 45 53 46 54 #endif
Note:
See TracChangeset
for help on using the changeset viewer.