From: Changhuang Liang <changhuang.liang@starfivetech.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Jack Zhu <jack.zhu@starfivetech.com>,
Changhuang Liang <changhuang.liang@starfivetech.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: [PATCH v2 1/8] staging: media: starfive: Get rid of current_fmt
Date: Wed, 10 Apr 2024 02:10:19 -0700 [thread overview]
Message-ID: <20240410091026.50272-2-changhuang.liang@starfivetech.com> (raw)
In-Reply-To: <20240410091026.50272-1-changhuang.liang@starfivetech.com>
We want to support multiple formats so saving one "current_fmt" doesn't
work. This was only used to set the ISP_REG_STRIDE so use the sd_state
directly for that and delete the ->current_fmt pointer. No functional
change.
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
---
.../media/starfive/camss/stf-isp-hw-ops.c | 10 ++++---
.../staging/media/starfive/camss/stf-isp.c | 26 +++++++++++++++----
.../staging/media/starfive/camss/stf-isp.h | 3 ++-
3 files changed, 30 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 84716c809ab1..44ac472d9dc3 100644
--- a/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
+++ b/drivers/staging/media/starfive/camss/stf-isp-hw-ops.c
@@ -387,7 +387,6 @@ void stf_isp_init_cfg(struct stf_isp_dev *isp_dev)
static void stf_isp_config_crop(struct stfcamss *stfcamss,
struct v4l2_rect *crop)
{
- u32 bpp = stfcamss->isp_dev.current_fmt->bpp;
u32 val;
val = VSTART_CAP(crop->top) | HSTART_CAP(crop->left);
@@ -399,9 +398,14 @@ static void stf_isp_config_crop(struct stfcamss *stfcamss,
val = H_ACT_CAP(crop->height) | W_ACT_CAP(crop->width);
stf_isp_reg_write(stfcamss, ISP_REG_PIPELINE_XY_SIZE, val);
+}
+
+void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
+ u32 width, u8 bpp)
+{
+ u32 val = ALIGN(width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_8);
- val = ALIGN(crop->width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_8);
- stf_isp_reg_write(stfcamss, ISP_REG_STRIDE, val);
+ stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_STRIDE, val);
}
static void stf_isp_config_raw_fmt(struct stfcamss *stfcamss, u32 mcode)
diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
index 0cbd23069ac6..d961e06d9f7a 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -53,6 +53,19 @@ stf_g_fmt_by_mcode(const struct stf_isp_format_table *fmt_table, u32 mcode)
return NULL;
}
+static int stf_isp_g_index_by_mcode(const struct stf_isp_format_table *fmt_table,
+ u32 mcode)
+{
+ int i;
+
+ for (i = 0; i < fmt_table->nfmts; i++) {
+ if (fmt_table->fmts[i].code == mcode)
+ return i;
+ }
+
+ return -EINVAL;
+}
+
int stf_isp_init(struct stfcamss *stfcamss)
{
struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
@@ -60,7 +73,6 @@ int stf_isp_init(struct stfcamss *stfcamss)
isp_dev->stfcamss = stfcamss;
isp_dev->formats = isp_formats_st7110;
isp_dev->nformats = ARRAY_SIZE(isp_formats_st7110);
- isp_dev->current_fmt = &isp_formats_source[0];
return 0;
}
@@ -68,15 +80,22 @@ int stf_isp_init(struct stfcamss *stfcamss)
void stf_isp_stream_on(struct stf_isp_dev *isp_dev,
struct v4l2_subdev_state *sd_state)
{
- struct v4l2_mbus_framefmt *fmt;
+ const struct stf_isp_format_table *fmt_t_src;
+ struct v4l2_mbus_framefmt *fmt, *fmt_src;
struct v4l2_rect *crop;
+ int src;
+ fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
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);
crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SRC);
+ src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->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_stream_set(isp_dev);
}
@@ -181,9 +200,6 @@ static int isp_set_format(struct v4l2_subdev *sd,
if (fmt->pad == STF_ISP_PAD_SRC_SCD || fmt->pad == STF_ISP_PAD_SINK_PARAMS)
return 0;
- isp_dev->current_fmt = stf_g_fmt_by_mcode(&isp_dev->formats[fmt->pad],
- fmt->format.code);
-
/* Propagate to in crop */
if (fmt->pad == STF_ISP_PAD_SINK) {
struct v4l2_subdev_selection sel = { 0 };
diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h
index cad202d9ce6d..3eade22c669e 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.h
+++ b/drivers/staging/media/starfive/camss/stf-isp.h
@@ -574,7 +574,6 @@ struct stf_isp_dev {
const struct stf_isp_format_table *formats;
unsigned int nformats;
struct v4l2_subdev *source_subdev;
- const struct stf_isp_format *current_fmt;
};
int stf_isp_reset(struct stf_isp_dev *isp_dev);
@@ -584,6 +583,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_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);
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
next prev parent reply other threads:[~2024-04-10 9:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 9:10 [PATCH v2 0/8] Add ISP Bayer for StarFive Changhuang Liang
2024-04-10 9:10 ` Changhuang Liang [this message]
2024-04-10 9:10 ` [PATCH v2 2/8] staging: media: starfive: Add bayer pad for ISP Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 3/8] staging: media: starfive: Use PAD_SINK instead of PAD_SRC for crop Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 4/8] staging: media: starfive: Introduce isp_stream Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 5/8] staging: media: starfive: Add ISP bayer video device Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 6/8] staging: media: starfive: Fix bayer output stride configuration Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 7/8] staging: media: starfive: Move the struct media_pipeline position Changhuang Liang
2024-04-10 9:10 ` [PATCH v2 8/8] admin-guide: media: Update documents for StarFive Camera Subsystem Changhuang Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240410091026.50272-2-changhuang.liang@starfivetech.com \
--to=changhuang.liang@starfivetech.com \
--cc=bryan.odonoghue@linaro.org \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jack.zhu@starfivetech.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®