Message ID | 20250417065554.437541-10-r-donadkar@ti.com |
---|---|
State | New |
Headers | show |
Series | media: cadence,ti: CSI2RX Multistream Support | expand |
> From: Jai Luthra <j-luthra@ti.com> > > The enable_streams() API in v4l2 supports passing a bitmask to enable each > pad/stream combination individually on any media subdev instead of doing > s_stream(1) to start all streams on the subdev at once. > > This API is implemented by ds90ub960 driver (FPDLink deser) and thus the > caller (cdns-csi2x) is required to use it. For now we only enable stream0. > > Signed-off-by: Jai Luthra <j-luthra@ti.com> > Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com> Reviewed-by: Changhuang Liang <changhuang.liang@starfivetech.com> Best Regards, Changhuang
Hi Rishikesh, Thank you for the patch. On Thu, Apr 17, 2025 at 12:25:50PM +0530, Rishikesh Donadkar wrote: > From: Jai Luthra <j-luthra@ti.com> > > The enable_streams() API in v4l2 supports passing a bitmask to enable > each pad/stream combination individually on any media subdev instead of > doing s_stream(1) to start all streams on the subdev at once. > > This API is implemented by ds90ub960 driver (FPDLink deser) and thus the > caller (cdns-csi2x) is required to use it. For now we only enable > stream0. > > Signed-off-by: Jai Luthra <j-luthra@ti.com> > Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com> > --- > drivers/media/platform/cadence/cdns-csi2rx.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c > index b7e9225f66a41..df05d278df379 100644 > --- a/drivers/media/platform/cadence/cdns-csi2rx.c > +++ b/drivers/media/platform/cadence/cdns-csi2rx.c > @@ -224,10 +224,18 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) > static int csi2rx_start(struct csi2rx_priv *csi2rx) > { > unsigned int i; > + struct media_pad *remote_pad; > unsigned long lanes_used = 0; > u32 reg; > int ret; > > + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); Can't you use csi2rx->source_pad instead ? > + if (!remote_pad) { > + dev_err(csi2rx->dev, > + "Failed to find connected source\n"); > + return -ENODEV; > + } > + > ret = clk_prepare_enable(csi2rx->p_clk); > if (ret) > return ret; > @@ -311,7 +319,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) > > reset_control_deassert(csi2rx->sys_rst); > > - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); > + ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, > + remote_pad->index, BIT(0)); > if (ret) > goto err_disable_sysclk; > > @@ -339,6 +348,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) > > static void csi2rx_stop(struct csi2rx_priv *csi2rx) > { > + struct media_pad *remote_pad; > unsigned int i; > u32 val; > int ret; > @@ -367,8 +377,12 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) > reset_control_assert(csi2rx->p_rst); > clk_disable_unprepare(csi2rx->p_clk); > > - if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false)) > + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); > + if (!remote_pad || > + v4l2_subdev_disable_streams(csi2rx->source_subdev, > + remote_pad->index, BIT(0))) { > dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); > + } > > if (csi2rx->dphy) { > writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index b7e9225f66a41..df05d278df379 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -224,10 +224,18 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) static int csi2rx_start(struct csi2rx_priv *csi2rx) { unsigned int i; + struct media_pad *remote_pad; unsigned long lanes_used = 0; u32 reg; int ret; + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad) { + dev_err(csi2rx->dev, + "Failed to find connected source\n"); + return -ENODEV; + } + ret = clk_prepare_enable(csi2rx->p_clk); if (ret) return ret; @@ -311,7 +319,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) reset_control_deassert(csi2rx->sys_rst); - ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); + ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, + remote_pad->index, BIT(0)); if (ret) goto err_disable_sysclk; @@ -339,6 +348,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) static void csi2rx_stop(struct csi2rx_priv *csi2rx) { + struct media_pad *remote_pad; unsigned int i; u32 val; int ret; @@ -367,8 +377,12 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) reset_control_assert(csi2rx->p_rst); clk_disable_unprepare(csi2rx->p_clk); - if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false)) + remote_pad = media_pad_remote_pad_first(&csi2rx->pads[CSI2RX_PAD_SINK]); + if (!remote_pad || + v4l2_subdev_disable_streams(csi2rx->source_subdev, + remote_pad->index, BIT(0))) { dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); + } if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);