Changeset af897ff0 in mainline
- Timestamp:
- 2011-06-12T14:51:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5f88293
- Parents:
- f2f99ae
- Location:
- uspace/srv/hid
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
rf2f99ae raf897ff0 973 973 974 974 /* Start fibril for checking on hot-plugged keyboards. */ 975 // check_new_devices_in_background(connect_keyboard, "keyboard");976 975 check_new_devices_in_background(connect_mouse, "mouse"); 977 976 -
uspace/srv/hid/kbd/generic/kbd.c
rf2f99ae raf897ff0 62 62 #include <kernel/ipc/ipc_methods.h> 63 63 64 #define NAME "kbd" 65 #define NAMESPACE "hid_in"64 /* In microseconds */ 65 #define DISCOVERY_POLL_INTERVAL (10*1000*1000) 66 66 67 67 static void kbd_devs_yield(void); … … 223 223 } 224 224 225 /** Add new keyboard device. */225 /** Add new legacy keyboard device. */ 226 226 static void kbd_add_dev(kbd_port_ops_t *port, kbd_ctl_ops_t *ctl) 227 227 { … … 235 235 236 236 link_initialize(&kdev->kbd_devs); 237 kdev->dev_path = NULL; 237 238 kdev->port_ops = port; 238 239 kdev->ctl_ops = ctl; 239 240 240 241 /* Initialize port driver. */ 241 if (kdev->port_ops != NULL) { 242 if ((*kdev->port_ops->init)(kdev) != 0) 243 goto fail; 244 } 242 if ((*kdev->port_ops->init)(kdev) != 0) 243 goto fail; 245 244 246 245 /* Initialize controller driver. */ … … 254 253 fail: 255 254 free(kdev); 255 } 256 257 /** Add new kbdev device. 258 * 259 * @param dev_path Filesystem path to the device (/dev/class/...) 260 */ 261 static int kbd_add_kbdev(const char *dev_path) 262 { 263 kbd_dev_t *kdev; 264 265 kdev = malloc(sizeof(kbd_dev_t)); 266 if (kdev == NULL) { 267 printf(NAME ": Failed adding keyboard device. Out of memory.\n"); 268 return -1; 269 } 270 271 link_initialize(&kdev->kbd_devs); 272 kdev->dev_path = dev_path; 273 kdev->port_ops = NULL; 274 kdev->ctl_ops = &kbdev_ctl; 275 276 /* Initialize controller driver. */ 277 if ((*kdev->ctl_ops->init)(kdev) != 0) { 278 goto fail; 279 } 280 281 list_append(&kdev->kbd_devs, &kbd_devs); 282 return EOK; 283 fail: 284 free(kdev); 285 return -1; 256 286 } 257 287 … … 309 339 kbd_add_dev(&ns16550_port, &sun_ctl); 310 340 #endif 341 /* Silence warning on abs32le about kbd_add_dev() being unused */ 342 (void) kbd_add_dev; 311 343 } 312 344 … … 337 369 } 338 370 371 /** Periodically check for new kbdev devices in /dev/class/keyboard. 372 * 373 * @param arg Ignored 374 */ 375 static int dev_discovery_fibril(void *arg) 376 { 377 char *dev_path; 378 size_t id = 1; 379 int rc; 380 381 while (true) { 382 async_usleep(DISCOVERY_POLL_INTERVAL); 383 384 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", id); 385 if (rc < 0) 386 continue; 387 388 if (kbd_add_kbdev(dev_path) == EOK) { 389 printf(NAME ": Connected kbdev device '%s'\n", 390 dev_path); 391 392 /* XXX Handle device removal */ 393 ++id; 394 } 395 396 free(dev_path); 397 } 398 399 return EOK; 400 } 401 402 /** Start a fibril for discovering new devices. */ 403 static void kbd_start_dev_discovery(void) 404 { 405 fid_t fid; 406 407 fid = fibril_create(dev_discovery_fibril, NULL); 408 if (!fid) { 409 printf(NAME ": Failed to create device discovery fibril.\n"); 410 return; 411 } 412 413 fibril_add_ready(fid); 414 } 415 339 416 int main(int argc, char **argv) 340 417 { … … 357 434 /* Add legacy devices. */ 358 435 kbd_add_legacy_devs(); 359 360 /* Add kbdev device */361 kbd_add_dev(NULL, &kbdev_ctl);362 436 363 437 /* Initialize (reset) layout. */ … … 380 454 } 381 455 456 /* Start looking for new kbdev devices */ 457 kbd_start_dev_discovery(); 458 382 459 printf(NAME ": Accepting connections\n"); 383 460 async_manager(); -
uspace/srv/hid/kbd/include/kbd.h
rf2f99ae raf897ff0 42 42 #include <bool.h> 43 43 44 #define NAME "kbd" 45 #define NAMESPACE "hid_in" 46 44 47 struct kbd_port_ops; 45 48 struct kbd_ctl_ops; … … 48 51 /** Link to kbd_devs list */ 49 52 link_t kbd_devs; 53 54 /** Path to the device (only for kbdev devices) */ 55 const char *dev_path; 50 56 51 57 /** Port ops */ -
uspace/srv/hid/kbd/port/chardev.c
rf2f99ae raf897ff0 44 44 #include <errno.h> 45 45 #include <stdio.h> 46 47 #define NAME "kbd/chardev"48 46 49 47 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
Note:
See TracChangeset
for help on using the changeset viewer.