2012-01-24 17:51:26 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/usbdev/composite.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdint.h>
|
2012-01-25 15:27:20 -04:00
|
|
|
#include <string.h>
|
2012-01-24 17:51:26 -04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
#include <nuttx/arch.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
#include <nuttx/usb/usb.h>
|
|
|
|
#include <nuttx/usb/usbdev.h>
|
2012-01-24 17:51:26 -04:00
|
|
|
#include <nuttx/usb/usbdev_trace.h>
|
|
|
|
|
|
|
|
#include "composite.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_USBDEV_COMPOSITE
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
/* This structure describes the internal state of the driver */
|
|
|
|
|
|
|
|
struct composite_dev_s
|
|
|
|
{
|
2012-01-26 13:42:44 -04:00
|
|
|
FAR struct usbdev_s *usbdev; /* usbdev driver pointer */
|
2012-01-25 15:27:20 -04:00
|
|
|
uint8_t config; /* Configuration number */
|
|
|
|
FAR struct usbdev_req_s *ctrlreq; /* Allocated control request */
|
|
|
|
struct usbdevclass_driver_s *dev1; /* Device 1 class object */
|
|
|
|
struct usbdevclass_driver_s *dev2; /* Device 2 class object */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The internal version of the class driver */
|
|
|
|
|
|
|
|
struct composite_driver_s
|
|
|
|
{
|
|
|
|
struct usbdevclass_driver_s drvr;
|
|
|
|
FAR struct composite_dev_s *dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is what is allocated */
|
|
|
|
|
|
|
|
struct composite_alloc_s
|
|
|
|
{
|
|
|
|
struct composite_dev_s dev;
|
|
|
|
struct composite_driver_s drvr;
|
|
|
|
};
|
|
|
|
|
2012-01-24 17:51:26 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
2012-01-25 15:27:20 -04:00
|
|
|
/* USB helps ****************************************************************/
|
|
|
|
|
|
|
|
static void composite_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
|
|
|
FAR struct usbdev_req_s *req);
|
|
|
|
static int composite_classsetup(FAR struct composite_dev_s *priv,
|
|
|
|
FAR struct usbdev_s *dev,
|
2012-04-12 13:30:48 -03:00
|
|
|
FAR const struct usb_ctrlreq_s *ctrl, FAR uint8_t *dataout,
|
|
|
|
size_t outlen);
|
2012-01-25 15:27:20 -04:00
|
|
|
static struct usbdev_req_s *composite_allocreq(FAR struct usbdev_ep_s *ep,
|
|
|
|
uint16_t len);
|
|
|
|
static void composite_freereq(FAR struct usbdev_ep_s *ep,
|
|
|
|
FAR struct usbdev_req_s *req);
|
|
|
|
|
|
|
|
/* USB class device ********************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static int composite_bind(FAR struct usbdevclass_driver_s *driver,
|
2012-01-26 19:14:27 -04:00
|
|
|
FAR struct usbdev_s *dev);
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev);
|
|
|
|
static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev,
|
2012-04-12 13:30:48 -03:00
|
|
|
FAR const struct usb_ctrlreq_s *ctrl, FAR uint8_t *dataout,
|
|
|
|
size_t outlen);
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev);
|
|
|
|
static void composite_suspend(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev);
|
|
|
|
static void composite_resume(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev);
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
2012-01-25 15:27:20 -04:00
|
|
|
/* USB class device *********************************************************/
|
|
|
|
|
|
|
|
static const struct usbdevclass_driverops_s g_driverops =
|
|
|
|
{
|
|
|
|
composite_bind, /* bind */
|
|
|
|
composite_unbind, /* unbind */
|
|
|
|
composite_setup, /* setup */
|
|
|
|
composite_disconnect, /* disconnect */
|
|
|
|
composite_suspend, /* suspend */
|
|
|
|
composite_resume, /* resume */
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
const char g_compvendorstr[] = CONFIG_COMPOSITE_VENDORSTR;
|
|
|
|
const char g_compproductstr[] = CONFIG_COMPOSITE_PRODUCTSTR;
|
|
|
|
const char g_compserialstr[] = CONFIG_COMPOSITE_SERIALSTR;
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
2012-01-25 15:27:20 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* Helpers
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_ep0incomplete
|
|
|
|
*
|
|
|
|
* Description:
|
2012-01-26 13:42:44 -04:00
|
|
|
* Handle completion of the composite driver's EP0 control operations
|
2012-01-25 15:27:20 -04:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void composite_ep0incomplete(FAR struct usbdev_ep_s *ep,
|
|
|
|
FAR struct usbdev_req_s *req)
|
|
|
|
{
|
2012-01-26 13:42:44 -04:00
|
|
|
/* Just check the result of the transfer */
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
if (req->result || req->xfrd != req->len)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_REQRESULT), (uint16_t)-req->result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_classsetup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Forward a setup command to the appropriate component device
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int composite_classsetup(FAR struct composite_dev_s *priv,
|
|
|
|
FAR struct usbdev_s *dev,
|
2012-04-12 13:30:48 -03:00
|
|
|
FAR const struct usb_ctrlreq_s *ctrl,
|
|
|
|
FAR uint8_t *dataout, size_t outlen)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
uint16_t index;
|
|
|
|
uint8_t interface;
|
|
|
|
int ret = -EOPNOTSUPP;
|
|
|
|
|
|
|
|
index = GETUINT16(ctrl->index);
|
|
|
|
interface = (uint8_t)(index & 0xff);
|
|
|
|
|
2012-01-27 14:33:41 -04:00
|
|
|
if (interface >= DEV1_FIRSTINTERFACE && interface < (DEV1_FIRSTINTERFACE + DEV1_NINTERFACES))
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
2012-04-12 13:30:48 -03:00
|
|
|
ret = CLASS_SETUP(priv->dev1, dev, ctrl, dataout, outlen);
|
2012-01-25 15:27:20 -04:00
|
|
|
}
|
2012-01-27 14:33:41 -04:00
|
|
|
else if (interface >= DEV2_FIRSTINTERFACE && interface < (DEV2_FIRSTINTERFACE + DEV2_NINTERFACES))
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
2012-04-12 13:30:48 -03:00
|
|
|
ret = CLASS_SETUP(priv->dev2, dev, ctrl, dataout, outlen);
|
2012-01-25 15:27:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_allocreq
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a request instance along with its buffer
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static struct usbdev_req_s *composite_allocreq(FAR struct usbdev_ep_s *ep,
|
|
|
|
uint16_t len)
|
|
|
|
{
|
|
|
|
FAR struct usbdev_req_s *req;
|
|
|
|
|
|
|
|
req = EP_ALLOCREQ(ep);
|
|
|
|
if (req != NULL)
|
|
|
|
{
|
|
|
|
req->len = len;
|
|
|
|
req->buf = EP_ALLOCBUFFER(ep, len);
|
|
|
|
if (!req->buf)
|
|
|
|
{
|
|
|
|
EP_FREEREQ(ep, req);
|
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_freereq
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Free a request instance along with its buffer
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void composite_freereq(FAR struct usbdev_ep_s *ep,
|
|
|
|
FAR struct usbdev_req_s *req)
|
|
|
|
{
|
|
|
|
if (ep != NULL && req != NULL)
|
|
|
|
{
|
|
|
|
if (req->buf != NULL)
|
|
|
|
{
|
|
|
|
EP_FREEBUFFER(ep, req->buf);
|
|
|
|
}
|
|
|
|
EP_FREEREQ(ep, req);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* USB Class Driver Methods
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_bind
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked when the driver is bound to a USB device driver
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static int composite_bind(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
2012-01-26 13:42:44 -04:00
|
|
|
FAR struct composite_dev_s *priv = ((FAR struct composite_driver_s*)driver)->dev;
|
2012-01-25 15:27:20 -04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
usbtrace(TRACE_CLASSBIND, 0);
|
|
|
|
|
|
|
|
/* Bind the structures */
|
|
|
|
|
|
|
|
priv->usbdev = dev;
|
2012-01-26 13:42:44 -04:00
|
|
|
|
|
|
|
/* Save the reference to our private data structure in EP0 so that it
|
|
|
|
* can be recovered in ep0 completion events.
|
|
|
|
*/
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
dev->ep0->priv = priv;
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
/* Preallocate one control request */
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
priv->ctrlreq = composite_allocreq(dev->ep0, COMPOSITE_CFGDESCSIZE);
|
|
|
|
if (priv->ctrlreq == NULL)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_ALLOCCTRLREQ), 0);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the pre-allocated control request */
|
|
|
|
|
|
|
|
priv->ctrlreq->callback = composite_ep0incomplete;
|
|
|
|
|
|
|
|
/* Then bind each of the constituent class drivers */
|
|
|
|
|
|
|
|
ret = CLASS_BIND(priv->dev1, dev);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = CLASS_BIND(priv->dev2, dev);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Report if we are selfpowered */
|
|
|
|
|
|
|
|
#ifdef CONFIG_USBDEV_SELFPOWERED
|
|
|
|
DEV_SETSELFPOWERED(dev);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* And pull-up the data line for the soft connect function */
|
|
|
|
|
|
|
|
DEV_CONNECT(dev);
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
errout:
|
2012-01-26 19:14:27 -04:00
|
|
|
composite_unbind(driver, dev);
|
2012-01-25 15:27:20 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_unbind
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked when the driver is unbound from a USB device driver
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_dev_s *priv;
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
usbtrace(TRACE_CLASSUNBIND, 0);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-26 13:42:44 -04:00
|
|
|
if (!driver || !dev || !dev->ep0)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_INVALIDARG), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Extract reference to private data */
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
priv = ((FAR struct composite_driver_s*)driver)->dev;
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
if (!priv)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EP0NOTBOUND), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Make sure that we are not already unbound */
|
|
|
|
|
|
|
|
if (priv != NULL)
|
|
|
|
{
|
|
|
|
/* Unbind the constituent class drivers */
|
|
|
|
|
|
|
|
flags = irqsave();
|
|
|
|
CLASS_UNBIND(priv->dev1, dev);
|
|
|
|
CLASS_UNBIND(priv->dev2, dev);
|
|
|
|
|
|
|
|
/* Free the pre-allocated control request */
|
|
|
|
|
|
|
|
priv->config = COMPOSITE_CONFIGIDNONE;
|
|
|
|
if (priv->ctrlreq != NULL)
|
|
|
|
{
|
|
|
|
composite_freereq(dev->ep0, priv->ctrlreq);
|
|
|
|
priv->ctrlreq = NULL;
|
|
|
|
}
|
|
|
|
irqrestore(flags);
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_setup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked for ep0 control requests. This function probably executes
|
|
|
|
* in the context of an interrupt handler.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev,
|
2012-04-12 13:30:48 -03:00
|
|
|
FAR const struct usb_ctrlreq_s *ctrl,
|
|
|
|
FAR uint8_t *dataout, size_t outlen)
|
2012-01-24 17:51:26 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_dev_s *priv;
|
|
|
|
FAR struct usbdev_req_s *ctrlreq;
|
|
|
|
uint16_t value;
|
|
|
|
uint16_t index;
|
|
|
|
uint16_t len;
|
2012-01-25 15:27:20 -04:00
|
|
|
bool dispatched = false;
|
2012-01-24 17:51:26 -04:00
|
|
|
int ret = -EOPNOTSUPP;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-26 13:42:44 -04:00
|
|
|
if (!driver || !dev || !dev->ep0 || !ctrl)
|
2012-01-24 17:51:26 -04:00
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
usbtrace(TRACE_CLSERROR(COMPOSITE_TRACEERR_SETUPINVALIDARGS), 0);
|
2012-01-24 17:51:26 -04:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
/* Extract a reference to private data */
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
usbtrace(TRACE_CLASSSETUP, ctrl->req);
|
2012-01-26 13:42:44 -04:00
|
|
|
priv = ((FAR struct composite_driver_s*)driver)->dev;
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-25 15:27:20 -04:00
|
|
|
if (!priv)
|
2012-01-24 17:51:26 -04:00
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
usbtrace(TRACE_CLSERROR(COMPOSITE_TRACEERR_EP0NOTBOUND2), 0);
|
2012-01-24 17:51:26 -04:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-25 15:27:20 -04:00
|
|
|
ctrlreq = priv->ctrlreq;
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
/* Extract the little-endian 16-bit values to host order */
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
value = GETUINT16(ctrl->value);
|
|
|
|
index = GETUINT16(ctrl->index);
|
|
|
|
len = GETUINT16(ctrl->len);
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
uvdbg("type=%02x req=%02x value=%04x index=%04x len=%04x\n",
|
|
|
|
ctrl->type, ctrl->req, value, index, len);
|
|
|
|
|
|
|
|
if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
|
|
|
|
{
|
|
|
|
/**********************************************************************
|
|
|
|
* Standard Requests
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
switch (ctrl->req)
|
|
|
|
{
|
|
|
|
case USB_REQ_GETDESCRIPTOR:
|
|
|
|
{
|
|
|
|
/* The value field specifies the descriptor type in the MS byte and the
|
|
|
|
* descriptor index in the LS byte (order is little endian)
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (ctrl->value[1])
|
|
|
|
{
|
|
|
|
case USB_DESC_TYPE_DEVICE:
|
|
|
|
{
|
|
|
|
ret = USB_SIZEOF_DEVDESC;
|
|
|
|
memcpy(ctrlreq->buf, composite_getdevdesc(), ret);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
|
|
|
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
|
|
|
{
|
|
|
|
ret = USB_SIZEOF_QUALDESC;
|
|
|
|
memcpy(ctrlreq->buf, composite_getqualdesc(), ret);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
2012-01-25 15:27:20 -04:00
|
|
|
#endif
|
2012-01-24 17:51:26 -04:00
|
|
|
|
|
|
|
case USB_DESC_TYPE_CONFIG:
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
2012-01-27 17:03:20 -04:00
|
|
|
ret = composite_mkcfgdesc(ctrlreq->buf, dev->speed,
|
|
|
|
ctrl->value[1]);
|
2012-01-24 17:51:26 -04:00
|
|
|
#else
|
|
|
|
ret = composite_mkcfgdesc(ctrlreq->buf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_DESC_TYPE_STRING:
|
|
|
|
{
|
2012-01-27 17:03:20 -04:00
|
|
|
/* value == string index. Zero is the language ID. */
|
|
|
|
|
|
|
|
uint8_t strid = ctrl->value[0];
|
|
|
|
FAR struct usb_strdesc_s *buf = (FAR struct usb_strdesc_s *)ctrlreq->buf;
|
|
|
|
|
|
|
|
if (strid <= COMPOSITE_NSTRIDS)
|
|
|
|
{
|
|
|
|
ret = composite_mkstrdesc(strid, buf);
|
|
|
|
}
|
2012-01-29 10:15:20 -04:00
|
|
|
#if DEV1_NSTRIDS > 0
|
|
|
|
else if (strid <= DEV1_STRIDBASE + DEV1_NSTRIDS)
|
2012-01-27 17:03:20 -04:00
|
|
|
{
|
|
|
|
ret = DEV1_MKSTRDESC(strid, buf);
|
|
|
|
}
|
2012-01-29 10:15:20 -04:00
|
|
|
#endif
|
|
|
|
#if DEV2_NSTRIDS > 0
|
|
|
|
else if (strid <= DEV2_STRIDBASE + DEV2_NSTRIDS)
|
2012-01-27 17:03:20 -04:00
|
|
|
{
|
|
|
|
ret = DEV2_MKSTRDESC(strid, buf);
|
|
|
|
}
|
2012-01-29 10:15:20 -04:00
|
|
|
#endif
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
usbtrace(TRACE_CLSERROR(COMPOSITE_TRACEERR_GETUNKNOWNDESC), value);
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_REQ_SETCONFIGURATION:
|
|
|
|
{
|
|
|
|
if (ctrl->type == 0)
|
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
/* Save the configuration and inform the constituent classes */
|
2012-01-24 17:51:26 -04:00
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
ret = CLASS_SETUP(priv->dev1, dev, ctrl);
|
|
|
|
dispatched = true;
|
2012-01-24 17:51:26 -04:00
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
if (ret >= 0)
|
|
|
|
{
|
2012-01-27 14:33:41 -04:00
|
|
|
ret = CLASS_SETUP(priv->dev2, dev, ctrl);
|
2012-01-25 15:27:20 -04:00
|
|
|
if (ret >= 0)
|
|
|
|
{
|
|
|
|
priv->config = value;
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_REQ_GETCONFIGURATION:
|
|
|
|
{
|
|
|
|
if (ctrl->type == USB_DIR_IN)
|
|
|
|
{
|
|
|
|
ctrlreq->buf[0] = priv->config;
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_REQ_SETINTERFACE:
|
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
if (ctrl->type == USB_REQ_RECIPIENT_INTERFACE &&
|
|
|
|
priv->config == COMPOSITE_CONFIGID)
|
2012-01-24 17:51:26 -04:00
|
|
|
{
|
2012-04-12 13:30:48 -03:00
|
|
|
ret = composite_classsetup(priv, dev, ctrl, dataout, outlen);
|
2012-01-27 17:03:20 -04:00
|
|
|
dispatched = true;
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_REQ_GETINTERFACE:
|
|
|
|
{
|
|
|
|
if (ctrl->type == (USB_DIR_IN|USB_REQ_RECIPIENT_INTERFACE) &&
|
2012-01-25 15:27:20 -04:00
|
|
|
priv->config == COMPOSITE_CONFIGIDNONE)
|
2012-01-24 17:51:26 -04:00
|
|
|
{
|
2012-04-12 13:30:48 -03:00
|
|
|
ret = composite_classsetup(priv, dev, ctrl, dataout, outlen);
|
2012-01-27 17:03:20 -04:00
|
|
|
dispatched = true;
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-01-25 15:27:20 -04:00
|
|
|
usbtrace(TRACE_CLSERROR(COMPOSITE_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
2012-01-24 17:51:26 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-25 15:27:20 -04:00
|
|
|
uint8_t recipient;
|
|
|
|
|
2012-01-24 17:51:26 -04:00
|
|
|
/**********************************************************************
|
|
|
|
* Non-Standard Class Requests
|
|
|
|
**********************************************************************/
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
/* Class implementations should handle there own interface and endpoint
|
|
|
|
* requests.
|
|
|
|
*/
|
|
|
|
|
|
|
|
recipient = ctrl->type & USB_REQ_RECIPIENT_MASK;
|
|
|
|
if (recipient == USB_REQ_RECIPIENT_INTERFACE || recipient == USB_REQ_RECIPIENT_ENDPOINT)
|
|
|
|
{
|
2012-04-12 13:30:48 -03:00
|
|
|
ret = composite_classsetup(priv, dev, ctrl, dataout, outlen);
|
2012-01-27 17:03:20 -04:00
|
|
|
dispatched = true;
|
2012-01-25 15:27:20 -04:00
|
|
|
}
|
2012-01-24 17:51:26 -04:00
|
|
|
}
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
/* Respond to the setup command if (1) data was returned, and (2) the request was
|
|
|
|
* NOT successfully dispatched to the component class driver. On an error return
|
|
|
|
* value (ret < 0), the USB driver will stall EP0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ret >= 0 && !dispatched)
|
|
|
|
{
|
2012-01-26 13:42:44 -04:00
|
|
|
/* Setup the request */
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
ctrlreq->len = MIN(len, ret);
|
|
|
|
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
2012-01-26 13:42:44 -04:00
|
|
|
|
|
|
|
/* And submit the request to the USB controller driver */
|
|
|
|
|
|
|
|
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
2012-01-25 15:27:20 -04:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(COMPOSITE_TRACEERR_EPRESPQ), (uint16_t)-ret);
|
|
|
|
ctrlreq->result = OK;
|
|
|
|
composite_ep0incomplete(dev->ep0, ctrlreq);
|
|
|
|
}
|
|
|
|
}
|
2012-01-27 17:03:20 -04:00
|
|
|
|
2012-01-24 17:51:26 -04:00
|
|
|
return ret;
|
|
|
|
}
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_disconnect
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked after all transfers have been stopped, when the host is
|
|
|
|
* disconnected. This function is probably called from the context of an
|
|
|
|
* interrupt handler.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_disconnect(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_dev_s *priv;
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
usbtrace(TRACE_CLASSDISCONNECT, 0);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-26 13:42:44 -04:00
|
|
|
if (!driver || !dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_INVALIDARG), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Extract reference to private data */
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
priv = ((FAR struct composite_driver_s*)driver)->dev;
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
if (!priv)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EP0NOTBOUND), 0);
|
|
|
|
return;
|
|
|
|
}
|
2012-01-24 17:51:26 -04:00
|
|
|
#endif
|
|
|
|
|
2012-01-25 15:27:20 -04:00
|
|
|
/* Reset the configuration and inform the constituent class drivers of
|
|
|
|
* the disconnection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
flags = irqsave();
|
|
|
|
priv->config = COMPOSITE_CONFIGIDNONE;
|
|
|
|
CLASS_DISCONNECT(priv->dev1, dev);
|
|
|
|
CLASS_DISCONNECT(priv->dev2, dev);
|
|
|
|
irqrestore(flags);
|
|
|
|
|
|
|
|
/* Perform the soft connect function so that we will we can be
|
|
|
|
* re-enumerated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
DEV_CONNECT(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_suspend
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked on a USB suspend event.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_suspend(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_dev_s *priv;
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
usbtrace(TRACE_CLASSSUSPEND, 0);
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-26 13:42:44 -04:00
|
|
|
if (!dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_INVALIDARG), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Extract reference to private data */
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
priv = ((FAR struct composite_driver_s*)driver)->dev;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
if (!priv)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EP0NOTBOUND), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
/* Forward the suspend event to the constituent devices */
|
|
|
|
|
|
|
|
flags = irqsave();
|
|
|
|
CLASS_SUSPEND(priv->dev1, priv->usbdev);
|
|
|
|
CLASS_SUSPEND(priv->dev2, priv->usbdev);
|
|
|
|
irqrestore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_resume
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Invoked on a USB resume event.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
static void composite_resume(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_dev_s *priv = NULL;
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
2012-01-26 13:42:44 -04:00
|
|
|
if (!dev)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_INVALIDARG), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Extract reference to private data */
|
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
priv = ((FAR struct composite_driver_s*)driver)->dev;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG
|
|
|
|
if (!priv)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EP0NOTBOUND), 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
/* Forward the resume event to the constituent devices */
|
|
|
|
|
|
|
|
flags = irqsave();
|
|
|
|
CLASS_RESUME(priv->dev1, priv->usbdev);
|
|
|
|
CLASS_RESUME(priv->dev2, priv->usbdev);
|
|
|
|
irqrestore(flags);
|
|
|
|
}
|
|
|
|
|
2012-01-24 17:51:26 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
2012-01-25 15:27:20 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
2012-01-26 15:37:34 -04:00
|
|
|
* Register USB composite device as configured. This function will call
|
|
|
|
* board-specific implementations in order to obtain the class objects for
|
|
|
|
* each of the members of the composite (see board_mscclassobject(),
|
|
|
|
* board_cdcclassobjec(), ...)
|
2012-01-25 15:27:20 -04:00
|
|
|
*
|
|
|
|
* Input Parameter:
|
2012-01-26 15:37:34 -04:00
|
|
|
* None
|
2012-01-25 15:27:20 -04:00
|
|
|
*
|
|
|
|
* Returned Value:
|
2012-01-26 15:37:34 -04:00
|
|
|
* A non-NULL "handle" is returned on success. This handle may be used
|
|
|
|
* later with composite_uninitialize() in order to removed the composite
|
|
|
|
* device. This handle is the (untyped) internal representation of the
|
|
|
|
* the class driver instance.
|
|
|
|
*
|
|
|
|
* NULL is returned on any failure.
|
2012-01-25 15:27:20 -04:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-01-26 15:37:34 -04:00
|
|
|
FAR void *composite_initialize(void)
|
2012-01-25 15:27:20 -04:00
|
|
|
{
|
|
|
|
FAR struct composite_alloc_s *alloc;
|
|
|
|
FAR struct composite_dev_s *priv;
|
|
|
|
FAR struct composite_driver_s *drvr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Allocate the structures needed */
|
|
|
|
|
|
|
|
alloc = (FAR struct composite_alloc_s*)kmalloc(sizeof(struct composite_alloc_s));
|
|
|
|
if (!alloc)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_ALLOCDEVSTRUCT), 0);
|
2012-01-26 15:37:34 -04:00
|
|
|
return NULL;
|
2012-01-25 15:27:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convenience pointers into the allocated blob */
|
|
|
|
|
|
|
|
priv = &alloc->dev;
|
|
|
|
drvr = &alloc->drvr;
|
|
|
|
|
|
|
|
/* Initialize the USB composite driver structure */
|
|
|
|
|
|
|
|
memset(priv, 0, sizeof(struct composite_dev_s));
|
|
|
|
|
|
|
|
/* Get the constitueat class driver objects */
|
|
|
|
|
|
|
|
ret = DEV1_CLASSOBJECT(&priv->dev1);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_CLASSOBJECT), (uint16_t)-ret);
|
|
|
|
goto errout_with_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = DEV2_CLASSOBJECT(&priv->dev2);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_CLASSOBJECT), (uint16_t)-ret);
|
|
|
|
goto errout_with_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the USB class driver structure */
|
|
|
|
|
|
|
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
|
|
|
drvr->drvr.speed = USB_SPEED_HIGH;
|
|
|
|
#else
|
|
|
|
drvr->drvr.speed = USB_SPEED_FULL;
|
|
|
|
#endif
|
|
|
|
drvr->drvr.ops = &g_driverops;
|
|
|
|
drvr->dev = priv;
|
|
|
|
|
|
|
|
/* Register the USB composite class driver */
|
|
|
|
|
|
|
|
ret = usbdev_register(&drvr->drvr);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_DEVREGISTER), (uint16_t)-ret);
|
|
|
|
goto errout_with_alloc;
|
|
|
|
}
|
|
|
|
|
2012-01-26 19:14:27 -04:00
|
|
|
return (FAR void *)alloc;
|
2012-01-25 15:27:20 -04:00
|
|
|
|
|
|
|
errout_with_alloc:
|
|
|
|
kfree(alloc);
|
2012-01-26 15:37:34 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2012-01-26 19:14:27 -04:00
|
|
|
* Name: composite_uninitialize
|
2012-01-26 15:37:34 -04:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Un-initialize the USB composite driver. The handle is the USB composite
|
|
|
|
* class' device object as was returned by composite_initialize(). This
|
|
|
|
* function will call board-specific implementations in order to free the
|
|
|
|
* class objects for each of the members of the composite (see
|
|
|
|
* board_mscuninitialize(), board_cdcuninitialize(), ...)
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* handle - The handle returned by a previous call to composite_initialize().
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2012-01-26 19:14:27 -04:00
|
|
|
void composite_uninitialize(FAR void *handle)
|
2012-01-26 15:37:34 -04:00
|
|
|
{
|
2012-01-26 19:14:27 -04:00
|
|
|
FAR struct composite_alloc_s *alloc = (FAR struct composite_alloc_s *)handle;
|
|
|
|
FAR struct composite_dev_s *priv;
|
2012-01-26 15:37:34 -04:00
|
|
|
|
2012-01-26 19:14:27 -04:00
|
|
|
DEBUGASSERT(alloc != NULL);
|
2012-01-26 15:37:34 -04:00
|
|
|
|
|
|
|
/* Uninitialize each of the member classes */
|
|
|
|
|
2012-01-26 19:14:27 -04:00
|
|
|
priv = &alloc->dev;
|
2012-01-26 15:37:34 -04:00
|
|
|
if (priv->dev1)
|
|
|
|
{
|
|
|
|
DEV1_UNINITIALIZE(priv->dev1);
|
|
|
|
priv->dev1 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->dev2)
|
|
|
|
{
|
|
|
|
DEV1_UNINITIALIZE(priv->dev2);
|
|
|
|
priv->dev2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then unregister and destroy the composite class */
|
|
|
|
|
2012-01-26 19:14:27 -04:00
|
|
|
usbdev_unregister(&alloc->drvr.drvr);
|
2012-01-26 15:37:34 -04:00
|
|
|
|
|
|
|
/* Free any resources used by the composite driver */
|
2012-01-26 19:14:27 -04:00
|
|
|
/* None */
|
2012-01-26 15:37:34 -04:00
|
|
|
|
|
|
|
/* Then free the composite driver state structure itself */
|
|
|
|
|
|
|
|
kfree(priv);
|
2012-01-25 15:27:20 -04:00
|
|
|
}
|
2012-01-24 17:51:26 -04:00
|
|
|
|
2012-01-26 13:42:44 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: composite_ep0submit
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Members of the composite cannot send on EP0 directly because EP0 is
|
|
|
|
* is "owned" by the composite device. Instead, when configured as members
|
|
|
|
* of a composite device, those classes should call this method so that
|
|
|
|
* the composite device can send on EP0 onbehalf of the class.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int composite_ep0submit(FAR struct usbdevclass_driver_s *driver,
|
|
|
|
FAR struct usbdev_s *dev,
|
|
|
|
FAR struct usbdev_req_s *ctrlreq)
|
|
|
|
{
|
|
|
|
/* This function is not really necessary in the current design. However,
|
|
|
|
* keeping this will provide us a little flexibility in the future if
|
|
|
|
* it becomes necessary to manage the completion callbacks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return EP_SUBMIT(dev->ep0, ctrlreq);
|
|
|
|
}
|
|
|
|
|
2012-01-24 17:51:26 -04:00
|
|
|
#endif /* CONFIG_USBDEV_COMPOSITE */
|