Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

dwc_otg_hcd_queue.c File Reference

This file contains the functions to manage Queue Heads and Queue Transfer Descriptors. More...

#include "dwc_otg_hcd.h"
#include "dwc_otg_regs.h"

Go to the source code of this file.

Defines

#define BitStuffTime(bytecount)   ((8 * 7* bytecount) / 6)
#define HS_HOST_DELAY   5
#define FS_LS_HOST_DELAY   1000
#define HUB_LS_SETUP   333
#define NS_TO_US(ns)   ((ns + 500) / 1000)
#define SCHEDULE_SLOP   10
 Initializes a QH structure.

Functions

void dwc_otg_hcd_qh_free (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Free each QTD in the QH's QTD-list then free the QH.
uint32_t calc_bus_time (int speed, int is_in, int is_isoc, int bytecount)
void qh_init (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh, dwc_otg_hcd_urb_t *urb)
dwc_otg_qh_tdwc_otg_hcd_qh_create (dwc_otg_hcd_t *hcd, dwc_otg_hcd_urb_t *urb, int atomic_alloc)
 This function allocates and initializes a QH.
int periodic_channel_available (dwc_otg_hcd_t *hcd)
 Checks that a channel is available for a periodic transfer.
int check_periodic_bandwidth (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Checks that there is sufficient bandwidth for the specified QH in the periodic schedule.
int check_max_xfer_size (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Checks that the max transfer size allowed in a host channel is large enough to handle the maximum data transfer in a single (micro)frame for a periodic transfer.
int schedule_periodic (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Schedules an interrupt or isochronous transfer in the periodic schedule.
int dwc_otg_hcd_qh_add (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 This function adds a QH to either the non periodic or periodic schedule if it is not already in the schedule.
void deschedule_periodic (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Removes an interrupt or isochronous transfer from the periodic schedule.
void dwc_otg_hcd_qh_remove (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh)
 Removes a QH from either the non-periodic or periodic schedule.
void dwc_otg_hcd_qh_deactivate (dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh, int sched_next_periodic_split)
 Deactivates a QH.
dwc_otg_qtd_tdwc_otg_hcd_qtd_create (dwc_otg_hcd_urb_t *urb, int atomic_alloc)
 This function allocates and initializes a QTD.
void dwc_otg_hcd_qtd_init (dwc_otg_qtd_t *qtd, dwc_otg_hcd_urb_t *urb)
 Initializes a QTD structure.
int dwc_otg_hcd_qtd_add (dwc_otg_qtd_t *qtd, dwc_otg_hcd_t *hcd, dwc_otg_qh_t **qh, int atomic_alloc)
 This function adds a QTD to the QTD-list of a QH.


Detailed Description

This file contains the functions to manage Queue Heads and Queue Transfer Descriptors.

Definition in file dwc_otg_hcd_queue.c.


Define Documentation

#define SCHEDULE_SLOP   10
 

Initializes a QH structure.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
qh The QH to init.
urb Holds the information about the device/endpoint that we need to initialize the QH.

Definition at line 154 of file dwc_otg_hcd_queue.c.


Function Documentation

void dwc_otg_hcd_qh_free dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
 

Free each QTD in the QH's QTD-list then free the QH.

QH should already be removed from a list. QTD list should already be empty if called from URB Dequeue.

Parameters:
hcd HCD instance.
qh The QH to free.

Definition at line 53 of file dwc_otg_hcd_queue.c.

void qh_init dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh,
dwc_otg_hcd_urb_t *  urb
 

Todo:
Account for split transfers in the bus time.

Definition at line 155 of file dwc_otg_hcd_queue.c.

dwc_otg_qh_t* dwc_otg_hcd_qh_create dwc_otg_hcd_t hcd,
dwc_otg_hcd_urb_t *  urb,
int  atomic_alloc
 

This function allocates and initializes a QH.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
urb Holds the information about the device/endpoint that we need to initialize the QH.
atomic_alloc Flag to do atomic allocation if needed
Returns:
Returns pointer to the newly allocated QH, or NULL on error.

Todo:
add memflags argument

Definition at line 290 of file dwc_otg_hcd_queue.c.

int periodic_channel_available dwc_otg_hcd_t hcd  )  [static]
 

Checks that a channel is available for a periodic transfer.

Returns:
0 if successful, negative error code otherise.

Definition at line 319 of file dwc_otg_hcd_queue.c.

int check_periodic_bandwidth dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
[static]
 

Checks that there is sufficient bandwidth for the specified QH in the periodic schedule.

For simplicity, this calculation assumes that all the transfers in the periodic schedule may occur in the same (micro)frame.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
qh QH containing periodic bandwidth required.
Returns:
0 if successful, negative error code otherwise.

Definition at line 352 of file dwc_otg_hcd_queue.c.

int check_max_xfer_size dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
[static]
 

Checks that the max transfer size allowed in a host channel is large enough to handle the maximum data transfer in a single (micro)frame for a periodic transfer.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
qh QH for a periodic endpoint.
Returns:
0 if successful, negative error code otherwise.

Definition at line 392 of file dwc_otg_hcd_queue.c.

int schedule_periodic dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
[static]
 

Schedules an interrupt or isochronous transfer in the periodic schedule.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
qh QH for the periodic transfer. The QH should already contain the scheduling information.
Returns:
0 if successful, negative error code otherwise.

Definition at line 421 of file dwc_otg_hcd_queue.c.

int dwc_otg_hcd_qh_add dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
 

This function adds a QH to either the non periodic or periodic schedule if it is not already in the schedule.

If the QH is already in the schedule, no action is taken.

Returns:
0 if successful, negative error code otherwise.

Definition at line 468 of file dwc_otg_hcd_queue.c.

void deschedule_periodic dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
[static]
 

Removes an interrupt or isochronous transfer from the periodic schedule.

Parameters:
hcd The HCD state structure for the DWC OTG controller.
qh QH for the periodic transfer.

Definition at line 502 of file dwc_otg_hcd_queue.c.

void dwc_otg_hcd_qh_remove dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh
 

Removes a QH from either the non-periodic or periodic schedule.

Memory is not freed.

Parameters:
hcd The HCD state structure.
qh QH to remove from schedule.

Definition at line 519 of file dwc_otg_hcd_queue.c.

void dwc_otg_hcd_qh_deactivate dwc_otg_hcd_t hcd,
dwc_otg_qh_t qh,
int  sched_next_periodic_split
 

Deactivates a QH.

For non-periodic QHs, removes the QH from the active non-periodic schedule. The QH is added to the inactive non-periodic schedule if any QTDs are still attached to the QH.

For periodic QHs, the QH is removed from the periodic queued schedule. If there are any QTDs still attached to the QH, the QH is added to either the periodic inactive schedule or the periodic ready schedule and its next scheduled frame is calculated. The QH is placed in the ready schedule if the scheduled frame has been reached already. Otherwise it's placed in the inactive schedule. If there are no QTDs attached to the QH, the QH is completely removed from the periodic schedule.

Definition at line 558 of file dwc_otg_hcd_queue.c.

dwc_otg_qtd_t* dwc_otg_hcd_qtd_create dwc_otg_hcd_urb_t *  urb,
int  atomic_alloc
 

This function allocates and initializes a QTD.

Parameters:
urb The URB to create a QTD from. Each URB-QTD pair will end up pointing to each other so each pair should have a unique correlation.
atomic_alloc Flag to do atomic alloc if needed
Returns:
Returns pointer to the newly allocated QTD, or NULL on error.

Definition at line 638 of file dwc_otg_hcd_queue.c.

void dwc_otg_hcd_qtd_init dwc_otg_qtd_t qtd,
dwc_otg_hcd_urb_t *  urb
 

Initializes a QTD structure.

Parameters:
qtd The QTD to initialize.
urb The URB to use for initialization.

Definition at line 656 of file dwc_otg_hcd_queue.c.

int dwc_otg_hcd_qtd_add dwc_otg_qtd_t qtd,
dwc_otg_hcd_t hcd,
dwc_otg_qh_t **  qh,
int  atomic_alloc
 

This function adds a QTD to the QTD-list of a QH.

It will find the correct QH to place the QTD into. If it does not find a QH, then it will create a new QH. If the QH to which the QTD is added is not currently scheduled, it is placed into the proper schedule based on its EP type.

Parameters:
[in] qtd The QTD to add
[in] hcd The DWC HCD structure
[out] qh out parameter to return queue head
atomic_alloc Flag to do atomic alloc if needed
Returns:
0 if successful, negative error code otherwise.

Definition at line 694 of file dwc_otg_hcd_queue.c.


Generated on Thu Oct 27 03:56:38 2011 for DesignWare USB 2.0 OTG Controller (DWC_otg) Device Driver by  doxygen 1.3.9.1