Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a2afd8f in mainline


Ignore:
Timestamp:
2017-11-13T18:07:46Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
0dd4779
Parents:
56763a4
Message:

Move ADB keyboard and mouse support to separate drivers.

Files:
10 added
2 deleted
11 edited
2 moved

Legend:

Unmodified
Added
Removed
  • .gitignore

    r56763a4 ra2afd8f  
    306306uspace/drv/fb/amdm37x_dispc/amdm37x_dispc
    307307uspace/drv/fb/kfb/kfb
     308uspace/drv/hid/adb-kbd/adb-kbd
     309uspace/drv/hid/adb-mouse/adb-mouse
    308310uspace/drv/hid/atkbd/atkbd
    309311uspace/drv/hid/xtkbd/xtkbd
  • boot/arch/ppc32/Makefile.inc

    r56763a4 ra2afd8f  
    5252        bus/usb/vhc \
    5353        block/usbmast \
     54        hid/adb-kbd \
     55        hid/adb-mouse \
    5456        hid/usbhid
    5557
  • uspace/Makefile

    r56763a4 ra2afd8f  
    162162        drv/fb/amdm37x_dispc \
    163163        drv/fb/kfb \
     164        drv/hid/adb-kbd \
     165        drv/hid/adb-mouse \
    164166        drv/hid/atkbd \
    165167        drv/hid/ps2mouse \
  • uspace/drv/bus/adb/cuda_adb/cuda_adb.c

    r56763a4 ra2afd8f  
    109109};
    110110
    111 static int cuda_dev_create(cuda_t *cuda, const char *name, adb_dev_t **rdev)
     111static int cuda_dev_create(cuda_t *cuda, const char *name, const char *id,
     112    adb_dev_t **rdev)
    112113{
    113114        adb_dev_t *dev = NULL;
     
    115116        int rc;
    116117
    117         fun = ddf_fun_create(cuda->dev, fun_exposed, name);
     118        fun = ddf_fun_create(cuda->dev, fun_inner, name);
    118119        if (fun == NULL) {
    119120                ddf_msg(LVL_ERROR, "Failed creating function '%s'.", name);
     121                rc = ENOMEM;
     122                goto error;
     123        }
     124
     125        rc = ddf_fun_add_match_id(fun, id, 10);
     126        if (rc != EOK) {
     127                ddf_msg(LVL_ERROR, "Failed adding match ID.");
    120128                rc = ENOMEM;
    121129                goto error;
     
    156164        cuda->phys_base = res->base;
    157165
    158         rc = cuda_dev_create(cuda, "kbd", &kbd);
     166        rc = cuda_dev_create(cuda, "kbd", "adb/keyboard", &kbd);
    159167        if (rc != EOK)
    160168                goto error;
    161169
    162         rc = cuda_dev_create(cuda, "mouse", &mouse);
     170        rc = cuda_dev_create(cuda, "mouse", "adb/mouse", &mouse);
    163171        if (rc != EOK)
    164172                goto error;
  • uspace/drv/char/msim-con/msim-con.h

    r56763a4 ra2afd8f  
    4747} msim_con_t;
    4848
    49 extern int msim_con_init(msim_con_t *);
    50 extern void msim_con_write(uint8_t data);
    51 
    52 
    5349extern int msim_con_add(msim_con_t *);
    5450extern int msim_con_remove(msim_con_t *);
  • uspace/drv/hid/adb-kbd/ctl.c

    r56763a4 ra2afd8f  
    2727 */
    2828
    29 /** @addtogroup kbd_ctl
    30  * @ingroup input
    31  * @{
    32  */
    3329/**
    3430 * @file
    35  * @brief Apple ADB keyboard controller driver.
    36  */
    37 
     31 * @brief Apple ADB keyboard controller
     32 */
     33
     34#include <errno.h>
    3835#include <io/console.h>
    3936#include <io/keycode.h>
    40 #include "../kbd.h"
    41 #include "../kbd_ctl.h"
    42 #include "../kbd_port.h"
    43 
    44 static void apple_ctl_parse(sysarg_t);
    45 static int apple_ctl_init(kbd_dev_t *);
    46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned int);
    47 
    48 kbd_ctl_ops_t apple_ctl = {
    49         .parse = apple_ctl_parse,
    50         .init = apple_ctl_init,
    51         .set_ind = apple_ctl_set_ind
    52 };
     37
     38#include "ctl.h"
    5339
    5440#define KBD_KEY_RELEASE  0x80
     
    185171};
    186172
    187 static kbd_dev_t *kbd_dev;
    188 
    189 static int apple_ctl_init(kbd_dev_t *kdev)
     173/** Translate ADB keyboard scancode into keyboard event.
     174 *
     175 * @param scancode Scancode
     176 * @param rtype Place to store type of keyboard event (press or release)
     177 * @param rkey Place to store key code
     178 *
     179 * @return EOK on success, ENOENT if no translation exists
     180 */
     181int adb_kbd_key_translate(sysarg_t scancode, kbd_event_type_t *rtype,
     182    unsigned int *rkey)
    190183{
    191         kbd_dev = kdev;
    192         return 0;
    193 }
    194 
    195 static void apple_ctl_parse(sysarg_t scancode)
    196 {
    197         kbd_event_type_t type;
    198        
     184        kbd_event_type_t etype;
     185        unsigned int key;
     186
    199187        if (scancode & KBD_KEY_RELEASE) {
    200188                scancode &= ~KBD_KEY_RELEASE;
    201                 type = KEY_RELEASE;
    202         } else
    203                 type = KEY_PRESS;
    204        
     189                etype = KEY_RELEASE;
     190        } else {
     191                etype = KEY_PRESS;
     192        }
     193
    205194        if (scancode >= sizeof(scanmap) / sizeof(unsigned int))
    206                 return;
    207        
    208         unsigned int key = scanmap[scancode];
    209         if (key != 0)
    210                 kbd_push_event(kbd_dev, type, key);
     195                return ENOENT;
     196
     197        key = scanmap[scancode];
     198        if (key == 0)
     199                return ENOENT;
     200
     201        *rtype = etype;
     202        *rkey = key;
     203        return EOK;
    211204}
    212205
    213 static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    214 {
    215         (void) mods;
    216 }
    217 
    218206/** @}
    219207 */
  • uspace/drv/hid/adb-mouse/adb-mouse.h

    r56763a4 ra2afd8f  
    11/*
    2  * Copyright (c) 2011 Martin Decky
     2 * Copyright (c) 2017 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse_proto
    30  * @ingroup input
    31  * @{
    32  */
    33 /**
    34  * @file
    35  * @brief ADB protocol driver.
     29/** @file ADB mouse driver
    3630 */
    3731
     32#ifndef ADB_MOUSE_H
     33#define ADB_MOUSE_H
     34
     35#include <async.h>
     36#include <ddf/driver.h>
    3837#include <stdbool.h>
    39 #include "../mouse.h"
    40 #include "../mouse_port.h"
    41 #include "../mouse_proto.h"
    4238
    43 static mouse_dev_t *mouse_dev;
    44 static bool b1_pressed;
    45 static bool b2_pressed;
     39/** ADB mouse */
     40typedef struct {
     41        ddf_dev_t *dev;
     42        async_sess_t *parent_sess;
     43        ddf_fun_t *fun;
     44        async_sess_t *client_sess;
     45        bool b1_pressed;
     46        bool b2_pressed;
     47} adb_mouse_t;
    4648
    47 static int adb_proto_init(mouse_dev_t *mdev)
    48 {
    49         mouse_dev = mdev;
    50         b1_pressed = false;
    51         b2_pressed = false;
    52        
    53         return 0;
    54 }
     49extern int adb_mouse_add(adb_mouse_t *);
     50extern int adb_mouse_remove(adb_mouse_t *);
     51extern int adb_mouse_gone(adb_mouse_t *);
    5552
    56 /** Process mouse data */
    57 static void adb_proto_parse(sysarg_t data)
    58 {
    59         bool b1, b2;
    60         uint16_t udx, udy;
    61         int dx, dy;
    62        
    63         /* Extract fields. */
    64         b1 = ((data >> 15) & 1) == 0;
    65         udy = (data >> 8) & 0x7f;
    66         b2 = ((data >> 7) & 1) == 0;
    67         udx = data & 0x7f;
    68        
    69         /* Decode 7-bit two's complement signed values. */
    70         dx = (udx & 0x40) ? (udx - 0x80) : udx;
    71         dy = (udy & 0x40) ? (udy - 0x80) : udy;
    72        
    73         if (b1 != b1_pressed) {
    74                 mouse_push_event_button(mouse_dev, 1, b1);
    75                 b1_pressed = b1;
    76         }
    77        
    78         if (b2 != b2_pressed) {
    79                 mouse_push_event_button(mouse_dev, 2, b2);
    80                 b1_pressed = b1;
    81         }
    82        
    83         if (dx != 0 || dy != 0)
    84                 mouse_push_event_move(mouse_dev, dx, dy, 0);
    85 }
     53#endif
    8654
    87 mouse_proto_ops_t adb_proto = {
    88         .parse = adb_proto_parse,
    89         .init = adb_proto_init
    90 };
    91 
    92 /**
    93  * @}
     55/** @}
    9456 */
  • uspace/srv/hid/input/Makefile

    r56763a4 ra2afd8f  
    3737        layout/us_dvorak.c \
    3838        layout/ar.c \
    39         port/adb.c \
    40         port/adb_mouse.c \
    4139        port/chardev.c \
    42         proto/adb.c \
    4340        proto/mousedev.c \
    44         ctl/apple.c \
    4541        ctl/kbdev.c \
    4642        ctl/stty.c \
  • uspace/srv/hid/input/input.c

    r56763a4 ra2afd8f  
    458458}
    459459
    460 /** Add new legacy mouse device. */
    461 static void mouse_add_dev(mouse_port_ops_t *port, mouse_proto_ops_t *proto)
    462 {
    463         mouse_dev_t *mdev = mouse_dev_new();
    464         if (mdev == NULL)
    465                 return;
    466        
    467         mdev->port_ops = port;
    468         mdev->proto_ops = proto;
    469         mdev->svc_id = 0;
    470        
    471         /* Initialize port driver. */
    472         if ((*mdev->port_ops->init)(mdev) != 0)
    473                 goto fail;
    474        
    475         /* Initialize protocol driver. */
    476         if ((*mdev->proto_ops->init)(mdev) != 0) {
    477                 /* XXX Uninit port */
    478                 goto fail;
    479         }
    480        
    481         list_append(&mdev->link, &mouse_devs);
    482         return;
    483        
    484 fail:
    485         free(mdev);
    486 }
    487 
    488460/** Add new kbdev device.
    489461 *
     
    643615        kbd_add_dev(&chardev_port, &stty_ctl);
    644616#endif
    645 #if defined(UARCH_ppc32)
    646         kbd_add_dev(&adb_port, &apple_ctl);
    647 #endif
    648617#if defined(UARCH_sparc64) && defined(PROCESSOR_sun4v)
    649618        kbd_add_dev(&chardev_port, &stty_ctl);
     
    651620        /* Silence warning on abs32le about kbd_add_dev() being unused */
    652621        (void) kbd_add_dev;
    653 }
    654 
    655 /** Add legacy drivers/devices. */
    656 static void mouse_add_legacy_devs(void)
    657 {
    658         /*
    659          * Need to add these drivers based on config unless we can probe
    660          * them automatically.
    661          */
    662 #if defined(UARCH_ppc32)
    663         mouse_add_dev(&adb_mouse_port, &adb_proto);
    664 #endif
    665         /* Silence warning on abs32le about mouse_add_dev() being unused */
    666         (void) mouse_add_dev;
    667622}
    668623
     
    895850        kbd_add_legacy_devs();
    896851       
    897         /* Add legacy mouse devices. */
    898         mouse_add_legacy_devs();
    899        
    900852        /* Register driver */
    901853        async_set_client_data_constructor(client_data_create);
  • uspace/srv/hid/input/kbd_ctl.h

    r56763a4 ra2afd8f  
    4848} kbd_ctl_ops_t;
    4949
    50 extern kbd_ctl_ops_t apple_ctl;
    5150extern kbd_ctl_ops_t kbdev_ctl;
    5251extern kbd_ctl_ops_t stty_ctl;
  • uspace/srv/hid/input/kbd_port.h

    r56763a4 ra2afd8f  
    4747} kbd_port_ops_t;
    4848
    49 extern kbd_port_ops_t adb_port;
    5049extern kbd_port_ops_t chardev_port;
    5150extern kbd_port_ops_t ns16550_port;
  • uspace/srv/hid/input/mouse_port.h

    r56763a4 ra2afd8f  
    4747} mouse_port_ops_t;
    4848
    49 extern mouse_port_ops_t adb_mouse_port;
    5049extern mouse_port_ops_t chardev_mouse_port;
    5150
  • uspace/srv/hid/input/mouse_proto.h

    r56763a4 ra2afd8f  
    4747} mouse_proto_ops_t;
    4848
    49 extern mouse_proto_ops_t adb_proto;
    5049extern mouse_proto_ops_t mousedev_proto;
    5150
Note: See TracChangeset for help on using the changeset viewer.