Lines Matching +full:channel +full:- +full:count
5 * SPDX-License-Identifier: Apache-2.0
18 * Ensure that the size of the generic header aligns with the sensor channel specifier . If it
19 * doesn't, then cores that require aligned memory access will fail to read channel[0].
27 const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data; in sensor_iodev_submit()
28 const struct device *dev = cfg->sensor; in sensor_iodev_submit()
29 const struct sensor_driver_api *api = dev->api; in sensor_iodev_submit()
31 if (api->submit != NULL) { in sensor_iodev_submit()
32 api->submit(dev, iodev_sqe); in sensor_iodev_submit()
33 } else if (!cfg->is_streaming) { in sensor_iodev_submit()
36 rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP); in sensor_iodev_submit()
90 * @brief Checks if the header already contains a given channel
93 * @param[in] channel The channel to search for
95 * @return Index of the @p channel if found or negative if not found
103 if (sensor_chan_spec_eq(header->channels[i], chan_spec)) { in check_header_contains_channel()
107 return -1; in check_header_contains_channel()
117 const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data; in sensor_submit_fallback_sync()
118 const struct device *dev = cfg->sensor; in sensor_submit_fallback_sync()
119 const struct sensor_chan_spec *const channels = cfg->channels; in sensor_submit_fallback_sync()
120 const int num_output_samples = compute_num_samples(channels, cfg->count); in sensor_submit_fallback_sync()
145 header->timestamp_ns = timestamp_ns; in sensor_submit_fallback_sync()
146 header->num_channels = num_output_samples; in sensor_submit_fallback_sync()
147 header->shift = 0; in sensor_submit_fallback_sync()
152 for (size_t i = 0, sample_idx = 0; i < cfg->count; ++i) { in sensor_submit_fallback_sync()
156 /* Get the current channel requested by the user */ in sensor_submit_fallback_sync()
160 header->channels[sample_idx++] = (struct sensor_chan_spec) { in sensor_submit_fallback_sync()
161 rc == 0 ? channels[i].chan_type - 3 : SENSOR_CHAN_MAX, in sensor_submit_fallback_sync()
164 header->channels[sample_idx++] = (struct sensor_chan_spec) { in sensor_submit_fallback_sync()
165 rc == 0 ? channels[i].chan_type - 2 : SENSOR_CHAN_MAX, in sensor_submit_fallback_sync()
168 header->channels[sample_idx++] = (struct sensor_chan_spec) { in sensor_submit_fallback_sync()
169 rc == 0 ? channels[i].chan_type - 1 : SENSOR_CHAN_MAX, in sensor_submit_fallback_sync()
173 header->channels[sample_idx++] = (struct sensor_chan_spec) { in sensor_submit_fallback_sync()
180 LOG_DBG("Failed to get channel (type: %d, index %d), skipping", in sensor_submit_fallback_sync()
185 /* Get the largest absolute value reading to set the scale for the channel */ in sensor_submit_fallback_sync()
204 int8_t new_shift = ilog2(header_scale - 1) + 1; in sensor_submit_fallback_sync()
207 sample_idx -= num_samples; in sensor_submit_fallback_sync()
208 if (header->shift < new_shift) { in sensor_submit_fallback_sync()
215 q[q_idx] = q[q_idx] >> (new_shift - header->shift); in sensor_submit_fallback_sync()
217 header->shift = new_shift; in sensor_submit_fallback_sync()
226 /* Check if the channel is already in the buffer */ in sensor_submit_fallback_sync()
228 header, header->channels[sample_idx + sample], sample_idx + sample); in sensor_submit_fallback_sync()
239 /* Convert the value to micro-units */ in sensor_submit_fallback_sync()
244 ((value_u * ((INT64_C(1) << 31) - 1)) / 1000000) >> header->shift; in sensor_submit_fallback_sync()
247 sample, value_u < 0 ? "-" : "", in sensor_submit_fallback_sync()
250 q[sample_idx + sample], header->shift); in sensor_submit_fallback_sync()
254 LOG_DBG("Total channels in header: %" PRIu32, header->num_channels); in sensor_submit_fallback_sync()
271 rtio_iodev_sqe_err(iodev_sqe, -ENOMEM); in sensor_submit_fallback()
289 rc = cqe->result; in sensor_processing_with_callback()
290 userdata = cqe->userdata; in sensor_processing_with_callback()
304 * @brief Default decoder get frame count
309 * @param[in] channel The channel to get the count for
310 * @param[in] channel_idx The index of the channel
314 static int get_frame_count(const uint8_t *buffer, struct sensor_chan_spec channel, in get_frame_count() argument
319 switch (channel.chan_type) { in get_frame_count()
321 channel.chan_type = SENSOR_CHAN_ACCEL_X; in get_frame_count()
324 channel.chan_type = SENSOR_CHAN_GYRO_X; in get_frame_count()
327 channel.chan_type = SENSOR_CHAN_MAGN_X; in get_frame_count()
330 channel.chan_type = SENSOR_CHAN_POS_DX; in get_frame_count()
335 for (size_t i = 0; i < header->num_channels; ++i) { in get_frame_count()
336 if (sensor_chan_spec_eq(header->channels[i], channel)) { in get_frame_count()
342 return -ENOTSUP; in get_frame_count()
345 int sensor_natively_supported_channel_size_info(struct sensor_chan_spec channel, size_t *base_size, in sensor_natively_supported_channel_size_info() argument
351 if (channel.chan_type >= SENSOR_CHAN_ALL) { in sensor_natively_supported_channel_size_info()
352 return -ENOTSUP; in sensor_natively_supported_channel_size_info()
355 switch (channel.chan_type) { in sensor_natively_supported_channel_size_info()
393 for (size_t i = 0; i < header->num_channels; ++i) { in get_q31_value()
394 if (sensor_chan_spec_eq(chan_spec, header->channels[i])) { in get_q31_value()
399 return -EINVAL; in get_q31_value()
408 data_out->header.base_timestamp_ns = header->timestamp_ns; in decode_three_axis()
409 data_out->header.reading_count = 1; in decode_three_axis()
410 data_out->shift = header->shift; in decode_three_axis()
411 data_out->readings[0].timestamp_delta = 0; in decode_three_axis()
414 &data_out->readings[0].values[0]); in decode_three_axis()
419 &data_out->readings[0].values[1]); in decode_three_axis()
424 &data_out->readings[0].values[2]); in decode_three_axis()
436 data_out->header.base_timestamp_ns = header->timestamp_ns; in decode_q31()
437 data_out->header.reading_count = 1; in decode_q31()
438 data_out->shift = header->shift; in decode_q31()
439 data_out->readings[0].timestamp_delta = 0; in decode_q31()
441 rc = get_q31_value(header, values, chan_spec, &data_out->readings[0].value); in decode_q31()
451 * This function will never wrap frames. If 1 channel is available in the current frame and
452 * @p max_count is 2, only 1 channel will be decoded and the frame iterator will be modified
456 * @param[in] channel The channel to decode
457 * @param[in] channel_idx The index of the channel
470 const q31_t *q = (const q31_t *)(buffer + compute_header_size(header->num_channels)); in decode()
471 int count = 0; in decode() local
474 return -EINVAL; in decode()
481 /* Check for 3d channel mappings */ in decode()
487 count = decode_three_axis(header, q, data_out, SENSOR_CHAN_ACCEL_X, in decode()
495 count = decode_three_axis(header, q, data_out, SENSOR_CHAN_GYRO_X, in decode()
503 count = decode_three_axis(header, q, data_out, SENSOR_CHAN_MAGN_X, in decode()
511 count = decode_three_axis(header, q, data_out, SENSOR_CHAN_POS_DX, in decode()
516 count = decode_q31(header, q, data_out, chan_spec); in decode()
519 if (count > 0) { in decode()
522 return count; in decode()