/* * Default kernel arguments * arg0: * input, __read_only image2d_t * arg1: * output, __write_only image2d_t * suppose cl can get width/height pixels from * get_image_width/get_image_height */ XCamReturn CLImageKernel::pre_execute (SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output) { XCamReturn ret = XCAM_RETURN_NO_ERROR; SmartPtr<CLContext> context = get_context (); #define XCAM_CL_MAX_ARGS 256 CLArgument args[XCAM_CL_MAX_ARGS]; uint32_t arg_count = XCAM_CL_MAX_ARGS; CLWorkSize work_size; ret = prepare_arguments (input, output, args, arg_count, work_size); XCAM_ASSERT (arg_count); for (uint32_t i = 0; i < arg_count; ++i) { ret = set_argument (i, args[i].arg_adress, args[i].arg_size); XCAM_FAIL_RETURN ( WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "cl image kernel(%s) set argc(%d) failed", get_kernel_name (), i); } XCAM_ASSERT (work_size.global[0]); ret = set_work_size (work_size.dim, work_size.global, work_size.local); XCAM_FAIL_RETURN ( WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "cl image kernel(%s) set work size failed", get_kernel_name ()); return XCAM_RETURN_NO_ERROR; }
XCamReturn CLDemosaicImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & video_info = output->get_video_info (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); arg_count = 2; work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = video_info.width / 2; work_size.global[1] = video_info.height / 2; work_size.local[0] = 4; work_size.local[1] = 4; return XCAM_RETURN_NO_ERROR; }
void hardware::code::Real::get_work_sizes(const cl_kernel kernel, size_t* ls, size_t* gs, cl_uint* num_groups) const { Opencl_Module::get_work_sizes(kernel, ls, gs, num_groups); // Query specific sizes for kernels if needed std::string kernelname = get_kernel_name(kernel); if (kernelname.compare("get_elem_vector") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("set_elem_vector") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("real_ratio") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("real_product") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("real_sum") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("real_subtraction") == 0) { *ls = 1; *gs = 1; *num_groups = 1; } if (kernelname.compare("update_alpha_cgm") == 0) { *ls = 16; *gs = 16; *num_groups = 1; } if (kernelname.compare("update_beta_cgm") == 0) { *ls = 16; *gs = 16; *num_groups = 1; } if (kernelname.compare("update_zeta_cgm") == 0) { *ls = 16; *gs = 16; *num_groups = 1; } }
XCamReturn CLRgbPipeImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & video_info = input->get_video_info (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); if (_image_in_list.size () < 4) { while (_image_in_list.size () < 4) { _image_in_list.push_back (_image_in); } } else { _image_in_list.pop_front (); _image_in_list.push_back (_image_in); } XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; args[0].arg_adress = &_image_out->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_tnr_config; args[1].arg_size = sizeof (CLRgbPipeTnrConfig); uint8_t index = 0; for (std::list<SmartPtr<CLImage>>::iterator it = _image_in_list.begin (); it != _image_in_list.end (); it++) { args[2 + index].arg_adress = &(*it)->get_mem_id (); args[2 + index].arg_size = sizeof (cl_mem); index++; } arg_count = 2 + index; work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = XCAM_ALIGN_UP(video_info.width, 16); work_size.global[1] = XCAM_ALIGN_UP(video_info.height, 16); work_size.local[0] = 8; work_size.local[1] = 4; return XCAM_RETURN_NO_ERROR; }
XCamReturn CLKernel::set_arguments (const CLArgList &args, const CLWorkSize &work_size) { XCamReturn ret = XCAM_RETURN_NO_ERROR; uint32_t i_count = 0; XCAM_FAIL_RETURN ( ERROR, _arg_list.empty (), XCAM_RETURN_ERROR_PARAM, "cl image kernel(%s) arguments was already set, can NOT be set twice", get_kernel_name ()); for (CLArgList::const_iterator iter = args.begin (); iter != args.end (); ++iter, ++i_count) { const SmartPtr<CLArgument> &arg = *iter; XCAM_FAIL_RETURN ( WARNING, arg.ptr (), XCAM_RETURN_ERROR_PARAM, "cl image kernel(%s) argc(%d) is NULL", get_kernel_name (), i_count); void *adress = NULL; uint32_t size = 0; arg->get_value (adress, size); ret = set_argument (i_count, adress, size); XCAM_FAIL_RETURN ( WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "cl image kernel(%s) set argc(%d) failed", get_kernel_name (), i_count); } ret = set_work_size (work_size); XCAM_FAIL_RETURN ( WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "cl image kernel(%s) set worksize(global:%dx%dx%d, local:%dx%dx%d) failed", XCAM_STR(get_kernel_name ()), (int)work_size.global[0], (int)work_size.global[1], (int)work_size.global[2], (int)work_size.local[0], (int)work_size.local[1], (int)work_size.local[2]); _arg_list = args; return ret; }
XCamReturn CLDemoImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & video_info = input->get_video_info (); CLImageDesc image_info; uint32_t channel_bits = XCAM_ALIGN_UP (video_info.color_bits, 8); image_info.format.image_channel_order = CL_R; if (channel_bits == 8) image_info.format.image_channel_data_type = CL_UNORM_INT8; else if (channel_bits == 16) image_info.format.image_channel_data_type = CL_UNORM_INT16; image_info.width = video_info.strides[0] / CLImage::calculate_pixel_bytes (image_info.format); image_info.height = (video_info.size / video_info.strides[0]) / 4 * 4; image_info.row_pitch = video_info.strides[0]; _image_in = new CLVaImage (context, input, image_info); _image_out = new CLVaImage (context, output, image_info); XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); arg_count = 2; work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = image_info.width; work_size.global[1] = image_info.height; work_size.local[0] = 8; work_size.local[1] = 4; return XCAM_RETURN_NO_ERROR; }
XCamReturn CLGammaImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); _gamma_table_buffer = new CLBuffer( context, sizeof(float)*XCAM_GAMMA_TABLE_SIZE, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR , &_gamma_table); //CL_MEM_READ_ONLY XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid () && _gamma_table_buffer->is_valid()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid () && _gamma_table_buffer->is_valid(), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); args[2].arg_adress = &_gamma_table_buffer->get_mem_id(); args[2].arg_size = sizeof (cl_mem); arg_count = 3; const CLImageDesc out_info = _image_out->get_image_desc (); work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = out_info.width/4; work_size.global[1] = out_info.height/2; work_size.local[0] = 4; work_size.local[1] = 4; return XCAM_RETURN_NO_ERROR; }
XCamReturn CLBnrImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); args[2].arg_adress = &_bnr_config.bnr_gain; args[2].arg_size = sizeof (cl_float); args[3].arg_adress = &_bnr_config.direction; args[3].arg_size = sizeof (cl_float); arg_count = 4; const CLImageDesc out_info = _image_out->get_image_desc (); work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = out_info.width; work_size.global[1] = out_info.height; work_size.local[0] = 8; work_size.local[1] = 4; return XCAM_RETURN_NO_ERROR; }
XCamReturn CLTnrImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & video_info = input->get_video_info (); _image_in = new CLVaImage (context, input); if (CL_TNR_TYPE_RGB == _type) { if (_image_in_list.size () < _frame_count) { while (_image_in_list.size () < _frame_count) { _image_in_list.push_back (_image_in); } } else { _image_in_list.pop_front (); _image_in_list.push_back (_image_in); } } _image_out = new CLVaImage (context, output); if (CL_TNR_TYPE_YUV == _type) { if (!_image_out_prev.ptr ()) { _image_out_prev = _image_in; } } _vertical_offset = video_info.aligned_height; XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.local[0] = 8; work_size.local[1] = 4; if (CL_TNR_TYPE_YUV == _type) { args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out_prev->get_mem_id (); args[1].arg_size = sizeof (cl_mem); args[2].arg_adress = &_image_out->get_mem_id (); args[2].arg_size = sizeof (cl_mem); args[3].arg_adress = &_vertical_offset; args[3].arg_size = sizeof (_vertical_offset); args[4].arg_adress = &_gain; args[4].arg_size = sizeof (_gain); args[5].arg_adress = &_thr_Y; args[5].arg_size = sizeof (_thr_Y); args[6].arg_adress = &_thr_C; args[6].arg_size = sizeof (_thr_C); work_size.global[0] = video_info.width / 2; work_size.global[1] = video_info.height / 2; arg_count = 7; } else if (CL_TNR_TYPE_RGB == _type) { const CLImageDesc out_info = _image_out->get_image_desc (); work_size.global[0] = out_info.width; work_size.global[1] = out_info.height; args[0].arg_adress = &_image_out->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_thr_Y; args[1].arg_size = sizeof (_thr_Y); args[2].arg_adress = &_frame_count; args[2].arg_size = sizeof (_frame_count); uint8_t index = 0; for (std::list<SmartPtr<CLImage>>::iterator it = _image_in_list.begin (); it != _image_in_list.end (); it++) { args[3 + index].arg_adress = &(*it)->get_mem_id (); args[3 + index].arg_size = sizeof (cl_mem); index++; } arg_count = 3 + index; } return XCAM_RETURN_NO_ERROR; }
XCamReturn CLWaveletDenoiseImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & video_info_in = input->get_video_info (); const VideoBufferInfo & video_info_out = output->get_video_info (); _input_image = new CLVaBuffer (context, input); _reconstruct_image = new CLVaBuffer (context, output); _details_image = _handler->get_details_image (); _approx_image = _handler->get_approx_image (); _decomposition_levels = WAVELET_DECOMPOSITION_LEVELS; _soft_threshold = _handler->get_denoise_config ().threshold[0]; _hard_threshold = _handler->get_denoise_config ().threshold[1]; _input_y_offset = video_info_in.offsets[0] / 4; _output_y_offset = video_info_out.offsets[0] / 4; _input_uv_offset = video_info_in.aligned_height; _output_uv_offset = video_info_out.aligned_height; XCAM_ASSERT (_input_image->is_valid () && _reconstruct_image->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _input_image->is_valid () && _reconstruct_image->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); //set args; work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.local[0] = 8; work_size.local[1] = 4; if (_current_layer % 2) { args[0].arg_adress = &_input_image->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_approx_image->get_mem_id (); args[1].arg_size = sizeof (cl_mem); } else { args[0].arg_adress = &_approx_image->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_input_image->get_mem_id (); args[1].arg_size = sizeof (cl_mem); } args[2].arg_adress = &_details_image->get_mem_id (); args[2].arg_size = sizeof (cl_mem); args[3].arg_adress = &_reconstruct_image->get_mem_id (); args[3].arg_size = sizeof (cl_mem); args[4].arg_adress = &_input_y_offset; args[4].arg_size = sizeof (_input_y_offset); args[5].arg_adress = &_output_y_offset; args[5].arg_size = sizeof (_output_y_offset); args[6].arg_adress = &_input_uv_offset; args[6].arg_size = sizeof (_input_uv_offset); args[7].arg_adress = &_output_uv_offset; args[7].arg_size = sizeof (_output_uv_offset); args[8].arg_adress = &_current_layer; args[8].arg_size = sizeof (_current_layer); args[9].arg_adress = &_decomposition_levels; args[9].arg_size = sizeof (_decomposition_levels); args[10].arg_adress = &_hard_threshold; args[10].arg_size = sizeof (_hard_threshold); args[11].arg_adress = &_soft_threshold; args[11].arg_size = sizeof (_soft_threshold); #if WAVELET_DENOISE_UV work_size.global[0] = video_info_in.width / 16; work_size.global[1] = video_info_in.height / 2; #else work_size.global[0] = video_info_in.width / 16; work_size.global[1] = video_info_in.height; #endif arg_count = 12; return XCAM_RETURN_NO_ERROR; }
int install_from_cwd(Options *op) { Package *p; CommandList *c; int ret; int ran_pre_install_hook = FALSE; HookScriptStatus res; static const char* edit_your_xf86config = "Please update your XF86Config or xorg.conf file as " "appropriate; see the file /usr/share/doc/" "NVIDIA_GLX-1.0/README.txt for details."; /* * validate the manifest file in the cwd, and process it, building * a Package struct */ if ((p = parse_manifest(op)) == NULL) goto failed; if (!op->x_files_packaged) { edit_your_xf86config = ""; } ui_set_title(op, "%s (%s)", p->description, p->version); /* * warn the user if "legacy" GPUs are installed in this system * and if no supported GPU is found, at all. */ check_for_nvidia_graphics_devices(op, p); /* check that we are not running any X server */ if (!check_for_running_x(op)) goto failed; /* make sure the kernel module is unloaded */ if (!check_for_unloaded_kernel_module(op)) goto failed; /* ask the user to accept the license */ if (!get_license_acceptance(op)) goto exit_install; ui_log(op, "Installing NVIDIA driver version %s.", p->version); /* * determine the current NVIDIA version (if any); ask the user if * they really want to overwrite the existing installation */ if (!check_for_existing_driver(op, p)) goto exit_install; /* * check to see if an alternate method of installation is already installed * or is available, but not installed; ask the user if they really want to * install anyway despite the presence/availability of an alternate install. */ if (!check_for_alternate_install(op)) goto exit_install; /* run the distro preinstall hook */ res = run_distro_hook(op, "pre-install"); if (res == HOOK_SCRIPT_FAIL) { if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES, NUM_CONTINUE_ABORT_CHOICES, CONTINUE_CHOICE, /* Default choice */ "The distribution-provided pre-install " "script failed! Are you sure you want " "to continue?") == ABORT_CHOICE) { goto failed; } } else if (res == HOOK_SCRIPT_SUCCESS) { if (ui_multiple_choice(op, CONTINUE_ABORT_CHOICES, NUM_CONTINUE_ABORT_CHOICES, CONTINUE_CHOICE, /* Default choice */ "The distribution-provided pre-install script " "completed successfully. If this is the first " "time you have run the installer, this script " "may have helped disable Nouveau, but a reboot " "may be required first. " "Would you like to continue, or would you " "prefer to abort installation to reboot the " "system?") == ABORT_CHOICE) { goto exit_install; } ran_pre_install_hook = TRUE; } /* fail if the nouveau driver is currently in use */ if (!check_for_nouveau(op)) goto failed; /* ask if we should install the UVM kernel module */ should_install_uvm(op, p); /* attempt to build the kernel modules for the target kernel */ if (!op->no_kernel_module) { if (!install_kernel_modules(op, p)) { goto failed; } } else { ui_warn(op, "You specified the '--no-kernel-module' command line " "option, nvidia-installer will not install a kernel " "module as part of this driver installation, and it will " "not remove existing NVIDIA kernel modules not part of " "an earlier NVIDIA driver installation. Please ensure " "that an NVIDIA kernel module matching this driver version " "is installed seperately."); /* no_kernel_module should imply no DKMS */ if (op->dkms) { ui_warn(op, "You have specified both the '--no-kernel-module' " "and the '--dkms' command line options. The '--dkms' " "option will be ignored."); op->dkms = FALSE; } } /* * if we are only installing the kernel module, then remove * everything else from the package; otherwise do some * OpenGL-specific stuff */ if (op->kernel_module_only) { remove_non_kernel_module_files_from_package(op, p); } else { /* ask for the XFree86 and OpenGL installation prefixes. */ if (!get_prefixes(op)) goto failed; /* ask if we should install the OpenGL header files */ should_install_opengl_headers(op, p); /* * select the appropriate TLS class, modifying the package as * necessary. */ select_tls_class(op, p); /* * if the package contains any libGL.la or .desktop files, * process them (perform some search and replacing so * that they reflect the correct installation path, etc) * and add them to the package list (files to be installed). */ process_libGL_la_files(op, p); process_dot_desktop_files(op, p); #if defined(NV_X86_64) /* * ask if we should install the 32bit compatibility files on * this machine. */ should_install_compat32_files(op, p); #endif /* NV_X86_64 */ } if (op->no_opengl_files) { remove_opengl_files_from_package(op, p); } /* * now that we have the installation prefixes, build the * destination for each file to be installed */ if (!set_destinations(op, p)) goto failed; /* * if we are installing OpenGL libraries, ensure that a symlink gets * installed to /usr/lib/libGL.so.1. add_libgl_abi_symlink() sets its own * destination, so it must be called after set_destinations(). */ if (!op->kernel_module_only && !op->no_opengl_files) { add_libgl_abi_symlink(op, p); } /* * uninstall the existing driver; this needs to be done before * building the command list. * * XXX if we uninstall now, then build the command list, and * then ask the user if they really want to execute the * command list, if the user decides not to execute the * command list, they'll be left with no driver installed. */ if (!op->kernel_module_only) { if (!run_existing_uninstaller(op)) goto failed; } if (!check_libglvnd_files(op, p)) { goto failed; } /* build a list of operations to execute to do the install */ if ((c = build_command_list(op, p)) == NULL) goto failed; /* call the ui to get approval for the list of commands */ if (!ui_approve_command_list(op, c, "%s", p->description)) { goto exit_install; } /* initialize the backup log file */ if (!op->kernel_module_only) { if (!init_backup(op, p)) goto failed; } /* execute the command list */ if (!do_install(op, p, c)) goto failed; /* Register, build, and install the module with DKMS, if requested */ if (op->dkms && !dkms_install_module(op, p->version, get_kernel_name(op))) goto failed; /* * Leave the RM loaded in case an X server with OutputClass-based driver * matching is being used. */ if (!op->no_kernel_module || op->dkms) { if (!load_kernel_module(op, p->kernel_modules[0].module_name)) { goto failed; } } /* run the distro postinstall script */ run_distro_hook(op, "post-install"); /* * check that everything is installed properly (post-install * sanity check) */ check_installed_files_from_package(op, p); if (!check_runtime_configuration(op, p)) goto failed; /* done */ if (op->kernel_module_only || op->no_nvidia_xconfig_question) { ui_message(op, "Installation of the kernel module for the %s " "(version %s) is now complete.", p->description, p->version); } else { /* ask the user if they would like to run nvidia-xconfig */ const char *msg = "Would you like to run the nvidia-xconfig utility " "to automatically update your X configuration file " "so that the NVIDIA X driver will be used when you " "restart X? Any pre-existing X configuration " "file will be backed up."; ret = run_nvidia_xconfig(op, FALSE, msg, op->run_nvidia_xconfig); if (ret) { ui_message(op, "Your X configuration file has been successfully " "updated. Installation of the %s (version: %s) is now " "complete.", p->description, p->version); } else { ui_message(op, "Installation of the %s (version: %s) is now " "complete. %s", p->description, p->version, edit_your_xf86config); } } free_package(p); return TRUE; failed: /* * something bad happened during installation; print an error * message and return FALSE */ if (op->logging) { ui_error(op, "Installation has failed. Please see the file '%s' " "for details. You may find suggestions on fixing " "installation problems in the README available on the " "Linux driver download page at www.nvidia.com.", op->log_file_name); } else { ui_error(op, "Installation has failed. You may find suggestions " "on fixing installation problems in the README available " "on the Linux driver download page at www.nvidia.com."); } if (ran_pre_install_hook) run_distro_hook(op, "failed-install"); /* fall through into exit_install... */ exit_install: /* * we are exiting installation; this can happen for reasons that * do not merit the error message (e.g., the user declined the * license agreement) */ free_package(p); return FALSE; } /* install_from_cwd() */
XCamReturn CLNewTonemappingImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); const VideoBufferInfo & in_video_info = input->get_video_info (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); _image_height = in_video_info.aligned_height; XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); SmartPtr<X3aStats> stats = input->find_3a_stats (); XCAM_ASSERT (stats.ptr ()); XCam3AStats *stats_ptr = stats->get_stats (); XCAM_ASSERT (stats_ptr); int stats_totalnum = stats_ptr->info.width * stats_ptr->info.height; int hist_bin_count = 1 << stats_ptr->info.bit_depth; int y_max = 0; float y_avg = 0.0f; for(int i = hist_bin_count - 1; i >= 0; i--) { if(stats_ptr->hist_y[i] > 0) { y_max = i; break; } } for(int i = 0; i < hist_bin_count - 1; i++) { y_avg += i * stats_ptr->hist_y[i]; } y_max = y_max + 1; y_avg = y_avg / stats_totalnum; int* hist_log = new int[hist_bin_count]; int* sort_y = new int[stats_totalnum + 1]; float* map_index_leq = new float[hist_bin_count]; int* map_index_log = new int[hist_bin_count]; for(int i = 0; i < hist_bin_count; i++) { hist_log[i] = 0; } int thres = hist_bin_count * (53 * hist_bin_count / 256) / (2 * y_avg + 1); int y_max0 = (y_max > thres) ? thres : y_max; int y_max1 = (y_max - thres) > 0 ? (y_max - thres) : 0; if(y_max < thres) { y_max0 = hist_bin_count - 1; } float t0 = 0.01f * y_max0; float t1 = 0.01f * y_max1; float max0_log = log(y_max0 + t0); float max1_log = log(y_max1 + t1 + 0.01f); float t0_log = log(t0); float t1_log = log(t1 + 0.01f); float factor0; if(y_max < thres) factor0 = (hist_bin_count - 1) / (max0_log - t0_log + 0.01f); else factor0 = y_max0 / (max0_log - t0_log + 0.01f); float factor1 = y_max1 / (max1_log - t1_log + 0.01f); if(y_max < thres) { for(int i = 0; i < y_max; i++) { int index = (int)((log(i + t0) - t0_log) * factor0 + 0.5f); hist_log[index] += stats_ptr->hist_y[i]; map_index_log[i] = index; } } else { for(int i = 0; i < y_max0; i++) { int index = (int)((log(i + t0) - t0_log) * factor0 + 0.5f); hist_log[index] += stats_ptr->hist_y[i]; map_index_log[i] = index; } for(int i = y_max0; i < y_max; i++) { int r = y_max - i; int index = (int)((log(r + t1) - t1_log) * factor1 + 0.5f); index = y_max - index; hist_log[index] += stats_ptr->hist_y[i]; map_index_log[i] = index; } } for(int i = y_max; i < hist_bin_count; i++) { map_index_log[i] = map_index_log[y_max - 1]; } int sort_index = 1; for(int i = 0; i < hist_bin_count; i++) { for(int l = 0; l < hist_log[i]; l++) { sort_y[sort_index] = i; sort_index++; } } sort_y[0] = 0; for(int i = 1; i < hist_bin_count; i++) { hist_log[i] += hist_log[i - 1]; } int map_leq_index[256]; Haleq(sort_y, hist_log, map_leq_index, 0, sort_y[stats_totalnum], 0, 0, 255); map_leq_index[255] = hist_bin_count; map_leq_index[0] = 0; for(int i = 1; i < 256; i++) { if(map_leq_index[i] < map_leq_index[i - 1]) map_leq_index[i] = map_leq_index[i - 1]; } int k; for(int i = 0; i < 255; i++) { for(k = map_leq_index[i]; k < map_leq_index[i + 1]; k++) { map_index_leq[k] = (float)i; } } for(int i = 0; i < hist_bin_count; i++) { _map_hist[i] = map_index_leq[map_index_log[i]] / 255.0f; } delete[] hist_log; delete[] map_index_leq; delete[] map_index_log; delete[] sort_y; _map_hist_buffer = new CLBuffer( context, sizeof(float) * hist_bin_count, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, &_map_hist); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); args[2].arg_adress = &_map_hist_buffer->get_mem_id (); args[2].arg_size = sizeof (cl_mem); args[3].arg_adress = &_image_height; args[3].arg_size = sizeof (int); arg_count = 4; const CLImageDesc out_info = _image_out->get_image_desc (); work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = out_info.width; work_size.global[1] = out_info.height / 4; work_size.local[0] = 8; work_size.local[1] = 8; return XCAM_RETURN_NO_ERROR; }
XCamReturn CLTonemappingImageKernel::prepare_arguments ( SmartPtr<DrmBoBuffer> &input, SmartPtr<DrmBoBuffer> &output, CLArgument args[], uint32_t &arg_count, CLWorkSize &work_size) { SmartPtr<CLContext> context = get_context (); _image_in = new CLVaImage (context, input); _image_out = new CLVaImage (context, output); const VideoBufferInfo & in_video_info = input->get_video_info (); _image_height = in_video_info.aligned_height; XCAM_ASSERT (_image_in->is_valid () && _image_out->is_valid ()); XCAM_FAIL_RETURN ( WARNING, _image_in->is_valid () && _image_out->is_valid (), XCAM_RETURN_ERROR_MEM, "cl image kernel(%s) in/out memory not available", get_kernel_name ()); SmartPtr<X3aStats> stats = input->find_3a_stats (); XCAM_FAIL_RETURN ( ERROR, stats.ptr (), XCAM_RETURN_ERROR_MEM, "CLTonemappingImageKernel find_3a_stats failed"); XCam3AStats *stats_ptr = stats->get_stats (); XCAM_ASSERT (stats_ptr); int pixel_totalnum = stats_ptr->info.aligned_width * stats_ptr->info.aligned_height; int pixel_num = 0; int hist_bin_count = 1 << stats_ptr->info.bit_depth; int64_t cumulative_value = 0; int saturated_thresh = pixel_totalnum * 0.003f; int percent_90_thresh = pixel_totalnum * 0.1f; int medium_thresh = pixel_totalnum * 0.5f; float y_saturated = 0; float y_percent_90 = 0; float y_average = 0; float y_medium = 0; for (int i = (hist_bin_count - 1); i >= 0; i--) { pixel_num += stats_ptr->hist_y[i]; if ((y_saturated == 0) && (pixel_num >= saturated_thresh)) { y_saturated = i; } if ((y_percent_90 == 0) && (pixel_num >= percent_90_thresh)) { y_percent_90 = i; } if ((y_medium == 0) && (pixel_num >= medium_thresh)) { y_medium = i; } cumulative_value += i * stats_ptr->hist_y[i]; } y_average = cumulative_value / pixel_totalnum; if (y_saturated < (hist_bin_count - 1)) { y_saturated = y_saturated + 1; } _y_target = (hist_bin_count / y_saturated) * (1.5 * y_medium + 0.5 * y_average) / 2; if (_y_target < 4) { _y_target = 4; } if ((_y_target > y_saturated) || (y_saturated < 4)) { _y_target = y_saturated / 4; } _y_max = hist_bin_count * (2 * y_saturated + _y_target) / y_saturated - y_saturated - _y_target; _y_target = _y_target / pow(2, stats_ptr->info.bit_depth - 8); _y_max = _y_max / pow(2, stats_ptr->info.bit_depth - 8); //set args; args[0].arg_adress = &_image_in->get_mem_id (); args[0].arg_size = sizeof (cl_mem); args[1].arg_adress = &_image_out->get_mem_id (); args[1].arg_size = sizeof (cl_mem); args[2].arg_adress = &_y_max; args[2].arg_size = sizeof (float); args[3].arg_adress = &_y_target; args[3].arg_size = sizeof (float); args[4].arg_adress = &_image_height; args[4].arg_size = sizeof (int); arg_count = 5; const CLImageDesc out_info = _image_out->get_image_desc (); work_size.dim = XCAM_DEFAULT_IMAGE_DIM; work_size.global[0] = out_info.width; work_size.global[1] = out_info.height / 4; work_size.local[0] = 8; work_size.local[1] = 8; return XCAM_RETURN_NO_ERROR; }