aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s5p-jpeg
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2012-02-17 09:38:09 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-01 06:09:13 -0500
commit275de24dc0076fac25e86e586c9577b8caee28ce (patch)
tree6009b39a0a77a9e1a075f34778dc2b287969f2df /drivers/media/video/s5p-jpeg
parent29fa0eedd4703b0c7c93738faf28ac9d6f930224 (diff)
[media] s5p-jpeg: Use struct v4l2_fh
This patch is a prerequisite for per file handle control handlers. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@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-jpeg')
-rw-r--r--drivers/media/video/s5p-jpeg/jpeg-core.c65
-rw-r--r--drivers/media/video/s5p-jpeg/jpeg-core.h2
2 files changed, 40 insertions, 27 deletions
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c b/drivers/media/video/s5p-jpeg/jpeg-core.c
index 1105a8749c8b..c368c4fc9243 100644
--- a/drivers/media/video/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/video/s5p-jpeg/jpeg-core.c
@@ -203,6 +203,11 @@ static const unsigned char hactblg0[162] = {
203 0xf9, 0xfa 203 0xf9, 0xfa
204}; 204};
205 205
206static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
207{
208 return container_of(fh, struct s5p_jpeg_ctx, fh);
209}
210
206static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, 211static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl,
207 unsigned long tab, int len) 212 unsigned long tab, int len)
208{ 213{
@@ -276,12 +281,16 @@ static int s5p_jpeg_open(struct file *file)
276 struct video_device *vfd = video_devdata(file); 281 struct video_device *vfd = video_devdata(file);
277 struct s5p_jpeg_ctx *ctx; 282 struct s5p_jpeg_ctx *ctx;
278 struct s5p_jpeg_fmt *out_fmt; 283 struct s5p_jpeg_fmt *out_fmt;
284 int ret = 0;
279 285
280 ctx = kzalloc(sizeof *ctx, GFP_KERNEL); 286 ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
281 if (!ctx) 287 if (!ctx)
282 return -ENOMEM; 288 return -ENOMEM;
283 289
284 file->private_data = ctx; 290 v4l2_fh_init(&ctx->fh, vfd);
291 file->private_data = &ctx->fh;
292 v4l2_fh_add(&ctx->fh);
293
285 ctx->jpeg = jpeg; 294 ctx->jpeg = jpeg;
286 if (vfd == jpeg->vfd_encoder) { 295 if (vfd == jpeg->vfd_encoder) {
287 ctx->mode = S5P_JPEG_ENCODE; 296 ctx->mode = S5P_JPEG_ENCODE;
@@ -293,22 +302,28 @@ static int s5p_jpeg_open(struct file *file)
293 302
294 ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init); 303 ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);
295 if (IS_ERR(ctx->m2m_ctx)) { 304 if (IS_ERR(ctx->m2m_ctx)) {
296 int err = PTR_ERR(ctx->m2m_ctx); 305 ret = PTR_ERR(ctx->m2m_ctx);
297 kfree(ctx); 306 goto error;
298 return err;
299 } 307 }
300 308
301 ctx->out_q.fmt = out_fmt; 309 ctx->out_q.fmt = out_fmt;
302 ctx->cap_q.fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_YUYV); 310 ctx->cap_q.fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_YUYV);
303
304 return 0; 311 return 0;
312
313error:
314 v4l2_fh_del(&ctx->fh);
315 v4l2_fh_exit(&ctx->fh);
316 kfree(ctx);
317 return ret;
305} 318}
306 319
307static int s5p_jpeg_release(struct file *file) 320static int s5p_jpeg_release(struct file *file)
308{ 321{
309 struct s5p_jpeg_ctx *ctx = file->private_data; 322 struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
310 323
311 v4l2_m2m_ctx_release(ctx->m2m_ctx); 324 v4l2_m2m_ctx_release(ctx->m2m_ctx);
325 v4l2_fh_del(&ctx->fh);
326 v4l2_fh_exit(&ctx->fh);
312 kfree(ctx); 327 kfree(ctx);
313 328
314 return 0; 329 return 0;
@@ -317,14 +332,14 @@ static int s5p_jpeg_release(struct file *file)
317static unsigned int s5p_jpeg_poll(struct file *file, 332static unsigned int s5p_jpeg_poll(struct file *file,
318 struct poll_table_struct *wait) 333 struct poll_table_struct *wait)
319{ 334{
320 struct s5p_jpeg_ctx *ctx = file->private_data; 335 struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
321 336
322 return v4l2_m2m_poll(file, ctx->m2m_ctx, wait); 337 return v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
323} 338}
324 339
325static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma) 340static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
326{ 341{
327 struct s5p_jpeg_ctx *ctx = file->private_data; 342 struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
328 343
329 return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma); 344 return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
330} 345}
@@ -448,7 +463,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
448static int s5p_jpeg_querycap(struct file *file, void *priv, 463static int s5p_jpeg_querycap(struct file *file, void *priv,
449 struct v4l2_capability *cap) 464 struct v4l2_capability *cap)
450{ 465{
451 struct s5p_jpeg_ctx *ctx = priv; 466 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
452 467
453 if (ctx->mode == S5P_JPEG_ENCODE) { 468 if (ctx->mode == S5P_JPEG_ENCODE) {
454 strlcpy(cap->driver, S5P_JPEG_M2M_NAME " encoder", 469 strlcpy(cap->driver, S5P_JPEG_M2M_NAME " encoder",
@@ -497,9 +512,7 @@ static int enum_fmt(struct s5p_jpeg_fmt *formats, int n,
497static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, 512static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
498 struct v4l2_fmtdesc *f) 513 struct v4l2_fmtdesc *f)
499{ 514{
500 struct s5p_jpeg_ctx *ctx; 515 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
501
502 ctx = priv;
503 516
504 if (ctx->mode == S5P_JPEG_ENCODE) 517 if (ctx->mode == S5P_JPEG_ENCODE)
505 return enum_fmt(formats_enc, NUM_FORMATS_ENC, f, 518 return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
@@ -511,9 +524,7 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
511static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv, 524static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
512 struct v4l2_fmtdesc *f) 525 struct v4l2_fmtdesc *f)
513{ 526{
514 struct s5p_jpeg_ctx *ctx; 527 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
515
516 ctx = priv;
517 528
518 if (ctx->mode == S5P_JPEG_ENCODE) 529 if (ctx->mode == S5P_JPEG_ENCODE)
519 return enum_fmt(formats_enc, NUM_FORMATS_ENC, f, 530 return enum_fmt(formats_enc, NUM_FORMATS_ENC, f,
@@ -538,7 +549,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
538 struct vb2_queue *vq; 549 struct vb2_queue *vq;
539 struct s5p_jpeg_q_data *q_data = NULL; 550 struct s5p_jpeg_q_data *q_data = NULL;
540 struct v4l2_pix_format *pix = &f->fmt.pix; 551 struct v4l2_pix_format *pix = &f->fmt.pix;
541 struct s5p_jpeg_ctx *ct = priv; 552 struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
542 553
543 vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type); 554 vq = v4l2_m2m_get_vq(ct->m2m_ctx, f->type);
544 if (!vq) 555 if (!vq)
@@ -659,8 +670,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt,
659static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, 670static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
660 struct v4l2_format *f) 671 struct v4l2_format *f)
661{ 672{
673 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
662 struct s5p_jpeg_fmt *fmt; 674 struct s5p_jpeg_fmt *fmt;
663 struct s5p_jpeg_ctx *ctx = priv;
664 675
665 fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat); 676 fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat);
666 if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) { 677 if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) {
@@ -676,8 +687,8 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
676static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, 687static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv,
677 struct v4l2_format *f) 688 struct v4l2_format *f)
678{ 689{
690 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
679 struct s5p_jpeg_fmt *fmt; 691 struct s5p_jpeg_fmt *fmt;
680 struct s5p_jpeg_ctx *ctx = priv;
681 692
682 fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat); 693 fmt = s5p_jpeg_find_format(ctx->mode, f->fmt.pix.pixelformat);
683 if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) { 694 if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) {
@@ -728,7 +739,7 @@ static int s5p_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
728 if (ret) 739 if (ret)
729 return ret; 740 return ret;
730 741
731 return s5p_jpeg_s_fmt(priv, f); 742 return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
732} 743}
733 744
734static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv, 745static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
@@ -740,13 +751,13 @@ static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
740 if (ret) 751 if (ret)
741 return ret; 752 return ret;
742 753
743 return s5p_jpeg_s_fmt(priv, f); 754 return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
744} 755}
745 756
746static int s5p_jpeg_reqbufs(struct file *file, void *priv, 757static int s5p_jpeg_reqbufs(struct file *file, void *priv,
747 struct v4l2_requestbuffers *reqbufs) 758 struct v4l2_requestbuffers *reqbufs)
748{ 759{
749 struct s5p_jpeg_ctx *ctx = priv; 760 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
750 761
751 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs); 762 return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
752} 763}
@@ -754,14 +765,14 @@ static int s5p_jpeg_reqbufs(struct file *file, void *priv,
754static int s5p_jpeg_querybuf(struct file *file, void *priv, 765static int s5p_jpeg_querybuf(struct file *file, void *priv,
755 struct v4l2_buffer *buf) 766 struct v4l2_buffer *buf)
756{ 767{
757 struct s5p_jpeg_ctx *ctx = priv; 768 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
758 769
759 return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf); 770 return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
760} 771}
761 772
762static int s5p_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) 773static int s5p_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
763{ 774{
764 struct s5p_jpeg_ctx *ctx = priv; 775 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
765 776
766 return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf); 777 return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
767} 778}
@@ -769,7 +780,7 @@ static int s5p_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
769static int s5p_jpeg_dqbuf(struct file *file, void *priv, 780static int s5p_jpeg_dqbuf(struct file *file, void *priv,
770 struct v4l2_buffer *buf) 781 struct v4l2_buffer *buf)
771{ 782{
772 struct s5p_jpeg_ctx *ctx = priv; 783 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
773 784
774 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); 785 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
775} 786}
@@ -777,7 +788,7 @@ static int s5p_jpeg_dqbuf(struct file *file, void *priv,
777static int s5p_jpeg_streamon(struct file *file, void *priv, 788static int s5p_jpeg_streamon(struct file *file, void *priv,
778 enum v4l2_buf_type type) 789 enum v4l2_buf_type type)
779{ 790{
780 struct s5p_jpeg_ctx *ctx = priv; 791 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
781 792
782 return v4l2_m2m_streamon(file, ctx->m2m_ctx, type); 793 return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
783} 794}
@@ -785,7 +796,7 @@ static int s5p_jpeg_streamon(struct file *file, void *priv,
785static int s5p_jpeg_streamoff(struct file *file, void *priv, 796static int s5p_jpeg_streamoff(struct file *file, void *priv,
786 enum v4l2_buf_type type) 797 enum v4l2_buf_type type)
787{ 798{
788 struct s5p_jpeg_ctx *ctx = priv; 799 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
789 800
790 return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type); 801 return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
791} 802}
@@ -793,7 +804,7 @@ static int s5p_jpeg_streamoff(struct file *file, void *priv,
793int s5p_jpeg_g_selection(struct file *file, void *priv, 804int s5p_jpeg_g_selection(struct file *file, void *priv,
794 struct v4l2_selection *s) 805 struct v4l2_selection *s)
795{ 806{
796 struct s5p_jpeg_ctx *ctx = priv; 807 struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
797 808
798 if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && 809 if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
799 s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 810 s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.h b/drivers/media/video/s5p-jpeg/jpeg-core.h
index facad6114f5e..4dd705fb99d5 100644
--- a/drivers/media/video/s5p-jpeg/jpeg-core.h
+++ b/drivers/media/video/s5p-jpeg/jpeg-core.h
@@ -14,6 +14,7 @@
14#define JPEG_CORE_H_ 14#define JPEG_CORE_H_
15 15
16#include <media/v4l2-device.h> 16#include <media/v4l2-device.h>
17#include <media/v4l2-fh.h>
17 18
18#define S5P_JPEG_M2M_NAME "s5p-jpeg" 19#define S5P_JPEG_M2M_NAME "s5p-jpeg"
19 20
@@ -125,6 +126,7 @@ struct s5p_jpeg_ctx {
125 struct v4l2_m2m_ctx *m2m_ctx; 126 struct v4l2_m2m_ctx *m2m_ctx;
126 struct s5p_jpeg_q_data out_q; 127 struct s5p_jpeg_q_data out_q;
127 struct s5p_jpeg_q_data cap_q; 128 struct s5p_jpeg_q_data cap_q;
129 struct v4l2_fh fh;
128 bool hdr_parsed; 130 bool hdr_parsed;
129}; 131};
130 132