1.1 --- a/pkg/landfall-examples/qi_lb60_keypad_physical/qi_lb60_keypad_physical.c Mon Jun 19 16:58:52 2023 +0200
1.2 +++ b/pkg/landfall-examples/qi_lb60_keypad_physical/qi_lb60_keypad_physical.c Mon Jun 19 16:59:21 2023 +0200
1.3 @@ -20,20 +20,19 @@
1.4 */
1.5
1.6 #include <l4/re/c/rm.h>
1.7 -#include <l4/re/c/util/cap_alloc.h>
1.8 #include <l4/re/env.h>
1.9 -#include <l4/util/util.h>
1.10 -#include <l4/sys/ipc.h>
1.11
1.12 #include <l4/re/c/util/video/goos_fb.h>
1.13 #include <l4/re/c/video/view.h>
1.14
1.15 -#include <l4/util/util.h>
1.16 -#include <stdio.h>
1.17 #include <unistd.h>
1.18 #include <stdint.h>
1.19 #include <stdlib.h>
1.20
1.21 +#include "keypad_client.h"
1.22 +
1.23 +
1.24 +
1.25 enum Jz4740_keypad_gpio
1.26 {
1.27 Jz4740_keypad_gpio_inputs_count = 8,
1.28 @@ -48,8 +47,7 @@
1.29
1.30 /* Keypad status and dimensions. */
1.31
1.32 -uint32_t *keypad = 0;
1.33 -void *keymem = 0;
1.34 +uint32_t *keymem = 0;
1.35 int columns = Jz4740_keypad_gpio_outputs_count, rows = Jz4740_keypad_gpio_inputs_count;
1.36
1.37 /* Position units. */
1.38 @@ -246,7 +244,7 @@
1.39 /* Plot the rectangle for the key. */
1.40
1.41 fill_rectangle((pos[0] * fbi.width) / WIDTH, pos[1] * rowsize, colsize, rowsize,
1.42 - keypad[column] & mask ? 0xffffff : 0);
1.43 + keymem[column] & mask ? 0xffffff : 0);
1.44 }
1.45
1.46 /* Refresh the display. */
1.47 @@ -258,9 +256,8 @@
1.48
1.49 int main(void)
1.50 {
1.51 - l4_cap_idx_t keypad_server;
1.52 + l4_cap_idx_t keypad_cap;
1.53 l4re_ds_t mem;
1.54 - l4_msgtag_t tag;
1.55
1.56 if (l4re_util_video_goos_fb_setup_name(&gfb, "fb"))
1.57 return 1;
1.58 @@ -273,28 +270,21 @@
1.59
1.60 /* Obtain a reference to the keypad. */
1.61
1.62 - keypad_server = l4re_env_get_cap("keypad");
1.63 - if (l4_is_invalid_cap(keypad_server)) return 1;
1.64 + keypad_cap = l4re_env_get_cap("keypad");
1.65
1.66 - /* Obtain a capability for the keypad data. */
1.67 -
1.68 - mem = l4re_util_cap_alloc();
1.69 - if (l4_is_invalid_cap(mem)) return 1;
1.70 + if (l4_is_invalid_cap(keypad_cap))
1.71 + return 1;
1.72
1.73 /* Obtain a reference to the keypad data. */
1.74
1.75 - l4_utcb_br()->bdr = 0;
1.76 - l4_utcb_br()->br[0] = L4_RCV_ITEM_SINGLE_CAP | mem;
1.77 + Keypad keypad = {.ref={.cap=keypad_cap}, .iface=&client_iface_Keypad};
1.78
1.79 - tag = l4_ipc_call(keypad_server, l4_utcb(),
1.80 - l4_msgtag(0, 0, 0, 0), /* label zero, zero words, zero *sent* items */
1.81 - L4_IPC_NEVER);
1.82 -
1.83 - if (l4_ipc_error(tag, l4_utcb())) return 1;
1.84 + if (keypad.iface->get_keypad_data(keypad.ref, &mem))
1.85 + return 1;
1.86
1.87 /* Attach the keypad data to a region in this task. */
1.88
1.89 - if (l4re_rm_attach(&keymem, l4re_ds_size(mem),
1.90 + if (l4re_rm_attach((void **) &keymem, l4re_ds_size(mem),
1.91 L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R,
1.92 mem, 0,
1.93 L4_PAGESHIFT))
1.94 @@ -302,9 +292,8 @@
1.95
1.96 /* Show the keypad state. */
1.97
1.98 - keypad = (uint32_t *) keymem;
1.99 -
1.100 - while (1) show_keypad();
1.101 + while (1)
1.102 + show_keypad();
1.103
1.104 return 0;
1.105 }