bthost: Add qos support to bthost_set_cig_params
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 5 Aug 2022 21:48:37 +0000 (14:48 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This enables setting QoS other then the mandatory 16_2_1.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
emulator/bthost.c
emulator/bthost.h
tools/iso-tester.c

index bd8d1d5..c106ed1 100755 (executable)
@@ -3130,25 +3130,29 @@ bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr)
 }
 
 void bthost_set_cig_params(struct bthost *bthost, uint8_t cig_id,
-                                               uint8_t cis_id)
+                               uint8_t cis_id, const struct bt_iso_qos *qos)
 {
        struct bt_hci_cmd_le_set_cig_params *cp;
 
        cp = malloc(sizeof(*cp) + sizeof(*cp->cis));
        memset(cp, 0, sizeof(*cp) + sizeof(*cp->cis));
        cp->cig_id = cig_id;
-       put_le24(10000, cp->c_interval);
-       put_le24(10000, cp->p_interval);
-       cp->c_latency = cpu_to_le16(10);
-       cp->p_latency = cpu_to_le16(10);
+       put_le24(qos->in.interval ? qos->in.interval : qos->out.interval,
+                                                       cp->c_interval);
+       put_le24(qos->out.interval ? qos->out.interval : qos->in.interval,
+                                                       cp->p_interval);
+       cp->c_latency = cpu_to_le16(qos->in.latency ? qos->in.latency :
+                                                       qos->out.latency);
+       cp->p_latency = cpu_to_le16(qos->out.latency ? qos->out.latency :
+                                                       qos->in.latency);
        cp->num_cis = 0x01;
        cp->cis[0].cis_id = cis_id;
-       cp->cis[0].c_sdu = 40;
-       cp->cis[0].p_sdu = 40;
-       cp->cis[0].c_phy = 0x02;
-       cp->cis[0].p_phy = 0x02;
-       cp->cis[0].c_rtn = 2;
-       cp->cis[0].p_rtn = 2;
+       cp->cis[0].c_sdu = qos->in.sdu;
+       cp->cis[0].p_sdu = qos->out.sdu;
+       cp->cis[0].c_phy = qos->in.phy ? qos->in.phy : qos->out.phy;
+       cp->cis[0].p_phy = qos->out.phy ? qos->out.phy : qos->in.phy;
+       cp->cis[0].c_rtn = qos->in.rtn;
+       cp->cis[0].p_rtn = qos->out.rtn;
 
        send_command(bthost, BT_HCI_CMD_LE_SET_CIG_PARAMS, cp,
                                sizeof(*cp) + sizeof(*cp->cis));
index fd177ac..3d7a124 100755 (executable)
@@ -12,6 +12,8 @@
 #include <stdint.h>
 #include <sys/uio.h>
 
+#include "lib/bluetooth.h"
+
 typedef void (*bthost_send_func) (const struct iovec *iov, int iovlen,
                                                        void *user_data);
 
@@ -101,7 +103,7 @@ void bthost_create_big(struct bthost *bthost, uint8_t num_bis);
 bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr);
 
 void bthost_set_cig_params(struct bthost *bthost, uint8_t cig_id,
-                                               uint8_t cis_id);
+                               uint8_t cis_id, const struct bt_iso_qos *qos);
 void bthost_create_cis(struct bthost *bthost, uint16_t cis_handle,
                                                uint16_t acl_handle);
 
index 56c17b7..44bed6c 100644 (file)
@@ -1450,7 +1450,7 @@ static void setup_listen(struct test_data *data, uint8_t num, GIOFunc func)
                client = hciemu_get_client(data->hciemu, 0);
                host = hciemu_client_host(client);
 
-               bthost_set_cig_params(host, 0x01, 0x01);
+               bthost_set_cig_params(host, 0x01, 0x01, &isodata->qos);
                bthost_create_cis(host, 257, data->acl_handle);
        }
 }