aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s5p-fimc
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2010-11-25 09:01:51 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-20 11:10:59 -0500
commite004e02f3a121e5293ef56eaca6ee6d4ad60bc64 (patch)
tree2c81c9a30b9706d019b37521ca31f729b7f91449 /drivers/media/video/s5p-fimc
parent09b693f0bdf360b6a8e099f26c771c9fca4c3447 (diff)
[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: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc')
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c48
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c26
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.h4
3 files changed, 59 insertions, 19 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index 017cf6c50954..1f2009271540 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -652,6 +652,50 @@ static int fimc_cap_s_ctrl(struct file *file, void *priv,
652 return ret; 652 return ret;
653} 653}
654 654
655static int fimc_cap_cropcap(struct file *file, void *fh,
656 struct v4l2_cropcap *cr)
657{
658 struct fimc_frame *f;
659 struct fimc_ctx *ctx = fh;
660 struct fimc_dev *fimc = ctx->fimc_dev;
661
662 if (cr->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
663 return -EINVAL;
664
665 if (mutex_lock_interruptible(&fimc->lock))
666 return -ERESTARTSYS;
667
668 f = &ctx->s_frame;
669 cr->bounds.left = 0;
670 cr->bounds.top = 0;
671 cr->bounds.width = f->o_width;
672 cr->bounds.height = f->o_height;
673 cr->defrect = cr->bounds;
674
675 mutex_unlock(&fimc->lock);
676 return 0;
677}
678
679static int fimc_cap_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
680{
681 struct fimc_frame *f;
682 struct fimc_ctx *ctx = file->private_data;
683 struct fimc_dev *fimc = ctx->fimc_dev;
684
685
686 if (mutex_lock_interruptible(&fimc->lock))
687 return -ERESTARTSYS;
688
689 f = &ctx->s_frame;
690 cr->c.left = f->offs_h;
691 cr->c.top = f->offs_v;
692 cr->c.width = f->width;
693 cr->c.height = f->height;
694
695 mutex_unlock(&fimc->lock);
696 return 0;
697}
698
655static int fimc_cap_s_crop(struct file *file, void *fh, 699static int fimc_cap_s_crop(struct file *file, void *fh,
656 struct v4l2_crop *cr) 700 struct v4l2_crop *cr)
657{ 701{
@@ -716,9 +760,9 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = {
716 .vidioc_g_ctrl = fimc_vidioc_g_ctrl, 760 .vidioc_g_ctrl = fimc_vidioc_g_ctrl,
717 .vidioc_s_ctrl = fimc_cap_s_ctrl, 761 .vidioc_s_ctrl = fimc_cap_s_ctrl,
718 762
719 .vidioc_g_crop = fimc_vidioc_g_crop, 763 .vidioc_g_crop = fimc_cap_g_crop,
720 .vidioc_s_crop = fimc_cap_s_crop, 764 .vidioc_s_crop = fimc_cap_s_crop,
721 .vidioc_cropcap = fimc_vidioc_cropcap, 765 .vidioc_cropcap = fimc_cap_cropcap,
722 766
723 .vidioc_enum_input = fimc_cap_enum_input, 767 .vidioc_enum_input = fimc_cap_enum_input,
724 .vidioc_s_input = fimc_cap_s_input, 768 .vidioc_s_input = fimc_cap_s_input,
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 2e7c547894b6..f45970d4b905 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -1115,7 +1115,7 @@ static int fimc_m2m_s_ctrl(struct file *file, void *priv,
1115 return 0; 1115 return 0;
1116} 1116}
1117 1117
1118int fimc_vidioc_cropcap(struct file *file, void *fh, 1118static int fimc_m2m_cropcap(struct file *file, void *fh,
1119 struct v4l2_cropcap *cr) 1119 struct v4l2_cropcap *cr)
1120{ 1120{
1121 struct fimc_frame *frame; 1121 struct fimc_frame *frame;
@@ -1139,7 +1139,7 @@ int fimc_vidioc_cropcap(struct file *file, void *fh,
1139 return 0; 1139 return 0;
1140} 1140}
1141 1141
1142int fimc_vidioc_g_crop(struct file *file, void *fh, struct v4l2_crop *cr) 1142static int fimc_m2m_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
1143{ 1143{
1144 struct fimc_frame *frame; 1144 struct fimc_frame *frame;
1145 struct fimc_ctx *ctx = file->private_data; 1145 struct fimc_ctx *ctx = file->private_data;
@@ -1167,22 +1167,22 @@ int fimc_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
1167 struct fimc_frame *f; 1167 struct fimc_frame *f;
1168 u32 min_size, halign; 1168 u32 min_size, halign;
1169 1169
1170 f = (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) ?
1171 &ctx->s_frame : &ctx->d_frame;
1172
1173 if (cr->c.top < 0 || cr->c.left < 0) { 1170 if (cr->c.top < 0 || cr->c.left < 0) {
1174 v4l2_err(&fimc->m2m.v4l2_dev, 1171 v4l2_err(&fimc->m2m.v4l2_dev,
1175 "doesn't support negative values for top & left\n"); 1172 "doesn't support negative values for top & left\n");
1176 return -EINVAL; 1173 return -EINVAL;
1177 } 1174 }
1178 1175
1179 f = ctx_get_frame(ctx, cr->type); 1176 if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1180 if (IS_ERR(f)) 1177 f = (ctx->state & FIMC_CTX_CAP) ? &ctx->s_frame : &ctx->d_frame;
1181 return PTR_ERR(f); 1178 else if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
1179 ctx->state & FIMC_CTX_M2M)
1180 f = &ctx->s_frame;
1181 else
1182 return -EINVAL;
1182 1183
1183 min_size = (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) 1184 min_size = (f == &ctx->s_frame) ?
1184 ? fimc->variant->min_inp_pixsize 1185 fimc->variant->min_inp_pixsize : fimc->variant->min_out_pixsize;
1185 : fimc->variant->min_out_pixsize;
1186 1186
1187 if (ctx->state & FIMC_CTX_M2M) { 1187 if (ctx->state & FIMC_CTX_M2M) {
1188 if (fimc->id == 1 && fimc->variant->pix_hoff) 1188 if (fimc->id == 1 && fimc->variant->pix_hoff)
@@ -1285,9 +1285,9 @@ static const struct v4l2_ioctl_ops fimc_m2m_ioctl_ops = {
1285 .vidioc_g_ctrl = fimc_vidioc_g_ctrl, 1285 .vidioc_g_ctrl = fimc_vidioc_g_ctrl,
1286 .vidioc_s_ctrl = fimc_m2m_s_ctrl, 1286 .vidioc_s_ctrl = fimc_m2m_s_ctrl,
1287 1287
1288 .vidioc_g_crop = fimc_vidioc_g_crop, 1288 .vidioc_g_crop = fimc_m2m_g_crop,
1289 .vidioc_s_crop = fimc_m2m_s_crop, 1289 .vidioc_s_crop = fimc_m2m_s_crop,
1290 .vidioc_cropcap = fimc_vidioc_cropcap 1290 .vidioc_cropcap = fimc_m2m_cropcap
1291 1291
1292}; 1292};
1293 1293
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h b/drivers/media/video/s5p-fimc/fimc-core.h
index 3e1078516560..afafebc167a6 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.h
+++ b/drivers/media/video/s5p-fimc/fimc-core.h
@@ -594,10 +594,6 @@ int fimc_vidioc_g_fmt(struct file *file, void *priv,
594 struct v4l2_format *f); 594 struct v4l2_format *f);
595int fimc_vidioc_try_fmt(struct file *file, void *priv, 595int fimc_vidioc_try_fmt(struct file *file, void *priv,
596 struct v4l2_format *f); 596 struct v4l2_format *f);
597int fimc_vidioc_g_crop(struct file *file, void *fh,
598 struct v4l2_crop *cr);
599int fimc_vidioc_cropcap(struct file *file, void *fh,
600 struct v4l2_cropcap *cr);
601int fimc_vidioc_queryctrl(struct file *file, void *priv, 597int fimc_vidioc_queryctrl(struct file *file, void *priv,
602 struct v4l2_queryctrl *qc); 598 struct v4l2_queryctrl *qc);
603int fimc_vidioc_g_ctrl(struct file *file, void *priv, 599int fimc_vidioc_g_ctrl(struct file *file, void *priv,