

struct iso_packet_desc_array {
  <`i::I>
  tag_t<`i> len;
  struct iso_packet_descriptor *{valueof(`i)} base;
};

typedef struct iso_packet_desc_array iso_arr_t;

extern "C include" {
  iso_arr_t build_iso_arr(struct urb *u) {
    iso_arr_t ret = {u->number_of_packets, &u->iso_frame_desc};
    return ret;
  }

  void update_urb(struct urb<`a> *urb,   
		  struct urb<`a> *next,		// pointer to next URB	
		  struct usb_device *dev,		// pointer to associated USB device
		  unsigned int pipe,		// pipe information
		  int status,			// returned status
		  unsigned int transfer_flags,	// USB_DISABLE_SPD | USB_ISO_ASAP | etc.
		  `b transfer_buffer,		// associated data buffer
		  dma_addr_t transfer_dma,	// dma addr for transfer_buffer
		  unsigned int transfer_buffer_length,	// data buffer length
		  int actual_length,              // actual data buffer length	
		  int bandwidth,			// bandwidth for this transfer request (INT or ISO)
		  unsigned char *setup_packet,	// setup packet (control only)
		  dma_addr_t setup_dma,		// dma addr for setup_packet
		  //
		  int start_frame,		// start frame (iso/irq only)
		  int number_of_packets,		// number of packets in this request (iso)
		  int interval,                   // polling interval (irq only)
		  int error_count,		// number of errors in this transfer (iso only)
		  int timeout,			// timeout (in jiffies)
		  `a *context,			// context for completion routine
		  void (*complete)(struct urb<`a> *)) {
    urb->next = next;
    urb->dev = dev;
    urb->pipe = pipe;	
    urb->status=status ;	
    urb->transfer_flags=transfer_flags;
    urb->transfer_buffer=transfer_buffer;	
    urb->transfer_dma=transfer_dma;
    urb->transfer_buffer_length=transfer_buffer_length;
    urb->actual_length=actual_length; 
    urb->bandwidth=bandwidth;	
    urb->setup_packet=setup_packet;
    urb->setup_dma=setup_dma;
    urb->start_frame=start_frame;		
    urb->number_of_packets=number_of_packets;	
    urb->interval=interval;              
    urb->error_count=error_count;		
    urb->timeout=timeout;		
    urb->context=context;
    urb->complete=complete;
  }
		  

}
export { * } 
