1173 iEndpointStatusChangePtr(NULL), |
1173 iEndpointStatusChangePtr(NULL), |
1174 iEndpointStatusCallbackInfo(this, DLddUsbcScChannel::EndpointStatusChangeCallback, |
1174 iEndpointStatusCallbackInfo(this, DLddUsbcScChannel::EndpointStatusChangeCallback, |
1175 KUsbRequestCallbackPriority), |
1175 KUsbRequestCallbackPriority), |
1176 iOtgFeatureChangePtr(NULL), |
1176 iOtgFeatureChangePtr(NULL), |
1177 iOtgFeatureCallbackInfo(this, DLddUsbcScChannel::OtgFeatureChangeCallback, KUsbRequestCallbackPriority), |
1177 iOtgFeatureCallbackInfo(this, DLddUsbcScChannel::OtgFeatureChangeCallback, KUsbRequestCallbackPriority), |
|
1178 iChargerTypeChangePtr(NULL), |
|
1179 iChargerTypeCallbackInfo(this, DLddUsbcScChannel::ChargerTypeChangeCallback, KUsbRequestCallbackPriority), |
1178 iNumberOfEndpoints(0), |
1180 iNumberOfEndpoints(0), |
1179 iDeviceState(UsbShai::EUsbPeripheralStateUndefined), |
1181 iDeviceState(UsbShai::EUsbPeripheralStateUndefined), |
1180 iOwnsDeviceControl(EFalse), |
1182 iOwnsDeviceControl(EFalse), |
1181 iAlternateSetting(0), |
1183 iAlternateSetting(0), |
1182 iAsSeq(0), |
1184 iAsSeq(0), |
1211 { |
1213 { |
1212 iController->DeRegisterClient(this); |
1214 iController->DeRegisterClient(this); |
1213 iStatusCallbackInfo.Cancel(); |
1215 iStatusCallbackInfo.Cancel(); |
1214 iEndpointStatusCallbackInfo.Cancel(); |
1216 iEndpointStatusCallbackInfo.Cancel(); |
1215 iOtgFeatureCallbackInfo.Cancel(); |
1217 iOtgFeatureCallbackInfo.Cancel(); |
|
1218 iChargerTypeCallbackInfo.Cancel(); |
1216 iCompleteAllCallbackInfo.Cancel(); |
1219 iCompleteAllCallbackInfo.Cancel(); |
1217 DestroyAllInterfaces(); |
1220 DestroyAllInterfaces(); |
1218 if (iOwnsDeviceControl) |
1221 if (iOwnsDeviceControl) |
1219 { |
1222 { |
1220 iController->ReleaseDeviceControl(this); |
1223 iController->ReleaseDeviceControl(this); |
1286 SetDfcQ(iController->DfcQ(0)); // sets the channel's dfc queue |
1289 SetDfcQ(iController->DfcQ(0)); // sets the channel's dfc queue |
1287 iCompleteAllCallbackInfo.SetDfcQ(iDfcQ); |
1290 iCompleteAllCallbackInfo.SetDfcQ(iDfcQ); |
1288 iStatusCallbackInfo.SetDfcQ(iDfcQ); // use the channel's dfcq for this dfc |
1291 iStatusCallbackInfo.SetDfcQ(iDfcQ); // use the channel's dfcq for this dfc |
1289 iEndpointStatusCallbackInfo.SetDfcQ(iDfcQ); // use the channel's dfcq for this dfc |
1292 iEndpointStatusCallbackInfo.SetDfcQ(iDfcQ); // use the channel's dfcq for this dfc |
1290 iOtgFeatureCallbackInfo.SetDfcQ(iDfcQ); |
1293 iOtgFeatureCallbackInfo.SetDfcQ(iDfcQ); |
|
1294 iChargerTypeCallbackInfo.SetDfcQ(iDfcQ); |
1291 iMsgQ.Receive(); //start up the message q |
1295 iMsgQ.Receive(); //start up the message q |
1292 TInt r = iController->RegisterClientCallback(iCompleteAllCallbackInfo); |
1296 TInt r = iController->RegisterClientCallback(iCompleteAllCallbackInfo); |
1293 if (r != KErrNone) |
1297 if (r != KErrNone) |
1294 return r; |
1298 return r; |
1295 r = iController->RegisterForStatusChange(iStatusCallbackInfo); |
1299 r = iController->RegisterForStatusChange(iStatusCallbackInfo); |
1422 { |
1429 { |
1423 __KTRACE_OPT(KUSB, Kern::Printf("ERequestOtgFeaturesNotify")); |
1430 __KTRACE_OPT(KUSB, Kern::Printf("ERequestOtgFeaturesNotify")); |
1424 BREAK_IF_NULL_ARG(a1,r); |
1431 BREAK_IF_NULL_ARG(a1,r); |
1425 |
1432 |
1426 iOtgFeatureChangePtr = a1; |
1433 iOtgFeatureChangePtr = a1; |
|
1434 break; |
|
1435 } |
|
1436 case RDevUsbcScClient::ERequestChargingPortTypeNotify: |
|
1437 { |
|
1438 __KTRACE_OPT(KUSB, Kern::Printf("ERequestChargingPortTypeNotify")); |
|
1439 BREAK_IF_NULL_ARG(a1,r); |
|
1440 |
|
1441 iChargerTypeChangePtr = a1; |
|
1442 needsCompletion = iChargerTypeCallbackInfo.PendingNotify(); |
|
1443 if(needsCompletion) |
|
1444 { |
|
1445 TUint chargerType; |
|
1446 chargerType = iChargerTypeCallbackInfo.ChargerType(); |
|
1447 TInt r=Kern::ThreadRawWrite(iClient, iChargerTypeChangePtr, (TUint*)&chargerType, sizeof(chargerType), iClient); |
|
1448 if (r != KErrNone) |
|
1449 PanicClientThread(r); |
|
1450 iChargerTypeChangePtr = NULL; |
|
1451 iChargerTypeCallbackInfo.SetPendingNotify(EFalse); |
|
1452 } |
1427 break; |
1453 break; |
1428 } |
1454 } |
1429 default: |
1455 default: |
1430 r = KErrNotSupported; |
1456 r = KErrNotSupported; |
1431 } |
1457 } |
1647 case RDevUsbcScClient::ERequestOtgFeaturesNotifyCancel: |
1673 case RDevUsbcScClient::ERequestOtgFeaturesNotifyCancel: |
1648 __KTRACE_OPT(KUSB, Kern::Printf("DoCancel ERequestOtgFeaturesNotify: 0x%x", aReqNo)); |
1674 __KTRACE_OPT(KUSB, Kern::Printf("DoCancel ERequestOtgFeaturesNotify: 0x%x", aReqNo)); |
1649 CancelNotifyOtgFeatures(); |
1675 CancelNotifyOtgFeatures(); |
1650 break; |
1676 break; |
1651 |
1677 |
1652 default: |
1678 case RDevUsbcScClient::ERequestChargingPortTypeNotifyCancel: |
1653 __KTRACE_OPT(KUSB, Kern::Printf("DoCancel Unknown! 0x%x", aReqNo)); |
1679 __KTRACE_OPT(KUSB, Kern::Printf("DoCancel ERequestChargingPortTypeNotify: 0x%x", aReqNo)); |
1654 return KErrArgument; |
1680 CancelNotifyChargerType(); |
1655 } |
1681 break; |
|
1682 |
|
1683 default: |
|
1684 __KTRACE_OPT(KUSB, Kern::Printf("DoCancel Unknown! 0x%x", aReqNo)); |
|
1685 return KErrArgument; |
|
1686 } |
1656 |
1687 |
1657 Kern::RequestComplete(iClient,iRequestStatus[aReqNo & ~RDevUsbcScClient::ERequestCancel], KErrCancel); |
1688 Kern::RequestComplete(iClient,iRequestStatus[aReqNo & ~RDevUsbcScClient::ERequestCancel], KErrCancel); |
1658 return r; |
1689 return r; |
1659 } |
1690 } |
1660 |
1691 |
1689 PanicClientThread(r); |
1720 PanicClientThread(r); |
1690 iOtgFeatureChangePtr = NULL; |
1721 iOtgFeatureChangePtr = NULL; |
1691 } |
1722 } |
1692 } |
1723 } |
1693 |
1724 |
1694 |
1725 void DLddUsbcScChannel::CancelNotifyChargerType() |
|
1726 { |
|
1727 if (iChargerTypeChangePtr) |
|
1728 { |
|
1729 TUint chargerType; |
|
1730 chargerType = iChargerTypeCallbackInfo.ChargerType(); |
|
1731 TInt r=Kern::ThreadRawWrite(iClient, iChargerTypeChangePtr, (TUint*)&chargerType, sizeof(chargerType), iClient); |
|
1732 if (r != KErrNone) |
|
1733 PanicClientThread(r); |
|
1734 iChargerTypeChangePtr = NULL; |
|
1735 iChargerTypeCallbackInfo.SetPendingNotify(EFalse); |
|
1736 } |
|
1737 } |
1695 |
1738 |
1696 // |
1739 // |
1697 // DoControl - Synchronous requests |
1740 // DoControl - Synchronous requests |
1698 // |
1741 // |
1699 // Called from HandleMsg. |
1742 // Called from HandleMsg. |
1708 TPtrC8 pZeroDesc(NULL, 0); |
1751 TPtrC8 pZeroDesc(NULL, 0); |
1709 TEndpointDescriptorInfo epInfo; |
1752 TEndpointDescriptorInfo epInfo; |
1710 TUsbcScIfcInfo ifcInfo; |
1753 TUsbcScIfcInfo ifcInfo; |
1711 TCSDescriptorInfo desInfo; |
1754 TCSDescriptorInfo desInfo; |
1712 TUsbcEndpointResource epRes; |
1755 TUsbcEndpointResource epRes; |
|
1756 TUsbcChargerDetectorProperties chargingPro; |
1713 |
1757 |
1714 switch (aFunction) |
1758 switch (aFunction) |
1715 { |
1759 { |
1716 case RDevUsbcScClient::EControlEndpointZeroRequestError: |
1760 case RDevUsbcScClient::EControlEndpointZeroRequestError: |
1717 __KTRACE_OPT(KUSB, Kern::Printf("EControlEndpointZeroRequestError")); |
1761 __KTRACE_OPT(KUSB, Kern::Printf("EControlEndpointZeroRequestError")); |
2058 r = Kern::ThreadRawRead(iClient, a2, &ifcInfo, sizeof(ifcInfo)); |
2102 r = Kern::ThreadRawRead(iClient, a2, &ifcInfo, sizeof(ifcInfo)); |
2059 if (r != KErrNone) |
2103 if (r != KErrNone) |
2060 PanicClientThread(r); |
2104 PanicClientThread(r); |
2061 r = SetInterface((TInt) a1, &ifcInfo); |
2105 r = SetInterface((TInt) a1, &ifcInfo); |
2062 break; |
2106 break; |
|
2107 |
|
2108 |
|
2109 case RDevUsbcScClient::EControlGetChargerDetectorCaps: |
|
2110 __KTRACE_OPT(KUSB, Kern::Printf("EControlGetChargerDetectorCaps")); |
|
2111 iController->ChargerDetectorCaps(chargingPro); |
|
2112 r = Kern::ThreadRawWrite(iClient, a1, &chargingPro, sizeof(chargingPro), iClient); |
|
2113 if (r != KErrNone) |
|
2114 { |
|
2115 PanicClientThread(r); |
|
2116 } |
|
2117 break; |
2063 |
2118 |
2064 case RDevUsbcScClient::EControlReleaseInterface: |
2119 case RDevUsbcScClient::EControlReleaseInterface: |
2065 __KTRACE_OPT(KUSB, Kern::Printf("EControlReleaseInterface")); |
2120 __KTRACE_OPT(KUSB, Kern::Printf("EControlReleaseInterface")); |
2066 if (!iRealizeCalled) |
2121 if (!iRealizeCalled) |
2067 { |
2122 { |
3054 Kern::RequestComplete(dUsbc->iClient, dUsbc->iRequestStatus[reqNo], r); |
3109 Kern::RequestComplete(dUsbc->iClient, dUsbc->iRequestStatus[reqNo], r); |
3055 dUsbc->iOtgFeatureChangePtr = NULL; |
3110 dUsbc->iOtgFeatureChangePtr = NULL; |
3056 } |
3111 } |
3057 } |
3112 } |
3058 |
3113 |
|
3114 void DLddUsbcScChannel::ChargerTypeChangeCallback(TAny* aDLddUsbcScChannel) |
|
3115 { |
|
3116 __KTRACE_OPT(KUSB, Kern::Printf("ChargerTypeChangeCallback")); |
|
3117 DLddUsbcScChannel* dUsbc = (DLddUsbcScChannel*) aDLddUsbcScChannel; |
|
3118 if (dUsbc->iChannelClosing) |
|
3119 return; |
|
3120 |
|
3121 const TInt reqNo = (TInt) RDevUsbcScClient::ERequestChargingPortTypeNotify; |
|
3122 if (dUsbc->iRequestStatus[reqNo]) |
|
3123 { |
|
3124 __KTRACE_OPT(KUSB, Kern::Printf("ChargerTypeChangeCallback Notify status")); |
|
3125 TUint chargerType; |
|
3126 chargerType = dUsbc->iChargerTypeCallbackInfo.ChargerType(); |
|
3127 TInt r=Kern::ThreadRawWrite(dUsbc->iClient, dUsbc->iChargerTypeChangePtr, (TUint*)&chargerType, sizeof(chargerType), dUsbc->iClient); |
|
3128 if (r != KErrNone) |
|
3129 dUsbc->PanicClientThread(r); |
|
3130 Kern::RequestComplete(dUsbc->iClient, dUsbc->iRequestStatus[reqNo], r); |
|
3131 dUsbc->iChargerTypeChangePtr = NULL; |
|
3132 dUsbc->iChargerTypeCallbackInfo.SetPendingNotify(EFalse); |
|
3133 } |
|
3134 else |
|
3135 { |
|
3136 __KTRACE_OPT(KUSB, Kern::Printf("ChargerTypeChangeCallback Set pending notify")); |
|
3137 dUsbc->iChargerTypeCallbackInfo.SetPendingNotify(ETrue); |
|
3138 } |
|
3139 } |
3059 |
3140 |
3060 // |
3141 // |
3061 // SelectAlternateSetting |
3142 // SelectAlternateSetting |
3062 // |
3143 // |
3063 |
3144 |
3399 } |
3480 } |
3400 } |
3481 } |
3401 iStatusCallbackInfo.Cancel(); |
3482 iStatusCallbackInfo.Cancel(); |
3402 iEndpointStatusCallbackInfo.Cancel(); |
3483 iEndpointStatusCallbackInfo.Cancel(); |
3403 iOtgFeatureCallbackInfo.Cancel(); |
3484 iOtgFeatureCallbackInfo.Cancel(); |
3404 |
3485 iChargerTypeCallbackInfo.Cancel(); |
3405 return KErrNone; |
3486 return KErrNone; |
3406 } |
3487 } |
3407 |
3488 |
3408 |
3489 |
3409 void DLddUsbcScChannel::PanicClientThread(TInt aReason) |
3490 void DLddUsbcScChannel::PanicClientThread(TInt aReason) |
3410 { |
3491 { |
3411 Kern::ThreadKill(iClient, EExitPanic, aReason, KUsbLDDKillCat); |
3492 Kern::ThreadKill(iClient, EExitPanic, aReason, KUsbLDDKillCat); |