static int init_server(void) { if (mw_start_aaa(fd_iav) < 0) { APP_ERROR("mw_start_aaa"); #ifdef CONFIG_AMBARELLA_IMAGE_SERVER_DAEMON nl_image_config.nl_msg.pid = getpid(); nl_image_config.nl_msg.index = IMAGE_MSG_INDEX_AAA_STATUS; nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_START_AAA_FAIL; send_image_msg_to_kernel(nl_image_config.nl_msg); #endif return -1; } #ifdef CONFIG_AMBARELLA_IMAGE_SERVER_DAEMON nl_image_config.nl_msg.pid = getpid(); nl_image_config.nl_msg.index = IMAGE_MSG_INDEX_AAA_STATUS; nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_START_AAA_SUCCESS; send_image_msg_to_kernel(nl_image_config.nl_msg); #endif if (mw_set_log_level(G_log_level) < 0) { APP_ERROR("mw_set_log_level"); return -1; } if (get_library_params() < 0) { APP_ERROR("get_library_params"); return -1; } if (config_imager() < 0) { APP_ERROR("config_imager"); return -1; } APP_INFO("[Done] init image_server\n"); return 0; }
static int do_aaa_control(Request *req) { int retv = 0; Ack ack; APP_INFO("Process AAA control id [%d].\n", (int)req->info); switch (req->info) { case AAA_START: retv = mw_start_aaa(fd_iav); if (retv < 0) { APP_ERROR("mw_start_aaa failed!\n"); } APP_INFO("AAA control : Start AAA done !\n"); break; case AAA_STOP: retv = mw_stop_aaa(); APP_INFO("AAA control : Stop AAA done !\n"); break; default: APP_PRINTF("Unknown AAA control id [%d]\n", (int)req->info); break; } ack.result = ack.info = retv; retv = send_text((u8 *)&ack, sizeof(ack)); return retv; }
/*init*/ int imagingInit(void) { #if 0 if ((fd_iav = open("/dev/iav", O_RDWR, 0)) < 0) { perror("open /dev/iav"); return -1; } #endif #ifndef NO_HARDWARE if (mw_start_aaa(fd_iav) < 0) { perror("mw_start_aaa"); return -1; } mw_enable_ae(aeMode); mw_enable_awb(whiteBlanceMode); mw_set_white_balance_mode(MW_WB_AUTO); #endif return IMAGING_OK; }
static int process_image_cmd(int image_cmd) { int ret = 0; if (image_cmd == IMAGE_CMD_START_AAA) { if (nl_image_config.image_init == 0) { if (create_server() < 0) { APP_ERROR("create_server"); return -1; } else { nl_image_config.image_init = 1; } } else { ret = mw_start_aaa(fd_iav); nl_image_config.nl_msg.pid = getpid(); nl_image_config.nl_msg.index = IMAGE_MSG_INDEX_AAA_STATUS; if (ret < 0) { printf("Start AAA failed!\n"); nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_START_AAA_FAIL; send_image_msg_to_kernel(nl_image_config.nl_msg); } else { nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_START_AAA_SUCCESS; send_image_msg_to_kernel(nl_image_config.nl_msg); } } } else if (image_cmd == IMAGE_CMD_STOP_AAA) { ret = mw_stop_aaa(); nl_image_config.nl_msg.pid = getpid(); nl_image_config.nl_msg.index = IMAGE_MSG_INDEX_AAA_STATUS; if (ret < 0) { printf("Stop AAA failed!\n"); nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_STOP_AAA_FAIL; send_image_msg_to_kernel(nl_image_config.nl_msg); } else { nl_image_config.nl_msg.msg.image_status = IMAGE_STATUS_STOP_AAA_SUCCESS; send_image_msg_to_kernel(nl_image_config.nl_msg); } } else { printf("Unrecognized kernel message!\n"); ret = -1; } return ret; }
static int start_aaa_for_non_idle(void) { int ret = 0; int state; mw_get_iav_state(fd_iav, &state); if ((state == MW_IAV_STATE_ENCODING) || (state == MW_IAV_STATE_PREVIEW)) { if (nl_image_config.image_init == 0) { if (create_server() < 0) { APP_ERROR("create_server"); } else { nl_image_config.image_init = 1; } } else { ret = mw_start_aaa(fd_iav); } } return ret; }