BOOL PCIE_SW_IntIsEnabled(WDC_DEVICE_HANDLE hDev) { if (!IsValidDevice((PWDC_DEVICE)hDev, "PCIE_SW_IntIsEnabled")) return FALSE; return WDC_IntIsEnabled(hDev); }
ECode BluetoothA2dpSink::SetPriority( /* [in] */ IBluetoothDevice* device, /* [in] */ Int32 priority, /* [out] */ Boolean* result) { String str; IObject::Probe(device)->ToString(&str); if (VDBG) Logger::D(TAG, String("setPriority(") + str + ", " + StringUtils::ToString(priority) + ")"); *result = FALSE; if (mService != NULL && IsEnabled() && IsValidDevice(device)) { if (priority != IBluetoothProfile::PRIORITY_OFF && priority != IBluetoothProfile::PRIORITY_ON){ return NOERROR; } // try { if (FAILED(mService->SetPriority(device, priority, result))) { Logger::E(TAG, "SetPriority: Remote invoke error"); } // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // *result = false; // return NOERROR; // } } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); return NOERROR; }
BOOL PCIE_SW_EventIsRegistered(WDC_DEVICE_HANDLE hDev) { if (!IsValidDevice((PWDC_DEVICE)hDev, "PCIE_SW_EventIsRegistered")) return FALSE; return WDC_EventIsRegistered(hDev); }
DWORD PCIE_SW_EventUnregister(WDC_DEVICE_HANDLE hDev) { DWORD dwStatus; TraceLog("PCIE_SW_EventUnregister entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice((PWDC_DEVICE)hDev, "PCIE_SW_EventUnregister")) return WD_INVALID_PARAMETER; if (!WDC_EventIsRegistered(hDev)) { ErrLog("Cannot unregister events - no events currently registered ...\n"); return WD_OPERATION_ALREADY_DONE; } dwStatus = WDC_EventUnregister(hDev); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed to unregister events. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); } return dwStatus; }
ECode BluetoothMap::SetPriority( /* [in] */ IBluetoothDevice* device, /* [in] */ Int32 priority, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result); if (DBG) Logger::D(TAG, "setPriority(");// + device + ", " + priority + ")"); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { if (priority != IBluetoothProfile::PRIORITY_OFF && priority != IBluetoothProfile::PRIORITY_ON) { *result = FALSE; return NOERROR; } //try { return mService->SetPriority(device, priority, result); //} catch (RemoteException e) { // Logger::E(TAG, Log.getStackTraceString(new Throwable())); // return FALSE; //} } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = FALSE; return NOERROR; }
DWORD PCIE_SW_IntDisable(WDC_DEVICE_HANDLE hDev) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PPCIE_SW_DEV_CTX pDevCtx; TraceLog("PCIE_SW_IntDisable entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "PCIE_SW_IntDisable")) return WD_INVALID_PARAMETER; pDevCtx = (PPCIE_SW_DEV_CTX)WDC_GetDevContext(pDev); if (!WDC_IntIsEnabled(hDev)) { ErrLog("Interrupts are already disabled ...\n"); return WD_OPERATION_ALREADY_DONE; } /* TODO: You can add code here to write to the device in order to physically disable the hardware interrupts */ /* Disable the interrupts */ dwStatus = WDC_IntDisable(hDev); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed disabling interrupts. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); } return dwStatus; }
static int SerparMatch(const char *name, const char *arg) { char sername[2]; char parname[2]; UNUSED(arg); sername[0] = name[0]; parname[0] = name[1]; sername[1] = parname[1] = 0; if (IsValidDevice(sername) == COM_DEVICENOTVALID || IsValidDevice(parname) == COM_DEVICENOTVALID) return -1; else return 0; }
DWORD PCIE_SW_IntEnable(WDC_DEVICE_HANDLE hDev, PCIE_SW_INT_HANDLER funcIntHandler) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PPCIE_SW_DEV_CTX pDevCtx; TraceLog("PCIE_SW_IntEnable entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "PCIE_SW_IntEnable")) return WD_INVALID_PARAMETER; if (!IsItemExists(pDev, ITEM_INTERRUPT)) return WD_OPERATION_FAILED; pDevCtx = (PPCIE_SW_DEV_CTX)WDC_GetDevContext(pDev); /* Check if interrupts are already enabled */ if (WDC_IntIsEnabled(hDev)) { ErrLog("Interrupts are already enabled ...\n"); return WD_OPERATION_ALREADY_DONE; } /* Define the number of interrupt transfer commands to use */ #define NUM_TRANS_CMDS 0 /* NOTE: In order to correctly handle PCI interrupts, you need to ADD CODE HERE to set up transfer commands to read/write the relevant register(s) in order to correctly acknowledge the interrupts, as dictated by your hardware's specifications. When adding transfer commands, be sure to also modify the definition of NUM_TRANS_CMDS (above) accordingly. */ /* Store the diag interrupt handler routine, which will be executed by PCIE_SW_IntHandler() when an interrupt is received */ pDevCtx->funcDiagIntHandler = funcIntHandler; /* Enable the interrupts */ /* NOTE: When adding read transfer commands, set the INTERRUPT_CMD_COPY flag in the 4th argument (dwOptions) passed to WDC_IntEnable() */ dwStatus = WDC_IntEnable(hDev, NULL, 0, 0, PCIE_SW_IntHandler, (PVOID)pDev, WDC_IS_KP(hDev)); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed enabling interrupts. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); return dwStatus; } /* TODO: You can add code here to write to the device in order to physically enable the hardware interrupts */ TraceLog("PCIE_SW_IntEnable: Interrupts enabled\n"); return WD_STATUS_SUCCESS; }
/* ----------------------------------------------- Address spaces information ----------------------------------------------- */ DWORD PCIE_SW_GetNumAddrSpaces(WDC_DEVICE_HANDLE hDev) { PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; if (!IsValidDevice(pDev, "PCIE_SW_GetNumAddrSpaces")) return 0; return pDev->dwNumAddrSpaces; }
static int SerialMatch(const char *name, const char *arg) { UNUSED(arg); #ifdef COMPILING_ON_WINDOWS if (IsValidDevice(name) == COM_DEVICENOTVALID) return -1; else return 0; #else return Unix_MatchValidSerialDevice(name) == 0 ? -1 : 0; #endif }
BOOL PCIE_SW_GetAddrSpaceInfo(WDC_DEVICE_HANDLE hDev, PCIE_SW_ADDR_SPACE_INFO *pAddrSpaceInfo) { PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; WDC_ADDR_DESC *pAddrDesc; DWORD dwAddrSpace, dwMaxAddrSpace; BOOL fIsMemory; if (!IsValidDevice(pDev, "PCIE_SW_GetAddrSpaceInfo")) return FALSE; #if defined(DEBUG) if (!pAddrSpaceInfo) { ErrLog("PCIE_SW_GetAddrSpaceInfo: Error - NULL address space information pointer\n"); return FALSE; } #endif dwAddrSpace = pAddrSpaceInfo->dwAddrSpace; dwMaxAddrSpace = pDev->dwNumAddrSpaces - 1; if (dwAddrSpace > dwMaxAddrSpace) { ErrLog("PCIE_SW_GetAddrSpaceInfo: Error - Address space %ld is out of range (0 - %ld)\n", dwAddrSpace, dwMaxAddrSpace); return FALSE; } pAddrDesc = &pDev->pAddrDesc[dwAddrSpace]; fIsMemory = WDC_ADDR_IS_MEM(pAddrDesc); snprintf(pAddrSpaceInfo->sName, MAX_NAME - 1, "BAR %ld", dwAddrSpace); snprintf(pAddrSpaceInfo->sType, MAX_TYPE - 1, fIsMemory ? "Memory" : "I/O"); if (WDC_AddrSpaceIsActive(pDev, dwAddrSpace)) { WD_ITEMS *pItem = &pDev->cardReg.Card.Item[pAddrDesc->dwItemIndex]; DWORD dwAddr = fIsMemory ? pItem->I.Mem.dwPhysicalAddr : (DWORD)pItem->I.IO.dwAddr; snprintf(pAddrSpaceInfo->sDesc, MAX_DESC - 1, "0x%0*lX - 0x%0*lX (0x%lx bytes)", (int)WDC_SIZE_32 * 2, dwAddr, (int)WDC_SIZE_32 * 2, dwAddr + pAddrDesc->dwBytes - 1, pAddrDesc->dwBytes); } else snprintf(pAddrSpaceInfo->sDesc, MAX_DESC - 1, "Inactive address space"); /* TODO: You can modify the code above to set a different address space name/description */ return TRUE; }
DWORD EDEN_IntEnable(WDC_DEVICE_HANDLE hDev, EDEN_INT_HANDLER funcIntHandler) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PEDEN_DEV_CTX pDevCtx; TraceLog("EDEN_IntEnable entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "EDEN_IntEnable")) return WD_INVALID_PARAMETER; if (!IsItemExists(pDev, ITEM_INTERRUPT)) return WD_OPERATION_FAILED; pDevCtx = (PEDEN_DEV_CTX)WDC_GetDevContext(pDev); /* Check if interrupts are already enabled */ if (WDC_IntIsEnabled(hDev)) { ErrLog("Interrupts are already enabled ...\n"); return WD_OPERATION_ALREADY_DONE; } /* Store the diag interrupt handler routine, which will be executed by EDEN_IntHandler() when an interrupt is received */ pDevCtx->funcDiagIntHandler = funcIntHandler; /* Enable the interrupts */ /* NOTE: When adding read transfer commands, set the INTERRUPT_CMD_COPY flag in the 4th argument (dwOptions) passed to WDC_IntEnable() */ dwStatus = WDC_IntEnable(hDev, NULL, 0, 0, EDEN_IntHandler, (PVOID)pDev, WDC_IS_KP(hDev)); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed enabling interrupts. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); return dwStatus; } /* TODO: You can add code here to write to the device in order to physically enable the hardware interrupts */ TraceLog("EDEN_IntEnable: Interrupts enabled\n"); return WD_STATUS_SUCCESS; }
int USBAudioDevice::GetCurrentSampleRate() { if(!IsValidDevice()) return 0; if(m_acInterfaceList.Count() == 1 && m_acInterfaceList.First()->m_clockSourceList.Count() == 1) { int acInterfaceNum = m_acInterfaceList.First()->Descriptor().bInterfaceNumber; int clockID = m_acInterfaceList.First()->m_clockSourceList.First()->m_clockSource.bClockID; return GetSampleRateInternal(acInterfaceNum, clockID); } else { //more AC interfaces??? } return 0; }
bool USBAudioDevice::SetSampleRate(int freq) { if(!IsValidDevice()) return FALSE; #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Set samplerate %d\n", freq); #endif if(SetSampleRateInternal(freq)) { if(m_adc != NULL) m_adc->SetSampleFreq(freq); if(m_dac != NULL) m_dac->SetSampleFreq(freq); return TRUE; } return FALSE; }
ECode BluetoothA2dpSink::IsA2dpPlaying( /* [in] */ IBluetoothDevice* device, /* [out] */ Boolean* result) { *result = FALSE; if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { if (FAILED(mService->IsA2dpPlaying(device, result))) { Logger::E(TAG, "IsA2dpPlaying: Remote invoke error"); } // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return false; // } } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); return NOERROR; }
ECode BluetoothMap::Disconnect( /* [in] */ IBluetoothDevice* device, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result); if (DBG) Logger::D(TAG, "disconnect(");// + device + ")"); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { //try { return mService->Disconnect(device, result); //} catch (RemoteException e) { // Logger::E(TAG, Log.getStackTraceString(new Throwable())); // return FALSE; //} } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = FALSE; return NOERROR; }
ECode BluetoothMap::GetConnectionState( /* [in] */ IBluetoothDevice* device, /* [out] */ Int32* result) { VALIDATE_NOT_NULL(result); if (DBG) Logger::D(TAG, "getConnectionState(");// + device + ")"); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { //try { return mService->GetConnectionState(device, result); //} catch (RemoteException e) { // Logger::E(TAG, Log.getStackTraceString(new Throwable())); // return BluetoothProfile.STATE_DISCONNECTED; //} } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = IBluetoothProfile::STATE_DISCONNECTED; return NOERROR; }
ECode BluetoothMap::GetPriority( /* [in] */ IBluetoothDevice* device, /* [out] */ Int32* result) { VALIDATE_NOT_NULL(result); if (VDBG) Logger::D(TAG, "getPriority(");// + device + ")"); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { //try { return mService->GetPriority(device, result); //} catch (RemoteException e) { // Logger::E(TAG, Log.getStackTraceString(new Throwable())); // return PRIORITY_OFF; //} } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = PRIORITY_OFF; return NOERROR; }
ECode BluetoothA2dpSink::GetAudioConfig( /* [in] */ IBluetoothDevice* device, /* [out] */ IBluetoothAudioConfig** result) { VALIDATE_NOT_NULL(result); if (VDBG) Logger::D(TAG, "getAudioConfig( device )"); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { //try { return mService->GetAudioConfig(device, result); //} catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return null; //} } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = NULL; return NOERROR; }
DWORD PCIE_SW_EventRegister(WDC_DEVICE_HANDLE hDev, PCIE_SW_EVENT_HANDLER funcEventHandler) { DWORD dwStatus; PWDC_DEVICE pDev = (PWDC_DEVICE)hDev; PPCIE_SW_DEV_CTX pDevCtx; DWORD dwActions = WD_ACTIONS_ALL; /* TODO: Modify the above to set up the plug-and-play/power management events for which you wish to receive notifications. dwActions can be set to any combination of the WD_EVENT_ACTION flags defined in windrvr.h */ TraceLog("PCIE_SW_EventRegister entered. Device handle: 0x%p\n", hDev); if (!IsValidDevice(pDev, "PCIE_SW_EventRegister")) return WD_INVALID_PARAMETER; pDevCtx = (PPCIE_SW_DEV_CTX)WDC_GetDevContext(pDev); /* Check if event is already registered */ if (WDC_EventIsRegistered(hDev)) { ErrLog("Events are already registered ...\n"); return WD_OPERATION_ALREADY_DONE; } /* Store the diag event handler routine to be executed from PCIE_SW_EventHandler() upon an event */ pDevCtx->funcDiagEventHandler = funcEventHandler; /* Register event */ dwStatus = WDC_EventRegister(hDev, dwActions, PCIE_SW_EventHandler, hDev, FALSE); if (WD_STATUS_SUCCESS != dwStatus) { ErrLog("Failed to register events. Error 0x%lx - %s\n", dwStatus, Stat2Str(dwStatus)); return dwStatus; } TraceLog("Events registered\n"); return WD_STATUS_SUCCESS; }
bool USBAudioDevice::Start() { if(m_isStarted || !IsValidDevice()) return FALSE; bool retVal = TRUE; #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: USBAudioDevice start\n"); #endif if(m_adcEndpoint) { UsbClaimInterface(m_adcEndpoint->m_interface->Descriptor().bInterfaceNumber); UsbSetAltInterface(m_adcEndpoint->m_interface->Descriptor().bInterfaceNumber, m_adcEndpoint->m_interface->Descriptor().bAlternateSetting); #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Claim ADC interface 0x%X (alt 0x%X)\n", m_adcEndpoint->m_interface->Descriptor().bInterfaceNumber, m_adcEndpoint->m_interface->Descriptor().bAlternateSetting); #endif if(m_adc != NULL) retVal &= m_adc->Start(); } if(m_dacEndpoint) { UsbClaimInterface(m_dacEndpoint->m_interface->Descriptor().bInterfaceNumber); UsbSetAltInterface(m_dacEndpoint->m_interface->Descriptor().bInterfaceNumber, m_dacEndpoint->m_interface->Descriptor().bAlternateSetting); #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Claim DAC interface 0x%X (alt 0x%X)\n", m_dacEndpoint->m_interface->Descriptor().bInterfaceNumber, m_dacEndpoint->m_interface->Descriptor().bAlternateSetting); #endif if(m_dac != NULL) retVal &= m_dac->Start(); if(m_feedback != NULL) retVal &= m_feedback->Start(); } m_isStarted = TRUE; return retVal; }
ECode BluetoothA2dpSink::GetPriority( /* [in] */ IBluetoothDevice* device, /* [out] */ Int32* priority) { String str; IObject::Probe(device)->ToString(&str); if (VDBG) Logger::D(TAG, String("GetPriority(") + str); if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { if (FAILED(mService->GetPriority(device, priority))) { Logger::E(TAG, "GetPriority: Remote invoke error"); *priority = IBluetoothProfile::PRIORITY_OFF; } // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return BluetoothProfile.PRIORITY_OFF; // } } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *priority = IBluetoothProfile::PRIORITY_OFF; return NOERROR; }
bool USBAudioDevice::Stop() { if(!m_isStarted || !IsValidDevice()) return FALSE; #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: USBAudioDevice stop\n"); #endif bool retVal = TRUE; if(m_dac != NULL) retVal &= m_dac->Stop(); if(m_feedback != NULL) retVal &= m_feedback->Stop(); if(m_adc != NULL) retVal &= m_adc->Stop(); if(!IsConnected()) { #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Device isn't connected\n"); #endif m_isStarted = FALSE; return FALSE; } if(m_adcEndpoint) { #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Try release ADC interfaces\n"); #endif USBAudioStreamingInterface * iface = m_asInterfaceList.First(); while(iface) { if(iface->Descriptor().bInterfaceNumber == m_adcEndpoint->m_interface->Descriptor().bInterfaceNumber && iface->m_endpointsList.Count() == 0) { UsbSetAltInterface(iface->Descriptor().bInterfaceNumber, iface->Descriptor().bAlternateSetting); UsbReleaseInterface(iface->Descriptor().bInterfaceNumber); #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Release ADC interface 0x%X\n", iface->Descriptor().bInterfaceNumber); #endif break; } iface = m_asInterfaceList.Next(iface); } } if(m_dacEndpoint) { #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Try release DAC interfaces\n"); #endif USBAudioStreamingInterface * iface = m_asInterfaceList.First(); while(iface) { if(iface->Descriptor().bInterfaceNumber == m_dacEndpoint->m_interface->Descriptor().bInterfaceNumber && iface->m_endpointsList.Count() == 0) { UsbSetAltInterface(iface->Descriptor().bInterfaceNumber, iface->Descriptor().bAlternateSetting); UsbReleaseInterface(iface->Descriptor().bInterfaceNumber); #ifdef _ENABLE_TRACE debugPrintf("ASIOUAC: Release DAC interface 0x%X\n", iface->Descriptor().bInterfaceNumber); #endif break; } iface = m_asInterfaceList.Next(iface); } } m_isStarted = FALSE; return retVal; }
static int SerialOpen(const char *name, const char *arg) { const char *port_name = name; #ifdef DEBUG printf("SerialOpen: name %s arg %s\n", name, arg ? arg : "<NULL>"); #endif #ifdef COMPILING_ON_WINDOWS if (IsOpenSerial()) return -1; #else if (Unix_IsSerialInUse()) return -1; #endif #ifdef COMPILING_ON_WINDOWS if (SerialMatch(name, arg) != adp_ok) return adp_failed; #else port_name = Unix_MatchValidSerialDevice(port_name); # ifdef DEBUG printf("translated port to %s\n", port_name == 0 ? "NULL" : port_name); # endif if (port_name == 0) return adp_failed; #endif user_options_set = FALSE; /* interpret and store the arguments */ if ( arg != NULL ) { unsigned int target_baud_rate; target_baud_rate = (unsigned int)strtoul(arg, NULL, 10); if (target_baud_rate > 0) { #ifdef DEBUG printf( "user selected baud rate %u\n", target_baud_rate ); #endif process_baud_rate( target_baud_rate ); } #ifdef DEBUG else printf( "could not understand baud rate %s\n", arg ); #endif } else if (baud_rate > 0) { /* If the user specified a baud rate on the command line "-b" or via the "set remotebaud" command then try to use that one */ process_baud_rate( baud_rate ); } #ifdef COMPILING_ON_WINDOWS { int port = IsValidDevice(name); if (OpenSerial(port, FALSE) != COM_OK) return -1; } #else if (Unix_OpenSerial(port_name) < 0) return -1; #endif serial_reset(); #if defined(__unix) || defined(__CYGWIN__) Unix_ioctlNonBlocking(); #endif Angel_RxEngineInit(&config, &rxstate); /* * DANGER!: passing in NULL as the packet is ok for now as it is just * IGNOREd but this may well change */ Angel_TxEngineInit(&config, NULL, &wstate.txstate); return 0; }
bool USBAudioDevice::CanSampleRate(int freq) { if(!IsValidDevice()) return FALSE; return FindClockSource(freq) != NULL; }
int USBAudioDevice::GetInputChannelNumber() { if(!IsValidDevice()) return 0; return m_useInput ? 2 : 0; }
int USBAudioDevice::GetOutputChannelNumber() { if(!IsValidDevice()) return 0; return 2; }