From: liuxl0327 Date: Mon, 21 Mar 2022 06:56:22 +0000 (+0800) Subject: v4l2: starfive CSI support multi stream on X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e81535c9708b48a204731848809fb439312f0ffa;p=platform%2Fkernel%2Flinux-starfive.git v4l2: starfive CSI support multi stream on Signed-off-by: mason.huo --- diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_csi.c b/drivers/media/platform/starfive/v4l2_driver/stf_csi.c old mode 100755 new mode 100644 index acdb516..967e2cc --- a/drivers/media/platform/starfive/v4l2_driver/stf_csi.c +++ b/drivers/media/platform/starfive/v4l2_driver/stf_csi.c @@ -10,15 +10,13 @@ #include #include -#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); } diff --git a/drivers/media/platform/starfive/v4l2_driver/stf_csi.h b/drivers/media/platform/starfive/v4l2_driver/stf_csi.h index d71676c..a3e2656 100755 --- a/drivers/media/platform/starfive/v4l2_driver/stf_csi.h +++ b/drivers/media/platform/starfive/v4l2_driver/stf_csi.h @@ -11,6 +11,8 @@ #include #include