@WMXZ and @Paul (and all) - Looking at the USB2 events stuff and trying to figure out how events should work... What I am wondering and need probably to reread some sections of documents. is how the Events stuff should work? with MTP. Some of the current configuration sort of confuses me.
Sorry if this message reflects my confusion.
For my own rambling, I think I need to talk about it in two parts:
a) How the Host sends EVENTS to the Teensy (MTP).
b) How the Teensy sends Events to the HOST.
And how and which endpoints are involved with these two cases. Again remember I know just enough to be dangerous.
But when I look in usb2_desc.c I see the MTP interface defined as:
Code:
#ifdef USB2_MTP_INTERFACE
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
9, // bLength
4, // bDescriptorType
USB2_MTP_INTERFACE, // bInterfaceNumber
0, // bAlternateSetting
3, // bNumEndpoints
0x06, // bInterfaceClass (0x06 = still image)
0x01, // bInterfaceSubClass
0x01, // bInterfaceProtocol
4, // iInterface
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
7, // bLength
5, // bDescriptorType
USB2_MTP_TX_ENDPOINT | 0x80, // bEndpointAddress
0x02, // bmAttributes (0x02=bulk)
LSB(USB2_MTP_TX_SIZE_480),MSB(USB2_MTP_TX_SIZE_480), // wMaxPacketSize
0, // bInterval
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
7, // bLength
5, // bDescriptorType
USB2_MTP_RX_ENDPOINT, // bEndpointAddress
0x02, // bmAttributes (0x02=bulk)
LSB(USB2_MTP_RX_SIZE_480),MSB(USB2_MTP_RX_SIZE_480), // wMaxPacketSize
0, // bInterval
// endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
7, // bLength
5, // bDescriptorType
USB2_MTP_EVENT_ENDPOINT | 0x80, // bEndpointAddress
0x03, // bmAttributes (0x03=intr)
USB2_MTP_EVENT_SIZE, 0, // wMaxPacketSize
USB2_MTP_EVENT_INTERVAL, // bInterval
#endif // MTP_INTERFACE
It has an Event endpoint defined, which I show in RED:
When I read this, I take it that as the 0x80 bit is set end point, that it is a TX end point, and likewise I believe that Interrupt end points are unidirectional. Again could be wrong, but I also get that impression from documents like: https://www.beyondlogic.org/usbnutshell/usb4.shtml
So I am not sure if the usb2_mtp_configure that tries to setup that end point for two different types of transfers:
Code:
usb2_config_rx(MTP_EVENT_ENDPOINT, MTP_EVENT_SIZE, 0, rx_event_event);
usb2_config_tx(MTP_EVENT_ENDPOINT, MTP_EVENT_SIZE, 0, tx_event_event);
Again I could be completely wrong here. But assuming that this is a TX end point, not sure if the RX has a different end point? Or does it receive data over the control end point?
May be interesting to look at another device that does MTP... And see how it is defined...
Now back to experimenting.
EDIT: I plugged in an older Kindle Fire I have into an RPI4, and looked at how it was configured.
Code:
ubuntu@ubuntu:~$ lsusb -v -d 1949:000c
Bus 001 Device 005: ID 1949:000c Lab126, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1949 Lab126, Inc.
idProduct 0x000c
bcdDevice 2.32
iManufacturer 1 Android
iProduct 2 Android
iSerial 3 D0FCA0A0342600M6
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0027
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 0
iInterface 4 MTP
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x001c 1x 28 bytes
bInterval 6
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0016
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
HIRD Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000f
Device can operate at Low Speed (1Mbps)
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 1 micro seconds
bU2DevExitLat 500 micro seconds
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0001
Self Powered
And it shows the third Endpoint as IN as well.
EDIT2: I tried same with an IPAD, but it does not show it supports MTP, it does support PTP