1.1 --- a/pkg/devices/backlight/src/pwm/backlight-pwm.cc Thu Dec 31 16:58:39 2020 +0100
1.2 +++ b/pkg/devices/backlight/src/pwm/backlight-pwm.cc Thu Dec 31 17:59:03 2020 +0100
1.3 @@ -19,19 +19,14 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 -#include <l4/re/env>
1.8 -#include <l4/sys/capability>
1.9 +#include <l4/re/env.h>
1.10
1.11 #include <stdlib.h>
1.12
1.13 -#include <l4/devices/pwm-client.h>
1.14 -
1.15 #include <ipc/server.h>
1.16 #include "backlight_object_server.h"
1.17 -
1.18 -/* PWM access abstractions. */
1.19 -
1.20 -static L4::Cap<Pwm_device_interface> pwm_device;
1.21 +#include "activation_client.h"
1.22 +#include "pwm_client.h"
1.23
1.24
1.25
1.26 @@ -39,11 +34,14 @@
1.27
1.28 class server_BacklightObject : public BacklightObject
1.29 {
1.30 + Activation *_activation;
1.31 + PWM *_pwm;
1.32 int _min, _max;
1.33
1.34 public:
1.35 - explicit server_BacklightObject(int min, int max)
1.36 - : _min(min), _max(max)
1.37 + explicit server_BacklightObject(Activation *activation, PWM *pwm,
1.38 + int min, int max)
1.39 + : _activation(activation), _pwm(pwm), _min(min), _max(max)
1.40 {
1.41 }
1.42
1.43 @@ -51,7 +49,7 @@
1.44
1.45 long disable()
1.46 {
1.47 - pwm_device->disable();
1.48 + _activation->disable();
1.49 return L4_EOK;
1.50 }
1.51
1.52 @@ -59,7 +57,7 @@
1.53
1.54 long enable()
1.55 {
1.56 - pwm_device->enable();
1.57 + _activation->enable();
1.58 return L4_EOK;
1.59 }
1.60
1.61 @@ -67,7 +65,7 @@
1.62
1.63 long set_brightness(int level)
1.64 {
1.65 - pwm_device->set_duty(level);
1.66 + _pwm->set_duty(level);
1.67 return L4_EOK;
1.68 }
1.69 };
1.70 @@ -85,15 +83,18 @@
1.71
1.72 /* Obtain a reference to the PWM device. */
1.73
1.74 - pwm_device = L4Re::Env::env()->get_cap<Pwm_device_interface>("pwm");
1.75 - if (!pwm_device.is_valid()) return 1;
1.76 + l4_cap_idx_t pwm = l4re_env_get_cap("pwm");
1.77 + if (!l4_is_valid_cap(pwm)) return 1;
1.78 +
1.79 + client_Activation activation_obj(pwm);
1.80 + client_PWM pwm_obj(pwm);
1.81
1.82 /* Initialise and register a new server object. */
1.83
1.84 min = atoi(argv[1]);
1.85 max = atoi(argv[2]);
1.86
1.87 - server_BacklightObject obj(min, max);
1.88 + server_BacklightObject obj(&activation_obj, &pwm_obj, min, max);
1.89 l4_cap_idx_t server;
1.90
1.91 if (ipc_server_bind("backlight", (l4_umword_t) &obj, &server)) return 1;