!204 usb0825commit

Merge pull request !204 from bigA2021/0825usb
This commit is contained in:
openharmony_ci
2021-08-27 08:31:15 +00:00
committed by Gitee
7 changed files with 273 additions and 81 deletions
+6 -6
View File
@@ -26,13 +26,13 @@ struct UsbPnpMatchIdTable {
const char *deviceMatchAttr;
int32_t interfaceClassLength;
int32_t interfaceClassMask;
uint32_t interfaceClassMask;
int32_t interfaceSubClassLength;
int32_t interfaceSubClassMask;
uint32_t interfaceSubClassMask;
int32_t interfaceProtocolLength;
int32_t interfaceProtocolMask;
uint32_t interfaceProtocolMask;
int32_t interfaceLength;
int32_t interfaceMask;
uint32_t interfaceMask;
uint8_t pnpMatchFlag;
@@ -63,7 +63,7 @@ struct UsbPnpDeviceListTable {
const char *serviceName;
const char *deviceMatchAttr;
UsbPnpDriverStatus status;
uint32_t usbDevAddr;
uintptr_t usbDevAddr;
int32_t devNum;
int32_t busNum;
int32_t interfaceLength;
@@ -72,7 +72,7 @@ struct UsbPnpDeviceListTable {
struct UsbPnpRemoveInfo {
uint8_t removeType;
uint32_t usbDevAddr;
uintptr_t usbDevAddr;
int32_t devNum;
int32_t busNum;
uint8_t interfaceNum;
+29 -29
View File
@@ -65,7 +65,7 @@ out:
return NULL;
}
static bool UsbDdkPnpLoaderMatchDevice(struct UsbPnpNotifyMatchInfoTable *dev,
static bool UsbDdkPnpLoaderMatchDevice(const struct UsbPnpNotifyMatchInfoTable *dev,
const struct UsbPnpMatchIdTable *id)
{
if ((id->matchFlag & USB_PNP_NOTIFY_MATCH_VENDOR) &&
@@ -106,7 +106,7 @@ static bool UsbDdkPnpLoaderMatchDevice(struct UsbPnpNotifyMatchInfoTable *dev,
return true;
}
static void UsbDdkPnpLoaderMatchHandle(struct UsbPnpNotifyMatchInfoTable *dev,
static void UsbDdkPnpLoaderMatchHandle(const struct UsbPnpNotifyMatchInfoTable *dev,
int8_t index, struct UsbPnpMatchIdTable *id, bool flag)
{
if ((id->pnpMatchFlag == false) && (flag == true)) {
@@ -125,7 +125,7 @@ static void UsbDdkPnpLoaderMatchHandle(struct UsbPnpNotifyMatchInfoTable *dev,
}
}
static bool UsbDdkPnpLoaderMatchFlag(struct UsbPnpNotifyMatchInfoTable *dev,
static bool UsbDdkPnpLoaderMatchFlag(const struct UsbPnpNotifyMatchInfoTable *dev,
int8_t index, struct UsbPnpMatchIdTable *id, bool flag)
{
int32_t i;
@@ -187,10 +187,10 @@ out:
return ret;
}
static bool UsbDdkPnpLoaderMatchInterface(struct UsbPnpNotifyMatchInfoTable *dev,
static bool UsbDdkPnpLoaderMatchInterface(const struct UsbPnpNotifyMatchInfoTable *dev,
int8_t index, struct UsbPnpMatchIdTable *id)
{
int32_t i;
uint32_t i;
bool maskFlag = true;
if (id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_CLASS) {
@@ -248,7 +248,7 @@ static bool UsbDdkPnpLoaderMatchInterface(struct UsbPnpNotifyMatchInfoTable *dev
return maskFlag;
}
static bool UsbDdkPnpLoaderMatchOneIdIntf(struct UsbPnpNotifyMatchInfoTable *dev,
static bool UsbDdkPnpLoaderMatchOneIdIntf(const struct UsbPnpNotifyMatchInfoTable *dev,
int8_t index, struct UsbPnpMatchIdTable *id)
{
bool maskFlag = true;
@@ -275,7 +275,7 @@ static bool UsbDdkPnpLoaderMatchOneIdIntf(struct UsbPnpNotifyMatchInfoTable *dev
}
static int32_t UsbDdkPnpLoaderParseIdInfClass(const struct DeviceResourceNode *node,
struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
const struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
{
table->interfaceClassMask = 0;
table->interfaceClassLength = devResIface->GetElemNum(node, "interfaceClass");
@@ -313,7 +313,7 @@ static int32_t UsbDdkPnpLoaderParseIdInfClass(const struct DeviceResourceNode *n
static int32_t UsbDdkPnpLoaderParseIdInferface(const struct DeviceResourceNode *node,
struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
const struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
{
if (UsbDdkPnpLoaderParseIdInfClass(node, devResIface, table) != HDF_SUCCESS) {
return HDF_FAILURE;
@@ -354,7 +354,7 @@ static int32_t UsbDdkPnpLoaderParseIdInferface(const struct DeviceResourceNode *
}
static int32_t UsbDdkPnpLoaderParseIdDevice(const struct DeviceResourceNode *node,
struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
const struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
{
if (devResIface->GetUint16(node, "vendorId", &table->vendorId, 0) != HDF_SUCCESS) {
HDF_LOGE("%s: read vendorId fail!", __func__);
@@ -395,7 +395,7 @@ static int32_t UsbDdkPnpLoaderParseIdDevice(const struct DeviceResourceNode *nod
}
static int32_t UsbDdkPnpLoaderParseIdTable(const struct DeviceResourceNode *node,
struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
const struct DeviceResourceIface *devResIface, struct UsbPnpMatchIdTable *table)
{
if (node == NULL || table == NULL || devResIface == NULL) {
HDF_LOGE("%s: node or table or devResIface is NULL!", __func__);
@@ -435,7 +435,7 @@ static int32_t UsbDdkPnpLoaderParseIdTable(const struct DeviceResourceNode *node
}
static struct UsbPnpMatchIdTable **UsbDdkPnpLoaderParseTableList(
const struct DeviceResourceNode *node, int32_t idTabCount, struct DeviceResourceIface *devResIface)
const struct DeviceResourceNode *node, int32_t idTabCount, const struct DeviceResourceIface *devResIface)
{
int32_t ret;
int32_t count;
@@ -564,7 +564,7 @@ static struct UsbPnpMatchIdTable **UsbDdkPnpLoaderPnpMatch(void)
}
static int32_t UsbDdkPnpLoaderDispatchPnpDevice(
struct IDevmgrService *devmgrSvc, struct HdfSBuf *data, bool isReg)
const struct IDevmgrService *devmgrSvc, struct HdfSBuf *data, bool isReg)
{
uint32_t infoSize = 0;
struct UsbPnpNotifyServiceInfo *privateData = NULL;
@@ -589,7 +589,7 @@ static int32_t UsbDdkPnpLoaderDispatchPnpDevice(
privateData = NULL;
}
managerInfo.devmgrSvc = devmgrSvc;
managerInfo.devmgrSvc = (struct IDevmgrService *)devmgrSvc;
managerInfo.moduleName = moduleName;
managerInfo.serviceName = serviceName;
managerInfo.deviceMatchAttr = deviceMatchAttr;
@@ -599,7 +599,7 @@ static int32_t UsbDdkPnpLoaderDispatchPnpDevice(
return UsbPnpManagerRegisterOrUnregisterDevice(managerInfo);
}
static int UsbDdkPnpLoaderDeviceListAdd(struct UsbPnpNotifyMatchInfoTable *info,
static int UsbDdkPnpLoaderDeviceListAdd(const struct UsbPnpNotifyMatchInfoTable *info,
const struct UsbPnpMatchIdTable *idTable)
{
int ret;
@@ -634,7 +634,7 @@ static int UsbDdkPnpLoaderDeviceListAdd(struct UsbPnpNotifyMatchInfoTable *info,
}
static struct UsbPnpDeviceListTable *UsbDdkPnpLoaderAddInterface(
struct UsbPnpNotifyMatchInfoTable *info, const struct UsbPnpMatchIdTable *idTable)
const struct UsbPnpNotifyMatchInfoTable *info, const struct UsbPnpMatchIdTable *idTable)
{
struct UsbPnpDeviceListTable *deviceListTablePos = NULL;
struct UsbPnpDeviceListTable *deviceListTableTemp = NULL;
@@ -658,13 +658,13 @@ static struct UsbPnpDeviceListTable *UsbDdkPnpLoaderAddInterface(
HDF_LOGE("%s:%d usbDevAddr=0x%x, interface=%d-%d-%d to \
be add but not exist. ",
__func__, __LINE__, info->usbDevAddr, info->devNum, info->busNum, info->numInfos);
__func__, __LINE__, (uint32_t)info->usbDevAddr, info->devNum, info->busNum, info->numInfos);
return NULL;
}
static int UsbDdkPnpLoaderrAddPnpDevice(struct IDevmgrService *devmgrSvc,
struct UsbPnpNotifyMatchInfoTable *infoTable, struct UsbPnpMatchIdTable *idTable, uint32_t cmdId)
static int UsbDdkPnpLoaderrAddPnpDevice(const struct IDevmgrService *devmgrSvc,
const struct UsbPnpNotifyMatchInfoTable *infoTable, const struct UsbPnpMatchIdTable *idTable, uint32_t cmdId)
{
int ret;
struct HdfSBuf *pnpData = NULL;
@@ -718,10 +718,10 @@ error:
return ret;
}
static void UsbDdkPnpLoaderAddDevice(uint32_t cmdId, uint8_t index, struct IDevmgrService *devmgrSvc,
struct UsbPnpNotifyMatchInfoTable *infoTable, struct UsbPnpMatchIdTable **matchIdTable)
static void UsbDdkPnpLoaderAddDevice(uint32_t cmdId, uint8_t index, const struct IDevmgrService *devmgrSvc,
const struct UsbPnpNotifyMatchInfoTable *infoTable, struct UsbPnpMatchIdTable **matchIdTable)
{
int ret;
int ret = HDF_FAILURE;
struct UsbPnpMatchIdTable *idTable = NULL;
int32_t tableCount;
@@ -747,7 +747,7 @@ static void UsbDdkPnpLoaderAddDevice(uint32_t cmdId, uint8_t index, struct IDevm
HDF_LOGD("%s:%d AddDevice end, index=%d, ret=%d", __func__, __LINE__, index, ret);
}
static int UsbDdkPnpLoaderRemoveHandle(struct IDevmgrService *devmgrSvc,
static int UsbDdkPnpLoaderRemoveHandle(const struct IDevmgrService *devmgrSvc,
struct UsbPnpDeviceListTable *deviceListTablePos)
{
struct UsbPnpNotifyServiceInfo serviceInfo;
@@ -783,7 +783,7 @@ error:
return ret;
}
static int UsbDdkPnpLoaderRemoveDevice(struct IDevmgrService *devmgrSvc,
static int UsbDdkPnpLoaderRemoveDevice(const struct IDevmgrService *devmgrSvc,
struct UsbPnpRemoveInfo removeInfo, uint32_t cmdId)
{
int ret = HDF_SUCCESS;
@@ -828,15 +828,15 @@ static int UsbDdkPnpLoaderRemoveDevice(struct IDevmgrService *devmgrSvc,
if (findFlag == false) {
HDF_LOGE("%s:%d removeType=%d, usbDevAddr=0x%x, to be remove but not exist.",
__func__, __LINE__, removeInfo.removeType, removeInfo.usbDevAddr);
__func__, __LINE__, removeInfo.removeType, (uint32_t)removeInfo.usbDevAddr);
ret = HDF_FAILURE;
}
return ret;
}
static int UsbDdkPnpLoaderDevice(struct UsbPnpNotifyMatchInfoTable *infoTable,
struct IDevmgrService *super, uint32_t id)
static int UsbDdkPnpLoaderDevice(const struct UsbPnpNotifyMatchInfoTable *infoTable,
const struct IDevmgrService *super, uint32_t id)
{
int8_t i;
int32_t tableCount;
@@ -875,7 +875,7 @@ static int UsbDdkPnpLoaderDevice(struct UsbPnpNotifyMatchInfoTable *infoTable,
return HDF_SUCCESS;
}
static int UsbDdkPnpLoaderEventSend(struct HdfIoService *serv, char *eventData)
static int UsbDdkPnpLoaderEventSend(const struct HdfIoService *serv, const char *eventData)
{
int ret;
int replyData = 0;
@@ -901,7 +901,7 @@ static int UsbDdkPnpLoaderEventSend(struct HdfIoService *serv, char *eventData)
goto out;
}
ret = serv->dispatcher->Dispatch(&serv->object, USB_PNP_NOTIFY_REPORT_INTERFACE, data, reply);
ret = serv->dispatcher->Dispatch((struct HdfObject *)&serv->object, USB_PNP_NOTIFY_REPORT_INTERFACE, data, reply);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: fail to send serivice call, ret=%d", __func__, ret);
goto out;
@@ -941,7 +941,7 @@ int UsbDdkPnpLoaderEventReceived(void *priv, uint32_t id, struct HdfSBuf *data)
HDF_LOGI("%s:%d id=%d infoSize=%d, usbDevAddr=0x%x, devNum=%d, \
busNum=%d, infoTable=0x%x-0x%x success",
__func__, __LINE__, id, infoSize, infoTable->usbDevAddr, infoTable->devNum,
__func__, __LINE__, id, infoSize, (uint32_t)infoTable->usbDevAddr, infoTable->devNum,
infoTable->busNum, infoTable->deviceInfo.vendorId, infoTable->deviceInfo.productId);
switch (id) {
@@ -181,6 +181,8 @@ enum UsbRawTestCmd {
#define USB_RAW_IO_SLEEP_MS_TIME 500
#define USB_IO_THREAD_STACK_SIZE 8192
#define USB_BUFFER_MAX_SIZE 256
struct AcmRawDevice;
struct RawWb {
struct UsbRawRequest *request;
+2
View File
@@ -42,6 +42,7 @@ enum UsbTestCmd {
USB_HOSTSDK_CLOSE_INTERFACE_003_TEST,
USB_HOSTSDK_OPEN_INTERFACE_004_TEST,
USB_HOSTSDK_OPEN_INTERFACE_005_TEST,
USB_HOSTSDK_CLOSE_INTERFACE_005_TEST,
USB_HOSTSDK_OPEN_INTERFACE_006_TEST,
USB_HOSTSDK_SELECT_INTERFACE_001_TEST,
USB_HOSTSDK_SELECT_INTERFACE_002_TEST,
@@ -112,6 +113,7 @@ enum UsbTestCmd {
USB_HOSTSDK_ADD_INTERFACE_002_TEST,
USB_HOSTSDK_REMOVE_INTERFACE_003_TEST,
USB_HOSTSDK_ADD_INTERFACE_003_TEST,
USB_HOSTSDK_CLOSE_INTERFACE_006_TEST,
};
#define TARGET_MASK 0x3
@@ -78,6 +78,7 @@ int UsbStartIo(void)
int ret;
printf("%s start\n", __func__);
g_stopIoThreadFlag = false;
/* creat Io thread */
(void)memset_s(&threadCfg, sizeof(threadCfg), 0, sizeof(threadCfg));
@@ -106,13 +107,11 @@ int UsbStopIo(void)
int ret;
g_stopIoThreadFlag = true;
HDF_LOGD("%s:%d", __func__, __LINE__);
OsalMDelay(TEST_SLEEP_TIME);
ret = OsalThreadDestroy(&g_acm->ioThread);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s:%d OsalThreadDestroy faile, ret=%d ", __func__, __LINE__, ret);
return ret;
}
g_stopIoThreadFlag = false;
return HDF_SUCCESS;
}
+159 -38
View File
@@ -306,7 +306,7 @@ int32_t CheckRawSdkIfFillIsoRequest001(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(g_acm->isoReq, g_acm->devHandle, &reqData);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -333,7 +333,7 @@ int32_t CheckRawSdkIfFillIsoRequest002(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(NULL, g_acm->devHandle, &reqData);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -360,7 +360,7 @@ int32_t CheckRawSdkIfFillIsoRequest003(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(g_acm->isoReq, g_acm->devHandle, NULL);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -387,7 +387,7 @@ int32_t CheckRawSdkIfFillIsoRequest004(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(g_acm->isoReq, NULL, &reqData);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -414,7 +414,7 @@ int32_t CheckRawSdkIfFillIsoRequest005(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(NULL, NULL, &reqData);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -441,7 +441,7 @@ int32_t CheckRawSdkIfFillIsoRequest006(void)
reqData.length = size;
ret = UsbRawFillIsoRequest(NULL, NULL, NULL);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -570,60 +570,108 @@ int32_t CheckRawSdkIfAllocRequest009(void)
int32_t CheckRawSdkIfGetDescriptor001(void)
{
struct UsbRawDescriptorParam param;
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(NULL, g_acm->devHandle, &param, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor002(void)
{
struct UsbRawDescriptorParam param;
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(g_acm->ctrlReq, NULL, &param, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor003(void)
{
struct UsbRawDescriptorParam param;
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(NULL, NULL, &param, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor004(void)
{
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(g_acm->ctrlReq, g_acm->devHandle, NULL, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor005(void)
@@ -643,34 +691,58 @@ int32_t CheckRawSdkIfGetDescriptor005(void)
int32_t CheckRawSdkIfGetDescriptor006(void)
{
struct UsbRawDescriptorParam param;
unsigned char data[256];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
param.descType = USB_DESC_TYPE;
param.descIndex = 0;
param.length = sizeof(data);
param.length = USB_BUFFER_MAX_SIZE;
ret = UsbRawGetDescriptor(g_acm->ctrlReq, g_acm->devHandle, &param, data);
if (ret < 0) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor007(void)
{
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(g_acm->ctrlReq, NULL, NULL, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor008(void)
@@ -688,16 +760,28 @@ int32_t CheckRawSdkIfGetDescriptor008(void)
int32_t CheckRawSdkIfGetDescriptor009(void)
{
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(NULL, g_acm->devHandle, NULL, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor010(void)
@@ -740,16 +824,28 @@ int32_t CheckRawSdkIfGetDescriptor011(void)
int32_t CheckRawSdkIfGetDescriptor012(void)
{
unsigned char data[100];
unsigned char *data = NULL;
int ret;
data = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (data == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawGetDescriptor(NULL, NULL, NULL, data);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(data);
data = NULL;
return ret;
}
int32_t CheckRawSdkIfGetDescriptor013(void)
@@ -841,7 +937,7 @@ int32_t CheckRawSdkIfFillBulkRequest001(void)
printf("maxPacketSize:%d+snd->request:%p\n", g_acm->dataOutEp.maxPacketSize, snd->request);
ret = UsbRawFillBulkRequest(snd->request, g_acm->devHandle, &reqData);
if (ret) {
printf("%s: error++ret", __func__, ret);
printf("%s: error++ret=%d\n", __func__, ret);
return HDF_FAILURE;
}
}
@@ -1143,16 +1239,28 @@ int32_t CheckRawSdkIfFillControlSetup001(void)
int32_t CheckRawSdkIfFillControlSetup002(void)
{
unsigned char setup[100] = {0};
unsigned char *setup = NULL;
int ret;
setup = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (setup == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawFillControlSetup(setup, NULL);
if (ret != HDF_ERR_INVALID_PARAM) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
ret = HDF_SUCCESS;
error:
OsalMemFree(setup);
setup = NULL;
return ret;
}
int32_t CheckRawSdkIfFillControlSetup003(void)
@@ -1171,8 +1279,9 @@ int32_t CheckRawSdkIfFillControlSetup003(void)
int32_t CheckRawSdkIfFillControlSetup004(void)
{
struct UsbControlRequestData ctrlReq;
unsigned char setup[100] = {0};
unsigned char *setup = NULL;
int ret;
g_acm->lineCoding.dwDTERate = CpuToLe32(DATARATE);
g_acm->lineCoding.bCharFormat = CHARFORMAT;
g_acm->lineCoding.bParityType = USB_CDC_NO_PARITY;
@@ -1186,13 +1295,25 @@ int32_t CheckRawSdkIfFillControlSetup004(void)
ctrlReq.length = sizeof(struct UsbCdcLineCoding);
ctrlReq.timeout = USB_CTRL_SET_TIMEOUT;
setup = OsalMemCalloc(USB_BUFFER_MAX_SIZE);
if (setup == NULL) {
HDF_LOGE("%s:%d OsalMemCalloc error", __func__, __LINE__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UsbRawFillControlSetup(setup, &ctrlReq);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
ret = HDF_FAILURE;
goto error;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
error:
OsalMemFree(setup);
setup = NULL;
return ret;
}
int32_t CheckRawSdkIfSendControlRequest001(void)
+74 -6
View File
@@ -29,6 +29,7 @@ static UsbInterfaceHandle *g_ecmDataDevHandle = NULL;
static UsbInterfaceHandle *g_ecmIntDevHandle = NULL;
static bool g_initFlag;
static bool g_writeBufFlag = 0;
static UsbInterfaceHandle *g_acmDataDevHandle[USB_LOOP_NUM];
static void AcmReadBulk(struct UsbRequest *req)
{
@@ -498,8 +499,23 @@ static int32_t CheckHostSdkIfOpenInterface005(void)
{
int i;
for (i = 0; i < USB_LOOP_NUM; i++) {
g_acm->data_devHandle = UsbOpenInterface(g_acm->dataIface);
if (g_acm->data_devHandle == NULL) {
g_acmDataDevHandle[i] = UsbOpenInterface(g_acm->dataIface);
if (g_acmDataDevHandle[i] == NULL) {
HDF_LOGE("%s:%d i=%d error", __func__, __LINE__, i);
return HDF_FAILURE;
}
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
}
static int32_t CheckHostSdkIfCloseInterface005(void)
{
int i;
int ret;
for (i = 0; i < USB_LOOP_NUM; i++) {
ret = UsbCloseInterface(g_acmDataDevHandle[i]);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
@@ -689,6 +705,9 @@ static int32_t CheckHostSdkIfGetPipe002(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->dataIface->info.interfaceIndex;
*pi = p;
g_acm->dataInPipe = pi;
@@ -748,6 +767,9 @@ static int32_t CheckHostSdkIfGetPipe004(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_BULK)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->dataIface->info.interfaceIndex;
*pi = p;
g_acm->dataOutPipe = pi;
@@ -774,6 +796,9 @@ static int32_t CheckHostSdkIfGetPipe005(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_INTERRUPT)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->intIface->info.interfaceIndex;
*pi = p;
g_acm->intPipe = pi;
@@ -803,6 +828,9 @@ static int32_t CheckHostSdkIfGetPipe006(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_IN) && (p.pipeType == USB_PIPE_TYPE_INTERRUPT)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->intIface->info.interfaceIndex;
*pi = p;
g_acm->intPipe = pi;
@@ -830,6 +858,9 @@ static int32_t CheckHostSdkIfGetPipe007(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_CONTROL)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->interfaceIndex;
*pi = p;
g_acm->ctrPipe = pi;
@@ -860,6 +891,9 @@ static int32_t CheckHostSdkIfGetPipe008(void)
}
if ((p.pipeDirection == USB_PIPE_DIRECTION_OUT) && (p.pipeType == USB_PIPE_TYPE_CONTROL)) {
struct UsbPipeInfo *pi = (struct UsbPipeInfo *)OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
return HDF_FAILURE;
}
p.interfaceId = g_acm->interfaceIndex;
*pi = p;
g_acm->ctrPipe = pi;
@@ -1339,7 +1373,7 @@ static int32_t CheckHostSdkIfFillRequest001(void)
readParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
readParmas.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
readParmas.dataReq.numIsoPackets = 0;
readParmas.dataReq.directon = (UsbRequestDirection)((g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET)
readParmas.dataReq.directon = (UsbRequestDirection)(((uint32_t)g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET)
& DIRECTION_MASK);
readParmas.dataReq.length = g_acm->readSize;
ret = UsbFillRequest(g_acm->readReq[i], g_acm->data_devHandle, &readParmas);
@@ -1401,7 +1435,7 @@ static int32_t CheckHostSdkIfFillRequest003(void)
intParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
intParmas.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
intParmas.dataReq.numIsoPackets = 0;
intParmas.dataReq.directon = (UsbRequestDirection)((g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET)
intParmas.dataReq.directon = (UsbRequestDirection)(((uint32_t)g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET)
& DIRECTION_MASK);
intParmas.dataReq.length = g_acm->intSize;
ret = UsbFillRequest(g_acm->notifyReq, g_acm->int_devHandle, &intParmas);
@@ -1517,7 +1551,7 @@ static int32_t CheckHostSdkIfFillRequest005(void)
readParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
readParmas.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
readParmas.dataReq.numIsoPackets = 0;
readParmas.dataReq.directon = (UsbRequestDirection)((g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET)
readParmas.dataReq.directon = (UsbRequestDirection)(((uint32_t)g_acm->dataInPipe->pipeDirection >> USB_DIR_OFFSET)
& DIRECTION_MASK);
readParmas.dataReq.length = g_acm->readSize;
ret = UsbFillRequest(g_acm->readReq[i], g_acm->data_devHandle, &readParmas);
@@ -1577,7 +1611,7 @@ static int32_t CheckHostSdkIfFillRequest007(void)
intParmas.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
intParmas.timeout = USB_RAW_REQUEST_TIME_ZERO_MS;
intParmas.dataReq.numIsoPackets = 0;
intParmas.dataReq.directon = (UsbRequestDirection)((g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET)
intParmas.dataReq.directon = (UsbRequestDirection)(((uint32_t)g_acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET)
& DIRECTION_MASK);
intParmas.dataReq.length = g_acm->intSize;
ret = UsbFillRequest(g_acm->notifyReq, g_acm->int_devHandle, &intParmas);
@@ -1854,6 +1888,38 @@ static int32_t CheckHostSdkIfAddInterface003(void)
return HDF_SUCCESS;
}
static int32_t CheckHostSdkIfCloseInterface006(void)
{
int ret;
ret = UsbCloseInterface(g_ecmIntDevHandle);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
ret = UsbCloseInterface(g_ecmDataDevHandle);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
ret = UsbCloseInterface(g_acm->ctrl_devHandle);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
ret = UsbCloseInterface(g_acm->int_devHandle);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
ret = UsbCloseInterface(g_acm->data_devHandle);
if (ret) {
HDF_LOGE("%s: error", __func__);
return HDF_FAILURE;
}
HDF_LOGE("%s: success", __func__);
return HDF_SUCCESS;
}
struct UsbTestFunc g_usbTestFunc[] = {
{ USB_HOSTSDK_INIT_001_TEST, CheckHostSdkIfInit001},
{ Usb_HOSTSDK_EXIT_001_TEST, CheckHostSdkIfExit001},
@@ -1879,6 +1945,7 @@ struct UsbTestFunc g_usbTestFunc[] = {
{ USB_HOSTSDK_CLOSE_INTERFACE_003_TEST, CheckHostSdkIfCloseInterface003},
{ USB_HOSTSDK_OPEN_INTERFACE_004_TEST, CheckHostSdkIfOpenInterface004},
{ USB_HOSTSDK_OPEN_INTERFACE_005_TEST, CheckHostSdkIfOpenInterface005},
{ USB_HOSTSDK_CLOSE_INTERFACE_005_TEST, CheckHostSdkIfCloseInterface005},
{ USB_HOSTSDK_OPEN_INTERFACE_006_TEST, CheckHostSdkIfOpenInterface006},
{ USB_HOSTSDK_SELECT_INTERFACE_001_TEST, CheckHostSdkIfSelectInterfaceSetting001},
{ USB_HOSTSDK_SELECT_INTERFACE_002_TEST, CheckHostSdkIfSelectInterfaceSetting002},
@@ -1947,6 +2014,7 @@ struct UsbTestFunc g_usbTestFunc[] = {
{ USB_HOSTSDK_ADD_INTERFACE_002_TEST, CheckHostSdkIfAddInterface002},
{ USB_HOSTSDK_REMOVE_INTERFACE_003_TEST, CheckHostSdkIfRemoveInterface003},
{ USB_HOSTSDK_ADD_INTERFACE_003_TEST, CheckHostSdkIfAddInterface003},
{ USB_HOSTSDK_CLOSE_INTERFACE_006_TEST, CheckHostSdkIfCloseInterface006},
};
int32_t UsbTestEntry(int32_t cmd)