I know there are some modes for USB endpoint(Control, Bulk, Interrupt and isochronous) and they can be used for each purpose, but i don't know how can we change USB endpoint into these modes in a gadget? I have already read USB2.0 spec, then i can get the USB transfer descriptor by below setting:
ctrl.bRequestType = USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT;
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
ctrl.wIndex = 0;
ctrl.wLength = sizeof(buff);
ctrl.data = buff;
ctrl.wValue = (USB_DT_CONFIG << 8) | 0;
result = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
But i still don't know what should i do to change the USB transfer mode?
Endpoints are described in the device's descriptors.
It is not possible to change descriptors without (virtually) unplugging and re-enumerating the device.
To allow changing the endpoints of a single interface, you can use alternate settings.
To allow changing more properties of the device, you can use multiple configurations.
To implement this, you need to list all alternate settings/configurations in the descriptors, and to implement the set interface/configuration requests.