v4l2: starfive CSI support multi stream on
authorliuxl0327 <liuxl0327@starfivetech.com>
Mon, 21 Mar 2022 06:56:22 +0000 (14:56 +0800)
committermason.huo <mason.huo@starfivetech.com>
Fri, 1 Jul 2022 07:05:37 +0000 (15:05 +0800)
Signed-off-by: mason.huo <mason.huo@starfivetech.com>
drivers/media/platform/starfive/v4l2_driver/stf_csi.c [changed mode: 0755->0644]
drivers/media/platform/starfive/v4l2_driver/stf_csi.h
drivers/media/platform/starfive/v4l2_driver/stf_csi_hw_ops.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index acdb516..967e2cc
 #include <media/v4l2-fwnode.h>
 #include <media/v4l2-subdev.h>
 
-#define STF_CSI_NAME "stf_csi"
-
 static const struct csi_format csi_formats_st7110[] = {
        { MEDIA_BUS_FMT_YUYV8_2X8, 16},
        { MEDIA_BUS_FMT_RGB565_2X8_LE, 16},
-       { MEDIA_BUS_FMT_SRGGB10_1X10, 12},
-       { MEDIA_BUS_FMT_SGRBG10_1X10, 12},
-       { MEDIA_BUS_FMT_SGBRG10_1X10, 12},
-       { MEDIA_BUS_FMT_SBGGR10_1X10, 12},
+       { MEDIA_BUS_FMT_SRGGB10_1X10, 10},
+       { MEDIA_BUS_FMT_SGRBG10_1X10, 10},
+       { MEDIA_BUS_FMT_SGBRG10_1X10, 10},
+       { MEDIA_BUS_FMT_SBGGR10_1X10, 10},
 };
 
 static int csi_find_format(u32 code,
@@ -138,15 +136,15 @@ static void csi_try_format(struct stf_csi_dev *csi_dev,
                                break;
 
                if (i >= csi_dev->nformats)
-                       fmt->code = MEDIA_BUS_FMT_RGB565_2X8_LE;
+                       fmt->code = csi_dev->formats[0].code;
 
                fmt->width = clamp_t(u32,
                                fmt->width,
-                               1,
+                               STFCAMSS_FRAME_MIN_WIDTH,
                                STFCAMSS_FRAME_MAX_WIDTH);
                fmt->height = clamp_t(u32,
                                fmt->height,
-                               1,
+                               STFCAMSS_FRAME_MIN_HEIGHT,
                                STFCAMSS_FRAME_MAX_HEIGHT_PIX);
 
                fmt->field = V4L2_FIELD_NONE;
@@ -245,8 +243,16 @@ static int csi_set_format(struct v4l2_subdev *sd,
        if (format == NULL)
                return -EINVAL;
 
-       csi_try_format(csi_dev, state, fmt->pad, &fmt->format, fmt->which);
-       *format = fmt->format;
+       mutex_lock(&csi_dev->stream_lock);
+       if (csi_dev->stream_count) {
+               fmt->format = *format;
+               mutex_unlock(&csi_dev->stream_lock);
+               goto out;
+       } else {
+               csi_try_format(csi_dev, state, fmt->pad, &fmt->format, fmt->which);
+               *format = fmt->format;
+       }
+       mutex_unlock(&csi_dev->stream_lock);
 
        /* Propagate the format from sink to source */
        if (fmt->pad == STF_CSI_PAD_SINK) {
@@ -257,7 +263,7 @@ static int csi_set_format(struct v4l2_subdev *sd,
                csi_try_format(csi_dev, state, STF_CSI_PAD_SRC, format,
                                        fmt->which);
        }
-
+out:
        return 0;
 }
 
@@ -322,7 +328,7 @@ static int csi_link_setup(struct media_entity *entity,
                csiphy_dev = v4l2_get_subdevdata(sd);
 
                csi_dev->csiphy_id = csiphy_dev->id;
-               st_info(ST_SENSOR, "CSI%d link to csiphy%d\n",
+               st_info(ST_CSI, "CSI%d link to csiphy%d\n",
                                csi_dev->id, csi_dev->csiphy_id);
        }
 
index d71676c..a3e2656 100755 (executable)
@@ -11,6 +11,8 @@
 #include <media/media-entity.h>
 #include <video/stf-vin.h>
 
+#define STF_CSI_NAME "stf_csi"
+
 #define STF_CSI_PAD_SINK     0
 #define STF_CSI_PAD_SRC      1
 #define STF_CSI_PADS_NUM     2