@@ -1037,8 +1037,9 @@ static bool btintel_firmware_version(struct hci_dev *hdev,
1037
1037
1038
1038
params = (void * )(fw_ptr + sizeof (* cmd ));
1039
1039
1040
- bt_dev_info (hdev , "Boot Address: 0x%x" ,
1041
- le32_to_cpu (params -> boot_addr ));
1040
+ * boot_addr = le32_to_cpu (params -> boot_addr );
1041
+
1042
+ bt_dev_info (hdev , "Boot Address: 0x%x" , * boot_addr );
1042
1043
1043
1044
bt_dev_info (hdev , "Firmware Version: %u-%u.%u" ,
1044
1045
params -> fw_build_num , params -> fw_build_ww ,
@@ -1071,9 +1072,6 @@ int btintel_download_firmware(struct hci_dev *hdev,
1071
1072
/* Skip version checking */
1072
1073
break ;
1073
1074
default :
1074
- /* Skip reading firmware file version in bootloader mode */
1075
- if (ver -> fw_variant == 0x06 )
1076
- break ;
1077
1075
1078
1076
/* Skip download if firmware has the same version */
1079
1077
if (btintel_firmware_version (hdev , ver -> fw_build_num ,
@@ -1114,19 +1112,16 @@ static int btintel_download_fw_tlv(struct hci_dev *hdev,
1114
1112
int err ;
1115
1113
u32 css_header_ver ;
1116
1114
1117
- /* Skip reading firmware file version in bootloader mode */
1118
- if (ver -> img_type != 0x01 ) {
1119
- /* Skip download if firmware has the same version */
1120
- if (btintel_firmware_version (hdev , ver -> min_fw_build_nn ,
1121
- ver -> min_fw_build_cw ,
1122
- ver -> min_fw_build_yy ,
1123
- fw , boot_param )) {
1124
- bt_dev_info (hdev , "Firmware already loaded" );
1125
- /* Return -EALREADY to indicate that firmware has
1126
- * already been loaded.
1127
- */
1128
- return - EALREADY ;
1129
- }
1115
+ /* Skip download if firmware has the same version */
1116
+ if (btintel_firmware_version (hdev , ver -> min_fw_build_nn ,
1117
+ ver -> min_fw_build_cw ,
1118
+ ver -> min_fw_build_yy ,
1119
+ fw , boot_param )) {
1120
+ bt_dev_info (hdev , "Firmware already loaded" );
1121
+ /* Return -EALREADY to indicate that firmware has
1122
+ * already been loaded.
1123
+ */
1124
+ return - EALREADY ;
1130
1125
}
1131
1126
1132
1127
/* The firmware variant determines if the device is in bootloader
@@ -1285,12 +1280,16 @@ static int btintel_read_debug_features(struct hci_dev *hdev,
1285
1280
static int btintel_set_debug_features (struct hci_dev * hdev ,
1286
1281
const struct intel_debug_features * features )
1287
1282
{
1288
- u8 mask [11 ] = { 0x0a , 0x92 , 0x02 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 ,
1283
+ u8 mask [11 ] = { 0x0a , 0x92 , 0x02 , 0x7f , 0x00 , 0x00 , 0x00 , 0x00 ,
1289
1284
0x00 , 0x00 , 0x00 };
1285
+ u8 period [5 ] = { 0x04 , 0x91 , 0x02 , 0x05 , 0x00 };
1286
+ u8 trace_enable = 0x02 ;
1290
1287
struct sk_buff * skb ;
1291
1288
1292
- if (!features )
1289
+ if (!features ) {
1290
+ bt_dev_warn (hdev , "Debug features not read" );
1293
1291
return - EINVAL ;
1292
+ }
1294
1293
1295
1294
if (!(features -> page1 [0 ] & 0x3f )) {
1296
1295
bt_dev_info (hdev , "Telemetry exception format not supported" );
@@ -1303,11 +1302,95 @@ static int btintel_set_debug_features(struct hci_dev *hdev,
1303
1302
PTR_ERR (skb ));
1304
1303
return PTR_ERR (skb );
1305
1304
}
1305
+ kfree_skb (skb );
1306
+
1307
+ skb = __hci_cmd_sync (hdev , 0xfc8b , 5 , period , HCI_INIT_TIMEOUT );
1308
+ if (IS_ERR (skb )) {
1309
+ bt_dev_err (hdev , "Setting periodicity for link statistics traces failed (%ld)" ,
1310
+ PTR_ERR (skb ));
1311
+ return PTR_ERR (skb );
1312
+ }
1313
+ kfree_skb (skb );
1314
+
1315
+ skb = __hci_cmd_sync (hdev , 0xfca1 , 1 , & trace_enable , HCI_INIT_TIMEOUT );
1316
+ if (IS_ERR (skb )) {
1317
+ bt_dev_err (hdev , "Enable tracing of link statistics events failed (%ld)" ,
1318
+ PTR_ERR (skb ));
1319
+ return PTR_ERR (skb );
1320
+ }
1321
+ kfree_skb (skb );
1322
+
1323
+ bt_dev_info (hdev , "set debug features: trace_enable 0x%02x mask 0x%02x" ,
1324
+ trace_enable , mask [3 ]);
1325
+
1326
+ return 0 ;
1327
+ }
1328
+
1329
+ static int btintel_reset_debug_features (struct hci_dev * hdev ,
1330
+ const struct intel_debug_features * features )
1331
+ {
1332
+ u8 mask [11 ] = { 0x0a , 0x92 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
1333
+ 0x00 , 0x00 , 0x00 };
1334
+ u8 trace_enable = 0x00 ;
1335
+ struct sk_buff * skb ;
1336
+
1337
+ if (!features ) {
1338
+ bt_dev_warn (hdev , "Debug features not read" );
1339
+ return - EINVAL ;
1340
+ }
1341
+
1342
+ if (!(features -> page1 [0 ] & 0x3f )) {
1343
+ bt_dev_info (hdev , "Telemetry exception format not supported" );
1344
+ return 0 ;
1345
+ }
1346
+
1347
+ /* Should stop the trace before writing ddc event mask. */
1348
+ skb = __hci_cmd_sync (hdev , 0xfca1 , 1 , & trace_enable , HCI_INIT_TIMEOUT );
1349
+ if (IS_ERR (skb )) {
1350
+ bt_dev_err (hdev , "Stop tracing of link statistics events failed (%ld)" ,
1351
+ PTR_ERR (skb ));
1352
+ return PTR_ERR (skb );
1353
+ }
1354
+ kfree_skb (skb );
1306
1355
1356
+ skb = __hci_cmd_sync (hdev , 0xfc8b , 11 , mask , HCI_INIT_TIMEOUT );
1357
+ if (IS_ERR (skb )) {
1358
+ bt_dev_err (hdev , "Setting Intel telemetry ddc write event mask failed (%ld)" ,
1359
+ PTR_ERR (skb ));
1360
+ return PTR_ERR (skb );
1361
+ }
1307
1362
kfree_skb (skb );
1363
+
1364
+ bt_dev_info (hdev , "reset debug features: trace_enable 0x%02x mask 0x%02x" ,
1365
+ trace_enable , mask [3 ]);
1366
+
1308
1367
return 0 ;
1309
1368
}
1310
1369
1370
+ int btintel_set_quality_report (struct hci_dev * hdev , bool enable )
1371
+ {
1372
+ struct intel_debug_features features ;
1373
+ int err ;
1374
+
1375
+ bt_dev_dbg (hdev , "enable %d" , enable );
1376
+
1377
+ /* Read the Intel supported features and if new exception formats
1378
+ * supported, need to load the additional DDC config to enable.
1379
+ */
1380
+ err = btintel_read_debug_features (hdev , & features );
1381
+ if (err )
1382
+ return err ;
1383
+
1384
+ /* Set or reset the debug features. */
1385
+ if (enable )
1386
+ err = btintel_set_debug_features (hdev , & features );
1387
+ else
1388
+ err = btintel_reset_debug_features (hdev , & features );
1389
+
1390
+ return err ;
1391
+ }
1392
+ EXPORT_SYMBOL_GPL (btintel_set_quality_report );
1393
+
1311
1394
static const struct firmware * btintel_legacy_rom_get_fw (struct hci_dev * hdev ,
1312
1395
struct intel_version * ver )
1313
1396
{
@@ -1893,7 +1976,6 @@ static int btintel_bootloader_setup(struct hci_dev *hdev,
1893
1976
u32 boot_param ;
1894
1977
char ddcname [64 ];
1895
1978
int err ;
1896
- struct intel_debug_features features ;
1897
1979
1898
1980
BT_DBG ("%s" , hdev -> name );
1899
1981
@@ -1934,14 +2016,7 @@ static int btintel_bootloader_setup(struct hci_dev *hdev,
1934
2016
btintel_load_ddc_config (hdev , ddcname );
1935
2017
}
1936
2018
1937
- /* Read the Intel supported features and if new exception formats
1938
- * supported, need to load the additional DDC config to enable.
1939
- */
1940
- err = btintel_read_debug_features (hdev , & features );
1941
- if (!err ) {
1942
- /* Set DDC mask for available debug features */
1943
- btintel_set_debug_features (hdev , & features );
1944
- }
2019
+ hci_dev_clear_flag (hdev , HCI_QUALITY_REPORT );
1945
2020
1946
2021
/* Read the Intel version information after loading the FW */
1947
2022
err = btintel_read_version (hdev , & new_ver );
@@ -2083,13 +2158,102 @@ static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,
2083
2158
return err ;
2084
2159
}
2085
2160
2161
+ static int btintel_get_codec_config_data (struct hci_dev * hdev ,
2162
+ __u8 link , struct bt_codec * codec ,
2163
+ __u8 * ven_len , __u8 * * ven_data )
2164
+ {
2165
+ int err = 0 ;
2166
+
2167
+ if (!ven_data || !ven_len )
2168
+ return - EINVAL ;
2169
+
2170
+ * ven_len = 0 ;
2171
+ * ven_data = NULL ;
2172
+
2173
+ if (link != ESCO_LINK ) {
2174
+ bt_dev_err (hdev , "Invalid link type(%u)" , link );
2175
+ return - EINVAL ;
2176
+ }
2177
+
2178
+ * ven_data = kmalloc (sizeof (__u8 ), GFP_KERNEL );
2179
+ if (!* ven_data ) {
2180
+ err = - ENOMEM ;
2181
+ goto error ;
2182
+ }
2183
+
2184
+ /* supports only CVSD and mSBC offload codecs */
2185
+ switch (codec -> id ) {
2186
+ case 0x02 :
2187
+ * * ven_data = 0x00 ;
2188
+ break ;
2189
+ case 0x05 :
2190
+ * * ven_data = 0x01 ;
2191
+ break ;
2192
+ default :
2193
+ err = - EINVAL ;
2194
+ bt_dev_err (hdev , "Invalid codec id(%u)" , codec -> id );
2195
+ goto error ;
2196
+ }
2197
+ /* codec and its capabilities are pre-defined to ids
2198
+ * preset id = 0x00 represents CVSD codec with sampling rate 8K
2199
+ * preset id = 0x01 represents mSBC codec with sampling rate 16K
2200
+ */
2201
+ * ven_len = sizeof (__u8 );
2202
+ return err ;
2203
+
2204
+ error :
2205
+ kfree (* ven_data );
2206
+ * ven_data = NULL ;
2207
+ return err ;
2208
+ }
2209
+
2210
+ static int btintel_get_data_path_id (struct hci_dev * hdev , __u8 * data_path_id )
2211
+ {
2212
+ /* Intel uses 1 as data path id for all the usecases */
2213
+ * data_path_id = 1 ;
2214
+ return 0 ;
2215
+ }
2216
+
2217
+ static int btintel_configure_offload (struct hci_dev * hdev )
2218
+ {
2219
+ struct sk_buff * skb ;
2220
+ int err = 0 ;
2221
+ struct intel_offload_use_cases * use_cases ;
2222
+
2223
+ skb = __hci_cmd_sync (hdev , 0xfc86 , 0 , NULL , HCI_INIT_TIMEOUT );
2224
+ if (IS_ERR (skb )) {
2225
+ bt_dev_err (hdev , "Reading offload use cases failed (%ld)" ,
2226
+ PTR_ERR (skb ));
2227
+ return PTR_ERR (skb );
2228
+ }
2229
+
2230
+ if (skb -> len < sizeof (* use_cases )) {
2231
+ err = - EIO ;
2232
+ goto error ;
2233
+ }
2234
+
2235
+ use_cases = (void * )skb -> data ;
2236
+
2237
+ if (use_cases -> status ) {
2238
+ err = - bt_to_errno (skb -> data [0 ]);
2239
+ goto error ;
2240
+ }
2241
+
2242
+ if (use_cases -> preset [0 ] & 0x03 ) {
2243
+ hdev -> get_data_path_id = btintel_get_data_path_id ;
2244
+ hdev -> get_codec_config_data = btintel_get_codec_config_data ;
2245
+ }
2246
+ error :
2247
+ kfree_skb (skb );
2248
+ return err ;
2249
+ }
2250
+
2086
2251
static int btintel_bootloader_setup_tlv (struct hci_dev * hdev ,
2087
2252
struct intel_version_tlv * ver )
2088
2253
{
2089
2254
u32 boot_param ;
2090
2255
char ddcname [64 ];
2091
2256
int err ;
2092
- struct intel_debug_features features ;
2093
2257
struct intel_version_tlv new_ver ;
2094
2258
2095
2259
bt_dev_dbg (hdev , "" );
@@ -2125,14 +2289,10 @@ static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
2125
2289
*/
2126
2290
btintel_load_ddc_config (hdev , ddcname );
2127
2291
2128
- /* Read the Intel supported features and if new exception formats
2129
- * supported, need to load the additional DDC config to enable.
2130
- */
2131
- err = btintel_read_debug_features (hdev , & features );
2132
- if (!err ) {
2133
- /* Set DDC mask for available debug features */
2134
- btintel_set_debug_features (hdev , & features );
2135
- }
2292
+ /* Read supported use cases and set callbacks to fetch datapath id */
2293
+ btintel_configure_offload (hdev );
2294
+
2295
+ hci_dev_clear_flag (hdev , HCI_QUALITY_REPORT );
2136
2296
2137
2297
/* Read the Intel version information after loading the FW */
2138
2298
err = btintel_read_version_tlv (hdev , & new_ver );
@@ -2232,6 +2392,9 @@ static int btintel_setup_combined(struct hci_dev *hdev)
2232
2392
set_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , & hdev -> quirks );
2233
2393
set_bit (HCI_QUIRK_NON_PERSISTENT_DIAG , & hdev -> quirks );
2234
2394
2395
+ /* Set up the quality report callback for Intel devices */
2396
+ hdev -> set_quality_report = btintel_set_quality_report ;
2397
+
2235
2398
/* For Legacy device, check the HW platform value and size */
2236
2399
if (skb -> len == sizeof (ver ) && skb -> data [1 ] == 0x37 ) {
2237
2400
bt_dev_dbg (hdev , "Read the legacy Intel version information" );
0 commit comments