aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mx3_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mx3_camera.c')
-rw-r--r--drivers/media/video/mx3_camera.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index 2edf77a6256b..677d355be8fc 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -431,7 +431,7 @@ static void mx3_camera_init_videobuf(struct videobuf_queue *q,
431 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 431 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
432 struct mx3_camera_dev *mx3_cam = ici->priv; 432 struct mx3_camera_dev *mx3_cam = ici->priv;
433 433
434 videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, ici->dev, 434 videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, icd->dev.parent,
435 &mx3_cam->lock, 435 &mx3_cam->lock,
436 V4L2_BUF_TYPE_VIDEO_CAPTURE, 436 V4L2_BUF_TYPE_VIDEO_CAPTURE,
437 V4L2_FIELD_NONE, 437 V4L2_FIELD_NONE,
@@ -494,17 +494,11 @@ static int mx3_camera_add_device(struct soc_camera_device *icd)
494{ 494{
495 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 495 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
496 struct mx3_camera_dev *mx3_cam = ici->priv; 496 struct mx3_camera_dev *mx3_cam = ici->priv;
497 int ret;
498 497
499 if (mx3_cam->icd) { 498 if (mx3_cam->icd)
500 ret = -EBUSY; 499 return -EBUSY;
501 goto ebusy;
502 }
503 500
504 mx3_camera_activate(mx3_cam, icd); 501 mx3_camera_activate(mx3_cam, icd);
505 ret = icd->ops->init(icd);
506 if (ret < 0)
507 goto einit;
508 502
509 mx3_cam->icd = icd; 503 mx3_cam->icd = icd;
510 504
@@ -512,12 +506,6 @@ static int mx3_camera_add_device(struct soc_camera_device *icd)
512 icd->devnum); 506 icd->devnum);
513 507
514 return 0; 508 return 0;
515
516einit:
517 clk_disable(mx3_cam->clk);
518ebusy:
519
520 return ret;
521} 509}
522 510
523/* Called with .video_lock held */ 511/* Called with .video_lock held */
@@ -534,8 +522,6 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd)
534 *ichan = NULL; 522 *ichan = NULL;
535 } 523 }
536 524
537 icd->ops->release(icd);
538
539 clk_disable(mx3_cam->clk); 525 clk_disable(mx3_cam->clk);
540 526
541 mx3_cam->icd = NULL; 527 mx3_cam->icd = NULL;
@@ -600,7 +586,7 @@ static int test_platform_param(struct mx3_camera_dev *mx3_cam,
600 *flags |= SOCAM_DATAWIDTH_4; 586 *flags |= SOCAM_DATAWIDTH_4;
601 break; 587 break;
602 default: 588 default:
603 dev_info(mx3_cam->soc_host.dev, "Unsupported bus width %d\n", 589 dev_info(mx3_cam->soc_host.v4l2_dev.dev, "Unsupported bus width %d\n",
604 buswidth); 590 buswidth);
605 return -EINVAL; 591 return -EINVAL;
606 } 592 }
@@ -616,7 +602,7 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd,
616 unsigned long bus_flags, camera_flags; 602 unsigned long bus_flags, camera_flags;
617 int ret = test_platform_param(mx3_cam, depth, &bus_flags); 603 int ret = test_platform_param(mx3_cam, depth, &bus_flags);
618 604
619 dev_dbg(ici->dev, "requested bus width %d bit: %d\n", depth, ret); 605 dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n", depth, ret);
620 606
621 if (ret < 0) 607 if (ret < 0)
622 return ret; 608 return ret;
@@ -639,7 +625,7 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
639 if (!rq) 625 if (!rq)
640 return false; 626 return false;
641 627
642 pdata = rq->mx3_cam->soc_host.dev->platform_data; 628 pdata = rq->mx3_cam->soc_host.v4l2_dev.dev->platform_data;
643 629
644 return rq->id == chan->chan_id && 630 return rq->id == chan->chan_id &&
645 pdata->dma_dev == chan->device->dev; 631 pdata->dma_dev == chan->device->dev;
@@ -699,7 +685,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
699 xlate->cam_fmt = icd->formats + idx; 685 xlate->cam_fmt = icd->formats + idx;
700 xlate->buswidth = buswidth; 686 xlate->buswidth = buswidth;
701 xlate++; 687 xlate++;
702 dev_dbg(ici->dev, "Providing format %s using %s\n", 688 dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
703 mx3_camera_formats[0].name, 689 mx3_camera_formats[0].name,
704 icd->formats[idx].name); 690 icd->formats[idx].name);
705 } 691 }
@@ -711,7 +697,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
711 xlate->cam_fmt = icd->formats + idx; 697 xlate->cam_fmt = icd->formats + idx;
712 xlate->buswidth = buswidth; 698 xlate->buswidth = buswidth;
713 xlate++; 699 xlate++;
714 dev_dbg(ici->dev, "Providing format %s using %s\n", 700 dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
715 mx3_camera_formats[0].name, 701 mx3_camera_formats[0].name,
716 icd->formats[idx].name); 702 icd->formats[idx].name);
717 } 703 }
@@ -724,7 +710,7 @@ passthrough:
724 xlate->cam_fmt = icd->formats + idx; 710 xlate->cam_fmt = icd->formats + idx;
725 xlate->buswidth = buswidth; 711 xlate->buswidth = buswidth;
726 xlate++; 712 xlate++;
727 dev_dbg(ici->dev, 713 dev_dbg(icd->dev.parent,
728 "Providing format %s in pass-through mode\n", 714 "Providing format %s in pass-through mode\n",
729 icd->formats[idx].name); 715 icd->formats[idx].name);
730 } 716 }
@@ -831,7 +817,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
831 817
832 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); 818 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
833 if (!xlate) { 819 if (!xlate) {
834 dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat); 820 dev_warn(icd->dev.parent, "Format %x not found\n", pix->pixelformat);
835 return -EINVAL; 821 return -EINVAL;
836 } 822 }
837 823
@@ -847,7 +833,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
847 833
848 configure_geometry(mx3_cam, &rect); 834 configure_geometry(mx3_cam, &rect);
849 835
850 ret = icd->ops->set_fmt(icd, f); 836 ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, s_fmt, f);
851 if (!ret) { 837 if (!ret) {
852 icd->buswidth = xlate->buswidth; 838 icd->buswidth = xlate->buswidth;
853 icd->current_fmt = xlate->host_fmt; 839 icd->current_fmt = xlate->host_fmt;
@@ -868,7 +854,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
868 854
869 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 855 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
870 if (pixfmt && !xlate) { 856 if (pixfmt && !xlate) {
871 dev_warn(ici->dev, "Format %x not found\n", pixfmt); 857 dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
872 return -EINVAL; 858 return -EINVAL;
873 } 859 }
874 860
@@ -885,7 +871,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
885 /* camera has to see its format, but the user the original one */ 871 /* camera has to see its format, but the user the original one */
886 pix->pixelformat = xlate->cam_fmt->fourcc; 872 pix->pixelformat = xlate->cam_fmt->fourcc;
887 /* limit to sensor capabilities */ 873 /* limit to sensor capabilities */
888 ret = icd->ops->try_fmt(icd, f); 874 ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, try_fmt, f);
889 pix->pixelformat = xlate->host_fmt->fourcc; 875 pix->pixelformat = xlate->host_fmt->fourcc;
890 876
891 field = pix->field; 877 field = pix->field;
@@ -935,11 +921,11 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
935 921
936 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 922 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
937 if (!xlate) { 923 if (!xlate) {
938 dev_warn(ici->dev, "Format %x not found\n", pixfmt); 924 dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
939 return -EINVAL; 925 return -EINVAL;
940 } 926 }
941 927
942 dev_dbg(ici->dev, "requested bus width %d bit: %d\n", 928 dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n",
943 icd->buswidth, ret); 929 icd->buswidth, ret);
944 930
945 if (ret < 0) 931 if (ret < 0)
@@ -948,10 +934,10 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
948 camera_flags = icd->ops->query_bus_param(icd); 934 camera_flags = icd->ops->query_bus_param(icd);
949 935
950 common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags); 936 common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
951 dev_dbg(ici->dev, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n", 937 dev_dbg(icd->dev.parent, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n",
952 camera_flags, bus_flags, common_flags); 938 camera_flags, bus_flags, common_flags);
953 if (!common_flags) { 939 if (!common_flags) {
954 dev_dbg(ici->dev, "no common flags"); 940 dev_dbg(icd->dev.parent, "no common flags");
955 return -EINVAL; 941 return -EINVAL;
956 } 942 }
957 943
@@ -1005,7 +991,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
1005 991
1006 ret = icd->ops->set_bus_param(icd, common_flags); 992 ret = icd->ops->set_bus_param(icd, common_flags);
1007 if (ret < 0) { 993 if (ret < 0) {
1008 dev_dbg(ici->dev, "camera set_bus_param(%lx) returned %d\n", 994 dev_dbg(icd->dev.parent, "camera set_bus_param(%lx) returned %d\n",
1009 common_flags, ret); 995 common_flags, ret);
1010 return ret; 996 return ret;
1011 } 997 }
@@ -1060,7 +1046,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
1060 1046
1061 csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF); 1047 csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF);
1062 1048
1063 dev_dbg(ici->dev, "Set SENS_CONF to %x\n", sens_conf | dw); 1049 dev_dbg(icd->dev.parent, "Set SENS_CONF to %x\n", sens_conf | dw);
1064 1050
1065 return 0; 1051 return 0;
1066} 1052}
@@ -1145,7 +1131,7 @@ static int __devinit mx3_camera_probe(struct platform_device *pdev)
1145 soc_host->drv_name = MX3_CAM_DRV_NAME; 1131 soc_host->drv_name = MX3_CAM_DRV_NAME;
1146 soc_host->ops = &mx3_soc_camera_host_ops; 1132 soc_host->ops = &mx3_soc_camera_host_ops;
1147 soc_host->priv = mx3_cam; 1133 soc_host->priv = mx3_cam;
1148 soc_host->dev = &pdev->dev; 1134 soc_host->v4l2_dev.dev = &pdev->dev;
1149 soc_host->nr = pdev->id; 1135 soc_host->nr = pdev->id;
1150 1136
1151 err = soc_camera_host_register(soc_host); 1137 err = soc_camera_host_register(soc_host);