#
✕ nick:marcan
#asahi-dev · 2023-08-04 07:18
marcanonce at least 2 are enqueued again you can fetch another batch (of at least size 2)
#asahi-dev · 2023-08-04 07:18
marcanactually no, if you do 6 why wouldn't that work? they'd pop one, and add one, but there's 5 more left to pop so it won't block
#asahi-dev · 2023-08-04 07:17
marcanyeah, so you never want to do the full queue size
#asahi-dev · 2023-08-04 07:13
marcanI'm trying to understand how that works, sort of looks like an additional buffer count?
#asahi-dev · 2023-08-04 07:13
marcaneiln: looks like queue_setup is allowed to do stuff with the buffer count, see e.g. v4l2-pci-skeleton.c
#asahi-dev · 2023-08-04 07:07
marcanhttps://www.kernel.org/doc/html/v4.9/media/uapi/v4l/vidioc-g-parm.html <- you also need to set readbuffers to 2+ I think
#asahi-dev · 2023-08-04 07:06
marcanso that would work perfectly fine with your use case
#asahi-dev · 2023-08-04 07:06
marcanfwiw I just checked ffplay and it requests 256 buffers, gets 32, pops 6, then starts alternately queuing and dequeuing, eventually catching up with more queueing (?)
#asahi-dev · 2023-08-04 07:05
marcanlarger batches = more efficient, more latency I assume
#asahi-dev · 2023-08-04 07:04
marcannot sure, might be worth experimenting with.
#asahi-dev · 2023-08-04 07:02
marcanand only submit a request to ISP once you have at least 2
#asahi-dev · 2023-08-04 07:02
marcanI think it's perfectly fine to block if there's only one buffer queued
#asahi-dev · 2023-08-04 07:02
marcanyeah, but it looks like exactly your use case in practice
#asahi-dev · 2023-08-04 07:01
marcanand that looks like exactly your use case
#asahi-dev · 2023-08-04 07:01
marcanlooks like you need to set that to 2
#asahi-dev · 2023-08-04 07:01
marcanhttps://www.kernel.org/doc/html/v4.9/media/kapi/v4l2-videobuf2.html <- see min_buffers_needed
#asahi-dev · 2023-08-04 06:59
marcanone thing you *could* do is unconditionally always allocate at least 1 more buffer than userspace requested, so that if userspace is trying to allocate some exact number of buffers it wants "in flight", there will always be one extra one in the queue (but userspace could still use too many in that case anyway)
#asahi-dev · 2023-08-04 06:59
marcanwithout any random blocks
#asahi-dev · 2023-08-04 06:59
marcannormally you expect buffers to be dequeued, processed, and enqueued again
#asahi-dev · 2023-08-04 06:58
marcanyeah, but is there any userspace out there that breaks like this?
#asahi-dev · 2023-08-04 06:57
marcanthere's a reason there were 2+ buffers to begin with
#asahi-dev · 2023-08-04 06:56
marcanif userspace refuses to give buffers back and waits for a new one, that's its problem
#asahi-dev · 2023-08-04 06:56
marcanyeah, that's fine
#asahi-dev · 2023-08-04 06:56
marcanif we find stuff that breaks under that model, we get it fixed :)
#asahi-dev · 2023-08-04 06:56
marcanthat's a userspace problem
#asahi-dev · 2023-08-04 06:55
marcanyeah, so then that blocks
#asahi-dev · 2023-08-04 06:55
marcanso the idea is you force the buffer count allocated to always be at least 2 (or 4), and then tell ISP it's okay to deliver 2 frames once 2 free buffers are available
#asahi-dev · 2023-08-04 06:54
marcanright
#asahi-dev · 2023-08-04 06:53
marcanI think I don't really understand what the problem is
#asahi-dev · 2023-08-04 06:52
marcanif you want to guarantee you can double-buffer, you could make the minimum 4
#asahi-dev · 2023-08-04 06:50
marcanisp delivers 2 frames, user pops one, user pops another one, isp delivers 2 frames, etc
#asahi-dev · 2023-08-04 06:50
marcanyes, but then you have 2 buffers available so it should work, no?
#asahi-dev · 2023-08-04 06:48
marcanso I think you can always just force min 2
#asahi-dev · 2023-08-04 06:48
marcan"A larger number is also possible when the driver requires more buffers to function correctly."
#asahi-dev · 2023-08-04 06:48
marcanwait it does say it's legal
#asahi-dev · 2023-08-04 06:47
marcanhttps://www.kernel.org/doc/html/v4.16/media/uapi/v4l/vidioc-reqbufs.html#vidioc-reqbufs is a bit ambiguous but doesn't clearly seem to state that allocating more buffers than requested is illegal
#asahi-dev · 2023-08-04 06:46
marcanright, but then you could deliver the fallback next time the user pops a buffer?
#asahi-dev · 2023-08-04 06:44
marcanwhat do you mean by wastes half the work?
#asahi-dev · 2023-08-04 06:44
marcanhmmm :/
#asahi-dev · 2023-08-04 06:44
marcanoof, yeah, no, that's a bad idea
#asahi-dev · 2023-08-04 06:43
marcanI don't know much about v4l2 but go ahead :)
#asahi-dev · 2023-08-04 06:32
marcanjannau: that smells like not a kernel thing?
#asahi-dev · 2023-08-04 01:18
marcanyou still want to pull device trees from the most recent installed kernel, since backwards-compatible changes do happen that are required to support new hardware, and you also often need m1n1 updates to go along with it (though we generally try to keep the m1n1 side also backwards compatible)
#asahi-dev · 2023-08-04 01:17
marcancy8aer: kernel dual-boot rollbacks are not (fully) supported when device tree compat breaks happen. this is expected and a limitation we accept. once device tree bindings are upstreamed, they become stable, and this doesn't happen any more.
#asahi-dev · 2023-08-04 01:16
marcantarzeau: glad to hear that! hope you hang around and feel free to ask any questions :) (I know this stuff is kind of complicated)
#asahi-dev · 2023-08-04 01:08
marcankettenis: sounds reasonable
#asahi-dev · 2023-08-04 01:08
marcanah yes, totally forgot about that, thanks!
#asahi-dev · 2023-08-02 07:14
marcanneeever mind
#asahi-dev · 2023-08-02 07:14
marcanyeah, I'm really confused here
#asahi-dev · 2023-08-02 07:08
marcanam I really confused here?

plus ›