You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.7 KiB
112 lines
3.7 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2022. All rights reserved.
|
|
* Description: virtualkeypad input lsadc interface
|
|
* Author: App-Dev Group
|
|
* Create: 2020-06-15
|
|
*/
|
|
|
|
#include "LsadcInterface.h"
|
|
|
|
using namespace std;
|
|
using namespace android;
|
|
|
|
td_s32 LsadcInterface::LsadcInit() const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
return uapi_lsadc_init();
|
|
#endif
|
|
}
|
|
|
|
td_s32 LsadcInterface::LsadcDeinit() const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
return uapi_lsadc_deinit();
|
|
#endif
|
|
}
|
|
|
|
td_s32 LsadcInterface::LsadcGetValue(td_u32 channel, td_u32& value) const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
return uapi_lsadc_get_value(channel, &value);
|
|
#endif
|
|
}
|
|
|
|
td_s32 LsadcInterface::LsadcGetConfig(LSADC_Config& config) const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
return uapi_lsadc_get_config(&config);
|
|
#endif
|
|
}
|
|
|
|
td_s32 LsadcInterface::LsadcSetConfig(LSADC_Config& config) const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
return uapi_lsadc_set_config(&config);
|
|
#endif
|
|
}
|
|
|
|
void LsadcInterface::LsadcStructConfig(LSADC_Config& config, LsadcConfig& tempConfig) const
|
|
{
|
|
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
|
|
config.channel_mask = tempConfig.channelMask;
|
|
config.active_bit = tempConfig.activeBit;
|
|
config.data_delta = tempConfig.dataDelta;
|
|
config.deglitch_bypass = tempConfig.deglitchBypass;
|
|
config.glitch_sample = tempConfig.glitchSample;
|
|
config.lsadc_reset = tempConfig.lsadcReset;
|
|
config.lsadc_zero = tempConfig.lsadcZero;
|
|
config.model_sel = tempConfig.modelSel;
|
|
config.power_down_mod = tempConfig.powerDownMod;
|
|
config.time_scan = tempConfig.timeScan;
|
|
#endif
|
|
}
|
|
|
|
td_u32 LsadcInterface::LsadcPmocPowerKeySet(const vector<td_u8>& powerKey, const td_u32 length,
|
|
const td_u32 keyNum, const td_u32 channelMask)
|
|
{
|
|
uapi_pmoc_suspend_param attr;
|
|
uapi_pmoc_wakeup_src source;
|
|
td_u32 keyValHigh = 0;
|
|
td_bool changed = TD_FALSE;
|
|
td_u32 ret = uapi_pmoc_init();
|
|
if (ret != TD_SUCCESS) {
|
|
LSADC_INTERFACE_LOG("uapi_pmoc_init err, 0x%08x !\n", ret);
|
|
return ret;
|
|
}
|
|
if (memset_s(&attr, sizeof(attr), 0, sizeof(attr)) != EOK) {
|
|
LSADC_INTERFACE_LOG("LsadcPmocPowerKeySet attr init failed");
|
|
return TD_FAILURE;
|
|
}
|
|
source = UAPI_PMOC_WAKEUP_LSADC;
|
|
ret = uapi_pmoc_get_suspend_param(source, &changed, &attr);
|
|
if (ret != TD_SUCCESS) {
|
|
LSADC_INTERFACE_LOG("uapi_pmoc_get_suspend_param lsadc power key err, 0x%08x !\n", ret);
|
|
return ret;
|
|
}
|
|
td_u32 count = (keyNum > length) ? length : keyNum;
|
|
attr.lsadc_param.channel_mask = channelMask;
|
|
for (td_u32 i = 0; i < count; i++) {
|
|
keyValHigh = powerKey[i];
|
|
if (attr.lsadc_param.key_value_range[i].high != keyValHigh) {
|
|
attr.lsadc_param.key_value_range[i].high = keyValHigh;
|
|
attr.lsadc_param.key_value_range[i].low = (keyValHigh < lsadcMinThreshold) ?
|
|
keyValHigh : (keyValHigh - lsadcThresholdCoordinate);
|
|
changed = TD_TRUE;
|
|
}
|
|
}
|
|
if (changed) {
|
|
LSADC_INTERFACE_LOG("LsadcPmocPowerKeySet, changed !\n");
|
|
ret = uapi_pmoc_set_suspend_param(source, changed, &attr);
|
|
if (ret != TD_SUCCESS) {
|
|
LSADC_INTERFACE_LOG("uapi_pmoc_set_suspend_param lsadc power key err, 0x%08x !\n", ret);
|
|
}
|
|
}
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
void LsadcInterface::LsadcPowerKeySet(const vector<td_u8> powerKey, const td_u32 length, const td_u32 keyNum,
|
|
const td_u32 channelMask)
|
|
{
|
|
td_u32 ret = LsadcPmocPowerKeySet(powerKey, length, keyNum, channelMask);
|
|
LSADC_INTERFACE_LOG("LsadcPmocPowerKeySet ret, %08x !\n", ret);
|
|
} |