• Home
  • Raw
  • Download

Lines Matching refs:hci

432 static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,  in bt_hci_event_start()  argument
446 if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte]) in bt_hci_event_start()
449 packet = hci->evt_packet(hci->opaque); in bt_hci_event_start()
456 static inline void bt_hci_event(struct bt_hci_s *hci, int evt, in bt_hci_event() argument
459 uint8_t *packet = bt_hci_event_start(hci, evt, len); in bt_hci_event()
467 hci->evt_submit(hci->opaque, len + 2); in bt_hci_event()
470 static inline void bt_hci_event_status(struct bt_hci_s *hci, int status) in bt_hci_event_status() argument
475 .opcode = hci->last_cmd, in bt_hci_event_status()
478 bt_hci_event(hci, EVT_CMD_STATUS, &params, EVT_CMD_STATUS_SIZE); in bt_hci_event_status()
481 static inline void bt_hci_event_complete(struct bt_hci_s *hci, in bt_hci_event_complete() argument
484 uint8_t *packet = bt_hci_event_start(hci, EVT_CMD_COMPLETE, in bt_hci_event_complete()
492 params->opcode = hci->last_cmd; in bt_hci_event_complete()
496 hci->evt_submit(hci->opaque, len + EVT_CMD_COMPLETE_SIZE + 2); in bt_hci_event_complete()
501 struct bt_hci_s *hci = (struct bt_hci_s *) opaque; in bt_hci_inquiry_done() local
504 if (!hci->lm.periodic) in bt_hci_inquiry_done()
505 hci->lm.inquire = 0; in bt_hci_inquiry_done()
512 bt_hci_event(hci, EVT_INQUIRY_COMPLETE, &status, 1); in bt_hci_inquiry_done()
515 static void bt_hci_inquiry_result_standard(struct bt_hci_s *hci, in bt_hci_inquiry_result_standard() argument
531 bt_hci_event(hci, EVT_INQUIRY_RESULT, &params, INQUIRY_INFO_SIZE); in bt_hci_inquiry_result_standard()
534 static void bt_hci_inquiry_result_with_rssi(struct bt_hci_s *hci, in bt_hci_inquiry_result_with_rssi() argument
550 bt_hci_event(hci, EVT_INQUIRY_RESULT_WITH_RSSI, in bt_hci_inquiry_result_with_rssi()
554 static void bt_hci_inquiry_result(struct bt_hci_s *hci, in bt_hci_inquiry_result() argument
557 if (!slave->inquiry_scan || !hci->lm.responses_left) in bt_hci_inquiry_result()
560 hci->lm.responses_left --; in bt_hci_inquiry_result()
561 hci->lm.responses ++; in bt_hci_inquiry_result()
563 switch (hci->lm.inquiry_mode) { in bt_hci_inquiry_result()
565 bt_hci_inquiry_result_standard(hci, slave); in bt_hci_inquiry_result()
568 bt_hci_inquiry_result_with_rssi(hci, slave); in bt_hci_inquiry_result()
572 hci->lm.inquiry_mode); in bt_hci_inquiry_result()
583 static void bt_hci_inquiry_start(struct bt_hci_s *hci, int length) in bt_hci_inquiry_start() argument
587 hci->lm.inquiry_length = length; in bt_hci_inquiry_start()
588 for (slave = hci->device.net->slave; slave; slave = slave->next) in bt_hci_inquiry_start()
590 if (slave != &hci->device) in bt_hci_inquiry_start()
591 bt_hci_inquiry_result(hci, slave); in bt_hci_inquiry_start()
598 if (hci->lm.responses_left) in bt_hci_inquiry_start()
599 bt_hci_mod_timer_1280ms(hci->lm.inquiry_done, hci->lm.inquiry_length); in bt_hci_inquiry_start()
601 bt_hci_inquiry_done(hci); in bt_hci_inquiry_start()
603 if (hci->lm.periodic) in bt_hci_inquiry_start()
604 bt_hci_mod_timer_1280ms(hci->lm.inquiry_next, hci->lm.inquiry_period); in bt_hci_inquiry_start()
609 struct bt_hci_s *hci = (struct bt_hci_s *) opaque; in bt_hci_inquiry_next() local
611 hci->lm.responses_left += hci->lm.responses; in bt_hci_inquiry_next()
612 hci->lm.responses = 0; in bt_hci_inquiry_next()
613 bt_hci_inquiry_start(hci, hci->lm.inquiry_length); in bt_hci_inquiry_next()
616 static inline int bt_hci_handle_bad(struct bt_hci_s *hci, uint16_t handle) in bt_hci_handle_bad() argument
620 !hci->lm.handle[handle & ~HCI_HANDLE_OFFSET].link; in bt_hci_handle_bad()
623 static inline int bt_hci_role_master(struct bt_hci_s *hci, uint16_t handle) in bt_hci_role_master() argument
625 return !!(hci->lm.role_bmp & (1 << (handle & ~HCI_HANDLE_OFFSET))); in bt_hci_role_master()
628 static inline struct bt_device_s *bt_hci_remote_dev(struct bt_hci_s *hci, in bt_hci_remote_dev() argument
631 struct bt_link_s *link = hci->lm.handle[handle & ~HCI_HANDLE_OFFSET].link; in bt_hci_remote_dev()
633 return bt_hci_role_master(hci, handle) ? link->slave : link->host; in bt_hci_remote_dev()
637 static void bt_hci_lmp_link_establish(struct bt_hci_s *hci, in bt_hci_lmp_link_establish() argument
640 hci->lm.handle[hci->lm.last_handle].link = link; in bt_hci_lmp_link_establish()
644 hci->lm.role_bmp |= 1 << hci->lm.last_handle; in bt_hci_lmp_link_establish()
646 hci->lm.handle[hci->lm.last_handle].lmp_acl_data = in bt_hci_lmp_link_establish()
650 hci->lm.role_bmp &= ~(1 << hci->lm.last_handle); in bt_hci_lmp_link_establish()
652 hci->lm.handle[hci->lm.last_handle].lmp_acl_data = in bt_hci_lmp_link_establish()
659 hci->lm.handle[hci->lm.last_handle].acl_mode_timer = in bt_hci_lmp_link_establish()
664 static void bt_hci_lmp_link_teardown(struct bt_hci_s *hci, uint16_t handle) in bt_hci_lmp_link_teardown() argument
667 hci->lm.handle[handle].link = NULL; in bt_hci_lmp_link_teardown()
669 if (bt_hci_role_master(hci, handle)) { in bt_hci_lmp_link_teardown()
670 qemu_del_timer(hci->lm.handle[handle].acl_mode_timer); in bt_hci_lmp_link_teardown()
671 qemu_free_timer(hci->lm.handle[handle].acl_mode_timer); in bt_hci_lmp_link_teardown()
675 static int bt_hci_connect(struct bt_hci_s *hci, bdaddr_t *bdaddr) in bt_hci_connect() argument
680 for (slave = hci->device.net->slave; slave; slave = slave->next) in bt_hci_connect()
683 if (!slave || slave == &hci->device) in bt_hci_connect()
686 bacpy(&hci->lm.awaiting_bdaddr[hci->lm.connecting ++], &slave->bd_addr); in bt_hci_connect()
689 link.host = &hci->device; in bt_hci_connect()
695 static void bt_hci_connection_reject(struct bt_hci_s *hci, in bt_hci_connection_reject() argument
699 .slave = &hci->device, in bt_hci_connection_reject()
708 static void bt_hci_connection_reject_event(struct bt_hci_s *hci, in bt_hci_connection_reject_event() argument
718 bt_hci_event(hci, EVT_CONN_COMPLETE, &params, EVT_CONN_COMPLETE_SIZE); in bt_hci_connection_reject_event()
721 static void bt_hci_connection_accept(struct bt_hci_s *hci, in bt_hci_connection_accept() argument
732 while (hci->lm.handle[++ hci->lm.last_handle].link && -- tries) in bt_hci_connection_accept()
733 hci->lm.last_handle &= HCI_HANDLES_MAX - 1; in bt_hci_connection_accept()
734 handle = hci->lm.last_handle | HCI_HANDLE_OFFSET; in bt_hci_connection_accept()
735 } while ((handle == hci->asb_handle || handle == hci->psb_handle) && in bt_hci_connection_accept()
740 bt_hci_connection_reject(hci, host, HCI_REJECTED_LIMITED_RESOURCES); in bt_hci_connection_accept()
745 link->btlink.slave = &hci->device; in bt_hci_connection_accept()
750 bt_hci_lmp_link_establish(hci, &link->btlink, 0); in bt_hci_connection_accept()
758 bt_hci_event(hci, EVT_CONN_COMPLETE, &params, EVT_CONN_COMPLETE_SIZE); in bt_hci_connection_accept()
771 struct bt_hci_s *hci = hci_from_device(link->slave); in bt_hci_lmp_connection_request() local
774 if (hci->conn_req_host) { in bt_hci_lmp_connection_request()
775 bt_hci_connection_reject(hci, link->host, in bt_hci_lmp_connection_request()
779 hci->conn_req_host = link->host; in bt_hci_lmp_connection_request()
788 bt_hci_event(hci, EVT_CONN_REQUEST, &params, EVT_CONN_REQUEST_SIZE); in bt_hci_lmp_connection_request()
794 struct bt_hci_s *hci = (struct bt_hci_s *) opaque; in bt_hci_conn_accept_timeout() local
796 if (!hci->conn_req_host) in bt_hci_conn_accept_timeout()
810 static int bt_hci_lmp_connection_ready(struct bt_hci_s *hci, in bt_hci_lmp_connection_ready() argument
815 for (i = 0; i < hci->lm.connecting; i ++) in bt_hci_lmp_connection_ready()
816 if (!bacmp(&hci->lm.awaiting_bdaddr[i], bdaddr)) { in bt_hci_lmp_connection_ready()
817 if (i < -- hci->lm.connecting) in bt_hci_lmp_connection_ready()
818 bacpy(&hci->lm.awaiting_bdaddr[i], in bt_hci_lmp_connection_ready()
819 &hci->lm.awaiting_bdaddr[hci->lm.connecting]); in bt_hci_lmp_connection_ready()
828 struct bt_hci_s *hci = hci_from_device(link->host); in bt_hci_lmp_connection_complete() local
834 if (bt_hci_lmp_connection_ready(hci, &link->slave->bd_addr)) { in bt_hci_lmp_connection_complete()
835 if (!hci->device.reject_reason) in bt_hci_lmp_connection_complete()
842 if (hci->device.reject_reason) { in bt_hci_lmp_connection_complete()
844 status = hci->device.reject_reason; in bt_hci_lmp_connection_complete()
850 while (hci->lm.handle[++ hci->lm.last_handle].link && -- tries) in bt_hci_lmp_connection_complete()
851 hci->lm.last_handle &= HCI_HANDLES_MAX - 1; in bt_hci_lmp_connection_complete()
852 handle = hci->lm.last_handle | HCI_HANDLE_OFFSET; in bt_hci_lmp_connection_complete()
853 } while ((handle == hci->asb_handle || handle == hci->psb_handle) && in bt_hci_lmp_connection_complete()
864 bt_hci_lmp_link_establish(hci, link, 1); in bt_hci_lmp_connection_complete()
872 bt_hci_event(hci, EVT_CONN_COMPLETE, &params, EVT_CONN_COMPLETE_SIZE); in bt_hci_lmp_connection_complete()
875 static void bt_hci_disconnect(struct bt_hci_s *hci, in bt_hci_disconnect() argument
879 hci->lm.handle[handle & ~HCI_HANDLE_OFFSET].link; in bt_hci_disconnect()
883 if (bt_hci_role_master(hci, handle)) { in bt_hci_disconnect()
899 bt_hci_lmp_link_teardown(hci, handle); in bt_hci_disconnect()
904 bt_hci_event(hci, EVT_DISCONN_COMPLETE, in bt_hci_disconnect()
911 struct bt_hci_s *hci = hci_from_device(link->host); in bt_hci_lmp_disconnect_host() local
915 bt_hci_lmp_link_teardown(hci, handle); in bt_hci_lmp_disconnect_host()
919 params.reason = hci->device.reject_reason; in bt_hci_lmp_disconnect_host()
920 bt_hci_event(hci, EVT_DISCONN_COMPLETE, in bt_hci_lmp_disconnect_host()
927 struct bt_hci_s *hci = hci_from_device(btlink->slave); in bt_hci_lmp_disconnect_slave() local
933 bt_hci_lmp_link_teardown(hci, handle); in bt_hci_lmp_disconnect_slave()
937 params.reason = hci->device.reject_reason; in bt_hci_lmp_disconnect_slave()
938 bt_hci_event(hci, EVT_DISCONN_COMPLETE, in bt_hci_lmp_disconnect_slave()
942 static int bt_hci_name_req(struct bt_hci_s *hci, bdaddr_t *bdaddr) in bt_hci_name_req() argument
948 for (slave = hci->device.net->slave; slave; slave = slave->next) in bt_hci_name_req()
954 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_name_req()
961 bt_hci_event(hci, EVT_REMOTE_NAME_REQ_COMPLETE, in bt_hci_name_req()
967 static int bt_hci_features_req(struct bt_hci_s *hci, uint16_t handle) in bt_hci_features_req() argument
972 if (bt_hci_handle_bad(hci, handle)) in bt_hci_features_req()
975 slave = bt_hci_remote_dev(hci, handle); in bt_hci_features_req()
977 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_features_req()
989 bt_hci_event(hci, EVT_READ_REMOTE_FEATURES_COMPLETE, in bt_hci_features_req()
995 static int bt_hci_version_req(struct bt_hci_s *hci, uint16_t handle) in bt_hci_version_req() argument
999 if (bt_hci_handle_bad(hci, handle)) in bt_hci_version_req()
1002 bt_hci_remote_dev(hci, handle); in bt_hci_version_req()
1004 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_version_req()
1011 bt_hci_event(hci, EVT_READ_REMOTE_VERSION_COMPLETE, in bt_hci_version_req()
1017 static int bt_hci_clkoffset_req(struct bt_hci_s *hci, uint16_t handle) in bt_hci_clkoffset_req() argument
1022 if (bt_hci_handle_bad(hci, handle)) in bt_hci_clkoffset_req()
1025 slave = bt_hci_remote_dev(hci, handle); in bt_hci_clkoffset_req()
1027 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_clkoffset_req()
1033 bt_hci_event(hci, EVT_READ_CLOCK_OFFSET_COMPLETE, in bt_hci_clkoffset_req()
1039 static void bt_hci_event_mode(struct bt_hci_s *hci, struct bt_link_s *link, in bt_hci_event_mode() argument
1049 bt_hci_event(hci, EVT_MODE_CHANGE, &params, EVT_MODE_CHANGE_SIZE); in bt_hci_event_mode()
1052 static void bt_hci_lmp_mode_change_master(struct bt_hci_s *hci, in bt_hci_lmp_mode_change_master() argument
1058 bt_hci_event_mode(hci, link, link->handle); in bt_hci_lmp_mode_change_master()
1066 struct bt_hci_s *hci = hci_from_device(btlink->slave); in bt_hci_lmp_mode_change_slave() local
1068 bt_hci_event_mode(hci, btlink, link->handle); in bt_hci_lmp_mode_change_slave()
1071 static int bt_hci_mode_change(struct bt_hci_s *hci, uint16_t handle, in bt_hci_mode_change() argument
1076 if (bt_hci_handle_bad(hci, handle) || !bt_hci_role_master(hci, handle)) in bt_hci_mode_change()
1079 link = &hci->lm.handle[handle & ~HCI_HANDLE_OFFSET]; in bt_hci_mode_change()
1081 bt_hci_event_status(hci, HCI_COMMAND_DISALLOWED); in bt_hci_mode_change()
1085 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_mode_change()
1089 bt_hci_lmp_mode_change_master(hci, link->link, mode, interval); in bt_hci_mode_change()
1094 static int bt_hci_mode_cancel(struct bt_hci_s *hci, uint16_t handle, int mode) in bt_hci_mode_cancel() argument
1098 if (bt_hci_handle_bad(hci, handle) || !bt_hci_role_master(hci, handle)) in bt_hci_mode_cancel()
1101 link = &hci->lm.handle[handle & ~HCI_HANDLE_OFFSET]; in bt_hci_mode_cancel()
1103 bt_hci_event_status(hci, HCI_COMMAND_DISALLOWED); in bt_hci_mode_cancel()
1108 bt_hci_event_status(hci, HCI_SUCCESS); in bt_hci_mode_cancel()
1111 bt_hci_lmp_mode_change_master(hci, link->link, acl_active, 0); in bt_hci_mode_cancel()
1119 struct bt_hci_s *hci = hci_from_device(link->host); in bt_hci_mode_tick() local
1121 bt_hci_lmp_mode_change_master(hci, link, acl_active, 0); in bt_hci_mode_tick()
1124 static void bt_hci_reset(struct bt_hci_s *hci) in bt_hci_reset() argument
1126 hci->acl_len = 0; in bt_hci_reset()
1127 hci->last_cmd = 0; in bt_hci_reset()
1128 hci->lm.connecting = 0; in bt_hci_reset()
1130 hci->event_mask[0] = 0xff; in bt_hci_reset()
1131 hci->event_mask[1] = 0xff; in bt_hci_reset()
1132 hci->event_mask[2] = 0xff; in bt_hci_reset()
1133 hci->event_mask[3] = 0xff; in bt_hci_reset()
1134 hci->event_mask[4] = 0xff; in bt_hci_reset()
1135 hci->event_mask[5] = 0x1f; in bt_hci_reset()
1136 hci->event_mask[6] = 0x00; in bt_hci_reset()
1137 hci->event_mask[7] = 0x00; in bt_hci_reset()
1138 hci->device.inquiry_scan = 0; in bt_hci_reset()
1139 hci->device.page_scan = 0; in bt_hci_reset()
1140 if (hci->device.lmp_name) in bt_hci_reset()
1141 qemu_free((void *) hci->device.lmp_name); in bt_hci_reset()
1142 hci->device.lmp_name = NULL; in bt_hci_reset()
1143 hci->device.class[0] = 0x00; in bt_hci_reset()
1144 hci->device.class[1] = 0x00; in bt_hci_reset()
1145 hci->device.class[2] = 0x00; in bt_hci_reset()
1146 hci->voice_setting = 0x0000; in bt_hci_reset()
1147 hci->conn_accept_tout = 0x1f40; in bt_hci_reset()
1148 hci->lm.inquiry_mode = 0x00; in bt_hci_reset()
1150 hci->psb_handle = 0x000; in bt_hci_reset()
1151 hci->asb_handle = 0x000; in bt_hci_reset()
1154 qemu_del_timer(hci->lm.inquiry_done); in bt_hci_reset()
1155 qemu_del_timer(hci->lm.inquiry_next); in bt_hci_reset()
1156 qemu_del_timer(hci->conn_accept_timer); in bt_hci_reset()
1159 static void bt_hci_read_local_version_rp(struct bt_hci_s *hci) in bt_hci_read_local_version_rp() argument
1170 bt_hci_event_complete(hci, &lv, READ_LOCAL_VERSION_RP_SIZE); in bt_hci_read_local_version_rp()
1173 static void bt_hci_read_local_commands_rp(struct bt_hci_s *hci) in bt_hci_read_local_commands_rp() argument
1191 bt_hci_event_complete(hci, &lc, READ_LOCAL_COMMANDS_RP_SIZE); in bt_hci_read_local_commands_rp()
1194 static void bt_hci_read_local_features_rp(struct bt_hci_s *hci) in bt_hci_read_local_features_rp() argument
1199 (hci->device.lmp_caps >> 0) & 0xff, in bt_hci_read_local_features_rp()
1200 (hci->device.lmp_caps >> 8) & 0xff, in bt_hci_read_local_features_rp()
1201 (hci->device.lmp_caps >> 16) & 0xff, in bt_hci_read_local_features_rp()
1202 (hci->device.lmp_caps >> 24) & 0xff, in bt_hci_read_local_features_rp()
1203 (hci->device.lmp_caps >> 32) & 0xff, in bt_hci_read_local_features_rp()
1204 (hci->device.lmp_caps >> 40) & 0xff, in bt_hci_read_local_features_rp()
1205 (hci->device.lmp_caps >> 48) & 0xff, in bt_hci_read_local_features_rp()
1206 (hci->device.lmp_caps >> 56) & 0xff, in bt_hci_read_local_features_rp()
1210 bt_hci_event_complete(hci, &lf, READ_LOCAL_FEATURES_RP_SIZE); in bt_hci_read_local_features_rp()
1213 static void bt_hci_read_local_ext_features_rp(struct bt_hci_s *hci, int page) in bt_hci_read_local_ext_features_rp() argument
1227 bt_hci_event_complete(hci, &lef, READ_LOCAL_EXT_FEATURES_RP_SIZE); in bt_hci_read_local_ext_features_rp()
1230 static void bt_hci_read_buffer_size_rp(struct bt_hci_s *hci) in bt_hci_read_buffer_size_rp() argument
1243 bt_hci_event_complete(hci, &bs, READ_BUFFER_SIZE_RP_SIZE); in bt_hci_read_buffer_size_rp()
1247 static void bt_hci_read_country_code_rp(struct bt_hci_s *hci) in bt_hci_read_country_code_rp() argument
1254 bt_hci_event_complete(hci, &cc, READ_COUNTRY_CODE_RP_SIZE); in bt_hci_read_country_code_rp()
1259 static void bt_hci_read_bd_addr_rp(struct bt_hci_s *hci) in bt_hci_read_bd_addr_rp() argument
1263 .bdaddr = BAINIT(&hci->device.bd_addr), in bt_hci_read_bd_addr_rp()
1266 bt_hci_event_complete(hci, &ba, READ_BD_ADDR_RP_SIZE); in bt_hci_read_bd_addr_rp()
1269 static int bt_hci_link_quality_rp(struct bt_hci_s *hci, uint16_t handle) in bt_hci_link_quality_rp() argument
1277 if (bt_hci_handle_bad(hci, handle)) in bt_hci_link_quality_rp()
1280 bt_hci_event_complete(hci, &lq, READ_LINK_QUALITY_RP_SIZE); in bt_hci_link_quality_rp()
1285 static inline void bt_hci_event_complete_status(struct bt_hci_s *hci, in bt_hci_event_complete_status() argument
1288 bt_hci_event_complete(hci, &status, 1); in bt_hci_event_complete_status()
1291 static inline void bt_hci_event_complete_conn_cancel(struct bt_hci_s *hci, in bt_hci_event_complete_conn_cancel() argument
1299 bt_hci_event_complete(hci, &params, CREATE_CONN_CANCEL_RP_SIZE); in bt_hci_event_complete_conn_cancel()
1302 static inline void bt_hci_event_auth_complete(struct bt_hci_s *hci, in bt_hci_event_auth_complete() argument
1310 bt_hci_event(hci, EVT_AUTH_COMPLETE, &params, EVT_AUTH_COMPLETE_SIZE); in bt_hci_event_auth_complete()
1313 static inline void bt_hci_event_encrypt_change(struct bt_hci_s *hci, in bt_hci_event_encrypt_change() argument
1322 bt_hci_event(hci, EVT_ENCRYPT_CHANGE, &params, EVT_ENCRYPT_CHANGE_SIZE); in bt_hci_event_encrypt_change()
1325 static inline void bt_hci_event_complete_name_cancel(struct bt_hci_s *hci, in bt_hci_event_complete_name_cancel() argument
1333 bt_hci_event_complete(hci, &params, REMOTE_NAME_REQ_CANCEL_RP_SIZE); in bt_hci_event_complete_name_cancel()
1336 static inline void bt_hci_event_read_remote_ext_features(struct bt_hci_s *hci, in bt_hci_event_read_remote_ext_features() argument
1345 bt_hci_event(hci, EVT_READ_REMOTE_EXT_FEATURES_COMPLETE, in bt_hci_event_read_remote_ext_features()
1349 static inline void bt_hci_event_complete_lmp_handle(struct bt_hci_s *hci, in bt_hci_event_complete_lmp_handle() argument
1359 bt_hci_event_complete(hci, &params, READ_LMP_HANDLE_RP_SIZE); in bt_hci_event_complete_lmp_handle()
1362 static inline void bt_hci_event_complete_role_discovery(struct bt_hci_s *hci, in bt_hci_event_complete_role_discovery() argument
1371 bt_hci_event_complete(hci, &params, ROLE_DISCOVERY_RP_SIZE); in bt_hci_event_complete_role_discovery()
1374 static inline void bt_hci_event_complete_flush(struct bt_hci_s *hci, in bt_hci_event_complete_flush() argument
1382 bt_hci_event_complete(hci, &params, FLUSH_RP_SIZE); in bt_hci_event_complete_flush()
1385 static inline void bt_hci_event_complete_read_local_name(struct bt_hci_s *hci) in bt_hci_event_complete_read_local_name() argument
1390 if (hci->device.lmp_name) in bt_hci_event_complete_read_local_name()
1391 strncpy(params.name, hci->device.lmp_name, sizeof(params.name)); in bt_hci_event_complete_read_local_name()
1393 bt_hci_event_complete(hci, &params, READ_LOCAL_NAME_RP_SIZE); in bt_hci_event_complete_read_local_name()
1397 struct bt_hci_s *hci) in bt_hci_event_complete_read_conn_accept_timeout() argument
1401 .timeout = cpu_to_le16(hci->conn_accept_tout), in bt_hci_event_complete_read_conn_accept_timeout()
1404 bt_hci_event_complete(hci, &params, READ_CONN_ACCEPT_TIMEOUT_RP_SIZE); in bt_hci_event_complete_read_conn_accept_timeout()
1407 static inline void bt_hci_event_complete_read_scan_enable(struct bt_hci_s *hci) in bt_hci_event_complete_read_scan_enable() argument
1412 (hci->device.inquiry_scan ? SCAN_INQUIRY : 0) | in bt_hci_event_complete_read_scan_enable()
1413 (hci->device.page_scan ? SCAN_PAGE : 0), in bt_hci_event_complete_read_scan_enable()
1416 bt_hci_event_complete(hci, &params, READ_SCAN_ENABLE_RP_SIZE); in bt_hci_event_complete_read_scan_enable()
1419 static inline void bt_hci_event_complete_read_local_class(struct bt_hci_s *hci) in bt_hci_event_complete_read_local_class() argument
1424 memcpy(params.dev_class, hci->device.class, sizeof(params.dev_class)); in bt_hci_event_complete_read_local_class()
1426 bt_hci_event_complete(hci, &params, READ_CLASS_OF_DEV_RP_SIZE); in bt_hci_event_complete_read_local_class()
1429 static inline void bt_hci_event_complete_voice_setting(struct bt_hci_s *hci) in bt_hci_event_complete_voice_setting() argument
1433 .voice_setting = hci->voice_setting, /* Note: no swapping */ in bt_hci_event_complete_voice_setting()
1436 bt_hci_event_complete(hci, &params, READ_VOICE_SETTING_RP_SIZE); in bt_hci_event_complete_voice_setting()
1440 struct bt_hci_s *hci) in bt_hci_event_complete_read_inquiry_mode() argument
1444 .mode = hci->lm.inquiry_mode, in bt_hci_event_complete_read_inquiry_mode()
1447 bt_hci_event_complete(hci, &params, READ_INQUIRY_MODE_RP_SIZE); in bt_hci_event_complete_read_inquiry_mode()
1450 static inline void bt_hci_event_num_comp_pkts(struct bt_hci_s *hci, in bt_hci_event_num_comp_pkts() argument
1460 bt_hci_event(hci, EVT_NUM_COMP_PKTS, params, EVT_NUM_COMP_PKTS_SIZE(1)); in bt_hci_event_num_comp_pkts()
1466 struct bt_hci_s *hci = hci_from_info(info); in bt_submit_hci() local
1473 memcpy(&hci->last_cmd, data, 2); in bt_submit_hci()
1497 bt_hci_event_complete_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1501 hci->lm.inquire = 1; in bt_submit_hci()
1502 hci->lm.periodic = 0; in bt_submit_hci()
1503 hci->lm.responses_left = PARAM(inquiry, num_rsp) ?: INT_MAX; in bt_submit_hci()
1504 hci->lm.responses = 0; in bt_submit_hci()
1505 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1506 bt_hci_inquiry_start(hci, PARAM(inquiry, length)); in bt_submit_hci()
1510 if (!hci->lm.inquire || hci->lm.periodic) { in bt_submit_hci()
1516 bt_hci_event_complete_status(hci, HCI_COMMAND_DISALLOWED); in bt_submit_hci()
1520 hci->lm.inquire = 0; in bt_submit_hci()
1521 qemu_del_timer(hci->lm.inquiry_done); in bt_submit_hci()
1522 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1535 bt_hci_event_complete_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1539 hci->lm.inquire = 1; in bt_submit_hci()
1540 hci->lm.periodic = 1; in bt_submit_hci()
1541 hci->lm.responses_left = PARAM(periodic_inquiry, num_rsp); in bt_submit_hci()
1542 hci->lm.responses = 0; in bt_submit_hci()
1543 hci->lm.inquiry_period = PARAM16(periodic_inquiry, max_period); in bt_submit_hci()
1544 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1545 bt_hci_inquiry_start(hci, PARAM(periodic_inquiry, length)); in bt_submit_hci()
1549 if (!hci->lm.inquire || !hci->lm.periodic) { in bt_submit_hci()
1555 bt_hci_event_complete_status(hci, HCI_COMMAND_DISALLOWED); in bt_submit_hci()
1558 hci->lm.inquire = 0; in bt_submit_hci()
1559 qemu_del_timer(hci->lm.inquiry_done); in bt_submit_hci()
1560 qemu_del_timer(hci->lm.inquiry_next); in bt_submit_hci()
1561 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1567 if (hci->lm.connecting >= HCI_HANDLES_MAX) { in bt_submit_hci()
1568 bt_hci_event_status(hci, HCI_REJECTED_LIMITED_RESOURCES); in bt_submit_hci()
1571 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1573 if (bt_hci_connect(hci, &PARAM(create_conn, bdaddr))) in bt_submit_hci()
1574 bt_hci_connection_reject_event(hci, &PARAM(create_conn, bdaddr)); in bt_submit_hci()
1580 if (bt_hci_handle_bad(hci, PARAMHANDLE(disconnect))) { in bt_submit_hci()
1581 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1585 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1586 bt_hci_disconnect(hci, PARAMHANDLE(disconnect), in bt_submit_hci()
1593 if (bt_hci_lmp_connection_ready(hci, in bt_submit_hci()
1596 if (bt_hci_role_master(hci, i) && hci->lm.handle[i].link && in bt_submit_hci()
1597 !bacmp(&hci->lm.handle[i].link->slave->bd_addr, in bt_submit_hci()
1601 bt_hci_event_complete_conn_cancel(hci, i < HCI_HANDLES_MAX ? in bt_submit_hci()
1605 bt_hci_event_complete_conn_cancel(hci, HCI_SUCCESS, in bt_submit_hci()
1612 if (!hci->conn_req_host || in bt_submit_hci()
1614 &hci->conn_req_host->bd_addr)) { in bt_submit_hci()
1615 bt_hci_event_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1619 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1620 bt_hci_connection_accept(hci, hci->conn_req_host); in bt_submit_hci()
1621 hci->conn_req_host = NULL; in bt_submit_hci()
1627 if (!hci->conn_req_host || in bt_submit_hci()
1629 &hci->conn_req_host->bd_addr)) { in bt_submit_hci()
1630 bt_hci_event_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1634 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1635 bt_hci_connection_reject(hci, hci->conn_req_host, in bt_submit_hci()
1637 bt_hci_connection_reject_event(hci, &hci->conn_req_host->bd_addr); in bt_submit_hci()
1638 hci->conn_req_host = NULL; in bt_submit_hci()
1644 if (bt_hci_handle_bad(hci, PARAMHANDLE(auth_requested))) in bt_submit_hci()
1645 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1647 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1648 bt_hci_event_auth_complete(hci, PARAMHANDLE(auth_requested)); in bt_submit_hci()
1655 if (bt_hci_handle_bad(hci, PARAMHANDLE(set_conn_encrypt))) in bt_submit_hci()
1656 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1658 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1659 bt_hci_event_encrypt_change(hci, in bt_submit_hci()
1668 if (bt_hci_name_req(hci, &PARAM(remote_name_req, bdaddr))) in bt_submit_hci()
1669 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1675 bt_hci_event_complete_name_cancel(hci, in bt_submit_hci()
1682 if (bt_hci_features_req(hci, PARAMHANDLE(read_remote_features))) in bt_submit_hci()
1683 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1689 if (bt_hci_handle_bad(hci, PARAMHANDLE(read_remote_ext_features))) in bt_submit_hci()
1690 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1692 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1693 bt_hci_event_read_remote_ext_features(hci, in bt_submit_hci()
1701 if (bt_hci_version_req(hci, PARAMHANDLE(read_remote_version))) in bt_submit_hci()
1702 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1708 if (bt_hci_clkoffset_req(hci, PARAMHANDLE(read_clock_offset))) in bt_submit_hci()
1709 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1716 bt_hci_event_complete_lmp_handle(hci, PARAMHANDLE(read_lmp_handle)); in bt_submit_hci()
1728 bt_hci_event_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1732 if (bt_hci_mode_change(hci, PARAMHANDLE(hold_mode), in bt_submit_hci()
1735 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1746 bt_hci_event_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1750 if (bt_hci_mode_change(hci, PARAMHANDLE(park_mode), in bt_submit_hci()
1753 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1759 if (bt_hci_mode_cancel(hci, PARAMHANDLE(exit_park_mode), in bt_submit_hci()
1761 bt_hci_event_status(hci, HCI_NO_CONNECTION); in bt_submit_hci()
1767 if (bt_hci_handle_bad(hci, PARAMHANDLE(role_discovery))) in bt_submit_hci()
1768 bt_hci_event_complete_role_discovery(hci, in bt_submit_hci()
1771 bt_hci_event_complete_role_discovery(hci, in bt_submit_hci()
1773 bt_hci_role_master(hci, in bt_submit_hci()
1780 memcpy(hci->event_mask, PARAM(set_event_mask, mask), 8); in bt_submit_hci()
1781 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1785 bt_hci_reset(hci); in bt_submit_hci()
1786 bt_hci_event_status(hci, HCI_SUCCESS); in bt_submit_hci()
1796 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1802 if (bt_hci_handle_bad(hci, PARAMHANDLE(flush))) in bt_submit_hci()
1803 bt_hci_event_complete_flush(hci, in bt_submit_hci()
1807 bt_hci_event(hci, EVT_FLUSH_OCCURRED, in bt_submit_hci()
1810 bt_hci_event_complete_flush(hci, in bt_submit_hci()
1818 if (hci->device.lmp_name) in bt_submit_hci()
1819 qemu_free((void *) hci->device.lmp_name); in bt_submit_hci()
1820 hci->device.lmp_name = qemu_strndup(PARAM(change_local_name, name), in bt_submit_hci()
1822 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1826 bt_hci_event_complete_read_local_name(hci); in bt_submit_hci()
1830 bt_hci_event_complete_read_conn_accept_timeout(hci); in bt_submit_hci()
1839 bt_hci_event_complete_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1843 hci->conn_accept_tout = PARAM16(write_conn_accept_timeout, timeout); in bt_submit_hci()
1844 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1848 bt_hci_event_complete_read_scan_enable(hci); in bt_submit_hci()
1855 hci->device.inquiry_scan = in bt_submit_hci()
1857 hci->device.page_scan = in bt_submit_hci()
1859 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1863 bt_hci_event_complete_read_local_class(hci); in bt_submit_hci()
1869 memcpy(hci->device.class, PARAM(write_class_of_dev, dev_class), in bt_submit_hci()
1871 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1875 bt_hci_event_complete_voice_setting(hci); in bt_submit_hci()
1881 hci->voice_setting = PARAM(write_voice_setting, voice_setting); in bt_submit_hci()
1882 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1890 if (bt_hci_handle_bad(hci, in bt_submit_hci()
1892 bt_hci_event_complete_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1899 bt_hci_event_complete_read_inquiry_mode(hci); in bt_submit_hci()
1909 bt_hci_event_complete_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1913 hci->lm.inquiry_mode = PARAM(write_inquiry_mode, mode); in bt_submit_hci()
1914 bt_hci_event_complete_status(hci, HCI_SUCCESS); in bt_submit_hci()
1918 bt_hci_read_local_version_rp(hci); in bt_submit_hci()
1922 bt_hci_read_local_commands_rp(hci); in bt_submit_hci()
1926 bt_hci_read_local_features_rp(hci); in bt_submit_hci()
1932 bt_hci_read_local_ext_features_rp(hci, in bt_submit_hci()
1937 bt_hci_read_buffer_size_rp(hci); in bt_submit_hci()
1941 bt_hci_read_country_code_rp(hci); in bt_submit_hci()
1945 bt_hci_read_bd_addr_rp(hci); in bt_submit_hci()
1951 bt_hci_link_quality_rp(hci, PARAMHANDLE(read_link_quality)); in bt_submit_hci()
1955 bt_hci_event_status(hci, HCI_UNKNOWN_COMMAND); in bt_submit_hci()
1961 bt_hci_event_status(hci, HCI_INVALID_PARAMETERS); in bt_submit_hci()
1970 static inline void bt_hci_lmp_acl_data(struct bt_hci_s *hci, uint16_t handle, in bt_hci_lmp_acl_data() argument
1973 struct hci_acl_hdr *pkt = (void *) hci->acl_buf; in bt_hci_lmp_acl_data()
1978 if (len + HCI_ACL_HDR_SIZE > sizeof(hci->acl_buf)) { in bt_hci_lmp_acl_data()
1983 memcpy(hci->acl_buf + HCI_ACL_HDR_SIZE, data, len); in bt_hci_lmp_acl_data()
1988 hci->info.acl_recv(hci->info.opaque, in bt_hci_lmp_acl_data()
1989 hci->acl_buf, len + HCI_ACL_HDR_SIZE); in bt_hci_lmp_acl_data()
2011 struct bt_hci_s *hci = hci_from_info(info); in bt_submit_acl() local
2028 if (bt_hci_handle_bad(hci, handle)) { in bt_submit_acl()
2042 link = hci->lm.handle[handle].link; in bt_submit_acl()
2045 if (!hci->asb_handle) in bt_submit_acl()
2046 hci->asb_handle = handle; in bt_submit_acl()
2047 else if (handle != hci->asb_handle) { in bt_submit_acl()
2058 if (!hci->psb_handle) in bt_submit_acl()
2059 hci->psb_handle = handle; in bt_submit_acl()
2060 else if (handle != hci->psb_handle) { in bt_submit_acl()
2071 bt_hci_event_num_comp_pkts(hci, handle | HCI_HANDLE_OFFSET, 1); in bt_submit_acl()
2074 hci->lm.handle[handle].lmp_acl_data(link, data, in bt_submit_acl()
2081 struct bt_hci_s *hci = hci_from_info(info); in bt_submit_sco() local
2092 if (bt_hci_handle_bad(hci, handle)) { in bt_submit_sco()
2130 struct bt_hci_s *hci = hci_from_info(info); in bt_hci_bdaddr_set() local
2132 bacpy(&hci->device.bd_addr, (const bdaddr_t *) bd_addr); in bt_hci_bdaddr_set()
2139 struct bt_hci_s *hci = hci_from_device(dev); in bt_hci_destroy() local
2141 bt_hci_done(&hci->info); in bt_hci_destroy()
2185 struct bt_hci_s *hci = hci_from_info(info); in bt_hci_done() local
2188 bt_device_done(&hci->device); in bt_hci_done()
2190 if (hci->device.lmp_name) in bt_hci_done()
2191 qemu_free((void *) hci->device.lmp_name); in bt_hci_done()
2196 if (hci->conn_req_host) { in bt_hci_done()
2197 bt_hci_connection_reject(hci, in bt_hci_done()
2198 hci->conn_req_host, HCI_OE_POWER_OFF); in bt_hci_done()
2204 if (!bt_hci_handle_bad(hci, handle)) in bt_hci_done()
2205 bt_hci_disconnect(hci, handle, HCI_OE_POWER_OFF); in bt_hci_done()
2216 qemu_free_timer(hci->lm.inquiry_done); in bt_hci_done()
2217 qemu_free_timer(hci->lm.inquiry_next); in bt_hci_done()
2218 qemu_free_timer(hci->conn_accept_timer); in bt_hci_done()
2220 qemu_free(hci); in bt_hci_done()