Changeset 56ad818 in mainline


Ignore:
Timestamp:
2011-06-11T20:29:41Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9be360ee
Parents:
b1bdc7a4
Message:

Control keyboard ctl modules through ops structures. Always compile in
all ctl modules.

Location:
uspace/srv/hid/kbd
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/kbd/Makefile

    rb1bdc7a4 r56ad818  
    6161        port/ski.c \
    6262        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
    15669
    15770include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/kbd/ctl/apple.c

    rb1bdc7a4 r56ad818  
    4242#include <kbd_port.h>
    4343
     44static void apple_ctl_parse_scancode(int scancode);
     45static int apple_ctl_init(kbd_port_ops_t *kbd_port);
     46static void apple_ctl_set_ind(unsigned mods);
     47
     48kbd_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
    4454#define KBD_KEY_RELEASE         0x80
    4555
    4656static int scanmap[];
    4757
    48 int kbd_ctl_init(kbd_port_ops_t *kbd_port)
     58static int apple_ctl_init(kbd_port_ops_t *kbd_port)
    4959{
    5060        (void) kbd_port;
     
    5262}
    5363
    54 void kbd_ctl_parse_scancode(int scancode)
     64static void apple_ctl_parse_scancode(int scancode)
    5565{
    5666        kbd_event_type_t type;
     
    7282}
    7383
    74 void kbd_ctl_set_ind(unsigned mods)
     84static void apple_ctl_set_ind(unsigned mods)
    7585{
    7686        (void) mods;
  • uspace/srv/hid/kbd/ctl/gxe_fb.c

    rb1bdc7a4 r56ad818  
    4444#include <stroke.h>
    4545
     46static void gxe_fb_ctl_parse_scancode(int scancode);
     47static int gxe_fb_ctl_init(kbd_port_ops_t *kbd_port);
     48static void gxe_fb_ctl_set_ind(unsigned mods);
     49
     50kbd_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
    4656/** Scancode parser */
    4757static gsp_t sp;
     
    5262#include <stdio.h>
    5363
    54 int seq_defs[] = {
     64static int seq_defs[] = {
    5565        /* Not shifted */
    5666
     
    208218};
    209219
    210 int kbd_ctl_init(kbd_port_ops_t *kbd_port)
     220static int gxe_fb_ctl_init(kbd_port_ops_t *kbd_port)
    211221{
    212222        (void) kbd_port;
     
    217227}
    218228
    219 void kbd_ctl_parse_scancode(int scancode)
     229static void gxe_fb_ctl_parse_scancode(int scancode)
    220230{
    221231        unsigned mods, key;
     
    227237}
    228238
    229 void kbd_ctl_set_ind(unsigned mods)
     239static void gxe_fb_ctl_set_ind(unsigned mods)
    230240{
    231241        (void) mods;
  • uspace/srv/hid/kbd/ctl/pc.c

    rb1bdc7a4 r56ad818  
    4343#include <gsp.h>
    4444
     45static void pc_ctl_parse_scancode(int scancode);
     46static int pc_ctl_init(kbd_port_ops_t *kbd_port);
     47static void pc_ctl_set_ind(unsigned mods);
     48
     49kbd_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
    4555enum dec_state {
    4656        ds_s,
     
    198208};
    199209
    200 int kbd_ctl_init(kbd_port_ops_t *kbd_p)
     210static int pc_ctl_init(kbd_port_ops_t *kbd_p)
    201211{
    202212        kbd_port = kbd_p;
     
    205215}
    206216
    207 void kbd_ctl_parse_scancode(int scancode)
     217static void pc_ctl_parse_scancode(int scancode)
    208218{
    209219        kbd_event_type_t type;
     
    255265}
    256266
    257 void kbd_ctl_set_ind(unsigned mods)
     267static void pc_ctl_set_ind(unsigned mods)
    258268{
    259269        uint8_t b;
  • uspace/srv/hid/kbd/ctl/stty.c

    rb1bdc7a4 r56ad818  
    4343#include <stroke.h>
    4444
     45static void stty_ctl_parse_scancode(int scancode);
     46static int stty_ctl_init(kbd_port_ops_t *kbd_port);
     47static void stty_ctl_set_ind(unsigned mods);
     48
     49kbd_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
    4555/** Scancode parser */
    4656static gsp_t sp;
     
    5161#include <stdio.h>
    5262
    53 int seq_defs[] = {
     63static int seq_defs[] = {
    5464        /* Not shifted */
    5565
     
    207217};
    208218
    209 int kbd_ctl_init(kbd_port_ops_t *kbd_port)
     219static int stty_ctl_init(kbd_port_ops_t *kbd_port)
    210220{
    211221        (void) kbd_port;
     
    216226}
    217227
    218 void kbd_ctl_parse_scancode(int scancode)
     228static void stty_ctl_parse_scancode(int scancode)
    219229{
    220230        unsigned mods, key;
     
    226236}
    227237
    228 void kbd_ctl_set_ind(unsigned mods)
     238static void stty_ctl_set_ind(unsigned mods)
    229239{
    230240        (void) mods;
  • uspace/srv/hid/kbd/ctl/sun.c

    rb1bdc7a4 r56ad818  
    4242#include <kbd_port.h>
    4343
     44static void sun_ctl_parse_scancode(int scancode);
     45static int sun_ctl_init(kbd_port_ops_t *kbd_port);
     46static void sun_ctl_set_ind(unsigned mods);
     47
     48kbd_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
    4454#define KBD_KEY_RELEASE         0x80
    4555#define KBD_ALL_KEYS_UP         0x7f
     
    4757static int scanmap_simple[];
    4858
    49 int kbd_ctl_init(kbd_port_ops_t *kbd_port)
     59static int sun_ctl_init(kbd_port_ops_t *kbd_port)
    5060{
    5161        return 0;
    5262}
    5363
    54 void kbd_ctl_parse_scancode(int scancode)
     64static void sun_ctl_parse_scancode(int scancode)
    5565{
    5666        kbd_event_type_t type;
     
    7585}
    7686
    77 void kbd_ctl_set_ind(unsigned mods)
     87static void sun_ctl_set_ind(unsigned mods)
    7888{
    7989        (void) mods;
  • uspace/srv/hid/kbd/generic/kbd.c

    rb1bdc7a4 r56ad818  
    7272
    7373static kbd_port_ops_t *kbd_port;
     74static kbd_ctl_ops_t *kbd_ctl;
    7475
    7576bool irc_service = false;
     
    8990{
    9091/*      printf("scancode: 0x%x\n", scancode);*/
    91         kbd_ctl_parse_scancode(scancode);
     92        (*kbd_ctl->parse_scancode)(scancode);
    9293}
    9394
     
    132133
    133134                        /* Update keyboard lock indicator lights. */
    134                         kbd_ctl_set_ind(mods);
     135                        (*kbd_ctl->set_ind)(mods);
    135136                } else {
    136137                        lock_keys = lock_keys & ~mod_mask;
     
    217218}
    218219
    219 static kbd_port_ops_t *kbd_select_port(void)
    220 {
    221         kbd_port_ops_t *kbd_port;
    222 
     220static void kbd_select_drivers(kbd_port_ops_t **port, kbd_ctl_ops_t **ctl)
     221{
    223222#if defined(UARCH_amd64)
    224         kbd_port = &chardev_port;
     223        *port = &chardev_port;
     224        *ctl = &pc_ctl;
    225225#elif defined(UARCH_arm32) && defined(MACHINE_gta02)
    226         kbd_port = &chardev_port;
     226        *port = &chardev_port;
     227        *ctl = &stty_ctl;
    227228#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
    229235#elif defined(UARCH_arm32) && defined(MACHINE_integratorcp)
    230         kbd_port = &pl050_port;
     236        *port = &pl050_port;
     237        *ctl = &pc_ctl;
    231238#elif defined(UARCH_ia32)
    232         kbd_port = &chardev_port;
     239        *port = &chardev_port;
     240        *ctl = &pc_ctl;
    233241#elif defined(MACHINE_i460GX)
    234         kbd_port = &chardev_port;
     242        *port = &chardev_port;
     243        *ctl = &pc_ctl;
    235244#elif defined(MACHINE_ski)
    236         kbd_port = &ski_port;
     245        *port = &ski_port;
     246        *ctl = &stty_ctl;
    237247#elif defined(MACHINE_msim)
    238         kbd_port = &msim_port;
     248        *port = &msim_port;
     249        *ctl = &stty_ctl;
    239250#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
    241257#elif defined(UARCH_ppc32)
    242         kbd_port = &adb_port;
     258        *port = &adb_port;
     259        *ctl = &apple_ctl;
    243260#elif defined(UARCH_sparc64) && defined(PROCESSOR_sun4v)
    244         kbd_port = &niagara_port;
     261        *port = &niagara_port;
     262        *ctl = &stty_ctl;
    245263#elif defined(UARCH_sparc64) && defined(MACHINE_serengeti)
    246         kbd_port = &sgcn_port;
     264        *port = &sgcn_port;
     265        *ctl = &stty_ctl;
    247266#elif defined(UARCH_sparc64) && defined(MACHINE_generic)
    248         kbd_port = &sun_port;
     267        *port = &sun_port;
     268        *ctl = &sun_ctl;
    249269#else
    250         kbd_port = &dummy_port;
     270        *port = &dummy_port;
     271        *ctl = &pc_ctl;
    251272#endif
    252         return kbd_port;
    253273}
    254274
     
    269289        }
    270290       
    271         /* Select port driver. */
    272         kbd_port = kbd_select_port();
     291        /* Select port and controller drivers. */
     292        kbd_select_drivers(&kbd_port, &kbd_ctl);
    273293
    274294        /* Initialize port driver. */
     
    277297
    278298        /* Initialize controller driver. */
    279         if (kbd_ctl_init(kbd_port) != 0)
     299        if ((*kbd_ctl->init)(kbd_port) != 0)
    280300                return -1;
    281301
  • uspace/srv/hid/kbd/include/kbd_ctl.h

    rb1bdc7a4 r56ad818  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040#include <kbd_port.h>
    4141
    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);
     42typedef struct {
     43        void (*parse_scancode)(int);
     44        int (*init)(kbd_port_ops_t *);
     45        void (*set_ind)(unsigned);
     46} kbd_ctl_ops_t;
     47
     48extern kbd_ctl_ops_t apple_ctl;
     49extern kbd_ctl_ops_t gxe_fb_ctl;
     50extern kbd_ctl_ops_t pc_ctl;
     51extern kbd_ctl_ops_t stty_ctl;
     52extern kbd_ctl_ops_t sun_ctl;
    4553
    4654#endif
Note: See TracChangeset for help on using the changeset viewer.