Esempio n. 1
0
static int fimc_set_scaler_info(struct fimc_ctx *ctx)
{
    struct fimc_scaler *sc = &ctx->scaler;
    struct fimc_frame *s_frame = &ctx->s_frame;
    struct fimc_frame *d_frame = &ctx->d_frame;
    int tx, ty, sx, sy;
    int ret;

    tx = d_frame->width;
    ty = d_frame->height;
    if (tx <= 0 || ty <= 0) {
        v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev,
                 "invalid target size: %d x %d", tx, ty);
        return -EINVAL;
    }

    sx = s_frame->width;
    sy = s_frame->height;
    if (sx <= 0 || sy <= 0) {
        err("invalid source size: %d x %d", sx, sy);
        return -EINVAL;
    }

    sc->real_width = sx;
    sc->real_height = sy;
    dbg("sx= %d, sy= %d, tx= %d, ty= %d", sx, sy, tx, ty);

    ret = fimc_get_scaler_factor(sx, tx, &sc->pre_hratio, &sc->hfactor);
    if (ret)
        return ret;

    ret = fimc_get_scaler_factor(sy, ty,  &sc->pre_vratio, &sc->vfactor);
    if (ret)
        return ret;

    sc->pre_dst_width = sx / sc->pre_hratio;
    sc->pre_dst_height = sy / sc->pre_vratio;

    sc->main_hratio = (sx << 8) / (tx << sc->hfactor);
    sc->main_vratio = (sy << 8) / (ty << sc->vfactor);

    sc->scaleup_h = (tx >= sx) ? 1 : 0;
    sc->scaleup_v = (ty >= sy) ? 1 : 0;

    /* check to see if input and output size/format differ */
    if (s_frame->fmt->color == d_frame->fmt->color
            && s_frame->width == d_frame->width
            && s_frame->height == d_frame->height)
        sc->copy_mode = 1;
    else
        sc->copy_mode = 0;

    return 0;
}
Esempio n. 2
0
static int fimc_capture_scaler_info(struct fimc_control *ctrl)
{
	struct fimc_scaler *sc = &ctrl->sc;
	struct v4l2_rect *window = &ctrl->cam->window;
	int tx, ty, sx, sy;
#ifdef VIEW_FUNCTION_CALL
	printk("[FIMC_CAPTURE] %s(%d)\n", __func__, __LINE__);
#endif

	sx = window->width;
	sy = window->height;
	tx = ctrl->cap->fmt.width;
	ty = ctrl->cap->fmt.height;

	sc->real_width = sx;
	sc->real_height = sy;

	if (sx <= 0 || sy <= 0) {
		dev_err(ctrl->dev, "%s: invalid source size\n", __func__);
		return -EINVAL;
	}

	if (tx <= 0 || ty <= 0) {
		dev_err(ctrl->dev, "%s: invalid target size\n", __func__);
		return -EINVAL;
	}

	fimc_get_scaler_factor(sx, tx, &sc->pre_hratio, &sc->hfactor);
	fimc_get_scaler_factor(sy, ty, &sc->pre_vratio, &sc->vfactor);

	sc->pre_dst_width = sx / sc->pre_hratio;
	sc->pre_dst_height = sy / sc->pre_vratio;

	sc->main_hratio = (sx << 8) / (tx << sc->hfactor);
	sc->main_vratio = (sy << 8) / (ty << sc->vfactor);

//giridhar: fix from 6410 to 6442 regarding hardware problem related to zoom
	if((ctrl->sc.main_hratio & 0x01) && (ctrl->sc.main_hratio != 0x01))
	        ctrl->sc.main_hratio--;
 
	if((ctrl->sc.main_vratio & 0x01) && (ctrl->sc.main_vratio != 0x01))
        	ctrl->sc.main_vratio--;

	sc->scaleup_h = (tx >= sx) ? 1 : 0;
	sc->scaleup_v = (ty >= sy) ? 1 : 0;

	return 0;
}
Esempio n. 3
0
static int fimc_capture_scaler_info(struct fimc_control *ctrl)
{
	struct fimc_scaler *sc = &ctrl->sc;
	struct v4l2_rect *window = &ctrl->cam->window;
	int tx, ty, sx, sy;

	sx = window->width;
	sy = window->height;
	tx = ctrl->cap->fmt.width;
	ty = ctrl->cap->fmt.height;

	sc->real_width = sx;
	sc->real_height = sy;

	if (sx <= 0 || sy <= 0) {
		dev_err(ctrl->dev, "%s: invalid source size\n", __func__);
		return -EINVAL;
	}

	if (tx <= 0 || ty <= 0) {
		dev_err(ctrl->dev, "%s: invalid target size\n", __func__);
		return -EINVAL;
	}

	fimc_get_scaler_factor(sx, tx, &sc->pre_hratio, &sc->hfactor);
	fimc_get_scaler_factor(sy, ty, &sc->pre_vratio, &sc->vfactor);

	sc->pre_dst_width = sx / sc->pre_hratio;
	sc->pre_dst_height = sy / sc->pre_vratio;

	sc->main_hratio = (sx << 8) / (tx << sc->hfactor);
	sc->main_vratio = (sy << 8) / (ty << sc->vfactor);

	sc->scaleup_h = (tx >= sx) ? 1 : 0;
	sc->scaleup_v = (ty >= sy) ? 1 : 0;

	return 0;
}
Esempio n. 4
0
int fimc_set_scaler_info(struct fimc_ctx *ctx)
{
	struct fimc_variant *variant = ctx->fimc_dev->variant;
	struct device *dev = &ctx->fimc_dev->pdev->dev;
	struct fimc_scaler *sc = &ctx->scaler;
	struct fimc_frame *s_frame = &ctx->s_frame;
	struct fimc_frame *d_frame = &ctx->d_frame;
	int tx, ty, sx, sy;
	int ret;

	if (ctx->rotation == 90 || ctx->rotation == 270) {
		ty = d_frame->width;
		tx = d_frame->height;
	} else {
		tx = d_frame->width;
		ty = d_frame->height;
	}
	if (tx <= 0 || ty <= 0) {
		dev_err(dev, "Invalid target size: %dx%d", tx, ty);
		return -EINVAL;
	}

	sx = s_frame->width;
	sy = s_frame->height;
	if (sx <= 0 || sy <= 0) {
		dev_err(dev, "Invalid source size: %dx%d", sx, sy);
		return -EINVAL;
	}
	sc->real_width = sx;
	sc->real_height = sy;

	ret = fimc_get_scaler_factor(sx, tx, &sc->pre_hratio, &sc->hfactor);
	if (ret)
		return ret;

	ret = fimc_get_scaler_factor(sy, ty,  &sc->pre_vratio, &sc->vfactor);
	if (ret)
		return ret;

	sc->pre_dst_width = sx / sc->pre_hratio;
	sc->pre_dst_height = sy / sc->pre_vratio;

	if (variant->has_mainscaler_ext) {
		sc->main_hratio = (sx << 14) / (tx << sc->hfactor);
		sc->main_vratio = (sy << 14) / (ty << sc->vfactor);
	} else {
		sc->main_hratio = (sx << 8) / (tx << sc->hfactor);
		sc->main_vratio = (sy << 8) / (ty << sc->vfactor);

	}

	sc->scaleup_h = (tx >= sx) ? 1 : 0;
	sc->scaleup_v = (ty >= sy) ? 1 : 0;

	/* check to see if input and output size/format differ */
	if (s_frame->fmt->color == d_frame->fmt->color
		&& s_frame->width == d_frame->width
		&& s_frame->height == d_frame->height)
		sc->copy_mode = 1;
	else
		sc->copy_mode = 0;

	return 0;
}