call usbh_xxx_stop when class enumerates completely
This commit is contained in:
@@ -222,7 +222,7 @@ int usbh_audio_set_mute(struct usbh_audio *audio_class, const char *name, uint8_
|
|||||||
|
|
||||||
memcpy(g_audio_buf, &mute, 1);
|
memcpy(g_audio_buf, &mute, 1);
|
||||||
ret = usbh_control_transfer(audio_class->hport->ep0, setup, g_audio_buf);
|
ret = usbh_control_transfer(audio_class->hport->ep0, setup, g_audio_buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,12 +422,13 @@ static int usbh_audio_ctrl_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(audio_class->isoout);
|
usbh_pipe_free(audio_class->isoout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_audio_stop(audio_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister Audio Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_audio_stop(audio_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(audio_class, 0, sizeof(struct usbh_audio));
|
memset(audio_class, 0, sizeof(struct usbh_audio));
|
||||||
usb_free(audio_class);
|
usb_free(audio_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister Audio Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -124,13 +124,7 @@ static int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
|
|
||||||
#ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY
|
#ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY
|
||||||
ep_desc = &hport->config.intf[intf].altsetting[0].ep[0].ep_desc;
|
ep_desc = &hport->config.intf[intf].altsetting[0].ep[0].ep_desc;
|
||||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
usbh_hport_activate_epx(&cdc_acm_class->intin, hport, ep_desc);
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize;
|
|
||||||
ep_cfg.ep_interval = ep_desc->bInterval;
|
|
||||||
ep_cfg.hport = hport;
|
|
||||||
usbh_pipe_alloc(&cdc_acm_class->intin, &ep_cfg);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i = 0; i < hport->config.intf[intf + 1].altsetting[0].intf_desc.bNumEndpoints; i++) {
|
for (uint8_t i = 0; i < hport->config.intf[intf + 1].altsetting[0].intf_desc.bNumEndpoints; i++) {
|
||||||
ep_desc = &hport->config.intf[intf + 1].altsetting[0].ep[i].ep_desc;
|
ep_desc = &hport->config.intf[intf + 1].altsetting[0].ep[i].ep_desc;
|
||||||
@@ -167,12 +161,13 @@ static int usbh_cdc_acm_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(cdc_acm_class->bulkout);
|
usbh_pipe_free(cdc_acm_class->bulkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_cdc_acm_stop(cdc_acm_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister CDC ACM Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_cdc_acm_stop(cdc_acm_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(cdc_acm_class, 0, sizeof(struct usbh_cdc_acm));
|
memset(cdc_acm_class, 0, sizeof(struct usbh_cdc_acm));
|
||||||
usb_free(cdc_acm_class);
|
usb_free(cdc_acm_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister CDC ACM Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -190,12 +185,10 @@ static int usbh_cdc_data_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
|
|
||||||
__WEAK void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class)
|
__WEAK void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__WEAK void usbh_cdc_acm_stop(struct usbh_cdc_acm *cdc_acm_class)
|
__WEAK void usbh_cdc_acm_stop(struct usbh_cdc_acm *cdc_acm_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct usbh_class_driver cdc_acm_class_driver = {
|
const struct usbh_class_driver cdc_acm_class_driver = {
|
||||||
|
|||||||
@@ -169,12 +169,13 @@ int usbh_hid_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(hid_class->intout);
|
usbh_pipe_free(hid_class->intout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_hid_stop(hid_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister HID Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_hid_stop(hid_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(hid_class, 0, sizeof(struct usbh_hid));
|
memset(hid_class, 0, sizeof(struct usbh_hid));
|
||||||
usb_free(hid_class);
|
usb_free(hid_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister HID Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -182,12 +183,10 @@ int usbh_hid_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
|
|
||||||
__WEAK void usbh_hid_run(struct usbh_hid *hid_class)
|
__WEAK void usbh_hid_run(struct usbh_hid *hid_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__WEAK void usbh_hid_stop(struct usbh_hid *hid_class)
|
__WEAK void usbh_hid_stop(struct usbh_hid *hid_class)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct usbh_class_driver hid_class_driver = {
|
const struct usbh_class_driver hid_class_driver = {
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ static void usbh_msc_cbw_dump(struct CBW *cbw)
|
|||||||
USB_LOG_DBG("CB:\r\n");
|
USB_LOG_DBG("CB:\r\n");
|
||||||
for (i = 0; i < cbw->bCBLength; i += 8) {
|
for (i = 0; i < cbw->bCBLength; i += 8) {
|
||||||
USB_LOG_DBG(" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n",
|
USB_LOG_DBG(" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n",
|
||||||
cbw->CB[i], cbw->CB[i + 1], cbw->CB[i + 2],
|
cbw->CB[i], cbw->CB[i + 1], cbw->CB[i + 2],
|
||||||
cbw->CB[i + 3], cbw->CB[i + 4], cbw->CB[i + 5],
|
cbw->CB[i + 3], cbw->CB[i + 4], cbw->CB[i + 5],
|
||||||
cbw->CB[i + 6], cbw->CB[i + 7]);
|
cbw->CB[i + 6], cbw->CB[i + 7]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,12 +359,13 @@ static int usbh_msc_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(msc_class->bulkout);
|
usbh_pipe_free(msc_class->bulkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_msc_stop(msc_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister MSC Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_msc_stop(msc_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(msc_class, 0, sizeof(struct usbh_msc));
|
memset(msc_class, 0, sizeof(struct usbh_msc));
|
||||||
usb_free(msc_class);
|
usb_free(msc_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister MSC Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -21,37 +21,22 @@ static int usbh_mtp_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(mtp_class, 0, sizeof(struct usbh_mtp));
|
memset(mtp_class, 0, sizeof(struct usbh_mtp));
|
||||||
|
|
||||||
mtp_class->hport = hport;
|
mtp_class->hport = hport;
|
||||||
mtp_class->ctrl_intf = intf;
|
mtp_class->intf = intf;
|
||||||
mtp_class->data_intf = intf + 1;
|
|
||||||
|
|
||||||
hport->config.intf[intf].priv = mtp_class;
|
hport->config.intf[intf].priv = mtp_class;
|
||||||
hport->config.intf[intf + 1].priv = NULL;
|
|
||||||
strncpy(hport->config.intf[intf].devname, DEV_FORMAT, CONFIG_USBHOST_DEV_NAMELEN);
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST_MTP_NOTIFY
|
#ifdef CONFIG_USBHOST_MTP_NOTIFY
|
||||||
ep_desc = &hport->config.intf[intf].ep[0].ep_desc;
|
ep_desc = &hport->config.intf[intf].altsetting[0].ep[0].ep_desc;
|
||||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
usbh_hport_activate_epx(&mtp_class->intin, hport, ep_desc);
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize;
|
|
||||||
ep_cfg.ep_interval = ep_desc->bInterval;
|
|
||||||
ep_cfg.hport = hport;
|
|
||||||
usbh_pipe_alloc(&mtp_class->intin, &ep_cfg);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t i = 0; i < hport->config.intf[intf + 1].intf_desc.bNumEndpoints; i++) {
|
for (uint8_t i = 0; i < hport->config.intf[intf + 1].altsetting[0].intf_desc.bNumEndpoints; i++) {
|
||||||
ep_desc = &hport->config.intf[intf + 1].ep[i].ep_desc;
|
ep_desc = &hport->config.intf[intf + 1].altsetting[0].ep[i].ep_desc;
|
||||||
|
|
||||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;;
|
|
||||||
ep_cfg.ep_interval = ep_desc->bInterval;
|
|
||||||
ep_cfg.hport = hport;
|
|
||||||
if (ep_desc->bEndpointAddress & 0x80) {
|
if (ep_desc->bEndpointAddress & 0x80) {
|
||||||
usbh_pipe_alloc(&mtp_class->bulkin, &ep_cfg);
|
usbh_hport_activate_epx(&mtp_class->bulkin, hport, ep_desc);
|
||||||
} else {
|
} else {
|
||||||
usbh_pipe_alloc(&mtp_class->bulkout, &ep_cfg);
|
usbh_hport_activate_epx(&mtp_class->bulkout, hport, ep_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,14 +62,12 @@ static int usbh_mtp_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(mtp_class->bulkout);
|
usbh_pipe_free(mtp_class->bulkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_free(mtp_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister MTP Class:%s\r\n", hport->config.intf[intf].devname);
|
USB_LOG_INFO("Unregister MTP Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
}
|
||||||
|
|
||||||
memset(hport->config.intf[intf].devname, 0, CONFIG_USBHOST_DEV_NAMELEN);
|
memset(mtp_class, 0, sizeof(struct usbh_mtp));
|
||||||
hport->config.intf[intf].priv = NULL;
|
usb_free(mtp_class);
|
||||||
hport->config.intf[intf + 1].priv = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -69,18 +69,13 @@ static int usbh_printer_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
|
|
||||||
hport->config.intf[intf].priv = printer_class;
|
hport->config.intf[intf].priv = printer_class;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < hport->config.intf[intf + 1].intf_desc.bNumEndpoints; i++) {
|
for (uint8_t i = 0; i < hport->config.intf[intf + 1].altsetting[0].intf_desc.bNumEndpoints; i++) {
|
||||||
ep_desc = &hport->config.intf[intf + 1].ep[i].ep_desc;
|
ep_desc = &hport->config.intf[intf + 1].altsetting[0].ep[i].ep_desc;
|
||||||
|
|
||||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
|
||||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
|
||||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
|
||||||
ep_cfg.ep_interval = ep_desc->bInterval;
|
|
||||||
ep_cfg.hport = hport;
|
|
||||||
if (ep_desc->bEndpointAddress & 0x80) {
|
if (ep_desc->bEndpointAddress & 0x80) {
|
||||||
usbh_pipe_alloc(&printer_class->bulkin, &ep_cfg);
|
usbh_hport_activate_epx(&printer_class->bulkin, hport, ep_desc);
|
||||||
} else {
|
} else {
|
||||||
usbh_pipe_alloc(&printer_class->bulkout, &ep_cfg);
|
usbh_hport_activate_epx(&printer_class->bulkout, hport, ep_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +85,7 @@ static int usbh_printer_connect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
|
|
||||||
USB_LOG_INFO("Register Printer Class:%s\r\n", hport->config.intf[intf].devname);
|
USB_LOG_INFO("Register Printer Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbh_printer_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
static int usbh_printer_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
||||||
@@ -108,13 +103,12 @@ static int usbh_printer_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(printer_class->bulkout);
|
usbh_pipe_free(printer_class->bulkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_free(printer_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister Printer Class:%s\r\n", hport->config.intf[intf].devname);
|
USB_LOG_INFO("Unregister Printer Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
}
|
||||||
|
|
||||||
memset(hport->config.intf[intf].devname, 0, CONFIG_USBHOST_DEV_NAMELEN);
|
memset(printer_class, 0, sizeof(struct usbh_printer));
|
||||||
hport->config.intf[intf].priv = NULL;
|
usb_free(printer_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -411,12 +411,13 @@ static int usbh_video_ctrl_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(video_class->isoout);
|
usbh_pipe_free(video_class->isoout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_video_stop(video_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister Video Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_video_stop(video_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(video_class, 0, sizeof(struct usbh_video));
|
memset(video_class, 0, sizeof(struct usbh_video));
|
||||||
usb_free(video_class);
|
usb_free(video_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister Video Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -395,12 +395,13 @@ static int usbh_rndis_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
|||||||
usbh_pipe_free(rndis_class->bulkout);
|
usbh_pipe_free(rndis_class->bulkout);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbh_rndis_stop(rndis_class);
|
if (hport->config.intf[intf].devname[0] != '\0') {
|
||||||
|
USB_LOG_INFO("Unregister RNDIS Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
usbh_rndis_stop(rndis_class);
|
||||||
|
}
|
||||||
|
|
||||||
memset(rndis_class, 0, sizeof(struct usbh_rndis));
|
memset(rndis_class, 0, sizeof(struct usbh_rndis));
|
||||||
usb_free(rndis_class);
|
usb_free(rndis_class);
|
||||||
|
|
||||||
if (hport->config.intf[intf].devname[0] != '\0')
|
|
||||||
USB_LOG_INFO("Unregister RNDIS Class:%s\r\n", hport->config.intf[intf].devname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user