Skip to content

Commit 0b49f5d

Browse files
trettergregkh
authored andcommitted
media: staging: imx: request mbus_config in csi_start
commit 9df2aaa upstream. Request the upstream mbus_config in csi_start, which starts the stream, instead of caching it in link_validate. This allows to get rid of the mbus_cfg field in the struct csi_priv and avoids state in the driver. Fixes: 4a34ec8 ("[media] media: imx: Add CSI subdev driver") Cc: stable@vger.kernel.org Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2dde85b commit 0b49f5d

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

drivers/staging/media/imx/imx-media-csi.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ struct csi_priv {
9797
/* the mipi virtual channel number at link validate */
9898
int vc_num;
9999

100-
/* media bus config of the upstream subdevice CSI is receiving from */
101-
struct v4l2_mbus_config mbus_cfg;
102-
103100
spinlock_t irqlock; /* protect eof_irq handler */
104101
struct timer_list eof_timeout_timer;
105102
int eof_irq;
@@ -403,7 +400,8 @@ static void csi_idmac_unsetup_vb2_buf(struct csi_priv *priv,
403400
}
404401

405402
/* init the SMFC IDMAC channel */
406-
static int csi_idmac_setup_channel(struct csi_priv *priv)
403+
static int csi_idmac_setup_channel(struct csi_priv *priv,
404+
struct v4l2_mbus_config *mbus_cfg)
407405
{
408406
struct imx_media_video_dev *vdev = priv->vdev;
409407
const struct imx_media_pixfmt *incc;
@@ -432,7 +430,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
432430
image.phys0 = phys[0];
433431
image.phys1 = phys[1];
434432

435-
passthrough = requires_passthrough(&priv->mbus_cfg, infmt, incc);
433+
passthrough = requires_passthrough(mbus_cfg, infmt, incc);
436434
passthrough_cycles = 1;
437435

438436
/*
@@ -572,11 +570,12 @@ static void csi_idmac_unsetup(struct csi_priv *priv,
572570
csi_idmac_unsetup_vb2_buf(priv, state);
573571
}
574572

575-
static int csi_idmac_setup(struct csi_priv *priv)
573+
static int csi_idmac_setup(struct csi_priv *priv,
574+
struct v4l2_mbus_config *mbus_cfg)
576575
{
577576
int ret;
578577

579-
ret = csi_idmac_setup_channel(priv);
578+
ret = csi_idmac_setup_channel(priv, mbus_cfg);
580579
if (ret)
581580
return ret;
582581

@@ -595,7 +594,8 @@ static int csi_idmac_setup(struct csi_priv *priv)
595594
return 0;
596595
}
597596

598-
static int csi_idmac_start(struct csi_priv *priv)
597+
static int csi_idmac_start(struct csi_priv *priv,
598+
struct v4l2_mbus_config *mbus_cfg)
599599
{
600600
struct imx_media_video_dev *vdev = priv->vdev;
601601
int ret;
@@ -619,7 +619,7 @@ static int csi_idmac_start(struct csi_priv *priv)
619619
priv->last_eof = false;
620620
priv->nfb4eof = false;
621621

622-
ret = csi_idmac_setup(priv);
622+
ret = csi_idmac_setup(priv, mbus_cfg);
623623
if (ret) {
624624
v4l2_err(&priv->sd, "csi_idmac_setup failed: %d\n", ret);
625625
goto out_free_dma_buf;
@@ -701,7 +701,8 @@ static void csi_idmac_stop(struct csi_priv *priv)
701701
}
702702

703703
/* Update the CSI whole sensor and active windows */
704-
static int csi_setup(struct csi_priv *priv)
704+
static int csi_setup(struct csi_priv *priv,
705+
struct v4l2_mbus_config *mbus_cfg)
705706
{
706707
struct v4l2_mbus_framefmt *infmt, *outfmt;
707708
const struct imx_media_pixfmt *incc;
@@ -719,7 +720,7 @@ static int csi_setup(struct csi_priv *priv)
719720
* if cycles is set, we need to handle this over multiple cycles as
720721
* generic/bayer data
721722
*/
722-
if (is_parallel_bus(&priv->mbus_cfg) && incc->cycles) {
723+
if (is_parallel_bus(mbus_cfg) && incc->cycles) {
723724
if_fmt.width *= incc->cycles;
724725
crop.width *= incc->cycles;
725726
}
@@ -730,7 +731,7 @@ static int csi_setup(struct csi_priv *priv)
730731
priv->crop.width == 2 * priv->compose.width,
731732
priv->crop.height == 2 * priv->compose.height);
732733

733-
ipu_csi_init_interface(priv->csi, &priv->mbus_cfg, &if_fmt, outfmt);
734+
ipu_csi_init_interface(priv->csi, mbus_cfg, &if_fmt, outfmt);
734735

735736
ipu_csi_set_dest(priv->csi, priv->dest);
736737

@@ -745,9 +746,17 @@ static int csi_setup(struct csi_priv *priv)
745746

746747
static int csi_start(struct csi_priv *priv)
747748
{
749+
struct v4l2_mbus_config mbus_cfg = { .type = 0 };
748750
struct v4l2_fract *input_fi, *output_fi;
749751
int ret;
750752

753+
ret = csi_get_upstream_mbus_config(priv, &mbus_cfg);
754+
if (ret) {
755+
v4l2_err(&priv->sd,
756+
"failed to get upstream media bus configuration\n");
757+
return ret;
758+
}
759+
751760
input_fi = &priv->frame_interval[CSI_SINK_PAD];
752761
output_fi = &priv->frame_interval[priv->active_output_pad];
753762

@@ -758,7 +767,7 @@ static int csi_start(struct csi_priv *priv)
758767
return ret;
759768

760769
/* Skip first few frames from a BT.656 source */
761-
if (priv->mbus_cfg.type == V4L2_MBUS_BT656) {
770+
if (mbus_cfg.type == V4L2_MBUS_BT656) {
762771
u32 delay_usec, bad_frames = 20;
763772

764773
delay_usec = DIV_ROUND_UP_ULL((u64)USEC_PER_SEC *
@@ -769,12 +778,12 @@ static int csi_start(struct csi_priv *priv)
769778
}
770779

771780
if (priv->dest == IPU_CSI_DEST_IDMAC) {
772-
ret = csi_idmac_start(priv);
781+
ret = csi_idmac_start(priv, &mbus_cfg);
773782
if (ret)
774783
goto stop_upstream;
775784
}
776785

777-
ret = csi_setup(priv);
786+
ret = csi_setup(priv, &mbus_cfg);
778787
if (ret)
779788
goto idmac_stop;
780789

@@ -1122,7 +1131,6 @@ static int csi_link_validate(struct v4l2_subdev *sd,
11221131

11231132
mutex_lock(&priv->lock);
11241133

1125-
priv->mbus_cfg = mbus_cfg;
11261134
is_csi2 = !is_parallel_bus(&mbus_cfg);
11271135
if (is_csi2) {
11281136
/*

0 commit comments

Comments
 (0)