On Fri Mar 20 14:42:02 2026 +0800, Guoniu Zhou wrote:
> The number of times to use the discard buffer is determined by the
> out_pending list size:
> 
>   discard = list_empty(&video->out_pending) ? 2
>             : list_is_singular(&video->out_pending) ? 1
>             : 0;
> 
> In the current buffer selection logic, when both discard and pending
> buffers are available, the driver fills hardware slots with discard
> buffers first which results in an unnecessary frame drop even though
> a user buffer was queued and ready.
> 
> Change the buffer selection logic to use pending buffers first (up to
> the number available), and only use discard buffers to fill remaining
> slots when insufficient pending buffers are queued.
> 
> This improves behavior by:
> - Reducing discarded frames at stream start when user buffers are ready
> - Decreasing latency in delivering captured frames to user-space
> - Ensuring user buffers are utilized as soon as they are queued
> - Improving overall buffer utilization efficiency
> 
> Signed-off-by: Guoniu Zhou <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Link: 
> https://patch.msgid.link/[email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

---

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c 
b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
index 1be3a728f32f..fe4adfa3a1f0 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
@@ -792,7 +792,11 @@ static void mxc_isi_video_queue_first_buffers(struct 
mxc_isi_video *video)
                struct mxc_isi_buffer *buf;
                struct list_head *list;
 
-               list = i < discard ? &video->out_discard : &video->out_pending;
+               /*
+                * Queue buffers: prioritize pending buffers, then discard
+                * buffers.
+                */
+               list = (i < 2 - discard) ? &video->out_pending : 
&video->out_discard;
                buf = list_first_entry(list, struct mxc_isi_buffer, list);
 
                mxc_isi_channel_set_outbuf(video->pipe, buf->dma_addrs, buf_id);
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to