OTGHNP_EventNotify
函数CHub::IdentifyOTGDevice中对m_bOtgDescriptor进行赋值
m_bOtgDescriptor = m_bOtgDesc[2];
函数CDevice::CreateUsbConfigurationStructure中对m_bOtgDesc进行了赋值:
//identify the OTG descriptor
memset((PVOID)&m_bOtgDesc[0], 0, 3);
memcpy((PVOID)&m_bOtgDesc[0], pDataBuffer + offset, 3);
函数CHub::GetOtgDescriptor返回m_bOtgDescriptor:
return m_bOtgDescriptor;
函数HcdMdd_GetOTGDescAttr调用了函数CHub::GetOtgDescriptor:
CHcd * pobHcd = (CHcd *)lpvHcdObject;
return pobHcd->m_pCRootHub->GetOtgDescriptor();
函数HcdPdd_GetOTGDescAttr调用了函数HcdMdd_GetOTGDescAttr:
SEHCDPdd * pPddObject = (SEHCDPdd *)hDeviceContext;
return HcdMdd_GetOTGDescAttr(pPddObject->lpvEHCDMddObject);
函数HCD_GetOTGDescAttr调用了函数HcdPdd_GetOTGDescAttr:
return HcdPdd_GetOTGDescAttr(g_dwPddContext);
函数OTGHNP_EventNotify中,判断event类型,若为HNP_EVENT_HOST_OTGDESC:
调用函数HCD_GetOTGDescAttr获取OTG descriptor属性。
根据获取的数据,设置g_RmtDevInfo的参数。
g_RmtDevInfo; // Information of the remote device
if (dwData & OTG_ATTR_HNP_SUPPORT)
g_RmtDevInfo.m_dwRmtDevAttr = OTG_RMTATTR_B_SRP | OTG_RMTATTR_B_HNP;
else if (dwData & OTG_ATTR_SRP_SUPPORT)
g_RmtDevInfo.m_dwRmtDevAttr = OTG_RMTATTR_B_SRP;
else
g_RmtDevInfo.m_dwRmtDevAttr = 0;
if (g_RmtDevInfo.m_dwRmtDevAttr)
g_RmtDevInfo.m_dwRmtDevType = OTG_RMTDEV_B;
调用函数OTG_EventNotify写event MSG。
OTG_EventNotify(OTG_EVENT_STATE_CHANGED + 1);
函数OTG_EventNotify中:
如果g_OtgCoreInfo.m_hMsgQ不为空:
调用函数OS_WriteMsgQ往g_OtgCoreInfo.m_hMsgQ中写入MSG。
OS_WriteMsgQ(g_OtgCoreInfo.m_hMsgQ, (PVOID)&dwNotifyCode, sizeof(DWORD))
函数OS_WriteMsgQ调用函数WriteMsgQueue。
return WriteMsgQueue(hMsgQ, pBuffer, cbBufSize, 0, 0);