2024-03-06 09:37:45

by Changhuang Liang

[permalink] [raw]
Subject: [PATCH v1 6/7] staging: media: starfive: Add raw output stride configure

Add raw output stride to enable sent the aligned raw data to memory.

Signed-off-by: Changhuang Liang <[email protected]>
---
.../staging/media/starfive/camss/stf-isp-hw-ops.c | 13 +++++++++----
drivers/staging/media/starfive/camss/stf-isp.c | 11 ++++++++---
drivers/staging/media/starfive/camss/stf-isp.h | 4 ++--
3 files changed, 19 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 b933d425cbd0..e7f60616bd7c 100644
--- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
+++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
@@ -366,6 +366,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_raw_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;
@@ -417,10 +426,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 1bfd336b14a1..845446ba279c 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -78,18 +78,21 @@ int stf_isp_init(struct stfcamss *stfcamss)
static int isp_set_stream(struct v4l2_subdev *sd, int enable)
{
struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd);
- 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_raw;
+ struct v4l2_mbus_framefmt *fmt, *fmt_src, *fmt_raw;
struct v4l2_subdev_state *sd_state;
struct v4l2_rect *crop;
- int src;
+ int src, raw;

sd_state = v4l2_subdev_lock_and_get_active_state(sd);
fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
+ fmt_t_raw = &isp_dev->formats[STF_ISP_PAD_SRC_RAW];
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_raw = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC_RAW);
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);
+ raw = stf_isp_g_index_by_mcode(fmt_t_raw, fmt_raw->code);

if (enable) {
if (!isp_dev->stream_count) {
@@ -98,6 +101,8 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
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_raw_out_stride(isp_dev, crop->width,
+ fmt_t_raw->fmts[raw].bpp);
stf_isp_stream_set(isp_dev);

v4l2_subdev_call(isp_dev->source_subdev, video,
diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h
index 30e4eb29f077..dcbc42f0dfe4 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.h
+++ b/drivers/staging/media/starfive/camss/stf-isp.h
@@ -76,8 +76,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)
@@ -424,6 +422,8 @@ void stf_isp_settings(struct stf_isp_dev *isp_dev,
void stf_isp_stream_set(struct stf_isp_dev *isp_dev);
void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
u32 width, u8 bpp);
+void stf_isp_config_raw_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



2024-03-06 14:27:33

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v1 6/7] staging: media: starfive: Add raw output stride configure

On Wed, Mar 06, 2024 at 01:33:33AM -0800, Changhuang Liang wrote:
> Add raw output stride to enable sent the aligned raw data to memory.
>

Subject: staging: media: starfive: Fix raw output stride configuration

I think this is bugfix? What is the impact of this change to the user?

But I can't really understand the commit message and it's hard to review
the code without being able to apply it. I'm also new to this subsystem
so maybe someone else would have been able to understand it better...
Sorry...

regards,
dan carpenter


2024-03-07 02:34:40

by Changhuang Liang

[permalink] [raw]
Subject: 回复: [PATCH v1 6/7] staging: media: starfive : Add raw output stride configure

Hi, Dan

> On Wed, Mar 06, 2024 at 01:33:33AM -0800, Changhuang Liang wrote:
> > Add raw output stride to enable sent the aligned raw data to memory.
> >
>
> Subject: staging: media: starfive: Fix raw output stride configuration
>
> I think this is bugfix? What is the impact of this change to the user?
>
> But I can't really understand the commit message and it's hard to review the
> code without being able to apply it. I'm also new to this subsystem so
> maybe someone else would have been able to understand it better...
> Sorry...
>

You can try to apply it on tag v6.8-rc7.

1.
Applying: staging: media: starfive: Renamed capture_raw to capture_dump

2.
Applying: staging: media: starfive: Replaced current_fmt with get from sd_state
Applying: staging: media: starfive: Add raw pad for ISP
Applying: staging: media: starfive: Sink rectangle set to ISP source pad
Applying: staging: media: starfive: Add multi streams for ISP
Applying: staging: media: starfive: Add ISP raw video device
Applying: staging: media: starfive: Add raw output stride configure
Applying: admin-guide: media: Update documents for StarFive Camera Subsystem

Regards,
Changhuang