MLK-17230-12: camera: fixed enum frame interval issue
authorGuoniu.Zhou <guoniu.zhou@nxp.com>
Tue, 6 Feb 2018 03:34:13 +0000 (11:34 +0800)
committerHaibo Chen <haibo.chen@nxp.com>
Thu, 12 Apr 2018 10:45:43 +0000 (18:45 +0800)
when enum frame interval, kernel will be panic. It caused by
an null pointer, so correct the subdev data structure pointer.

ov5640 only support 15fps when mode is 1080P, so add this info
when user enum frame interval.

Reviewed-by: Sandor.Yu <sandor.yu@nxp.com>
Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 4089120ce5fbcb253728a23102a62c849b71c88b)

drivers/media/platform/imx8/mxc-mipi-csi2.c
drivers/media/platform/imx8/mxc-parallel-csi.c
drivers/media/platform/imx8/ov5640_v3.c

index 8d875a4..3d46b62 100644 (file)
@@ -577,7 +577,7 @@ static int mipi_csi2_enum_frame_interval(struct v4l2_subdev *sd,
                return -EINVAL;
        }
 
-       return v4l2_subdev_call(sd, pad, enum_frame_interval, NULL, fie);
+       return v4l2_subdev_call(sen_sd, pad, enum_frame_interval, NULL, fie);
 }
 
 static int mipi_csi2_get_fmt(struct v4l2_subdev *sd,
index 3676c27..8686717 100644 (file)
@@ -331,7 +331,7 @@ static int mxc_pcsi_enum_frame_interval(struct v4l2_subdev *sd,
                return -EINVAL;
        }
 
-       return v4l2_subdev_call(sd, pad, enum_frame_interval, NULL, fie);
+       return v4l2_subdev_call(sen_sd, pad, enum_frame_interval, NULL, fie);
 }
 
 static int mxc_pcsi_get_fmt(struct v4l2_subdev *sd,
index 37b09ae..106cf8c 100644 (file)
@@ -1146,7 +1146,7 @@ static int ov5640_enum_frameintervals(struct v4l2_subdev *sd,
                struct v4l2_subdev_pad_config *cfg,
                struct v4l2_subdev_frame_interval_enum *fie)
 {
-       int j, count;
+       int i, j, count;
 
        if (fie->index < 0 || fie->index > ov5640_mode_MAX)
                return -EINVAL;
@@ -1160,15 +1160,20 @@ static int ov5640_enum_frameintervals(struct v4l2_subdev *sd,
        fie->interval.numerator = 1;
 
        count = 0;
-       for (j = 0; j < (ov5640_mode_MAX + 1); j++) {
-               if (fie->width == ov5640_mode_info_data[j].width
-                && fie->height == ov5640_mode_info_data[j].height
-                && ov5640_mode_info_data[j].init_data_ptr != NULL) {
-                       count++;
-               }
-               if (fie->index == (count - 1)) {
-                       fie->interval.denominator = ov5640_framerates[0];
-                       return 0;
+       for (i = 0; i < ARRAY_SIZE(ov5640_framerates); i++) {
+               for (j = 0; j < (ov5640_mode_MAX + 1); j++) {
+                       if (fie->width == ov5640_mode_info_data[j].width
+                        && fie->height == ov5640_mode_info_data[j].height
+                        && ov5640_mode_info_data[j].init_data_ptr != NULL) {
+                               count++;
+                       }
+                       if (fie->index == (count - 1)) {
+                               fie->interval.denominator = ov5640_framerates[i];
+                               if (ov5640_mode_info_data[j].mode ==
+                                               ov5640_mode_1080P_1920_1080)
+                                       fie->interval.denominator = ov5640_framerates[0];
+                               return 0;
+                       }
                }
        }