19 #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
20 #define WRITES_IN_FLIGHT (4)
21 #define MAX_VENDOR_DESCRIPTOR_SIZE 256
23 #define GET_URB_TIMEOUT HZ
24 #define FREE_URB_TIMEOUT (HZ*2)
26 static int udl_parse_vendor_descriptor(
struct drm_device *
dev,
27 struct usb_device *usbdev)
44 DRM_INFO(
"vendor descriptor length:%x data:%*ph\n",
47 if ((desc[0] != total_len) ||
51 (desc[4] != total_len - 2))
57 while (desc < desc_end) {
70 DRM_DEBUG(
"DL chip limited to %d pixel modes\n",
86 DRM_ERROR(
"Unrecognized vendor firmware descriptor\n");
98 up(&unode->
dev->urbs.limit_sem);
103 struct urb_node *unode = urb->context;
109 if (!(urb->status == -
ENOENT ||
112 DRM_ERROR(
"%s - nonzero write bulk status received: %d\n",
113 __func__, urb->status);
118 urb->transfer_buffer_length = udl->
urbs.size;
122 udl->
urbs.available++;
123 spin_unlock_irqrestore(&udl->
urbs.lock, flags);
147 DRM_DEBUG(
"Waiting for completes and freeing all render urbs\n");
159 node = udl->
urbs.list.next;
162 spin_unlock_irqrestore(&udl->
urbs.lock, flags);
169 urb->transfer_buffer, urb->transfer_dma);
176 static int udl_alloc_urb_list(
struct drm_device *dev,
int count,
size_t size)
187 INIT_LIST_HEAD(&udl->
urbs.list);
196 udl_release_urb_work);
214 usb_fill_bulk_urb(urb, udl->
ddev->usbdev, usb_sndbulkpipe(udl->
ddev->usbdev, 1),
216 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
223 sema_init(&udl->
urbs.limit_sem, i);
225 udl->
urbs.available =
i;
227 DRM_DEBUG(
"allocated %d %d byte urbs\n", i, (
int) size);
238 struct urb *urb =
NULL;
245 DRM_INFO(
"wait for urb interrupted: %x available: %d\n",
246 ret, udl->
urbs.available);
253 entry = udl->
urbs.list.next;
254 list_del_init(entry);
255 udl->
urbs.available--;
257 spin_unlock_irqrestore(&udl->
urbs.lock, flags);
273 urb->transfer_buffer_length = len;
278 DRM_ERROR(
"usb_submit_urb error %x\n", ret);
294 dev->dev_private = udl;
296 if (!udl_parse_vendor_descriptor(dev, dev->usbdev)) {
297 DRM_ERROR(
"firmware not recognized. Assume incompatible device\n");
303 DRM_ERROR(
"udl_alloc_urb_list failed\n");
314 DRM_ERROR(
"%d\n", ret);
320 udl_free_urb_list(dev);
329 udl_free_urb_list(dev);