monitor: Add support for decoding Read Local Controller Delay
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 27 Feb 2021 00:55:44 +0000 (16:55 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
< HCI Command: Read Local Supported Controller Delay (0x04|0x000f) plen 8
        Codec: mSBC (0x05)
        Logical Transport Type: 0x02
          Codec supported over BR/EDR SCO and eSCO
        Direction: Input (Host to Controller) (0x00)
        Length Codec Configuration: 0
> HCI Event: Command Complete (0x0e) plen 10
      Read Local Supported Controller Delay (0x04|0x000f) ncmd 1
        Status: Success (0x00)
        Minimum Controller delay: 0 us (0x000000)
        Maximum Controller delay: 0 us (0x000000)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
emulator/btdev.c
monitor/bt.h
monitor/packet.c

index c4b132a..efc9e41 100755 (executable)
@@ -4653,7 +4653,7 @@ static int cmd_read_local_codec_caps(struct btdev *dev, const void *data,
 
        memset(&rsp, 0, sizeof(rsp));
 
-       if (cmd->codec_id > 0x05)
+       if (cmd->codec.id > 0x05)
                rsp.status = BT_HCI_ERR_INVALID_PARAMETERS;
 
        cmd_complete(dev, BT_HCI_CMD_READ_LOCAL_CODEC_CAPS, &rsp, sizeof(rsp));
index 0e43d51..3c62185 100755 (executable)
@@ -1776,8 +1776,9 @@ struct bt_hci_rsp_read_local_pairing_options {
 #define BT_HCI_LOCAL_CODEC_LE_BIS              BIT(3)
 
 struct bt_hci_vnd_codec {
-       uint16_t company;
-       uint16_t id;
+       uint8_t  id;
+       uint16_t cid;
+       uint16_t vid;
        uint8_t  transport;
 } __attribute__ ((packed));
 
@@ -1795,10 +1796,7 @@ struct bt_hci_rsp_read_local_codecs_v2 {
 #define BT_HCI_CMD_READ_LOCAL_CODEC_CAPS       0x100e
 #define BT_HCI_BIT_READ_LOCAL_CODEC_CAPS       BT_HCI_CMD_BIT(45, 3)
 struct bt_hci_cmd_read_local_codec_caps {
-       uint8_t  codec_id;
-       uint16_t codec_cid;
-       uint16_t codec_vid;
-       uint8_t  transport;
+       struct bt_hci_vnd_codec codec;
        uint8_t  dir;
 } __attribute__ ((packed));
 
@@ -1813,6 +1811,21 @@ struct bt_hci_rsp_read_local_codec_caps {
        struct bt_hci_codec_caps caps[0];
 } __attribute__ ((packed));
 
+#define BT_HCI_CMD_READ_LOCAL_CTRL_DELAY       0x100f
+#define BT_HCI_BIT_READ_LOCAL_CTRL_DELAY       BT_HCI_CMD_BIT(45, 4)
+struct bt_hci_cmd_read_local_ctrl_delay {
+       struct bt_hci_vnd_codec codec;
+       uint8_t  dir;
+       uint8_t  codec_cfg_len;
+       uint8_t  codec_cfg[0];
+} __attribute__ ((packed));
+
+struct bt_hci_rsp_read_local_ctrl_delay {
+       uint8_t  status;
+       uint8_t  min_delay[3];
+       uint8_t  max_delay[3];
+} __attribute__ ((packed));
+
 #define BT_HCI_CMD_READ_FAILED_CONTACT_COUNTER 0x1401
 struct bt_hci_cmd_read_failed_contact_counter {
        uint16_t handle;
index f8750ae..0ab4a83 100755 (executable)
@@ -5990,26 +5990,31 @@ static void print_path_direction(const char *prefix, uint8_t dir)
        print_field("%s: %s (0x%2.2x)", prefix, str, dir);
 }
 
-static void read_local_codec_caps_cmd(const void *data, uint8_t size)
+static void print_vnd_codec(const char *label,
+                               const struct bt_hci_vnd_codec *codec)
 {
-       const struct bt_hci_cmd_read_local_codec_caps *cmd = data;
        uint8_t mask;
 
-       print_codec_id("Codec ID", cmd->codec_id);
+       print_codec_id(label, codec->id);
 
-       if (cmd->codec_id == 0xff) {
+       if (codec->id == 0xff) {
                packet_print_company("Company Codec ID",
-                                       le16_to_cpu(cmd->codec_cid));
-               print_field("Vendor Codec ID: %d",
-                                       le16_to_cpu(cmd->codec_vid));
+                                       le16_to_cpu(codec->cid));
+               print_field("Vendor Codec ID: %d", le16_to_cpu(codec->vid));
        }
 
-       print_field("Logical Transport Type: 0x%02x", cmd->transport);
-       mask = print_bitfield(2, cmd->transport, codec_transport_table);
+       print_field("Logical Transport Type: 0x%02x", codec->transport);
+       mask = print_bitfield(2, codec->transport, codec_transport_table);
        if (mask)
                print_text(COLOR_UNKNOWN_SERVICE_CLASS,
                                "  Unknown transport (0x%2.2x)", mask);
+}
+
+static void read_local_codec_caps_cmd(const void *data, uint8_t size)
+{
+       const struct bt_hci_cmd_read_local_codec_caps *cmd = data;
 
+       print_vnd_codec("Codec", &cmd->codec);
        print_path_direction("Direction", cmd->dir);
 }
 
@@ -6041,6 +6046,33 @@ static void read_local_codec_caps_rsp(const void *data, uint8_t size)
        }
 }
 
+static void read_local_ctrl_delay_cmd(const void *data, uint8_t size)
+{
+       const struct bt_hci_cmd_read_local_ctrl_delay *cmd = data;
+
+       print_vnd_codec("Codec", &cmd->codec);
+       print_path_direction("Direction", cmd->dir);
+       print_field("Length Codec Configuration: %u", cmd->codec_cfg_len);
+}
+
+static void print_usec_interval(const char *prefix, const uint8_t interval[3])
+{
+       uint32_t u24 = 0;
+
+       memcpy(&u24, interval, 3);
+       print_field("%s: %u us (0x%6.6x)", prefix, le32_to_cpu(u24),
+                                               le32_to_cpu(u24));
+}
+
+static void read_local_ctrl_delay_rsp(const void *data, uint8_t size)
+{
+       const struct bt_hci_rsp_read_local_ctrl_delay *rsp = data;
+
+       print_status(rsp->status);
+       print_usec_interval("Minimum Controller delay", rsp->min_delay);
+       print_usec_interval("Maximum Controller delay", rsp->max_delay);
+}
+
 static void read_local_pairing_options_rsp(const void *data, uint8_t size)
 {
        const struct bt_hci_rsp_read_local_pairing_options *rsp = data;
@@ -7957,15 +7989,6 @@ static void print_cis_params(const void *data, int i)
                                                        cis->s_rtn);
 }
 
-static void print_usec_interval(const char *prefix, const uint8_t interval[3])
-{
-       uint32_t u24 = 0;
-
-       memcpy(&u24, interval, 3);
-       print_field("%s: %u us (0x%6.6x)", prefix, le32_to_cpu(u24),
-                                               le32_to_cpu(u24));
-}
-
 static void le_set_cig_params_cmd(const void *data, uint8_t size)
 {
        const struct bt_hci_cmd_le_set_cig_params *cmd = data;
@@ -8808,6 +8831,13 @@ static const struct opcode_data opcode_table[] = {
                read_local_codec_caps_rsp,
                sizeof(struct bt_hci_rsp_read_local_codec_caps), false
        },
+       { BT_HCI_CMD_READ_LOCAL_CTRL_DELAY, BT_HCI_BIT_READ_LOCAL_CTRL_DELAY,
+               "Read Local Supported Controller Delay",
+               read_local_ctrl_delay_cmd,
+               sizeof(struct bt_hci_cmd_read_local_ctrl_delay), false,
+               read_local_ctrl_delay_rsp,
+               sizeof(struct bt_hci_rsp_read_local_ctrl_delay), true
+       },
 
        /* OGF 5 - Status Parameter */
        { 0x1401, 122, "Read Failed Contact Counter",