@@ -343,7 +343,7 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq
343
343
struct bma4xx_data * bma4xx = dev -> data ;
344
344
345
345
const struct sensor_read_config * cfg = iodev_sqe -> sqe .iodev -> data ;
346
- const enum sensor_channel * const channels = cfg -> channels ;
346
+ const struct sensor_chan_spec * const channels = cfg -> channels ;
347
347
const size_t num_channels = cfg -> count ;
348
348
349
349
uint32_t min_buf_len = sizeof (struct bma4xx_encoded_data );
@@ -370,7 +370,11 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq
370
370
371
371
/* Determine what channels we need to fetch */
372
372
for (int i = 0 ; i < num_channels ; i ++ ) {
373
- switch (channels [i ]) {
373
+ if (channels [i ].chan_idx != 0 ) {
374
+ LOG_ERR ("Only channel index 0 supported" );
375
+ return - ENOTSUP ;
376
+ }
377
+ switch (channels [i ].chan_type ) {
374
378
case SENSOR_CHAN_ALL :
375
379
edata -> has_accel = 1 ;
376
380
#ifdef CONFIG_BMA4XX_TEMPERATURE
@@ -389,7 +393,8 @@ static int bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_sq
389
393
break ;
390
394
#endif /* CONFIG_BMA4XX_TEMPERATURE */
391
395
default :
392
- LOG_ERR ("Requested unsupported channel ID %d" , channels [i ]);
396
+ LOG_ERR ("Requested unsupported channel type %d, idx %d" ,
397
+ channels [i ].chan_type , channels [i ].chan_idx );
393
398
return - ENOTSUP ;
394
399
}
395
400
}
@@ -436,18 +441,18 @@ static int bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_
436
441
* RTIO decoder
437
442
*/
438
443
439
- static int bma4xx_decoder_get_frame_count (const uint8_t * buffer , enum sensor_channel channel ,
440
- size_t channel_idx , uint16_t * frame_count )
444
+ static int bma4xx_decoder_get_frame_count (const uint8_t * buffer , struct sensor_chan_spec ch ,
445
+ uint16_t * frame_count )
441
446
{
442
447
const struct bma4xx_encoded_data * edata = (const struct bma4xx_encoded_data * )buffer ;
443
448
const struct bma4xx_decoder_header * header = & edata -> header ;
444
449
445
- if (channel_idx != 0 ) {
450
+ if (ch . chan_idx != 0 ) {
446
451
return - ENOTSUP ;
447
452
}
448
453
449
454
if (!header -> is_fifo ) {
450
- switch (channel ) {
455
+ switch (ch . chan_type ) {
451
456
case SENSOR_CHAN_ACCEL_X :
452
457
case SENSOR_CHAN_ACCEL_Y :
453
458
case SENSOR_CHAN_ACCEL_Z :
@@ -467,10 +472,10 @@ static int bma4xx_decoder_get_frame_count(const uint8_t *buffer, enum sensor_cha
467
472
return - ENOTSUP ;
468
473
}
469
474
470
- static int bma4xx_decoder_get_size_info (enum sensor_channel channel , size_t * base_size ,
475
+ static int bma4xx_decoder_get_size_info (struct sensor_chan_spec ch , size_t * base_size ,
471
476
size_t * frame_size )
472
477
{
473
- switch (channel ) {
478
+ switch (ch . chan_type ) {
474
479
case SENSOR_CHAN_ACCEL_X :
475
480
case SENSOR_CHAN_ACCEL_Y :
476
481
case SENSOR_CHAN_ACCEL_Z :
@@ -487,9 +492,9 @@ static int bma4xx_decoder_get_size_info(enum sensor_channel channel, size_t *bas
487
492
}
488
493
}
489
494
490
- static int bma4xx_get_shift (enum sensor_channel channel , uint8_t accel_fs , int8_t * shift )
495
+ static int bma4xx_get_shift (struct sensor_chan_spec ch , uint8_t accel_fs , int8_t * shift )
491
496
{
492
- switch (channel ) {
497
+ switch (ch . chan_type ) {
493
498
case SENSOR_CHAN_ACCEL_X :
494
499
case SENSOR_CHAN_ACCEL_Y :
495
500
case SENSOR_CHAN_ACCEL_Z :
@@ -562,9 +567,8 @@ static void bma4xx_convert_raw_temp_to_q31(int8_t raw_val, q31_t *out)
562
567
}
563
568
#endif /* CONFIG_BMA4XX_TEMPERATURE */
564
569
565
- static int bma4xx_one_shot_decode (const uint8_t * buffer , enum sensor_channel channel ,
566
- size_t channel_idx , uint32_t * fit , uint16_t max_count ,
567
- void * data_out )
570
+ static int bma4xx_one_shot_decode (const uint8_t * buffer , struct sensor_chan_spec ch ,
571
+ uint32_t * fit , uint16_t max_count , void * data_out )
568
572
{
569
573
const struct bma4xx_encoded_data * edata = (const struct bma4xx_encoded_data * )buffer ;
570
574
const struct bma4xx_decoder_header * header = & edata -> header ;
@@ -573,11 +577,11 @@ static int bma4xx_one_shot_decode(const uint8_t *buffer, enum sensor_channel cha
573
577
if (* fit != 0 ) {
574
578
return 0 ;
575
579
}
576
- if (max_count == 0 || channel_idx != 0 ) {
580
+ if (max_count == 0 || ch . chan_idx != 0 ) {
577
581
return - EINVAL ;
578
582
}
579
583
580
- switch (channel ) {
584
+ switch (ch . chan_type ) {
581
585
case SENSOR_CHAN_ACCEL_X :
582
586
case SENSOR_CHAN_ACCEL_Y :
583
587
case SENSOR_CHAN_ACCEL_Z :
@@ -590,7 +594,9 @@ static int bma4xx_one_shot_decode(const uint8_t *buffer, enum sensor_channel cha
590
594
591
595
out -> header .base_timestamp_ns = edata -> header .timestamp ;
592
596
out -> header .reading_count = 1 ;
593
- rc = bma4xx_get_shift (SENSOR_CHAN_ACCEL_XYZ , header -> accel_fs , & out -> shift );
597
+ rc = bma4xx_get_shift ((struct sensor_chan_spec ){.chan_type = SENSOR_CHAN_ACCEL_XYZ ,
598
+ .chan_idx = 0 },
599
+ header -> accel_fs , & out -> shift );
594
600
if (rc != 0 ) {
595
601
return - EINVAL ;
596
602
}
@@ -628,8 +634,8 @@ static int bma4xx_one_shot_decode(const uint8_t *buffer, enum sensor_channel cha
628
634
}
629
635
}
630
636
631
- static int bma4xx_decoder_decode (const uint8_t * buffer , enum sensor_channel channel ,
632
- size_t channel_idx , uint32_t * fit , uint16_t max_count ,
637
+ static int bma4xx_decoder_decode (const uint8_t * buffer , struct sensor_chan_spec ch ,
638
+ uint32_t * fit , uint16_t max_count ,
633
639
void * data_out )
634
640
{
635
641
const struct bma4xx_decoder_header * header = (const struct bma4xx_decoder_header * )buffer ;
@@ -639,7 +645,7 @@ static int bma4xx_decoder_decode(const uint8_t *buffer, enum sensor_channel chan
639
645
return - ENOTSUP ;
640
646
}
641
647
642
- return bma4xx_one_shot_decode (buffer , channel , channel_idx , fit , max_count , data_out );
648
+ return bma4xx_one_shot_decode (buffer , ch , fit , max_count , data_out );
643
649
}
644
650
645
651
SENSOR_DECODER_API_DT_DEFINE () = {
0 commit comments