@@ -22,6 +22,11 @@ LOG_MODULE_REGISTER(bt_cs);
22
22
static struct bt_le_cs_test_cb cs_test_callbacks ;
23
23
#endif
24
24
25
+ #define A1 (0)
26
+ #define A2 (1)
27
+ #define A3 (2)
28
+ #define A4 (3)
29
+
25
30
struct reassembly_buf_meta_data {
26
31
uint16_t conn_handle ;
27
32
};
@@ -1344,4 +1349,99 @@ void bt_le_cs_step_data_parse(struct net_buf_simple *step_data_buf,
1344
1349
}
1345
1350
}
1346
1351
1352
+ /* Bluetooth Core Specification 6.0, Table 4.13, Antenna Path Permutation for N_AP=2.
1353
+ * The last element corresponds to extension slot
1354
+ */
1355
+ static const uint8_t antenna_path_lut_n_ap_2 [2 ][3 ] = {
1356
+ {A1 , A2 , A2 },
1357
+ {A2 , A1 , A1 },
1358
+ };
1359
+
1360
+ /* Bluetooth Core Specification 6.0, Table 4.14, Antenna Path Permutation for N_AP=3.
1361
+ * The last element corresponds to extension slot
1362
+ */
1363
+ static const uint8_t antenna_path_lut_n_ap_3 [6 ][4 ] = {
1364
+ {A1 , A2 , A3 , A3 },
1365
+ {A2 , A1 , A3 , A3 },
1366
+ {A1 , A3 , A2 , A2 },
1367
+ {A3 , A1 , A2 , A2 },
1368
+ {A3 , A2 , A1 , A1 },
1369
+ {A2 , A3 , A1 , A1 },
1370
+ };
1371
+
1372
+ /* Bluetooth Core Specification 6.0, Table 4.15, Antenna Path Permutation for N_AP=4.
1373
+ * The last element corresponds to extension slot
1374
+ */
1375
+ static const uint8_t antenna_path_lut_n_ap_4 [24 ][5 ] = {
1376
+ {A1 , A2 , A3 , A4 , A4 },
1377
+ {A2 , A1 , A3 , A4 , A4 },
1378
+ {A1 , A3 , A2 , A4 , A4 },
1379
+ {A3 , A1 , A2 , A4 , A4 },
1380
+ {A3 , A2 , A1 , A4 , A4 },
1381
+ {A2 , A3 , A1 , A4 , A4 },
1382
+ {A1 , A2 , A4 , A3 , A3 },
1383
+ {A2 , A1 , A4 , A3 , A3 },
1384
+ {A1 , A4 , A2 , A3 , A3 },
1385
+ {A4 , A1 , A2 , A3 , A3 },
1386
+ {A4 , A2 , A1 , A3 , A3 },
1387
+ {A2 , A4 , A1 , A3 , A3 },
1388
+ {A1 , A4 , A3 , A2 , A2 },
1389
+ {A4 , A1 , A3 , A2 , A2 },
1390
+ {A1 , A3 , A4 , A2 , A2 },
1391
+ {A3 , A1 , A4 , A2 , A2 },
1392
+ {A3 , A4 , A1 , A2 , A2 },
1393
+ {A4 , A3 , A1 , A2 , A2 },
1394
+ {A4 , A2 , A3 , A1 , A1 },
1395
+ {A2 , A4 , A3 , A1 , A1 },
1396
+ {A4 , A3 , A2 , A1 , A1 },
1397
+ {A3 , A4 , A2 , A1 , A1 },
1398
+ {A3 , A2 , A4 , A1 , A1 },
1399
+ {A2 , A3 , A4 , A1 , A1 },
1400
+ };
1401
+
1402
+ int bt_le_cs_get_antenna_path (uint8_t n_ap ,
1403
+ uint8_t antenna_path_permutation_index ,
1404
+ uint8_t tone_index )
1405
+ {
1406
+ switch (n_ap ) {
1407
+ case 1 :
1408
+ {
1409
+ uint8_t antenna_path_permutations = 1 ;
1410
+ uint8_t num_tones = n_ap + 1 ; /* one additional tone extension slot */
1411
+
1412
+ if (antenna_path_permutation_index >= antenna_path_permutations ||
1413
+ tone_index >= num_tones ) {
1414
+ return - EINVAL ;
1415
+ }
1416
+ return A1 ;
1417
+ }
1418
+ case 2 :
1419
+ {
1420
+ if (antenna_path_permutation_index >= ARRAY_SIZE (antenna_path_lut_n_ap_2 ) ||
1421
+ tone_index >= ARRAY_SIZE (antenna_path_lut_n_ap_2 [0 ])) {
1422
+ return - EINVAL ;
1423
+ }
1424
+ return antenna_path_lut_n_ap_2 [antenna_path_permutation_index ][tone_index ];
1425
+ }
1426
+ case 3 :
1427
+ {
1428
+ if (antenna_path_permutation_index >= ARRAY_SIZE (antenna_path_lut_n_ap_3 ) ||
1429
+ tone_index >= ARRAY_SIZE (antenna_path_lut_n_ap_3 [0 ])) {
1430
+ return - EINVAL ;
1431
+ }
1432
+ return antenna_path_lut_n_ap_3 [antenna_path_permutation_index ][tone_index ];
1433
+ }
1434
+ case 4 :
1435
+ {
1436
+ if (antenna_path_permutation_index >= ARRAY_SIZE (antenna_path_lut_n_ap_4 ) ||
1437
+ tone_index >= ARRAY_SIZE (antenna_path_lut_n_ap_4 [0 ])) {
1438
+ return - EINVAL ;
1439
+ }
1440
+ return antenna_path_lut_n_ap_4 [antenna_path_permutation_index ][tone_index ];
1441
+ }
1442
+ default :
1443
+ return - EINVAL ;
1444
+ }
1445
+ }
1446
+
1347
1447
#endif /* CONFIG_BT_CHANNEL_SOUNDING */
0 commit comments