|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
|
|
|
* Description: pmoc sample
|
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <unistd.h>
|
|
|
#include <string.h>
|
|
|
#include <sys/types.h>
|
|
|
#include <sys/socket.h>
|
|
|
#include <netinet/in.h>
|
|
|
#include <arpa/inet.h>
|
|
|
#include <pthread.h>
|
|
|
#include <sys/reboot.h>
|
|
|
#include <sys/mman.h>
|
|
|
#include <sys/ioctl.h>
|
|
|
#include <fcntl.h>
|
|
|
#include <signal.h>
|
|
|
#include <securec.h>
|
|
|
#include <linux/fb.h>
|
|
|
|
|
|
#include "uapi_pmoc.h"
|
|
|
#include "uapi_pdm.h"
|
|
|
|
|
|
#ifdef CONFIG_SUPPORT_CA_RELEASE
|
|
|
#define log_info_pmoc(format, arg ...)
|
|
|
#else
|
|
|
#define log_info_pmoc(format, arg ...) printf(format, ## arg)
|
|
|
#endif
|
|
|
|
|
|
#define pmoc_notice(format...) printf("> "); printf(format);
|
|
|
|
|
|
#define modify_number(x) do { \
|
|
|
td_u32 num; \
|
|
|
if (get_input_number(&num) == 0) { \
|
|
|
(x) = num; \
|
|
|
} \
|
|
|
} while (0)
|
|
|
|
|
|
#define U32_MAX 0xFFFFFFFF
|
|
|
#define MESSAGE_LEN 32
|
|
|
|
|
|
#define unused(x) ((void)(x))
|
|
|
|
|
|
typedef struct {
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_char wakeup_source[MESSAGE_LEN];
|
|
|
td_s32 (*f_set_suspend_param)(td_void);
|
|
|
td_s32 (*f_get_suspend_param)(td_void);
|
|
|
} pmoc_wakeup_source_map;
|
|
|
|
|
|
typedef enum {
|
|
|
EXT_KEYLED_TYPE_CT1642 = 0x0, /* <KEYLED type: CT1642 */ /* <CNcomment:KEYLED型号:CT1642 */
|
|
|
EXT_KEYLED_TYPE_FD650, /* <KEYLED type: FD650 */ /* <CNcomment:KEYLED型号:FD650 */
|
|
|
EXT_KEYLED_TYPE_GPIOKEY, /* <KEYLED type: GPIOKEY */ /* <CNcomment:GPIO按键面板 */
|
|
|
EXT_KEYLED_TYPE_MAX
|
|
|
} keyled_type;
|
|
|
|
|
|
static td_void show_usage_info(td_void)
|
|
|
{
|
|
|
pmoc_notice("usage: sample_pmoc [-t trigger] [-s set] [-g get] [[command] arg].\n");
|
|
|
pmoc_notice("command as follows:\n");
|
|
|
pmoc_notice("sample_pmoc -t -- enter standby.\n");
|
|
|
pmoc_notice("sample_pmoc -m -- enter memory standby.\n");
|
|
|
pmoc_notice("sample_pmoc -s timer_wakeup -- configure timer wakeup params.\n");
|
|
|
pmoc_notice("sample_pmoc -s suspend_param -- configure wakeup params.\n");
|
|
|
pmoc_notice("sample_pmoc -s wakeup_type -- configure wakeup type.\n");
|
|
|
pmoc_notice("sample_pmoc -s display -- configure keyled display params.\n");
|
|
|
pmoc_notice("sample_pmoc -s power_off_gpio -- configure power off gpio params.\n");
|
|
|
pmoc_notice("sample_pmoc -s pmoc_poweron_flag -- configure memory standby flag.\n");
|
|
|
pmoc_notice("sample_pmoc -g pmoc_poweron_flag -- get memory standby flag.\n");
|
|
|
pmoc_notice("sample_pmoc -g suspend_param -- get wakeup params.\n");
|
|
|
pmoc_notice("sample_pmoc -g chip_temperature -- get chip temperature.\n");
|
|
|
pmoc_notice("sample_pmoc -s standby_led -- set standby led.\n");
|
|
|
pmoc_notice("sample_pmoc -s mcu_msg -- set cutom mcu msg.\n");
|
|
|
pmoc_notice("sample_pmoc -g mcu_msg -- get cutom mcu msg.\n");
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
typedef struct {
|
|
|
td_char cmd[MESSAGE_LEN];
|
|
|
td_s32(*f_process)(void);
|
|
|
} pmoc_func_map;
|
|
|
|
|
|
static int get_input_number(td_u32 *num)
|
|
|
{
|
|
|
size_t bytes;
|
|
|
char buffer[128] = {0}; /* console I/O buffer, size: 128 */
|
|
|
|
|
|
log_info_pmoc(" ? ");
|
|
|
(void)fflush(stdout);
|
|
|
read(0, buffer, 127); /* read size: 127 */
|
|
|
|
|
|
bytes = strlen(buffer);
|
|
|
if (bytes == 0) {
|
|
|
return -1;
|
|
|
} else {
|
|
|
char *end = TD_NULL;
|
|
|
/* hex */
|
|
|
if (strncmp(buffer, "0x", sizeof("0x") - 1) == 0) {
|
|
|
*num = strtoul(buffer, &end, 16); /* 16 system */
|
|
|
} else {
|
|
|
*num = strtoul(buffer, &end, 10); /* 10 system */
|
|
|
}
|
|
|
|
|
|
bytes = (size_t)(end - buffer);
|
|
|
if (bytes != 0) {
|
|
|
return 0;
|
|
|
} else {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static td_void power_off(td_void)
|
|
|
{
|
|
|
reboot(RB_POWER_OFF);
|
|
|
}
|
|
|
|
|
|
static td_s32 set_ir_wakeup_config(uapi_pmoc_suspend_param *param)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
|
|
|
log_info_pmoc("Select ir type(0-nec simple, 1-tc9012, 2-nec full, 3-sony_12bit, 4-raw, 5-not support)\n");
|
|
|
pmoc_notice("Please input new ir type[%d]", param->ir_param.ir_type);
|
|
|
ret = scanf_s("%u", ¶m->ir_param.ir_type);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (param->ir_param.ir_type == UAPI_IR_CODE_RAW) {
|
|
|
/* Here is ir powerkey code values of support */
|
|
|
param->ir_param.ir_num = 6; /* 6: Ir code raw support number */
|
|
|
|
|
|
param->ir_param.ir_low_val[0] = 0x48140f00; /* XMP-1 short-IR */
|
|
|
param->ir_param.ir_high_val[0] = 0x0;
|
|
|
param->ir_param.ir_low_val[1] = 0x47180f00; /* XMP-1 long-IR */
|
|
|
param->ir_param.ir_high_val[1] = 0x0;
|
|
|
param->ir_param.ir_low_val[2] = 0x639cff00; /* nec simple, 2: array offset value */
|
|
|
param->ir_param.ir_high_val[2] = 0x0; /* 2: array offset value */
|
|
|
param->ir_param.ir_low_val[3] = 0x8010260c; /* RC6 32bit, 3: array offset value */
|
|
|
param->ir_param.ir_high_val[3] = 0x0000001c; /* 3: array offset value */
|
|
|
param->ir_param.ir_low_val[4] = 0x0000000c; /* RC5 14bit, 4: array offset value */
|
|
|
param->ir_param.ir_high_val[4] = 0x00000000; /* 4: array offset value */
|
|
|
param->ir_param.ir_low_val[5] = 0x58535754; /* nec full dezhou like, 5: array offset value */
|
|
|
param->ir_param.ir_high_val[5] = 0x00005750; /* 5: array offset value */
|
|
|
} else if (param->ir_param.ir_type == UAPI_IR_CODE_SONY_12BIT) {
|
|
|
param->ir_param.ir_num = 1;
|
|
|
param->ir_param.ir_low_val[0] = 0x00000095;
|
|
|
param->ir_param.ir_high_val[0] = 0x0;
|
|
|
} else if (param->ir_param.ir_type == UAPI_IR_CODE_NEC_FULL) {
|
|
|
param->ir_param.ir_num = 1;
|
|
|
param->ir_param.ir_low_val[0] = 0x58595a53;
|
|
|
param->ir_param.ir_high_val[0] = 0x5750;
|
|
|
} else if (param->ir_param.ir_type == UAPI_IR_CODE_TC9012) {
|
|
|
param->ir_param.ir_num = 1;
|
|
|
param->ir_param.ir_low_val[0] = 0xf30c0e0e;
|
|
|
param->ir_param.ir_high_val[0] = 0x0;
|
|
|
} else {
|
|
|
param->ir_param.ir_num = 1;
|
|
|
param->ir_param.ir_low_val[0] = 0x639cff00;
|
|
|
param->ir_param.ir_high_val[0] = 0x0;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_ir_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify ir suspend param =================\n");
|
|
|
|
|
|
source = UAPI_PMOC_WAKEUP_IR;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new ir wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
ret = set_ir_wakeup_config(¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("set_ir_wakeup_config err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_keyled_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify keyled suspend param =============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_KEYLED;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new keyled wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("Select keyled type(0-CT1642, 1-FD650, 2-gpiokey, 3-not support)\n");
|
|
|
pmoc_notice("Please input new keyled type[%u]", param.keyled_param.keyled_type);
|
|
|
ret = scanf_s("%u", ¶m.keyled_param.keyled_type);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (param.keyled_param.keyled_type < EXT_KEYLED_TYPE_GPIOKEY) {
|
|
|
pmoc_notice("Please input new keyled wakeup key[%u]", param.keyled_param.wakeup_key);
|
|
|
ret = scanf_s("%u", ¶m.keyled_param.wakeup_key);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_gpio_wakeup_config(uapi_pmoc_suspend_param *param)
|
|
|
{
|
|
|
td_u8 i;
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
|
|
|
pmoc_notice("Please input new gpio wakeup num[%u]", param->gpio_param.num);
|
|
|
ret = scanf_s("%u", ¶m->gpio_param.num);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (param->gpio_param.num > UAPI_PMOC_WAKEUP_GPIO_MAXNUM) {
|
|
|
log_info_pmoc("num is bigger than %d, force it to %d \n", UAPI_PMOC_WAKEUP_GPIO_MAXNUM,
|
|
|
UAPI_PMOC_WAKEUP_GPIO_MAXNUM);
|
|
|
param->gpio_param.num = UAPI_PMOC_WAKEUP_GPIO_MAXNUM;
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < param->gpio_param.num; i++) {
|
|
|
pmoc_notice("Please input num%d new wakeup group[%d]", i, param->gpio_param.group[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->gpio_param.group[i] = (td_u8)tmp;
|
|
|
|
|
|
pmoc_notice("Please input num%d new wakeup bit[%d]", i, param->gpio_param.bit[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->gpio_param.bit[i] = (td_u8)tmp;
|
|
|
|
|
|
log_info_pmoc("Select gpio interrupt type(0-up edge, 1-down edge, 2-both the up and down edge, ");
|
|
|
log_info_pmoc("3-high level, 4-low level, 5-not support\n");
|
|
|
pmoc_notice("Please input num%d new interrupt type[%d]", i, param->gpio_param.interrupt_type[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->gpio_param.interrupt_type[i] = tmp;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_gpio_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify gpio suspend param ===============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_GPIO;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new gpio wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
ret = set_gpio_wakeup_config(¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("set_gpio_wakeup_config err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_lsadc_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
td_bool enable;
|
|
|
td_u8 i;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify lsadc suspend param ===============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_LSADC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input lsadc wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
pmoc_notice("Please input lsadc channel mask(bit0~3 means channel0~3): 0x");
|
|
|
ret = scanf_s("%x", ¶m.lsadc_param.channel_mask);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (enable) {
|
|
|
for (i = 0; i < UAPI_PMOC_LSADC_CHANNEL_MAXNUM; i++) {
|
|
|
if ((param.lsadc_param.channel_mask & (1 << i)) == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input channel%d key low value[%d]", i, param.lsadc_param.key_value_range[i].low);
|
|
|
ret = scanf_s("%x", ¶m.lsadc_param.key_value_range[i].low);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input channel%u key high value[%u]", i, param.lsadc_param.key_value_range[i].high);
|
|
|
ret = scanf_s("%x", ¶m.lsadc_param.key_value_range[i].high);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_uart_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify uart suspend param ===============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_UART;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new uart wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
pmoc_notice("Please input new uart wakeup key:0x");
|
|
|
ret = scanf_s("%x", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.uart_param.wakeup_key = (td_u8)tmp;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_void set_frame_filter(uapi_pmoc_suspend_param *param)
|
|
|
{
|
|
|
td_u8 i;
|
|
|
|
|
|
/* normal filter */
|
|
|
param->eth_param.frame[0].mask_bytes = U32_MAX;
|
|
|
param->eth_param.frame[0].offset = 15; /* offset: 15 */
|
|
|
param->eth_param.frame[0].filter_valid = TD_TRUE;
|
|
|
|
|
|
for (i = 0; i < UAPI_PMOC_FILTER_VALUE_COUNT; i++) {
|
|
|
param->eth_param.frame[0].value[i] = i;
|
|
|
}
|
|
|
|
|
|
/* enable part of mask bytes */
|
|
|
param->eth_param.frame[1].mask_bytes = 0xf0ffffff;
|
|
|
param->eth_param.frame[1].offset = 15; /* offset: 15 */
|
|
|
param->eth_param.frame[1].filter_valid = TD_TRUE;
|
|
|
|
|
|
for (i = 0; i < UAPI_PMOC_FILTER_VALUE_COUNT; i++) {
|
|
|
param->eth_param.frame[1].value[i] = i;
|
|
|
}
|
|
|
|
|
|
/* offset > 128 */
|
|
|
param->eth_param.frame[2].mask_bytes = U32_MAX; /* 2: array offset value */
|
|
|
param->eth_param.frame[2].offset = 130; /* offset: 130, 2: array offset value */
|
|
|
param->eth_param.frame[2].filter_valid = TD_TRUE; /* 2: array offset value */
|
|
|
|
|
|
for (i = 0; i < UAPI_PMOC_FILTER_VALUE_COUNT; i++) {
|
|
|
param->eth_param.frame[2].value[i] = 0x2; /* frame value: 0x2, 2: array offset value */
|
|
|
}
|
|
|
|
|
|
/* false filter, invalid */
|
|
|
param->eth_param.frame[3].mask_bytes = U32_MAX; /* 3: array offset value */
|
|
|
param->eth_param.frame[3].offset = 9; /* offset: 9, 3: array offset value */
|
|
|
param->eth_param.frame[3].filter_valid = TD_FALSE; /* 3: array offset value */
|
|
|
|
|
|
for (i = 0; i < UAPI_PMOC_FILTER_VALUE_COUNT; i++) {
|
|
|
param->eth_param.frame[3].value[i] = 0x1; /* frame value: 0x1, 3: array offset value */
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static td_s32 set_eth_wakeup_config(uapi_pmoc_suspend_param *param)
|
|
|
{
|
|
|
td_u32 tmp;
|
|
|
|
|
|
param->eth_param.index = 0; /* 0-eth0, 1-eth1 */
|
|
|
|
|
|
pmoc_notice("Please input new single packet wakeup enable flag[%d]", param->eth_param.unicast_packet_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->eth_param.unicast_packet_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (param->eth_param.unicast_packet_enable == TD_FALSE) {
|
|
|
pmoc_notice("Please input new magic packet wakeup enable flag[%d]", param->eth_param.magic_packet_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->eth_param.magic_packet_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (param->eth_param.magic_packet_enable == TD_FALSE) {
|
|
|
pmoc_notice("Please input magic frame wakeup enable flag[%d]", param->eth_param.wakeup_frame_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->eth_param.wakeup_frame_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (param->eth_param.wakeup_frame_enable) {
|
|
|
set_frame_filter(param);
|
|
|
}
|
|
|
|
|
|
if (param->eth_param.unicast_packet_enable || param->eth_param.magic_packet_enable ||
|
|
|
param->eth_param.wakeup_frame_enable) {
|
|
|
pmoc_notice("Please input Eth wakeup to pasive standby time[%u]", param->eth_param.time_to_passive_standby);
|
|
|
if (scanf_s("%u", &(param->eth_param.time_to_passive_standby)) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input mute wakeup enable flag[%d]", param->eth_param.mute_wakeup_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param->eth_param.mute_wakeup_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_eth_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify eth suspend param ================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_ETH;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new eth wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
ret = set_eth_wakeup_config(¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("set_eth_wakeup_config err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_vga_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("================= Modify vga suspend param ================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_VGA;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new vga wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_voice_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("================ Modify voice suspend param ===============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_VOICE;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new voice wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_usb_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify usb suspend param ================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_USB;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new usb wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_hdmirx_plugin_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("============= Modify hdmirx plugin suspend param===========\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMIRX_PLUGIN;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new hdmirx plugin wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
pmoc_notice("Please input new hdmirx plugin port [%u]", param.hdmirx_plugin_param.port);
|
|
|
ret = scanf_s("%u", ¶m.hdmirx_plugin_param.port);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_hdmirx_cec_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("============= Modify hdmirx cec suspend param =============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMIRX_CEC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new hdmirx cec wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_hdmitx_cec_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("============= Modify hdmitx cec suspend param =============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMITX_CEC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new hdmitx cec wakeup enable flag[%d]", enable);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
param.hdmitx_cec_param.id[0] = 1;
|
|
|
log_info_pmoc("Select cec control type(0-bilateral, 1-tv to chip, 2-chip to tv, 3-not support)\n");
|
|
|
pmoc_notice("Please input new hdmitx cec control type [%d]", param.hdmitx_cec_param.cec_control[0]);
|
|
|
ret = scanf_s("%u", ¶m.hdmitx_cec_param.cec_control[0]);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_timeout_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= Modify timeout suspend param ============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_TIMEOUT;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new timeout wakeup enable flag[%d]", enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
if (enable) {
|
|
|
pmoc_notice("Please input new suspend period[%u]", param.timeout_param.suspend_period);
|
|
|
if (scanf_s("%u", ¶m.timeout_param.suspend_period) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input new pvr enable flag[%d]", param.timeout_param.pvr_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.timeout_param.pvr_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
|
|
|
pmoc_notice("Please input mute wakeup enable flag[%d]", param.timeout_param.mute_wakeup_enable);
|
|
|
if (scanf_s("%u", &tmp) <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.timeout_param.mute_wakeup_enable = (tmp != 0) ? TD_TRUE : TD_FALSE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(source, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_ir_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u8 i;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= ir suspend param ========================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_IR;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("ir wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("ir type \t:%d \n", param.ir_param.ir_type);
|
|
|
|
|
|
for (i = 0; i < param.ir_param.ir_num; i++) {
|
|
|
log_info_pmoc("IR wakeup key \t:High 32-bit(0x%08x), Low 32-bit(0x%08x)\n",
|
|
|
param.ir_param.ir_high_val[i], param.ir_param.ir_low_val[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_keyled_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= keyled suspend param ====================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_KEYLED;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("keyled wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("keyled type \t:%u(0-CT1642, 1-FD650, 2-gpiokey, 3-not support)\n",
|
|
|
param.keyled_param.keyled_type);
|
|
|
|
|
|
if (param.keyled_param.keyled_type < EXT_KEYLED_TYPE_GPIOKEY) {
|
|
|
log_info_pmoc("wakeup key \t:%u \n", param.keyled_param.wakeup_key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_gpio_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u8 i;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= gpio suspend param ======================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_GPIO;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("gpio wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
for (i = 0; i < param.gpio_param.num; i++) {
|
|
|
log_info_pmoc("gpio port \t:%d_%d \n", param.gpio_param.group[i], param.gpio_param.bit[i]);
|
|
|
log_info_pmoc("interrupt type \t:%d \n", param.gpio_param.interrupt_type[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_lsadc_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_bool enable;
|
|
|
td_u8 i;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= lsadc suspend param =====================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_LSADC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("lsadc wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("lsadc channel mask \t:0x%x \n", param.lsadc_param.channel_mask);
|
|
|
|
|
|
for (i = 0; i < UAPI_PMOC_LSADC_CHANNEL_MAXNUM; i++) {
|
|
|
log_info_pmoc("lsadc key value range \t:Low (%u), High (%u)\n",
|
|
|
param.lsadc_param.key_value_range[i].low, param.lsadc_param.key_value_range[i].high);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_uart_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= uart suspend param ======================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_UART;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("uart wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("wakeup key \t:%u \n", param.uart_param.wakeup_key);
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_eth_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= eth suspend param =======================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_ETH;
|
|
|
param.eth_param.index = 0;
|
|
|
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("Magic packet wakeup \t:%s \n",
|
|
|
param.eth_param.magic_packet_enable ? "enable" : "disable");
|
|
|
log_info_pmoc("Unicast packet wakeup \t:%s \n",
|
|
|
param.eth_param.unicast_packet_enable ? "enable" : "disable");
|
|
|
log_info_pmoc("Wakeup frame wakeup \t:%s \n",
|
|
|
param.eth_param.wakeup_frame_enable ? "enable" : "disable");
|
|
|
log_info_pmoc("Eth wakeup mode to passive standby time \t:%u \n", param.eth_param.time_to_passive_standby);
|
|
|
log_info_pmoc("mute wakeup \t:%s \n", param.eth_param.mute_wakeup_enable ? "enable" : "disable");
|
|
|
} else {
|
|
|
log_info_pmoc("eth wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_voice_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("================= voice suspend param =====================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_VOICE;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("voice wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_vga_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("================== vga suspend param ======================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_VGA;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("vga wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_usb_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= usb suspend param =======================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_USB;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("usb wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_hdmirx_plugin_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= hdmirx plugin suspend param =============\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMIRX_PLUGIN;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("hdmirx plugin wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("hdmirx plugin port \t:%u \n", param.hdmirx_plugin_param.port);
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_hdmirx_cec_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
|
|
|
pmoc_notice("================= hdmirx cec suspend param ================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMIRX_CEC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, NULL);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("hdmirx cec wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_hdmitx_cec_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= hdmitx cec suspend param ================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_HDMITX_CEC;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("hdmitx cec wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("cec control type \t:%d \n", param.hdmitx_cec_param.cec_control[0]);
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_timeout_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("================= timeout suspend param ===================\n");
|
|
|
source = UAPI_PMOC_WAKEUP_TIMEOUT;
|
|
|
ret = uapi_pmoc_get_suspend_param(source, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("timeout wakeup \t:%s \n", enable ? "enable" : "disable");
|
|
|
|
|
|
if (enable) {
|
|
|
log_info_pmoc("suspend period \t:%u\n", param.timeout_param.suspend_period);
|
|
|
log_info_pmoc("pvr enable flag \t:%s\n", param.timeout_param.pvr_enable ? "enable" : "disable");
|
|
|
log_info_pmoc("mute enable flag \t:%s\n", param.timeout_param.mute_wakeup_enable ? "enable" : "disable");
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static pmoc_wakeup_source_map g_wakeup_source_map[] = {
|
|
|
{ UAPI_PMOC_WAKEUP_TIMEOUT, "TIMEOUT", set_timeout_suspend_param, get_timeout_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_IR, "IR", set_ir_suspend_param, get_ir_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_KEYLED, "KEYLED", set_keyled_suspend_param, get_keyled_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_GPIO, "GPIO", set_gpio_suspend_param, get_gpio_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_LSADC, "LSADC", set_lsadc_suspend_param, get_lsadc_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_UART, "UART", set_uart_suspend_param, get_uart_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_ETH, "ETH", set_eth_suspend_param, get_eth_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_USB, "USB", set_usb_suspend_param, get_usb_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_VOICE, "VOICE", set_voice_suspend_param, get_voice_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_VGA, "VGA", set_vga_suspend_param, get_vga_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_HDMIRX_PLUGIN, "HDMIRX_PLUGIN", set_hdmirx_plugin_param, get_hdmirx_plugin_param },
|
|
|
{ UAPI_PMOC_WAKEUP_HDMIRX_CEC, "HDMIRX_CEC", set_hdmirx_cec_suspend_param, get_hdmirx_cec_suspend_param },
|
|
|
{ UAPI_PMOC_WAKEUP_HDMITX_CEC, "HDMITX_CEC", set_hdmitx_cec_suspend_param, get_hdmitx_cec_suspend_param },
|
|
|
};
|
|
|
|
|
|
static td_s32 set_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
size_t i;
|
|
|
size_t source_num;
|
|
|
|
|
|
source_num = sizeof(g_wakeup_source_map) / sizeof(g_wakeup_source_map[0]);
|
|
|
for (i = 0; i < source_num; i++) {
|
|
|
ret = g_wakeup_source_map[i].f_set_suspend_param();
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("set %s suspend param err, 0x%08x !\n", g_wakeup_source_map[i].wakeup_source, ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_suspend_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
size_t i;
|
|
|
size_t source_num;
|
|
|
|
|
|
source_num = sizeof(g_wakeup_source_map) / sizeof(g_wakeup_source_map[0]);
|
|
|
for (i = 0; i < source_num; i++) {
|
|
|
ret = g_wakeup_source_map[i].f_get_suspend_param();
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("get %s suspend param err, 0x%08x !\n", g_wakeup_source_map[i].wakeup_source, ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_wakeup_attr(uapi_pmoc_wakeup_src source)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 j;
|
|
|
td_u32 standby_period;
|
|
|
uapi_pmoc_wakeup_attr attr;
|
|
|
|
|
|
for (j = 0; j < sizeof(g_wakeup_source_map) / sizeof(g_wakeup_source_map[0]); j++) {
|
|
|
if (source == g_wakeup_source_map[j].source) {
|
|
|
log_info_pmoc("wakeup by %s !!!\n", g_wakeup_source_map[j].wakeup_source);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_get_wakeup_attr(&attr);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_wakeup_attr err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
if (attr.source == UAPI_PMOC_WAKEUP_IR) {
|
|
|
log_info_pmoc("wakeup key(Low): 0x%x, key(High):0x%x \n", attr.wakeup_param.ir_param.ir_low_val,
|
|
|
attr.wakeup_param.ir_param.ir_high_val);
|
|
|
} else if (attr.source == UAPI_PMOC_WAKEUP_GPIO) {
|
|
|
log_info_pmoc("wakeup by GPIO%d_%d \n", attr.wakeup_param.gpio_param.group,
|
|
|
attr.wakeup_param.gpio_param.bit);
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_get_standby_period(&standby_period);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_standby_period err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("\nstandby period = %d \n", standby_period);
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 tigger_standby(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 runnint_count = 1;
|
|
|
td_u32 i;
|
|
|
td_bool enable;
|
|
|
uapi_pmoc_suspend_param param;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
|
|
|
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
|
|
log_info_pmoc("param init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("===================== enter standby ====================\n");
|
|
|
pmoc_notice("Please input standby running count[%u]", runnint_count);
|
|
|
modify_number(runnint_count);
|
|
|
|
|
|
if (runnint_count > 1) {
|
|
|
ret = uapi_pmoc_get_suspend_param(UAPI_PMOC_WAKEUP_TIMEOUT, &enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
if (!enable) {
|
|
|
enable = TD_TRUE;
|
|
|
|
|
|
pmoc_notice("Please input new standby period[%u s]", param.timeout_param.suspend_period);
|
|
|
modify_number(param.timeout_param.suspend_period);
|
|
|
|
|
|
ret = uapi_pmoc_set_suspend_param(UAPI_PMOC_WAKEUP_TIMEOUT, enable, ¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < runnint_count; i++) {
|
|
|
ret = uapi_pmoc_enter_standby(&source);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_enter_standby err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
if (get_wakeup_attr(source) != TD_SUCCESS) {
|
|
|
log_info_pmoc("get_wakeup_attr err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("%%%%%%%% cnt = %u %%%%%%%% \n", i);
|
|
|
|
|
|
sleep(1);
|
|
|
}
|
|
|
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 memory_standby(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 j;
|
|
|
uapi_pmoc_wakeup_src source;
|
|
|
uapi_pdm_pmoc_param pmoc_param = {0};
|
|
|
uapi_pdm_config_info info;
|
|
|
|
|
|
if (memset_s(&info, sizeof(info), 0, sizeof(info)) != EOK) {
|
|
|
log_info_pmoc("info init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("===================== memory standby ====================\n");
|
|
|
|
|
|
if (uapi_pdm_get_pmoc_param(&pmoc_param) != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_get_pmoc_param err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (pmoc_param.power_on_mode != UAPI_PDM_PMOC_MEMORY_STANDBY) {
|
|
|
printf("memory standby flag has not been set\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (uapi_pdm_get_cfg_info(&info) != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_get_cfg_info err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
/* app should set memory flag when enter standby */
|
|
|
info.pmoc_flag = UAPI_PDM_PMOC_MEMORY_FLAG_SUSPEND;
|
|
|
if (uapi_pdm_update_cfg_info(&info) != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_update_cfg_info err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_enter_standby(&source);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_enter_standby err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
for (j = 0; j < sizeof(g_wakeup_source_map) / sizeof(g_wakeup_source_map[0]); j++) {
|
|
|
if (source == g_wakeup_source_map[j].source) {
|
|
|
log_info_pmoc("wakeup by %s !!!\n", g_wakeup_source_map[j].wakeup_source);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* app should clear memory flag when wakeup */
|
|
|
info.pmoc_flag = UAPI_PDM_PMOC_MEMORY_FLAG_RUN;
|
|
|
if (uapi_pdm_update_cfg_info(&info) != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_update_cfg_info err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_wakeup_type(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_wakeup_type wakeup_type = {0};
|
|
|
|
|
|
pmoc_notice("============= Modify wakeup type =============\n");
|
|
|
pmoc_notice("(0-wakeup to ddr, 1-reset) Select wakeup type[%d]", wakeup_type);
|
|
|
ret = scanf_s("%u", &wakeup_type);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_wakeup_type(wakeup_type);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("get_timeout_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_display_params(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_display_param display_param = {0};
|
|
|
|
|
|
pmoc_notice("============= Modify keyled display params =============\n");
|
|
|
log_info_pmoc("Select keyled type(0-CT1642, 1-FD650, 3-gpiokey, 4-not support)");
|
|
|
pmoc_notice("Please input new keyled type[%u]", display_param.keyled_type);
|
|
|
ret = scanf_s("%u", &display_param.keyled_type);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("Select display type(0-no display, 1-display number, 2-display time(in second))");
|
|
|
pmoc_notice("Please input new display type[%d]", display_param.display_type);
|
|
|
ret = scanf_s("%u", &display_param.display_type);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (display_param.display_type == UAPI_PMOC_DISPLAY_DIGIT) {
|
|
|
pmoc_notice("Please input new display digit[%u]", display_param.display_value);
|
|
|
ret = scanf_s("%u", &display_param.display_value);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
} else if (display_param.display_type == UAPI_PMOC_DISPLAY_TIME) {
|
|
|
display_param.display_time_info.hour = 6; /* hour: 6 */
|
|
|
display_param.display_time_info.minute = 9; /* minute: 9 */
|
|
|
display_param.display_time_info.second = 36; /* second: 36 */
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_standby_display_param(&display_param);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_standby_display_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("keyled display params modify success! \n");
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_gpio_power_off(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u8 i;
|
|
|
td_u32 tmp;
|
|
|
uapi_pmoc_poweroff_gpio_param param = {0};
|
|
|
|
|
|
pmoc_notice("============= Modify power off gpio params =============\n");
|
|
|
|
|
|
pmoc_notice("Please input poweroff gpio num[%d]", param.num);
|
|
|
ret = scanf_s("%u", ¶m.num);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
if (param.num > UAPI_PMOC_POWEROFF_GPIO_MAXNUM) {
|
|
|
log_info_pmoc("num is bigger than %d, force it to %d", UAPI_PMOC_POWEROFF_GPIO_MAXNUM,
|
|
|
UAPI_PMOC_POWEROFF_GPIO_MAXNUM);
|
|
|
param.num = UAPI_PMOC_POWEROFF_GPIO_MAXNUM;
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < param.num; i++) {
|
|
|
pmoc_notice("Please input poweroff num%d group:[%d] ", i, param.group[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.group[i] = (td_u8)tmp;
|
|
|
pmoc_notice("Please input poweroff num%d bit:[%d] ", i, param.bit[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.bit[i] = (td_u8)tmp;
|
|
|
pmoc_notice("Please input poweroff num%u level:[%u] ", i, param.level[i]);
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
param.level[i] = (td_u8)tmp;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_gpio_power_off(¶m);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_gpio_power_off err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("power off gpio params modify success! \n");
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_pmoc_poweron_flag(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pdm_pmoc_param pmoc_param = {0};
|
|
|
|
|
|
pmoc_notice("================ set poweron standby flag ==============\n");
|
|
|
|
|
|
ret = uapi_pdm_get_pmoc_param(&pmoc_param);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_get_pmoc_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
log_info_pmoc("Select pmoc poweron flag(0-standby, 1-poweron, 2-memory standby)");
|
|
|
pmoc_notice("Please input pmoc poweron flag:[%d] ", pmoc_param.power_on_mode);
|
|
|
ret = scanf_s("%u", &pmoc_param.power_on_mode);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pdm_update_pmoc_param(&pmoc_param);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_update_pmoc_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("poweron standby flag modify success! \n");
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_pmoc_poweron_flag(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pdm_pmoc_param pmoc_param = {0};
|
|
|
uapi_pdm_config_info info;
|
|
|
|
|
|
if (memset_s(&info, sizeof(info), 0, sizeof(info)) != EOK) {
|
|
|
log_info_pmoc("info init failed");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pdm_get_pmoc_param(&pmoc_param);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_get_pmoc_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
switch (pmoc_param.power_on_mode) {
|
|
|
case UAPI_PDM_PMOC_STANDBY:
|
|
|
printf("standby(when powerup) flag has been set\n");
|
|
|
break;
|
|
|
case UAPI_PDM_PMOC_POWERON:
|
|
|
printf("poweron flag has been set\n");
|
|
|
break;
|
|
|
case UAPI_PDM_PMOC_MEMORY_STANDBY:
|
|
|
printf("memory standby flag(when powerup) has been set\n");
|
|
|
break;
|
|
|
default:
|
|
|
printf("not support flag\n");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pdm_get_cfg_info(&info);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pdm_get_cfg_info err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
switch (info.pmoc_flag) {
|
|
|
case UAPI_PDM_PMOC_MEMORY_FLAG_RUN:
|
|
|
printf("memorry flag has been set to UAPI_PDM_PMOC_MEMORY_FLAG_RUN\n");
|
|
|
break;
|
|
|
case UAPI_PDM_PMOC_MEMORY_FLAG_SUSPEND:
|
|
|
printf("memorry flag has been set to UAPI_PDM_PMOC_MEMORY_FLAG_SUSPEND\n");
|
|
|
break;
|
|
|
default:
|
|
|
printf("not support flag\n");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_chip_temperature(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
uapi_pmoc_chip_temperature chip_temprature = {0};
|
|
|
|
|
|
ret = uapi_pmoc_get_chip_temperature(&chip_temprature);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_chip_temperature err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("==================== chip temperature ==================\n");
|
|
|
pmoc_notice("chip temperature \t:%d \n", chip_temprature.t_sensor1_temperature);
|
|
|
pmoc_notice("========================================================\n");
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_standby_led(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 led_mode, tmp, led_breath_cycle;
|
|
|
td_u8 group, bit, level;
|
|
|
|
|
|
pmoc_notice("Select led mode in standby state(0-standby led, 1-breath led): ");
|
|
|
ret = scanf_s("%u", &led_mode);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Please input gpio group: ");
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
group = (td_u8)tmp;
|
|
|
|
|
|
pmoc_notice("Please input gpio bit: ");
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
bit = (td_u8)tmp;
|
|
|
|
|
|
if (led_mode == 0) {
|
|
|
pmoc_notice("Please input gpio level(0/1): ");
|
|
|
ret = scanf_s("%u", &tmp);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
level = (td_u8)tmp;
|
|
|
|
|
|
ret = uapi_pmoc_set_standby_led(group, bit, level);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_standby_led err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
} else {
|
|
|
pmoc_notice("Please input led breath cycle(0~0xffffffff): ");
|
|
|
ret = scanf_s("%u", &led_breath_cycle);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_breath_led(group, bit, led_breath_cycle);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_breath_led err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_mcu_msg(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 msg_index, value;
|
|
|
|
|
|
pmoc_notice("Input msg index(0~15): ");
|
|
|
ret = scanf_s("%u", &msg_index);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
pmoc_notice("Input value: 0x");
|
|
|
ret = scanf_s("%x", &value);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_set_mcu_msg(msg_index, value);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_set_mcu_msg err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 get_mcu_msg(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
td_u32 msg_index, value;
|
|
|
|
|
|
pmoc_notice("Input msg index(0~15): ");
|
|
|
ret = scanf_s("%u", &msg_index);
|
|
|
if (ret <= 0) {
|
|
|
log_info_pmoc("scanf_s err!\n");
|
|
|
return TD_FAILURE;
|
|
|
}
|
|
|
|
|
|
ret = uapi_pmoc_get_mcu_msg(msg_index, &value);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("uapi_pmoc_get_mcu_msg err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
printf("value: 0x%x\n", value);
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static td_s32 set_timer_wakeup_param(td_void)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
|
|
|
ret = set_timeout_suspend_param();
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
log_info_pmoc("set_timeout_suspend_param err, 0x%08x !\n", ret);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
return TD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
static pmoc_func_map g_setting_functions[] = {
|
|
|
{ "timer_wakeup", set_timer_wakeup_param },
|
|
|
{ "suspend_param", set_suspend_param },
|
|
|
{ "wakeup_type", set_wakeup_type },
|
|
|
{ "display", set_display_params },
|
|
|
{ "power_off_gpio", set_gpio_power_off },
|
|
|
{ "pmoc_poweron_flag", set_pmoc_poweron_flag },
|
|
|
{ "standby_led", set_standby_led },
|
|
|
{ "mcu_msg", set_mcu_msg },
|
|
|
};
|
|
|
|
|
|
static pmoc_func_map g_getting_functions[] = {
|
|
|
{ "pmoc_poweron_flag", get_pmoc_poweron_flag },
|
|
|
{ "suspend_param", get_suspend_param },
|
|
|
{ "chip_temperature", get_chip_temperature },
|
|
|
{ "mcu_msg", get_mcu_msg },
|
|
|
};
|
|
|
|
|
|
static void sig_handler(int signo)
|
|
|
{
|
|
|
unused(signo);
|
|
|
_exit(0);
|
|
|
}
|
|
|
|
|
|
td_s32 main(td_s32 argc, td_char *argv[])
|
|
|
{
|
|
|
td_s32 ret, result;
|
|
|
td_u8 i;
|
|
|
|
|
|
if (uapi_pmoc_init() != TD_SUCCESS) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
if (signal(SIGINT, sig_handler) == SIG_ERR) {
|
|
|
log_info_pmoc("get SIGINT failed\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
result = getopt(argc, argv, "tpms:g:");
|
|
|
|
|
|
switch (result) {
|
|
|
case 't':
|
|
|
tigger_standby();
|
|
|
uapi_pmoc_deinit();
|
|
|
return 0;
|
|
|
case 'p':
|
|
|
power_off();
|
|
|
uapi_pmoc_deinit();
|
|
|
return 0;
|
|
|
case 'm':
|
|
|
memory_standby();
|
|
|
uapi_pmoc_deinit();
|
|
|
return 0;
|
|
|
case 's':
|
|
|
for (i = 0; i < sizeof(g_setting_functions) / sizeof(g_setting_functions[0]); i++) {
|
|
|
if (strcmp(g_setting_functions[i].cmd, optarg) == 0) {
|
|
|
ret = g_setting_functions[i].f_process();
|
|
|
uapi_pmoc_deinit();
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case 'g':
|
|
|
for (i = 0; i < sizeof(g_getting_functions) / sizeof(g_getting_functions[0]); i++) {
|
|
|
if (strcmp(g_getting_functions[i].cmd, optarg) == 0) {
|
|
|
ret = g_getting_functions[i].f_process();
|
|
|
uapi_pmoc_deinit();
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
uapi_pmoc_deinit();
|
|
|
|
|
|
show_usage_info();
|
|
|
|
|
|
return -1;
|
|
|
}
|
|
|
|