static void func_lock_isoch_mutex(TRANSFER_DATA* transfer_data) { int noAck = 0; IUDEVICE* pdev; UINT32 FunctionId; UINT32 RequestField; UINT16 URB_Function; IUDEVMAN* udevman = transfer_data->udevman; if (transfer_data->cbSize >= 8) { data_read_UINT32(transfer_data->pBuffer + 4, FunctionId); if ((FunctionId == TRANSFER_IN_REQUEST || FunctionId == TRANSFER_OUT_REQUEST) && transfer_data->cbSize >= 16) { data_read_UINT16(transfer_data->pBuffer + 14, URB_Function); if (URB_Function == URB_FUNCTION_ISOCH_TRANSFER && transfer_data->cbSize >= 20) { data_read_UINT32(transfer_data->pBuffer + 16, RequestField); noAck = (RequestField & 0x80000000) >> 31; if (!noAck) { pdev = udevman->get_udevice_by_UsbDevice(udevman, transfer_data->UsbDevice); pdev->lock_fifo_isoch(pdev); } }
static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_number, int UsbDevice, uint16_t idVendor, uint16_t idProduct, char * option) { UDEVMAN * udevman = (UDEVMAN *) idevman; IUDEVICE* pdev; if (option && strcmp(option, "new") == 0) { pdev = udev_new_by_addr(bus_number, dev_number); if (pdev == NULL) return 0; } else if (option && strcmp(option, "renew") == 0) { pdev = udev_new_by_id(idVendor, idProduct); if (pdev == NULL) return 0; } else { printf("udevman_register_udevice: function error!!"); return 0; } pdev->set_UsbDevice(pdev, UsbDevice); if (udevman->head == NULL) { /* linked list is empty */ udevman->head = pdev; udevman->tail = pdev; } else { /* append device to the end of the linked list */ udevman->tail->set_p_next(udevman->tail, pdev); pdev->set_p_prev(pdev, udevman->tail); udevman->tail = pdev; } udevman->device_num += 1; return 1; }
static IUDEVICE* udevman_get_udevice_by_addr(IUDEVMAN * idevman, int bus_number, int dev_number) { IUDEVICE * pdev; idevman->rewind (idevman); while (idevman->has_next (idevman)) { pdev = idevman->get_next (idevman); if (pdev->get_bus_number(pdev) == bus_number && pdev->get_dev_number(pdev) == dev_number) { idevman->loading_unlock(idevman); return pdev; } } printf("udevman_get_udevice_by_addr: bus:%d dev:%d ERROR!!\n", bus_number, dev_number); return NULL; }
static IUDEVICE* udevman_get_udevice_by_addr(IUDEVMAN * idevman, int bus_number, int dev_number) { IUDEVICE * pdev; idevman->loading_lock(idevman); idevman->rewind (idevman); while (idevman->has_next (idevman)) { pdev = idevman->get_next (idevman); if (pdev->get_bus_number(pdev) == bus_number && pdev->get_dev_number(pdev) == dev_number) { idevman->loading_unlock(idevman); return pdev; } } idevman->loading_unlock(idevman); LLOGLN(libusb_debug, ("%s: bus:%d dev:%d not exist in udevman", __func__, bus_number, dev_number)); return NULL; }
static int udevman_register_udevice(IUDEVMAN* idevman, int bus_number, int dev_number, int UsbDevice, uint16 idVendor, uint16 idProduct, int flag) { UDEVMAN * udevman = (UDEVMAN *) idevman; IUDEVICE * pdev = NULL; IUDEVICE ** devArray; int i, num, addnum = 0; pdev = (IUDEVICE *)udevman_get_udevice_by_addr(idevman, bus_number, dev_number); if (pdev != NULL) return 0; if (flag == UDEVMAN_FLAG_ADD_BY_ADDR) { pdev = udev_new_by_addr(bus_number, dev_number); if (pdev == NULL) return 0; pdev->set_UsbDevice(pdev, UsbDevice); idevman->loading_lock(idevman); if (udevman->head == NULL) { /* linked list is empty */ udevman->head = pdev; udevman->tail = pdev; } else { /* append device to the end of the linked list */ udevman->tail->set_p_next(udevman->tail, pdev); pdev->set_p_prev(pdev, udevman->tail); udevman->tail = pdev; } udevman->device_num += 1; idevman->loading_unlock(idevman); } else if (flag == UDEVMAN_FLAG_ADD_BY_VID_PID) { addnum = 0; /* register all device that match pid vid */ num = udev_new_by_id(idVendor, idProduct, &devArray); for (i = 0; i < num; i++) { pdev = devArray[i]; if (udevman_get_udevice_by_addr(idevman, pdev->get_bus_number(pdev), pdev->get_dev_number(pdev)) != NULL) { zfree(pdev); continue; } pdev->set_UsbDevice(pdev, UsbDevice); idevman->loading_lock(idevman); if (udevman->head == NULL) { /* linked list is empty */ udevman->head = pdev; udevman->tail = pdev; } else { /* append device to the end of the linked list */ udevman->tail->set_p_next(udevman->tail, pdev); pdev->set_p_prev(pdev, udevman->tail); udevman->tail = pdev; } udevman->device_num += 1; idevman->loading_unlock(idevman); addnum++; } zfree(devArray); return addnum; } else { printf("udevman_register_udevice: function error!!"); return 0; } return 1; }