这篇教程C++ usb_endpoint_dir_in函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_endpoint_dir_in函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_endpoint_dir_in函数的具体用法?C++ usb_endpoint_dir_in怎么用?C++ usb_endpoint_dir_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_endpoint_dir_in函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: cdc_ncm_find_endpointsstatic voidcdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf){ struct usb_host_endpoint *e; u8 ep; for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) { e = intf->cur_altsetting->endpoint + ep; switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_INT: if (usb_endpoint_dir_in(&e->desc)) { if (ctx->status_ep == NULL) ctx->status_ep = e; } break; case USB_ENDPOINT_XFER_BULK: if (usb_endpoint_dir_in(&e->desc)) { if (ctx->in_ep == NULL) ctx->in_ep = e; } else { if (ctx->out_ep == NULL) ctx->out_ep = e; } break; default: break; } }}
开发者ID:smx-smx,项目名称:dsl-n55u,代码行数:32,
示例2: usbnet_get_endpointsint usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf){ int tmp; struct usb_host_interface *alt = NULL; struct usb_host_endpoint *in = NULL, *out = NULL; struct usb_host_endpoint *status = NULL; for (tmp = 0; tmp < intf->num_altsetting; tmp++) { unsigned ep; in = out = status = NULL; alt = intf->altsetting + tmp; for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { struct usb_host_endpoint *e; int intr = 0; e = alt->endpoint + ep; switch (e->desc.bmAttributes) { case USB_ENDPOINT_XFER_INT: if (!usb_endpoint_dir_in(&e->desc)) continue; intr = 1; case USB_ENDPOINT_XFER_BULK: break; default: continue; } if (usb_endpoint_dir_in(&e->desc)) { if (!intr && !in) in = e; else if (intr && !status) status = e; } else { if (!out) out = e; } } if (in && out) break; } if (!alt || !in || !out) return -EINVAL; if (alt->desc.bAlternateSetting != 0 || !(dev->driver_info->flags & FLAG_NO_SETINT)) { tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting); if (tmp < 0) return tmp; } dev->in = usb_rcvbulkpipe (dev->udev, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); dev->out = usb_sndbulkpipe (dev->udev, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); dev->status = status; return 0;}
开发者ID:droidcore,项目名称:kangaroo-m7-mkv,代码行数:60,
示例3: usbhsg_ep_enable/* * * usb_ep_ops * */static int usbhsg_ep_enable(struct usb_ep *ep, const struct usb_endpoint_descriptor *desc){ struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); struct usbhs_pipe *pipe; int ret = -EIO; unsigned long flags; usbhs_lock(priv, flags); /* * if it already have pipe, * nothing to do */ if (uep->pipe) { usbhs_pipe_clear(uep->pipe); usbhs_pipe_sequence_data0(uep->pipe); ret = 0; goto usbhsg_ep_enable_end; } pipe = usbhs_pipe_malloc(priv, usb_endpoint_type(desc), usb_endpoint_dir_in(desc)); if (pipe) { uep->pipe = pipe; pipe->mod_private = uep; /* set epnum / maxp */ usbhs_pipe_config_update(pipe, 0, usb_endpoint_num(desc), usb_endpoint_maxp(desc)); /* * usbhs_fifo_dma_push/pop_handler try to * use dmaengine if possible. * It will use pio handler if impossible. */ if (usb_endpoint_dir_in(desc)) { pipe->handler = &usbhs_fifo_dma_push_handler; } else { pipe->handler = &usbhs_fifo_dma_pop_handler; usbhs_xxxsts_clear(priv, BRDYSTS, usbhs_pipe_number(pipe)); } ret = 0; }usbhsg_ep_enable_end: usbhs_unlock(priv, flags); return ret;}
开发者ID:mkrufky,项目名称:linux,代码行数:61,
示例4: xhci_get_endpoint_typestatic inline u32 xhci_get_endpoint_type(struct usb_device *udev, struct usb_host_endpoint *ep){ int in; u32 type; in = usb_endpoint_dir_in(&ep->desc); if (usb_endpoint_xfer_control(&ep->desc)) { type = EP_TYPE(CTRL_EP); } else if (usb_endpoint_xfer_bulk(&ep->desc)) { if (in) type = EP_TYPE(BULK_IN_EP); else type = EP_TYPE(BULK_OUT_EP); } else if (usb_endpoint_xfer_isoc(&ep->desc)) { if (in) type = EP_TYPE(ISOC_IN_EP); else type = EP_TYPE(ISOC_OUT_EP); } else if (usb_endpoint_xfer_int(&ep->desc)) { if (in) type = EP_TYPE(INT_IN_EP); else type = EP_TYPE(INT_OUT_EP); } else { BUG(); } return type;}
开发者ID:mikebyrne,项目名称:linux-2.6,代码行数:29,
示例5: ecos_usbserial_probestatic int ecos_usbserial_probe(struct usb_serial *serial, const struct usb_device_id *id){ struct usb_interface *interface = serial->interface; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int num_bulk_in = 0; int num_bulk_out = 0; int i; iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_xfer_bulk(endpoint)) { if (usb_endpoint_dir_in(endpoint)) { /* we found a bulk in endpoint */ dbg("found bulk in on endpoint %d", i); ++num_bulk_in; } else { /* we found a bulk out endpoint */ dbg("found bulk out on endpoint %d", i); ++num_bulk_out; } } } if (!num_bulk_in || !num_bulk_out) { info("Ignoring interface, insufficient endpoints"); return -ENODEV; } return 0;}
开发者ID:Palantir555,项目名称:ecos-mars-zx3,代码行数:33,
示例6: xhci_get_endpoint_index/** * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and * HCDs. Find the index for an endpoint given its descriptor. Use the return * value to right shift 1 for the bitmask. * * Index = (epnum * 2) + direction - 1, * where direction = 0 for OUT, 1 for IN. * For control endpoints, the IN index is used (OUT index is unused), so * index = (epnum * 2) + direction - 1 = (epnum * 2) + 1 - 1 = (epnum * 2) */unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc){ unsigned int index; if (usb_endpoint_xfer_control(desc)) index = (unsigned int) (usb_endpoint_num(desc)*2); else index = (unsigned int) (usb_endpoint_num(desc)*2) + (usb_endpoint_dir_in(desc) ? 1 : 0) - 1; return index;}
开发者ID:redareda9,项目名称:linux,代码行数:20,
示例7: get_pipes/* Get the pipe settings */static int get_pipes(struct us_data *us){ struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; int i; struct usb_endpoint_descriptor *ep; struct usb_endpoint_descriptor *ep_in = NULL; struct usb_endpoint_descriptor *ep_out = NULL; struct usb_endpoint_descriptor *ep_int = NULL;//---------------------------pr_info("13 get pipes/n"); /* * Find the first endpoint of each type we need. * We are expecting a minimum of 2 endpoints - in and out (bulk). * An optional interrupt-in is OK (necessary for CBI protocol). * We will ignore any others. */ for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { ep = &altsetting->endpoint[i].desc; if (usb_endpoint_xfer_bulk(ep)) { if (usb_endpoint_dir_in(ep)) { if (!ep_in) ep_in = ep; } else { if (!ep_out) ep_out = ep; } } else if (usb_endpoint_is_int_in(ep)) { if (!ep_int) ep_int = ep; } } if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { US_DEBUGP("Endpoint sanity check failed! Rejecting dev./n"); return -EIO; } /* Calculate and store the pipe values */ us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, usb_endpoint_num(ep_out)); us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, usb_endpoint_num(ep_in)); if (ep_int) { us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, usb_endpoint_num(ep_int)); us->ep_bInterval = ep_int->bInterval; } return 0;}
开发者ID:Andrealphus,项目名称:Drivers-for-USB-storage-Zhao,代码行数:56,
示例8: match_endpointstatic bool match_endpoint(struct usb_endpoint_descriptor *epd, struct usb_endpoint_descriptor **bulk_in, struct usb_endpoint_descriptor **bulk_out, struct usb_endpoint_descriptor **int_in, struct usb_endpoint_descriptor **int_out){ switch (usb_endpoint_type(epd)) { case USB_ENDPOINT_XFER_BULK: if (usb_endpoint_dir_in(epd)) { if (bulk_in && !*bulk_in) { *bulk_in = epd; break; } } else { if (bulk_out && !*bulk_out) { *bulk_out = epd; break; } } return false; case USB_ENDPOINT_XFER_INT: if (usb_endpoint_dir_in(epd)) { if (int_in && !*int_in) { *int_in = epd; break; } } else { if (int_out && !*int_out) { *int_out = epd; break; } } return false; default: return false; } return (!bulk_in || *bulk_in) && (!bulk_out || *bulk_out) && (!int_in || *int_in) && (!int_out || *int_out);}
开发者ID:guribe94,项目名称:linux,代码行数:42,
示例9: cdc_ncm_find_endpointsstatic voidcdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf){ struct usb_host_endpoint *e, *in = NULL, *out = NULL; u8 ep; for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) { e = intf->cur_altsetting->endpoint + ep; switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_INT: if (usb_endpoint_dir_in(&e->desc)) { if (!dev->status) dev->status = e; } break; case USB_ENDPOINT_XFER_BULK: if (usb_endpoint_dir_in(&e->desc)) { if (!in) in = e; } else { if (!out) out = e; } break; default: break; } } if (in && !dev->in) dev->in = usb_rcvbulkpipe(dev->udev, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); if (out && !dev->out) dev->out = usb_sndbulkpipe(dev->udev, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:40,
示例10: get_pipesstatic int get_pipes(struct rts51x_chip *chip){ struct rts51x_usb *rts51x = chip->usb; struct usb_host_interface *altsetting = rts51x->pusb_intf->cur_altsetting; int i; struct usb_endpoint_descriptor *ep; struct usb_endpoint_descriptor *ep_in = NULL; struct usb_endpoint_descriptor *ep_out = NULL; struct usb_endpoint_descriptor *ep_int = NULL; for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { ep = &altsetting->endpoint[i].desc; if (usb_endpoint_xfer_bulk(ep)) { if (usb_endpoint_dir_in(ep)) { if (!ep_in) ep_in = ep; } else { if (!ep_out) ep_out = ep; } } else if (usb_endpoint_is_int_in(ep)) { if (!ep_int) ep_int = ep; } } if (!ep_in || !ep_out) { RTS51X_DEBUGP("Endpoint sanity check failed!" "Rejecting dev./n"); return -EIO; } rts51x->send_ctrl_pipe = usb_sndctrlpipe(rts51x->pusb_dev, 0); rts51x->recv_ctrl_pipe = usb_rcvctrlpipe(rts51x->pusb_dev, 0); rts51x->send_bulk_pipe = usb_sndbulkpipe(rts51x->pusb_dev, usb_endpoint_num(ep_out)); rts51x->recv_bulk_pipe = usb_rcvbulkpipe(rts51x->pusb_dev, usb_endpoint_num(ep_in)); if (ep_int) { rts51x->recv_intr_pipe = usb_rcvintpipe(rts51x->pusb_dev, usb_endpoint_num (ep_int)); rts51x->ep_bInterval = ep_int->bInterval; } return 0;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:51,
示例11: fotg210_ep_enablestatic int fotg210_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc){ struct fotg210_ep *ep; ep = container_of(_ep, struct fotg210_ep, ep); ep->desc = desc; ep->epnum = usb_endpoint_num(desc); ep->type = usb_endpoint_type(desc); ep->dir_in = usb_endpoint_dir_in(desc); ep->ep.maxpacket = usb_endpoint_maxp(desc); return fotg210_config_ep(ep, desc);}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:15,
示例12: usbhsg_ep_enable/* * * usb_ep_ops * */static int usbhsg_ep_enable(struct usb_ep *ep, const struct usb_endpoint_descriptor *desc){ struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); struct usbhs_pipe *pipe; spinlock_t *lock; unsigned long flags; int ret = -EIO; /* * if it already have pipe, * nothing to do */ if (uep->pipe) return 0; /******************** spin lock ********************/ lock = usbhsg_trylock(gpriv, &flags); pipe = usbhs_pipe_malloc(priv, desc); if (pipe) { uep->pipe = pipe; pipe->mod_private = uep; INIT_LIST_HEAD(&uep->list); if (usb_endpoint_dir_in(desc)) uep->handler = &usbhsg_handler_send_packet; else uep->handler = &usbhsg_handler_recv_packet; ret = 0; } usbhsg_unlock(lock, &flags); /******************** spin unlock ******************/ return ret;}
开发者ID:SmokyBob,项目名称:android_kernel_asus_padfone2,代码行数:45,
示例13: g13_probe/* FIXME VP 27.12.2010: Really long method */static int g13_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device* device = interface_to_usbdev(intf); struct usb_host_interface* cur_altsetting = intf->cur_altsetting; struct usb_interface_descriptor desc = cur_altsetting->desc; int usb_register_dev_result; int i; struct usb_host_endpoint endpoint; struct usb_endpoint_descriptor endpoint_descriptor; __u8 bEndpointAddress; __u8 bmAttributes; __u8 bInterval; struct urb* urb; unsigned int in_pipe; __le16 wMaxPacketSize; unsigned char* in_transfer_buffer; unsigned int in_transfer_buffer_length; int input_register_device_result; g13_input_device = input_allocate_device(); if (g13_input_device == NULL) { printk("G13: input_allocate_device failed./n"); return -1; } g13_input_device->name = "G13"; g13_input_device->evbit[0] = BIT_MASK(EV_KEY); REGISTER_BUTTON(1); REGISTER_BUTTON(2); REGISTER_BUTTON(3); REGISTER_BUTTON(4); REGISTER_BUTTON(5); REGISTER_BUTTON(6); REGISTER_BUTTON(7); REGISTER_BUTTON(8); REGISTER_BUTTON(9); REGISTER_BUTTON(10); REGISTER_BUTTON(11); REGISTER_BUTTON(12); REGISTER_BUTTON(13); REGISTER_BUTTON(14); REGISTER_BUTTON(15); REGISTER_BUTTON(16); REGISTER_BUTTON(17); REGISTER_BUTTON(18); REGISTER_BUTTON(19); REGISTER_BUTTON(20); REGISTER_BUTTON(21); REGISTER_BUTTON(22); input_register_device_result = input_register_device(g13_input_device); if (input_register_device_result) { printk("G13: input_register_device failed: %d/n", input_register_device_result); return input_register_device_result; } for (i = 0; i < desc.bNumEndpoints; i++) { endpoint = cur_altsetting->endpoint[i]; endpoint_descriptor = endpoint.desc; bEndpointAddress = endpoint_descriptor.bEndpointAddress; bmAttributes = endpoint_descriptor.bmAttributes; if (usb_endpoint_dir_in(&endpoint_descriptor)) { /* We know that bmAttributes == USB_ENDPOINT_XFER_INT */ if (usb_endpoint_xfer_int(&endpoint_descriptor)) { bInterval = endpoint_descriptor.bInterval; wMaxPacketSize = endpoint_descriptor.wMaxPacketSize; in_pipe = usb_rcvintpipe(device, bEndpointAddress); in_transfer_buffer = kzalloc((sizeof (unsigned char)) * wMaxPacketSize, GFP_ATOMIC); in_transfer_buffer_length = wMaxPacketSize; urb = usb_alloc_urb(0, GFP_ATOMIC); usb_fill_int_urb(urb, device, in_pipe, in_transfer_buffer, in_transfer_buffer_length, &g13_urb_complete, NULL, bInterval); usb_submit_urb(urb, GFP_ATOMIC); } } else if (usb_endpoint_dir_out(&endpoint_descriptor)) { /* We know that bmAttributes == USB_ENDPOINT_XFER_INT */ if (usb_endpoint_xfer_int(&endpoint_descriptor)) { bInterval = endpoint_descriptor.bInterval; /* TODO VP 27.12.2010: Implement output */ } } else { printk("G13: Bug found! Endpoint not IN nor OUT./n"); } } usb_register_dev_result = usb_register_dev(intf, &g13_class); if (usb_register_dev_result ) { printk("G13: usb_register_dev failed: %d/n", usb_register_dev_result); return usb_register_dev_result; } printk("G13: Device registration successful./n"); return 0;}
开发者ID:vpeurala,项目名称:g13driver,代码行数:87,
示例14: acm_probe//.........这里部分代码省略......... /*workaround for switched interfaces */ if (data_interface->cur_altsetting->desc.bInterfaceClass != CDC_DATA_INTERFACE_TYPE) { if (control_interface->cur_altsetting->desc.bInterfaceClass == CDC_DATA_INTERFACE_TYPE) { struct usb_interface *t; dev_dbg(&intf->dev,"Your device has switched interfaces./n"); t = control_interface; control_interface = data_interface; data_interface = t; } else { return -EINVAL; } } /* Accept probe requests only for the control interface */ if (intf != control_interface) return -ENODEV; if (usb_interface_claimed(data_interface)) { /* valid in this context */ dev_dbg(&intf->dev,"The data interface isn't available/n"); return -EBUSY; } if (data_interface->cur_altsetting->desc.bNumEndpoints < 2) return -EINVAL; epctrl = &control_interface->cur_altsetting->endpoint[0].desc; epread = &data_interface->cur_altsetting->endpoint[0].desc; epwrite = &data_interface->cur_altsetting->endpoint[1].desc; /* workaround for switched endpoints */ if (!usb_endpoint_dir_in(epread)) { /* descriptors are swapped */ struct usb_endpoint_descriptor *t; dev_dbg(&intf->dev,"The data interface has switched endpoints/n"); t = epread; epread = epwrite; epwrite = t; } dbg("interfaces are valid"); for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++); if (minor == ACM_TTY_MINORS) { err("no more free acm devices"); return -ENODEV; } if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) { dev_dbg(&intf->dev, "out of memory (acm kzalloc)/n"); goto alloc_fail; } ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); readsize = le16_to_cpu(epread->wMaxPacketSize)* ( quirks == SINGLE_RX_URB ? 1 : 2); acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize) * 20; acm->control = control_interface; acm->data = data_interface; acm->minor = minor; acm->dev = usb_dev; acm->ctrl_caps = ac_management_function; acm->ctrlsize = ctrlsize; acm->readsize = readsize; acm->rx_buflimit = num_rx_buf;
开发者ID:IgnasD,项目名称:Tomato-RAF,代码行数:67,
示例15: pixcir_probestatic int pixcir_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_host_interface *interface = intf->cur_altsetting; struct usb_device *dev = interface_to_usbdev(intf); struct input_dev *input_dev1; int n = 0, insize = TOUCH_PACKAGE_LEN; int err; const char *path; int len; char input_buf[10]; struct pixcir_mt_usb *psmt = kzalloc(sizeof(struct pixcir_mt_usb), GFP_KERNEL); kref_init(&psmt->kref); mutex_init(&psmt->io_mutex); printk("%s/n", __FUNCTION__); psmt->type = &type; psmt->udev = dev; if (dev->manufacturer) strlcpy(psmt->name, dev->manufacturer, sizeof(psmt->name)); if (dev->product) { if (dev->manufacturer) strlcat(psmt->name, " ", sizeof(psmt->name)); strlcat(psmt->name, dev->product, sizeof(psmt->name)); } if (!strlen(psmt->name)) snprintf(psmt->name, sizeof(psmt->name), "USB Touchscreen %04x:%04x", le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); if (!psmt->type->process_pkt) { printk("process_pkt is null/n"); psmt->type->process_pkt = usbtouch_process_pkt; } usb_set_intfdata(intf, psmt); err = usb_register_dev(intf,&pixcir_class_driver); if(err){ printk("Not able to get minor for this device."); } dev_info(&intf->dev,"now attach to USB-%d",intf->minor); input_dev1 = input_allocate_device(); input_dev1->name = "pixcir_usb_ts"; usb_to_input_id(dev, &input_dev1->id); psmt->input_dev = input_dev1; if(!psmt|| !input_dev1) { printk("Memory is not enough/n"); goto fail1; } input_dev1->dev.parent = &intf->dev; input_set_drvdata(input_dev1, psmt); set_bit(EV_SYN, input_dev1->evbit); set_bit(EV_KEY, input_dev1->evbit); set_bit(EV_ABS, input_dev1->evbit); set_bit(BTN_TOUCH, input_dev1->keybit); input_set_abs_params(input_dev1, ABS_X, psmt->type->min_xc, psmt->type->max_xc, 0, 0); input_set_abs_params(input_dev1, ABS_Y, psmt->type->min_yc, psmt->type->max_yc, 0, 0); input_set_abs_params(input_dev1, ABS_MT_POSITION_X, psmt->type->min_xc, psmt->type->max_xc, 0, 0); input_set_abs_params(input_dev1, ABS_MT_POSITION_Y, psmt->type->min_yc, psmt->type->max_yc, 0, 0); input_set_abs_params(input_dev1, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(input_dev1, ABS_MT_WIDTH_MAJOR, 0, 25, 0, 0); psmt->data = usb_alloc_coherent(dev, insize, GFP_KERNEL, &psmt->data_dma); if(!psmt->data) { printk("psmt->data allocating fail"); goto fail; } for (n = 0; n < interface->desc.bNumEndpoints; n++) { struct usb_endpoint_descriptor *endpoint; int pipe; int interval; endpoint = &interface->endpoint[n].desc; /*find a int endpoint*/ if (!usb_endpoint_xfer_int(endpoint)) continue; interval = endpoint->bInterval; if (usb_endpoint_dir_in(endpoint)) { if (psmt->urb) continue; if (!(psmt->urb = usb_alloc_urb(0, GFP_KERNEL))) goto fail; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); usb_fill_int_urb(psmt->urb, dev, pipe, psmt->data, insize, pixcir_mt_irq, psmt, interval); psmt->urb->transfer_dma = psmt->data_dma;//.........这里部分代码省略.........
开发者ID:unixjazz,项目名称:linux-mixtile,代码行数:101,
示例16: GatherEndpoints/*===========================================================================METHOD: GatherEndpoints (Public Method)DESCRIPTION: Enumerate endpointsPARAMETERS pIntf [ I ] - Pointer to usb interfaceRETURN VALUE: sEndpoints structure NULL for failure===========================================================================*/sEndpoints * GatherEndpoints( struct usb_interface * pIntf ){ int numEndpoints; int endpointIndex; sEndpoints * pOut; struct usb_host_endpoint * pEndpoint = NULL; pOut = kzalloc( sizeof( sEndpoints ), GFP_ATOMIC ); if (pOut == NULL) { DBG( "unable to allocate memory/n" ); return NULL; } pOut->mIntfNum = pIntf->cur_altsetting->desc.bInterfaceNumber; // Scan endpoints numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints; for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++) { pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex; if (pEndpoint == NULL) { DBG( "invalid endpoint %u/n", endpointIndex ); kfree( pOut ); return NULL; } if (usb_endpoint_dir_in( &pEndpoint->desc ) == true && usb_endpoint_xfer_int( &pEndpoint->desc ) == true) { pOut->mIntInEndp = pEndpoint->desc.bEndpointAddress; } else if (usb_endpoint_dir_in( &pEndpoint->desc ) == true && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) { pOut->mBlkInEndp = pEndpoint->desc.bEndpointAddress; } else if (usb_endpoint_dir_in( &pEndpoint->desc ) == false && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) { pOut->mBlkOutEndp = pEndpoint->desc.bEndpointAddress; } } if (pOut->mIntInEndp == 0 || pOut->mBlkInEndp == 0 || pOut->mBlkOutEndp == 0) { DBG( "One or more endpoints missing/n" ); kfree( pOut ); return NULL; } DBG( "intf %u/n", pOut->mIntfNum ); DBG( " int in 0x%02x/n", pOut->mIntInEndp ); DBG( " blk in 0x%02x/n", pOut->mBlkInEndp ); DBG( " blk out 0x%02x/n", pOut->mBlkOutEndp ); return pOut;}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:75,
示例17: usbnet_get_endpoints/* handles CDC Ethernet and many other network "bulk data" interfaces */int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf){ int tmp; struct usb_host_interface *alt = NULL; struct usb_host_endpoint *in = NULL, *out = NULL; struct usb_host_endpoint *status = NULL; for (tmp = 0; tmp < intf->num_altsetting; tmp++) { unsigned ep; in = out = status = NULL; alt = intf->altsetting + tmp; /* take the first altsetting with in-bulk + out-bulk; * remember any status endpoint, just in case; * ignore other endpoints and altsettings. */ for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { struct usb_host_endpoint *e; int intr = 0; e = alt->endpoint + ep; switch (e->desc.bmAttributes) { case USB_ENDPOINT_XFER_INT: if (!usb_endpoint_dir_in(&e->desc)) continue; intr = 1; /* FALLTHROUGH */ case USB_ENDPOINT_XFER_BULK: break; default: continue; } if (usb_endpoint_dir_in(&e->desc)) { if (!intr && !in) in = e; else if (intr && !status) status = e; } else { if (!out) out = e; } } if (in && out) break; } if (!alt || !in || !out) return -EINVAL; if (alt->desc.bAlternateSetting != 0 || !(dev->driver_info->flags & FLAG_NO_SETINT)) { tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, alt->desc.bAlternateSetting); if (tmp < 0) return tmp; } dev->in = usb_rcvbulkpipe (dev->udev, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); dev->out = usb_sndbulkpipe (dev->udev, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); dev->status = status;#ifdef LG_FW_HSIC_EMS_DEBUG /* secheol.pyo - endpoint logging */ printk("[%s] usbnet bulk_in_Addr = %d, bulk_out_Addr = %d, bulk_in_endpoint = %d , bulk_out_endpoint = %d /n", __func__, in->desc.bEndpointAddress, out->desc.bEndpointAddress, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);#endif /* secheol.pyo - endpoint logging */ return 0;}
开发者ID:regit66,项目名称:android_kernel_lge_geehrc,代码行数:72,
示例18: GobiNetDriverBind/*===========================================================================METHOD: GobiNetDriverBind (Public Method)DESCRIPTION: Setup in and out pipesPARAMETERS pDev [ I ] - Pointer to usbnet device pIntf [ I ] - Pointer to interfaceRETURN VALUE: int - 0 for success Negative errno for error===========================================================================*/static int GobiNetDriverBind( struct usbnet * pDev, struct usb_interface * pIntf ){ int numEndpoints; int endpointIndex; struct usb_host_endpoint * pEndpoint = NULL; struct usb_host_endpoint * pIn = NULL; struct usb_host_endpoint * pOut = NULL; DBG( "UnBind GobiNet driver /n" ); // Verify one altsetting if (pIntf->num_altsetting != 1) { DBG( "invalid num_altsetting %u/n", pIntf->num_altsetting ); return -ENODEV; } /* We only accept certain interfaces */ if( InterfaceIsWhitelisted( (signed char)pIntf->cur_altsetting->desc.bInterfaceNumber, (const signed char *)pDev->driver_info->data) == false ) { DBG( "invalid interface %d/n", pIntf->cur_altsetting->desc.bInterfaceNumber ); return -ENODEV; } // Collect In and Out endpoints numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints; for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++) { pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex; if (pEndpoint == NULL) { DBG( "invalid endpoint %u/n", endpointIndex ); return -ENODEV; } if (usb_endpoint_dir_in( &pEndpoint->desc ) == true && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) { pIn = pEndpoint; } else if (usb_endpoint_dir_out( &pEndpoint->desc ) == true) { pOut = pEndpoint; } } if (pIn == NULL || pOut == NULL) { DBG( "invalid endpoints/n" ); return -ENODEV; } if (usb_set_interface( pDev->udev, pIntf->cur_altsetting->desc.bInterfaceNumber, 0 ) != 0) { DBG( "unable to set interface/n" ); return -ENODEV; } pDev->in = usb_rcvbulkpipe( pDev->udev, pIn->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); pDev->out = usb_sndbulkpipe( pDev->udev, pOut->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); DBG( "in %x, out %x/n", pIn->desc.bEndpointAddress, pOut->desc.bEndpointAddress ); // In later versions of the kernel, usbnet helps with this#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) pIntf->dev.platform_data = (void *)pDev;#endif return 0;}
开发者ID:develersrl,项目名称:winmate-kernel,代码行数:97,
示例19: RT_usb_endpoint_is_int_instatic inline int RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd){ return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);}
开发者ID:3null,项目名称:linux,代码行数:4,
示例20: GobiNetDriverBind/*===========================================================================METHOD: GobiNetDriverBind (Public Method)DESCRIPTION: Setup in and out pipesPARAMETERS pDev [ I ] - Pointer to usbnet device pIntf [ I ] - Pointer to interfaceRETURN VALUE: int - 0 for success Negative errno for error===========================================================================*/static int GobiNetDriverBind( struct usbnet * pDev, struct usb_interface * pIntf ){ int numEndpoints; int endpointIndex; struct usb_host_endpoint * pEndpoint = NULL; struct usb_host_endpoint * pIn = NULL; struct usb_host_endpoint * pOut = NULL; // Verify one altsetting if (pIntf->num_altsetting != 1) { DBG( "invalid num_altsetting %u/n", pIntf->num_altsetting ); return -ENODEV; } /* We only accept certain interfaces */ if (pIntf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC ) { DBG( "Ignoring non vendor class interface #%d/n", pIntf->cur_altsetting->desc.bInterfaceNumber ); return -ENODEV; } else if (pDev->driver_info->data && !test_bit(pIntf->cur_altsetting->desc.bInterfaceNumber, &pDev->driver_info->data)) { DBG( "invalid interface %d/n", pIntf->cur_altsetting->desc.bInterfaceNumber ); return -ENODEV; } // Collect In and Out endpoints numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints; for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++) { pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex; if (pEndpoint == NULL) { DBG( "invalid endpoint %u/n", endpointIndex ); return -ENODEV; } if (usb_endpoint_dir_in( &pEndpoint->desc ) == true && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) { pIn = pEndpoint; } else if (usb_endpoint_dir_out( &pEndpoint->desc ) == true) { pOut = pEndpoint; } } if (pIn == NULL || pOut == NULL) { DBG( "invalid endpoints/n" ); return -ENODEV; } if (usb_set_interface( pDev->udev, pIntf->cur_altsetting->desc.bInterfaceNumber, 0 ) != 0) { DBG( "unable to set interface/n" ); return -ENODEV; } pDev->in = usb_rcvbulkpipe( pDev->udev, pIn->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); pDev->out = usb_sndbulkpipe( pDev->udev, pOut->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); DBG( "in %x, out %x/n", pIn->desc.bEndpointAddress, pOut->desc.bEndpointAddress ); // In later versions of the kernel, usbnet helps with this#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) pIntf->dev.platform_data = (void *)pDev;#endif /* make MAC addr easily distinguishable from an IP header */ if (possibly_iphdr(pDev->net->dev_addr)) { pDev->net->dev_addr[0] |= 0x02; /* set local assignment bit */ pDev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit *///.........这里部分代码省略.........
开发者ID:Tookmund,项目名称:GobiNet,代码行数:101,
示例21: mwifiex_usb_probe/* This function probes an mwifiex device and registers it. It allocates * the card structure, initiates the device registration and initialization * procedure by adding a logical interface. */static int mwifiex_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_interface *iface_desc = intf->cur_altsetting; struct usb_endpoint_descriptor *epd; int ret, i; struct usb_card_rec *card; u16 id_vendor, id_product, bcd_device, bcd_usb; card = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); if (!card) return -ENOMEM; id_vendor = le16_to_cpu(udev->descriptor.idVendor); id_product = le16_to_cpu(udev->descriptor.idProduct); bcd_device = le16_to_cpu(udev->descriptor.bcdDevice); bcd_usb = le16_to_cpu(udev->descriptor.bcdUSB); pr_debug("info: VID/PID = %X/%X, Boot2 version = %X/n", id_vendor, id_product, bcd_device); /* PID_1 is used for firmware downloading only */ switch (id_product) { case USB8797_PID_1: case USB8897_PID_1: card->usb_boot_state = USB8XXX_FW_DNLD; break; case USB8797_PID_2: case USB8897_PID_2: card->usb_boot_state = USB8XXX_FW_READY; break; default: pr_warning("unknown id_product %#x/n", id_product); card->usb_boot_state = USB8XXX_FW_DNLD; break; } card->udev = udev; card->intf = intf; pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocol=%#x/n", udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass, udev->descriptor.bDeviceSubClass, udev->descriptor.bDeviceProtocol); for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { epd = &iface_desc->endpoint[i].desc; if (usb_endpoint_dir_in(epd) && usb_endpoint_num(epd) == MWIFIEX_USB_EP_CMD_EVENT && usb_endpoint_xfer_bulk(epd)) { pr_debug("info: bulk IN: max pkt size: %d, addr: %d/n", le16_to_cpu(epd->wMaxPacketSize), epd->bEndpointAddress); card->rx_cmd_ep = usb_endpoint_num(epd); atomic_set(&card->rx_cmd_urb_pending, 0); } if (usb_endpoint_dir_in(epd) && usb_endpoint_num(epd) == MWIFIEX_USB_EP_DATA && usb_endpoint_xfer_bulk(epd)) { pr_debug("info: bulk IN: max pkt size: %d, addr: %d/n", le16_to_cpu(epd->wMaxPacketSize), epd->bEndpointAddress); card->rx_data_ep = usb_endpoint_num(epd); atomic_set(&card->rx_data_urb_pending, 0); } if (usb_endpoint_dir_out(epd) && usb_endpoint_num(epd) == MWIFIEX_USB_EP_DATA && usb_endpoint_xfer_bulk(epd)) { pr_debug("info: bulk OUT: max pkt size: %d, addr: %d/n", le16_to_cpu(epd->wMaxPacketSize), epd->bEndpointAddress); card->tx_data_ep = usb_endpoint_num(epd); atomic_set(&card->tx_data_urb_pending, 0); } if (usb_endpoint_dir_out(epd) && usb_endpoint_num(epd) == MWIFIEX_USB_EP_CMD_EVENT && usb_endpoint_xfer_bulk(epd)) { pr_debug("info: bulk OUT: max pkt size: %d, addr: %d/n", le16_to_cpu(epd->wMaxPacketSize), epd->bEndpointAddress); card->tx_cmd_ep = usb_endpoint_num(epd); atomic_set(&card->tx_cmd_urb_pending, 0); card->bulk_out_maxpktsize = le16_to_cpu(epd->wMaxPacketSize); } } usb_set_intfdata(intf, card); ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops, MWIFIEX_USB); if (ret) { pr_err("%s: mwifiex_add_card failed: %d/n", __func__, ret); usb_reset_device(udev); kfree(card); return ret;//.........这里部分代码省略.........
开发者ID:7799,项目名称:linux,代码行数:101,
示例22: brcmf_usb_probestatic intbrcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *usb = interface_to_usbdev(intf); struct brcmf_usbdev_info *devinfo; struct usb_interface_descriptor *desc; struct usb_endpoint_descriptor *endpoint; int ret = 0; u32 num_of_eps; u8 endpoint_num, ep; brcmf_dbg(USB, "Enter 0x%04x:0x%04x/n", id->idVendor, id->idProduct); devinfo = kzalloc(sizeof(*devinfo), GFP_ATOMIC); if (devinfo == NULL) return -ENOMEM; devinfo->usbdev = usb; devinfo->dev = &usb->dev; /* Take an init lock, to protect for disconnect while still loading. * Necessary because of the asynchronous firmware load construction */ mutex_init(&devinfo->dev_init_lock); mutex_lock(&devinfo->dev_init_lock); usb_set_intfdata(intf, devinfo); /* Check that the device supports only one configuration */ if (usb->descriptor.bNumConfigurations != 1) { brcmf_err("Number of configurations: %d not supported/n", usb->descriptor.bNumConfigurations); ret = -ENODEV; goto fail; } if ((usb->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) && (usb->descriptor.bDeviceClass != USB_CLASS_MISC) && (usb->descriptor.bDeviceClass != USB_CLASS_WIRELESS_CONTROLLER)) { brcmf_err("Device class: 0x%x not supported/n", usb->descriptor.bDeviceClass); ret = -ENODEV; goto fail; } desc = &intf->altsetting[0].desc; if ((desc->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || (desc->bInterfaceSubClass != 2) || (desc->bInterfaceProtocol != 0xff)) { brcmf_err("non WLAN interface %d: 0x%x:0x%x:0x%x/n", desc->bInterfaceNumber, desc->bInterfaceClass, desc->bInterfaceSubClass, desc->bInterfaceProtocol); ret = -ENODEV; goto fail; } num_of_eps = desc->bNumEndpoints; for (ep = 0; ep < num_of_eps; ep++) { endpoint = &intf->altsetting[0].endpoint[ep].desc; endpoint_num = usb_endpoint_num(endpoint); if (!usb_endpoint_xfer_bulk(endpoint)) continue; if (usb_endpoint_dir_in(endpoint)) { if (!devinfo->rx_pipe) devinfo->rx_pipe = usb_rcvbulkpipe(usb, endpoint_num); } else { if (!devinfo->tx_pipe) devinfo->tx_pipe = usb_sndbulkpipe(usb, endpoint_num); } } if (devinfo->rx_pipe == 0) { brcmf_err("No RX (in) Bulk EP found/n"); ret = -ENODEV; goto fail; } if (devinfo->tx_pipe == 0) { brcmf_err("No TX (out) Bulk EP found/n"); ret = -ENODEV; goto fail; } devinfo->ifnum = desc->bInterfaceNumber; if (usb->speed == USB_SPEED_SUPER) brcmf_dbg(USB, "Broadcom super speed USB WLAN interface detected/n"); else if (usb->speed == USB_SPEED_HIGH) brcmf_dbg(USB, "Broadcom high speed USB WLAN interface detected/n"); else brcmf_dbg(USB, "Broadcom full speed USB WLAN interface detected/n"); ret = brcmf_usb_probe_cb(devinfo); if (ret) goto fail; /* Success */ return 0;fail: mutex_unlock(&devinfo->dev_init_lock);//.........这里部分代码省略.........
开发者ID:BORETS24,项目名称:common.git-android-4.4,代码行数:101,
注:本文中的usb_endpoint_dir_in函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ usb_endpoint_is_bulk_out函数代码示例 C++ usb_enable_autosuspend函数代码示例 |