Re: [Upstream] [PATCH] media: imx: imx7-media-csi: Sync frames to start of frame for MIPI

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

 



Hi Laurent,

On Thu, 2023-10-19 at 07:44 +0000, Stefan Riedmüller wrote:
> Hi Laurant,
> 
> On Wed, 2023-10-18 at 14:48 +0300, Laurent Pinchart wrote:
> > Hi Stefan,
> > 
> > Thank you for the patch.
> > 
> > On Tue, Oct 17, 2023 at 05:08:54PM +0200, Stefan Riedmüller wrote:
> > > The default behavior for a base address change is to do it automatically
> > > after a DMA completion. This can lead to the situation, were one
> > > corrupted frame, with less lines than configured, results in all
> > > following frames being corrupted as well, due to a missing
> > > re-synchronization to the beginning of the next frame.
> > > 
> > > Fix this by configuring the base address switch to be synced with the
> > > start of frame event.
> > > 
> > > Currently this is already implemented for the parallel interface. To
> > > have it with MIPI as well, simply configure it unconditionally.
> > > 
> > > Tested on i.MX 8MM.
> > 
> > I recall not doing this unconditionally as it didn't work on some of the
> > platforms I was testing, but I'm not sure of the details anymore. I'll
> > retest on i.MX7.
> 
> Thanks!

Any update yet on the i.MX7 test?

Regards,
Stefan

> 
> > Do we have any buffer overflow protection in this mode ? If the sensor
> > happens to send more lines than expected, will extra lines be dropped,
> > or overflow the buffer ?
> 
> As far as I understand the imx8mm reference manual, I think there is a
> buffer
> overflow protection, in the form that the DMA will only write the amount of
> data which was configured in CSI_IMAG_PARA. If additional data arrives on
> the
> bus, without a new start of frame event, a new DMA transfer will be
> triggered
> eventually. Since there was no base address change, due to the missing start
> frame event, the new DMA transfer will use the same buffer as before and
> corrupt that data. But all subsequent frames will be ok since a new frame
> will
> trigger the start of frame event and thus a base address change.
> 
> 
> Regards,
> Stefan  t
> 
> > 
> > > Signed-off-by: Stefan Riedmüller <s.riedmueller@xxxxxxxxx>
> > > ---
> > >  drivers/media/platform/nxp/imx7-media-csi.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/media/platform/nxp/imx7-media-csi.c
> > > b/drivers/media/platform/nxp/imx7-media-csi.c
> > > index 15049c6aab37..0c9e3f01e96d 100644
> > > --- a/drivers/media/platform/nxp/imx7-media-csi.c
> > > +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> > > @@ -529,13 +529,13 @@ static void imx7_csi_configure(struct imx7_csi
> > > *csi,
> > >  		stride = out_pix->width;
> > >  	}
> > >  
> > > +	cr18 |= BIT_BASEADDR_SWITCH_EN | BIT_BASEADDR_SWITCH_SEL |
> > > +		BIT_BASEADDR_CHG_ERR_EN;
> > > +
> > >  	if (!csi->is_csi2) {
> > >  		cr1 = BIT_SOF_POL | BIT_REDGE | BIT_GCLK_MODE |
> > > BIT_HSYNC_POL
> > >  		    | BIT_FCC | BIT_MCLKDIV(1) | BIT_MCLKEN;
> > >  
> > > -		cr18 |= BIT_BASEADDR_SWITCH_EN |
> > > BIT_BASEADDR_SWITCH_SEL
> > > > 
> > > -			BIT_BASEADDR_CHG_ERR_EN;
> > > -
> > >  		if (out_pix->pixelformat == V4L2_PIX_FMT_UYVY ||
> > >  		    out_pix->pixelformat == V4L2_PIX_FMT_YUYV)
> > >  			width *= 2;
> > 
> _______________________________________________
> upstream mailing list
> upstream@xxxxxxxxxxxxxxx
> http://lists.phytec.de/cgi-bin/mailman/listinfo/upstream




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux