Motion-Project / motionplus

MotionPlus Home Page: https://motion-project.github.io/
GNU General Public License v3.0
293 stars 38 forks source link

Raspi Linux 6.6.31 breaking libcamera buffer allocator #155

Closed 2konrad closed 4 months ago

2konrad commented 4 months ago

Did you read the guide?

Yes

What is the base version number of MotionPlus being used?

0.1.x

What was the install method?

Built from source code

What is base architecture?

ARM-64bit

What is the distro being used?

Raspbian

Disto version number

bookworm, Linux 6.6.31-v8+ #1765 SMP PREEMPT Thu May 23 14:39:39 BST 2024 aarch64 GNU/Linux

Camera/Sound type(s) being used?

PI camera via libcam

Describe the issue/problem and steps to reproduce

Since Raspi Firmware Linux 4.6.6.31 the libcam buffer allocator returns a larger buffer as requested. Therefore the width needs to be adjusted, to use the whole provided buffer. E.g. from 1280 (as requested in motionplus config) to 1920 pixel (to use the whole provided buffer). The transmitted camera pic is still only 1280 wide, the remaining part of the picture on the right side (from 1280 to 1920) is just dark green (Y=0, U=0, V=0).

This behavioral started with Linux 6.6.31-v8+ #1765 SMP PREEMPT Thu May 23 14:39:39 BST 2024 aarch64 GNU/Linux installed with sudo rpi-update d5b3efe9b15c118a46888bff9eea6608affc1f36

it worked well with Linux 6.6.31-v8+ #1764 SMP PREEMPT Mon May 20 15:26:28 BST 2024 aarch64 GNU/Linux installed with sudo rpi-update 30a6adaded0241842a58fecb70ca4ed99bac0e35

the problematic commit in the raspberry kernel repository is commit

No idea what is causing this behavior. Clearly not a problem of motionplus. However i am keen to understand what is the pronlem.

Relevant MotionPlus log output (at log_level 8)

log excerpt
Jun 01 11:05:45 [NTC][VID][00:ml00:Cam1] cam_start_req: stream 0 image size adjusted from 1280 x 720 to 1920 x 720

libcam.so DEGUG is not not revealing any insight to buffer resize
2konrad commented 4 months ago

This issue is currently investigated between kernel and libcamera team.

you can solve it by setting the stream stride to 0 before stream config.

config->at(0).pixelFormat = PixelFormat::fromString("YUV420");
config->at(0).size.width = camctx->conf->width;
config->at(0).size.height = camctx->conf->height;
config->at(0).bufferCount = 1;
config->at(0).stride = 0;
2konrad commented 4 months ago

This is how rpicam-apps dealt with the issue.