1.1 --- a/pkg/devices/display/src/letux400/display-letux400.cc Wed Dec 30 22:51:48 2020 +0100
1.2 +++ b/pkg/devices/display/src/letux400/display-letux400.cc Thu Dec 31 01:11:34 2020 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Export Letux 400 display operations as a server.
1.6 *
1.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -20,24 +20,21 @@
1.13 */
1.14
1.15 #include <l4/devices/gpio-jz4730.h>
1.16 -#include <l4/devices/backlight-client.h>
1.17 #include <l4/devices/memory.h>
1.18
1.19 -#include <l4/cxx/ipc_server>
1.20 -#include <l4/re/env>
1.21 -#include <l4/re/util/object_registry>
1.22 -#include <l4/sys/capability>
1.23 +#include <l4/re/env.h>
1.24
1.25 -#include "display-ops.h"
1.26 +#include <ipc/server.h>
1.27 +#include "activation_client.h"
1.28 +#include "activation_server.h"
1.29
1.30 /* Virtual address for the GPIO register block. */
1.31
1.32 static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0;
1.33
1.34 -/* GPIO and backlight device abstractions. */
1.35 +/* GPIO abstraction. */
1.36
1.37 static Gpio_jz4730_chip *gpio_port_b = 0, *gpio_port_c = 0;
1.38 -static L4::Cap<Backlight_device_interface> backlight_device;
1.39
1.40
1.41
1.42 @@ -67,15 +64,18 @@
1.43
1.44
1.45
1.46 -/* Display device. */
1.47 +/* Display device only implementing the activation interface. */
1.48
1.49 -class Display_device_server : public L4::Server_object_t<L4::Kobject>
1.50 +class server_DisplayObject : public Activation
1.51 {
1.52 Pin_slice lcd_mask1 = {.offset=0, .mask=Jz4730_lcd_gpio_func1};
1.53 Pin_slice lcd_mask2 = {.offset=0, .mask=Jz4730_lcd_gpio_func2};
1.54
1.55 + Activation *_backlight;
1.56 +
1.57 public:
1.58 - explicit Display_device_server()
1.59 + explicit server_DisplayObject(Activation *backlight)
1.60 + : _backlight(backlight)
1.61 {
1.62 /* Set functions for the LCD pins. */
1.63
1.64 @@ -88,49 +88,25 @@
1.65 gpio_port_c->setup(Jz4730_lcd_gpio_display_enable, Hw::Gpio_chip::Output, 0);
1.66 }
1.67
1.68 - /* Dispatch incoming requests. */
1.69 -
1.70 - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
1.71 - {
1.72 - l4_msgtag_t tag;
1.73 -
1.74 - (void) obj;
1.75 - ios >> tag;
1.76 -
1.77 - switch (tag.label())
1.78 - {
1.79 - case Display_op_disable:
1.80 - disable();
1.81 - return L4_EOK;
1.82 -
1.83 - case Display_op_enable:
1.84 - enable();
1.85 - return L4_EOK;
1.86 -
1.87 - default:
1.88 - return -L4_EBADPROTO;
1.89 - }
1.90 - }
1.91 -
1.92 /* Switch the display off. */
1.93
1.94 - void disable(void)
1.95 + long disable(void)
1.96 {
1.97 gpio_port_c->setup(Jz4730_lcd_gpio_display_enable, Hw::Gpio_chip::Output, 0);
1.98 - backlight_device->disable();
1.99 + _backlight->disable();
1.100 + return L4_EOK;
1.101 }
1.102
1.103 /* Switch the display on. */
1.104
1.105 - void enable(void)
1.106 + long enable(void)
1.107 {
1.108 gpio_port_c->setup(Jz4730_lcd_gpio_display_enable, Hw::Gpio_chip::Output, 1);
1.109 - backlight_device->enable();
1.110 + _backlight->enable();
1.111 + return L4_EOK;
1.112 }
1.113 };
1.114
1.115 -static L4Re::Util::Registry_server<> server;
1.116 -
1.117
1.118
1.119 int main(void)
1.120 @@ -147,16 +123,23 @@
1.121
1.122 /* Obtain a reference to the backlight device. */
1.123
1.124 - backlight_device = L4Re::Env::env()->get_cap<Backlight_device_interface>("backlight");
1.125 - if (!backlight_device.is_valid()) return 1;
1.126 + l4_cap_idx_t backlight = l4re_env_get_cap("backlight");
1.127 + if (!l4_is_valid_cap(backlight)) return 1;
1.128 +
1.129 + /* Use the activation interface with the backlight. */
1.130 +
1.131 + client_Activation backlight_obj(backlight);
1.132
1.133 /* Initialise and register a new server object. */
1.134
1.135 - Display_device_server server_obj;
1.136 - server.registry()->register_obj(&server_obj, "display");
1.137 + server_DisplayObject obj(&backlight_obj);
1.138 + l4_cap_idx_t server;
1.139 +
1.140 + if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1;
1.141
1.142 /* Enter the IPC server loop. */
1.143
1.144 - server.loop();
1.145 + ipc_server_loop(Activation_expected_items, &obj,
1.146 + (ipc_server_handler_type) handle_Activation);
1.147 return 0;
1.148 }