mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 10:28:54 +00:00
V1.0.5
This commit is contained in:
28
packages/third-party/cherryusb/Kconfig
vendored
28
packages/third-party/cherryusb/Kconfig
vendored
@@ -150,10 +150,38 @@ if LPKG_USING_CHERRYUSB
|
||||
config MSC_STORAGE_PATH
|
||||
string "MSC_STORAGE_PATH"
|
||||
default "/sdcard"
|
||||
config CONFIG_USBDEV_MSC_MAX_BUFSIZE
|
||||
int "USBDEV_MSC_MAX_BUFSIZE"
|
||||
default 204800
|
||||
endmenu
|
||||
endif
|
||||
|
||||
menuconfig LPKG_CHERRYUSB_DEVICE_MTP
|
||||
bool
|
||||
prompt "Enable usb mtp device"
|
||||
default n
|
||||
|
||||
if LPKG_CHERRYUSB_DEVICE_MTP
|
||||
config LPKG_CHERRYUSB_DEVICE_MTP_TEMPLATE
|
||||
bool
|
||||
prompt "Use mtp template"
|
||||
default y
|
||||
menu "MTP Parameter"
|
||||
depends on LPKG_CHERRYUSB_DEVICE_MTP_TEMPLATE
|
||||
if KERNEL_RTTHREAD
|
||||
config USBDEV_MTP_THREAD
|
||||
bool "USBDEV_MTP_THREAD"
|
||||
default n
|
||||
endif
|
||||
config ROOT_PATH
|
||||
string "ROOT_PATH"
|
||||
default "/sdcard"
|
||||
|
||||
config MTP_OBJECT_HANDLES_MAX_NUM
|
||||
int "MTP_OBJECT_HANDLES_MAX_NUM"
|
||||
default 512
|
||||
endmenu
|
||||
endif
|
||||
|
||||
menuconfig LPKG_CHERRYUSB_DEVICE_AUDIO
|
||||
bool
|
||||
|
||||
5
packages/third-party/cherryusb/SConscript
vendored
5
packages/third-party/cherryusb/SConscript
vendored
@@ -6,6 +6,7 @@ path = [cwd + '/common']
|
||||
path += [cwd + '/core']
|
||||
path += [cwd + '/class/cdc']
|
||||
path += [cwd + '/class/msc']
|
||||
path += [cwd + '/class/mtp']
|
||||
path += [cwd + '/class/hid']
|
||||
path += [cwd + '/class/audio']
|
||||
path += [cwd + '/class/video']
|
||||
@@ -36,6 +37,8 @@ if GetDepend(['LPKG_CHERRYUSB_DEVICE']) and GetDepend(['AIC_USB_DEVICE_DRV']):
|
||||
src += Glob('class/hid/usbd_hid.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_MSC']):
|
||||
src += Glob('class/msc/usbd_msc.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_MTP']):
|
||||
src += Glob('class/mtp/usbd_mtp.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_AUDIO']):
|
||||
src += Glob('class/audio/usbd_audio.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_VIDEO']):
|
||||
@@ -61,6 +64,8 @@ if GetDepend(['LPKG_CHERRYUSB_DEVICE']) and GetDepend(['AIC_USB_DEVICE_DRV']):
|
||||
src += Glob('demo/msc_ram_template.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_MSC_STORAGE_TEMPLATE']):
|
||||
src += Glob('demo/msc_storage_template.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_MTP_TEMPLATE']):
|
||||
src += Glob('demo/mtp_template.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_AUDIO_V1_TEMPLATE']):
|
||||
src += Glob('demo/audio_v1_mic_speaker_multichan_template.c')
|
||||
if GetDepend(['LPKG_CHERRYUSB_DEVICE_AUDIO_V2_TEMPLATE']):
|
||||
|
||||
485
packages/third-party/cherryusb/class/mtp/usb_mtp.h
vendored
Normal file
485
packages/third-party/cherryusb/class/mtp/usb_mtp.h
vendored
Normal file
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USB_MTP_H
|
||||
#define USB_MTP_H
|
||||
|
||||
#define USB_MTP_CLASS 0x06
|
||||
|
||||
#define USB_MTP_SUB_CLASS 0x01U
|
||||
#define USB_MTP_PROTOCOL 0x01U
|
||||
|
||||
/* MTP class requests */
|
||||
#define MTP_REQUEST_CANCEL 0x64U
|
||||
#define MTP_REQUEST_GET_EXT_EVENT_DATA 0x65U
|
||||
#define MTP_REQUEST_RESET 0x66U
|
||||
#define MTP_REQUEST_GET_DEVICE_STATUS 0x67U
|
||||
|
||||
/* Container Types */
|
||||
#define MTP_CONTAINER_TYPE_UNDEFINED 0U
|
||||
#define MTP_CONTAINER_TYPE_COMMAND 1U
|
||||
#define MTP_CONTAINER_TYPE_DATA 2U
|
||||
#define MTP_CONTAINER_TYPE_RESPONSE 3U
|
||||
#define MTP_CONTAINER_TYPE_EVENT 4U
|
||||
|
||||
/*
|
||||
* MTP Class specification Revision 1.1
|
||||
* Appendix D. Operations
|
||||
*/
|
||||
|
||||
/* Operations code */
|
||||
#define MTP_OP_GET_DEVICE_INFO 0x1001U
|
||||
#define MTP_OP_OPEN_SESSION 0x1002U
|
||||
#define MTP_OP_CLOSE_SESSION 0x1003U
|
||||
#define MTP_OP_GET_STORAGE_IDS 0x1004U
|
||||
#define MTP_OP_GET_STORAGE_INFO 0x1005U
|
||||
#define MTP_OP_GET_NUM_OBJECTS 0x1006U
|
||||
#define MTP_OP_GET_OBJECT_HANDLES 0x1007U
|
||||
#define MTP_OP_GET_OBJECT_INFO 0x1008U
|
||||
#define MTP_OP_GET_OBJECT 0x1009U
|
||||
#define MTP_OP_GET_THUMB 0x100AU
|
||||
#define MTP_OP_DELETE_OBJECT 0x100BU
|
||||
#define MTP_OP_SEND_OBJECT_INFO 0x100CU
|
||||
#define MTP_OP_SEND_OBJECT 0x100DU
|
||||
#define MTP_OP_FORMAT_STORE 0x100FU
|
||||
#define MTP_OP_RESET_DEVICE 0x1010U
|
||||
#define MTP_OP_GET_DEVICE_PROP_DESC 0x1014U
|
||||
#define MTP_OP_GET_DEVICE_PROP_VALUE 0x1015U
|
||||
#define MTP_OP_SET_DEVICE_PROP_VALUE 0x1016U
|
||||
#define MTP_OP_RESET_DEVICE_PROP_VALUE 0x1017U
|
||||
#define MTP_OP_TERMINATE_OPEN_CAPTURE 0x1018U
|
||||
#define MTP_OP_MOVE_OBJECT 0x1019U
|
||||
#define MTP_OP_COPY_OBJECT 0x101AU
|
||||
#define MTP_OP_GET_PARTIAL_OBJECT 0x101BU
|
||||
#define MTP_OP_INITIATE_OPEN_CAPTURE 0x101CU
|
||||
#define MTP_OP_GET_OBJECT_PROPS_SUPPORTED 0x9801U
|
||||
#define MTP_OP_GET_OBJECT_PROP_DESC 0x9802U
|
||||
#define MTP_OP_GET_OBJECT_PROP_VALUE 0x9803U
|
||||
#define MTP_OP_SET_OBJECT_PROP_VALUE 0x9804U
|
||||
#define MTP_OP_GET_OBJECT_PROPLIST 0x9805U
|
||||
#define MTP_OP_GET_OBJECT_PROP_REFERENCES 0x9810U
|
||||
#define MTP_OP_GETSERVICEIDS 0x9301U
|
||||
#define MTP_OP_GETSERVICEINFO 0x9302U
|
||||
#define MTP_OP_GETSERVICECAPABILITIES 0x9303U
|
||||
#define MTP_OP_GETSERVICEPROPDESC 0x9304U
|
||||
|
||||
/* MTP response code */
|
||||
#define MTP_RESPONSE_OK 0x2001U
|
||||
#define MTP_RESPONSE_GENERAL_ERROR 0x2002U
|
||||
#define MTP_RESPONSE_PARAMETER_NOT_SUPPORTED 0x2006U
|
||||
#define MTP_RESPONSE_INCOMPLETE_TRANSFER 0x2007U
|
||||
#define MTP_RESPONSE_INVALID_STORAGE_ID 0x2008U
|
||||
#define MTP_RESPONSE_INVALID_OBJECT_HANDLE 0x2009U
|
||||
#define MTP_RESPONSE_DEVICEPROP_NOT_SUPPORTED 0x200AU
|
||||
#define MTP_RESPONSE_INVALID_OBJECT_FORMAT_CODE 0x200BU
|
||||
#define MTP_RESPONSE_STORE_FULL 0x200CU
|
||||
#define MTP_RESPONSE_ACCESS_DENIED 0x200FU
|
||||
#define MTP_RESPONSE_STORE_NOT_AVAILABLE 0x2013U
|
||||
#define MTP_RESPONSE_SPECIFICATION_BY_FORMAT_NOT_SUPPORTED 0x2014U
|
||||
#define MTP_RESPONSE_NO_VALID_OBJECT_INFO 0x2015U
|
||||
#define MTP_RESPONSE_DEVICE_BUSY 0x2019U
|
||||
#define MTP_RESPONSE_INVALID_PARENT_OBJECT 0x201AU
|
||||
#define MTP_RESPONSE_INVALID_PARAMETER 0x201DU
|
||||
#define MTP_RESPONSE_SESSION_ALREADY_OPEN 0x201EU
|
||||
#define MTP_RESPONSE_TRANSACTION_CANCELLED 0x201FU
|
||||
#define MTP_RESPONSE_INVALID_OBJECT_PROP_CODE 0xA801U
|
||||
#define MTP_RESPONSE_SPECIFICATION_BY_GROUP_UNSUPPORTED 0xA807U
|
||||
#define MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED 0xA80AU
|
||||
|
||||
/* MTP Object format codes */
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED 0x3000U
|
||||
#define MTP_OBJ_FORMAT_ASSOCIATION 0x3001U
|
||||
#define MTP_OBJ_FORMAT_SCRIPT 0x3002U
|
||||
#define MTP_OBJ_FORMAT_EXECUTABLE 0x3003U
|
||||
#define MTP_OBJ_FORMAT_TEXT 0x3004U
|
||||
#define MTP_OBJ_FORMAT_HTML 0x3005U
|
||||
#define MTP_OBJ_FORMAT_DPOF 0x3006U
|
||||
#define MTP_OBJ_FORMAT_AIFF 0x3007U
|
||||
#define MTP_OBJ_FORMAT_WAV 0x3008U
|
||||
#define MTP_OBJ_FORMAT_MP3 0x3009U
|
||||
#define MTP_OBJ_FORMAT_AVI 0x300AU
|
||||
#define MTP_OBJ_FORMAT_MPEG 0x300BU
|
||||
#define MTP_OBJ_FORMAT_ASF 0x300CU
|
||||
#define MTP_OBJ_FORMAT_DEFINED 0x3800U
|
||||
#define MTP_OBJ_FORMAT_EXIF_JPEG 0x3801U
|
||||
#define MTP_OBJ_FORMAT_TIFF_EP 0x3802U
|
||||
#define MTP_OBJ_FORMAT_FLASHPIX 0x3803U
|
||||
#define MTP_OBJ_FORMAT_BMP 0x3804U
|
||||
#define MTP_OBJ_FORMAT_CIFF 0x3805U
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED_RESERVED0 0x3806U
|
||||
#define MTP_OBJ_FORMAT_GIF 0x3807U
|
||||
#define MTP_OBJ_FORMAT_JFIF 0x3808U
|
||||
#define MTP_OBJ_FORMAT_CD 0x3809U
|
||||
#define MTP_OBJ_FORMAT_PICT 0x380AU
|
||||
#define MTP_OBJ_FORMAT_PNG 0x380BU
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED_RESERVED1 0x380CU
|
||||
#define MTP_OBJ_FORMAT_TIFF 0x380DU
|
||||
#define MTP_OBJ_FORMAT_TIFF_IT 0x380EU
|
||||
#define MTP_OBJ_FORMAT_JP2 0x380FU
|
||||
#define MTP_OBJ_FORMAT_JPX 0x3810U
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED_FIRMWARE 0xB802U
|
||||
#define MTP_OBJ_FORMAT_WINDOWS_IMAGE_FORMAT 0xB881U
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED_AUDIO 0xB900U
|
||||
#define MTP_OBJ_FORMAT_WMA 0xB901U
|
||||
#define MTP_OBJ_FORMAT_OGG 0xB902U
|
||||
#define MTP_OBJ_FORMAT_AAC 0xB903U
|
||||
#define MTP_OBJ_FORMAT_AUDIBLE 0xB904U
|
||||
#define MTP_OBJ_FORMAT_FLAC 0xB906U
|
||||
#define MTP_OBJ_FORMAT_UNDEFINED_VIDEO 0xB980U
|
||||
#define MTP_OBJ_FORMAT_WMV 0xB981U
|
||||
#define MTP_OBJ_FORMAT_MP4_CONTAINER 0xB982U
|
||||
#define MTP_OBJ_FORMAT_MP2 0xB983U
|
||||
#define MTP_OBJ_FORMAT_3GP_CONTAINER 0xB984U
|
||||
|
||||
/* MTP event codes*/
|
||||
#define MTP_EVENT_UNDEFINED 0x4000U
|
||||
#define MTP_EVENT_CANCELTRANSACTION 0x4001U
|
||||
#define MTP_EVENT_OBJECTADDED 0x4002U
|
||||
#define MTP_EVENT_OBJECTREMOVED 0x4003U
|
||||
#define MTP_EVENT_STOREADDED 0x4004U
|
||||
#define MTP_EVENT_STOREREMOVED 0x4005U
|
||||
#define MTP_EVENT_DEVICEPROPCHANGED 0x4006U
|
||||
#define MTP_EVENT_OBJECTINFOCHANGED 0x4007U
|
||||
#define MTP_EVENT_DEVICEINFOCHANGED 0x4008U
|
||||
#define MTP_EVENT_REQUESTOBJECTTRANSFER 0x4009U
|
||||
#define MTP_EVENT_STOREFULL 0x400AU
|
||||
#define MTP_EVENT_DEVICERESET 0x400BU
|
||||
#define MTP_EVENT_STORAGEINFOCHANGED 0x400CU
|
||||
#define MTP_EVENT_CAPTURECOMPLETE 0x400DU
|
||||
#define MTP_EVENT_UNREPORTEDSTATUS 0x400EU
|
||||
#define MTP_EVENT_OBJECTPROPCHANGED 0xC801U
|
||||
#define MTP_EVENT_OBJECTPROPDESCCHANGED 0xC802U
|
||||
#define MTP_EVENT_OBJECTREFERENCESCHANGED 0xC803U
|
||||
|
||||
/* MTP device properties code*/
|
||||
#define MTP_DEV_PROP_UNDEFINED 0x5000U
|
||||
#define MTP_DEV_PROP_BATTERY_LEVEL 0x5001U
|
||||
#define MTP_DEV_PROP_FUNCTIONAL_MODE 0x5002U
|
||||
#define MTP_DEV_PROP_IMAGE_SIZE 0x5003U
|
||||
#define MTP_DEV_PROP_COMPRESSION_SETTING 0x5004U
|
||||
#define MTP_DEV_PROP_WHITE_BALANCE 0x5005U
|
||||
#define MTP_DEV_PROP_RGB_GAIN 0x5006U
|
||||
#define MTP_DEV_PROP_F_NUMBER 0x5007U
|
||||
#define MTP_DEV_PROP_FOCAL_LENGTH 0x5008U
|
||||
#define MTP_DEV_PROP_FOCUS_DISTANCE 0x5009U
|
||||
#define MTP_DEV_PROP_FOCUS_MODE 0x500AU
|
||||
#define MTP_DEV_PROP_EXPOSURE_METERING_MODE 0x500BU
|
||||
#define MTP_DEV_PROP_FLASH_MODE 0x500CU
|
||||
#define MTP_DEV_PROP_EXPOSURE_TIME 0x500DU
|
||||
#define MTP_DEV_PROP_EXPOSURE_PROGRAM_MODE 0x500EU
|
||||
#define MTP_DEV_PROP_EXPOSURE_INDEX 0x500FU
|
||||
#define MTP_DEV_PROP_EXPOSURE_BIAS_COMPENSATION 0x5010U
|
||||
#define MTP_DEV_PROP_DATETIME 0x5011U
|
||||
#define MTP_DEV_PROP_CAPTURE_DELAY 0x5012U
|
||||
#define MTP_DEV_PROP_STILL_CAPTURE_MODE 0x5013U
|
||||
#define MTP_DEV_PROP_CONTRAST 0x5014U
|
||||
#define MTP_DEV_PROP_SHARPNESS 0x5015U
|
||||
#define MTP_DEV_PROP_DIGITAL_ZOOM 0x5016U
|
||||
#define MTP_DEV_PROP_EFFECT_MODE 0x5017U
|
||||
#define MTP_DEV_PROP_BURST_NUMBER 0x5018U
|
||||
#define MTP_DEV_PROP_BURST_INTERVAL 0x5019U
|
||||
#define MTP_DEV_PROP_TIMELAPSE_NUMBER 0x501AU
|
||||
#define MTP_DEV_PROP_TIMELAPSE_INTERVAL 0x501BU
|
||||
#define MTP_DEV_PROP_FOCUS_METERING_MODE 0x501CU
|
||||
#define MTP_DEV_PROP_UPLOAD_URL 0x501DU
|
||||
#define MTP_DEV_PROP_ARTIST 0x501EU
|
||||
#define MTP_DEV_PROP_COPYRIGHT_INFO 0x501FU
|
||||
#define MTP_DEV_PROP_SYNCHRONIZATION_PARTNER 0xD401U
|
||||
#define MTP_DEV_PROP_DEVICE_FRIENDLY_NAME 0xD402U
|
||||
#define MTP_DEV_PROP_VOLUME 0xD403U
|
||||
#define MTP_DEV_PROP_SUPPORTEDFORMATSORDERED 0xD404U
|
||||
#define MTP_DEV_PROP_DEVICEICON 0xD405U
|
||||
#define MTP_DEV_PROP_PLAYBACK_RATE 0xD410U
|
||||
#define MTP_DEV_PROP_PLAYBACK_OBJECT 0xD411U
|
||||
#define MTP_DEV_PROP_PLAYBACK_CONTAINER 0xD412U
|
||||
#define MTP_DEV_PROP_SESSION_INITIATOR_VERSION_INFO 0xD406U
|
||||
#define MTP_DEV_PROP_PERCEIVED_DEVICE_TYPE 0xD407U
|
||||
|
||||
/*
|
||||
* MTP Class specification Revision 1.1
|
||||
* Appendix B. Object Properties
|
||||
*/
|
||||
|
||||
/* MTP OBJECT PROPERTIES supported*/
|
||||
#define MTP_OB_PROP_STORAGE_ID 0xDC01U
|
||||
#define MTP_OB_PROP_OBJECT_FORMAT 0xDC02U
|
||||
#define MTP_OB_PROP_PROTECTION_STATUS 0xDC03U
|
||||
#define MTP_OB_PROP_OBJECT_SIZE 0xDC04U
|
||||
#define MTP_OB_PROP_ASSOC_TYPE 0xDC05U
|
||||
#define MTP_OB_PROP_ASSOC_DESC 0xDC06U
|
||||
#define MTP_OB_PROP_OBJ_FILE_NAME 0xDC07U
|
||||
#define MTP_OB_PROP_DATE_CREATED 0xDC08U
|
||||
#define MTP_OB_PROP_DATE_MODIFIED 0xDC09U
|
||||
#define MTP_OB_PROP_KEYWORDS 0xDC0AU
|
||||
#define MTP_OB_PROP_PARENT_OBJECT 0xDC0BU
|
||||
#define MTP_OB_PROP_ALLOWED_FOLD_CONTENTS 0xDC0CU
|
||||
#define MTP_OB_PROP_HIDDEN 0xDC0DU
|
||||
#define MTP_OB_PROP_SYSTEM_OBJECT 0xDC0EU
|
||||
#define MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN 0xDC41U
|
||||
#define MTP_OB_PROP_SYNCID 0xDC42U
|
||||
#define MTP_OB_PROP_PROPERTY_BAG 0xDC43U
|
||||
#define MTP_OB_PROP_NAME 0xDC44U
|
||||
#define MTP_OB_PROP_CREATED_BY 0xDC45U
|
||||
#define MTP_OB_PROP_ARTIST 0xDC46U
|
||||
#define MTP_OB_PROP_DATE_AUTHORED 0xDC47U
|
||||
#define MTP_OB_PROP_DESCRIPTION 0xDC48U
|
||||
#define MTP_OB_PROP_URL_REFERENCE 0xDC49U
|
||||
#define MTP_OB_PROP_LANGUAGELOCALE 0xDC4AU
|
||||
#define MTP_OB_PROP_COPYRIGHT_INFORMATION 0xDC4BU
|
||||
#define MTP_OB_PROP_SOURCE 0xDC4CU
|
||||
#define MTP_OB_PROP_ORIGIN_LOCATION 0xDC4DU
|
||||
#define MTP_OB_PROP_DATE_ADDED 0xDC4EU
|
||||
#define MTP_OB_PROP_NON_CONSUMABLE 0xDC4FU
|
||||
#define MTP_OB_PROP_CORRUPTUNPLAYABLE 0xDC50U
|
||||
#define MTP_OB_PROP_PRODUCERSERIALNUMBER 0xDC51U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_FORMAT 0xDC81U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_SIZE 0xDC82U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_HEIGHT 0xDC83U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_WIDTH 0xDC84U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_DURATION 0xDC85U
|
||||
#define MTP_OB_PROP_REPRESENTATIVE_SAMPLE_DATA 0xDC86U
|
||||
#define MTP_OB_PROP_WIDTH 0xDC87U
|
||||
#define MTP_OB_PROP_HEIGHT 0xDC88U
|
||||
#define MTP_OB_PROP_DURATION 0xDC89U
|
||||
#define MTP_OB_PROP_RATING 0xDC8AU
|
||||
#define MTP_OB_PROP_TRACK 0xDC8BU
|
||||
#define MTP_OB_PROP_GENRE 0xDC8CU
|
||||
#define MTP_OB_PROP_CREDITS 0xDC8DU
|
||||
#define MTP_OB_PROP_LYRICS 0xDC8EU
|
||||
#define MTP_OB_PROP_SUBSCRIPTION_CONTENT_ID 0xDC8FU
|
||||
#define MTP_OB_PROP_PRODUCED_BY 0xDC90U
|
||||
#define MTP_OB_PROP_USE_COUNT 0xDC91U
|
||||
#define MTP_OB_PROP_SKIP_COUNT 0xDC92U
|
||||
#define MTP_OB_PROP_LAST_ACCESSED 0xDC93U
|
||||
#define MTP_OB_PROP_PARENTAL_RATING 0xDC94U
|
||||
#define MTP_OB_PROP_META_GENRE 0xDC95U
|
||||
#define MTP_OB_PROP_COMPOSER 0xDC96U
|
||||
#define MTP_OB_PROP_EFFECTIVE_RATING 0xDC97U
|
||||
#define MTP_OB_PROP_SUBTITLE 0xDC98U
|
||||
#define MTP_OB_PROP_ORIGINAL_RELEASE_DATE 0xDC99U
|
||||
#define MTP_OB_PROP_ALBUM_NAME 0xDC9AU
|
||||
#define MTP_OB_PROP_ALBUM_ARTIST 0xDC9BU
|
||||
#define MTP_OB_PROP_MOOD 0xDC9CU
|
||||
#define MTP_OB_PROP_DRM_STATUS 0xDC9DU
|
||||
#define MTP_OB_PROP_SUB_DESCRIPTION 0xDC9EU
|
||||
#define MTP_OB_PROP_IS_CROPPED 0xDCD1U
|
||||
#define MTP_OB_PROP_IS_COLOUR_CORRECTED 0xDCD2U
|
||||
#define MTP_OB_PROP_IMAGE_BIT_DEPTH 0xDCD3U
|
||||
#define MTP_OB_PROP_FNUMBER 0xDCD4U
|
||||
#define MTP_OB_PROP_EXPOSURE_TIME 0xDCD5U
|
||||
#define MTP_OB_PROP_EXPOSURE_INDEX 0xDCD6U
|
||||
#define MTP_OB_PROP_TOTAL_BITRATE 0xDE91U
|
||||
#define MTP_OB_PROP_BITRATE_TYPE 0xDE92U
|
||||
#define MTP_OB_PROP_SAMPLE_RATE 0xDE93U
|
||||
#define MTP_OB_PROP_NUMBER_OF_CHANNELS 0xDE94U
|
||||
#define MTP_OB_PROP_AUDIO_BITDEPTH 0xDE95U
|
||||
#define MTP_OB_PROP_SCAN_TYPE 0xDE97U
|
||||
#define MTP_OB_PROP_AUDIO_WAVE_CODEC 0xDE99U
|
||||
#define MTP_OB_PROP_AUDIO_BITRATE 0xDE9AU
|
||||
#define MTP_OB_PROP_VIDEO_FOURCC_CODEC 0xDE9BU
|
||||
#define MTP_OB_PROP_VIDEO_BITRATE 0xDE9CU
|
||||
#define MTP_OB_PROP_FRAMES_PER_THOUSAND_SECONDS 0xDE9DU
|
||||
#define MTP_OB_PROP_KEYFRAME_DISTANCE 0xDE9EU
|
||||
#define MTP_OB_PROP_BUFFER_SIZE 0xDE9FU
|
||||
#define MTP_OB_PROP_ENCODING_QUALITY 0xDEA0U
|
||||
#define MTP_OB_PROP_ENCODING_PROFILE 0xDEA1U
|
||||
#define MTP_OB_PROP_DISPLAY_NAME 0xDCE0U
|
||||
#define MTP_OB_PROP_BODY_TEXT 0xDCE1U
|
||||
#define MTP_OB_PROP_SUBJECT 0xDCE2U
|
||||
#define MTP_OB_PROP_PRIORITY 0xDCE3U
|
||||
#define MTP_OB_PROP_GIVEN_NAME 0xDD00U
|
||||
#define MTP_OB_PROP_MIDDLE_NAMES 0xDD01U
|
||||
#define MTP_OB_PROP_FAMILY_NAME 0xDD02U
|
||||
#define MTP_OB_PROP_PREFIX 0xDD03U
|
||||
#define MTP_OB_PROP_SUFFIX 0xDD04U
|
||||
#define MTP_OB_PROP_PHONETIC_GIVEN_NAME 0xDD05U
|
||||
#define MTP_OB_PROP_PHONETIC_FAMILY_NAME 0xDD06U
|
||||
#define MTP_OB_PROP_EMAIL_PRIMARY 0xDD07U
|
||||
#define MTP_OB_PROP_EMAIL_PERSONAL_1 0xDD08U
|
||||
#define MTP_OB_PROP_EMAIL_PERSONAL_2 0xDD09U
|
||||
#define MTP_OB_PROP_EMAIL_BUSINESS_1 0xDD0AU
|
||||
#define MTP_OB_PROP_EMAIL_BUSINESS_2 0xDD0BU
|
||||
#define MTP_OB_PROP_EMAIL_OTHERS 0xDD0CU
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_PRIMARY 0xDD0DU
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_PERSONAL 0xDD0EU
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_PERSONAL_2 0xDD0FU
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_BUSINESS 0xDD10U
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_BUSINESS_2 0xDD11U
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_MOBILE 0xDD12U
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_MOBILE_2 0xDD13U
|
||||
#define MTP_OB_PROP_FAX_NUMBER_PRIMARY 0xDD14U
|
||||
#define MTP_OB_PROP_FAX_NUMBER_PERSONAL 0xDD15U
|
||||
#define MTP_OB_PROP_FAX_NUMBER_BUSINESS 0xDD16U
|
||||
#define MTP_OB_PROP_PAGER_NUMBER 0xDD17U
|
||||
#define MTP_OB_PROP_PHONE_NUMBER_OTHERS 0xDD18U
|
||||
#define MTP_OB_PROP_PRIMARY_WEB_ADDRESS 0xDD19U
|
||||
#define MTP_OB_PROP_PERSONAL_WEB_ADDRESS 0xDD1AU
|
||||
#define MTP_OB_PROP_BUSINESS_WEB_ADDRESS 0xDD1BU
|
||||
#define MTP_OB_PROP_INSTANT_MESSENGER_ADDRESS 0xDD1CU
|
||||
#define MTP_OB_PROP_INSTANT_MESSENGER_ADDRESS_2 0xDD1DU
|
||||
#define MTP_OB_PROP_INSTANT_MESSENGER_ADDRESS_3 0xDD1EU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_FULL 0xDD1FU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_LINE_1 0xDD20U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_LINE_2 0xDD21U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_CITY 0xDD22U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_REGION 0xDD23U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_POSTAL_CODE 0xDD24U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_PERSONAL_COUNTRY 0xDD25U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_FULL 0xDD26U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_LINE_1 0xDD27U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_LINE_2 0xDD28U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_CITY 0xDD29U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_REGION 0xDD2AU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_POSTAL_CODE 0xDD2BU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_BUSINESS_COUNTRY 0xDD2CU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_FULL 0xDD2DU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_LINE_1 0xDD2EU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_LINE_2 0xDD2FU
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_CITY 0xDD30U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_REGION 0xDD31U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_POSTAL_CODE 0xDD32U
|
||||
#define MTP_OB_PROP_POSTAL_ADDRESS_OTHER_COUNTRY 0xDD33U
|
||||
#define MTP_OB_PROP_ORGANIZATION_NAME 0xDD34U
|
||||
#define MTP_OB_PROP_PHONETIC_ORGANIZATION_NAME 0xDD35U
|
||||
#define MTP_OB_PROP_ROLE 0xDD36U
|
||||
#define MTP_OB_PROP_BIRTHDATE 0xDD37U
|
||||
#define MTP_OB_PROP_MESSAGE_TO 0xDD40U
|
||||
#define MTP_OB_PROP_MESSAGE_CC 0xDD41U
|
||||
#define MTP_OB_PROP_MESSAGE_BCC 0xDD42U
|
||||
#define MTP_OB_PROP_MESSAGE_READ 0xDD43U
|
||||
#define MTP_OB_PROP_MESSAGE_RECEIVED_TIME 0xDD44U
|
||||
#define MTP_OB_PROP_MESSAGE_SENDER 0xDD45U
|
||||
#define MTP_OB_PROP_ACT_BEGIN_TIME 0xDD50U
|
||||
#define MTP_OB_PROP_ACT_END_TIME 0xDD51U
|
||||
#define MTP_OB_PROP_ACT_LOCATION 0xDD52U
|
||||
#define MTP_OB_PROP_ACT_REQUIRED_ATTENDEES 0xDD54U
|
||||
#define MTP_OB_PROP_ACT_OPTIONAL_ATTENDEES 0xDD55U
|
||||
#define MTP_OB_PROP_ACT_RESOURCES 0xDD56U
|
||||
#define MTP_OB_PROP_ACT_ACCEPTED 0xDD57U
|
||||
#define MTP_OB_PROP_OWNER 0xDD5DU
|
||||
#define MTP_OB_PROP_EDITOR 0xDD5EU
|
||||
#define MTP_OB_PROP_WEBMASTER 0xDD5FU
|
||||
#define MTP_OB_PROP_URL_SOURCE 0xDD60U
|
||||
#define MTP_OB_PROP_URL_DESTINATION 0xDD61U
|
||||
#define MTP_OB_PROP_TIME_BOOKMARK 0xDD62U
|
||||
#define MTP_OB_PROP_OBJECT_BOOKMARK 0xDD63U
|
||||
#define MTP_OB_PROP_BYTE_BOOKMARK 0xDD64U
|
||||
#define MTP_OB_PROP_LAST_BUILD_DATE 0xDD70U
|
||||
#define MTP_OB_PROP_TIME_TO_LIVE 0xDD71U
|
||||
#define MTP_OB_PROP_MEDIA_GUID 0xDD72U
|
||||
|
||||
/* MTP storage type */
|
||||
#define MTP_STORAGE_UNDEFINED 0U
|
||||
#define MTP_STORAGE_FIXED_ROM 0x0001U
|
||||
#define MTP_STORAGE_REMOVABLE_ROM 0x0002U
|
||||
#define MTP_STORAGE_FIXED_RAM 0x0003U
|
||||
#define MTP_STORAGE_REMOVABLE_RAM 0x0004U
|
||||
|
||||
/* MTP file system type */
|
||||
#define MTP_FILESYSTEM_UNDEFINED 0U
|
||||
#define MTP_FILESYSTEM_GENERIC_FLAT 0x0001U
|
||||
#define MTP_FILESYSTEM_GENERIC_HIERARCH 0x0002U
|
||||
#define MTP_FILESYSTEM_DCF 0x0003U
|
||||
|
||||
/* MTP access capability */
|
||||
#define MTP_ACCESS_CAP_RW 0U /* read write */
|
||||
#define MTP_ACCESS_CAP_RO_WITHOUT_DEL 0x0001U
|
||||
#define MTP_ACCESS_CAP_RO_WITH_DEL 0x0002U
|
||||
|
||||
/* MTP standard data types supported */
|
||||
#define MTP_DATATYPE_INT8 0x0001U
|
||||
#define MTP_DATATYPE_UINT8 0x0002U
|
||||
#define MTP_DATATYPE_INT16 0x0003U
|
||||
#define MTP_DATATYPE_UINT16 0x0004U
|
||||
#define MTP_DATATYPE_INT32 0x0005U
|
||||
#define MTP_DATATYPE_UINT32 0x0006U
|
||||
#define MTP_DATATYPE_INT64 0x0007U
|
||||
#define MTP_DATATYPE_UINT64 0x0008U
|
||||
#define MTP_DATATYPE_UINT128 0x000AU
|
||||
#define MTP_DATATYPE_STR 0xFFFFU
|
||||
|
||||
/* MTP reading only or reading/writing */
|
||||
#define MTP_PROP_GET 0x00U
|
||||
#define MTP_PROP_GET_SET 0x01U
|
||||
|
||||
#define MTP_SESSION_CLOSED 0x00
|
||||
#define MTP_SESSION_OPENED 0x01
|
||||
|
||||
struct mtp_container {
|
||||
uint32_t conlen;
|
||||
uint16_t contype;
|
||||
uint16_t code;
|
||||
uint32_t trans_id;
|
||||
};
|
||||
|
||||
struct mtp_container_command {
|
||||
uint32_t conlen;
|
||||
uint16_t contype;
|
||||
uint16_t code;
|
||||
uint32_t trans_id;
|
||||
uint32_t param1;
|
||||
uint32_t param2;
|
||||
uint32_t param3;
|
||||
uint32_t param4;
|
||||
uint32_t param5;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_container_data {
|
||||
uint32_t conlen;
|
||||
uint16_t contype;
|
||||
uint16_t code;
|
||||
uint32_t trans_id;
|
||||
uint8_t data[2048];
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_container_response {
|
||||
uint32_t conlen;
|
||||
uint16_t contype;
|
||||
uint16_t code;
|
||||
uint32_t trans_id;
|
||||
uint32_t param1;
|
||||
uint32_t param2;
|
||||
uint32_t param3;
|
||||
uint32_t param4;
|
||||
uint32_t param5;
|
||||
} __PACKED;
|
||||
|
||||
/*Length of template descriptor: 23 bytes*/
|
||||
#define MTP_DESCRIPTOR_LEN (9 + 7 + 7 + 7)
|
||||
|
||||
// clang-format off
|
||||
#define MTP_DESCRIPTOR_INIT(bFirstInterface, out_ep, in_ep, int_ep, wMaxPacketSize, str_idx) \
|
||||
/* Interface */ \
|
||||
0x09, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
|
||||
bFirstInterface, /* bInterfaceNumber */ \
|
||||
0x00, /* bAlternateSetting */ \
|
||||
0x03, /* bNumEndpoints */ \
|
||||
USB_DEVICE_CLASS_IMAGE, /* bInterfaceClass */ \
|
||||
USB_MTP_SUB_CLASS, /* bInterfaceSubClass */ \
|
||||
USB_MTP_PROTOCOL, /* bInterfaceProtocol */ \
|
||||
str_idx, /* iInterface */ \
|
||||
0x07, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
out_ep, /* bEndpointAddress */ \
|
||||
0x02, /* bmAttributes */ \
|
||||
WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
|
||||
0x00, /* bInterval */ \
|
||||
0x07, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
in_ep, /* bEndpointAddress */ \
|
||||
0x02, /* bmAttributes */ \
|
||||
WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
|
||||
0x00, /* bInterval */ \
|
||||
0x07, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
int_ep, /* bEndpointAddress */ \
|
||||
0x03, /* bmAttributes */ \
|
||||
0x1c, /* wMaxPacketSize */ \
|
||||
0x00, /* bInterval */ \
|
||||
0x06 /* bLength */
|
||||
// clang-format on
|
||||
|
||||
#endif /* USB_MTP_H */
|
||||
1370
packages/third-party/cherryusb/class/mtp/usbd_mtp.c
vendored
Normal file
1370
packages/third-party/cherryusb/class/mtp/usbd_mtp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
packages/third-party/cherryusb/class/mtp/usbd_mtp.h
vendored
Normal file
24
packages/third-party/cherryusb/class/mtp/usbd_mtp.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USBD_MTP_H
|
||||
#define USBD_MTP_H
|
||||
|
||||
#include "usb_mtp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct usbd_interface *usbd_mtp_init_intf(struct usbd_interface *intf,
|
||||
const uint8_t out_ep,
|
||||
const uint8_t in_ep,
|
||||
const uint8_t int_ep);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* USBD_MTP_H */
|
||||
255
packages/third-party/cherryusb/class/mtp/usbd_mtp_config.h
vendored
Normal file
255
packages/third-party/cherryusb/class/mtp/usbd_mtp_config.h
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USB_MTP_CONFIG_H
|
||||
#define USB_MTP_CONFIG_H
|
||||
|
||||
#include "usb_mtp.h"
|
||||
|
||||
static const uint16_t VendExtDesc[] = { 'm', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', '.', 'c', 'o', 'm', ':', ' ', '1', '.', '0', ';', ' ', 0 }; /* last 2 bytes must be 0*/
|
||||
|
||||
static const uint16_t SuppOP[] = { MTP_OP_GET_DEVICE_INFO, MTP_OP_OPEN_SESSION, MTP_OP_CLOSE_SESSION,
|
||||
MTP_OP_GET_STORAGE_IDS, MTP_OP_GET_STORAGE_INFO, MTP_OP_GET_NUM_OBJECTS,
|
||||
MTP_OP_GET_OBJECT_HANDLES, MTP_OP_GET_OBJECT_INFO, MTP_OP_GET_OBJECT,
|
||||
MTP_OP_DELETE_OBJECT, MTP_OP_SEND_OBJECT_INFO, MTP_OP_SEND_OBJECT,
|
||||
MTP_OP_GET_DEVICE_PROP_DESC, MTP_OP_GET_OBJECT_PROPS_SUPPORTED
|
||||
};
|
||||
/* MTP_OP_GET_OBJECT_PROPLIST,MTP_OP_GET_OBJECT_PROP_DESC,
|
||||
MTP_OP_GET_DEVICE_PROP_VALUE,
|
||||
MTP_OP_SET_OBJECT_PROP_VALUE,MTP_OP_GET_OBJECT_PROP_VALUE
|
||||
MTP_OP_GET_OBJECT_PROP_REFERENCES,*/
|
||||
static const uint16_t SuppEvents[] = { MTP_EVENT_OBJECTADDED };
|
||||
|
||||
static const uint16_t DevicePropSupp[] = { MTP_DEV_PROP_DEVICE_FRIENDLY_NAME, MTP_DEV_PROP_BATTERY_LEVEL };
|
||||
|
||||
static const uint16_t SuppCaptFormat[] = { MTP_OBJ_FORMAT_UNDEFINED, MTP_OBJ_FORMAT_ASSOCIATION, MTP_OBJ_FORMAT_TEXT };
|
||||
|
||||
static const uint16_t SuppImgFormat[] = { MTP_OBJ_FORMAT_UNDEFINED, MTP_OBJ_FORMAT_TEXT, MTP_OBJ_FORMAT_ASSOCIATION,
|
||||
MTP_OBJ_FORMAT_EXECUTABLE, MTP_OBJ_FORMAT_WAV, MTP_OBJ_FORMAT_MP3,
|
||||
MTP_OBJ_FORMAT_EXIF_JPEG, MTP_OBJ_FORMAT_MPEG, MTP_OBJ_FORMAT_MP4_CONTAINER,
|
||||
MTP_OBJ_FORMAT_WINDOWS_IMAGE_FORMAT, MTP_OBJ_FORMAT_PNG, MTP_OBJ_FORMAT_WMA,
|
||||
MTP_OBJ_FORMAT_WMV };
|
||||
|
||||
static const uint16_t Manuf[] = { 'C', 'h', 'e', 'r', 'r', 'y', 'U', 'S', 'B', 0 }; /* last 2 bytes must be 0*/
|
||||
static const uint16_t Model[] = { 'C', 'h', 'e', 'r', 'r', 'y', 'U', 'S', 'B', 0 }; /* last 2 bytes must be 0*/
|
||||
static const uint16_t DeviceVers[] = { 'V', '1', '.', '0', '0', 0 }; /* last 2 bytes must be 0*/
|
||||
/*SerialNbr shall be 32 character hexadecimal string for legacy compatibility reasons */
|
||||
static const uint16_t SerialNbr[] = { '0', '0', '0', '0', '1', '0', '0', '0', '0', '1', '0', '0', '0', '0',
|
||||
'1', '0', '0', '0', '0', '1', '0', '0', '0', '0', '1', '0', '0', '0',
|
||||
'0', '1', '0', '0', 0 }; /* last 2 bytes must be 0*/
|
||||
|
||||
static const uint16_t DefaultFileName[] = { 'N', 'e', 'w', ' ', 'F', 'o', 'l', 'd', 'e', 'r', 0 };
|
||||
|
||||
static const uint16_t DevicePropDefVal[] = { 'C', 'h', 'e', 'r', 'r', 'y', 'U', 'S', 'B', 0 }; /* last 2 bytes must be 0*/
|
||||
static const uint16_t DevicePropCurDefVal[] = { 'C', 'h', 'e', 'r', 'r', 'y', 'U', 'S', 'B', 0 };
|
||||
|
||||
/* required for all object format : storageID, objectFormat, ObjectCompressedSize,
|
||||
persistent unique object identifier, name*/
|
||||
static const uint16_t ObjectPropCode[] = { MTP_OB_PROP_STORAGE_ID, MTP_OB_PROP_OBJECT_FORMAT, MTP_OB_PROP_OBJECT_SIZE,
|
||||
MTP_OB_PROP_OBJ_FILE_NAME, MTP_OB_PROP_PARENT_OBJECT, MTP_OB_PROP_NAME,
|
||||
MTP_OB_PROP_PERS_UNIQ_OBJ_IDEN, MTP_OB_PROP_PROTECTION_STATUS,
|
||||
MTP_OB_PROP_DISPLAY_NAME};
|
||||
|
||||
#define MTP_STORAGE_ID 0x00010001U /* SD card is inserted*/
|
||||
|
||||
#define CONFIG_MTP_VEND_EXT_DESC_LEN (sizeof(VendExtDesc) / 2U)
|
||||
#define CONFIG_MTP_SUPP_OP_LEN (sizeof(SuppOP) / 2U)
|
||||
#define CONFIG_MTP_SUPP_EVENTS_LEN (sizeof(SuppEvents) / 2U)
|
||||
#define CONFIG_MTP_SUPP_DEVICE_PROP_LEN (sizeof(DevicePropSupp) / 2U)
|
||||
#define CONFIG_MTP_SUPP_CAPT_FORMAT_LEN (sizeof(SuppCaptFormat) / 2U)
|
||||
#define CONFIG_MTP_SUPP_IMG_FORMAT_LEN (sizeof(SuppImgFormat) / 2U)
|
||||
#define CONFIG_MTP_MANUF_LEN (sizeof(Manuf) / 2U)
|
||||
#define CONFIG_MTP_MODEL_LEN (sizeof(Model) / 2U)
|
||||
#define CONFIG_MTP_DEVICE_VERSION_LEN (sizeof(DeviceVers) / 2U)
|
||||
#define CONFIG_MTP_SERIAL_NBR_LEN (sizeof(SerialNbr) / 2U)
|
||||
#define CONFIG_MTP_SUPP_OBJ_PROP_LEN (sizeof(ObjectPropCode) / 2U)
|
||||
#define CONFIG_MTP_DEVICE_PROP_DESC_DEF_LEN (sizeof(DevicePropDefVal) / 2U)
|
||||
#define CONFIG_MTP_DEVICE_PROP_DESC_CUR_LEN (sizeof(DevicePropCurDefVal) / 2U)
|
||||
#define CONFIG_MTP_FILE_NAME_LEN (sizeof(DefaultFileName) / 2U)
|
||||
#define CONFIG_MTP_STORAGE_ID_LEN 1
|
||||
#define CONFIG_MTP_OBJECT_HANDLE_LEN 124
|
||||
#define CONFIG_MTP_COMMAND_LEN 12
|
||||
|
||||
struct mtp_device_info {
|
||||
uint16_t StandardVersion;
|
||||
uint32_t VendorExtensionID;
|
||||
uint16_t VendorExtensionVersion;
|
||||
uint8_t VendorExtensionDesc_len;
|
||||
uint16_t VendorExtensionDesc[CONFIG_MTP_VEND_EXT_DESC_LEN];
|
||||
uint16_t FunctionalMode;
|
||||
uint32_t OperationsSupported_len;
|
||||
uint16_t OperationsSupported[CONFIG_MTP_SUPP_OP_LEN];
|
||||
uint32_t EventsSupported_len;
|
||||
uint16_t EventsSupported[CONFIG_MTP_SUPP_EVENTS_LEN];
|
||||
uint32_t DevicePropertiesSupported_len;
|
||||
uint16_t DevicePropertiesSupported[CONFIG_MTP_SUPP_DEVICE_PROP_LEN];
|
||||
uint32_t CaptureFormats_len;
|
||||
uint16_t CaptureFormats[CONFIG_MTP_SUPP_CAPT_FORMAT_LEN];
|
||||
uint32_t ImageFormats_len;
|
||||
uint16_t ImageFormats[CONFIG_MTP_SUPP_IMG_FORMAT_LEN];
|
||||
uint8_t Manufacturer_len;
|
||||
uint16_t Manufacturer[CONFIG_MTP_MANUF_LEN];
|
||||
uint8_t Model_len;
|
||||
uint16_t Model[CONFIG_MTP_MODEL_LEN];
|
||||
uint8_t DeviceVersion_len;
|
||||
uint16_t DeviceVersion[CONFIG_MTP_DEVICE_VERSION_LEN];
|
||||
uint8_t SerialNumber_len;
|
||||
uint16_t SerialNumber[CONFIG_MTP_SERIAL_NBR_LEN];
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_object_props_support {
|
||||
uint32_t ObjectPropCode_len;
|
||||
uint16_t ObjectPropCode[CONFIG_MTP_SUPP_OBJ_PROP_LEN];
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_device_prop_desc {
|
||||
uint16_t DevicePropertyCode;
|
||||
uint16_t DataType;
|
||||
uint8_t GetSet;
|
||||
uint8_t DefaultValue_len;
|
||||
uint16_t DefaultValue[CONFIG_MTP_DEVICE_PROP_DESC_DEF_LEN];
|
||||
uint8_t CurrentValue_len;
|
||||
uint16_t CurrentValue[CONFIG_MTP_DEVICE_PROP_DESC_CUR_LEN];
|
||||
uint8_t FormFlag;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_storage_id {
|
||||
uint32_t StorageIDS_len;
|
||||
uint32_t StorageIDS[CONFIG_MTP_STORAGE_ID_LEN];
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_storage_info {
|
||||
uint16_t StorageType;
|
||||
uint16_t FilesystemType;
|
||||
uint16_t AccessCapability;
|
||||
uint64_t MaxCapability;
|
||||
uint64_t FreeSpaceInBytes;
|
||||
uint32_t FreeSpaceInObjects;
|
||||
uint8_t StorageDescription;
|
||||
uint8_t VolumeLabel;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_object_handle {
|
||||
uint32_t ObjectHandle_len;
|
||||
uint32_t ObjectHandle[CONFIG_USBDEV_MTP_GET_MAX_HANDLES];
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_object_info {
|
||||
uint32_t Storage_id;
|
||||
uint16_t ObjectFormat;
|
||||
uint16_t ProtectionStatus;
|
||||
uint32_t ObjectCompressedSize;
|
||||
uint16_t ThumbFormat;
|
||||
uint32_t ThumbCompressedSize;
|
||||
uint32_t ThumbPixWidth;
|
||||
uint32_t ThumbPixHeight;
|
||||
uint32_t ImagePixWidth;
|
||||
uint32_t ImagePixHeight;
|
||||
uint32_t ImageBitDepth;
|
||||
uint32_t ParentObject;
|
||||
uint16_t AssociationType;
|
||||
uint32_t AssociationDesc;
|
||||
uint32_t SequenceNumber;
|
||||
uint8_t Filename_len;
|
||||
uint16_t Filename[255];
|
||||
uint32_t CaptureDate;
|
||||
uint32_t ModificationDate;
|
||||
uint8_t Keywords;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_object_prop_desc {
|
||||
uint16_t ObjectPropertyCode;
|
||||
uint16_t DataType;
|
||||
uint8_t GetSet;
|
||||
uint8_t *DefValue;
|
||||
uint32_t GroupCode;
|
||||
uint8_t FormFlag;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_string {
|
||||
uint8_t len;
|
||||
uint16_t string[255];
|
||||
};
|
||||
|
||||
union _property_value {
|
||||
uint8_t *str;
|
||||
uint8_t u8;
|
||||
int8_t i8;
|
||||
uint16_t u16;
|
||||
int16_t i16;
|
||||
uint32_t u32;
|
||||
int32_t i32;
|
||||
uint64_t u64;
|
||||
int64_t i64;
|
||||
|
||||
struct array {
|
||||
uint32_t count;
|
||||
union _property_value *v;
|
||||
}a;
|
||||
};
|
||||
typedef union _property_value property_value;
|
||||
|
||||
struct mtp_object_prop_element {
|
||||
uint32_t ObjectHandle;
|
||||
uint16_t PropertyCode;
|
||||
uint16_t Datatype;
|
||||
// uint8_t *propval;
|
||||
property_value propval;
|
||||
} __PACKED;
|
||||
|
||||
struct mtp_object_prop_list {
|
||||
uint32_t Properties_len;
|
||||
struct mtp_object_prop_element Properties[CONFIG_MTP_SUPP_OBJ_PROP_LEN];
|
||||
} __PACKED;
|
||||
|
||||
#define MTP_MAX_LONG_NAME_LEN 256
|
||||
typedef struct object_prop_value_dataset
|
||||
{
|
||||
uint32_t storage_id;
|
||||
uint16_t format;
|
||||
uint16_t protection_status;
|
||||
uint32_t size;
|
||||
uint32_t file_name_length;
|
||||
uint8_t file_name[MTP_MAX_LONG_NAME_LEN];
|
||||
uint32_t file_full_name_length;
|
||||
uint8_t file_full_name[MTP_MAX_LONG_NAME_LEN];
|
||||
uint32_t parent_object;
|
||||
uint16_t identifier[4];
|
||||
}object_property_data_set_typedef;
|
||||
|
||||
struct mtp_object {
|
||||
uint32_t handle;
|
||||
object_property_data_set_typedef property;
|
||||
};
|
||||
|
||||
struct mtp_file {
|
||||
uint32_t handle;
|
||||
int fd;
|
||||
int offset;
|
||||
int32_t data_length;
|
||||
};
|
||||
|
||||
int usbd_mtp_get_cap(uint64_t *max_capability, uint64_t *free_space);
|
||||
int usbd_mtp_make_dir(const char *path);
|
||||
int usbd_mtp_remove_dir(const char *path);
|
||||
int usbd_mtp_creat_file(const char *path);
|
||||
int usbd_mtp_unlink_file(const char *pathname);
|
||||
int usbd_mtp_open_file_rdonly(const char *file);
|
||||
int usbd_mtp_open_file_wronly(const char *file);
|
||||
int usbd_mtp_close_file(int fd);
|
||||
int usbd_mtp_read_file(int fd, void *buf, size_t len);
|
||||
int usbd_mtp_write_file(int fd, void *buf, size_t len);
|
||||
void *usbd_mtp_open_dir(const char *path);
|
||||
void *usbd_mtp_close_dir(const char *path);
|
||||
int usbd_mtp_get_file_info(void *d,
|
||||
char *file_name,
|
||||
uint8_t *file_name_len,
|
||||
uint32_t *protection_status);
|
||||
uint32_t usbd_mtp_get_file_size(const char *file);
|
||||
int usbd_mtp_get_fullpath(char *buf, const char *directory,
|
||||
const char *filename);
|
||||
|
||||
|
||||
#endif /* USB_MTP_CONFIG_H */
|
||||
@@ -1024,6 +1024,7 @@ void usbd_event_ep0_setup_complete_handler(uint8_t *psetup)
|
||||
/* handle class request when all the data is received */
|
||||
if (setup->wLength && ((setup->bmRequestType & USB_REQUEST_DIR_MASK) == USB_REQUEST_DIR_OUT)) {
|
||||
USB_LOG_DBG("[2]: Control write transfer start reading %d bytes from ep0\r\n", setup->wLength);
|
||||
aicos_udelay(200);
|
||||
usbd_ep_start_read(USB_CONTROL_OUT_EP0, g_usbd_core.ep0_data_buf, setup->wLength);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#define USB_HID_CONFIG_DESC_SIZ (9 + 9 + 9 + 7 + 7)
|
||||
|
||||
/*!< custom hid report descriptor size */
|
||||
#define HID_CUSTOM_REPORT_DESC_SIZE 38
|
||||
#define HID_CUSTOM_REPORT_DESC_SIZE 63
|
||||
|
||||
/*!< global descriptor */
|
||||
static const uint8_t hid_descriptor[] = {
|
||||
@@ -88,7 +88,7 @@ static const uint8_t hid_descriptor[] = {
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
WBVAL(HIDRAW_OUT_EP_SIZE), /* wMaxPacketSize: 4 Byte max */
|
||||
HIDRAW_OUT_EP_INTERVAL, /* bInterval: Polling Interval */
|
||||
/* 73 */
|
||||
/* 41 */
|
||||
/*
|
||||
* string0 descriptor
|
||||
*/
|
||||
@@ -163,29 +163,39 @@ static const uint8_t hid_descriptor[] = {
|
||||
0x00
|
||||
};
|
||||
|
||||
/*!< custom hid report descriptor */
|
||||
static const uint8_t hid_custom_report_desc[HID_CUSTOM_REPORT_DESC_SIZE] = {
|
||||
/* USER CODE BEGIN 0 */
|
||||
0x06, 0x00, 0xff, /* USAGE_PAGE (Vendor Defined Page 1) */
|
||||
0x09, 0x01, /* USAGE (Vendor Usage 1) */
|
||||
0xa1, 0x01, /* COLLECTION (Application) */
|
||||
0x85, 0x02, /* REPORT ID (0x02) */
|
||||
0x09, 0x01, /* USAGE (Vendor Usage 1) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */
|
||||
0x95, 0x40 - 1, /* REPORT_COUNT (63) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
/* <___________________________________________________> */
|
||||
0x85, 0x01, /* REPORT ID (0x01) */
|
||||
0x09, 0x01, /* USAGE (Vendor Usage 1) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */
|
||||
0x95, 0x40 - 1, /* REPORT_COUNT (63) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
/* USER CODE END 0 */
|
||||
0xC0 /* END_COLLECTION */
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
|
||||
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0x95, 0x01, // REPORT_COUNT (1)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
||||
0x95, 0x05, // REPORT_COUNT (5)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x05, 0x08, // USAGE_PAGE (LEDs)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
|
||||
0x29, 0x05, // USAGE_MAXIMUM (Kana)
|
||||
0x91, 0x02, // OUTPUT (Data,Var,Abs)
|
||||
0x95, 0x01, // REPORT_COUNT (1)
|
||||
0x75, 0x03, // REPORT_SIZE (3)
|
||||
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
|
||||
0x95, 0x06, // REPORT_COUNT (6)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
|
||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
|
||||
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
|
||||
0x81, 0x00, // INPUT (Data,Ary,Abs)
|
||||
0xc0 // END_COLLECTION
|
||||
};
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t read_buffer[HIDRAW_OUT_EP_SIZE];
|
||||
@@ -217,7 +227,6 @@ struct hid_vbuf {
|
||||
unsigned int buf_len[HID_RECV_BUF_SIZE / HID_VBUF_PLANE_SIZE];
|
||||
struct vb_queue queue;
|
||||
struct list_head active_list;
|
||||
aicos_mutex_t active_lock; /* lock of active buf list */
|
||||
unsigned int sequence;
|
||||
unsigned int streaming;
|
||||
};
|
||||
@@ -268,7 +277,7 @@ static void show_speed(u64 start, u64 end, int bytes)
|
||||
static void notify_file_decode(void)
|
||||
{
|
||||
printf("\nThe follow command can decode the image file to FB: \n");
|
||||
printf("pic_test -a 0x%lx -z %d\n", (long)g_hid_img_buf, g_hid_img_size);
|
||||
printf("pic_test -a 0x%lx -z %d\n", (long)g_hid_img_buf, (int)g_hid_img_size);
|
||||
if (!g_hid_only_recv)
|
||||
rt_sem_release(g_hid_sem);
|
||||
}
|
||||
@@ -390,7 +399,7 @@ static void dump_to_buf(uint8_t *data, uint32_t len)
|
||||
parse_file_type(data);
|
||||
|
||||
#ifdef HID_RECV_VIDEO_FILE
|
||||
if (!g_hid_vb.active_lock) {
|
||||
if (!g_hid_vb.vbuf.num_planes) {
|
||||
pr_err("Must init HID vb first!\n");
|
||||
return;
|
||||
}
|
||||
@@ -398,10 +407,8 @@ static void dump_to_buf(uint8_t *data, uint32_t len)
|
||||
if (g_hid_need_wr_file) {
|
||||
/* Need switch to the next buf */
|
||||
if (g_hid_img_size) { /* Be sure it's not the first pkt */
|
||||
aicos_mutex_take(g_hid_vb.active_lock, AICOS_WAIT_FOREVER);
|
||||
hid_buf_done();
|
||||
hid_buf_update();
|
||||
aicos_mutex_give(g_hid_vb.active_lock);
|
||||
}
|
||||
max_len = HID_VBUF_PLANE_SIZE;
|
||||
}
|
||||
@@ -454,7 +461,6 @@ static void dump_to_buf(uint8_t *data, uint32_t len)
|
||||
|
||||
static void usbd_hid_custom_in_callback(uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
usbd_ep_start_write(HIDRAW_IN_EP, send_buffer, nbytes);
|
||||
custom_state = HID_STATE_IDLE;
|
||||
}
|
||||
|
||||
@@ -536,9 +542,7 @@ int decode_pic(uint8_t* pic, int len, u32 offset_x, u32 offset_y,
|
||||
#ifdef HID_RECV_VIDEO_FILE
|
||||
static void hid_vb_buf_queue(struct vb_buffer *vb)
|
||||
{
|
||||
aicos_mutex_take(g_hid_vb.active_lock, AICOS_WAIT_FOREVER);
|
||||
list_add_tail(&vb->active_entry, &g_hid_vb.active_list);
|
||||
aicos_mutex_give(g_hid_vb.active_lock);
|
||||
vb->hw_using = 0;
|
||||
}
|
||||
|
||||
@@ -549,13 +553,11 @@ static int hid_vb_start_streaming(struct vb_queue *q)
|
||||
pr_debug("Start streaming\n");
|
||||
|
||||
g_hid_vb.sequence = 0;
|
||||
aicos_mutex_take(g_hid_vb.active_lock, AICOS_WAIT_FOREVER);
|
||||
|
||||
/* Prepare active_buffers for HID recv*/
|
||||
vb = list_first_entry(&g_hid_vb.active_list, struct vb_buffer, active_entry);
|
||||
hid_buf_reload(vb);
|
||||
|
||||
aicos_mutex_give(g_hid_vb.active_lock);
|
||||
g_hid_vb.streaming = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -564,12 +566,10 @@ static void hid_vb_reclaim_all_buffers(enum vb_buffer_state state)
|
||||
{
|
||||
struct vb_buffer *vb, *node;
|
||||
|
||||
aicos_mutex_take(g_hid_vb.active_lock, AICOS_WAIT_FOREVER);
|
||||
list_for_each_entry_safe(vb, node, &g_hid_vb.active_list, active_entry) {
|
||||
vin_vb_buffer_done(vb, state);
|
||||
list_del(&vb->active_entry);
|
||||
}
|
||||
aicos_mutex_give(g_hid_vb.active_lock);
|
||||
}
|
||||
|
||||
static void hid_vb_stop_streaming(struct vb_queue *q)
|
||||
@@ -577,9 +577,7 @@ static void hid_vb_stop_streaming(struct vb_queue *q)
|
||||
pr_debug("Stopping capture\n");
|
||||
|
||||
/* Release all active buffers */
|
||||
aicos_mutex_take(g_hid_vb.active_lock, AICOS_WAIT_FOREVER);
|
||||
hid_vb_reclaim_all_buffers(VB_BUF_STATE_ERROR);
|
||||
aicos_mutex_give(g_hid_vb.active_lock);
|
||||
g_hid_vb.streaming = 0;
|
||||
}
|
||||
|
||||
@@ -594,11 +592,10 @@ static int hid_vb_init(void)
|
||||
struct vin_video_buf *vbuf = &g_hid_vb.vbuf;
|
||||
int i, ret = 0;
|
||||
|
||||
g_hid_vb.active_lock = aicos_mutex_create();
|
||||
INIT_LIST_HEAD(&g_hid_vb.active_list);
|
||||
vin_vb_init(&g_hid_vb.queue, &hid_vb_ops);
|
||||
|
||||
vbuf->num_planes = HID_VBUF_PLANE_NUM;
|
||||
vbuf->num_planes = HID_VBUF_PLANE_NUM;
|
||||
vbuf->planes[0].len = HID_VBUF_PLANE_SIZE;
|
||||
ret = vin_vb_req_buf(&g_hid_vb.queue,
|
||||
(char *)g_hid_buf_poll, HID_RECV_BUF_SIZE, vbuf);
|
||||
@@ -670,7 +667,7 @@ static void hid_dec_thread(void *arg)
|
||||
/* 2. Write the buffer to a file */
|
||||
if (fd < 0) { /* Need create a new file */
|
||||
pr_info("Create a new file: %s\n", HID_FILE_FOR_SAVE);
|
||||
fd = open(HID_FILE_FOR_SAVE, O_CREAT|O_WRONLY|O_BINARY);
|
||||
fd = open(HID_FILE_FOR_SAVE, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
|
||||
if (fd < 0) {
|
||||
pr_err("Failed to open(%s)\n", HID_FILE_FOR_SAVE);
|
||||
return;
|
||||
@@ -695,11 +692,11 @@ static void hid_dec_thread(void *arg)
|
||||
/* 3. Release/Queue the buffer */
|
||||
vin_vb_q_buf(&g_hid_vb.queue, index);
|
||||
#else
|
||||
printf("\nWaiting for %d/%d file ...\n", cnt + 1, max);
|
||||
printf("\nWaiting for %d/%d file ...\n", (int)cnt + 1, (int)max);
|
||||
if (rt_sem_take(g_hid_sem, RT_WAITING_FOREVER) != RT_EOK)
|
||||
break;
|
||||
|
||||
printf("Try to decode and display the file ...\n");
|
||||
printf("Try to decode and display the picture ...\n");
|
||||
if (!g_hid_need_wr_file) {
|
||||
if (cnt % 5 == 0) {
|
||||
layer_id = AICFB_LAYER_TYPE_VIDEO;
|
||||
@@ -715,7 +712,7 @@ static void hid_dec_thread(void *arg)
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
printf("Layer %d: Offset (%d, %d), Size %d x %d\n", layer_id,
|
||||
printf("Layer %d: Offset (%d, %d), Size %d x %d\n", (int)layer_id,
|
||||
offset_x, offset_y, width, height);
|
||||
decode_pic(g_hid_img_buf, g_hid_img_size, offset_x, offset_y,
|
||||
width, height, layer_id);
|
||||
@@ -778,6 +775,25 @@ int cmd_test_usbd_hid_custom(int argc, char **argv)
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_test_usbd_hid_custom, test_usbd_hid_custom, Receive and decode a file);
|
||||
|
||||
static int test_usbd_hid_keyboard(int argc, char **argv)
|
||||
{
|
||||
uint8_t buf[8] = {0x00, 0x00, HID_KBD_USAGE_A, 0x00, 0x01, 0x03, 0x05, 0x07};
|
||||
|
||||
memcpy(send_buffer, buf, 8);
|
||||
int ret = usbd_ep_start_write(HIDRAW_IN_EP, send_buffer, 8);
|
||||
if (ret < 0) {
|
||||
pr_err("Failed to write IN_EP, return %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
custom_state = HID_STATE_BUSY;
|
||||
while (custom_state == HID_STATE_BUSY) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(test_usbd_hid_keyboard, test_usbd_hid_keyboard, test USB device HID keyboard);
|
||||
|
||||
#endif // end of #if defined(RT_USING_FINSH)
|
||||
|
||||
#endif // end of #if defined(KERNEL_RTTHREAD)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_hid.h"
|
||||
|
||||
@@ -204,9 +210,15 @@ void usbd_event_handler(uint8_t event)
|
||||
|
||||
/*!< hid state ! Data can be sent only when state is idle */
|
||||
static volatile uint8_t hid_state = HID_STATE_IDLE;
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t write_buffer[64];
|
||||
|
||||
void usbd_hid_int_callback(uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
if (hid_state == HID_STATE_BUSY) {
|
||||
memset(write_buffer, 0, 8);
|
||||
usbd_ep_start_write(HID_INT_EP, write_buffer, 8);
|
||||
}
|
||||
|
||||
hid_state = HID_STATE_IDLE;
|
||||
}
|
||||
|
||||
@@ -226,8 +238,6 @@ void hid_keyboard_init(void)
|
||||
usbd_initialize();
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t write_buffer[64];
|
||||
|
||||
void hid_keyboard_test(void)
|
||||
{
|
||||
const uint8_t sendbuffer[8] = { 0x00, 0x00, HID_KBD_USAGE_A, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
@@ -210,11 +210,14 @@ int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length)
|
||||
int ret = -1;
|
||||
struct usbd_storage_p *usbd_storage = get_usbd_storage();
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
ret = rt_device_read(usbd_storage->dev, sector, buffer, 1);
|
||||
ret = rt_device_read(usbd_storage->dev,
|
||||
sector, buffer,
|
||||
length / usbd_storage->block_size);
|
||||
if (ret == length / usbd_storage->block_size)
|
||||
return 0;
|
||||
#else
|
||||
ret = disk_read(usbd_storage->pdrv, buffer, sector, 1);
|
||||
ret = disk_read(usbd_storage->pdrv, buffer, sector,
|
||||
length / usbd_storage->block_size);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -224,11 +227,14 @@ int usbd_msc_sector_write(uint32_t sector, uint8_t *buffer, uint32_t length)
|
||||
int ret = -1;
|
||||
struct usbd_storage_p *usbd_storage = get_usbd_storage();
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
ret = rt_device_write(usbd_storage->dev, sector, buffer, 1);
|
||||
ret = rt_device_write(usbd_storage->dev,
|
||||
sector, buffer,
|
||||
length / usbd_storage->block_size);
|
||||
if (ret == length / usbd_storage->block_size)
|
||||
return 0;
|
||||
#else
|
||||
ret = disk_write(usbd_storage->pdrv, buffer, sector, 1);
|
||||
ret = disk_write(usbd_storage->pdrv, buffer, sector,
|
||||
length / usbd_storage->block_size);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -355,7 +361,8 @@ static void usbd_msc_detection_thread(void *parameter)
|
||||
int usbd_msc_detection(void)
|
||||
{
|
||||
usbd_msc_tid = rt_thread_create("usbd_msc_detection", usbd_msc_detection_thread, RT_NULL,
|
||||
1536, RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
1024 + CONFIG_USBDEV_MSC_MAX_BUFSIZE,
|
||||
RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
if (usbd_msc_tid != RT_NULL)
|
||||
rt_thread_startup(usbd_msc_tid);
|
||||
else
|
||||
|
||||
256
packages/third-party/cherryusb/demo/mtp_template.c
vendored
256
packages/third-party/cherryusb/demo/mtp_template.c
vendored
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_mtp.h"
|
||||
|
||||
@@ -38,20 +43,55 @@ __ALIGN_BEGIN const uint8_t WINUSB_WCIDDescriptor[40] __ALIGN_END = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* bReserved_6 */
|
||||
};
|
||||
|
||||
__ALIGN_BEGIN const uint8_t WINUSB_IF0_WCIDProperties[142] __ALIGN_END = {
|
||||
///////////////////////////////////////
|
||||
/// WCID property descriptor
|
||||
///////////////////////////////////////
|
||||
0x8e, 0x00, 0x00, 0x00, /* dwLength */
|
||||
0x00, 0x01, /* bcdVersion */
|
||||
0x05, 0x00, /* wIndex */
|
||||
0x01, 0x00, /* wCount */
|
||||
|
||||
///////////////////////////////////////
|
||||
/// registry propter descriptor
|
||||
///////////////////////////////////////
|
||||
0x84, 0x00, 0x00, 0x00, /* dwSize */
|
||||
0x01, 0x00, 0x00, 0x00, /* dwPropertyDataType */
|
||||
0x28, 0x00, /* wPropertyNameLength */
|
||||
/* DeviceInterfaceGUID */
|
||||
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, /* wcName_20 */
|
||||
'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, /* wcName_20 */
|
||||
't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, /* wcName_20 */
|
||||
'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, /* wcName_20 */
|
||||
'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00, /* wcName_20 */
|
||||
0x4e, 0x00, 0x00, 0x00, /* dwPropertyDataLength */
|
||||
|
||||
/* {1D4B2365-4749-48EA-B38A-7C6FDDDD7E26} */
|
||||
'{', 0x00, '1', 0x00, 'D', 0x00, '4', 0x00, /* wcData_39 */
|
||||
'B', 0x00, '2', 0x00, '3', 0x00, '6', 0x00, /* wcData_39 */
|
||||
'5', 0x00, '-', 0x00, '4', 0x00, '7', 0x00, /* wcData_39 */
|
||||
'4', 0x00, '9', 0x00, '-', 0x00, '4', 0x00, /* wcData_39 */
|
||||
'8', 0x00, 'E', 0x00, 'A', 0x00, '-', 0x00, /* wcData_39 */
|
||||
'B', 0x00, '3', 0x00, '8', 0x00, 'A', 0x00, /* wcData_39 */
|
||||
'-', 0x00, '7', 0x00, 'C', 0x00, '6', 0x00, /* wcData_39 */
|
||||
'F', 0x00, 'D', 0x00, 'D', 0x00, 'D', 0x00, /* wcData_39 */
|
||||
'D', 0x00, '7', 0x00, 'E', 0x00, '2', 0x00, /* wcData_39 */
|
||||
'6', 0x00, '}', 0x00, 0x00, 0x00, /* wcData_39 */
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct usb_msosv1_descriptor msosv1_desc = {
|
||||
.string = (uint8_t *)WCID_StringDescriptor_MSOS,
|
||||
.string_len = 18,
|
||||
.vendor_code = WCID_VENDOR_CODE,
|
||||
.compat_id = (uint8_t *)WINUSB_WCIDDescriptor,
|
||||
.compat_id_len = sizeof(WINUSB_WCIDDescriptor),
|
||||
.comp_id_property = NULL,
|
||||
.comp_id_property_len = 0,
|
||||
.comp_id_property = (const uint8_t **)&WINUSB_IF0_WCIDProperties,
|
||||
};
|
||||
|
||||
/*!< endpoint address */
|
||||
#define CDC_IN_EP 0x81
|
||||
#define CDC_OUT_EP 0x02
|
||||
#define CDC_INT_EP 0x83
|
||||
#define MTP_IN_EP 0x81
|
||||
#define MTP_OUT_EP 0x02
|
||||
#define MTP_INT_EP 0x83
|
||||
|
||||
#define USBD_VID 0x33C3
|
||||
#define USBD_PID 0xFFFF
|
||||
@@ -70,7 +110,7 @@ struct usb_msosv1_descriptor msosv1_desc = {
|
||||
const uint8_t mtp_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_1, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0201, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
MTP_DESCRIPTOR_INIT(0x00, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP, MTP_MAX_MPS, 0x02),
|
||||
MTP_DESCRIPTOR_INIT(0x00, MTP_OUT_EP, MTP_IN_EP, MTP_INT_EP, MTP_MAX_MPS, 0x02),
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
@@ -145,7 +185,7 @@ const uint8_t mtp_descriptor[] = {
|
||||
0x00
|
||||
};
|
||||
|
||||
const uint8_t bos_descriptor[] = {
|
||||
uint8_t bos_descriptor[] = {
|
||||
0x05, 0x0f, 0x16, 0x00, 0x02,
|
||||
0x07, 0x10, 0x02, 0x06, 0x00, 0x00, 0x00,
|
||||
0x0a, 0x10, 0x03, 0x00, 0x0f, 0x00, 0x01, 0x01, 0xf4, 0x01
|
||||
@@ -176,6 +216,21 @@ void usbd_event_handler(uint8_t event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <string.h>
|
||||
#include "ff.h" /* Declarations of FatFs API */
|
||||
/* ELM FatFs provide a DIR struct */
|
||||
#define HAVE_DIR_STRUCTURE
|
||||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_elm.h>
|
||||
#include "diskio.h" /* Declarations of device I/O functions */
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
#include "rtthread.h"
|
||||
#else
|
||||
#include "dfs_bare.h"
|
||||
#endif
|
||||
struct usbd_interface intf0;
|
||||
|
||||
struct usb_bos_descriptor bos_desc = {
|
||||
@@ -183,11 +238,190 @@ struct usb_bos_descriptor bos_desc = {
|
||||
.string_len = 22
|
||||
};
|
||||
|
||||
struct usbd_mtp_fs_p {
|
||||
struct dfs_filesystem *fs;
|
||||
struct statfs stat; /* 1. block size 2. total data blocks in file system 3. free blocks in file system*/
|
||||
char fs_path[10];
|
||||
char fs_type[5];
|
||||
};
|
||||
|
||||
struct usbd_mtp_fs_p usbd_mtp_fs;
|
||||
struct usbd_mtp_fs_p *get_usbd_mtp_fs(void)
|
||||
{
|
||||
return &usbd_mtp_fs;
|
||||
}
|
||||
|
||||
int usbd_mtp_get_cap(uint64_t *max_capability, uint64_t *free_space)
|
||||
{
|
||||
int ret;
|
||||
struct usbd_mtp_fs_p *usbd_mtp_fs = get_usbd_mtp_fs();
|
||||
|
||||
ret = dfs_statfs(usbd_mtp_fs->fs_path, &usbd_mtp_fs->stat);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
*max_capability = (uint64_t)usbd_mtp_fs->stat.f_bsize * (uint64_t)usbd_mtp_fs->stat.f_blocks;
|
||||
*free_space = (uint64_t)usbd_mtp_fs->stat.f_bsize * (uint64_t)usbd_mtp_fs->stat.f_bfree;
|
||||
|
||||
USB_LOG_DBG("max_capability:%lld free_space:%lld\n", *max_capability, *free_space);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "stdio.h"
|
||||
#include "fcntl.h"
|
||||
#include "dirent.h"
|
||||
#include "unistd.h"
|
||||
/* directory operation */
|
||||
int usbd_mtp_make_dir(const char *path)
|
||||
{
|
||||
return mkdir(path, 0);
|
||||
}
|
||||
|
||||
int usbd_mtp_remove_dir(const char *path)
|
||||
{
|
||||
return rmdir(path);
|
||||
}
|
||||
|
||||
void *usbd_mtp_open_dir(const char *path)
|
||||
{
|
||||
return opendir(path);
|
||||
}
|
||||
|
||||
int usbd_mtp_close_dir(void *d)
|
||||
{
|
||||
DIR *dir = (DIR *)d;
|
||||
return closedir(dir);
|
||||
}
|
||||
|
||||
int usbd_mtp_get_file_info(void *d,
|
||||
char *file_name,
|
||||
uint8_t *file_name_len,
|
||||
uint32_t *protection_status)
|
||||
{
|
||||
DIR *dir = (DIR *)d;
|
||||
struct dirent *dirent;
|
||||
|
||||
dirent = readdir(dir);
|
||||
if (dirent == NULL)
|
||||
return 0;
|
||||
|
||||
*file_name_len = dirent->d_namlen;
|
||||
strcpy(file_name, dirent->d_name);
|
||||
*protection_status = 0;
|
||||
|
||||
return 1; /* if still read the file, please return 1 */
|
||||
}
|
||||
|
||||
/* directory operation */
|
||||
int usbd_mtp_creat_file(const char *path)
|
||||
{
|
||||
return creat(path, O_RDWR);
|
||||
}
|
||||
|
||||
int usbd_mtp_unlink_file(const char *pathname)
|
||||
{
|
||||
return unlink(pathname);
|
||||
}
|
||||
|
||||
int usbd_mtp_open_file_rdonly(const char *file)
|
||||
{
|
||||
return open(file, O_RDONLY);
|
||||
}
|
||||
|
||||
int usbd_mtp_open_file_wronly(const char *file)
|
||||
{
|
||||
return open(file, O_WRONLY);
|
||||
}
|
||||
|
||||
int usbd_mtp_close_file(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
int usbd_mtp_read_file(int fd, void *buf, size_t len)
|
||||
{
|
||||
return read(fd, (char *)buf, len);
|
||||
}
|
||||
|
||||
int usbd_mtp_write_file(int fd, const void *buf, size_t len)
|
||||
{
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
uint32_t usbd_mtp_get_file_size(const char *file)
|
||||
{
|
||||
struct stat s;
|
||||
if(stat(file, &s) < 0)
|
||||
return -1;
|
||||
|
||||
return s.st_size;
|
||||
}
|
||||
|
||||
int usbd_mtp_get_fullpath(char *buf, const char *directory, const char *filename)
|
||||
{
|
||||
char *fullpath;
|
||||
fullpath = dfs_normalize_path(directory, filename);
|
||||
strcpy(buf, fullpath);
|
||||
rt_free(fullpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern struct dfs_filesystem filesystem_table[];
|
||||
|
||||
int usbd_mtp_fs_init(char *path)
|
||||
{
|
||||
struct dfs_filesystem *iter;
|
||||
struct usbd_mtp_fs_p *usbd_mtp_fs = get_usbd_mtp_fs();
|
||||
|
||||
for (iter = &filesystem_table[0];
|
||||
iter < &filesystem_table[DFS_FILESYSTEMS_MAX]; iter++) {
|
||||
if ((iter != NULL) && (iter->path != NULL)) {
|
||||
if (strcmp(iter->path, path) == 0)
|
||||
goto __init;
|
||||
}
|
||||
}
|
||||
USB_LOG_WRN("Invalid file system!\n");
|
||||
return -1;
|
||||
__init:
|
||||
usbd_mtp_fs->fs = dfs_filesystem_lookup(path);
|
||||
strcpy(usbd_mtp_fs->fs_type, iter->ops->name);
|
||||
strcpy(usbd_mtp_fs->fs_path, iter->path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mtp_init(void)
|
||||
{
|
||||
|
||||
usbd_mtp_fs_init(ROOT_PATH);
|
||||
usbd_desc_register(mtp_descriptor);
|
||||
usbd_msosv1_desc_register(&msosv1_desc);
|
||||
usbd_bos_desc_register(&bos_desc);
|
||||
usbd_add_interface(usbd_mtp_init_intf(&intf0, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP));
|
||||
usbd_add_interface(usbd_mtp_init_intf(&intf0, MTP_OUT_EP, MTP_IN_EP, MTP_INT_EP));
|
||||
usbd_initialize();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
rt_thread_t usbd_mtp_tid;
|
||||
|
||||
static void usbd_mtp_detection_thread(void *parameter)
|
||||
{
|
||||
// waiting to mount the correspongding file system
|
||||
rt_thread_mdelay(800);
|
||||
mtp_init();
|
||||
|
||||
}
|
||||
|
||||
int usbd_mtp_detection(void)
|
||||
{
|
||||
usbd_mtp_tid = rt_thread_create("usbd_mtp_detection", usbd_mtp_detection_thread, RT_NULL,
|
||||
1536, RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
if (usbd_mtp_tid != RT_NULL)
|
||||
rt_thread_startup(usbd_mtp_tid);
|
||||
else
|
||||
printf("create usbd_mtp_detection thread err!\n");
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_APP_EXPORT(usbd_mtp_detection);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Artinchip Technology Co., Ltd
|
||||
* Copyright (c) 2022, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
|
||||
#include <rtconfig.h>
|
||||
@@ -11,6 +12,44 @@
|
||||
struct usbh_msc *active_msc_class;
|
||||
struct dfs_partition part0;
|
||||
|
||||
#define USING_AIC_GET_PART
|
||||
|
||||
#ifdef USING_AIC_GET_PART
|
||||
#include <disk_part.h>
|
||||
#include <dfs_fs.h>
|
||||
static unsigned long usb_msc_read(struct blk_desc *blk_dev, u64 start, u64 blkcnt,
|
||||
const void *buffer)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = usbh_msc_scsi_read10(active_msc_class, start, buffer, blkcnt);
|
||||
if (err == RT_EOK)
|
||||
return blkcnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int aic_get_part(struct dfs_partition *part)
|
||||
{
|
||||
struct blk_desc dev_desc = {0};
|
||||
struct disk_blk_ops ops = {0};
|
||||
struct aic_partition *parts = NULL;
|
||||
ops.blk_read = usb_msc_read;
|
||||
dev_desc.blksz = active_msc_class->blocksize;
|
||||
dev_desc.lba_count = active_msc_class->blocknum;
|
||||
|
||||
aic_disk_part_set_ops(&ops);
|
||||
parts = aic_disk_get_gpt_parts(&dev_desc);
|
||||
|
||||
if (parts) {
|
||||
part->type = 0;
|
||||
part->offset = parts->start / dev_desc.blksz;
|
||||
part->size = parts->size / dev_desc.blksz;
|
||||
aic_part_free(parts);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL_RTTHREAD
|
||||
#include <dfs_fs.h>
|
||||
|
||||
@@ -103,32 +142,34 @@ int udisk_init(void)
|
||||
|
||||
/* get the first sector to read partition table */
|
||||
sector = (rt_uint8_t *)rt_malloc(512);
|
||||
if (sector == RT_NULL)
|
||||
{
|
||||
if (sector == RT_NULL) {
|
||||
pr_err("allocate partition sector buffer failed!");
|
||||
|
||||
return -RT_ENOMEM;
|
||||
}
|
||||
|
||||
ret = usbh_msc_scsi_read10(active_msc_class, 0, sector, 1);
|
||||
if (ret != RT_EOK)
|
||||
{
|
||||
if (ret != RT_EOK) {
|
||||
rt_kprintf("usb mass_storage read failed\n");
|
||||
goto free_res;;
|
||||
goto free_res;
|
||||
}
|
||||
|
||||
memset(&part0, 0, sizeof(part0));
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
/* Get the first partition */
|
||||
/* Get the first partition (MBR)*/
|
||||
ret = dfs_filesystem_get_partition(&part0, sector, i);
|
||||
if (ret == RT_EOK) {
|
||||
pr_info("Found partition %d: type = %d, offet=0x%x, size=0x%x\n",
|
||||
pr_info("Found partition %d: type = %d, offet=0x%lx, size=0x%x\n",
|
||||
i, part0.type, part0.offset, part0.size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USING_AIC_GET_PART
|
||||
aic_get_part(&part0);
|
||||
#endif
|
||||
|
||||
udisk_dev.type = RT_Device_Class_Block;
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
udisk_dev.ops = &udisk_device_ops;
|
||||
@@ -150,12 +191,9 @@ int udisk_init(void)
|
||||
#else
|
||||
int ret = 0;
|
||||
ret = dfs_mount(udisk_dev.parent.name, "/", "elm", 0, 0);
|
||||
if (ret == 0)
|
||||
{
|
||||
if (ret == 0) {
|
||||
printf("udisk mount successfully\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf("udisk mount failed, ret = %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
@@ -275,16 +313,14 @@ int udisk_init(void)
|
||||
|
||||
/* get the first sector to read partition table */
|
||||
sector = (uint8_t *)aicos_malloc(0, 512);
|
||||
if (sector == NULL)
|
||||
{
|
||||
if (sector == NULL) {
|
||||
pr_err("allocate partition sector buffer failed!");
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = usbh_msc_scsi_read10(active_msc_class, 0, sector, 1);
|
||||
if (ret != EOK)
|
||||
{
|
||||
if (ret != EOK) {
|
||||
pr_err("usb mass_storage read failed\n");
|
||||
goto free_res;;
|
||||
}
|
||||
@@ -301,6 +337,10 @@ int udisk_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USING_AIC_GET_PART
|
||||
aic_get_part(&part0);
|
||||
#endif
|
||||
|
||||
if (dfs_mount("udisk", "/udisk", "elm", 0, DEVICE_TYPE_USB_DISK) < 0) {
|
||||
pr_err("Failed to mount udisk with FatFS\n");
|
||||
} else {
|
||||
|
||||
@@ -948,12 +948,14 @@ int usbd_npinep_rewrite(const uint8_t ep)
|
||||
/* (1.4) Clear Global In NP NAK in Shared FIFO for non periodic ep */
|
||||
AIC_UDC_REG->usbdevfunc |= USBDEVFUNC_CGNPINNAK;
|
||||
|
||||
/* (2) reopen current ep */
|
||||
usbd_ep_open(&g_aic_udc.in_ep_desc[ep]);
|
||||
if (pending_map & (1 << ep)) {
|
||||
/* (2) reopen current ep */
|
||||
usbd_ep_open(&g_aic_udc.in_ep_desc[ep]);
|
||||
|
||||
/* (3) rewrite current ep */
|
||||
usbd_ep_start_write(ep, g_aic_udc.in_ep[ep].xfer_buf,
|
||||
g_aic_udc.in_ep[ep].xfer_len);
|
||||
/* (3) rewrite current ep */
|
||||
usbd_ep_start_write(ep, g_aic_udc.in_ep[ep].xfer_buf,
|
||||
g_aic_udc.in_ep[ep].xfer_len);
|
||||
}
|
||||
|
||||
/* (4) reopen & rewrite other ep, let's receive ep mismtach interrupt */
|
||||
for (i = 0U; i < USB_NUM_BIDIR_ENDPOINTS; i++) {
|
||||
|
||||
14
packages/third-party/cherryusb/usb_config.h
vendored
14
packages/third-party/cherryusb/usb_config.h
vendored
@@ -86,6 +86,18 @@
|
||||
#define CONFIG_USBDEV_MSC_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifdef USBDEV_MTP_THREAD
|
||||
#define CONFIG_USBDEV_MTP_THREAD
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_MAX_BUFSIZE
|
||||
#define CONFIG_USBDEV_MTP_MAX_BUFSIZE 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_GET_MAX_HANDLES
|
||||
#define CONFIG_USBDEV_MTP_GET_MAX_HANDLES 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
|
||||
#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
|
||||
#endif
|
||||
@@ -131,7 +143,7 @@
|
||||
#define CONFIG_USBHOST_PSC_PRIO 0
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
|
||||
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
|
||||
#define CONFIG_USBHOST_PSC_STACKSIZE 4096
|
||||
#endif
|
||||
|
||||
//#define CONFIG_USBHOST_GET_STRING_DESC
|
||||
|
||||
Reference in New Issue
Block a user