这篇教程C++ usb_sndctrlpipe函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_sndctrlpipe函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_sndctrlpipe函数的具体用法?C++ usb_sndctrlpipe怎么用?C++ usb_sndctrlpipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_sndctrlpipe函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: zd1201_fw_uploadstatic int zd1201_fw_upload(struct usb_device *dev, int apfw){ const struct firmware *fw_entry; const char *data; unsigned long len; int err; unsigned char ret; char *buf; char *fwfile; if (apfw) fwfile = "zd1201-ap.fw"; else fwfile = "zd1201.fw"; err = request_firmware(&fw_entry, fwfile, &dev->dev); if (err) { dev_err(&dev->dev, "Failed to load %s firmware file!/n", fwfile); dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed./n"); dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info./n"); return err; } data = fw_entry->data; len = fw_entry->size; buf = kmalloc(1024, GFP_ATOMIC); if (!buf) goto exit; while (len > 0) { int translen = (len > 1024) ? 1024 : len; memcpy(buf, data, translen); err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0, USB_DIR_OUT | 0x40, 0, 0, buf, translen, ZD1201_FW_TIMEOUT); if (err < 0) goto exit; len -= translen; data += translen; } err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0x2, USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT); if (err < 0) goto exit; err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT); if (err < 0) goto exit; if (ret & 0x80) { err = -EIO; goto exit; } err = 0;exit: kfree(buf); release_firmware(fw_entry); return err;}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:65,
示例2: spin_lock_irqstatic ssize_t wdm_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos){ u8 *buf; int rv = -EMSGSIZE, r, we; struct wdm_device *desc = file->private_data; struct usb_ctrlrequest *req; if (count > desc->wMaxCommand) count = desc->wMaxCommand; spin_lock_irq(&desc->iuspin); we = desc->werr; desc->werr = 0; spin_unlock_irq(&desc->iuspin); if (we < 0) return -EIO; r = mutex_lock_interruptible(&desc->wlock); /* concurrent writes */ rv = -ERESTARTSYS; if (r) goto outnl; r = usb_autopm_get_interface(desc->intf); if (r < 0) goto outnp; r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, &desc->flags)); if (r < 0) goto out; if (test_bit(WDM_DISCONNECTING, &desc->flags)) { rv = -ENODEV; goto out; } desc->outbuf = buf = kmalloc(count, GFP_KERNEL); if (!buf) { rv = -ENOMEM; goto out; } r = copy_from_user(buf, buffer, count); if (r > 0) { kfree(buf); rv = -EFAULT; goto out; } req = desc->orq; usb_fill_control_urb( desc->command, interface_to_usbdev(desc->intf), /* using common endpoint 0 */ usb_sndctrlpipe(interface_to_usbdev(desc->intf), 0), (unsigned char *)req, buf, count, wdm_out_callback, desc ); req->bRequestType = (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE); req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; req->wValue = 0; req->wIndex = desc->inum; req->wLength = cpu_to_le16(count); set_bit(WDM_IN_USE, &desc->flags); rv = usb_submit_urb(desc->command, GFP_KERNEL); if (rv < 0) { kfree(buf); clear_bit(WDM_IN_USE, &desc->flags); dev_err(&desc->intf->dev, "Tx URB error: %d/n", rv); } else { dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", req->wIndex); }out: usb_autopm_put_interface(desc->intf);outnp: mutex_unlock(&desc->wlock);outnl: return rv < 0 ? rv : count;}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:86,
示例3: btusb_send_framestatic int btusb_send_frame(struct sk_buff *skb){ struct hci_dev *hdev = (struct hci_dev *) skb->dev; struct btusb_data *data = hdev->driver_data; struct usb_ctrlrequest *dr; struct urb *urb; unsigned int pipe; int err; BT_DBG("%s", hdev->name); if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) return -ENOMEM; dr = kmalloc(sizeof(*dr), GFP_ATOMIC); if (!dr) { usb_free_urb(urb); return -ENOMEM; } dr->bRequestType = data->cmdreq_type; dr->bRequest = 0; dr->wIndex = 0; dr->wValue = 0; dr->wLength = __cpu_to_le16(skb->len); pipe = usb_sndctrlpipe(data->udev, 0x00); usb_fill_control_urb(urb, data->udev, pipe, (void *) dr, skb->data, skb->len, btusb_tx_complete, skb); hdev->stat.cmd_tx++; break; case HCI_ACLDATA_PKT: if (!data->bulk_tx_ep || (hdev->conn_hash.acl_num < 1 && hdev->conn_hash.le_num < 1)) return -ENODEV; urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) return -ENOMEM; pipe = usb_sndbulkpipe(data->udev, data->bulk_tx_ep->bEndpointAddress); usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len, btusb_tx_complete, skb); hdev->stat.acl_tx++; break; case HCI_SCODATA_PKT: if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1) return -ENODEV; urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC); if (!urb) return -ENOMEM; pipe = usb_sndisocpipe(data->udev, data->isoc_tx_ep->bEndpointAddress); usb_fill_int_urb(urb, data->udev, pipe, skb->data, skb->len, btusb_isoc_tx_complete, skb, data->isoc_tx_ep->bInterval); urb->transfer_flags = URB_ISO_ASAP; __fill_isoc_descriptor(urb, skb->len, le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize)); hdev->stat.sco_tx++; goto skip_waking; default: return -EILSEQ; } err = inc_tx(data); if (err) { usb_anchor_urb(urb, &data->deferred); schedule_work(&data->waker); err = 0; goto done; }skip_waking: usb_anchor_urb(urb, &data->tx_anchor); err = usb_submit_urb(urb, GFP_ATOMIC); if (err < 0) { BT_ERR("%s urb %p submission failed", hdev->name, urb); kfree(urb->setup_packet);//.........这里部分代码省略.........
开发者ID:404992361,项目名称:mi1_kernel,代码行数:101,
示例4: usb_set_port_featurestatic int usb_set_port_feature(struct usb_device *dev, int port, int feature){ return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port, NULL, 0, HZ);}
开发者ID:davidbau,项目名称:davej,代码行数:5,
示例5: InterfaceWRMINTInterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter, UINT addr, PVOID buff, INT len){ int retval = 0; USHORT usRetries = 0 ; if(psIntfAdapter == NULL ) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL"); return -EINVAL; } if(psIntfAdapter->psAdapter->device_removed == TRUE) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed"); return -ENODEV; } if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB)) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus..."); return EACCES; } if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed.."); return -EACCES; } psIntfAdapter->psAdapter->DeviceAccess = TRUE ; do{ retval = usb_control_msg(psIntfAdapter->udev, usb_sndctrlpipe(psIntfAdapter->udev,0), 0x01, 0x42, (addr & 0xFFFF), ((addr >> 16) & 0xFFFF), buff, len, 5000); usRetries++ ; if(-ENODEV == retval) { psIntfAdapter->psAdapter->device_removed = TRUE ; break; } }while((retval < 0) && ( usRetries < MAX_RDM_WRM_RETIRES)); if(retval < 0) { BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries); psIntfAdapter->psAdapter->DeviceAccess = FALSE ; return retval; } else { psIntfAdapter->psAdapter->DeviceAccess = FALSE ; BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval); return STATUS_SUCCESS; } }
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:68,
示例6: update_robotic_armstatic void update_robotic_arm(struct usb_robotic_arm *robotic_arm){ int retval = 0; u8 cmd[3]; cmd[0] = 0; cmd[1] = 0; cmd[2] = 0; /* * Byte 2 controls LED light inside the grip. * If Bit 0 is 1, LED on, otherwise LED off * */ if (robotic_arm->led) cmd[2] = 1; /* * Byte 1 controls the Base Motor * If value is 1, Base Motor rotates clockwise * If value is 2, Base Motor rotates anti-clockwise * Otherwise, Base Motor is off * */ if (robotic_arm->basemotor == 1) cmd[1] = 1; else if (robotic_arm->basemotor == 2) cmd[1] = 2; else cmd[1] = 0; /* * Byte 0 controls the Grip * If value is 1, Grip tightens * If values is 2, Grip Looses * */ if (robotic_arm->gripmotor == 1) cmd[0] = 1; else if (robotic_arm->gripmotor == 2) cmd[0] = 2; /* * Byte 0 controls the Motor 2 * If value is 1, Motor 2 (wrist) moves up * If value is 2, Motor 2 (wrist) moves down * */ else if (robotic_arm->motor2 == 1) cmd[0] = 4; else if (robotic_arm->motor2 == 2) cmd[0] = 8; /* * Byte 0 controls the Motor 3 * If value is 1, Motor 3 (elbow) moves up * If value is 2, Motor 3 (elbow) moves down * */ else if (robotic_arm->motor3 == 1) cmd[0] = 16; else if (robotic_arm->motor3 == 2) cmd[0] = 32; /* * Byte 0 controls the Motor 4 * If value is 1, Motor 4 (shoulder) moves up * If value is 2, Motor 4 (shoulder) moves down * */ else if (robotic_arm->motor4 == 1) cmd[0] = 64; else if (robotic_arm->motor4 == 2) cmd[0] = 128; else cmd[0] = 0; retval = usb_control_msg(robotic_arm->udev, usb_sndctrlpipe(robotic_arm->udev, 0), 6, 0x40, 0x100, 0, cmd, 3, 0); if (retval) dev_dbg(&robotic_arm->udev->dev, "retval = %d/n", retval);}
开发者ID:ferrouswheel,项目名称:robotic_arm_driver,代码行数:92,
示例7: carl9170_usb_load_firmwarestatic int carl9170_usb_load_firmware(struct ar9170 *ar){ const u8 *data; u8 *buf; unsigned int transfer; size_t len; u32 addr; int err = 0; buf = kmalloc(4096, GFP_KERNEL); if (!buf) { err = -ENOMEM; goto err_out; } data = ar->fw.fw->data; len = ar->fw.fw->size; addr = ar->fw.address; /* this removes the miniboot image */ data += ar->fw.offset; len -= ar->fw.offset; while (len) { transfer = min_t(unsigned int, len, 4096u); memcpy(buf, data, transfer); err = usb_control_msg(ar->udev, usb_sndctrlpipe(ar->udev, 0), 0x30 /* FW DL */, 0x40 | USB_DIR_OUT, addr >> 8, 0, buf, transfer, 100); if (err < 0) { kfree(buf); goto err_out; } len -= transfer; data += transfer; addr += transfer; } kfree(buf); err = usb_control_msg(ar->udev, usb_sndctrlpipe(ar->udev, 0), 0x31 /* FW DL COMPLETE */, 0x40 | USB_DIR_OUT, 0, 0, NULL, 0, 200); if (wait_for_completion_timeout(&ar->fw_boot_wait, HZ) == 0) { err = -ETIMEDOUT; goto err_out; } err = carl9170_echo_test(ar, 0x4a110123); if (err) goto err_out; /* now, start the command response counter */ ar->cmd_seq = -1; return 0;err_out: dev_err(&ar->udev->dev, "firmware upload failed (%d)./n", err); return err;}
开发者ID:JonnyH,项目名称:pandora-kernel,代码行数:64,
示例8: g19_input_get_keycodestatic int g19_input_get_keycode(struct input_dev * dev, unsigned int scancode, unsigned int * keycode){ int retval; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) struct input_keymap_entry ke = { .flags = 0, .len = sizeof(scancode), .index = scancode, .scancode = { scancode }, }; retval = input_get_keycode(dev, &ke); *keycode = ke.keycode; #else retval = input_get_keycode(dev, scancode, keycode); #endif return retval;}static void g19_led_send(struct hid_device *hdev){ struct g19_data *data = hid_get_g19data(hdev); data->led_report->field[0]->value[0] = data->led&0xFF; usbhid_submit_report(hdev, data->led_report, USB_DIR_OUT);}static void g19_screen_bl_send(struct hid_device *hdev){ struct usb_interface *intf; struct usb_device *usb_dev; struct g19_data *data = hid_get_g19data(hdev); unsigned int pipe; int i = 0; unsigned char cp[9]; cp[0] = data->screen_bl; cp[1] = 0xe2; cp[2] = 0x12; cp[3] = 0x00; cp[4] = 0x8c; cp[5] = 0x11; cp[6] = 0x00; cp[7] = 0x10; cp[8] = 0x00; intf = to_usb_interface(hdev->dev.parent); usb_dev = interface_to_usbdev(intf); pipe = usb_sndctrlpipe(usb_dev, 0x00); i = usb_control_msg(usb_dev, pipe, 0x0a, USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 0, 0, cp, sizeof(cp), 1 * HZ); if (i < 0) { dev_warn(&hdev->dev, G19_NAME " error setting LCD backlight level %d/n", i); }}static void g19_rgb_send(struct hid_device *hdev){ struct g19_data *data = hid_get_g19data(hdev); data->backlight_report->field[0]->value[0] = data->rgb[0]; data->backlight_report->field[0]->value[1] = data->rgb[1]; data->backlight_report->field[0]->value[2] = data->rgb[2]; usbhid_submit_report(hdev, data->backlight_report, USB_DIR_OUT);}static void g19_led_set(struct led_classdev *led_cdev, enum led_brightness value, int led_num){ struct device *dev; struct hid_device *hdev; struct g19_data *data; u8 mask; /* Get the device associated with the led */ dev = led_cdev->dev->parent; /* Get the hid associated with the device */ hdev = container_of(dev, struct hid_device, dev); /* Get the underlying data value */ data = hid_get_g19data(hdev); mask = 0x80>>led_num; if (value) data->led |= mask; else//.........这里部分代码省略.........
开发者ID:tanktarta,项目名称:lg4l,代码行数:101,
示例9: RTL_W32SUvoid RTL_W32SU(struct rtl8190_priv *priv,unsigned int indx, unsigned int data){ struct usb_device *udev = priv->udev; int status; unsigned char lcv_Count = 0; data=cpu_to_le32(data);#ifdef DEBUG_CHIHHSING //printk("----->(%s, %d)udev=0x%x, indx=0x%x/n", __FUNCTION__, __LINE__, (u32)udev, indx);#endif if (IS_DRV_CLOSE(priv)) {#ifdef CONFIG_RTK_VOIP // rock: reduce debug message#else printk("device unlink - skip %s/n",__FUNCTION__);#endif return; } if (indx==0x320) printk("RTL_W32SU!!/n/n"); status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8192_REQ_SET_REGS, RTL8192_REQT_WRITE, (indx&0xffff), 0, &data, 4, HZ / 2);#if 0 if (status < 0) { printk("write_nic_dword TimeOut! status:%d indx=0x%x/n", status,indx);// BUG(); while(1); }#endif if(status >= 0) { return; } /*if failed, continue*/ while(1) { printk("--------- we try again --------/n"); status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8192_REQ_SET_REGS, RTL8192_REQT_WRITE, (indx&0xffff), 0, &data, 4, (HZ * (++lcv_Count))); if(status >= 0) { break; } } if(status < 0) { printk("write_nic_word TimeOut! status:%x/n", status); dump_stack(); panic("TimeOut"); }#ifdef DEBUG_CHIHHSING printk("(REG_DUMP): write_nic_dword : idx=0x%x val=0x%x/n", indx, data);#endif // printk("w32 index=%x value=%x/n",indx,data); }
开发者ID:kyalipay,项目名称:rtl8192su,代码行数:66,
示例10: ipw_closestatic void ipw_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp){ struct usb_device *dev = port->serial->dev; int result; if (tty_hung_up_p(filp)) { dbg("%s: tty_hung_up_p ...", __func__); return; } /*--1: drop the dtr */ dbg("%s:dropping dtr", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_PIN_CLRDTR, 0, NULL, 0, 200000); if (result < 0) dev_err(&port->dev, "dropping dtr failed (error = %d)/n", result); /*--2: drop the rts */ dbg("%s:dropping rts", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_PIN_CLRRTS, 0, NULL, 0, 200000); if (result < 0) dev_err(&port->dev, "dropping rts failed (error = %d)/n", result); /*--3: purge */ dbg("%s:sending purge", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 0x03, 0, NULL, 0, 200000); if (result < 0) dev_err(&port->dev, "purge failed (error = %d)/n", result); /* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */ result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_RXCTL, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_RXBULK_OFF, 0, /* index */ NULL, 0, 100000); if (result < 0) dev_err(&port->dev, "Disabling bulk RxRead failed (error = %d)/n", result); /* shutdown any in-flight urbs that we know about */ usb_kill_urb(port->read_urb); usb_kill_urb(port->write_urb);}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:73,
示例11: ipw_openstatic int ipw_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp){ struct usb_device *dev = port->serial->dev; u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; u8 *buf_flow_init; int result; dbg("%s", __func__); buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL); if (!buf_flow_init) return -ENOMEM; if (tty) tty->low_latency = 1; /* --1: Tell the modem to initialize (we think) From sniffs this is * always the first thing that gets sent to the modem during * opening of the device */ dbg("%s: Sending SIO_INIT (we guess)", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_INIT, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 0, 0, /* index */ NULL, 0, 100000); if (result < 0) dev_err(&port->dev, "Init of modem failed (error = %d)/n", result); /* reset the bulk pipes */ usb_clear_halt(dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress)); usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress)); /*--2: Start reading from the device */ dbg("%s: setting up bulk read callback", __func__); usb_fill_bulk_urb(port->read_urb, dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), port->bulk_in_buffer, port->bulk_in_size, ipw_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); if (result < 0) dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result); /*--3: Tell the modem to open the floodgates on the rx bulk channel */ dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_RXCTL, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_RXBULK_ON, 0, /* index */ NULL, 0, 100000); if (result < 0) dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)/n", result); /*--4: setup the initial flowcontrol */ dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_HANDFLOW, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 0, 0, buf_flow_init, 0x10, 200000); if (result < 0) dev_err(&port->dev, "initial flowcontrol failed (error = %d)/n", result); /*--5: raise the dtr */ dbg("%s:raising dtr", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_PIN_SETDTR, 0, NULL, 0, 200000); if (result < 0) dev_err(&port->dev, "setting dtr failed (error = %d)/n", result); /*--6: raise the rts */ dbg("%s:raising rts", __func__); result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, IPW_PIN_SETRTS,//.........这里部分代码省略.........
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,
示例12: isight_firmware_loadstatic int isight_firmware_load(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *dev = interface_to_usbdev(intf); int llen, len, req, ret = 0; const struct firmware *firmware; unsigned char *buf = kmalloc(50, GFP_KERNEL); unsigned char data[4]; const u8 *ptr; if (!buf) return -ENOMEM; if (request_firmware(&firmware, "isight.fw", &dev->dev) != 0) { printk(KERN_ERR "Unable to load isight firmware/n"); ret = -ENODEV; goto out; } ptr = firmware->data; buf[0] = 0x01; if (usb_control_msg (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, 300) != 1) { printk(KERN_ERR "Failed to initialise isight firmware loader/n"); ret = -ENODEV; goto out; } while (ptr+4 <= firmware->data+firmware->size) { memcpy(data, ptr, 4); len = (data[0] << 8 | data[1]); req = (data[2] << 8 | data[3]); ptr += 4; if (len == 0x8001) break; /* */ else if (len == 0) continue; for (; len > 0; req += 50) { llen = min(len, 50); len -= llen; if (ptr+llen > firmware->data+firmware->size) { printk(KERN_ERR "Malformed isight firmware"); ret = -ENODEV; goto out; } memcpy(buf, ptr, llen); ptr += llen; if (usb_control_msg (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, req, 0, buf, llen, 300) != llen) { printk(KERN_ERR "Failed to load isight firmware/n"); ret = -ENODEV; goto out; } } } buf[0] = 0x00; if (usb_control_msg (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, 300) != 1) { printk(KERN_ERR "isight firmware loading completion failed/n"); ret = -ENODEV; }out: kfree(buf); release_firmware(firmware); return ret;}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:80,
示例13: zte_ev_usb_serial_closestatic void zte_ev_usb_serial_close(struct usb_serial_port *port){ struct usb_device *udev = port->serial->dev; struct device *dev = &port->dev; int result = 0; int len; unsigned char *buf; buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL); if (!buf) return; /* send 1st ctl cmd(CTL 21 22 02 00 00 00 00 00) */ len = 0; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x22, 0x21, 0x0002, 0x0000, NULL, len, USB_CTRL_GET_TIMEOUT); dev_dbg(dev, "result = %d/n", result); /* send 2st ctl cmd(CTL 21 22 03 00 00 00 00 00 ) */ len = 0; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x22, 0x21, 0x0003, 0x0000, NULL, len, USB_CTRL_GET_TIMEOUT); dev_dbg(dev, "result = %d/n", result); /* send 3st cmd and recieve data */ /* * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5) * 16.0 DI 00 08 07 00 00 00 08 */ len = 0x0007; result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x21, 0xa1, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 4th cmd */ /* * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0 * 16.0 DO 00 c2 01 00 00 00 08 .%..... 30.2.0 */ len = 0x0007; buf[0] = 0x00; buf[1] = 0xc2; buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x20, 0x21, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 5th cmd */ /* * 16.0 CTL 21 22 03 00 00 00 00 00 */ len = 0; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x22, 0x21, 0x0003, 0x0000, NULL, len, USB_CTRL_GET_TIMEOUT); dev_dbg(dev, "result = %d/n", result); /* send 6th cmd */ /* * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0 * 16.0 DI 00 c2 01 00 00 00 08 */ len = 0x0007; result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x21, 0xa1, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 7th cmd */ /* * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 354.1.0 * 16.0 DO 00 c2 01 00 00 00 08 ....... 354.2.0 */ len = 0x0007; buf[0] = 0x00; buf[1] = 0xc2; buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x20, 0x21, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result);//.........这里部分代码省略.........
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:101,
示例14: submit_control_msgint submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int len,struct devrequest *setup){ int done = 0; int devnum = usb_pipedevice(pipe); int ep = usb_pipeendpoint(pipe); dev->status = 0; if (devnum == root_hub_devnum) return sl811_rh_submit_urb(dev, pipe, buffer, len, setup); PDEBUG(7, "dev = %d pipe = %ld buf = %p size = %d rt = %#x req = %#x bus = %i/n", devnum, ep, buffer, len, (int)setup->requesttype, (int)setup->request, sl811_read(SL811_SOFCNTDIV)*64); sl811_write(SL811_DEV_A, devnum); sl811_write(SL811_PIDEP_A, PIDEP(USB_PID_SETUP, ep)); /* setup phase */ usb_settoggle(dev, ep, 1, 0); if (sl811_send_packet(dev, usb_sndctrlpipe(dev, ep), (__u8*)setup, sizeof(*setup)) == sizeof(*setup)) { int dir_in = usb_pipein(pipe); int max = usb_maxpacket(dev, pipe); /* data phase */ sl811_write(SL811_PIDEP_A, PIDEP(dir_in ? USB_PID_IN : USB_PID_OUT, ep)); usb_settoggle(dev, ep, usb_pipeout(pipe), 1); while (done < len) { int res = sl811_send_packet(dev, pipe, (__u8*)buffer+done, max > len - done ? len - done : max); if (res < 0) { PDEBUG(0, "status data failed!/n"); dev->status = -res; return 0; } done += res; usb_dotoggle(dev, ep, usb_pipeout(pipe)); if (dir_in && res < max) /* short packet */ break; } /* status phase */ sl811_write(SL811_PIDEP_A, PIDEP(!dir_in ? USB_PID_IN : USB_PID_OUT, ep)); usb_settoggle(dev, ep, !usb_pipeout(pipe), 1); if (sl811_send_packet(dev, !dir_in ? usb_rcvctrlpipe(dev, ep) : usb_sndctrlpipe(dev, ep), 0, 0) < 0) { PDEBUG(0, "status phase failed!/n"); dev->status = -1; } } else { PDEBUG(0, "setup phase failed!/n"); dev->status = -1; } dev->act_len = done; return done;}
开发者ID:8devices,项目名称:Caraboot,代码行数:63,
示例15: zte_ev_usb_serial_openstatic int zte_ev_usb_serial_open(struct tty_struct *tty, struct usb_serial_port *port){ struct usb_device *udev = port->serial->dev; struct device *dev = &port->dev; int result = 0; int len; unsigned char *buf; buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; /* send 1st ctl cmd(CTL 21 22 01 00 00 00 00 00) */ len = 0; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x22, 0x21, 0x0001, 0x0000, NULL, len, USB_CTRL_GET_TIMEOUT); dev_dbg(dev, "result = %d/n", result); /* send 2st cmd and receive data */ /* * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5) * 16.0 DI 00 96 00 00 00 00 08 */ len = 0x0007; result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x21, 0xa1, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 3rd cmd */ /* * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0 * 16.0 DO 80 25 00 00 00 00 08 .%..... 30.2.0 */ len = 0x0007; buf[0] = 0x80; buf[1] = 0x25; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x20, 0x21, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 4th cmd */ /* * 16.0 CTL 21 22 03 00 00 00 00 00 */ len = 0; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x22, 0x21, 0x0003, 0x0000, NULL, len, USB_CTRL_GET_TIMEOUT); dev_dbg(dev, "result = %d/n", result); /* send 5th cmd */ /* * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0 * 16.0 DI 80 25 00 00 00 00 08 */ len = 0x0007; result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x21, 0xa1, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); /* send 6th cmd */ /* * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 34.1.0 * 16.0 DO 80 25 00 00 00 00 08 */ len = 0x0007; buf[0] = 0x80; buf[1] = 0x25; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x20, 0x21, 0x0000, 0x0000, buf, len, USB_CTRL_GET_TIMEOUT); debug_data(dev, __func__, len, buf, result); kfree(buf); return usb_serial_generic_open(tty, port);}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:97,
示例16: usb_control_msgOVFX2 I2C address should be 0 or maybe the driver sets this and we could chose whateverDoes that line up with I2C writes?*//*Generated by uvusbreplay 0.1uvusbreplay copyright 2011 John McMaster <[email C++ usb_sndintpipe函数代码示例 C++ usb_sndbulkpipe函数代码示例
|