Skip to content

MMAL hungs if camera preview port encoding is not OPAQUE with capture port enabled #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Terminus-IMRC opened this issue Apr 16, 2017 · 8 comments

Comments

@Terminus-IMRC
Copy link
Contributor

It seems that MMAL hungs the system if the encoding of camera preview port is not OPAQUE with capture port enabled.

Please try with this code: https://github.com/Terminus-IMRC/mmal-hungs-if-preview-encoding-is-not-opaque
This program creates vc.ril.camera, vc.ril.render and vc.null_sink components and connect them in this way:

camera[0] -- [0]render
camera[2] -- [0]null

So the preview port of the camera is displayed on screen and the still port of the camera is consumed by null.

If you leave these things, MMAL freezes the entire system.

  • ENCODING_PREVIEW to an encoding other than OPAQUE such as RGB24, RGBA and so on.
  • CAPTURE to 1 (MMAL_TRUE).

If you change ENCODING_PREVIEW to OPAQUE or CAPTURE to 0 (MMAL_FALSE), it will work.

I think I'm not wrong in usage of the API.
Thanks for reading.

@6by9
Copy link
Contributor

6by9 commented Apr 18, 2017

null_sink doesn't support OPAQUE as produced by camera->output[2]. null_sink never returns the buffer indicating that the data has been consumed, therefore the camera stalls waiting for the capture to complete. That really ought to be fixed up and rejected in a more sensible manner, but no data is exchanged between the ports until the first buffer is passed, and the encoding doesn't make it explicit.
Switch to I420 and that goes away.

ZERO_COPY should do nothing with a mmal_connection with MMAL_CONNECTION_FLAG_TUNNELLING - the buffers then all stay on the VPU, so there is no need to copy between ARM and VC memory.

The fact that you're managing to trigger a kernel panic on both my Pi 2 & 3 is more entertaining. I was having issues last week anyway, so that may be totally unrelated and just mean I need to take a clean image.

Terminus-IMRC added a commit to Terminus-IMRC/mmal-hungs-if-preview-encoding-is-not-opaque that referenced this issue Apr 18, 2017
@Terminus-IMRC
Copy link
Contributor Author

Terminus-IMRC commented Apr 18, 2017

Thank you for your response. I removed ZERO_COPY settings and changed ENCODING_CAPTURE to I420 on the repo. Then the firmware continues working and the kernel stops, as your pis do. I'm using CM1+{OV5647,IMX219} and the latest Hexxeh/rpi-firmware.

@6by9
Copy link
Contributor

6by9 commented Apr 18, 2017

OK, got it. Firmware bug.

If the preview port is set up for an RGB or YUYV format the ISP gets incorrectly programmed on the still capture and will start scribbling data at physical address 0x00000000 :-o
Selecting OPAQUE, I420, or NV12 should be safe at the moment. I'll sort a firmware fix for the other formats.

@Terminus-IMRC
Copy link
Contributor Author

Thank you!

@6by9
Copy link
Contributor

6by9 commented Apr 18, 2017

Patch sorted and pushed internally.
I don't know exactly when it'll get picked up, but should be fairly soon.

popcornmix added a commit to raspberrypi/firmware that referenced this issue Apr 19, 2017
kernel: vc4 HDMI audio, unlimited CMA memory, bugfix
See: raspberrypi/linux#1936

firmware: IL Camera: snapshot format setup incorrectly for RGB and YUYV
See: raspberrypi/userland#388

firmware: arm_dt/unicam: Disable VPU unicam irqs if enabled in DT
firmware: MMAL: Add support for the missing raw12, raw16, and 10to8dpcm formats
firmware: Camera/tuner: Allow client to override lens shading table

firmware: Revert Set up HDMI VCO same for VEC as for HDMI
See: #795
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Apr 19, 2017
kernel: vc4 HDMI audio, unlimited CMA memory, bugfix
See: raspberrypi/linux#1936

firmware: IL Camera: snapshot format setup incorrectly for RGB and YUYV
See: raspberrypi/userland#388

firmware: arm_dt/unicam: Disable VPU unicam irqs if enabled in DT
firmware: MMAL: Add support for the missing raw12, raw16, and 10to8dpcm formats
firmware: Camera/tuner: Allow client to override lens shading table

firmware: Revert Set up HDMI VCO same for VEC as for HDMI
See: raspberrypi/firmware#795
@6by9
Copy link
Contributor

6by9 commented Apr 20, 2017

Fix for ENCODING_PREVIEW being other than I420 or NV12 has been released.
Please use rpi-update (usual caution to be observed) and retest.

I haven't tested ZERO_COPY with both settings but it probably makes no difference in this case, just it is redundant.

I've just raised #390 to note the OPAQUE handling from camera->output[2] to null_sink, so if your use case is now working then please close this issue.

@Terminus-IMRC
Copy link
Contributor Author

It seems to be fixed. Thank you!

mkreisl added a commit to xbianonpi/xbian-package-firmware that referenced this issue May 7, 2017
- firmware: bootcode: Don't let total_mem exceed sdram size
  See: #782

- firmware: bootcode: Store boot partition number in PM_SPARE

- firmware: dtoverlay: Change node address when reg is set
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=178721

- firmware: bootcode: Avoid PM_SPARE bit 23
  See: raspberrypi/linux#1937

- firmware: rebuild with Avoid PM_SPARE bit 23
  See: raspberrypi/linux#1937

- firmware: IL Camera: snapshot format setup incorrectly for RGB and YUYV
  See: raspberrypi/userland#388

- firmware: arm_dt/unicam: Disable VPU unicam irqs if enabled in DT
- firmware: MMAL: Add support for the missing raw12, raw16, and 10to8dpcm formats
- firmware: Camera/tuner: Allow client to override lens shading table

- firmware: Revert Set up HDMI VCO same for VEC as for HDMI
  See: #795

- bootcode: Fix failover from SD to net booting
  See: #754
  See: #794

- firmware: ldconfig: Zero W is a [pi0]
  See: #799

- firmware: mailbox: Add property that fills in a VC_IMAGE_T header for given format and dimensions

- firmware: Make vchiq_test functional test more interesting
  See: raspberrypi/userland#392

- firmware: di_adv: Fix regression with non-qpu deinterlace and opaque images
  See: #796

- firmware: bootcode: Set max_usb_current pin for B+ and Pi2
  See: #661

- firmware: arm_loader: Restore /axi/vc_mem/reg DT property
  See: raspberrypi/userland#393

- firmware: bootcode: Revert Set max_usb_current pin for B+ and Pi2
  See: #661

- firmware: dispmanx: Fix dispmanx_element_change_dest_rect in 3d mode
  See: http://forum.kodi.tv/showthread.php?tid=298461&pid=2579578#pid2579578

- firmware: isp_resize: Remove spurious turbo_cookie_isp assert
  See: #806

- firmware: ISP ctrl: Round up end address to avoid asserts
- firmware: IL ISP: Accept user specified stride on output port
- firmware: IL Rawcam: Don't fail on unicam->close failure
- firmware: IL source: Allow user specified strides
  See: #806
@6by9
Copy link
Contributor

6by9 commented Jul 12, 2017

I'm finally getting a chance to look into this one in more detail.

vc.null_sink I hadn't even realised was built and shipped - I'd read it as vc.ril.null_sink.
vc.ril.null_sink now supports opaque buffers (input[0]=audio, input[1]=video, input[2]=video).

There's a second fix for the framework that means the piepeline won't lock up if connected to camera->output[2] with opaque buffers regardless of sink component, but they won't necessarily encode the correct thing - no real way around that as the two formats don't necessarily intersect in requirements.

popcornmix added a commit to raspberrypi/firmware that referenced this issue Jul 21, 2017
…llback

See: raspberrypi/userland#390

firmware: RIL null_sink: Support MMAL opaque input
See: raspberrypi/userland#388

firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
See: guysoft/FullPageOS#137

firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

firmware: cdi_camera: Allow GPIO control on FS and FE events

firmware: IL ISP: Add option to alter the shift in the output stage
firmware: IL ISP: Add option for adjusting the input CCM
firmware: vc_image: fix size calcs for YUV_UV_16
firmware: vc_image_helper: Add YUV 16 bit formats to second header
firmware: isp: Avoid setting vpitch in YUVUV16 cases
firmware: isp: Handle 16 bit yuv in ip_is_supported_format

firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
See: raspberrypi/userland#408
popcornmix added a commit to raspberrypi/firmware that referenced this issue Jul 21, 2017
…llback

See: raspberrypi/userland#390

firmware: RIL null_sink: Support MMAL opaque input
See: raspberrypi/userland#388

firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
See: guysoft/FullPageOS#137

firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

firmware: cdi_camera: Allow GPIO control on FS and FE events

firmware: IL ISP: Add option to alter the shift in the output stage
firmware: IL ISP: Add option for adjusting the input CCM
firmware: vc_image: fix size calcs for YUV_UV_16
firmware: vc_image_helper: Add YUV 16 bit formats to second header
firmware: isp: Avoid setting vpitch in YUVUV16 cases
firmware: isp: Handle 16 bit yuv in ip_is_supported_format

firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
See: raspberrypi/userland#408
popcornmix added a commit to raspberrypi/firmware that referenced this issue Jul 21, 2017
…llback

See: raspberrypi/userland#390

firmware: RIL null_sink: Support MMAL opaque input
See: raspberrypi/userland#388

firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
See: guysoft/FullPageOS#137

firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

firmware: cdi_camera: Allow GPIO control on FS and FE events

firmware: IL ISP: Add option to alter the shift in the output stage
firmware: IL ISP: Add option for adjusting the input CCM
firmware: vc_image: fix size calcs for YUV_UV_16
firmware: vc_image_helper: Add YUV 16 bit formats to second header
firmware: isp: Avoid setting vpitch in YUVUV16 cases
firmware: isp: Handle 16 bit yuv in ip_is_supported_format

firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
See: raspberrypi/userland#408
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Jul 21, 2017
…llback

See: raspberrypi/userland#390

firmware: RIL null_sink: Support MMAL opaque input
See: raspberrypi/userland#388

firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
See: guysoft/FullPageOS#137

firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

firmware: cdi_camera: Allow GPIO control on FS and FE events

firmware: IL ISP: Add option to alter the shift in the output stage
firmware: IL ISP: Add option for adjusting the input CCM
firmware: vc_image: fix size calcs for YUV_UV_16
firmware: vc_image_helper: Add YUV 16 bit formats to second header
firmware: isp: Avoid setting vpitch in YUVUV16 cases
firmware: isp: Handle 16 bit yuv in ip_is_supported_format

firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
See: raspberrypi/userland#408
Terminus-IMRC added a commit to Terminus-IMRC/librpigrafx2 that referenced this issue Aug 20, 2017
mkreisl added a commit to xbianonpi/xbian-package-firmware that referenced this issue Sep 13, 2017
- firmware: platform: Move trait initialisation out of #ifdef'd function

- firmware: usb: Change USB PHY settings to make device mode work correctly

- firmware: dtoverlay: Update fixups when a node is renamed
- firmware: dtoverlay app: Add the -D (dry-run) option
  See: raspberrypi/linux#2002

- firmware: dispserver: Adjust open/close refcount on application exit
  See: #778

- firmware: filex: Optimise directory search of the root directory

- firmware: Revert Change USB PHY settings to make device mode work correctly.
  See: #816

- firmware: Comments: Replace copyright symbol with (c)

- firmware: arm_display: Remove unused sdtv variables

- firmware: tvservice: Avoid referencing uninitialised state when unsuccessful
  See: raspberrypi/userland#397

- firmware: dtoverlay: Short-circuit empty parameter handling
  See: raspberrypi/linux#2028

- firmware: rtos: Protect against null timer callback
  See: http://forum.kodi.tv/showthread.php?tid=280408

- firmware: arm_dt: Add txp node to device tree parsing to mask off transposer interrupt

- firmware: venc: Correct the validation on custom mb/mbps/br settings
  See: #819

- firmware: venc: Correct the validation on custom mb/mbps/br settings
  See: #819

- firmware: vc_image: Remove structure definition duplication
- firmware: vc_image/mmal/il/isp: Add support for 16bit/component YUV420 and YUVUV

- firmware: vcdbg: Don't use dma when file provided

- firmware: rtos: Avoid sleeping delay when RTOS is not present

- firmware: bootcode: Remove reliance on scanf to reduce bootcode.bin size
- firmware: bootcode: Changes to force to full speed
- firmware: bootcode: Make sure bootcode drops out
- firmware: bootcode: Mass storage changes to power off/on USB block
- firmware: bootcode: Change USB 1.1 to have 64 byte endpoints
- firmware: bootcode: Set MSD serial number to be the Pi serial number

- firmware: imx219: Extend line length for long frame times

- firmware: 2ndstage: Improve i2c_gpio support
- firmware: i2c_gpio: Improve implementation and usage

- firmware: Camplus: Enable RAW12 support in the ISP input formatter

- firmware: scalerlib: Don't flip tiled format and swap R/B
- firmware: arm_display: Provide mechanism to request tiled format framebuffer
  See: #820

- firmware: platform: Set BT LPO frequency to 32768Hz
  See: #831

- firmware: arm_display: Fix mixup with xres/xres_virtual
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=187058

- firmware: video_render: Relax the alignment requirements for pitches
- firmware: vc_image: Use vpitch when determining size of YUV buffers

- firmware: Fix regression in uart clock frequency
  See: #833

- bootcode: usb: Dont overwrite configured parameters

- firmware: usb: Force MSD app to use CM3 pin conf

- firmware: IL ISP: Fix typo in logging
- firmware: IL ISP: Add black level and lens shading controls
- firmware: isp: Correct ISP Bayer stride calcs for supported formats
- firmware: Remove unused duplicate versions of vc_sm_defs.h
- firmware: IL camera: add get_parameter for OMX_IndexConfigCustomAwbGains
- firmware: IL resize: Support get_parameter OMX_IndexConfigCommonInputCro
- firmware: MMAL/RIL: Add MMAL_PARAMETER_RESIZE_PARAMS / OMX_IndexParamResize mapping
- firmware: ISP IL: Add lresize output
- firmware: MMAL/RIL: Add mapping for OMX_IndexConfigCommon[In|Out]putCrop
- firmware: MMAL/RIL: Correct handling of MMAL_PARAMETER_VIDEO_SOURCE_PATTERN
- firmware: IL ISP: Add H & V flip support
- firmware: IL ISP: Implement OMX_IndexConfigCommonInputCrop

- firmware: imx219: Refactor exposure calculations

- firmware: dmalib: Stop spinning on dma_pause if END is signalled
  See: #824

- firmware: MMAL: Avoid lockup with opaque stripes into opaque frame callback
  See: raspberrypi/userland#390

- firmware: RIL null_sink: Support MMAL opaque input
  See: raspberrypi/userland#388

- firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
  See: guysoft/FullPageOS#137

- firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

- firmware: cdi_camera: Allow GPIO control on FS and FE events

- firmware: IL ISP: Add option to alter the shift in the output stage
- firmware: IL ISP: Add option for adjusting the input CCM
- firmware: vc_image: fix size calcs for YUV_UV_16
- firmware: vc_image_helper: Add YUV 16 bit formats to second header
- firmware: isp: Avoid setting vpitch in YUVUV16 cases
- firmware: isp: Handle 16 bit yuv in ip_is_supported_format

- firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
  See: raspberrypi/userland#408

- bootcode: Default to using total_mem=1024

- firmware: logging: Avoid wraparound issue with total_mem=1024

- firmware: armstubs: Add wfe to ARMv7/ARMv8-32 stubs
  See: raspberrypi/linux#1989

- firmware: arm_loader: Use ethernet0 as fallback for placing DT MAC address
  See: #846

- firmware: dt-blob: Remove Zero W static I2C0 mapping on 28 & 29
  See: raspberrypi/linux#2130

- firmware: Revert arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver

- firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver 2
  See: #849
  See: #853

- firmware: vc_image headers: Tidy up duplication
- firmware: video_splitter: Only copy eColorFormat if not already set
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=189830

- firmware: vcsm: Add new clean/invalidate command for 2D blocks
- firmware: gpuserver: Switch to using custom queue
- firmware: gpuserver: Add priority to queue

- firmware: MMAL/IL I420 and YUVUV 10bpp formats, + VCSM DMABUF import

- firmware: CEC: Fix crash when remote button release is received without a pressed
  See: https://forum.kodi.tv/showthread.php?tid=280408

- firmware: arm_loader display: Correct variable scope by renaming
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=84889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants