Lines Matching refs:p_dev
80 static int uhid_read_event(btif_hh_device_t* p_dev) { in uhid_read_event() argument
81 CHECK(p_dev); in uhid_read_event()
87 OSI_NO_INTR(ret = read(p_dev->fd, &ev, sizeof(ev))); in uhid_read_event()
101 p_dev->ready_for_data = true; in uhid_read_event()
105 p_dev->ready_for_data = false; in uhid_read_event()
109 p_dev->ready_for_data = true; in uhid_read_event()
113 p_dev->ready_for_data = false; in uhid_read_event()
127 btif_hh_setreport(p_dev, BTHH_FEATURE_REPORT, ev.u.output.size, in uhid_read_event()
130 btif_hh_senddata(p_dev, ev.u.output.size, ev.u.output.data); in uhid_read_event()
152 p_dev->get_rpt_snt++; in uhid_read_event()
153 if (p_dev->get_rpt_id_queue) { in uhid_read_event()
156 fixed_queue_enqueue(p_dev->get_rpt_id_queue, (void*)get_rpt_id); in uhid_read_event()
159 btif_hh_getreport(p_dev, BTHH_FEATURE_REPORT, ev.u.feature.rnum, 0); in uhid_read_event()
176 btif_hh_setreport(p_dev, BTHH_FEATURE_REPORT, in uhid_read_event()
179 btif_hh_setreport(p_dev, BTHH_OUTPUT_REPORT, in uhid_read_event()
182 btif_hh_setreport(p_dev, BTHH_INPUT_REPORT, in uhid_read_event()
231 btif_hh_device_t* p_dev = (btif_hh_device_t*)arg; in btif_hh_poll_event_thread() local
240 p_dev->hh_poll_thread_id = -1; in btif_hh_poll_event_thread()
243 p_dev->pid = gettid(); in btif_hh_poll_event_thread()
246 BT_HH_THREAD, p_dev->pid, p_dev->fd); in btif_hh_poll_event_thread()
248 pfds[0].fd = p_dev->fd; in btif_hh_poll_event_thread()
252 uhid_set_non_blocking(p_dev->fd); in btif_hh_poll_event_thread()
254 while (p_dev->hh_keep_polling) { in btif_hh_poll_event_thread()
264 ret = uhid_read_event(p_dev); in btif_hh_poll_event_thread()
269 p_dev->hh_poll_thread_id = -1; in btif_hh_poll_event_thread()
270 p_dev->pid = -1; in btif_hh_poll_event_thread()
274 static inline void btif_hh_close_poll_thread(btif_hh_device_t* p_dev) { in btif_hh_close_poll_thread() argument
276 p_dev->hh_keep_polling = 0; in btif_hh_close_poll_thread()
277 if (p_dev->hh_poll_thread_id > 0) in btif_hh_close_poll_thread()
278 pthread_join(p_dev->hh_poll_thread_id, NULL); in btif_hh_close_poll_thread()
320 btif_hh_device_t* p_dev = NULL; in bta_hh_co_open() local
329 p_dev = &btif_hh_cb.devices[i]; in bta_hh_co_open()
330 if (p_dev->dev_status != BTHH_CONN_STATE_UNKNOWN && in bta_hh_co_open()
331 p_dev->dev_handle == dev_handle) { in bta_hh_co_open()
336 __func__, p_dev->dev_status, p_dev->bd_addr.ToString().c_str(), in bta_hh_co_open()
337 p_dev->attr_mask, p_dev->sub_class, p_dev->app_id); in bta_hh_co_open()
339 if (p_dev->fd < 0) { in bta_hh_co_open()
340 p_dev->fd = open(dev_path, O_RDWR | O_CLOEXEC); in bta_hh_co_open()
341 if (p_dev->fd < 0) { in bta_hh_co_open()
346 APPL_TRACE_DEBUG("%s: uhid fd = %d", __func__, p_dev->fd); in bta_hh_co_open()
349 p_dev->hh_keep_polling = 1; in bta_hh_co_open()
350 p_dev->hh_poll_thread_id = in bta_hh_co_open()
351 create_thread(btif_hh_poll_event_thread, p_dev); in bta_hh_co_open()
354 p_dev = NULL; in bta_hh_co_open()
357 if (p_dev == NULL) { in bta_hh_co_open()
361 p_dev = &btif_hh_cb.devices[i]; in bta_hh_co_open()
362 p_dev->dev_handle = dev_handle; in bta_hh_co_open()
363 p_dev->attr_mask = attr_mask; in bta_hh_co_open()
364 p_dev->sub_class = sub_class; in bta_hh_co_open()
365 p_dev->app_id = app_id; in bta_hh_co_open()
366 p_dev->local_vup = false; in bta_hh_co_open()
370 p_dev->fd = open(dev_path, O_RDWR | O_CLOEXEC); in bta_hh_co_open()
371 if (p_dev->fd < 0) { in bta_hh_co_open()
376 APPL_TRACE_DEBUG("%s: uhid fd = %d", __func__, p_dev->fd); in bta_hh_co_open()
377 p_dev->hh_keep_polling = 1; in bta_hh_co_open()
378 p_dev->hh_poll_thread_id = in bta_hh_co_open()
379 create_thread(btif_hh_poll_event_thread, p_dev); in bta_hh_co_open()
387 if (p_dev == NULL) { in bta_hh_co_open()
392 p_dev->dev_status = BTHH_CONN_STATE_CONNECTED; in bta_hh_co_open()
393 p_dev->get_rpt_id_queue = fixed_queue_new(SIZE_MAX); in bta_hh_co_open()
394 CHECK(p_dev->get_rpt_id_queue); in bta_hh_co_open()
396 APPL_TRACE_DEBUG("%s: Return device status %d", __func__, p_dev->dev_status); in bta_hh_co_open()
413 btif_hh_device_t* p_dev = NULL; in bta_hh_co_close() local
424 p_dev = &btif_hh_cb.devices[i]; in bta_hh_co_close()
425 fixed_queue_flush(p_dev->get_rpt_id_queue, osi_free); in bta_hh_co_close()
426 fixed_queue_free(p_dev->get_rpt_id_queue, NULL); in bta_hh_co_close()
427 p_dev->get_rpt_id_queue = NULL; in bta_hh_co_close()
428 if (p_dev->dev_status != BTHH_CONN_STATE_UNKNOWN && in bta_hh_co_close()
429 p_dev->dev_handle == dev_handle) { in bta_hh_co_close()
433 __func__, p_dev->dev_status, p_dev->dev_handle); in bta_hh_co_close()
434 btif_hh_close_poll_thread(p_dev); in bta_hh_co_close()
460 btif_hh_device_t* p_dev; in bta_hh_co_data() local
467 p_dev = btif_hh_find_connected_dev_by_handle(dev_handle); in bta_hh_co_data()
468 if (p_dev == NULL) { in bta_hh_co_data()
476 if (p_dev->fd >= 0) { in bta_hh_co_data()
478 while (!p_dev->ready_for_data && in bta_hh_co_data()
485 if ((p_dev->fd >= 0) && p_dev->ready_for_data) { in bta_hh_co_data()
486 bta_hh_co_write(p_dev->fd, p_rpt, len); in bta_hh_co_data()
489 p_dev->fd, p_dev->ready_for_data, len); in bta_hh_co_data()
506 void bta_hh_co_send_hid_info(btif_hh_device_t* p_dev, const char* dev_name, in bta_hh_co_send_hid_info() argument
513 if (p_dev->fd < 0) { in bta_hh_co_send_hid_info()
514 APPL_TRACE_WARNING("%s: Error: fd = %d, dscp_len = %d", __func__, p_dev->fd, in bta_hh_co_send_hid_info()
520 p_dev->fd, dev_name, dscp_len); in bta_hh_co_send_hid_info()
531 p_dev->bd_addr.ToString().c_str()); in bta_hh_co_send_hid_info()
539 result = uhid_write(p_dev->fd, &ev); in bta_hh_co_send_hid_info()
543 p_dev->fd, dscp_len, result); in bta_hh_co_send_hid_info()
550 close(p_dev->fd); in bta_hh_co_send_hid_info()
551 p_dev->fd = -1; in bta_hh_co_send_hid_info()
582 btif_hh_device_t* p_dev; in bta_hh_co_get_rpt_rsp() local
586 p_dev = btif_hh_find_connected_dev_by_handle(dev_handle); in bta_hh_co_get_rpt_rsp()
587 if (p_dev == NULL) { in bta_hh_co_get_rpt_rsp()
593 if (!p_dev->get_rpt_id_queue) { in bta_hh_co_get_rpt_rsp()
599 if (p_dev->fd >= 0 && p_dev->get_rpt_snt > 0 && p_dev->get_rpt_snt--) { in bta_hh_co_get_rpt_rsp()
601 (uint32_t*)fixed_queue_dequeue(p_dev->get_rpt_id_queue); in bta_hh_co_get_rpt_rsp()
615 uhid_write(p_dev->fd, &ev); in bta_hh_co_get_rpt_rsp()