aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/sh_mobile_ceu_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 10:43:33 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:18:35 -0400
commit979ea1ddf80ac7383acdea03471355ca62702539 (patch)
tree2ee4c73eb672c1ee8167ed7e0906bac6f3b00e69 /drivers/media/video/sh_mobile_ceu_camera.c
parent0bab829de1ab60d8c3cbf7e402192bb9446840b7 (diff)
V4L/DVB (12510): soc-camera: (partially) convert to v4l2-(sub)dev API
Convert the soc-camera framework to use the v4l2-(sub)dev API. Start using v4l2-subdev operations. Only a part of the interface between the soc_camera core, soc_camera host drivers on one side and soc_camera device drivers on the other side is replaced so far. The rest of the interface will be replaced in incremental steps, and will require extensions and, possibly, modifications to the v4l2-subdev code. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/sh_mobile_ceu_camera.c')
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index e7ac84daf67..5101fa7cdb2 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -347,10 +347,9 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
347{ 347{
348 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 348 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
349 struct sh_mobile_ceu_dev *pcdev = ici->priv; 349 struct sh_mobile_ceu_dev *pcdev = ici->priv;
350 int ret = -EBUSY;
351 350
352 if (pcdev->icd) 351 if (pcdev->icd)
353 goto err; 352 return -EBUSY;
354 353
355 dev_info(&icd->dev, 354 dev_info(&icd->dev,
356 "SuperH Mobile CEU driver attached to camera %d\n", 355 "SuperH Mobile CEU driver attached to camera %d\n",
@@ -358,19 +357,13 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
358 357
359 clk_enable(pcdev->clk); 358 clk_enable(pcdev->clk);
360 359
361 ret = icd->ops->init(icd);
362 if (ret) {
363 clk_disable(pcdev->clk);
364 goto err;
365 }
366
367 ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ 360 ceu_write(pcdev, CAPSR, 1 << 16); /* reset */
368 while (ceu_read(pcdev, CSTSR) & 1) 361 while (ceu_read(pcdev, CSTSR) & 1)
369 msleep(1); 362 msleep(1);
370 363
371 pcdev->icd = icd; 364 pcdev->icd = icd;
372err: 365
373 return ret; 366 return 0;
374} 367}
375 368
376/* Called with .video_lock held */ 369/* Called with .video_lock held */
@@ -396,8 +389,6 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd)
396 } 389 }
397 spin_unlock_irqrestore(&pcdev->lock, flags); 390 spin_unlock_irqrestore(&pcdev->lock, flags);
398 391
399 icd->ops->release(icd);
400
401 clk_disable(pcdev->clk); 392 clk_disable(pcdev->clk);
402 393
403 dev_info(&icd->dev, 394 dev_info(&icd->dev,
@@ -614,7 +605,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
614 xlate->cam_fmt = icd->formats + idx; 605 xlate->cam_fmt = icd->formats + idx;
615 xlate->buswidth = icd->formats[idx].depth; 606 xlate->buswidth = icd->formats[idx].depth;
616 xlate++; 607 xlate++;
617 dev_dbg(ici->dev, "Providing format %s using %s\n", 608 dev_dbg(ici->v4l2_dev.dev, "Providing format %s using %s\n",
618 sh_mobile_ceu_formats[k].name, 609 sh_mobile_ceu_formats[k].name,
619 icd->formats[idx].name); 610 icd->formats[idx].name);
620 } 611 }
@@ -627,7 +618,7 @@ add_single_format:
627 xlate->cam_fmt = icd->formats + idx; 618 xlate->cam_fmt = icd->formats + idx;
628 xlate->buswidth = icd->formats[idx].depth; 619 xlate->buswidth = icd->formats[idx].depth;
629 xlate++; 620 xlate++;
630 dev_dbg(ici->dev, 621 dev_dbg(ici->v4l2_dev.dev,
631 "Providing format %s in pass-through mode\n", 622 "Providing format %s in pass-through mode\n",
632 icd->formats[idx].name); 623 icd->formats[idx].name);
633 } 624 }
@@ -649,18 +640,17 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
649 struct sh_mobile_ceu_dev *pcdev = ici->priv; 640 struct sh_mobile_ceu_dev *pcdev = ici->priv;
650 __u32 pixfmt = f->fmt.pix.pixelformat; 641 __u32 pixfmt = f->fmt.pix.pixelformat;
651 const struct soc_camera_format_xlate *xlate; 642 const struct soc_camera_format_xlate *xlate;
652 struct v4l2_format cam_f = *f;
653 int ret; 643 int ret;
654 644
655 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 645 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
656 if (!xlate) { 646 if (!xlate) {
657 dev_warn(ici->dev, "Format %x not found\n", pixfmt); 647 dev_warn(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt);
658 return -EINVAL; 648 return -EINVAL;
659 } 649 }
660 650
661 cam_f.fmt.pix.pixelformat = xlate->cam_fmt->fourcc; 651 f->fmt.pix.pixelformat = xlate->cam_fmt->fourcc;
662 ret = icd->ops->set_fmt(icd, &cam_f); 652 ret = v4l2_device_call_until_err(&ici->v4l2_dev, (__u32)icd, video, s_fmt, f);
663 653 f->fmt.pix.pixelformat = pixfmt;
664 if (!ret) { 654 if (!ret) {
665 icd->buswidth = xlate->buswidth; 655 icd->buswidth = xlate->buswidth;
666 icd->current_fmt = xlate->host_fmt; 656 icd->current_fmt = xlate->host_fmt;
@@ -681,7 +671,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
681 671
682 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 672 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
683 if (!xlate) { 673 if (!xlate) {
684 dev_warn(ici->dev, "Format %x not found\n", pixfmt); 674 dev_warn(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt);
685 return -EINVAL; 675 return -EINVAL;
686 } 676 }
687 677
@@ -694,8 +684,11 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
694 DIV_ROUND_UP(xlate->host_fmt->depth, 8); 684 DIV_ROUND_UP(xlate->host_fmt->depth, 8);
695 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 685 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
696 686
687 f->fmt.pix.pixelformat = xlate->cam_fmt->fourcc;
688
697 /* limit to sensor capabilities */ 689 /* limit to sensor capabilities */
698 ret = icd->ops->try_fmt(icd, f); 690 ret = v4l2_device_call_until_err(&ici->v4l2_dev, (__u32)icd, video, try_fmt, f);
691 f->fmt.pix.pixelformat = pixfmt;
699 if (ret < 0) 692 if (ret < 0)
700 return ret; 693 return ret;
701 694
@@ -771,7 +764,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q,
771 764
772 videobuf_queue_dma_contig_init(q, 765 videobuf_queue_dma_contig_init(q,
773 &sh_mobile_ceu_videobuf_ops, 766 &sh_mobile_ceu_videobuf_ops,
774 ici->dev, &pcdev->lock, 767 ici->v4l2_dev.dev, &pcdev->lock,
775 V4L2_BUF_TYPE_VIDEO_CAPTURE, 768 V4L2_BUF_TYPE_VIDEO_CAPTURE,
776 pcdev->is_interlaced ? 769 pcdev->is_interlaced ?
777 V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE, 770 V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE,
@@ -794,7 +787,7 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops = {
794 .init_videobuf = sh_mobile_ceu_init_videobuf, 787 .init_videobuf = sh_mobile_ceu_init_videobuf,
795}; 788};
796 789
797static int sh_mobile_ceu_probe(struct platform_device *pdev) 790static int __devinit sh_mobile_ceu_probe(struct platform_device *pdev)
798{ 791{
799 struct sh_mobile_ceu_dev *pcdev; 792 struct sh_mobile_ceu_dev *pcdev;
800 struct resource *res; 793 struct resource *res;
@@ -867,7 +860,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
867 pm_runtime_resume(&pdev->dev); 860 pm_runtime_resume(&pdev->dev);
868 861
869 pcdev->ici.priv = pcdev; 862 pcdev->ici.priv = pcdev;
870 pcdev->ici.dev = &pdev->dev; 863 pcdev->ici.v4l2_dev.dev = &pdev->dev;
871 pcdev->ici.nr = pdev->id; 864 pcdev->ici.nr = pdev->id;
872 pcdev->ici.drv_name = dev_name(&pdev->dev); 865 pcdev->ici.drv_name = dev_name(&pdev->dev);
873 pcdev->ici.ops = &sh_mobile_ceu_host_ops; 866 pcdev->ici.ops = &sh_mobile_ceu_host_ops;
@@ -891,7 +884,7 @@ exit:
891 return err; 884 return err;
892} 885}
893 886
894static int sh_mobile_ceu_remove(struct platform_device *pdev) 887static int __devexit sh_mobile_ceu_remove(struct platform_device *pdev)
895{ 888{
896 struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev); 889 struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
897 struct sh_mobile_ceu_dev *pcdev = container_of(soc_host, 890 struct sh_mobile_ceu_dev *pcdev = container_of(soc_host,
@@ -929,7 +922,7 @@ static struct platform_driver sh_mobile_ceu_driver = {
929 .pm = &sh_mobile_ceu_dev_pm_ops, 922 .pm = &sh_mobile_ceu_dev_pm_ops,
930 }, 923 },
931 .probe = sh_mobile_ceu_probe, 924 .probe = sh_mobile_ceu_probe,
932 .remove = sh_mobile_ceu_remove, 925 .remove = __exit_p(sh_mobile_ceu_remove),
933}; 926};
934 927
935static int __init sh_mobile_ceu_init(void) 928static int __init sh_mobile_ceu_init(void)