aboutsummaryrefslogtreecommitdiffstats
path: root/rules.mk
Commit message (Expand)AuthorAgeFilesLines
* imagebuilder: reuse rootfs preparation from rootfs.mkMatthias Schiffer2018-03-071-0/+1
* rules.mk: drop `include_mk` build ruleAlexandru Ardelean2018-01-261-4/+0
* build: remove use of STAGING_DIR_HOST/usr (fixes cmake build error on macOS)Felix Fietkau2018-01-171-2/+2
* rules.mk: export TMPDIRJo-Philipp Wich2017-12-121-0/+1
* rukes.mk: this patch broken grub2 buildsJohn Crispin2017-09-011-2/+0
* rules.mk: add missing CPP definitionBangLang Huang2017-08-231-0/+2
* rules.mk: make PKG_CONFIG_DEPENDS properly track string valuesMatthias Schiffer2017-02-271-1/+1
* build: Pass -iremap gcc option as a single argumentMichal Sojka2017-02-091-1/+1
* build: make <subdir>/install opt-in, use it for target/ onlyFelix Fietkau2017-02-091-1/+1
* build: remove libc version suffix from build/staging directoriesFelix Fietkau2017-02-071-2/+1
* build: Suffix build directory with _$(LIBC) for external toolchainsFlorian Fainelli2017-01-291-1/+2
* build: introduce STAGING_DIR_IMAGEJo-Philipp Wich2017-01-271-0/+1
* rules.mk: export STAGING_DIR_HOSTPKGMatthias Schiffer2017-01-191-1/+1
* build: introduce extra targets that contain only proper dependenciesFelix Fietkau2017-01-181-4/+5
* build: define common subdir targets in rules.mkFelix Fietkau2017-01-181-0/+9
* build: move STAGING_DIR_HOSTPKG and BUILD_DIR_HOST back to a common directory...Matthias Schiffer2017-01-181-5/+5
* build: use mkhash to replace various quirky md5sum/openssl callsFelix Fietkau2017-01-051-1/+1
* build: add defaults for PKG_SOURCE, PKG_SOURCE_SUBDIR, PKG_VERSIONFelix Fietkau2016-12-221-0/+2
* build: implement make check and make package/X/checkFelix Fietkau2016-12-171-0/+8
* rules.mk: add STAGING_DIR_HOSTPKG variableJo-Philipp Wich2016-11-011-0/+1
* build: add checksum targetJo-Philipp Wich2016-08-011-0/+7
* rules.mk: introduce new variable OUTPUT_DIRJo-Philipp Wich2016-04-061-1/+4
* build: disable the use of -iremap for UML (#21851)Felix Fietkau2016-02-131-1/+1
* rules.mk: add TARGET_INIT_PATH toplevel variablesJo-Philipp Wich2016-02-081-0/+2
* build: filter out -fno-plt for the kernel build, fixes #21712Felix Fietkau2016-01-281-2/+2
* build: use -iremap feature to replace __FILE__ absolute path names in package...Felix Fietkau2016-01-251-0/+4
* rules.mk: make the locked template available even if flock has not been built...Felix Fietkau2016-01-201-3/+7
* build: use a separate variable checking the subdir path (for host packages)Felix Fietkau2016-01-201-1/+2
* host-build.mk: change default installation prefix of package/* host builds to...Felix Fietkau2016-01-201-2/+2
* build: move host build directories of package/* to build_dir/target-*/host/Felix Fietkau2016-01-201-2/+5
* build: add pure make tolower/toupper funtions that do not require shell callsFelix Fietkau2016-01-031-0/+14
* gcc: remove version 4.6, it is no longer neededFelix Fietkau2015-11-101-1/+1
* build: add -Wno-error=unused-result to target cflagsFelix Fietkau2015-11-101-1/+1
* rules.mk: export STAGING_DIR_HOST to sub-makefiles and shellsFelix Fietkau2015-11-071-1/+1
* build: Allow kernel modules to set build ID debug symbolFelix Fietkau2015-10-301-1/+2
* rules.mk: remove GCC 4.4 and GCC 4.5 conditionalFelix Fietkau2015-08-251-2/+2
* toolchain: only use fortify-headers for muslSteven Barth2015-06-291-1/+5
* toolchain: add fortify-headers, enable FORTIFY_SOURCE by defaultSteven Barth2015-06-231-1/+1
* toolchain: switch to musl by default, except for mips64Felix Fietkau2015-06-151-1/+1
* build: add integration for managing opkg package feed keysFelix Fietkau2015-04-061-0/+2
* rules.mk: add newline definitionJohn Crispin2015-03-151-0/+5
* rules.mk: don't add staging_dir/host/bin/ path againJo-Philipp Wich2015-02-101-1/+1
* scripts: extend rstrip.sh to remove bad rpathsJo-Philipp Wich2015-02-101-0/+1
* rules.mk: use relative paths for BASH, TAR, FIND, PATCH, PYTHONJo-Philipp Wich2015-02-061-5/+5
* include: declare variables formerly set in tmp/.host.mkJo-Philipp Wich2015-02-051-0/+6
* build: do not assume that gcc-{ar,ranlib,nm} is usable with an external toolc...Felix Fietkau2015-01-101-1/+1
* build: use gcc-provided ar, nm and ranlib where appropriateFelix Fietkau2014-12-271-5/+13
* rules.mk: reduce shexport to one line to allow it to be put in a target contextFelix Fietkau2014-10-221-2/+1
* build: clean up and optimize ipkg control generator codeFelix Fietkau2014-10-221-0/+1
* build: add $(STAGING_DIR_HOST)/usr/{include, lib} to build search path.John Crispin2014-10-201-2/+2
ion with the use or performance of this software. */ #define __INCLUDE_FROM_USB_DRIVER #include "../../Core/USBMode.h" #if defined(USB_CAN_BE_HOST) #define __INCLUDE_FROM_HID_DRIVER #define __INCLUDE_FROM_HID_HOST_C #include "HIDClassHost.h" uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize, void* ConfigDescriptorData) { USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; USB_Descriptor_Interface_t* HIDInterface = NULL; USB_HID_Descriptor_HID_t* HIDDescriptor = NULL; memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State)); if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) return HID_ENUMERROR_InvalidConfigDescriptor; while (!(DataINEndpoint) || !(DataOUTEndpoint)) { if (!(HIDInterface) || USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { if (DataINEndpoint) break; do { if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) { return HID_ENUMERROR_NoCompatibleInterfaceFound; } HIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); } while (HIDInterfaceInfo->Config.HIDInterfaceProtocol && (HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol)); if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_Host_NextHIDDescriptor) != DESCRIPTOR_SEARCH_COMP_Found) { return HID_ENUMERROR_NoCompatibleInterfaceFound; } HIDDescriptor = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_HID_Descriptor_HID_t); DataINEndpoint = NULL; DataOUTEndpoint = NULL; continue; } USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) DataINEndpoint = EndpointData; else DataOUTEndpoint = EndpointData; } HIDInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); HIDInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; HIDInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataINPipe, 1))) return HID_ENUMERROR_PipeConfigurationFailed; if (DataOUTEndpoint) { HIDInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); HIDInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT; if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1))) return HID_ENUMERROR_PipeConfigurationFailed; } HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(HIDDescriptor->HIDReportLength); HIDInterfaceInfo->State.DeviceUsesOUTPipe = DataOUTEndpoint; HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol); HIDInterfaceInfo->State.LargestReportSize = 8; HIDInterfaceInfo->State.IsActive = true; return HID_ENUMERROR_NoError; } static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == DTYPE_Interface) { USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); if (Interface->Class == HID_CSCP_HIDClass) return DESCRIPTOR_SEARCH_Found; } return DESCRIPTOR_SEARCH_NotFound; } static uint8_t DCOMP_HID_Host_NextHIDDescriptor(void* const CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == HID_DTYPE_HID) return DESCRIPTOR_SEARCH_Found; else if (Header->Type == DTYPE_Interface) return DESCRIPTOR_SEARCH_Fail; else return DESCRIPTOR_SEARCH_NotFound; } static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) { USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == DTYPE_Endpoint) { USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); if (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))) return DESCRIPTOR_SEARCH_Found; } else if (Header->Type == DTYPE_Interface) { return DESCRIPTOR_SEARCH_Fail; } return DESCRIPTOR_SEARCH_NotFound; } #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const uint8_t ReportID, void* Buffer) { USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = HID_REQ_SetReport, .wValue = ((HID_REPORT_ITEM_In + 1) << 8) | ReportID, .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In), }; Pipe_SelectPipe(PIPE_CONTROLPIPE); return USB_Host_SendControlRequest(Buffer); } #endif uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, void* Buffer) { if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return PIPE_READYWAIT_DeviceDisconnected; uint8_t ErrorCode; Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); uint16_t ReportSize; uint8_t* BufferPos = Buffer; #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) if (!(HIDInterfaceInfo->State.UsingBootProtocol)) { uint8_t ReportID = 0; if (HIDInterfaceInfo->Config.HIDParserData->UsingReportIDs) { ReportID = Pipe_Read_8(); *(BufferPos++) = ReportID; } ReportSize = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In); } else #endif { ReportSize = Pipe_BytesInPipe(); } if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NULL)) != PIPE_RWSTREAM_NoError) return ErrorCode; Pipe_ClearIN(); Pipe_Freeze(); return PIPE_RWSTREAM_NoError; } uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) const uint8_t ReportID, #endif const uint8_t ReportType, void* Buffer, const uint16_t ReportSize) { #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return PIPE_RWSTREAM_NoError; if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == HID_REPORT_ITEM_Out)) { uint8_t ErrorCode; Pipe_SelectPipe(HIDInterfaceInfo->Config.DataOUTPipe.Address); Pipe_Unfreeze(); if (ReportID) Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NULL); if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NULL)) != PIPE_RWSTREAM_NoError) return ErrorCode; Pipe_ClearOUT(); Pipe_Freeze(); return PIPE_RWSTREAM_NoError; } else #endif { USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = HID_REQ_SetReport, #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) .wValue = ((ReportType + 1) << 8) | ReportID, #else .wValue = ((ReportType + 1) << 8), #endif .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = ReportSize, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); return USB_Host_SendControlRequest(Buffer); } } bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) return false; bool ReportReceived; Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipe.Address); Pipe_Unfreeze(); ReportReceived = Pipe_IsINReceived(); Pipe_Freeze(); return ReportReceived; } uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { uint8_t ErrorCode; if (!(HIDInterfaceInfo->State.SupportsBootProtocol)) return HID_ERROR_LOGICAL; USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = HID_REQ_SetProtocol, .wValue = 0, .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = 0, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) return ErrorCode; HIDInterfaceInfo->State.LargestReportSize = 8; HIDInterfaceInfo->State.UsingBootProtocol = true; return HOST_SENDCONTROL_Successful; } uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const uint16_t MS) { USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = HID_REQ_SetIdle, .wValue = ((MS << 6) & 0xFF00), .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = 0, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); return USB_Host_SendControlRequest(NULL); } #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) { uint8_t ErrorCode; uint8_t HIDReportData[HIDInterfaceInfo->State.HIDReportSize]; USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), .bRequest = REQ_GetDescriptor, .wValue = (HID_DTYPE_Report << 8), .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = HIDInterfaceInfo->State.HIDReportSize, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); if ((ErrorCode = USB_Host_SendControlRequest(HIDReportData)) != HOST_SENDCONTROL_Successful) return ErrorCode; if (HIDInterfaceInfo->State.UsingBootProtocol) { USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = HID_REQ_SetProtocol, .wValue = 1, .wIndex = HIDInterfaceInfo->State.InterfaceNumber, .wLength = 0, }; if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) return ErrorCode; HIDInterfaceInfo->State.UsingBootProtocol = false; } if (HIDInterfaceInfo->Config.HIDParserData == NULL) return HID_ERROR_LOGICAL; if ((ErrorCode = USB_ProcessHIDReport(HIDReportData, HIDInterfaceInfo->State.HIDReportSize, HIDInterfaceInfo->Config.HIDParserData)) != HID_PARSE_Successful) { return HID_ERROR_LOGICAL | ErrorCode; } uint16_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits; HIDInterfaceInfo->State.LargestReportSize = (LargestReportSizeBits >> 3) + ((LargestReportSizeBits & 0x07) != 0); return 0; } #endif #endif