<div dir="ltr"><div dir="ltr">Hi Roman,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 9 Nov 2021 at 13:28, Roman Stratiienko <<a href="mailto:r.stratiienko@gmail.com">r.stratiienko@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">To make Android happy I've applied one patch:<br>
<br>
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
@@ -429,9 +429,10 @@ CameraConfiguration::Status<br>
RPiCameraConfiguration::validate()<br>
                        rawCount++;<br>
                } else {<br>
+                       cfg.bufferCount = 3;<br>
                        outSize[outCount] = std::make_pair(count, cfg.size);<br>
                        /* Record the largest resolution for fixups later. */<br>
                        if (maxSize < cfg.size) {<br>
<br>
(Similar are done in other pipelines).<br>
<br>
And it seems to me that it somehow conflicts with raspberrypi pipeline<br>
internals.<br></blockquote><div><br></div><div>The problem seems to be the number of cache slots is not set up correctly for your usage.</div><div>From what I can gather, the Android layer allocated its own buffers to use by the pipeline</div><div>handler, but the number of cache slots the pipeline handler allocates is smaller than</div><div>the total number of buffers available.  Hence the failure where the cache may not be able</div><div>to find a free slot to use.</div><div><br></div><div>I've been meaning to address this bit of logic for a long time now, so perhaps this is</div><div>a good time to do this.  It's not a big change, but there are certain assumptions to be made</div><div>to balance between over allocation and loss of performance.  I will post a patch soon, would</div><div>you be able to try it out in your environment and report if it solves your issue?</div><div><br></div><div>Thanks,</div><div>Naush</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
вт, 9 нояб. 2021 г. в 13:54, Roman Stratiienko <<a href="mailto:r.stratiienko@gmail.com" target="_blank">r.stratiienko@gmail.com</a>>:<br>
><br>
> Hi Naushir,<br>
><br>
> Thanks a lot for your support. You were right, it returns with error<br>
> in that place. I'm correctly investigating why there is no buffer in<br>
> the cache.<br>
><br>
> вт, 9 нояб. 2021 г. в 12:32, Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>>:<br>
> ><br>
> ><br>
> > On Tue, 9 Nov 2021 at 10:26, Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>> wrote:<br>
> >><br>
> >> Hi Roman,<br>
> >><br>
> >> Not sure if the email thread is the best place to discuss your issue, so perhaps create a bug report at <a href="http://bugs.libcamera.org" rel="noreferrer" target="_blank">bugs.libcamera.org</a>.<br>
> >> Onto the actual issue - it seems like the ISP gets starved of request buffers and fails to produce output and the pipeline handler stalls.<br>
> >> The reason it gets starved is likely to be due to the following errors in the log:<br>
> >><br>
> >> 10-07 14:37:46.726   360   442 D libcamera: DEBUG RPISTREAM rpi_stream.cpp:226 Queuing buffer 1048579 for ISP Output1<br>
> >> 10-07 14:37:46.727   360   442 E libcamera: ERROR RPISTREAM rpi_stream.cpp:231 Failed to queue buffer for ISP Output1<br>
> >> 10-07 14:37:46.727   360   442 D libcamera: DEBUG RPISTREAM rpi_stream.cpp:226 Queuing buffer 1048580 for ISP Output1<br>
> >> 10-07 14:37:46.727   360   442 E libcamera: ERROR RPISTREAM rpi_stream.cpp:231 Failed to queue buffer for ISP Output1<br>
> >> 10-07 14:37:46.727   360   442 D libcamera: DEBUG RPISTREAM rpi_stream.cpp:226 Queuing buffer 1048581 for ISP Output1<br>
> >> 10-07 14:37:46.728   360   442 E libcamera: ERROR RPISTREAM rpi_stream.cpp:231 Failed to queue buffer for ISP Output1<br>
> >><br>
> >> I cannot tell further why the qbuf ioctl has failed.  Perhaps something in dmesg would tell us?  Could you expand on how your request<br>
> >> buffers have been allocated?<br>
> ><br>
> ><br>
> > Just a pointer for you to investigate... The logs suggest that V4L2VideoDevice::queueBuffer() fails at:<br>
> ><br>
> > ret = cache_->get(*buffer);<br>
> > if (ret < 0)<br>
> >         return ret;<br>
> ><br>
> > as all other error paths through that function log a message, and we see none.  So it may not necessarily be the ioctl that fails.<br>
> ><br>
> > Naush<br>
> ><br>
> >><br>
> >><br>
> >> Thanks,<br>
> >> Naush<br>
> >><br>
> >><br>
> >> On Mon, 8 Nov 2021 at 20:20, Roman Stratiienko <<a href="mailto:r.stratiienko@gmail.com" target="_blank">r.stratiienko@gmail.com</a>> wrote:<br>
> >>><br>
> >>> Yes, I am on the very latest rpi branch without any custom patches. I had to upgrade it because of new media control used in mainline libcamera.<br>
> >>><br>
> >>> пн, 8 нояб. 2021 г., 22:12 Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com" target="_blank">kieran.bingham@ideasonboard.com</a>>:<br>
> >>>><br>
> >>>> Hi Roman,<br>
> >>>><br>
> >>>> Quoting Roman Stratiienko (2021-11-08 17:46:56)<br>
> >>>> > Hi guys,<br>
> >>>> ><br>
> >>>> > I have stuck with camera bring-up for Android. Could somebody who has<br>
> >>>> > experience in it help me to find a right way to solve this. Logs are<br>
> >>>> > available here:<br>
> >>>> > <a href="https://github.com/kbingham/libcamera/issues/31" rel="noreferrer" target="_blank">https://github.com/kbingham/libcamera/issues/31</a><br>
> >>>><br>
> >>>> The RPi kernel, and pipeline handler have had a large change recently to<br>
> >>>> convert to using MediaController. It may require ensuring you have the<br>
> >>>> latest kernel from RPi, along with the latest libcamera.<br>
> >>>><br>
> >>>> You mentioned that you have " rpi-kernel v5.10.y", do you know if this<br>
> >>>> contains the commits that update to the new MediaController drivers?<br>
> >>>><br>
> >>>> I assume you are building your own kernel, so you'll want to make sure<br>
> >>>> you're on the (very, very) latest branch, and it might be something to<br>
> >>>> check on the RPi forums otherwise.<br>
> >>>><br>
> >>>> --<br>
> >>>> Kieran<br>
> >>>><br>
> >>>><br>
> >>>> ><br>
> >>>> > Thanks in advance,<br>
> >>>> > Roman<br>
</blockquote></div></div>