diff options
Diffstat (limited to 'drivers/media/video/mx2_camera.c')
-rw-r--r-- | drivers/media/video/mx2_camera.c | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index ec2410c0c806..a803d9ea8fd6 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c | |||
@@ -686,16 +686,15 @@ static void mx2_camera_init_videobuf(struct videobuf_queue *q, | |||
686 | icd, &icd->video_lock); | 686 | icd, &icd->video_lock); |
687 | } | 687 | } |
688 | 688 | ||
689 | #define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \ | 689 | #define MX2_BUS_FLAGS (V4L2_MBUS_MASTER | \ |
690 | SOCAM_MASTER | \ | 690 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | \ |
691 | SOCAM_VSYNC_ACTIVE_HIGH | \ | 691 | V4L2_MBUS_VSYNC_ACTIVE_LOW | \ |
692 | SOCAM_VSYNC_ACTIVE_LOW | \ | 692 | V4L2_MBUS_HSYNC_ACTIVE_HIGH | \ |
693 | SOCAM_HSYNC_ACTIVE_HIGH | \ | 693 | V4L2_MBUS_HSYNC_ACTIVE_LOW | \ |
694 | SOCAM_HSYNC_ACTIVE_LOW | \ | 694 | V4L2_MBUS_PCLK_SAMPLE_RISING | \ |
695 | SOCAM_PCLK_SAMPLE_RISING | \ | 695 | V4L2_MBUS_PCLK_SAMPLE_FALLING | \ |
696 | SOCAM_PCLK_SAMPLE_FALLING | \ | 696 | V4L2_MBUS_DATA_ACTIVE_HIGH | \ |
697 | SOCAM_DATA_ACTIVE_HIGH | \ | 697 | V4L2_MBUS_DATA_ACTIVE_LOW) |
698 | SOCAM_DATA_ACTIVE_LOW) | ||
699 | 698 | ||
700 | static int mx27_camera_emma_prp_reset(struct mx2_camera_dev *pcdev) | 699 | static int mx27_camera_emma_prp_reset(struct mx2_camera_dev *pcdev) |
701 | { | 700 | { |
@@ -770,46 +769,59 @@ static void mx27_camera_emma_buf_init(struct soc_camera_device *icd, | |||
770 | static int mx2_camera_set_bus_param(struct soc_camera_device *icd, | 769 | static int mx2_camera_set_bus_param(struct soc_camera_device *icd, |
771 | __u32 pixfmt) | 770 | __u32 pixfmt) |
772 | { | 771 | { |
773 | struct soc_camera_host *ici = | 772 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
774 | to_soc_camera_host(icd->parent); | 773 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
775 | struct mx2_camera_dev *pcdev = ici->priv; | 774 | struct mx2_camera_dev *pcdev = ici->priv; |
776 | unsigned long camera_flags, common_flags; | 775 | struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,}; |
777 | int ret = 0; | 776 | unsigned long common_flags; |
777 | int ret; | ||
778 | int bytesperline; | 778 | int bytesperline; |
779 | u32 csicr1 = pcdev->csicr1; | 779 | u32 csicr1 = pcdev->csicr1; |
780 | 780 | ||
781 | camera_flags = icd->ops->query_bus_param(icd); | 781 | ret = v4l2_subdev_call(sd, video, g_mbus_config, &cfg); |
782 | 782 | if (!ret) { | |
783 | common_flags = soc_camera_bus_param_compatible(camera_flags, | 783 | common_flags = soc_mbus_config_compatible(&cfg, MX2_BUS_FLAGS); |
784 | MX2_BUS_FLAGS); | 784 | if (!common_flags) { |
785 | if (!common_flags) | 785 | dev_warn(icd->parent, |
786 | return -EINVAL; | 786 | "Flags incompatible: camera 0x%x, host 0x%x\n", |
787 | cfg.flags, MX2_BUS_FLAGS); | ||
788 | return -EINVAL; | ||
789 | } | ||
790 | } else if (ret != -ENOIOCTLCMD) { | ||
791 | return ret; | ||
792 | } else { | ||
793 | common_flags = MX2_BUS_FLAGS; | ||
794 | } | ||
787 | 795 | ||
788 | if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) && | 796 | if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) && |
789 | (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) { | 797 | (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) { |
790 | if (pcdev->platform_flags & MX2_CAMERA_HSYNC_HIGH) | 798 | if (pcdev->platform_flags & MX2_CAMERA_HSYNC_HIGH) |
791 | common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW; | 799 | common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW; |
792 | else | 800 | else |
793 | common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH; | 801 | common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH; |
794 | } | 802 | } |
795 | 803 | ||
796 | if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) && | 804 | if ((common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) && |
797 | (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) { | 805 | (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)) { |
798 | if (pcdev->platform_flags & MX2_CAMERA_PCLK_SAMPLE_RISING) | 806 | if (pcdev->platform_flags & MX2_CAMERA_PCLK_SAMPLE_RISING) |
799 | common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; | 807 | common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING; |
800 | else | 808 | else |
801 | common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; | 809 | common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING; |
802 | } | 810 | } |
803 | 811 | ||
804 | ret = icd->ops->set_bus_param(icd, common_flags); | 812 | cfg.flags = common_flags; |
805 | if (ret < 0) | 813 | ret = v4l2_subdev_call(sd, video, s_mbus_config, &cfg); |
814 | if (ret < 0 && ret != -ENOIOCTLCMD) { | ||
815 | dev_dbg(icd->parent, "camera s_mbus_config(0x%lx) returned %d\n", | ||
816 | common_flags, ret); | ||
806 | return ret; | 817 | return ret; |
818 | } | ||
807 | 819 | ||
808 | if (common_flags & SOCAM_PCLK_SAMPLE_RISING) | 820 | if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) |
809 | csicr1 |= CSICR1_REDGE; | 821 | csicr1 |= CSICR1_REDGE; |
810 | if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH) | 822 | if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) |
811 | csicr1 |= CSICR1_SOF_POL; | 823 | csicr1 |= CSICR1_SOF_POL; |
812 | if (common_flags & SOCAM_HSYNC_ACTIVE_HIGH) | 824 | if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) |
813 | csicr1 |= CSICR1_HSYNC_POL; | 825 | csicr1 |= CSICR1_HSYNC_POL; |
814 | if (pcdev->platform_flags & MX2_CAMERA_SWAP16) | 826 | if (pcdev->platform_flags & MX2_CAMERA_SWAP16) |
815 | csicr1 |= CSICR1_SWAP16_EN; | 827 | csicr1 |= CSICR1_SWAP16_EN; |