您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ usb_pipein函数代码示例

51自学网 2021-06-03 09:20:29
  C++
这篇教程C++ usb_pipein函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中usb_pipein函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_pipein函数的具体用法?C++ usb_pipein怎么用?C++ usb_pipein使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了usb_pipein函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: usb_stor_clear_halt

/* This is a version of usb_clear_halt() that allows early termination and * doesn't read the status from the device -- this is because some devices * crash their internal firmware when the status is requested after a halt. * * A definitive list of these 'bad' devices is too difficult to maintain or * make complete enough to be useful.  This problem was first observed on the * Hagiwara FlashGate DUAL unit.  However, bus traces reveal that neither * MacOS nor Windows checks the status after clearing a halt. * * Since many vendors in this space limit their testing to interoperability * with these two OSes, specification violations like this one are common. */int usb_stor_clear_halt(struct us_data *us, unsigned int pipe){	int result;	int endp = usb_pipeendpoint(pipe);	if (usb_pipein (pipe))		endp |= USB_DIR_IN;	result = usb_stor_control_msg(us, us->send_ctrl_pipe,		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,		USB_ENDPOINT_HALT, endp,		NULL, 0, 3*HZ);	if (result >= 0)		usb_reset_endpoint(us->pusb_dev, endp);	usb_stor_dbg(us, "result = %d/n", result);	return result;}
开发者ID:ShedrockN4,项目名称:wiliteneo,代码行数:31,


示例2: mon_text_get_data

static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,    int len, char ev_type){	int pipe = urb->pipe;	if (len <= 0)		return 'L';	if (len >= DATA_MAX)		len = DATA_MAX;	/*	 * Bulk is easy to shortcut reliably. 	 * XXX Other pipe types need consideration. Currently, we overdo it	 * and collect garbage for them: better more than less.	 */	if (usb_pipebulk(pipe) || usb_pipecontrol(pipe)) {		if (usb_pipein(pipe)) {			if (ev_type == 'S')				return '<';		} else {			if (ev_type == 'C')				return '>';		}	}	/*	 * The check to see if it's safe to poke at data has an enormous	 * number of corner cases, but it seems that the following is	 * more or less safe.	 *	 * We do not even try to look transfer_buffer, because it can	 * contain non-NULL garbage in case the upper level promised to	 * set DMA for the HCD.	 */	if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)		return mon_dmapeek(ep->data, urb->transfer_dma, len);	if (urb->transfer_buffer == NULL)		return 'Z';	/* '0' would be not as pretty. */	memcpy(ep->data, urb->transfer_buffer, len);	return 0;}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:43,


示例3: usb_stor_clear_halt

/* This is a version of usb_clear_halt() that doesn't read the status from * the device -- this is because some devices crash their internal firmware * when the status is requested after a halt */int usb_stor_clear_halt(struct usb_device *dev, int pipe){	int result;	int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);	result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),				 USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,				 endp, NULL, 0, HZ * 3);	/* this is a failure case */	if (result < 0)		return result;	/* reset the toggles and endpoint flags */	usb_endpoint_running(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));	usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);	return 0;}
开发者ID:nhanh0,项目名称:hah,代码行数:23,


示例4: usb_buffer_unmap

void usb_buffer_unmap(struct urb *urb){	struct usb_bus		*bus;	struct device		*controller;	if (!urb			|| !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)			|| !urb->dev			|| !(bus = urb->dev->bus)			|| !(controller = bus->controller))		return;	if (controller->dma_mask) {		dma_unmap_single(controller,			urb->transfer_dma, urb->transfer_buffer_length,			usb_pipein(urb->pipe)				? DMA_FROM_DEVICE : DMA_TO_DEVICE);	}	urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP;}
开发者ID:krachlatte,项目名称:Sony-Xperia-Go-ST27i,代码行数:20,


示例5: usb_stor_clear_halt

//----- usb_stor_clear_halt() ---------------------int usb_stor_clear_halt(struct us_data *us, unsigned int pipe){	int result;	int endp = usb_pipeendpoint(pipe);	//printk("transport --- usb_stor_clear_halt/n");	if (usb_pipein (pipe))		endp |= USB_DIR_IN;	result = usb_stor_control_msg(us, us->send_ctrl_pipe,		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,		USB_ENDPOINT_HALT, endp,		NULL, 0, 3*HZ);	/* reset the endpoint toggle */	if (result >= 0)		//usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);                usb_reset_endpoint(us->pusb_dev, endp);	return result;}
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:22,


示例6: clear_halt

/* This is a version of usb_clear_halt() that doesn't read the status from * the device -- this is because some devices crash their internal firmware * when the status is requested after a halt */static int  clear_halt(USB_DEV_T *dev, int pipe){    int    result;    int    endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);    UMAS_DEBUG("clear_halt!/n");    result = USBH_SendCtrlMsg(dev, usb_sndctrlpipe(dev, 0),                              USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,                              endp, NULL, 0, 0);    /* this is a failure case */    if(result < 0)    {        UMAS_DEBUG("clear_halt failed!!/n");        return result;    }    /* reset the toggles and endpoint flags */    usb_endpoint_running(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));    usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0x1000);    return 0;}
开发者ID:brucetsao,项目名称:Nuvoton,代码行数:26,


示例7: usbip_recv_xbuff

/* some members of urb must be substituted before. */int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb){	int ret;	int size;	if (ud->side == USBIP_STUB) {		/* stub_rx.c */		/* the direction of urb must be OUT. */		if (usb_pipein(urb->pipe))			return 0;		size = urb->transfer_buffer_length;	} else {		/* vhci_rx.c */		/* the direction of urb must be IN. */		if (usb_pipeout(urb->pipe))			return 0;		size = urb->actual_length;	}	/* no need to recv xbuff */	if (!(size > 0))		return 0;	ret = usbip_xmit(0, ud->tcp_socket, (char *)urb->transfer_buffer,			 size, 0);	if (ret != size) {		dev_err(&urb->dev->dev, "recv xbuf, %d/n", ret);		if (ud->side == USBIP_STUB) {			usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);		} else {			usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);			return -EPIPE;		}	}	return ret;}
开发者ID:cubieb,项目名称:kernel_3.2.40_with_comment,代码行数:40,


示例8: usbip_recv_xbuff

int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb){	int ret;	int size;	if (ud->side == USBIP_STUB) {						if (usb_pipein(urb->pipe))			return 0;		size = urb->transfer_buffer_length;	} else {						if (usb_pipeout(urb->pipe))			return 0;		size = urb->actual_length;	}		if (!(size > 0))		return 0;	ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);	if (ret != size) {		dev_err(&urb->dev->dev, "recv xbuf, %d/n", ret);		if (ud->side == USBIP_STUB) {			usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);		} else {			usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);			return -EPIPE;		}	}	return ret;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:38,


示例9: ehci_urb_complete

static void ehci_urb_complete (	struct ehci_hcd		*ehci,	dma_addr_t		addr,	struct urb		*urb) {	if (urb->transfer_buffer_length && usb_pipein (urb->pipe))		pci_dma_sync_single (ehci->hcd.pdev, addr,			urb->transfer_buffer_length,			PCI_DMA_FROMDEVICE);	/* cleanse status if we saw no error */	if (likely (urb->status == -EINPROGRESS)) {		if (urb->actual_length != urb->transfer_buffer_length				&& (urb->transfer_flags & USB_DISABLE_SPD))			urb->status = -EREMOTEIO;		else			urb->status = 0;	}	/* only report unlinks once */	if (likely (urb->status != -ENOENT && urb->status != -ENOTCONN))		urb->complete (urb);}
开发者ID:iwangv,项目名称:edimax-br-6528n,代码行数:23,


示例10: dma_map_single

struct urb *usb_buffer_map(struct urb *urb){	struct usb_bus		*bus;	struct device		*controller;	if (!urb			|| !urb->dev			|| !(bus = urb->dev->bus)			|| !(controller = bus->controller))		return NULL;	if (controller->dma_mask) {		urb->transfer_dma = dma_map_single(controller,			urb->transfer_buffer, urb->transfer_buffer_length,			usb_pipein(urb->pipe)				? DMA_FROM_DEVICE : DMA_TO_DEVICE);	/* FIXME generic api broken like pci, can't report errors */	/* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */	} else		urb->transfer_dma = ~0;	urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	return urb;}
开发者ID:krachlatte,项目名称:Sony-Xperia-Go-ST27i,代码行数:23,


示例11: usb_stor_clear_halt

/* This is a version of usb_clear_halt() that doesn't read the status from * the device -- this is because some devices crash their internal firmware * when the status is requested after a halt */int usb_stor_clear_halt(struct us_data *us, int pipe){	int result;	int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);	result = usb_stor_control_msg(us,		usb_sndctrlpipe(us->pusb_dev, 0),		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,		endp, NULL, 0);		/* note: no 3*HZ timeout */	US_DEBUGP("usb_stor_clear_halt: result=%d/n", result);	/* this is a failure case */	if (result < 0)		return result;	/* reset the toggles and endpoint flags */	usb_endpoint_running(us->pusb_dev, usb_pipeendpoint(pipe),		usb_pipeout(pipe));	usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),		usb_pipeout(pipe), 0);	return 0;}
开发者ID:liuxueyang,项目名称:Linux-Unix,代码行数:27,


示例12: vstusb_fill_and_send_urb

static int vstusb_fill_and_send_urb(struct urb *urb,				    struct usb_device *usb_dev,				    unsigned int pipe, void *data,				    unsigned int len, struct completion *done){	struct usb_host_endpoint *ep;	struct usb_host_endpoint **hostep;	unsigned int pipend;	int status;	hostep = usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out;	pipend = usb_pipeendpoint(pipe);	ep = hostep[pipend];	if (!ep || (len == 0))		return -EINVAL;	if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)	    == USB_ENDPOINT_XFER_INT) {		pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);		usb_fill_int_urb(urb, usb_dev, pipe, data, len,				 (usb_complete_t)usb_api_blocking_completion,				 NULL, ep->desc.bInterval);	} else		usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,				  (usb_complete_t)usb_api_blocking_completion,				  NULL);	init_completion(done);	urb->context = done;	urb->actual_length = 0;	status = usb_submit_urb(urb, GFP_KERNEL);	return status;}
开发者ID:mpalmer,项目名称:linux-2.6,代码行数:36,


示例13: usb_buffer_dmasync

/** * usb_buffer_dmasync - synchronize DMA and CPU view of buffer(s) * @urb: urb whose transfer_buffer/setup_packet will be synchronized */void usb_buffer_dmasync(struct urb *urb){	struct usb_bus		*bus;	struct device		*controller;	if (!urb			|| !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)			|| !urb->dev			|| !(bus = urb->dev->bus)			|| !(controller = bus->controller))		return;	if (controller->dma_mask) {		dma_sync_single(controller,			urb->transfer_dma, urb->transfer_buffer_length,			usb_pipein(urb->pipe)				? DMA_FROM_DEVICE : DMA_TO_DEVICE);		if (usb_pipecontrol(urb->pipe))			dma_sync_single(controller,					urb->setup_dma,					sizeof(struct usb_ctrlrequest),					DMA_TO_DEVICE);	}}
开发者ID:vovan888,项目名称:p750-kernel,代码行数:28,


示例14: usb_sg_init

/** * usb_sg_init - initializes scatterlist-based bulk/interrupt I/O request * @io: request block being initialized.  until usb_sg_wait() returns, *	treat this as a pointer to an opaque block of memory, * @dev: the usb device that will send or receive the data * @pipe: endpoint "pipe" used to transfer the data * @period: polling rate for interrupt endpoints, in frames or * 	(for high speed endpoints) microframes; ignored for bulk * @sg: scatterlist entries * @nents: how many entries in the scatterlist * @length: how many bytes to send from the scatterlist, or zero to * 	send every byte identified in the list. * @mem_flags: SLAB_* flags affecting memory allocations in this call * * Returns zero for success, else a negative errno value.  This initializes a * scatter/gather request, allocating resources such as I/O mappings and urb * memory (except maybe memory used by USB controller drivers). * * The request must be issued using usb_sg_wait(), which waits for the I/O to * complete (or to be canceled) and then cleans up all resources allocated by * usb_sg_init(). * * The request may be canceled with usb_sg_cancel(), either before or after * usb_sg_wait() is called. */int usb_sg_init (	struct usb_sg_request	*io,	struct usb_device	*dev,	unsigned		pipe, 	unsigned		period,	struct scatterlist	*sg,	int			nents,	size_t			length,	int			mem_flags){	int			i;	int			urb_flags;	int			dma;	if (!io || !dev || !sg			|| usb_pipecontrol (pipe)			|| usb_pipeisoc (pipe)			|| nents <= 0)		return -EINVAL;	spin_lock_init (&io->lock);	io->dev = dev;	io->pipe = pipe;	io->sg = sg;	io->nents = nents;	/* not all host controllers use DMA (like the mainstream pci ones);	 * they can use PIO (sl811) or be software over another transport.	 */	dma = (dev->dev.dma_mask != 0);	if (dma)		io->entries = usb_buffer_map_sg (dev, pipe, sg, nents);	else		io->entries = nents;	/* initialize all the urbs we'll use */	if (io->entries <= 0)		return io->entries;	io->count = 0;	io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags);	if (!io->urbs)		goto nomem;	urb_flags = URB_ASYNC_UNLINK | URB_NO_TRANSFER_DMA_MAP			| URB_NO_INTERRUPT;	if (usb_pipein (pipe))		urb_flags |= URB_SHORT_NOT_OK;	for (i = 0; i < io->entries; i++, io->count = i) {		unsigned		len;		io->urbs [i] = usb_alloc_urb (0, mem_flags);		if (!io->urbs [i]) {			io->entries = i;			goto nomem;		}		io->urbs [i]->dev = NULL;		io->urbs [i]->pipe = pipe;		io->urbs [i]->interval = period;		io->urbs [i]->transfer_flags = urb_flags;		io->urbs [i]->complete = sg_complete;		io->urbs [i]->context = io;		io->urbs [i]->status = -EINPROGRESS;		io->urbs [i]->actual_length = 0;		if (dma) {			/* hc may use _only_ transfer_dma */			io->urbs [i]->transfer_dma = sg_dma_address (sg + i);			len = sg_dma_len (sg + i);		} else {			/* hc may use _only_ transfer_buffer *///.........这里部分代码省略.........
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:101,


示例15: sg_complete

static void sg_complete (struct urb *urb, struct pt_regs *regs){	struct usb_sg_request	*io = (struct usb_sg_request *) urb->context;	spin_lock (&io->lock);	/* In 2.5 we require hcds' endpoint queues not to progress after fault	 * reports, until the completion callback (this!) returns.  That lets	 * device driver code (like this routine) unlink queued urbs first,	 * if it needs to, since the HC won't work on them at all.  So it's	 * not possible for page N+1 to overwrite page N, and so on.	 *	 * That's only for "hard" faults; "soft" faults (unlinks) sometimes	 * complete before the HCD can get requests away from hardware,	 * though never during cleanup after a hard fault.	 */	if (io->status			&& (io->status != -ECONNRESET				|| urb->status != -ECONNRESET)			&& urb->actual_length) {		dev_err (io->dev->bus->controller,			"dev %s ep%d%s scatterlist error %d/%d/n",			io->dev->devpath,			usb_pipeendpoint (urb->pipe),			usb_pipein (urb->pipe) ? "in" : "out",			urb->status, io->status);		// BUG ();	}	if (urb->status && urb->status != -ECONNRESET) {		int		i, found, status;		io->status = urb->status;		/* the previous urbs, and this one, completed already.		 * unlink pending urbs so they won't rx/tx bad data.		 */		for (i = 0, found = 0; i < io->entries; i++) {			if (!io->urbs [i])				continue;			if (found) {				status = usb_unlink_urb (io->urbs [i]);				if (status != -EINPROGRESS && status != -EBUSY)				{					dev_err (&io->dev->dev,						"%s, unlink --> %d/n",						__FUNCTION__, status);					if(status == -19)					{					    printk("sg_complete====will do softreset/n");                                            kerSysMipsSoftReset();                                        }			        }			} else if (urb == io->urbs [i])				found = 1;		}	}	urb->dev = NULL;	/* on the last completion, signal usb_sg_wait() */	io->bytes += urb->actual_length;	io->count--;	if (!io->count)		complete (&io->complete);	spin_unlock (&io->lock);}
开发者ID:earthGavinLee,项目名称:hg556a_source,代码行数:67,


示例16: ehci_submit_async

static intehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,		   int length, struct devrequest *req){	struct QH *qh;	struct qTD *td;	volatile struct qTD *vtd;	unsigned long ts;	uint32_t *tdp;	uint32_t endpt, token, usbsts;	uint32_t c, toggle;	uint32_t cmd;	int timeout;	int ret = 0;	debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p/n", dev, pipe,	      buffer, length, req);	if (req != NULL)		debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u/n",		      req->request, req->request,		      req->requesttype, req->requesttype,		      le16_to_cpu(req->value), le16_to_cpu(req->value),		      le16_to_cpu(req->index));	qh = ehci_alloc(sizeof(struct QH), 32);	if (qh == NULL) {		debug("unable to allocate QH/n");		return -1;	}	qh->qh_link = cpu_to_hc32((uint32_t)&qh_list | QH_LINK_TYPE_QH);	c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&	     usb_pipeendpoint(pipe) == 0) ? 1 : 0;	endpt = (8 << 28) |	    (c << 27) |	    (usb_maxpacket(dev, pipe) << 16) |	    (0 << 15) |	    (1 << 14) |	    (usb_pipespeed(pipe) << 12) |	    (usb_pipeendpoint(pipe) << 8) |	    (0 << 7) | (usb_pipedevice(pipe) << 0);	qh->qh_endpt1 = cpu_to_hc32(endpt);	endpt = (1 << 30) |	    (dev->portnr << 23) |	    (dev->parent->devnum << 16) | (0 << 8) | (0 << 0);	qh->qh_endpt2 = cpu_to_hc32(endpt);	qh->qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);	td = NULL;	tdp = &qh->qh_overlay.qt_next;	toggle =	    usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe));	if (req != NULL) {		td = ehci_alloc(sizeof(struct qTD), 32);		if (td == NULL) {			debug("unable to allocate SETUP td/n");			goto fail;		}		td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);		td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);		token = (0 << 31) |		    (sizeof(*req) << 16) |		    (0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0);		td->qt_token = cpu_to_hc32(token);		if (ehci_td_buffer(td, req, sizeof(*req)) != 0) {			debug("unable construct SETUP td/n");			ehci_free(td, sizeof(*td));			goto fail;		}		*tdp = cpu_to_hc32((uint32_t) td);		tdp = &td->qt_next;		toggle = 1;	}	if (length > 0 || req == NULL) {		td = ehci_alloc(sizeof(struct qTD), 32);		if (td == NULL) {			debug("unable to allocate DATA td/n");			goto fail;		}		td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);		td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);		token = (toggle << 31) |		    (length << 16) |		    ((req == NULL ? 1 : 0) << 15) |		    (0 << 12) |		    (3 << 10) |		    ((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0);		td->qt_token = cpu_to_hc32(token);		if (ehci_td_buffer(td, buffer, length) != 0) {			debug("unable construct DATA td/n");			ehci_free(td, sizeof(*td));			goto fail;		}		*tdp = cpu_to_hc32((uint32_t) td);		tdp = &td->qt_next;	}	if (req != NULL) {//.........这里部分代码省略.........
开发者ID:IngenicC,项目名称:u-boot,代码行数:101,


示例17: dwc_otg_hcd_qh_init

/** Initializes a QH structure. * * @param[in] _hcd The HCD state structure for the DWC OTG controller. * @param[in] _qh The QH to init. * @param[in] _urb Holds the information about the device/endpoint that we need * to initialize the QH. */#define SCHEDULE_SLOP 10#define SCHEDULE_SPLIT_SLOP	10  /* 1 == 125us,  10 -> 1.25ms, 20 -> 2.5ms, */void dwc_otg_hcd_qh_init(dwc_otg_hcd_t * _hcd, dwc_otg_qh_t * _qh,			 struct urb *_urb){	memset(_qh, 0, sizeof(dwc_otg_qh_t));	/* Initialize QH */	switch (usb_pipetype(_urb->pipe)) {	case PIPE_CONTROL:		_qh->ep_type = USB_ENDPOINT_XFER_CONTROL;		break;	case PIPE_BULK:		_qh->ep_type = USB_ENDPOINT_XFER_BULK;		break;	case PIPE_ISOCHRONOUS:		_qh->ep_type = USB_ENDPOINT_XFER_ISOC;		break;	case PIPE_INTERRUPT:		_qh->ep_type = USB_ENDPOINT_XFER_INT;		break;	}	_qh->ep_is_in = usb_pipein(_urb->pipe) ? 1 : 0;	_qh->data_toggle = DWC_OTG_HC_PID_DATA0;	_qh->maxp =	    usb_maxpacket(_urb->dev, _urb->pipe, !(usb_pipein(_urb->pipe)));	INIT_LIST_HEAD(&_qh->qtd_list);	INIT_LIST_HEAD(&_qh->qh_list_entry);	_qh->channel = NULL;	/* FS/LS Enpoint on HS Hub 	 * NOT virtual root hub */	_qh->do_split = 0;	if (((_urb->dev->speed == USB_SPEED_LOW) ||	     (_urb->dev->speed == USB_SPEED_FULL)) &&	    (_urb->dev->tt) && (_urb->dev->tt->hub)	    && (_urb->dev->tt->hub->devnum != 1)) {		DWC_DEBUGPL(DBG_HCD,			    "QH init: EP %d: TT found at hub addr %d, for port %d/n",			    usb_pipeendpoint(_urb->pipe),			    _urb->dev->tt->hub->devnum, _urb->dev->ttport);		_qh->do_split = 1;	}	if (_qh->ep_type == USB_ENDPOINT_XFER_INT ||	    _qh->ep_type == USB_ENDPOINT_XFER_ISOC) {		/* Compute scheduling parameters once and save them. */		hprt0_data_t hprt;		/** @todo Account for split transfers in the bus time. */		int bytecount =		    dwc_hb_mult(_qh->maxp) * dwc_max_packet(_qh->maxp);		int usecs = /*FIXME: hardcode to highspeed, to fix Full/Low speed device via Hub*/		    usb_calc_bus_time(/*_urb->dev->speed*/USB_SPEED_HIGH, usb_pipein(_urb->pipe),				      (_qh->ep_type == USB_ENDPOINT_XFER_ISOC),				      bytecount);		_qh->usecs = NS_TO_US(usecs);		/* Start in a slightly future (micro)frame. */		_qh->sched_frame = dwc_frame_num_inc(_hcd->frame_number,						     SCHEDULE_SLOP);		_qh->interval = _urb->interval;#if 0		/* Increase interrupt polling rate for debugging. */		if (_qh->ep_type == USB_ENDPOINT_XFER_INT) {			_qh->interval = 8;		}#endif		hprt.d32 = dwc_read_reg32(_hcd->core_if->host_if->hprt0);		if ((hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) &&		    ((_urb->dev->speed == USB_SPEED_LOW) ||		     (_urb->dev->speed == USB_SPEED_FULL))) {			_qh->interval *= 8;			_qh->sched_frame |= 0x7;			_qh->start_split_frame = _qh->sched_frame;		}	}else{		if(_qh->do_split){			_qh->interval = SCHEDULE_SPLIT_SLOP;			_qh->sched_frame = dwc_frame_num_inc(_hcd->frame_number,						     _qh->interval);		};	}	DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD QH Initialized/n");	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - qh = %p/n", _qh);	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - Device Address = %d/n",		    _urb->dev->devnum);	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - Endpoint %d, %s/n",		    usb_pipeendpoint(_urb->pipe),		    usb_pipein(_urb->pipe) == USB_DIR_IN ? "IN" : "OUT");//.........这里部分代码省略.........
开发者ID:CoreTech-Development,项目名称:buildroot-linux-kernel,代码行数:101,


示例18: ehci_submit_async

//.........这里部分代码省略.........			 * However, if the input buffer is not page-aligned, the			 * portion of the first page before the buffer start			 * offset within that page is unusable.			 */			xfr_bytes -= (unsigned long)buf_ptr & (EHCI_PAGE_SIZE - 1);			/*			 * In order to keep each packet within a qTD transfer,			 * align the qTD transfer size to PKT_ALIGN.			 */			xfr_bytes &= ~(PKT_ALIGN - 1);			/*			 * This transfer may be shorter than the available qTD			 * transfer size that has just been computed.			 */			xfr_bytes = min(xfr_bytes, left_length);			/*			 * Setup request qTD (3.5 in ehci-r10.pdf)			 *			 *   qt_next ................ 03-00 H			 *   qt_altnext ............. 07-04 H			 *   qt_token ............... 0B-08 H			 *			 *   [ buffer, buffer_hi ] loaded with "buffer".			 */			qtd[qtd_counter].qt_next =					cpu_to_hc32(QT_NEXT_TERMINATE);			qtd[qtd_counter].qt_altnext =					cpu_to_hc32(QT_NEXT_TERMINATE);			token = QT_TOKEN_DT(toggle) |				QT_TOKEN_TOTALBYTES(xfr_bytes) |				QT_TOKEN_IOC(req == NULL) | QT_TOKEN_CPAGE(0) |				QT_TOKEN_CERR(3) |				QT_TOKEN_PID(usb_pipein(pipe) ?					QT_TOKEN_PID_IN : QT_TOKEN_PID_OUT) |				QT_TOKEN_STATUS(QT_TOKEN_STATUS_ACTIVE);			qtd[qtd_counter].qt_token = cpu_to_hc32(token);			if (ehci_td_buffer(&qtd[qtd_counter], buf_ptr,						xfr_bytes)) {				printf("unable to construct DATA TD/n");				goto fail;			}			/* Update previous qTD! */			*tdp = cpu_to_hc32((unsigned long)&qtd[qtd_counter]);			tdp = &qtd[qtd_counter++].qt_next;			/*			 * Data toggle has to be adjusted since the qTD transfer			 * size is not always an even multiple of			 * wMaxPacketSize.			 */			if ((xfr_bytes / maxpacket) & 1)				toggle ^= 1;			buf_ptr += xfr_bytes;			left_length -= xfr_bytes;		} while (left_length > 0);	}	if (req != NULL) {		/*		 * Setup request qTD (3.5 in ehci-r10.pdf)		 *		 *   qt_next ................ 03-00 H		 *   qt_altnext ............. 07-04 H		 *   qt_token ............... 0B-08 H		 */		qtd[qtd_counter].qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
开发者ID:SDRG-UCT,项目名称:u-boot_rhino,代码行数:67,


示例19: usbpn_probe

int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id){	static const char ifname[] = "usbpn%d";	const struct usb_cdc_union_desc *union_header = NULL;	const struct usb_host_interface *data_desc;	struct usb_interface *data_intf;	struct usb_device *usbdev = interface_to_usbdev(intf);	struct net_device *dev;	struct usbpn_dev *pnd;	u8 *data;	int phonet = 0;	int len, err;	data = intf->altsetting->extra;	len = intf->altsetting->extralen;	while (len >= 3) {		u8 dlen = data[0];		if (dlen < 3)			return -EINVAL;		/* bDescriptorType */		if (data[1] == USB_DT_CS_INTERFACE) {			/* bDescriptorSubType */			switch (data[2]) {			case USB_CDC_UNION_TYPE:				if (union_header || dlen < 5)					break;				union_header =					(struct usb_cdc_union_desc *)data;				break;			case 0xAB:				phonet = 1;				break;			}		}		data += dlen;		len -= dlen;	}	if (!union_header || !phonet)		return -EINVAL;	data_intf = usb_ifnum_to_if(usbdev, union_header->bSlaveInterface0);	if (data_intf == NULL)		return -ENODEV;	/* Data interface has one inactive and one active setting */	if (data_intf->num_altsetting != 2)		return -EINVAL;	if (data_intf->altsetting[0].desc.bNumEndpoints == 0	 && data_intf->altsetting[1].desc.bNumEndpoints == 2)		data_desc = data_intf->altsetting + 1;	else	if (data_intf->altsetting[0].desc.bNumEndpoints == 2	 && data_intf->altsetting[1].desc.bNumEndpoints == 0)		data_desc = data_intf->altsetting;	else		return -EINVAL;	dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,				ifname, usbpn_setup);	if (!dev)		return -ENOMEM;	pnd = netdev_priv(dev);	SET_NETDEV_DEV(dev, &intf->dev);	netif_stop_queue(dev);	pnd->dev = dev;	pnd->usb = usb_get_dev(usbdev);	pnd->intf = intf;	pnd->data_intf = data_intf;	spin_lock_init(&pnd->tx_lock);	spin_lock_init(&pnd->rx_lock);	/* Endpoints */	if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) {		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,			data_desc->endpoint[0].desc.bEndpointAddress);		pnd->tx_pipe = usb_sndbulkpipe(usbdev,			data_desc->endpoint[1].desc.bEndpointAddress);	} else {		pnd->rx_pipe = usb_rcvbulkpipe(usbdev,			data_desc->endpoint[1].desc.bEndpointAddress);		pnd->tx_pipe = usb_sndbulkpipe(usbdev,			data_desc->endpoint[0].desc.bEndpointAddress);	}	pnd->active_setting = data_desc - data_intf->altsetting;	err = usb_driver_claim_interface(&usbpn_driver, data_intf, pnd);	if (err)		goto out;	/* Force inactive mode until the network device is brought UP */	usb_set_interface(usbdev, union_header->bSlaveInterface0,				!pnd->active_setting);	usb_set_intfdata(intf, pnd);	err = register_netdev(dev);	if (err) {		usb_driver_release_interface(&usbpn_driver, data_intf);		goto out;//.........这里部分代码省略.........
开发者ID:Atrix-Dev-Team,项目名称:kernel-MB860,代码行数:101,


示例20: if_usb_probe

static int __devinit if_usb_probe(struct usb_interface *intf,					const struct usb_device_id *id){	struct usb_host_interface *data_desc;	struct usb_link_device *usb_ld =			(struct usb_link_device *)id->driver_info;	struct link_device *ld = &usb_ld->ld;	struct usb_interface *data_intf;	struct usb_device *usbdev = interface_to_usbdev(intf);	struct device *dev, *ehci_dev, *root_hub;	struct if_usb_devdata *pipe;	struct urb *urb;	int i;	int j;	int dev_id;	int err;	/* To detect usb device order probed */	dev_id = intf->cur_altsetting->desc.bInterfaceNumber;	if (dev_id >= IF_USB_DEVNUM_MAX) {		dev_err(&intf->dev, "Device id %d cannot support/n",								dev_id);		return -EINVAL;	}	if (!usb_ld) {		dev_err(&intf->dev,		"if_usb device doesn't be allocated/n");		err = ENOMEM;		goto out;	}	mif_info("probe dev_id=%d usb_device_id(0x%p), usb_ld (0x%p)/n",				dev_id, id, usb_ld);	usb_ld->usbdev = usbdev;	usb_get_dev(usbdev);	for (i = 0; i < IF_USB_DEVNUM_MAX; i++) {		data_intf = usb_ifnum_to_if(usbdev, i);		/* remap endpoint of RAW to no.1 for LTE modem */		if (i == 0)			pipe = &usb_ld->devdata[1];		else if (i == 1)			pipe = &usb_ld->devdata[0];		else			pipe = &usb_ld->devdata[i];		pipe->disconnected = 0;		pipe->data_intf = data_intf;		data_desc = data_intf->cur_altsetting;		/* Endpoints */		if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) {			pipe->rx_pipe = usb_rcvbulkpipe(usbdev,				data_desc->endpoint[0].desc.bEndpointAddress);			pipe->tx_pipe = usb_sndbulkpipe(usbdev,				data_desc->endpoint[1].desc.bEndpointAddress);			pipe->rx_buf_size = 1024*4;		} else {			pipe->rx_pipe = usb_rcvbulkpipe(usbdev,				data_desc->endpoint[1].desc.bEndpointAddress);			pipe->tx_pipe = usb_sndbulkpipe(usbdev,				data_desc->endpoint[0].desc.bEndpointAddress);			pipe->rx_buf_size = 1024*4;		}		if (i == 0) {			dev_info(&usbdev->dev, "USB IF USB device found/n");		} else {			err = usb_driver_claim_interface(&if_usb_driver,					data_intf, usb_ld);			if (err < 0) {				mif_err("failed to cliam usb interface/n");				goto out;			}		}		usb_set_intfdata(data_intf, usb_ld);		usb_ld->dev_count++;		pm_suspend_ignore_children(&data_intf->dev, true);		for (j = 0; j < URB_COUNT; j++) {			urb = usb_alloc_urb(0, GFP_KERNEL);			if (!urb) {				mif_err("alloc urb fail/n");				err = -ENOMEM;				goto out2;			}			urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;			urb->transfer_buffer = usb_alloc_coherent(usbdev,				pipe->rx_buf_size, GFP_KERNEL,				&urb->transfer_dma);			if (!urb->transfer_buffer) {				mif_err(				"Failed to allocate transfer buffer/n");				usb_free_urb(urb);//.........这里部分代码省略.........
开发者ID:gadido30,项目名称:bigfatwifi,代码行数:101,


示例21: vhcd_urb_enqueue

static int vhcd_urb_enqueue(struct usb_hcd *hcd,                            struct usb_host_endpoint *ep,                            struct urb *urb,                            gfp_t mem_flags){	int ret = 0;	unsigned int transfer_flags = 0 ;	struct usb_device * udev = urb->dev;	/* FIXME Check for non existent device */	if (!HC_IS_RUNNING(hcd->state)) {		LOG("HC is not running/n");		return -ENODEV;	}	/* we have to trap some control messages, i.e. USB_REQ_SET_ADDRESS... */	/* TODO we don't have to do it here, but in the server */	if (usb_pipedevice(urb->pipe) == 0) {		__u8 type = usb_pipetype(urb->pipe);		struct usb_ctrlrequest *ctrlreq = (struct usb_ctrlrequest *) urb->setup_packet;		if (type != PIPE_CONTROL || !ctrlreq ) {			LOG("invalid request to devnum 0/n");			ret = -EINVAL;			goto no_need_xmit;		}		switch (ctrlreq->bRequest) {		case USB_REQ_SET_ADDRESS:			LOG("SetAddress Request (%d) to port %d/n",			          ctrlreq->wValue, urb->dev->portnum);			spin_lock (&urb->lock);			if (urb->status == -EINPROGRESS) {				/* This request is successfully completed. */				/* If not -EINPROGRESS, possibly unlinked. */				urb->status = 0;			}			spin_unlock (&urb->lock);			goto no_need_xmit;		case USB_REQ_GET_DESCRIPTOR:			if (ctrlreq->wValue == (USB_DT_DEVICE << 8))				LOG("Get_Descriptor to device 0 (get max pipe size)/n");			goto out;		default:			/* NOT REACHED */			LOG("invalid request to devnum 0 bRequest %u, wValue %u/n",			          ctrlreq->bRequest, ctrlreq->wValue);			ret = -EINVAL;			goto no_need_xmit;		}	}out:	if (urb->status != -EINPROGRESS) {		LOG("URB already unlinked!, status %d/n", urb->status);		return urb->status;	}	if (usb_pipeisoc(urb->pipe)) {		LOG("ISO URBs not supported");		ret = -EINVAL;		goto no_need_xmit;	}	urb->hcpriv = (void *) hcd_to_vhcd(hcd);	LOG("hcpriv %p", urb->hcpriv);	transfer_flags = urb->transfer_flags;	usb_get_urb(urb);#if 0	d_urb->type              = usb_pipetype(urb->pipe);	d_urb->dev_id            = data->gadget[urb->dev->portnum-1].id;	d_urb->endpoint          = usb_pipeendpoint(urb->pipe);	d_urb->direction         = 0 || usb_pipein(urb->pipe);	d_urb->interval          = urb->interval;	d_urb->transfer_flags    = urb->transfer_flags;	d_urb->number_of_packets = urb->number_of_packets;	d_urb->priv              = priv;	d_urb->size              = urb->transfer_buffer_length; 	d_urb->data			     = urb->transfer_buffer;	d_urb->phys_addr	     = d_urb->data?virt_to_phys(d_urb->data):0;	if (urb->setup_packet) {		memcpy(d_urb->setup_packet, urb->setup_packet, 8);	}	/* XXX ISO ? *///	if (urb->number_of_packets)//		memcpy(d_urb->iso_desc, urb->iso_frame_desc, urb->number_of_packets*sizeof(struct usb_iso_packet_descriptor));//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:linux_drivers,代码行数:101,


示例22: usb_submit_urb

//.........这里部分代码省略......... * * GFP_ATOMIC is used when *   (a) you are inside a completion handler, an interrupt, bottom half, *       tasklet or timer, or *   (b) you are holding a spinlock or rwlock (does not apply to *       semaphores), or *   (c) current->state != TASK_RUNNING, this is the case only after *       you've changed it. * * GFP_NOIO is used in the block io path and error handling of storage * devices. * * All other situations use GFP_KERNEL. * * Some more specific rules for mem_flags can be inferred, such as *  (1) start_xmit, timeout, and receive methods of network drivers must *      use GFP_ATOMIC (they are called with a spinlock held); *  (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also *      called with a spinlock held); *  (3) If you use a kernel thread with a network driver you must use *      GFP_NOIO, unless (b) or (c) apply; *  (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c) *      apply or your are in a storage driver's block io path; *  (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and *  (6) changing firmware on a running storage or net device uses *      GFP_NOIO, unless b) or c) apply * */int usb_submit_urb(struct urb *urb, gfp_t mem_flags){	int				xfertype, max;	struct usb_device		*dev;	struct usb_host_endpoint	*ep;	int				is_out;	if (!urb || urb->hcpriv || !urb->complete)		return -EINVAL;	dev = urb->dev;	if ((!dev) || (dev->state < USB_STATE_DEFAULT))		return -ENODEV;	/* For now, get the endpoint from the pipe.  Eventually drivers	 * will be required to set urb->ep directly and we will eliminate	 * urb->pipe.	 */	ep = (usb_pipein(urb->pipe) ? dev->ep_in : dev->ep_out)			[usb_pipeendpoint(urb->pipe)];	if (!ep)		return -ENOENT;	urb->ep = ep;	urb->status = -EINPROGRESS;	urb->actual_length = 0;	/* Lots of sanity checks, so HCDs can rely on clean data	 * and don't need to duplicate tests	 */	xfertype = usb_endpoint_type(&ep->desc);	if (xfertype == USB_ENDPOINT_XFER_CONTROL) {		struct usb_ctrlrequest *setup =				(struct usb_ctrlrequest *) urb->setup_packet;		if (!setup)			return -ENOEXEC;		is_out = !(setup->bRequestType & USB_DIR_IN) ||				!setup->wLength;	} else {		is_out = usb_endpoint_dir_out(&ep->desc);	}	/* Cache the direction for later use */	urb->transfer_flags = (urb->transfer_flags & ~URB_DIR_MASK) |			(is_out ? URB_DIR_OUT : URB_DIR_IN);	if (xfertype != USB_ENDPOINT_XFER_CONTROL &&			dev->state < USB_STATE_CONFIGURED)		return -ENODEV;	max = le16_to_cpu(ep->desc.wMaxPacketSize);	if (max <= 0) {		dev_dbg(&dev->dev,			"bogus endpoint ep%d%s in %s (bad maxpacket %d)/n",			usb_endpoint_num(&ep->desc), is_out ? "out" : "in",			__func__, max);		return -EMSGSIZE;	}	/* periodic transfers limit size per frame/uframe,	 * but drivers only control those sizes for ISO.	 * while we're checking, initialize return status.	 */	if (xfertype == USB_ENDPOINT_XFER_ISOC) {		int	n, len;		/* "high bandwidth" mode, 1-3 packets/uframe? */		if (dev->speed == USB_SPEED_HIGH) {			int	mult = 1 + ((max >> 11) & 0x03);			max &= 0x07ff;			max *= mult;		}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,


示例23: sl811_send_packet

static int sl811_send_packet(struct usb_device *dev, unsigned long pipe, __u8 *buffer, int len){	__u8 ctrl = SL811_USB_CTRL_ARM | SL811_USB_CTRL_ENABLE;	__u16 status = 0;	int err = 0, time_start = get_timer(0);	int need_preamble = !(rh_status.wPortStatus & USB_PORT_STAT_LOW_SPEED) &&		(dev->speed == USB_SPEED_LOW);	if (len > 239)		return -1;	if (usb_pipeout(pipe))		ctrl |= SL811_USB_CTRL_DIR_OUT;	if (usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe)))		ctrl |= SL811_USB_CTRL_TOGGLE_1;	if (need_preamble)		ctrl |= SL811_USB_CTRL_PREAMBLE;	sl811_write(SL811_INTRSTS, 0xff);	while (err < 3) {		sl811_write(SL811_ADDR_A, 0x10);		sl811_write(SL811_LEN_A, len);		if (usb_pipeout(pipe) && len)			sl811_write_buf(0x10, buffer, len);		if (!(rh_status.wPortStatus & USB_PORT_STAT_LOW_SPEED) &&		    sl811_read(SL811_SOFCNTDIV)*64 < calc_needed_buswidth(len, need_preamble))			ctrl |= SL811_USB_CTRL_SOF;		else			ctrl &= ~SL811_USB_CTRL_SOF;		sl811_write(SL811_CTRL_A, ctrl);		while (!(sl811_read(SL811_INTRSTS) & SL811_INTR_DONE_A)) {			if (5*CONFIG_SYS_HZ < get_timer(time_start)) {				printf("USB transmit timed out/n");				return -USB_ST_CRC_ERR;			}		}		sl811_write(SL811_INTRSTS, 0xff);		status = sl811_read(SL811_STS_A);		if (status & SL811_USB_STS_ACK) {			int remainder = sl811_read(SL811_CNT_A);			if (remainder) {				PDEBUG(0, "usb transfer remainder = %d/n", remainder);				len -= remainder;			}			if (usb_pipein(pipe) && len)				sl811_read_buf(0x10, buffer, len);			return len;		}		if ((status & SL811_USB_STS_NAK) == SL811_USB_STS_NAK)			continue;		PDEBUG(0, "usb transfer error %#x/n", (int)status);		err++;	}	err = 0;	if (status & SL811_USB_STS_ERROR)		err |= USB_ST_BUF_ERR;	if (status & SL811_USB_STS_TIMEOUT)		err |= USB_ST_CRC_ERR;	if (status & SL811_USB_STS_STALL)		err |= USB_ST_STALLED;	return -err;}
开发者ID:0xFelix,项目名称:u-boot-edminiv2,代码行数:72,


示例24: dwc_otg_hcd_qh_init

void dwc_otg_hcd_qh_init(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh, struct urb *urb){	char *speed, *type;	memset (qh, 0, sizeof (dwc_otg_qh_t));	/* Initialize QH */	switch (usb_pipetype(urb->pipe)) {	case PIPE_CONTROL:		qh->ep_type = USB_ENDPOINT_XFER_CONTROL;		break;	case PIPE_BULK:		qh->ep_type = USB_ENDPOINT_XFER_BULK;		break;	case PIPE_ISOCHRONOUS:		qh->ep_type = USB_ENDPOINT_XFER_ISOC;		break;	case PIPE_INTERRUPT:		qh->ep_type = USB_ENDPOINT_XFER_INT;		break;	}	qh->ep_is_in = usb_pipein(urb->pipe) ? 1 : 0;	qh->data_toggle = DWC_OTG_HC_PID_DATA0;	qh->maxp = usb_maxpacket(urb->dev, urb->pipe, !(usb_pipein(urb->pipe)));	INIT_LIST_HEAD(&qh->qtd_list);	INIT_LIST_HEAD(&qh->qh_list_entry);	qh->channel = NULL;	/* FS/LS Enpoint on HS Hub	 * NOT virtual root hub */	qh->do_split = 0;	if (((urb->dev->speed == USB_SPEED_LOW) ||	     (urb->dev->speed == USB_SPEED_FULL)) &&	     (urb->dev->tt) && (urb->dev->tt->hub) && (urb->dev->tt->hub->devnum != 1))	{		DWC_DEBUGPL(DBG_HCD, "QH init: EP %d: TT found at hub addr %d, for port %d/n",			   usb_pipeendpoint(urb->pipe), urb->dev->tt->hub->devnum,			   urb->dev->ttport);		qh->do_split = 1;	}	if (qh->ep_type == USB_ENDPOINT_XFER_INT ||	    qh->ep_type == USB_ENDPOINT_XFER_ISOC) {		/* Compute scheduling parameters once and save them. */		hprt0_data_t hprt;		/** @todo Account for split transfers in the bus time. */		int bytecount = dwc_hb_mult(qh->maxp) * dwc_max_packet(qh->maxp);		/* FIXME: work-around patch by Steven */		qh->usecs = NS_TO_US(usb_calc_bus_time(urb->dev->speed,					       usb_pipein(urb->pipe),					       (qh->ep_type == USB_ENDPOINT_XFER_ISOC),					       bytecount));		/* Start in a slightly future (micro)frame. */		qh->sched_frame = dwc_frame_num_inc(hcd->frame_number,						     SCHEDULE_SLOP);		qh->interval = urb->interval;#if 0		/* Increase interrupt polling rate for debugging. */		if (qh->ep_type == USB_ENDPOINT_XFER_INT) {			qh->interval = 8;		}#endif		hprt.d32 = dwc_read_reg32(hcd->core_if->host_if->hprt0);		if ((hprt.b.prtspd == DWC_HPRT0_PRTSPD_HIGH_SPEED) &&		    ((urb->dev->speed == USB_SPEED_LOW) ||		     (urb->dev->speed == USB_SPEED_FULL))) {			qh->interval *= 8;			qh->sched_frame |= 0x7;			qh->start_split_frame = qh->sched_frame;		}	}	DWC_DEBUGPL(DBG_HCD, "DWC OTG HCD QH Initialized/n");	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - qh = %p/n", qh);	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - Device Address = %d/n",		    urb->dev->devnum);	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - Endpoint %d, %s/n",		    usb_pipeendpoint(urb->pipe),		    usb_pipein(urb->pipe) == USB_DIR_IN ? "IN" : "OUT");	switch(urb->dev->speed) {	case USB_SPEED_LOW:		speed = "low";		break;	case USB_SPEED_FULL:		speed = "full";		break;	case USB_SPEED_HIGH:		speed = "high";		break;	default:		speed = "?";		break;	}	DWC_DEBUGPL(DBG_HCDV, "DWC OTG HCD QH  - Speed = %s/n", speed);//.........这里部分代码省略.........
开发者ID:4pao,项目名称:openwrt,代码行数:101,


示例25: submit_control_msg

int 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:0xFelix,项目名称:u-boot-edminiv2,代码行数:63,


示例26: ehci_submit_async

static intehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,		   int length, struct devrequest *req){	struct dwc_ctrl *ctrl = dev->controller;	pUSB_OTG_REG otgReg = ctrl->otgReg;	uint32_t channel_num = usb_pipeendpoint(pipe);	uint32_t eptype;	HOST_RET ret = HOST_OK;	HCTSIZ_DATA hctsiz;	HCCHAR_DATA hcchar;	uint32_t hcStat;	uint32_t errCnt;	uint32_t packet_size;	uint32_t datatoggle;	eptype = usb_pipetype(pipe);	// ep tye definition is different in pipe and dwc hcchar	if(eptype == 2 )		eptype = 0;	else if (eptype == 3)		eptype = 2;    	debug("ehci_submit_async channel pipe %lx req %p, len %x/n", pipe, req, length);	if(req == NULL)		packet_size = 0x200;	else		packet_size = 0x40;	if (req != NULL) {  // setup for control		hctsiz.d32 = 0;		hctsiz.b.pid =  DWC_HCTSIZ_SETUP;		hctsiz.b.pktcnt =  1;		hctsiz.b.xfersize =  8;		hcchar.d32 = 0;		hcchar.b.mps = packet_size; 		hcchar.b.epnum = channel_num; // use the same channel number as endpoint number		hcchar.b.epdir = DWC_EPDIR_OUT;		hcchar.b.eptype = eptype;		hcchar.b.multicnt = 1;		hcchar.b.devaddr = usb_pipedevice(pipe);		hcchar.b.chdis = 0;		hcchar.b.chen = 1;		hcStat = HCSTAT_SETUP;		errCnt = 0;		dwc_init_channel(dev, hctsiz.d32, hcchar, (uint32_t)req);		if(dwc_wait_for_complete(dev, channel_num, &hcStat, &errCnt)){			ret = HOST_ERR;			goto out;		}		if(hcStat != HCSTAT_DONE){			ret = HOST_ERR;			goto out;		}	}		if (length || (req == NULL)) {    // data for bulk & control		if(req)			datatoggle = DWC_HCTSIZ_DATA1;		else			datatoggle = ctrl->datatoggle[usb_pipein(pipe)];		debug("dwc_hcd data len %x toggle %x/n", length, datatoggle);		hctsiz.d32 = 0;		hctsiz.b.pid =  datatoggle;		hctsiz.b.pktcnt =  (length+packet_size - 1)/packet_size;		hctsiz.b.xfersize =  length;		hcchar.d32 = 0;		hcchar.b.mps = packet_size; 		hcchar.b.epnum = channel_num; // use the same channel number as endpoint number		hcchar.b.epdir = (req == NULL) ? usb_pipein(pipe) : DWC_EPDIR_IN;		hcchar.b.eptype = eptype;		hcchar.b.multicnt = 1;		hcchar.b.devaddr = usb_pipedevice(pipe);		hcchar.b.chdis = 0;		hcchar.b.chen = 1;		hcStat = HCSTAT_DATA;		errCnt = 0;        		if((req == NULL)&&(hctsiz.b.pktcnt&0x01))		{			ctrl->datatoggle[usb_pipein(pipe)] ^= 0x02;		}		dwc_init_channel(dev, hctsiz.d32, hcchar, (uint32_t)buffer);		if(dwc_wait_for_complete(dev, channel_num, &hcStat, &errCnt)){			ret = HOST_ERR;			goto out;		}		if(hcStat == HCSTAT_STALL)			ctrl->datatoggle[usb_pipein(pipe)] = 0;	}	if (req != NULL) {  // status for control		debug("status len %x/n", length);		hctsiz.d32 = 0;		hctsiz.b.dopng = 0;		hctsiz.b.pid =  DWC_HCTSIZ_DATA1;		hctsiz.b.pktcnt =  1;		hctsiz.b.xfersize =  0;		hcchar.d32 = 0;		hcchar.b.mps = packet_size; 		hcchar.b.epnum = channel_num; // use the same channel number as endpoint number//.........这里部分代码省略.........
开发者ID:michalliu,项目名称:rkchrome_uboot,代码行数:101,


示例27: _complete

/** * Sets the final status of an URB and returns it to the device driver. Any * required cleanup of the URB is performed. */static int _complete(dwc_otg_hcd_t * hcd, void *urb_handle,		     dwc_otg_hcd_urb_t * dwc_otg_urb, uint32_t status){	struct urb *urb = (struct urb *)urb_handle;#ifdef DEBUG	if (CHK_DEBUG_LEVEL(DBG_HCDV | DBG_HCD_URB)) {		DWC_PRINTF("%s: urb %p, device %d, ep %d %s, status=%d/n",			   __func__, urb, usb_pipedevice(urb->pipe),			   usb_pipeendpoint(urb->pipe),			   usb_pipein(urb->pipe) ? "IN" : "OUT", status);		if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {			int i;			for (i = 0; i < urb->number_of_packets; i++) {				DWC_PRINTF("  ISO Desc %d status: %d/n",					   i, urb->iso_frame_desc[i].status);			}		}	}#endif	urb->actual_length = dwc_otg_hcd_urb_get_actual_length(dwc_otg_urb);	/* Convert status value. */	switch (status) {	case -DWC_E_PROTOCOL:		status = -EPROTO;		break;	case -DWC_E_IN_PROGRESS:		status = -EINPROGRESS;		break;	case -DWC_E_PIPE:		status = -EPIPE;		break;	case -DWC_E_IO:		status = -EIO;		break;	case -DWC_E_TIMEOUT:		status = -ETIMEDOUT;		break;	default:		if (status) {			/* alan.K			 * DWC_OTG IP don't know this status, so assumed to be a DWC_E_PROTOCOL. 			 */			DWC_WARN("Unknown urb status %d, but assumed to be an EPROTO/n", status);			status = -EPROTO;		}	}	if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {		int i;		urb->error_count = dwc_otg_hcd_urb_get_error_count(dwc_otg_urb);		for (i = 0; i < urb->number_of_packets; ++i) {			urb->iso_frame_desc[i].actual_length =			    dwc_otg_hcd_urb_get_iso_desc_actual_length			    (dwc_otg_urb, i);			urb->iso_frame_desc[i].status =			    dwc_otg_hcd_urb_get_iso_desc_actual_length			    (dwc_otg_urb, i);		}	}	urb->status = status;	urb->hcpriv = NULL;	if (!status) {		if ((urb->transfer_flags & URB_SHORT_NOT_OK) &&		    (urb->actual_length < urb->transfer_buffer_length)) {			urb->status = -EREMOTEIO;		}	}	if ((usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) ||	    (usb_pipetype(urb->pipe) == PIPE_INTERRUPT)) {		struct usb_host_endpoint *ep = dwc_urb_to_endpoint(urb);		if (ep) {			free_bus_bandwidth(dwc_otg_hcd_to_hcd(hcd),					   dwc_otg_hcd_get_ep_bandwidth(hcd, ep->hcpriv),					   urb);		}	}	dwc_free(dwc_otg_urb);	usb_hcd_giveback_urb(dwc_otg_hcd_to_hcd(hcd), urb, status);	return 0;}
开发者ID:AmesianX,项目名称:telechips-linux,代码行数:89,



注:本文中的usb_pipein函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ usb_put_dev函数代码示例
C++ usb_pipeendpoint函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。