aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2010-09-28 13:19:26 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 05:55:46 -0400
commit28f06ff4b75a309d9255567b3a15b6a5bf63747d (patch)
treea158a7f6c91a67376ebf605f1ffd3a422ead3e3d /drivers/media
parent47654df8a925ea4f6660b357cbd4ef2ead50c6ad (diff)
[media] s5p-fimc: Do not lock both buffer queues in s_fmt
It is not necessary to lock both capture and output buffer queue while setting format for single queue. 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')
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 27379a6c503c..23cc054bd7b1 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -742,8 +742,9 @@ static int fimc_m2m_try_fmt(struct file *file, void *priv,
742static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f) 742static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
743{ 743{
744 struct fimc_ctx *ctx = priv; 744 struct fimc_ctx *ctx = priv;
745 struct v4l2_device *v4l2_dev = &ctx->fimc_dev->m2m.v4l2_dev; 745 struct fimc_dev *fimc = ctx->fimc_dev;
746 struct videobuf_queue *src_vq, *dst_vq; 746 struct v4l2_device *v4l2_dev = &fimc->m2m.v4l2_dev;
747 struct videobuf_queue *vq;
747 struct fimc_frame *frame; 748 struct fimc_frame *frame;
748 struct v4l2_pix_format *pix; 749 struct v4l2_pix_format *pix;
749 unsigned long flags; 750 unsigned long flags;
@@ -755,69 +756,61 @@ static int fimc_m2m_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
755 if (ret) 756 if (ret)
756 return ret; 757 return ret;
757 758
758 mutex_lock(&ctx->fimc_dev->lock); 759 if (mutex_lock_interruptible(&fimc->lock))
760 return -ERESTARTSYS;
759 761
760 src_vq = v4l2_m2m_get_src_vq(ctx->m2m_ctx); 762 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
761 dst_vq = v4l2_m2m_get_dst_vq(ctx->m2m_ctx); 763 mutex_lock(&vq->vb_lock);
762 764
763 mutex_lock(&src_vq->vb_lock); 765 if (videobuf_queue_is_busy(vq)) {
764 mutex_lock(&dst_vq->vb_lock); 766 v4l2_err(v4l2_dev, "%s: queue (%d) busy\n", __func__, f->type);
767 ret = -EBUSY;
768 goto sf_out;
769 }
765 770
771 spin_lock_irqsave(&ctx->slock, flags);
766 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 772 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
767 if (videobuf_queue_is_busy(src_vq)) {
768 v4l2_err(v4l2_dev, "%s queue busy\n", __func__);
769 ret = -EBUSY;
770 goto s_fmt_out;
771 }
772 frame = &ctx->s_frame; 773 frame = &ctx->s_frame;
773 spin_lock_irqsave(&ctx->slock, flags);
774 ctx->state |= FIMC_SRC_FMT; 774 ctx->state |= FIMC_SRC_FMT;
775 spin_unlock_irqrestore(&ctx->slock, flags);
776
777 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 775 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
778 if (videobuf_queue_is_busy(dst_vq)) {
779 v4l2_err(v4l2_dev, "%s queue busy\n", __func__);
780 ret = -EBUSY;
781 goto s_fmt_out;
782 }
783 frame = &ctx->d_frame; 776 frame = &ctx->d_frame;
784 spin_lock_irqsave(&ctx->slock, flags);
785 ctx->state |= FIMC_DST_FMT; 777 ctx->state |= FIMC_DST_FMT;
786 spin_unlock_irqrestore(&ctx->slock, flags);
787 } else { 778 } else {
779 spin_unlock_irqrestore(&ctx->slock, flags);
788 v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, 780 v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev,
789 "Wrong buffer/video queue type (%d)\n", f->type); 781 "Wrong buffer/video queue type (%d)\n", f->type);
790 ret = -EINVAL; 782 ret = -EINVAL;
791 goto s_fmt_out; 783 goto sf_out;
792 } 784 }
785 spin_unlock_irqrestore(&ctx->slock, flags);
793 786
794 pix = &f->fmt.pix; 787 pix = &f->fmt.pix;
795 frame->fmt = find_format(f); 788 frame->fmt = find_format(f);
796 if (!frame->fmt) { 789 if (!frame->fmt) {
797 ret = -EINVAL; 790 ret = -EINVAL;
798 goto s_fmt_out; 791 goto sf_out;
799 } 792 }
800 793
801 frame->f_width = pix->bytesperline * 8 / frame->fmt->depth; 794 frame->f_width = pix->bytesperline * 8 / frame->fmt->depth;
802 frame->f_height = pix->sizeimage/pix->bytesperline; 795 frame->f_height = pix->height;
803 frame->width = pix->width; 796 frame->width = pix->width;
804 frame->height = pix->height; 797 frame->height = pix->height;
805 frame->o_width = pix->width; 798 frame->o_width = pix->width;
806 frame->o_height = pix->height; 799 frame->o_height = pix->height;
807 frame->offs_h = 0; 800 frame->offs_h = 0;
808 frame->offs_v = 0; 801 frame->offs_v = 0;
809 frame->size = (pix->width * pix->height * frame->fmt->depth) >> 3; 802 frame->size = (pix->width * pix->height * frame->fmt->depth) >> 3;
810 src_vq->field = dst_vq->field = pix->field; 803 vq->field = pix->field;
804
811 spin_lock_irqsave(&ctx->slock, flags); 805 spin_lock_irqsave(&ctx->slock, flags);
812 ctx->state |= FIMC_PARAMS; 806 ctx->state |= FIMC_PARAMS;
813 spin_unlock_irqrestore(&ctx->slock, flags); 807 spin_unlock_irqrestore(&ctx->slock, flags);
814 808
815 dbg("f_width= %d, f_height= %d", frame->f_width, frame->f_height); 809 dbg("f_w: %d, f_h: %d", frame->f_width, frame->f_height);
816 810
817s_fmt_out: 811sf_out:
818 mutex_unlock(&dst_vq->vb_lock); 812 mutex_unlock(&vq->vb_lock);
819 mutex_unlock(&src_vq->vb_lock); 813 mutex_unlock(&fimc->lock);
820 mutex_unlock(&ctx->fimc_dev->lock);
821 return ret; 814 return ret;
822} 815}
823 816