Lines Matching defs:ecm

55     if (port->ecm == NULL) {
67 len = DataFifoRead(&port->writeFifo, req->buf, port->ecm->dataInPipe.maxPacketSize);
83 /* if ecm is disconnect, abort immediately */
84 if (port->ecm == NULL) {
94 struct UsbEcmPipe *out = &port->ecm->dataOutPipe;
114 /* if ecm is disconnect, abort immediately */
115 if (port->ecm == NULL) {
160 if (!disconnect && port->ecm) {
199 HDF_LOGV("%{public}s: ecm device was disconnected", __func__);
210 struct UsbEcmDevice *ecm = port->ecm;
216 req = UsbFnAllocRequest(ecm->dataIface.handle, ecm->dataOutPipe.id, ecm->dataOutPipe.maxPacketSize);
231 struct UsbEcmDevice *ecm = port->ecm;
237 req = UsbFnAllocRequest(ecm->dataIface.handle, ecm->dataInPipe.id, ecm->dataInPipe.maxPacketSize);
324 /* the ecm is enabled, start the io stream */
325 if (port->ecm) {
399 if (port->ecm) {
423 if (port->ecm) {
430 void UsbFnNotifyRequest(struct UsbFnRequest *req, struct UsbEcmDevice *ecm)
433 ecm->notifyReq = NULL;
436 ecm->notifyReq = req;
441 static void EcmDoNotify(struct UsbEcmDevice *ecm)
443 struct UsbFnRequest *req = ecm->notifyReq;
450 ecm->isOpen = true;
455 switch (ecm->notifyState) {
461 if (ecm->isOpen) {
469 HDF_LOGD("notify connect %{public}s", ecm->isOpen ? "true" : "false");
470 ecm->notifyState = ECM_NOTIFY_SPEED;
485 ecm->notifyState = ECM_NOTIFY_NONE;
492 event->wIndex = CPU_TO_LE16(ecm->ctrlId);
493 UsbFnNotifyRequest(req, ecm);
498 struct UsbEcmDevice *ecm = req->context;
500 ecm->notifyReq = req;
502 EcmDoNotify(ecm);
508 static int32_t EcmSetup(const struct UsbEcmDevice *ecm, const struct UsbFnCtrlRequest *ctrl)
510 struct UsbFnRequest *req = ecm->ep0Req;
519 if (length != 0 || index != ecm->ctrlId) {
533 HDF_LOGD("ecm req%{public}02x.%{public}02x v%{public}04x i%{public}04x l%{public}d",
538 HDF_LOGD("ecm req %{public}02x.%{public}02x response err %{public}d", ctrl->reqType, ctrl->request, ret);
548 struct UsbEcmDevice *ecm = NULL;
573 ecm = (struct UsbEcmDevice *)client->device->service;
574 port = ecm->port;
600 static int32_t EcmEnable(struct UsbEcmDevice *ecm)
602 (void)ecm;
606 static void EcmDisable(const struct UsbEcmDevice *ecm)
608 (void)ecm;
614 struct UsbEcmDevice *ecm = NULL;
621 ecm = (struct UsbEcmDevice *)event->context;
631 EcmEnable(ecm);
635 EcmDisable(ecm);
640 EcmSetup(ecm, event->setup);
654 static int32_t EcmAllocNotifyRequest(struct UsbEcmDevice *ecm)
657 ecm->notifyReq =
658 UsbFnAllocRequest(ecm->ctrlIface.handle, ecm->notifyPipe.id, sizeof(struct UsbCdcNotification) * USBCDC_LEN);
659 if (ecm->notifyReq == NULL) {
663 ecm->notifyReq->complete = EcmNotifyComplete;
664 ecm->notifyReq->context = ecm;
669 static int32_t EcmAllocEp0Request(struct UsbEcmDevice *ecm)
672 ecm->ep0Req = UsbFnAllocCtrlRequest(ecm->ctrlIface.handle, ECM_STATUS_BYTECOUNT);
673 if (ecm->ep0Req == NULL) {
680 static int32_t EcmParseEachPipe(struct UsbEcmDevice *ecm, struct UsbEcmInterface *iface)
695 ecm->notifyPipe.id = pipeInfo.id;
696 ecm->notifyPipe.maxPacketSize = pipeInfo.maxPacketSize;
697 ecm->ctrlIface = *iface;
701 ecm->dataInPipe.id = pipeInfo.id;
702 ecm->dataInPipe.maxPacketSize = pipeInfo.maxPacketSize;
703 ecm->dataIface = *iface;
705 ecm->dataOutPipe.id = pipeInfo.id;
706 ecm->dataOutPipe.maxPacketSize = pipeInfo.maxPacketSize;
723 static int32_t EcmParseEcmIface(struct UsbEcmDevice *ecm, struct UsbFnInterface *fnIface)
735 ret = EcmParseEachPipe(ecm, &iface);
742 static int32_t EcmParseEachIface(struct UsbEcmDevice *ecm, struct UsbFnDevice *fnDev)
755 (void)EcmParseEcmIface(ecm, fnIface);
761 (void)EcmParseEcmIface(ecm, fnIface);
769 static int32_t EcmCreateFuncDevice(struct UsbEcmDevice *ecm, struct DeviceResourceIface *iface)
774 if (iface->GetString(ecm->device->property, "udc_name", (const char **)&ecm->udcName, UDC_NAME) != HDF_SUCCESS) {
779 fnDev = (struct UsbFnDevice *)UsbFnGetDevice(ecm->udcName);
785 ret = EcmParseEachIface(ecm, fnDev);
791 ecm->fnDev = fnDev;
798 static void EcmFreeNotifyRequest(struct UsbEcmDevice *ecm)
803 ret = UsbFnFreeRequest(ecm->notifyReq);
808 ecm->notifyReq = NULL;
811 static int32_t EcmReleaseFuncDevice(struct UsbEcmDevice *ecm)
814 if (ecm->fnDev == NULL) {
818 (void)UsbFnFreeRequest(ecm->ep0Req);
819 (void)EcmFreeNotifyRequest(ecm);
820 UsbFnCloseInterface(ecm->ctrlIface.handle);
821 (void)UsbFnCloseInterface(ecm->dataIface.handle);
822 (void)UsbFnStopRecvInterfaceEvent(ecm->ctrlIface.fn);
826 static int32_t UsbEcmAlloc(struct UsbEcmDevice *ecm)
869 ecm->port = port;
873 static void UsbEcmFree(struct UsbEcmDevice *ecm)
875 if (ecm != NULL && ecm->port != NULL) {
876 OsalMutexDestroy(&ecm->port->lock);
877 OsalMutexDestroy(&ecm->port->lockRW);
878 OsalMutexDestroy(&ecm->port->lockReadFifo);
879 OsalMutexDestroy(&ecm->port->lockWriteFifo);
880 OsalMemFree(ecm->port);
881 ecm->port = NULL;
888 struct UsbEcmDevice *ecm = NULL;
895 ecm = (struct UsbEcmDevice *)OsalMemCalloc(sizeof(*ecm));
896 if (ecm == NULL) {
897 HDF_LOGE("%{public}s: Alloc usb ecm device failed", __func__);
900 ecm->ctrlId = 0;
901 ecm->dataId = 1;
902 if (OsalMutexInit(&ecm->lock) != HDF_SUCCESS) {
904 OsalMemFree(ecm);
910 OsalMemFree(ecm);
914 ecm->device = device;
915 device->service = &(ecm->service);
916 if (ecm->device->service) {
917 ecm->device->service->Dispatch = EcmDeviceDispatch;
924 struct UsbEcmDevice *ecm = NULL;
933 ecm = (struct UsbEcmDevice *)device->service;
934 if (ecm == NULL || ecm->initFlag) {
935 HDF_LOGE("%{public}s: ecm is null", __func__);
945 ret = EcmCreateFuncDevice(ecm, iface);
951 ret = UsbEcmAlloc(ecm);
957 ret = EcmAllocEp0Request(ecm);
963 ret = EcmAllocNotifyRequest(ecm);
969 ret = UsbFnStartRecvInterfaceEvent(ecm->ctrlIface.fn, RECEIVE_ALL_EVENTS, UsbEcmEventCallback, ecm);
974 ecm->initFlag = true;
977 UsbEcmFree(ecm);
978 (void)EcmReleaseFuncDevice(ecm);
984 struct UsbEcmDevice *ecm = NULL;
991 ecm = (struct UsbEcmDevice *)device->service;
992 if (ecm == NULL) {
993 HDF_LOGE("%{public}s: ecm is null", __func__);
996 if (ecm->initFlag == false) {
997 HDF_LOGE("%{public}s: ecm not init!", __func__);
1000 UsbEcmFree(ecm);
1001 (void)EcmReleaseFuncDevice(ecm);
1002 ecm->initFlag = false;
1015 struct UsbEcmDevice *ecm = NULL;
1021 ecm = (struct UsbEcmDevice *)device->service;
1022 if (ecm == NULL) {
1023 HDF_LOGE("%{public}s: ecm is null", __func__);
1027 (void)OsalMutexDestroy(&ecm->lock);
1028 OsalMemFree(ecm);