From acb43e042d0b8e49ce0da2519dd34a4ecf8143f3 Mon Sep 17 00:00:00 2001 From: QiaoChong Date: Fri, 29 Nov 2019 14:35:08 +0800 Subject: [PATCH] usb every endpoint has a irq handle handler. Change-Id: I259c6799f9d6b8338d622f1d7fb862a247ce1762 Signed-off-by: QiaoChong --- sys/dev/usb/usb-ohci.c | 18 ++++++++++++------ sys/dev/usb/usb.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/usb-ohci.c b/sys/dev/usb/usb-ohci.c index 745e1307..cd05d01e 100644 --- a/sys/dev/usb/usb-ohci.c +++ b/sys/dev/usb/usb-ohci.c @@ -2026,6 +2026,7 @@ static td_t *dl_reverse_done_list(ohci_t * ohci) int process_interrupt_urb(ohci_t *ohci) { int i; + int ed_num; for (i = 0; i < MAX_INTS; i++) { struct usb_device *pInt_dev = NULL; urb_priv_t *pInt_urb_priv = NULL; @@ -2040,9 +2041,14 @@ int process_interrupt_urb(ohci_t *ohci) || pInt_ed == NULL) continue; - if (pInt_dev->irq_handle) { - pInt_dev->irq_status = 0; - pInt_dev->irq_act_len = pInt_urb_priv->actual_length; + ed_num = usb_pipeendpoint(pInt_urb_priv->pipe) |(usb_pipecontrol(pInt_urb_priv->pipe) ? 0: (usb_pipeout(pInt_urb_priv->pipe)<<4)); + pInt_dev->irq_status = 0; + pInt_dev->irq_act_len = pInt_urb_priv->actual_length; + if (pInt_dev->irq_handle_ep[ed_num]) { + pInt_dev->irq_handle_ep[ed_num](pInt_dev); + if (!pInt_dev->irq_handle_ep[ed_num]) + ret = 0; + } else if (pInt_dev->irq_handle) { pInt_dev->irq_handle(pInt_dev); if (!pInt_dev->irq_handle) ret = 0; @@ -2129,7 +2135,7 @@ static int dl_done_list(ohci_t * ohci, td_t * td_list) lurb_priv = &ohci_urb[dev_num][ed_num]; //QYL-2008-03-07 - if (p_ed->type == PIPE_INTERRUPT || (p_ed->usb_dev->irq_handle && usb_pipein(lurb_priv->pipe))) { + if (p_ed->type == PIPE_INTERRUPT || p_ed->usb_dev->irq_handle_ep[ed_num]) { pInt_ed = p_ed; pInt_urb_priv = lurb_priv; pInt_dev = p_ed->usb_dev; @@ -2232,7 +2238,7 @@ static int dl_td_done_list(ohci_t * ohci, td_t * td_list) lurb_priv = &ohci_urb[dev_num][ed_num]; //QYL-2008-03-07 - if (p_ed->type == PIPE_INTERRUPT || (p_ed->usb_dev->irq_handle && usb_pipein(lurb_priv->pipe))) { + if (p_ed->type == PIPE_INTERRUPT || p_ed->usb_dev->irq_handle_ep[ed_num]) { pInt_ed = p_ed; pInt_urb_priv = lurb_priv; pInt_dev = p_ed->usb_dev; @@ -2859,7 +2865,7 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer, } //QYL-2008-03-07 - if (!(usb_pipetype(pipe) == PIPE_INTERRUPT || (dev->irq_handle && usb_pipein(lurb_priv->pipe)))) { /*FIXME, might not done bulk */ + if (!(usb_pipetype(pipe) == PIPE_INTERRUPT || dev->irq_handle_ep[ed_num])) { /*FIXME, might not done bulk */ //dev->status = stat; if(!dev->status && !timeout) dev->act_len = transfer_len; diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index b8a8ea4f..e913aa48 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -175,6 +175,7 @@ struct usb_device { int have_langid; /* whether string_langid is valid yet */ int string_langid; /* language ID for strings */ int (*irq_handle)(struct usb_device *dev); + int (*irq_handle_ep[USB_MAXENDPOINTS*2])(struct usb_device *dev); unsigned long irq_status; int irq_act_len; /* transfered bytes */ void *privptr;