Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e004e02f authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab
Browse files

[media] s5p-fimc: Fix vidioc_g_crop/cropcap on camera sensor



Create separate vidioc_g_crop/vidioc_s_crop handlers for capture
video node and so image cropping parameters are properly queried
at FIMC input (image sensor) and not at FIMC output.

Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 09b693f0
Loading
Loading
Loading
Loading
+46 −2
Original line number Diff line number Diff line
@@ -652,6 +652,50 @@ static int fimc_cap_s_ctrl(struct file *file, void *priv,
	return ret;
}

static int fimc_cap_cropcap(struct file *file, void *fh,
			    struct v4l2_cropcap *cr)
{
	struct fimc_frame *f;
	struct fimc_ctx *ctx = fh;
	struct fimc_dev *fimc = ctx->fimc_dev;

	if (cr->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	if (mutex_lock_interruptible(&fimc->lock))
		return -ERESTARTSYS;

	f = &ctx->s_frame;
	cr->bounds.left		= 0;
	cr->bounds.top		= 0;
	cr->bounds.width	= f->o_width;
	cr->bounds.height	= f->o_height;
	cr->defrect		= cr->bounds;

	mutex_unlock(&fimc->lock);
	return 0;
}

static int fimc_cap_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
{
	struct fimc_frame *f;
	struct fimc_ctx *ctx = file->private_data;
	struct fimc_dev *fimc = ctx->fimc_dev;


	if (mutex_lock_interruptible(&fimc->lock))
		return -ERESTARTSYS;

	f = &ctx->s_frame;
	cr->c.left	= f->offs_h;
	cr->c.top	= f->offs_v;
	cr->c.width	= f->width;
	cr->c.height	= f->height;

	mutex_unlock(&fimc->lock);
	return 0;
}

static int fimc_cap_s_crop(struct file *file, void *fh,
			       struct v4l2_crop *cr)
{
@@ -716,9 +760,9 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = {
	.vidioc_g_ctrl			= fimc_vidioc_g_ctrl,
	.vidioc_s_ctrl			= fimc_cap_s_ctrl,

	.vidioc_g_crop			= fimc_vidioc_g_crop,
	.vidioc_g_crop			= fimc_cap_g_crop,
	.vidioc_s_crop			= fimc_cap_s_crop,
	.vidioc_cropcap			= fimc_vidioc_cropcap,
	.vidioc_cropcap			= fimc_cap_cropcap,

	.vidioc_enum_input		= fimc_cap_enum_input,
	.vidioc_s_input			= fimc_cap_s_input,
+13 −13
Original line number Diff line number Diff line
@@ -1115,7 +1115,7 @@ static int fimc_m2m_s_ctrl(struct file *file, void *priv,
	return 0;
}

int fimc_vidioc_cropcap(struct file *file, void *fh,
static int fimc_m2m_cropcap(struct file *file, void *fh,
			struct v4l2_cropcap *cr)
{
	struct fimc_frame *frame;
@@ -1139,7 +1139,7 @@ int fimc_vidioc_cropcap(struct file *file, void *fh,
	return 0;
}

int fimc_vidioc_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
static int fimc_m2m_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
{
	struct fimc_frame *frame;
	struct fimc_ctx *ctx = file->private_data;
@@ -1167,22 +1167,22 @@ int fimc_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
	struct fimc_frame *f;
	u32 min_size, halign;

	f = (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) ?
		&ctx->s_frame : &ctx->d_frame;

	if (cr->c.top < 0 || cr->c.left < 0) {
		v4l2_err(&fimc->m2m.v4l2_dev,
			"doesn't support negative values for top & left\n");
		return -EINVAL;
	}

	f = ctx_get_frame(ctx, cr->type);
	if (IS_ERR(f))
		return PTR_ERR(f);
	if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
		f = (ctx->state & FIMC_CTX_CAP) ? &ctx->s_frame : &ctx->d_frame;
	else if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
		 ctx->state & FIMC_CTX_M2M)
		f = &ctx->s_frame;
	else
		return -EINVAL;

	min_size = (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
		? fimc->variant->min_inp_pixsize
		: fimc->variant->min_out_pixsize;
	min_size = (f == &ctx->s_frame) ?
		fimc->variant->min_inp_pixsize : fimc->variant->min_out_pixsize;

	if (ctx->state & FIMC_CTX_M2M) {
		if (fimc->id == 1 && fimc->variant->pix_hoff)
@@ -1285,9 +1285,9 @@ static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = {
	.vidioc_g_ctrl			= fimc_vidioc_g_ctrl,
	.vidioc_s_ctrl			= fimc_m2m_s_ctrl,

	.vidioc_g_crop			= fimc_vidioc_g_crop,
	.vidioc_g_crop			= fimc_m2m_g_crop,
	.vidioc_s_crop			= fimc_m2m_s_crop,
	.vidioc_cropcap			= fimc_vidioc_cropcap
	.vidioc_cropcap			= fimc_m2m_cropcap

};

+0 −4
Original line number Diff line number Diff line
@@ -594,10 +594,6 @@ int fimc_vidioc_g_fmt(struct file *file, void *priv,
		      struct v4l2_format *f);
int fimc_vidioc_try_fmt(struct file *file, void *priv,
			struct v4l2_format *f);
int fimc_vidioc_g_crop(struct file *file, void *fh,
		       struct v4l2_crop *cr);
int fimc_vidioc_cropcap(struct file *file, void *fh,
			struct v4l2_cropcap *cr);
int fimc_vidioc_queryctrl(struct file *file, void *priv,
			  struct v4l2_queryctrl *qc);
int fimc_vidioc_g_ctrl(struct file *file, void *priv,