|
1 | 1 | /*
|
2 | 2 | * Copyright (c) 2023 Google LLC.
|
| 3 | + * Copyright (c) 2024 Croxel Inc. |
3 | 4 | *
|
4 | 5 | * SPDX-License-Identifier: Apache-2.0
|
5 | 6 | */
|
|
9 | 10 | #include <zephyr/drivers/sensor.h>
|
10 | 11 | #include <zephyr/dsp/types.h>
|
11 | 12 | #include <zephyr/logging/log.h>
|
| 13 | +#include <zephyr/rtio/work.h> |
12 | 14 |
|
13 | 15 | LOG_MODULE_REGISTER(sensor_compat, CONFIG_SENSOR_LOG_LEVEL);
|
14 | 16 |
|
@@ -106,14 +108,14 @@ static inline int check_header_contains_channel(const struct sensor_data_generic
|
106 | 108 | }
|
107 | 109 |
|
108 | 110 | /**
|
109 |
| - * @brief Fallback function for retrofiting old drivers to rtio |
| 111 | + * @brief Fallback function for retrofiting old drivers to rtio (sync) |
110 | 112 | *
|
111 |
| - * @param[in] dev The sensor device to read |
112 | 113 | * @param[in] iodev_sqe The read submission queue event
|
113 | 114 | */
|
114 |
| -static void sensor_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) |
| 115 | +static void sensor_submit_fallback_sync(struct rtio_iodev_sqe *iodev_sqe) |
115 | 116 | {
|
116 | 117 | const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data;
|
| 118 | + const struct device *dev = cfg->sensor; |
117 | 119 | const struct sensor_chan_spec *const channels = cfg->channels;
|
118 | 120 | const int num_output_samples = compute_num_samples(channels, cfg->count);
|
119 | 121 | uint32_t min_buf_len = compute_min_buf_len(num_output_samples);
|
@@ -253,6 +255,21 @@ static void sensor_submit_fallback(const struct device *dev, struct rtio_iodev_s
|
253 | 255 | rtio_iodev_sqe_ok(iodev_sqe, 0);
|
254 | 256 | }
|
255 | 257 |
|
| 258 | +/** |
| 259 | + * @brief Fallback function for retrofiting old drivers to rtio |
| 260 | + * |
| 261 | + * @param[in] dev The sensor device to read |
| 262 | + * @param[in] iodev_sqe The read submission queue event |
| 263 | + */ |
| 264 | +static void sensor_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe) |
| 265 | +{ |
| 266 | + struct rtio_work_req *req = rtio_work_req_alloc(); |
| 267 | + |
| 268 | + __ASSERT_NO_MSG(req); |
| 269 | + |
| 270 | + rtio_work_req_submit(req, iodev_sqe, sensor_submit_fallback_sync); |
| 271 | +} |
| 272 | + |
256 | 273 | void sensor_processing_with_callback(struct rtio *ctx, sensor_processing_callback_t cb)
|
257 | 274 | {
|
258 | 275 | void *userdata = NULL;
|
|
0 commit comments