Example #1
0
static int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_buf)
{
    int ret =0;

    if (fimc_v4l2_stream_on(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT) < 0) {
        ALOGE("Fail : v4l2_stream_on()");
        return -1;
    }

    if (fimc_v4l2_queue(fd, fimc_buf) < 0) {
        ALOGE("Fail : v4l2_queue()");
        ret = -1;
        goto stream_off;
    }

    if (fimc_v4l2_dequeue(fd) < 0) {
        ALOGE("Fail : v4l2_dequeue()");
        ret = -1;
        goto stream_off;
    }

stream_off:
    if (fimc_v4l2_stream_off(fd) < 0) {
        ALOGE("Fail : v4l2_stream_off()");
        return -1;
    }

    if (fimc_v4l2_clr_buf(fd) < 0) {
        ALOGE("Fail : v4l2_clr_buf()");
        return -1;
    }

    return ret;
}
Example #2
0
bool SecFimc::destroy()
{
    if(mFlagCreate == false)
    {
        LOGE("%s:: Already Destroyed.. fail \n", __func__);
        return false;
    }

    LOGD("SecFimc::destroy()\n");

    /*
    if(mFimcOvlyMode == FIMC_OVLY_DMA_AUTO)
        LOGD("############# SecFimc::destroy(FIMC_OVLY_DMA_AUTO) called \n");
    else if(mFimcOvlyMode == FIMC_OVLY_NONE_SINGLE_BUF)
        LOGD("############# SecFimc::destroy(FIMC_OVLY_NONE_SINGLE_BUF) called \n");
    else
        LOGD("############# SecFimc::destroy(%x) called \n", mFimcOvlyMode);
    */
#ifdef DEBUG_LIB_FIMC
    LOGD("%s", __func__);
#endif
    if(fimc_v4l2_clr_buf(mS5pFimc.dev_fd) < 0)
    {
        LOGE("%s :: fimc_v4l2_clr_buf() fail", __func__);
        return false;
    }

    if(mS5pFimc.out_buf.phys_addr != NULL) {
        mS5pFimc.out_buf.phys_addr = NULL;
        mS5pFimc.out_buf.length = 0;
    }

    /* close */
    if(0 < mS5pFimc.dev_fd)
        close(mS5pFimc.dev_fd);
    mS5pFimc.dev_fd = 0;

    mFlagCreate = false;

    return true;
}
Example #3
0
bool SecFimc::setSrcParams(unsigned int width, unsigned int height,
                           unsigned int cropX, unsigned int cropY,
                           unsigned int* cropWidth, unsigned int* cropHeight,
                           int colorFormat,
                           bool forceChange)
{
#ifdef DEBUG_LIB_FIMC
    LOGD("%s", __func__);
#endif
    if(mFlagCreate == false)
    {
        LOGE("%s :: libFimc is not created", __func__);
        return false;
    }

    int fimcColorFormat = HAL_PIXEL_FORMAT_2_V4L2_PIX(colorFormat);
    if(fimcColorFormat < 0)
    {
        LOGE("%s:: not supported color format(0x%x)", __func__, colorFormat);
        return false;
    }

    s5p_fimc_params_t* params = &(mS5pFimc.params);
    unsigned int fimcWidth  = *cropWidth;
    unsigned int fimcHeight = *cropHeight;
    checkFimcSrcSize(width, height, cropX, cropY, &fimcWidth, &fimcHeight,
            fimcColorFormat, true);

    if(fimcWidth != *cropWidth || fimcHeight != *cropHeight)
    {
        if(forceChange){
#ifdef DEBUG_LIB_FIMC
            LOGD("size is changed from [w = %d, h= %d] to [w = %d, h = %d]",
                    *cropWidth, *cropHeight, fimcWidth, fimcHeight);
#endif
        }
        else{
            LOGE("%s :: invalid source params", __func__);
            return false;
        }
    }


#if 1
    if(   (params->src.full_width == width) && (params->src.full_height == height)
       && (params->src.start_x == cropX) &&  (params->src.start_y == cropY)
       && (params->src.width == fimcWidth) && (params->src.height == fimcHeight)
       && (params->src.color_space == fimcColorFormat))
        return true;
#endif

    params->src.full_width  = width;
    params->src.full_height = height;
    params->src.start_x     = cropX;
    params->src.start_y     = cropY;
    params->src.width       = fimcWidth;
    params->src.height      = fimcHeight;
    params->src.color_space = fimcColorFormat;

#ifdef DEBUG_LIB_FIMC
    LOGD("%s:: fd = %d", __func__, (int)mS5pFimc.dev_fd);
    LOGD("%s:: full_width = %d, full_height = %d, x = %d, y = %d, width = %d, height = %d",
            __func__, params->src.full_width, params->src.full_height,
            params->src.start_x, params->src.start_y, params->src.width, params->src.height);
#endif

    if(mFlagSetSrcParam == true)
    {
        if(fimc_v4l2_clr_buf(mS5pFimc.dev_fd) < 0)
        {
            LOGE("%s:: fimc_v4l2_clr_buf() fail", __func__);
            return false;
        }
    }

#ifdef DEBUG_LIB_FIMC
    LOGD("fimc_v4l2_set_src is called");
#endif
    if(fimc_v4l2_set_src(mS5pFimc.dev_fd, mS5pFimc.hw_ver, &(params->src)) < 0)
    {
        LOGE("%s:: fimc_v4l2_set_src() fail", __func__);
        return false;
    }

    if(fimc_v4l2_req_buf(mS5pFimc.dev_fd, &mBufNum, 0) < 0)
    {
        LOGE("%s:: fimc_v4l2_req_buf() fail", __func__);
        return false;
    }

    *cropWidth  = fimcWidth;
    *cropHeight = fimcHeight;

    mFlagSetSrcParam = true;
    return true;
}