Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add host OS detection quirk. #2628

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

HiFiPhile
Copy link
Collaborator

Describe the PR
Due to the nature of quirk I'm not sure where to put...

This 1st OS detection quirk mainly resolve UAC class issue. Windows and OSX demand different feedback endpoint size for FS as Windows doesn't implement UAC spec correctly (Linux is compatible with both).
So there needs a way to adjust Configuration Descriptor on the fly.

@HiFiPhile
Copy link
Collaborator Author

@Marcus2060 @kf6gpe @rhysmorgan134

A quirk is come out which (hopefully) resolve UAC feedback format issue, test welcomed.

Now it's possible to use different Config descriptors:

uint8_t const desc_configuration_default[] =
{
    // Config number, interface count, string index, total length, attribute, power in mA
    TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 500),
    // Interface number, Alternate count, starting string index, attributes, detach timeout, transfer size
    TUD_DFU_DESCRIPTOR(ITF_NUM_DFU, 1, 4, DFU_ATTR_CAN_UPLOAD | DFU_ATTR_CAN_DOWNLOAD | DFU_ATTR_MANIFESTATION_TOLERANT, 100, CFG_TUD_DFU_XFER_BUFSIZE),
};

uint8_t const desc_configuration_osx[] =
{
    // Config number, interface count, string index, total length, attribute, power in mA
    TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL_OSX, 0, CONFIG_TOTAL_LEN_OSX, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 500),
     // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
    TUD_CDC_DESCRIPTOR(ITF_NUM_CDC_0, 4, EPNUM_CDC_0_NOTIF, 8, EPNUM_CDC_0_OUT, EPNUM_CDC_0_IN, 64),
};

// Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
{
    (void) index; // for multiple configurations

    return  (tud_quirk_host_os_hint() == TUD_QUIRK_OS_HINT_OSX) ? desc_configuration_osx: desc_configuration_default;
}

@rhysmorgan134
Copy link

I'll have a go at building into my current project, may take a while as I few bits I think I need to get my head around to get it in there working. Thanks for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants