Date: Thu, 11 Sep 2008 07:58:03 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 149588 for review Message-ID: <200809110758.m8B7w3Q4047793@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149588 Change 149588 by hselasky@hselasky_laptop001 on 2008/09/11 07:57:17 Add support for preselected endpoint numbers. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/template/usb2_template.c#10 edit .. //depot/projects/usb/src/sys/dev/usb2/template/usb2_template.h#5 edit .. //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_cdce.c#7 edit .. //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_msc.c#6 edit .. //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_mtp.c#6 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/template/usb2_template.c#10 (text+ko) ==== @@ -164,7 +164,7 @@ /* escape for Zero Max Packet Size */ mps = 0; } - ea = (ted->direction & (UE_DIR_IN | UE_DIR_OUT)); + ea = (ted->bEndpointAddress & (UE_ADDR | UE_DIR_IN | UE_DIR_OUT)); et = (ted->bmAttributes & UE_XFERTYPE); /* @@ -503,7 +503,12 @@ distance = 0xFFFF; best_n = 0; + if ((!ep->needs_in) && (!ep->needs_out)) { + return (0); /* we are done */ + } if (ep->needs_ep_type == UE_CONTROL) { + ep->needs_in = 0; + ep->needs_out = 0; dir_in = 1; dir_out = 1; } else { @@ -572,12 +577,6 @@ /* get the correct profile */ pf = ep->pf; - /* get maximum frame size */ - if (dir_in) - max_frame_size = pf->max_in_frame_size; - else - max_frame_size = pf->max_out_frame_size; - /* reserve IN-endpoint */ if (dir_in || pf->is_simplex) { ues->bmInAlloc[best_n / 8] |= @@ -609,6 +608,7 @@ usb2_hw_ep_get_needs(struct usb2_hw_ep_scratch *ues, uint8_t ep_type, uint8_t is_complete) { + const struct usb2_hw_ep_profile *pf; struct usb2_hw_ep_scratch_sub *ep_iface; struct usb2_hw_ep_scratch_sub *ep_curr; struct usb2_hw_ep_scratch_sub *ep_max; @@ -619,6 +619,7 @@ uint16_t wMaxPacketSize; uint16_t temp; uint8_t speed; + uint8_t ep_no; ep_iface = ues->ep_max; ep_curr = ues->ep_max; @@ -670,13 +671,58 @@ /* handle packet multiplier */ temp = (wMaxPacketSize >> 11) & 3; wMaxPacketSize &= 0x7FF; - if (temp == 2) { + if (temp == 1) { wMaxPacketSize *= 2; } else { wMaxPacketSize *= 3; } } - if (is_complete) { + /* + * Check if we have a fixed endpoint number, else the + * endpoint number is allocated dynamically: + */ + ep_no = (ed->bEndpointAddress & UE_ADDR); + if (ep_no != 0) { + + /* get HW endpoint profile */ + (ues->methods->get_hw_ep_profile) + (ues->udev, &pf, ep_no); + if (pf == NULL) { + /* HW profile does not exist - failure */ + DPRINTFN(0, "Endpoint profile %u " + "does not exist\n", ep_no); + return (1); + } + /* reserve fixed endpoint number */ + if (ep_type == UE_CONTROL) { + ues->bmInAlloc[ep_no / 8] |= + (1 << (ep_no % 8)); + ues->bmOutAlloc[ep_no / 8] |= + (1 << (ep_no % 8)); + if ((pf->max_in_frame_size < wMaxPacketSize) || + (pf->max_out_frame_size < wMaxPacketSize)) { + DPRINTFN(0, "Endpoint profile %u " + "has too small buffer!\n", ep_no); + return (1); + } + } else if (ed->bEndpointAddress & UE_DIR_IN) { + ues->bmInAlloc[ep_no / 8] |= + (1 << (ep_no % 8)); + if (pf->max_in_frame_size < wMaxPacketSize) { + DPRINTFN(0, "Endpoint profile %u " + "has too small buffer!\n", ep_no); + return (1); + } + } else { + ues->bmOutAlloc[ep_no / 8] |= + (1 << (ep_no % 8)); + if (pf->max_out_frame_size < wMaxPacketSize) { + DPRINTFN(0, "Endpoint profile %u " + "has too small buffer!\n", ep_no); + return (1); + } + } + } else if (is_complete) { /* check if we have enough buffer space */ if (wMaxPacketSize > ==== //depot/projects/usb/src/sys/dev/usb2/template/usb2_template.h#5 (text+ko) ==== @@ -45,7 +45,12 @@ const void **ppRawDesc; const struct usb2_temp_packet_size *pPacketSize; const struct usb2_temp_interval *pIntervals; - uint8_t direction; /* UE_DIR_IN or UE_DIR_OUT */ + /* + * If (bEndpointAddress & UE_ADDR) is non-zero the endpoint number + * is pre-selected for this endpoint descriptor. Else an endpoint + * number is automatically chosen. + */ + uint8_t bEndpointAddress; /* UE_DIR_IN or UE_DIR_OUT */ uint8_t bmAttributes; }; ==== //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_cdce.c#7 (text+ko) ==== @@ -184,19 +184,27 @@ static const struct usb2_temp_endpoint_desc bulk_in_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_IN, +#ifdef USB_HIP_IN_EP_0 + .bEndpointAddress = USB_HIP_IN_EP_0, +#else + .bEndpointAddress = UE_DIR_IN, +#endif .bmAttributes = UE_BULK, }; static const struct usb2_temp_endpoint_desc bulk_out_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_OUT, +#ifdef USB_HIP_OUT_EP_0 + .bEndpointAddress = USB_HIP_OUT_EP_0, +#else + .bEndpointAddress = UE_DIR_OUT, +#endif .bmAttributes = UE_BULK, }; static const struct usb2_temp_endpoint_desc intr_in_ep = { .pPacketSize = &intr_mps, - .direction = UE_DIR_IN, + .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; ==== //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_msc.c#6 (text+ko) ==== @@ -104,13 +104,21 @@ static const struct usb2_temp_endpoint_desc bulk_in_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_IN, +#ifdef USB_HIP_IN_EP_0 + .bEndpointAddress = USB_HIP_IN_EP_0, +#else + .bEndpointAddress = UE_DIR_IN, +#endif .bmAttributes = UE_BULK, }; static const struct usb2_temp_endpoint_desc bulk_out_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_OUT, +#ifdef USB_HIP_OUT_EP_0 + .bEndpointAddress = USB_HIP_OUT_EP_0, +#else + .bEndpointAddress = UE_DIR_OUT, +#endif .bmAttributes = UE_BULK, }; ==== //depot/projects/usb/src/sys/dev/usb2/template/usb2_template_mtp.c#6 (text+ko) ==== @@ -108,21 +108,34 @@ .mps[USB_SPEED_HIGH] = 512, }; +static const struct usb2_temp_packet_size intr_mps = { + .mps[USB_SPEED_FULL] = 64, + .mps[USB_SPEED_HIGH] = 64, +}; + static const struct usb2_temp_endpoint_desc bulk_out_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_OUT, +#ifdef USB_HIP_OUT_EP_0 + .bEndpointAddress = USB_HIP_OUT_EP_0, +#else + .bEndpointAddress = UE_DIR_OUT, +#endif .bmAttributes = UE_BULK, }; static const struct usb2_temp_endpoint_desc intr_in_ep = { - .pPacketSize = &bulk_mps, - .direction = UE_DIR_IN, + .pPacketSize = &intr_mps, + .bEndpointAddress = UE_DIR_IN, .bmAttributes = UE_INTERRUPT, }; static const struct usb2_temp_endpoint_desc bulk_in_ep = { .pPacketSize = &bulk_mps, - .direction = UE_DIR_IN, +#ifdef USB_HIP_IN_EP_0 + .bEndpointAddress = USB_HIP_IN_EP_0, +#else + .bEndpointAddress = UE_DIR_IN, +#endif .bmAttributes = UE_BULK, };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809110758.m8B7w3Q4047793>