linux之mmi對led燈的控制(高通系列)
阿新 • • 發佈:2019-02-13
mmi_module_t MMI_MODULE_INFO_SYM = {
.version_major = 1,
.version_minor = 0,
.name = "Light",
.author = "Qualcomm Technologies, Inc.",
.methods = &module_methods,
.module_handle = NULL,
.supported_cmd_list = NULL,
.supported_cmd_list_size = 0,
.cb_print = NULL, /**it is initialized by mmi agent*/
.run_pid = -1,
};
MMI_MODULE_INFO_SYM
module_methods
module_init
pthread_mutex_init(&g_mutex, NULL); //初始化互斥
ret = hal_init();
devices = (struct Devices *) malloc(sizeof(struct Devices)); //分配裝置的記憶體
ret = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const **) &hw_module); //拉去light module
devices->lights[LIGHT_INDEX_BACKLIGHT] = get_device(hw_module, LIGHT_ID_BACKLIGHT); //分配light 的型別
devices->lights[LIGHT_INDEX_KEYBOARD] = get_device(hw_module, LIGHT_ID_KEYBOARD);
devices->lights[LIGHT_INDEX_BUTTONS] = get_device(hw_module, LIGHT_ID_BUTTONS);
devices->lights[LIGHT_INDEX_BATTERY] = get_device(hw_module, LIGHT_ID_BATTERY);
devices->lights[LIGHT_INDEX_NOTIFICATIONS] = get_device(hw_module, LIGHT_ID_NOTIFICATIONS);
devices->lights[LIGHT_INDEX_ATTENTION] = get_device(hw_module, LIGHT_ID_ATTENTION);
devices->lights[LIGHT_INDEX_BLUETOOTH] = get_device(hw_module, LIGHT_ID_BLUETOOTH);
devices->lights[LIGHT_INDEX_WIFI] = get_device(hw_module, LIGHT_ID_WIFI);
err = module->methods->open(module, name, &device); //開啟裝置
return (light_device_t *) device; //成功開啟裝置,返回指標
module_deinit
module_run
ret = module_run_mmi(module, params); //建立了一個runtest的任務
pthread_mutex_lock(&g_mutex); //互斥的鎖定
ret = init(params); //初始化引數
light_delay = atoi(params["delay"].c_str()); //獲取延時的時間
params["type"].c_str() light_device = LIGHT_INDEX_NOTIFICATIONS; //解析指令的型別
params["color"].c_str() led_color = LED_COLOR_RED;//解析控制燈的顏色
ret = pthread_create((pthread_t *) & module->run_pid, NULL, run_test, (void *) module); //建立亮燈的任務
signal(SIGUSR1, signal_handler); //獲取訊號量,但不知道訊號量從哪裡獲取的
enable((const mmi_module_t *) mod, true);
usleep(1000 * light_delay);
enable((const mmi_module_t *) mod, false);
usleep(1000 * light_delay);
pthread_join(module->run_pid, NULL); //把建立的任務加入任務聯中
pthread_mutex_unlock(&g_mutex); //解除互斥
ret = module_run_pcba(module, params); //單個指令的控制
ret = init(params); //獲取解析引數
light_delay = atoi(params["delay"].c_str());
params["type"].c_str() light_device = LIGHT_INDEX_NOTIFICATIONS;
params["color"].c_str() led_color = LED_COLOR_RED;
enable(module, true); //開啟燈
module_stop
kill_thread(module->run_pid); //結束建立的任務
deinit(module);
enable(mod, false);
.version_major = 1,
.version_minor = 0,
.name = "Light",
.author = "Qualcomm Technologies, Inc.",
.methods = &module_methods,
.module_handle = NULL,
.supported_cmd_list = NULL,
.supported_cmd_list_size = 0,
.cb_print = NULL, /**it is initialized by mmi agent*/
.run_pid = -1,
};
MMI_MODULE_INFO_SYM
module_methods
module_init
pthread_mutex_init(&g_mutex, NULL); //初始化互斥
ret = hal_init();
devices = (struct Devices *) malloc(sizeof(struct Devices)); //分配裝置的記憶體
ret = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const **) &hw_module); //拉去light module
devices->lights[LIGHT_INDEX_BACKLIGHT] = get_device(hw_module, LIGHT_ID_BACKLIGHT); //分配light 的型別
devices->lights[LIGHT_INDEX_KEYBOARD] = get_device(hw_module, LIGHT_ID_KEYBOARD);
devices->lights[LIGHT_INDEX_BUTTONS] = get_device(hw_module, LIGHT_ID_BUTTONS);
devices->lights[LIGHT_INDEX_BATTERY] = get_device(hw_module, LIGHT_ID_BATTERY);
devices->lights[LIGHT_INDEX_NOTIFICATIONS] = get_device(hw_module, LIGHT_ID_NOTIFICATIONS);
devices->lights[LIGHT_INDEX_ATTENTION] = get_device(hw_module, LIGHT_ID_ATTENTION);
devices->lights[LIGHT_INDEX_BLUETOOTH] = get_device(hw_module, LIGHT_ID_BLUETOOTH);
devices->lights[LIGHT_INDEX_WIFI] = get_device(hw_module, LIGHT_ID_WIFI);
err = module->methods->open(module, name, &device); //開啟裝置
return (light_device_t *) device; //成功開啟裝置,返回指標
module_deinit
module_run
ret = module_run_mmi(module, params); //建立了一個runtest的任務
pthread_mutex_lock(&g_mutex); //互斥的鎖定
ret = init(params); //初始化引數
light_delay = atoi(params["delay"].c_str()); //獲取延時的時間
params["type"].c_str() light_device = LIGHT_INDEX_NOTIFICATIONS; //解析指令的型別
params["color"].c_str() led_color = LED_COLOR_RED;//解析控制燈的顏色
ret = pthread_create((pthread_t *) & module->run_pid, NULL, run_test, (void *) module); //建立亮燈的任務
signal(SIGUSR1, signal_handler); //獲取訊號量,但不知道訊號量從哪裡獲取的
enable((const mmi_module_t *) mod, true);
usleep(1000 * light_delay);
enable((const mmi_module_t *) mod, false);
usleep(1000 * light_delay);
pthread_join(module->run_pid, NULL); //把建立的任務加入任務聯中
pthread_mutex_unlock(&g_mutex); //解除互斥
ret = module_run_pcba(module, params); //單個指令的控制
ret = init(params); //獲取解析引數
light_delay = atoi(params["delay"].c_str());
params["type"].c_str() light_device = LIGHT_INDEX_NOTIFICATIONS;
params["color"].c_str() led_color = LED_COLOR_RED;
enable(module, true); //開啟燈
module_stop
kill_thread(module->run_pid); //結束建立的任務
deinit(module);
enable(mod, false);