[PATCH v2 6/8] staging: media: starfive: Fix bayer output stride configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the bayer output stride configuration. And convert set the stride
be a helper function. Improve readability.

Fixes: e57854628f58 ("media: staging: media: starfive: camss: Add ISP driver")

Signed-off-by: Changhuang Liang <changhuang.liang@xxxxxxxxxxxxxxxx>
---
 .../staging/media/starfive/camss/stf-isp-hw-ops.c   | 13 +++++++++----
 drivers/staging/media/starfive/camss/stf-isp.c      | 12 +++++++++---
 drivers/staging/media/starfive/camss/stf-isp.h      |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
index f170fab2bfb4..c990dc124f77 100644
--- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
+++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
@@ -408,6 +408,15 @@ void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
 	stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_STRIDE, val);
 }
 
+void stf_isp_config_bayer_out_stride(struct stf_isp_dev *isp_dev,
+				     u32 width, u8 bpp)
+{
+	u32 val = ALIGN(width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_128);
+
+	stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_DUMP_CFG_1,
+			  DUMP_BURST_LEN(3) | val);
+}
+
 static void stf_isp_config_raw_fmt(struct stfcamss *stfcamss, u32 mcode)
 {
 	u32 val, val1;
@@ -459,10 +468,6 @@ void stf_isp_settings(struct stf_isp_dev *isp_dev,
 	stf_isp_config_crop(stfcamss, crop);
 	stf_isp_config_raw_fmt(stfcamss, mcode);
 
-	stf_isp_reg_set_bit(stfcamss, ISP_REG_DUMP_CFG_1,
-			    DUMP_BURST_LEN_MASK | DUMP_SD_MASK,
-			    DUMP_BURST_LEN(3));
-
 	stf_isp_reg_write(stfcamss, ISP_REG_ITIIWSR,
 			  ITI_HSIZE(IMAGE_MAX_HEIGH) |
 			  ITI_WSIZE(IMAGE_MAX_WIDTH));
diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
index fb48e7a29e8c..ef07639bf4d1 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -88,22 +88,28 @@ int stf_isp_init(struct stfcamss *stfcamss)
 void stf_isp_stream_on(struct stf_isp_dev *isp_dev,
 		       struct v4l2_subdev_state *sd_state)
 {
-	const struct stf_isp_format_table *fmt_t_src;
-	struct v4l2_mbus_framefmt *fmt, *fmt_src;
+	const struct stf_isp_format_table *fmt_t_src, *fmt_t_bayer;
+	struct v4l2_mbus_framefmt *fmt, *fmt_src, *fmt_bayer;
 	struct v4l2_rect *crop;
-	int src;
+	int src, bayer;
 
 	fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
+	fmt_t_bayer = &isp_dev->formats[STF_ISP_PAD_SRC_BAYER];
 	fmt = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SINK);
 	fmt_src = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC);
+	fmt_bayer = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC_BAYER);
 	crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SINK);
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
+	bayer = stf_isp_g_index_by_mcode(fmt_t_bayer, fmt_bayer->code);
 
 	stf_isp_reset(isp_dev);
 	stf_isp_init_cfg(isp_dev);
 	stf_isp_settings(isp_dev, crop, fmt->code);
 	stf_isp_config_yuv_out_stride(isp_dev, crop->width,
 				      fmt_t_src->fmts[src].bpp);
+	stf_isp_config_bayer_out_stride(isp_dev, crop->width,
+					fmt_t_bayer->fmts[bayer].bpp);
+
 	stf_isp_stream_set(isp_dev);
 }
 
diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h
index 8505603bdbc5..546c79332e9a 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.h
+++ b/drivers/staging/media/starfive/camss/stf-isp.h
@@ -77,8 +77,6 @@
 #define DUMP_SHT(n)				((n) << 20)
 #define DUMP_BURST_LEN(n)			((n) << 16)
 #define DUMP_SD(n)				((n) << 0)
-#define DUMP_BURST_LEN_MASK			GENMASK(17, 16)
-#define DUMP_SD_MASK				GENMASK(15, 0)
 
 #define ISP_REG_DEC_CFG				0x030
 #define DEC_V_KEEP(n)				((n) << 24)
@@ -586,6 +584,8 @@ void stf_isp_stream_on(struct stf_isp_dev *isp_dev,
 		       struct v4l2_subdev_state *sd_state);
 void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
 				   u32 width, u8 bpp);
+void stf_isp_config_bayer_out_stride(struct stf_isp_dev *isp_dev,
+				     u32 width, u8 bpp);
 int stf_isp_init(struct stfcamss *stfcamss);
 int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev);
 int stf_isp_unregister(struct stf_isp_dev *isp_dev);
-- 
2.25.1





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux