[v4l2][update kernel5.15]
authordavid.li <david.li@starfivetech.com>
Thu, 6 Jan 2022 05:04:28 +0000 (13:04 +0800)
committerdavid.li <david.li@starfivetech.com>
Thu, 6 Jan 2022 05:04:28 +0000 (13:04 +0800)
arch/riscv/boot/dts/starfive/starfive_jh7110.dts
drivers/media/platform/starfive/v4l2_driver/stf_dvp.c
drivers/media/platform/starfive/v4l2_driver/stf_dvp_hw_ops.c
drivers/media/platform/starfive/v4l2_driver/stf_isp.c
drivers/media/platform/starfive/v4l2_driver/stf_vin_hw_ops.c

index 151e02e..1a9b0cc 100755 (executable)
                                                bus-width = <8>;
                                                data-shift = <2>; /* lines 9:2 are used */
                                                hsync-active = <1>;
-                                               vsync-active = <1>;
+                                               vsync-active = <0>;
                                                pclk-sample = <1>;
                                                status = "okay";
                                        };
index c289c54..9f94ef4 100755 (executable)
@@ -56,15 +56,11 @@ static int dvp_set_power(struct v4l2_subdev *sd, int on)
 
 static struct v4l2_mbus_framefmt *
 __dvp_get_format(struct stf_dvp_dev *dvp_dev,
-               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_state *state,
                unsigned int pad,
                enum v4l2_subdev_format_whence which)
 {
-       struct v4l2_subdev_state *state;
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
-       if (!state)
-               return ERR_PTR(-ENOMEM);
-       
+
        if (which == V4L2_SUBDEV_FORMAT_TRY)
                return v4l2_subdev_get_try_format(
                        &dvp_dev->subdev, state, pad);
@@ -110,7 +106,7 @@ exit:
 }
 
 static void dvp_try_format(struct stf_dvp_dev *dvp_dev,
-                       struct v4l2_subdev_pad_config *cfg,
+                       struct v4l2_subdev_state *state,
                        unsigned int pad,
                        struct v4l2_mbus_framefmt *fmt,
                        enum v4l2_subdev_format_whence which)
@@ -141,7 +137,7 @@ static void dvp_try_format(struct stf_dvp_dev *dvp_dev,
 
        case STF_DVP_PAD_SRC:
 
-               *fmt = *__dvp_get_format(dvp_dev, cfg, STF_DVP_PAD_SINK, which);
+               *fmt = *__dvp_get_format(dvp_dev, state, STF_DVP_PAD_SINK, which);
 
                break;
        }
@@ -161,7 +157,7 @@ static int dvp_enum_mbus_code(struct v4l2_subdev *sd,
        } else {
                struct v4l2_mbus_framefmt *sink_fmt;
 
-               sink_fmt = __dvp_get_format(dvp_dev, state->pads, STF_DVP_PAD_SINK,
+               sink_fmt = __dvp_get_format(dvp_dev, state, STF_DVP_PAD_SINK,
                                        code->which);
 
                code->code = sink_fmt->code;
@@ -186,7 +182,7 @@ static int dvp_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       dvp_try_format(dvp_dev, state->pads, fse->pad, &format, fse->which);
+       dvp_try_format(dvp_dev, state, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -196,7 +192,7 @@ static int dvp_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       dvp_try_format(dvp_dev, state->pads, fse->pad, &format, fse->which);
+       dvp_try_format(dvp_dev, state, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
@@ -210,7 +206,7 @@ static int dvp_get_format(struct v4l2_subdev *sd,
        struct stf_dvp_dev *dvp_dev = v4l2_get_subdevdata(sd);
        struct v4l2_mbus_framefmt *format;
 
-       format = __dvp_get_format(dvp_dev, state->pads, fmt->pad, fmt->which);
+       format = __dvp_get_format(dvp_dev, state, fmt->pad, fmt->which);
        if (format == NULL)
                return -EINVAL;
 
@@ -227,20 +223,20 @@ static int dvp_set_format(struct v4l2_subdev *sd,
        struct v4l2_mbus_framefmt *format;
        int ret;
 
-       format = __dvp_get_format(dvp_dev, state->pads, fmt->pad, fmt->which);
+       format = __dvp_get_format(dvp_dev, state, fmt->pad, fmt->which);
        if (format == NULL)
                return -EINVAL;
 
-       dvp_try_format(dvp_dev, state->pads, fmt->pad, &fmt->format, fmt->which);
+       dvp_try_format(dvp_dev, state, fmt->pad, &fmt->format, fmt->which);
        *format = fmt->format;
 
        /* Propagate the format from sink to source */
        if (fmt->pad == STF_DVP_PAD_SINK) {
-               format = __dvp_get_format(dvp_dev, state->pads, STF_DVP_PAD_SRC,
+               format = __dvp_get_format(dvp_dev, state, STF_DVP_PAD_SRC,
                                        fmt->which);
 
                *format = fmt->format;
-               dvp_try_format(dvp_dev, state->pads, STF_DVP_PAD_SRC, format,
+               dvp_try_format(dvp_dev, state, STF_DVP_PAD_SRC, format,
                                        fmt->which);
        }
 
index 78a4228..24204cf 100755 (executable)
@@ -185,7 +185,7 @@ static int stf_dvp_stream_set(struct stf_dvp_dev *dvp_dev, int on)
                        0);
                reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_0, 
                        U0_VIN_CNFG_AXI_DVP_EN, 
-                       1<<2);
+                       !!on<<2);
                break;
        case SENSOR_ISP0:
                reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_36, 
index c6abdf8..8fdb69e 100755 (executable)
@@ -336,13 +336,11 @@ static int isp_set_power(struct v4l2_subdev *sd, int on)
 
 static struct v4l2_mbus_framefmt *
 __isp_get_format(struct stf_isp_dev *isp_dev,
-               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_state *state,
                unsigned int pad,
                enum v4l2_subdev_format_whence which)
 {
-       struct v4l2_subdev_state *state;
 
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
        if (which == V4L2_SUBDEV_FORMAT_TRY)
                return v4l2_subdev_get_try_format(&isp_dev->subdev, state, pad);
 
@@ -389,7 +387,7 @@ exit:
 }
 
 static void isp_try_format(struct stf_isp_dev *isp_dev,
-                       struct v4l2_subdev_pad_config *cfg,
+                       struct v4l2_subdev_state *state,
                        unsigned int pad,
                        struct v4l2_mbus_framefmt *fmt,
                        enum v4l2_subdev_format_whence which)
@@ -421,7 +419,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
 
        case STF_ISP_PAD_SRC:
 
-               *fmt = *__isp_get_format(isp_dev, cfg, STF_ISP_PAD_SINK, which);
+               *fmt = *__isp_get_format(isp_dev, state, STF_ISP_PAD_SINK, which);
 
                break;
        }
@@ -440,7 +438,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
        } else {
                struct v4l2_mbus_framefmt *sink_fmt;
 
-               sink_fmt = __isp_get_format(isp_dev, state->pads, STF_ISP_PAD_SINK,
+               sink_fmt = __isp_get_format(isp_dev, state, STF_ISP_PAD_SINK,
                                        code->which);
 
                code->code = sink_fmt->code;
@@ -465,7 +463,7 @@ static int isp_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       isp_try_format(isp_dev, state->pads, fse->pad, &format, fse->which);
+       isp_try_format(isp_dev, state, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -475,7 +473,7 @@ static int isp_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       isp_try_format(isp_dev, state->pads, fse->pad, &format, fse->which);
+       isp_try_format(isp_dev, state, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
@@ -489,7 +487,7 @@ static int isp_get_format(struct v4l2_subdev *sd,
        struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd);
        struct v4l2_mbus_framefmt *format;
 
-       format = __isp_get_format(isp_dev, state->pads, fmt->pad, fmt->which);
+       format = __isp_get_format(isp_dev, state, fmt->pad, fmt->which);
        if (format == NULL)
                return -EINVAL;
 
@@ -509,11 +507,11 @@ static int isp_set_format(struct v4l2_subdev *sd,
        struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd);
        struct v4l2_mbus_framefmt *format;
 
-       format = __isp_get_format(isp_dev, state->pads, fmt->pad, fmt->which);
+       format = __isp_get_format(isp_dev, state, fmt->pad, fmt->which);
        if (format == NULL)
                return -EINVAL;
 
-       isp_try_format(isp_dev, state->pads, fmt->pad, &fmt->format, fmt->which);
+       isp_try_format(isp_dev, state, fmt->pad, &fmt->format, fmt->which);
        *format = fmt->format;
 
        /* Propagate the format from sink to source */
@@ -521,11 +519,11 @@ static int isp_set_format(struct v4l2_subdev *sd,
                struct v4l2_subdev_selection sel = { 0 };
                int ret;
 
-               format = __isp_get_format(isp_dev, state->pads, STF_ISP_PAD_SRC,
+               format = __isp_get_format(isp_dev, state, STF_ISP_PAD_SRC,
                                        fmt->which);
 
                *format = fmt->format;
-               isp_try_format(isp_dev, state->pads, STF_ISP_PAD_SRC, format,
+               isp_try_format(isp_dev, state, STF_ISP_PAD_SRC, format,
                                        fmt->which);
 
                /* Reset sink pad compose selection */
@@ -568,13 +566,13 @@ __isp_get_crop(struct stf_isp_dev *isp_dev,
 }
 
 static void isp_try_compose(struct stf_isp_dev *isp_dev,
-                           struct v4l2_subdev_pad_config *cfg,
+                           struct v4l2_subdev_state *state,
                            struct v4l2_rect *rect,
                            enum v4l2_subdev_format_whence which)
 {
        struct v4l2_mbus_framefmt *fmt;
 
-       fmt = __isp_get_format(isp_dev, cfg, STF_ISP_PAD_SINK, which);
+       fmt = __isp_get_format(isp_dev, state, STF_ISP_PAD_SINK, which);
 
        if (rect->width > fmt->width)
                rect->width = fmt->width;
@@ -710,7 +708,7 @@ static int isp_set_selection(struct v4l2_subdev *sd,
                if (rect == NULL)
                        return -EINVAL;
 
-               isp_try_compose(isp_dev, state->pads, &sel->r, sel->which);
+               isp_try_compose(isp_dev, state, &sel->r, sel->which);
                *rect = sel->r;
 
                /* Reset source crop selection */
index 88ea10a..5e23f38 100755 (executable)
@@ -164,8 +164,11 @@ static int stf_vin_wr_stream_set(struct stf_vin2_dev *vin_dev, int on)
        if (on) {
                reg_set(vin->sysctrl_base, SYSCONSAIF_SYSCFG_20, U0_VIN_CNFG_AXIWR0_EN);          
        } else {
-               //reg_clear(vin->sysctrl_base, SYSCONSAIF_SYSCFG_20, U0_VIN_CNFG_AXIWR0_EN);
-               ;
+               reg_assert_rst(vin->clkgen_base,SOFTWARE_RESET_ASSERT0_ASSERT_SET,
+                       SOFTWARE_RESET_ASSERT0_ASSERT_SET_STATE, 
+                       RSTN_U0_VIN_RST_P_AXIWR); 
+               usleep_range(500, 1000);
+               reg_clear(vin->sysctrl_base, SYSCONSAIF_SYSCFG_20, U0_VIN_CNFG_AXIWR0_EN);
        }
        print_reg(ST_VIN, vin->sysctrl_base, SYSCONSAIF_SYSCFG_20);