Ejemplo n.º 1
0
XCamReturn
PollThread::poll_subdev_event_loop ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    struct v4l2_event event;
    int poll_ret = 0;

    poll_ret = _event_dev->poll_event (PollThread::default_subdev_event_timeout);

    if (poll_ret < 0) {
        XCAM_LOG_WARNING ("poll event failed but continue");
        ::usleep (100000); // 100ms
        return XCAM_RETURN_ERROR_TIMEOUT;
    }

    /* timeout */
    if (poll_ret == 0) {
        XCAM_LOG_DEBUG ("poll event timeout and continue");
        return XCAM_RETURN_ERROR_TIMEOUT;
    }

    xcam_mem_clear (event);
    ret = _event_dev->dequeue_event (event);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("dequeue event failed on dev:%s", XCAM_STR(_event_dev->get_device_name()));
        return XCAM_RETURN_ERROR_IOCTL;
    }

    ret = handle_events (event);
    return ret;
}
Ejemplo n.º 2
0
XCamReturn
X3aAnalyzer::init (uint32_t width, uint32_t height, double framerate)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;


    if (!_ae_handler.ptr() || !_awb_handler.ptr() ||
            !_af_handler.ptr() || !_common_handler.ptr()) {
        XCAM_LOG_WARNING (
            "analyzer:%s init failed, <prepare_handlers> need called first",
            XCAM_STR(get_name ()));
        return XCAM_RETURN_ERROR_PARAM;
    }

    XCAM_ASSERT (!_width && !_height);
    _width = width;
    _height = height;
    _framerate = framerate;

    ret = internal_init (width, height, _framerate);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("analyzer init failed");
        deinit ();
        return ret;
    }

    XCAM_LOG_INFO (
        "Analyzer(%s) initialized(w:%d, h:%d).",
        XCAM_STR(get_name()), _width, _height);
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 3
0
XCamReturn
V4l2Device::open ()
{
    struct v4l2_streamparm param;

    if (is_opened()) {
        XCAM_LOG_DEBUG ("device(%s) was already opened", XCAM_STR(_name));
        return XCAM_RETURN_NO_ERROR;
    }

    if (!_name) {
        XCAM_LOG_DEBUG ("v4l2 device open failed, there's no device name");
        return XCAM_RETURN_ERROR_PARAM;
    }
    _fd = ::open (_name, O_RDWR);
    if (_fd == -1) {
        XCAM_LOG_DEBUG ("open device(%s) failed", _name);
        return XCAM_RETURN_ERROR_IOCTL;
    }

    // set sensor id
    if (io_control (VIDIOC_S_INPUT, &_sensor_id) < 0) {
        XCAM_LOG_WARNING ("set sensor id(%d) failed but continue", _sensor_id);
    }

    // set capture mode
    xcam_mem_clear (param);
    param.type = _capture_buf_type;
    param.parm.capture.capturemode = _capture_mode;
    if (io_control (VIDIOC_S_PARM, &param) < 0) {
        XCAM_LOG_WARNING ("set capture mode(0x%08x) failed but continue", _capture_mode);
    }

    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 4
0
XCamReturn
CLKernel::load_from_source (const char *source, size_t length)
{
    cl_kernel new_kernel_id = NULL;

    XCAM_ASSERT (source);
    if (!source) {
        XCAM_LOG_WARNING ("kernel:%s source empty", XCAM_STR (_name));
        return XCAM_RETURN_ERROR_PARAM;
    }

    if (_kernel_id) {
        XCAM_LOG_WARNING ("kernel:%s already build yet", XCAM_STR (_name));
        return XCAM_RETURN_ERROR_PARAM;
    }

    XCAM_ASSERT (_context.ptr ());

    if (length == 0)
        length = strlen (source);

    new_kernel_id =
        _context->generate_kernel_id (
            this,
            (const uint8_t *)source, length,
            CLContext::KERNEL_BUILD_SOURCE);
    XCAM_FAIL_RETURN(
        WARNING,
        new_kernel_id != NULL,
        XCAM_RETURN_ERROR_CL,
        "cl kernel(%s) load from source failed", XCAM_STR (_name));

    _kernel_id = new_kernel_id;
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 5
0
XCamReturn
IspConfigTranslator::translate_exposure (
    const XCam3aResultExposure &from,
    struct atomisp_exposure &to)
{
    uint32_t coarse_time = 0, fine_time = 0;
    int32_t analog_code = 0, digital_code = 0;
    if (!_sensor->is_ready ()) {
        XCAM_LOG_WARNING ("translate exposure failed since sensor not ready");
        return XCAM_RETURN_ERROR_SENSOR;
    }
    if (!_sensor->exposure_time_to_integration (from.exposure_time, coarse_time, fine_time)) {
        XCAM_LOG_WARNING ("translate exposure time failed");
        return XCAM_RETURN_ERROR_SENSOR;
    }
    to.integration_time[0] = coarse_time;
    to.integration_time[1] = fine_time;

    if (!_sensor->exposure_gain_to_code (from.analog_gain, from.digital_gain, analog_code, digital_code)) {
        XCAM_LOG_WARNING ("translate exposure gain failed");
        return XCAM_RETURN_ERROR_SENSOR;
    }
    to.gain[0] = analog_code;
    to.gain[1] = digital_code;
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 6
0
bool
AiqCompositor::open (ia_binary_data &cpf)
{
    CmcParser cmc (cpf);

    _ia_mkn = ia_mkn_init (ia_mkn_cfg_compression, 32000, 100000);
    _ia_handle =
        ia_aiq_init (
            &cpf, NULL, NULL,
            MAX_STATISTICS_WIDTH, MAX_STATISTICS_HEIGHT,
            1, //max_num_stats_in
            cmc.get(),
            _ia_mkn);

    if (_ia_handle == NULL) {
        XCAM_LOG_WARNING ("AIQ init failed");
        return false;
    }

    _adaptor = new IaIspAdaptor22;
    XCAM_ASSERT (_adaptor.ptr());
    if (!_adaptor->init (&cpf, MAX_STATISTICS_WIDTH, MAX_STATISTICS_HEIGHT, cmc.get(), _ia_mkn)) {
        XCAM_LOG_WARNING ("AIQ isp adaptor init failed");
        return false;
    }

    _pa_result = NULL;

    XCAM_LOG_DEBUG ("Aiq compositor opened");
    return true;
}
Ejemplo n.º 7
0
XCamReturn
CLKernel::load_from_binary (const uint8_t *binary, size_t length)
{
    cl_kernel new_kernel_id = NULL;

    XCAM_ASSERT (binary);
    if (!binary || !length) {
        XCAM_LOG_WARNING ("kernel:%s binary empty", XCAM_STR (_name));
        return XCAM_RETURN_ERROR_PARAM;
    }

    if (_kernel_id) {
        XCAM_LOG_WARNING ("kernel:%s already build yet", XCAM_STR (_name));
        return XCAM_RETURN_ERROR_PARAM;
    }

    XCAM_ASSERT (_context.ptr ());

    new_kernel_id =
        _context->generate_kernel_id (
            this,
            binary, length,
            CLContext::KERNEL_BUILD_BINARY);
    XCAM_FAIL_RETURN(
        WARNING,
        new_kernel_id != NULL,
        XCAM_RETURN_ERROR_CL,
        "cl kernel(%s) load from binary failed", XCAM_STR (_name));

    _kernel_id = new_kernel_id;
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 8
0
XCamReturn
PollThread::capture_3a_stats (SmartPtr<X3aStats> &stats)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    SmartPtr<X3aIspStatistics> new_stats =
        _3a_stats_pool->get_buffer (_3a_stats_pool).dynamic_cast_ptr<X3aIspStatistics> ();

    if (!new_stats.ptr()) {
        XCAM_LOG_WARNING ("request stats buffer failed.");
        return XCAM_RETURN_ERROR_MEM;
    }

    ret = _isp_controller->get_3a_statistics (new_stats);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("get 3a stats from ISP failed");
        return ret;
    }

    if (!new_stats->fill_standard_stats ()) {
        XCAM_LOG_WARNING ("isp 3a stats failed to fill standard stats but continued");
    }

    stats = new_stats;
    return ret;
}
Ejemplo n.º 9
0
bool
CLVaImage::init_va_image (
    SmartPtr<CLContext> &context, SmartPtr<DrmBoBuffer> &bo,
    const CLImageDesc &cl_desc, uint32_t offset)
{

    uint32_t bo_name = 0;
    cl_mem mem_id = 0;
    bool need_create = true;
    cl_libva_image va_image_info;

    xcam_mem_clear (va_image_info);
    va_image_info.offset = offset;
    va_image_info.width = cl_desc.width;
    va_image_info.height = cl_desc.height;
    va_image_info.fmt = cl_desc.format;
    va_image_info.row_pitch = cl_desc.row_pitch;

    XCAM_ASSERT (bo.ptr ());

    SmartPtr<CLImageBoBuffer> cl_image_buffer = bo.dynamic_cast_ptr<CLImageBoBuffer> ();
    if (cl_image_buffer.ptr ()) {
        SmartPtr<CLImage> cl_image_data = cl_image_buffer->get_cl_image ();
        XCAM_ASSERT (cl_image_data.ptr ());
        CLImageDesc old_desc = cl_image_data->get_image_desc ();
        if (cl_desc == old_desc) {
            need_create = false;
            mem_id = cl_image_data->get_mem_id ();
        }
    }

    if (need_create) {
        if (drm_intel_bo_flink (bo->get_bo (), &bo_name) != 0) {
            XCAM_LOG_WARNING ("CLVaImage get bo flick failed");
            return false;
        }

        va_image_info.bo_name = bo_name;
        mem_id = context->create_va_image (va_image_info);
        if (mem_id == NULL) {
            XCAM_LOG_WARNING ("create va image failed");
            return false;
        }
    } else {
        va_image_info.bo_name = uint32_t(-1);
    }

    set_mem_id (mem_id, need_create);
    init_desc_by_image ();
    _va_image_info = va_image_info;
    return true;
}
Ejemplo n.º 10
0
bool
CLVaBuffer::init_va_buffer (SmartPtr<CLContext> &context, SmartPtr<DrmBoBuffer> &bo)
{
    cl_mem mem_id = NULL;
    uint32_t bo_name = 0;
    cl_import_buffer_info_intel import_buffer_info;

    xcam_mem_clear (import_buffer_info);
    import_buffer_info.fd = bo->get_fd ();
    import_buffer_info.size = bo->get_size ();
    if (import_buffer_info.fd != -1) {
        mem_id = context->import_dma_buffer (import_buffer_info);
    }

    if (mem_id == NULL) {
        drm_intel_bo_flink (bo->get_bo (), &bo_name);
        mem_id = context->create_va_buffer (bo_name);
        if (mem_id == NULL) {
            XCAM_LOG_WARNING ("CLVaBuffer create va buffer failed");
            return false;
        }
    }

    set_mem_id (mem_id);
    return true;
}
Ejemplo n.º 11
0
XCamReturn
X3aAnalyzer::prepare_handlers ()
{
    SmartPtr<AeHandler> ae_handler;
    SmartPtr<AwbHandler> awb_handler;
    SmartPtr<AfHandler> af_handler;
    SmartPtr<CommonHandler> common_handler;

    if (_ae_handler.ptr() && _awb_handler.ptr() &&
            _af_handler.ptr() && _common_handler.ptr())
        return XCAM_RETURN_NO_ERROR;

    XCAM_ASSERT (!_ae_handler.ptr() || !_awb_handler.ptr() ||
                 !_af_handler.ptr() || !_common_handler.ptr());

    ae_handler = create_ae_handler ();
    awb_handler = create_awb_handler ();
    af_handler = create_af_handler ();
    common_handler = create_common_handler ();

    if (!ae_handler.ptr() || !awb_handler.ptr() || !af_handler.ptr() || !common_handler.ptr()) {
        XCAM_LOG_WARNING ("create handlers failed");
        return XCAM_RETURN_ERROR_MEM;
    }

    _ae_handler = ae_handler;
    _awb_handler = awb_handler;
    _af_handler = af_handler;
    _common_handler = common_handler;

    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 12
0
VkCommandPool
VKDevice::create_cmd_pool (VkFlags queue_flag)
{
    XCAM_ASSERT (XCAM_IS_VALID_VK_ID (_dev_id));
    XCAM_ASSERT (_instance.ptr ());
    VkCommandPool pool_id = VK_NULL_HANDLE;

    VkCommandPoolCreateInfo create_pool_info = {};
    create_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
    create_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;

    if (queue_flag == VK_QUEUE_COMPUTE_BIT)
        create_pool_info.queueFamilyIndex = _instance->get_compute_queue_family_idx ();
    else if (queue_flag == VK_QUEUE_GRAPHICS_BIT)
        create_pool_info.queueFamilyIndex = _instance->get_graphics_queue_family_idx ();
    else {
        XCAM_LOG_WARNING ("VKDevice create command pool failed, queue_flag(%d) not supported.", queue_flag);
        return VK_NULL_HANDLE;
    }

    XCAM_VK_CHECK_RETURN (
        ERROR, vkCreateCommandPool (_dev_id, &create_pool_info,  _allocator.ptr (), &pool_id),
        VK_NULL_HANDLE, "VKDevice create command pool failed.");
    return pool_id;
}
Ejemplo n.º 13
0
bool
CLContext::init_context ()
{
    cl_context context_id = NULL;
    cl_int err_code = 0;
    cl_device_id device_id = _device->get_device_id ();

    XCAM_ASSERT (_context_id == NULL);

    if (!_device->is_inited()) {
        XCAM_LOG_DEBUG ("create cl context failed since device ");
        return false;
    }

    context_id =
        clCreateContext (NULL, 1, &device_id,
                         CLContext::context_pfn_notify, this,
                         &err_code);
    if (err_code != CL_SUCCESS)
    {
        XCAM_LOG_WARNING ("create cl context failed, error:%d", err_code);
        return false;
    }
    _context_id = context_id;
    return true;
}
Ejemplo n.º 14
0
uint32_t
VideoBufferInfo::get_pixel_bytes (const uint32_t format) const
{
    uint32_t bytes = 0;

    switch (format) {
    case V4L2_PIX_FMT_NV12:
    case V4L2_PIX_FMT_SBGGR8:
    case V4L2_PIX_FMT_SGBRG8:
    case V4L2_PIX_FMT_SGRBG8:
    case V4L2_PIX_FMT_SRGGB8:
        bytes = 1;
        break;

    case V4L2_PIX_FMT_YUYV:
    case V4L2_PIX_FMT_RGB565:
    case V4L2_PIX_FMT_SBGGR10:
    case V4L2_PIX_FMT_SGBRG10:
    case V4L2_PIX_FMT_SGRBG10:
    case V4L2_PIX_FMT_SRGGB10:
    case V4L2_PIX_FMT_SBGGR12:
    case V4L2_PIX_FMT_SGBRG12:
    case V4L2_PIX_FMT_SGRBG12:
    case V4L2_PIX_FMT_SRGGB12:
    case V4L2_PIX_FMT_SBGGR16:
    case XCAM_PIX_FMT_SGRBG16:
        bytes = 2;
        break;

    case V4L2_PIX_FMT_RGB24:
        bytes = 3;
        break;

    case V4L2_PIX_FMT_RGBA32:
    case V4L2_PIX_FMT_XBGR32:
    case V4L2_PIX_FMT_ABGR32:
    case V4L2_PIX_FMT_BGR32:
    case V4L2_PIX_FMT_RGB32:
    case V4L2_PIX_FMT_ARGB32:
    case V4L2_PIX_FMT_XRGB32:
        bytes = 4;
        break;

    case XCAM_PIX_FMT_RGB48:
        bytes = 3 * 2;
        break;

    case XCAM_PIX_FMT_RGBA64:
        bytes = 4 * 2;
        break;

    case XCAM_PIX_FMT_LAB:
        bytes = 3 * 4;
        break;
    default:
        XCAM_LOG_WARNING ("VideoBufferInfo get_pixel_bytes failed, unsupported format:%s", xcam_fourcc_to_string (format));
    }

    return bytes;
}
Ejemplo n.º 15
0
bool
AiqCompositor::set_sensor_mode_data (struct atomisp_sensor_mode_data *sensor_mode)
{
    _frame_params.horizontal_crop_offset = sensor_mode->crop_horizontal_start;
    _frame_params.vertical_crop_offset = sensor_mode->crop_vertical_start;
    _frame_params.cropped_image_height = sensor_mode->crop_vertical_end - sensor_mode->crop_vertical_start + 1;
    _frame_params.cropped_image_width = sensor_mode->crop_horizontal_end - sensor_mode->crop_horizontal_start + 1;

    /* hard code to 254? */
    _frame_params.horizontal_scaling_denominator = 254;
    _frame_params.vertical_scaling_denominator = 254;

    if ((_frame_params.cropped_image_width == 0) || (_frame_params.cropped_image_height == 0)) {
        _frame_params.horizontal_scaling_numerator = 0;
        _frame_params.vertical_scaling_numerator = 0;
    } else {
        _frame_params.horizontal_scaling_numerator =
            sensor_mode->output_width * 254 * sensor_mode->binning_factor_x / _frame_params.cropped_image_width;
        _frame_params.vertical_scaling_numerator =
            sensor_mode->output_height * 254 * sensor_mode->binning_factor_y / _frame_params.cropped_image_height;
    }

    if (!_ae_handler->set_description (sensor_mode)) {
        XCAM_LOG_WARNING ("AIQ set ae description failed");
        return XCAM_RETURN_ERROR_AIQ;
    }
    return true;
}
Ejemplo n.º 16
0
bool CLImage2DArray::init_image_2d_array (
    SmartPtr<CLContext> &context,
    const CLImageDesc &desc,
    cl_mem_flags  flags)
{
    cl_mem mem_id = 0;
    cl_image_desc cl_desc;

    xcam_mem_clear (cl_desc);
    cl_desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
    cl_desc.image_width = desc.width;
    cl_desc.image_height = desc.height;
    cl_desc.image_depth = 1;
    cl_desc.image_array_size = desc.array_size;
    cl_desc.image_row_pitch = 0;
    cl_desc.image_slice_pitch = 0;
    cl_desc.num_mip_levels = 0;
    cl_desc.num_samples = 0;
    cl_desc.buffer = NULL;

    mem_id = context->create_image (flags, desc.format, cl_desc);
    if (mem_id == NULL) {
        XCAM_LOG_WARNING ("CLImage2D create image 2d failed");
        return false;
    }
    set_mem_id (mem_id);
    init_desc_by_image ();
    return true;
}
Ejemplo n.º 17
0
XCamReturn
SmartAnalyzer::analyze (SmartPtr<BufferProxy> &buffer)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    X3aResultList results;

    if (!buffer.ptr ()) {
        XCAM_LOG_DEBUG ("SmartAnalyzer::analyze got NULL buffer!");
        return XCAM_RETURN_ERROR_PARAM;
    }

    SmartHandlerList::iterator i_handler = _handlers.begin ();
    for (; i_handler != _handlers.end ();  ++i_handler)
    {
        SmartPtr<SmartAnalysisHandler> handler = *i_handler;
        if (!handler->is_valid ())
            continue;

        ret = handler->analyze (buffer, results);
        if (ret != XCAM_RETURN_NO_ERROR && ret != XCAM_RETURN_BYPASS) {
            XCAM_LOG_WARNING ("smart analyzer analyze handler(%s) context failed", XCAM_STR(handler->get_name()));
            handler->destroy_context ();
        }
    }

    if (!results.empty ()) {
        set_results_timestamp (results, buffer->get_timestamp ());
        notify_calculation_done (results);
    }

    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 18
0
bool
CL3aImageProcessor::set_output_format (uint32_t fourcc)
{
    switch (fourcc) {
    case XCAM_PIX_FMT_RGBA64:
    case V4L2_PIX_FMT_XBGR32:
    case V4L2_PIX_FMT_ABGR32:
    case V4L2_PIX_FMT_BGR32:
    case V4L2_PIX_FMT_RGB32:
    case V4L2_PIX_FMT_ARGB32:
    case V4L2_PIX_FMT_XRGB32:
        _out_smaple_type = OutSampleRGB;
        break;
    case V4L2_PIX_FMT_NV12:
        _out_smaple_type = OutSampleYuv;
        break;
    default:
        XCAM_LOG_WARNING (
            "cl 3a processor doesn't support output format:%s",
            xcam_fourcc_to_string(fourcc));
        return false;
    }

    _output_fourcc = fourcc;
    return true;
}
Ejemplo n.º 19
0
bool
CLVaImage::merge_multi_plane (
    const VideoBufferInfo &video_info,
    CLImageDesc &cl_desc)
{
    if (cl_desc.array_size <= 1)
        return true;

    switch (video_info.format) {
    case V4L2_PIX_FMT_NV12:
        cl_desc.height = video_info.aligned_height + video_info.height / 2;
        break;

    case XCAM_PIX_FMT_RGB48_planar:
    case XCAM_PIX_FMT_RGB24_planar:
        cl_desc.height = video_info.aligned_height * 3;
        break;

    case XCAM_PIX_FMT_SGRBG16_planar:
    case XCAM_PIX_FMT_SGRBG8_planar:
        cl_desc.height = video_info.aligned_height * 4;
        break;

    default:
        XCAM_LOG_WARNING ("CLVaImage unknow format(%s) plane change", xcam_fourcc_to_string(video_info.format));
        return false;
    }
    cl_desc.array_size = 0;
    cl_desc.slice_pitch = 0;
    return true;
}
Ejemplo n.º 20
0
XCamReturn
V4l2Device::init_buffer_pool ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    uint32_t i = 0;

    _buf_pool.clear ();
    _buf_pool.reserve (_buf_count);

    for (; i < _buf_count; i++) {
        SmartPtr<V4l2Buffer> new_buf;
        ret = allocate_buffer (new_buf, _format, i);
        if (ret != XCAM_RETURN_NO_ERROR) {
            break;
        }
        _buf_pool.push_back (new_buf);
    }

    if (_buf_pool.empty()) {
        XCAM_LOG_ERROR ("No bufer allocated in device(%s)", XCAM_STR (_name));
        return XCAM_RETURN_ERROR_MEM;
    }

    if (i != _buf_count) {
        XCAM_LOG_WARNING (
            "device(%s) allocate buffer count:%d failback to %d",
            XCAM_STR (_name), _buf_count, i);
        _buf_count = i;
    }

    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 21
0
XCamReturn
FakePollThread::poll_buffer_loop ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    if (!_buf_pool.ptr () && init_buffer_pool () != XCAM_RETURN_NO_ERROR)
        return XCAM_RETURN_ERROR_MEM;

    SmartPtr<DrmBoBuffer> buf =
        _buf_pool->get_buffer (_buf_pool).dynamic_cast_ptr<DrmBoBuffer> ();
    if (!buf.ptr ()) {
        XCAM_LOG_WARNING ("FakePollThread get buffer failed");
        return XCAM_RETURN_ERROR_MEM;
    }

    ret = read_buf (buf);
    if (ret == XCAM_RETURN_BYPASS) {
        ret = read_buf (buf);
    }

    SmartPtr<VideoBuffer> video_buf = buf;
    if (ret == XCAM_RETURN_NO_ERROR && _poll_callback)
        return _poll_callback->poll_buffer_ready (video_buf);

    return ret;
}
Ejemplo n.º 22
0
XCamReturn AiqCompositor::integrate (X3aResultList &results)
{
    IspInputParameters isp_params;
    ia_aiq_pa_input_params pa_input;
    ia_aiq_pa_results *pa_result = NULL;
    ia_err ia_error = ia_err_none;
    ia_binary_data output;
    AiqAeHandler *aiq_ae = _ae_handler.ptr();
    AiqAwbHandler *aiq_awb = _awb_handler.ptr();
    AiqAfHandler *aiq_af = _af_handler.ptr();
    AiqCommonHandler *aiq_common = _common_handler.ptr();
    struct atomisp_parameters *isp_3a_result = NULL;
    SmartPtr<X3aResult> isp_results;

    XCAM_FAIL_RETURN (
        ERROR,
        aiq_ae && aiq_awb && aiq_af && aiq_common,
        XCAM_RETURN_ERROR_PARAM,
        "handlers are not AIQ inherited");

    xcam_mem_clear (&pa_input);
    pa_input.frame_use = _frame_use;
    pa_input.awb_results = aiq_awb->get_result ();
    if (aiq_ae->is_started())
        pa_input.exposure_params = (aiq_ae->get_result ())->exposures[0].exposure;
    pa_input.sensor_frame_params = &_frame_params;
    pa_input.color_gains = NULL;

    ia_error = ia_aiq_pa_run (_ia_handle, &pa_input, &pa_result);
    if (ia_error != ia_err_none) {
        XCAM_LOG_WARNING ("AIQ pa run failed"); // but not return error
    }
    _pa_result = pa_result;

    isp_params.frame_use = _frame_use;
    isp_params.awb_results = aiq_awb->get_result ();
    if (aiq_ae->is_started())
        isp_params.exposure_results = (aiq_ae->get_result ())->exposures[0].exposure;
    isp_params.gbce_results = aiq_common->get_gbce_result ();
    isp_params.sensor_frame_params = &_frame_params;
    isp_params.pa_results = pa_result;

    isp_params.manual_brightness = (int8_t)(aiq_common->get_brightness_unlock() * 128.0);
    isp_params.manual_contrast = (int8_t)(aiq_common->get_contrast_unlock() * 128.0);
    isp_params.manual_saturation = (int8_t)(aiq_common->get_saturation_unlock() * 128.0);
    isp_params.manual_hue = (int8_t)(aiq_common->get_hue_unlock() * 128.0);
    isp_params.manual_sharpness = (int8_t)(aiq_common->get_sharpness_unlock() * 128.0);
    isp_params.manual_nr_level = (int8_t)(aiq_common->get_nr_level_unlock() * 128.0);

    xcam_mem_clear (&output);
    if (!_adaptor->run (&isp_params, &output)) {
        XCAM_LOG_ERROR("Aiq to isp adaptor running failed");
        return XCAM_RETURN_ERROR_ISP;
    }
    isp_3a_result = ((struct atomisp_parameters *)output.data);
    isp_results = generate_3a_configs (isp_3a_result);
    results.push_back (isp_results);
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 23
0
bool
CLDevice::init ()
{
    cl_platform_id platform_id = NULL;
    cl_device_id   device_id = NULL;
    cl_uint num_platform = 0;
    cl_uint num_device = 0;
    CLDevieInfo device_info;

    if (clGetPlatformIDs (1, &platform_id, &num_platform) != CL_SUCCESS)
    {
        XCAM_LOG_WARNING ("get cl platform ID failed");
        return false;
    }
    XCAM_ASSERT (num_platform >= 1);

    if (clGetDeviceIDs (platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_device) != CL_SUCCESS)
    {
        XCAM_LOG_WARNING ("get cl device ID failed");
        return false;
    }
    XCAM_ASSERT (num_device >= 1);

    // only query first device info
    if (!query_device_info (device_id, device_info)) {
        //continue
        XCAM_LOG_WARNING ("cl get device info failed but continue");
    } else {
        XCAM_LOG_DEBUG (
            "cl get device info,\n"
            "\tmax_compute_unit:%d"
            "\tmax_work_item_dims:%d"
            "\tmax_work_item_sizes:{%d, %d, %d}"
            "\tmax_work_group_size:%d",
            device_info.max_compute_unit,
            device_info.max_work_item_dims,
            device_info.max_work_item_sizes[0], device_info.max_work_item_sizes[1], device_info.max_work_item_sizes[2],
            device_info.max_work_group_size);
    }

    _platform_id = platform_id;
    _device_id = device_id;
    _device_info = device_info;
    _inited = true;
    return true;
}
Ejemplo n.º 24
0
void
AnalyzerCallback::x3a_calculation_failed (X3aAnalyzer *analyzer, int64_t timestamp, const char *msg)
{
    XCAM_UNUSED (analyzer);

    XCAM_LOG_WARNING (
        "Calculate 3a result failed, ts(" XCAM_TIMESTAMP_FORMAT "), msg:%s",
        XCAM_TIMESTAMP_ARGS (timestamp), XCAM_STR (msg));
}
Ejemplo n.º 25
0
bool
V4l2Device::set_mem_type (enum v4l2_memory type) {
    if (is_activated ()) {
        XCAM_LOG_WARNING ("device(%s) set mem type failed", XCAM_STR (_name));
        return false;
    }
    _memory_type = type;
    return true;
}
Ejemplo n.º 26
0
XCamReturn
IspController::get_isp_parameter (struct atomisp_parm &parameters)
{
    if ( _device->io_control (ATOMISP_IOC_G_ISP_PARM, &parameters) < 0) {
        XCAM_LOG_WARNING (" get ISP parameters failed");
        return XCAM_RETURN_ERROR_IOCTL;
    }
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 27
0
XCamReturn
IspController::get_sensor_mode_data (struct atomisp_sensor_mode_data &sensor_mode_data)
{
    if ( _device->io_control (ATOMISP_IOC_G_SENSOR_MODE_DATA, &sensor_mode_data) < 0) {
        XCAM_LOG_WARNING (" get ISP sensor mode data failed");
        return XCAM_RETURN_ERROR_IOCTL;
    }
    return XCAM_RETURN_NO_ERROR;
}
Ejemplo n.º 28
0
bool
V4l2Device::set_capture_mode (uint32_t capture_mode)
{
    if (is_opened()) {
        XCAM_LOG_WARNING ("can't set sensor id since device opened");
        return false;
    }
    _capture_mode = capture_mode;
    return true;
}
Ejemplo n.º 29
0
bool
V4l2Device::set_sensor_id (int id)
{
    if (is_opened()) {
        XCAM_LOG_WARNING ("can't set sensor id since device opened");
        return false;
    }
    _sensor_id = id;
    return true;
}
Ejemplo n.º 30
0
bool
V4l2Device::set_buffer_count (uint32_t buf_count)
{
    if (is_activated ()) {
        XCAM_LOG_WARNING ("device(%s) set buffer count failed", XCAM_STR (_name));
        return false;
    }
    _buf_count = buf_count;
    return true;
}