drivers/input: enable touch/kbd/mouse for goldfish event

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
This commit is contained in:
rongyichang 2024-03-20 19:24:36 +08:00 committed by Alan Carvalho de Assis
parent 0b541be56a
commit 1676206651
2 changed files with 4 additions and 29 deletions

View File

@ -15,6 +15,9 @@ if INPUT
config INPUT_GOLDFISH_EVENTS config INPUT_GOLDFISH_EVENTS
bool "Goldfish input events driver" bool "Goldfish input events driver"
select INPUT_TOUCHSCREEN
select INPUT_KEYBOARD
select INPUT_MOUSE
default n default n
config INPUT_GOLDFISH_NBUFFER config INPUT_GOLDFISH_NBUFFER

View File

@ -75,18 +75,11 @@ struct goldfish_events_s
FAR void *base; FAR void *base;
int irq; int irq;
struct work_s work; /* Supports the interrupt handling "bottom half" */ struct work_s work; /* Supports the interrupt handling "bottom half" */
#ifdef CONFIG_INPUT_MOUSE
struct mouse_lowerhalf_s mouselower; /* Mouse device lowerhalf instance */ struct mouse_lowerhalf_s mouselower; /* Mouse device lowerhalf instance */
struct mouse_report_s mousesample; /* Mouse event */ struct mouse_report_s mousesample; /* Mouse event */
#endif
#ifdef CONFIG_INPUT_KEYBOARD
struct keyboard_lowerhalf_s keyboardlower; /* Keyboard device lowerhalf instance */ struct keyboard_lowerhalf_s keyboardlower; /* Keyboard device lowerhalf instance */
#endif
#ifdef CONFIG_INPUT_TOUCHSCREEN
struct touch_lowerhalf_s touchlower; /* Touchpad device lowerhalf instance */ struct touch_lowerhalf_s touchlower; /* Touchpad device lowerhalf instance */
struct touch_sample_s touchsample; /* Touchpad event */ struct touch_sample_s touchsample; /* Touchpad event */
#endif
}; };
/**************************************************************************** /****************************************************************************
@ -104,8 +97,6 @@ goldfish_events_interrupt(int irq, FAR void *dev_id, FAR void *arg);
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_INPUT_KEYBOARD
/**************************************************************************** /****************************************************************************
* Name: goldfish_events_send_keyboard_event * Name: goldfish_events_send_keyboard_event
****************************************************************************/ ****************************************************************************/
@ -118,15 +109,12 @@ goldfish_events_send_keyboard_event(FAR struct goldfish_events_s *events,
{ {
keyboard_event(&(events->keyboardlower), keyboard_event(&(events->keyboardlower),
keyboard_translate_virtio_code(evt->code), keyboard_translate_virtio_code(evt->code),
evt->value); !evt->value);
return true; return true;
} }
return false; return false;
} }
#endif
#ifdef CONFIG_INPUT_MOUSE
/**************************************************************************** /****************************************************************************
* Name: goldfish_events_send_mouse_event * Name: goldfish_events_send_mouse_event
@ -187,9 +175,6 @@ goldfish_events_send_mouse_event(FAR struct goldfish_events_s *events,
return false; return false;
} }
#endif
#ifdef CONFIG_INPUT_TOUCHSCREEN
/**************************************************************************** /****************************************************************************
* Name: goldfish_events_send_touch_event * Name: goldfish_events_send_touch_event
@ -249,7 +234,6 @@ goldfish_events_send_touch_event(FAR struct goldfish_events_s *events,
return false; return false;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: goldfish_events_worker * Name: goldfish_events_worker
@ -273,23 +257,17 @@ static void goldfish_events_worker(FAR void *arg)
iinfo("goldfish_events_interrupt events(%" PRIu32 ", %" PRIu32 ", \ iinfo("goldfish_events_interrupt events(%" PRIu32 ", %" PRIu32 ", \
%" PRIu32 ").\n", evt.type, evt.code, evt.value); %" PRIu32 ").\n", evt.type, evt.code, evt.value);
#ifdef CONFIG_INPUT_TOUCHSCREEN
if (goldfish_events_send_touch_event(events, &evt)) if (goldfish_events_send_touch_event(events, &evt))
{ {
goto out; goto out;
} }
#endif
#ifdef CONFIG_INPUT_MOUSE
if (goldfish_events_send_mouse_event(events, &evt)) if (goldfish_events_send_mouse_event(events, &evt))
{ {
goto out; goto out;
} }
#endif
#ifdef CONFIG_INPUT_KEYBOARD
goldfish_events_send_keyboard_event(events, &evt); goldfish_events_send_keyboard_event(events, &evt);
#endif
out: out:
up_enable_irq(events->irq); up_enable_irq(events->irq);
@ -316,7 +294,6 @@ goldfish_events_interrupt(int irq, FAR void *dev_id, FAR void *arg)
static void goldfish_drivers_register(FAR struct goldfish_events_s *events) static void goldfish_drivers_register(FAR struct goldfish_events_s *events)
{ {
#ifdef CONFIG_INPUT_KEYBOARD
putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_KEY, putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_KEY,
events->base + GOLDFISH_EVENTS_SET_PAGE); events->base + GOLDFISH_EVENTS_SET_PAGE);
if (getreg32(events->base + GOLDFISH_EVENTS_LEN)) if (getreg32(events->base + GOLDFISH_EVENTS_LEN))
@ -330,9 +307,7 @@ static void goldfish_drivers_register(FAR struct goldfish_events_s *events)
CONFIG_INPUT_GOLDFISH_NBUFFER); CONFIG_INPUT_GOLDFISH_NBUFFER);
} }
} }
#endif
#ifdef CONFIG_INPUT_MOUSE
putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_REL, putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_REL,
events->base + GOLDFISH_EVENTS_SET_PAGE); events->base + GOLDFISH_EVENTS_SET_PAGE);
if (getreg32(events->base + GOLDFISH_EVENTS_LEN)) if (getreg32(events->base + GOLDFISH_EVENTS_LEN))
@ -346,9 +321,7 @@ static void goldfish_drivers_register(FAR struct goldfish_events_s *events)
CONFIG_INPUT_GOLDFISH_NBUFFER); CONFIG_INPUT_GOLDFISH_NBUFFER);
} }
} }
#endif
#ifdef CONFIG_INPUT_TOUCHSCREEN
putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_ABS, putreg32(GOLDFISH_EVENTS_PAGE_EVBITS | EV_ABS,
events->base + GOLDFISH_EVENTS_SET_PAGE); events->base + GOLDFISH_EVENTS_SET_PAGE);
if (getreg32(events->base + GOLDFISH_EVENTS_LEN)) if (getreg32(events->base + GOLDFISH_EVENTS_LEN))
@ -362,7 +335,6 @@ static void goldfish_drivers_register(FAR struct goldfish_events_s *events)
CONFIG_INPUT_GOLDFISH_NBUFFER); CONFIG_INPUT_GOLDFISH_NBUFFER);
} }
} }
#endif
} }
/**************************************************************************** /****************************************************************************