| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2014 Martin Decky
|
|---|
| 3 | *
|
|---|
| 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /** @addtogroup libdrv
|
|---|
| 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <async.h>
|
|---|
| 14 | #include <errno.h>
|
|---|
| 15 | #include <io/pixel.h>
|
|---|
| 16 | #include <macros.h>
|
|---|
| 17 | #include <device/led_dev.h>
|
|---|
| 18 | #include <ops/led_dev.h>
|
|---|
| 19 | #include <ddf/driver.h>
|
|---|
| 20 |
|
|---|
| 21 | static void remote_led_color_set(ddf_fun_t *, void *, ipc_call_t *);
|
|---|
| 22 |
|
|---|
| 23 | /** Remote LED interface operations */
|
|---|
| 24 | static const remote_iface_func_ptr_t remote_led_dev_iface_ops[] = {
|
|---|
| 25 | [LED_DEV_COLOR_SET] = remote_led_color_set
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | /** Remote LED interface structure
|
|---|
| 29 | *
|
|---|
| 30 | * Interface for processing requests from remote clients
|
|---|
| 31 | * addressed by the LED interface.
|
|---|
| 32 | *
|
|---|
| 33 | */
|
|---|
| 34 | const remote_iface_t remote_led_dev_iface = {
|
|---|
| 35 | .method_count = ARRAY_SIZE(remote_led_dev_iface_ops),
|
|---|
| 36 | .methods = remote_led_dev_iface_ops
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | /** Process the color_set() request from the remote client
|
|---|
| 40 | *
|
|---|
| 41 | * @param fun The function to which the data are written
|
|---|
| 42 | * @param ops The local ops structure
|
|---|
| 43 | *
|
|---|
| 44 | */
|
|---|
| 45 | static void remote_led_color_set(ddf_fun_t *fun, void *ops, ipc_call_t *call)
|
|---|
| 46 | {
|
|---|
| 47 | led_dev_ops_t *led_dev_ops = (led_dev_ops_t *) ops;
|
|---|
| 48 | pixel_t color = DEV_IPC_GET_ARG1(*call);
|
|---|
| 49 |
|
|---|
| 50 | if (!led_dev_ops->color_set) {
|
|---|
| 51 | async_answer_0(call, ENOTSUP);
|
|---|
| 52 | return;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | errno_t rc = (*led_dev_ops->color_set)(fun, color);
|
|---|
| 56 | async_answer_0(call, rc);
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | /**
|
|---|
| 60 | * @}
|
|---|
| 61 | */
|
|---|