1.1 --- a/pkg/devices/backlight/src/pwm/backlight-pwm.cc Wed Dec 30 22:51:48 2020 +0100
1.2 +++ b/pkg/devices/backlight/src/pwm/backlight-pwm.cc Thu Dec 31 01:11:34 2020 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Access a PWM server to update a display panel backlight.
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 @@ -19,15 +19,15 @@
1.13 * Boston, MA 02110-1301, USA
1.14 */
1.15
1.16 -#include <l4/cxx/ipc_server>
1.17 #include <l4/re/env>
1.18 -#include <l4/re/util/object_registry>
1.19 #include <l4/sys/capability>
1.20
1.21 #include <stdlib.h>
1.22
1.23 #include <l4/devices/pwm-client.h>
1.24 -#include "backlight-ops.h"
1.25 +
1.26 +#include <ipc/server.h>
1.27 +#include "backlight_object_server.h"
1.28
1.29 /* PWM access abstractions. */
1.30
1.31 @@ -37,66 +37,41 @@
1.32
1.33 /* Backlight device. */
1.34
1.35 -class Backlight_device_server : public L4::Server_object_t<L4::Kobject>
1.36 +class server_BacklightObject : public BacklightObject
1.37 {
1.38 int _min, _max;
1.39
1.40 public:
1.41 - explicit Backlight_device_server(int min, int max)
1.42 + explicit server_BacklightObject(int min, int max)
1.43 : _min(min), _max(max)
1.44 {
1.45 }
1.46
1.47 - /* Dispatch incoming requests. */
1.48 -
1.49 - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
1.50 - {
1.51 - l4_msgtag_t tag;
1.52 - int arg;
1.53 -
1.54 - (void) obj;
1.55 - ios >> tag;
1.56 + /* Disable the backlight. */
1.57
1.58 - switch (tag.label())
1.59 - {
1.60 - case Backlight_op_disable:
1.61 - disable();
1.62 - return L4_EOK;
1.63 -
1.64 - case Backlight_op_enable:
1.65 - enable();
1.66 - return L4_EOK;
1.67 -
1.68 - case Backlight_op_set_brightness:
1.69 - ios >> arg;
1.70 - set_brightness(arg);
1.71 - return L4_EOK;
1.72 -
1.73 - default:
1.74 - return -L4_EBADPROTO;
1.75 - }
1.76 + long disable()
1.77 + {
1.78 + pwm_device->disable();
1.79 + return L4_EOK;
1.80 }
1.81
1.82 - void disable()
1.83 - {
1.84 - pwm_device->disable();
1.85 - }
1.86 + /* Enable the backlight. */
1.87
1.88 - void enable()
1.89 + long enable()
1.90 {
1.91 pwm_device->enable();
1.92 + return L4_EOK;
1.93 }
1.94
1.95 /* Use the PWM device to update the backlight level. */
1.96
1.97 - void set_brightness(int level)
1.98 + long set_brightness(int level)
1.99 {
1.100 pwm_device->set_duty(level);
1.101 + return L4_EOK;
1.102 }
1.103 };
1.104
1.105 -static L4Re::Util::Registry_server<> server;
1.106 -
1.107
1.108
1.109 /* Arguments: <minimum level> <maximum level> */
1.110 @@ -118,11 +93,14 @@
1.111 min = atoi(argv[1]);
1.112 max = atoi(argv[2]);
1.113
1.114 - Backlight_device_server server_obj(min, max);
1.115 - server.registry()->register_obj(&server_obj, "backlight");
1.116 + server_BacklightObject obj(min, max);
1.117 + l4_cap_idx_t server;
1.118 +
1.119 + if (ipc_server_bind("backlight", (l4_umword_t) &obj, &server)) return 1;
1.120
1.121 /* Enter the IPC server loop. */
1.122
1.123 - server.loop();
1.124 + ipc_server_loop(BacklightObject_expected_items, &obj,
1.125 + (ipc_server_handler_type) handle_BacklightObject);
1.126 return 0;
1.127 }