static CSC_ERRORCODE csc_set_format( void *handle) { CSC_HANDLE *csc_handle; CSC_ERRORCODE ret = CSC_ErrorNone; if (handle == NULL) return CSC_ErrorNotInit; csc_handle = (CSC_HANDLE *)handle; if (csc_handle->csc_method == CSC_METHOD_HW) { switch (csc_handle->csc_hw_type) { case CSC_HW_TYPE_FIMC: break; #ifdef ENABLE_GSCALER case CSC_HW_TYPE_GSCALER: exynos_gsc_set_src_format( csc_handle->csc_hw_handle, ALIGN(csc_handle->src_format.width, GSCALER_IMG_ALIGN), ALIGN(csc_handle->src_format.height, GSCALER_IMG_ALIGN), csc_handle->src_format.crop_left, csc_handle->src_format.crop_top, csc_handle->src_format.crop_width, csc_handle->src_format.crop_height, HAL_PIXEL_FORMAT_2_V4L2_PIX(csc_handle->src_format.color_format), csc_handle->src_format.cacheable, csc_handle->hw_property.mode_drm); exynos_gsc_set_dst_format( csc_handle->csc_hw_handle, ALIGN(csc_handle->dst_format.width, GSCALER_IMG_ALIGN), ALIGN(csc_handle->dst_format.height, GSCALER_IMG_ALIGN), csc_handle->dst_format.crop_left, csc_handle->dst_format.crop_top, csc_handle->dst_format.crop_width, csc_handle->dst_format.crop_height, HAL_PIXEL_FORMAT_2_V4L2_PIX(csc_handle->dst_format.color_format), csc_handle->dst_format.cacheable, csc_handle->hw_property.mode_drm, 0); break; #endif default: ALOGE("%s:: unsupported csc_hw_type", __func__); break; } } return ret; }
bool SecFimc::setDstParams(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; } unsigned int fimcWidth = *cropWidth; unsigned int fimcHeight = *cropHeight; int ret_val; struct v4l2_framebuffer fbuf; struct v4l2_format sFormat; 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); checkFimcDstSize(width, height, cropX, cropY, &fimcWidth, &fimcHeight, fimcColorFormat, mRotVal, true); params->dst.color_space = fimcColorFormat; 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 destination params", __func__); return false; } } if (90 == mRotVal || 270 == mRotVal) { params->dst.full_width = height; params->dst.full_height = width; if( 90 == mRotVal ) { params->dst.start_x = cropY; params->dst.start_y = width - (cropX + fimcWidth); } else { params->dst.start_x = height - (cropY + fimcHeight); params->dst.start_y = cropX; } params->dst.width = fimcHeight; params->dst.height = fimcWidth; // work-around if(0x50 != mS5pFimc.hw_ver) params->dst.start_y += (fimcWidth - params->dst.height); } else { params->dst.full_width = width; params->dst.full_height = height; if( 180 == mRotVal ) { params->dst.start_x = width - (cropX + fimcWidth); params->dst.start_y = height - (cropY + fimcHeight); } else { params->dst.start_x = cropX; params->dst.start_y = cropY; } params->dst.width = fimcWidth; params->dst.height = fimcHeight; } #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->dst.full_width, params->dst.full_height, params->dst.start_x, params->dst.start_y, params->dst.width, params->dst.height); #endif #ifdef DEBUG_LIB_FIMC LOGD("fimc_v4l2_set_dst is called"); #endif if(fimc_v4l2_set_dst(mS5pFimc.dev_fd, &(params->dst), mRotVal, (unsigned int)mS5pFimc.out_buf.phys_addr) < 0) { LOGE("%s :: fimc_v4l2_set_dst", __func__); return false; } *cropWidth = fimcWidth; *cropHeight = fimcHeight; mFlagSetDstParam = true; return true; }
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; }
static CSC_ERRORCODE csc_set_format( void *handle) { CSC_HANDLE *csc_handle; CSC_ERRORCODE ret = CSC_ErrorNone; if (handle == NULL) return CSC_ErrorNotInit; csc_handle = (CSC_HANDLE *)handle; if (csc_handle->csc_method == CSC_METHOD_HW) { switch (csc_handle->csc_hw_type) { case CSC_HW_TYPE_FIMC: break; #ifdef ENABLE_GSCALER case CSC_HW_TYPE_GSCALER: exynos_gsc_set_src_format( csc_handle->csc_hw_handle, ALIGN(csc_handle->src_format.width, GSCALER_IMG_ALIGN), ALIGN(csc_handle->src_format.height, GSCALER_IMG_ALIGN), csc_handle->src_format.crop_left, csc_handle->src_format.crop_top, csc_handle->src_format.crop_width, csc_handle->src_format.crop_height, HAL_PIXEL_FORMAT_2_V4L2_PIX(csc_handle->src_format.color_format), csc_handle->src_format.cacheable, csc_handle->hw_property.mode_drm); exynos_gsc_set_dst_format( csc_handle->csc_hw_handle, ALIGN(csc_handle->dst_format.width, GSCALER_IMG_ALIGN), ALIGN(csc_handle->dst_format.height, GSCALER_IMG_ALIGN), csc_handle->dst_format.crop_left, csc_handle->dst_format.crop_top, csc_handle->dst_format.crop_width, csc_handle->dst_format.crop_height, HAL_PIXEL_FORMAT_2_V4L2_PIX(csc_handle->dst_format.color_format), csc_handle->dst_format.cacheable, csc_handle->hw_property.mode_drm, 0); break; #endif #ifdef ENABLE_G2D case CSC_HW_TYPE_G2D: { g2d_data *g2d = (g2d_data *)csc_handle->csc_hw_handle; g2d->src.width = ALIGN(csc_handle->src_format.width, GSCALER_IMG_ALIGN); g2d->src.height = csc_handle->src_format.height; g2d->src.stride = g2d->src.width * hal_2_g2d_bpp(csc_handle->src_format.color_format) >> 3; g2d->src.order = hal_2_g2d_pixel_order(csc_handle->src_format.color_format); g2d->src.fmt = hal_2_g2d_color_format(csc_handle->src_format.color_format); g2d->src.rect.x1 = csc_handle->src_format.crop_left; g2d->src.rect.y1 = csc_handle->src_format.crop_top; g2d->src.rect.x2 = csc_handle->src_format.crop_left + csc_handle->src_format.crop_width; g2d->src.rect.y2 = csc_handle->src_format.crop_top + csc_handle->src_format.crop_height; g2d->dst.width = ALIGN(csc_handle->dst_format.width, GSCALER_IMG_ALIGN); g2d->dst.height = csc_handle->dst_format.height; g2d->dst.stride = g2d->dst.width * hal_2_g2d_bpp(csc_handle->dst_format.color_format) >> 3; g2d->dst.order = hal_2_g2d_pixel_order(csc_handle->dst_format.color_format); g2d->dst.fmt = hal_2_g2d_color_format(csc_handle->dst_format.color_format); g2d->dst.rect.x1 = csc_handle->dst_format.crop_left; g2d->dst.rect.y1 = csc_handle->dst_format.crop_top; g2d->dst.rect.x2 = csc_handle->dst_format.crop_left + csc_handle->dst_format.crop_width; g2d->dst.rect.y2 = csc_handle->dst_format.crop_top + csc_handle->dst_format.crop_height; break; } #endif default: ALOGE("%s:: unsupported csc_hw_type", __func__); break; } } return ret; }