DRM framebuffer capture tool

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DRM framebuffer capture tool

DRM framebuffer capture tool

On behalf of Gopise Yuan.

This is an update for the DRM framebuffer capture tool I used to share with the team. Some enhancement added.

Might be useful for debugging some display related issues.

 

Some special notes:

  1. Behavior of DRM subsystem is different between L4.x and L5.x.

For L4.x, you can capture the RGB buffer without any problem. But, there’s no API for YUV (multi-plane) buffer. To capture YUV, need to apply kernel_0001-drm-Add-getfb2-ioctl_L4.14.98.patch.

For L5.x, mapping/capturing the internal buffer is not allowed by default due to security reason. A simple change in “0001-drm-enable-mapping-of-internal-object-for-debugging_L5.x.patch can disable this guard.

  1. Capture raw data only. RGB and YUV (packed/planar, 420/422) supported.
  2. Support de-tile on “Amphion tile (VPU, NV12 only) and Super tile (Vivante GPU). Please use -t to enable this. Other tile might not be supported.
  3. This is a static linked binary. You can run it on any ARM64 based Linux/Android system in theory (prerequisites in item #1). If you need source code, come to me.

 

To get more details on how to use it, use “-? option:

DRM screen capture

DRM based screen capture program

Usage:

    ./drmfbcap [OP] [ARG]

[OP] OPeration (optional):

    -v Show version.

    -? Show help information.

    -i Show information about target DRM device only (no capture).

    -t Perform de-tile for tile format.

    -d DRM device to open. [ARG] should contain the path to the device node. Default: '/dev/dri/card0'

    -o Output folder. [ARG] should contain the path to the output folder. Default: '.'

    -p Specific plane # to capture. [ARG] should contain the plane number. If no '-p' specified, capture all planes

 

Example:

    ./drmfbcap

  Capture all planes on default DRM device.

    ./drmfbcap -d /dev/dri/controlD64

  Capture all planes on '/dev/dri/controlD64' device.

    ./drmfbcap -p 44 -t -o /sdcard

  Capture plane 44, do de-tile after capture and then output to /sdcard/.

 

Raw buffer capture will be done for each enabled/target plane and one file for each.

Captured file will be saved to './' if not specified.

--- By Gopise, 2022/08

 

Updated_2023_10_16:

continuous capture (repeat mode) support with this link:

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/DRM-screen-capture-tool/ta-p/1725363

Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-1523863%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EDRM%20framebuffer%20capture%20tool%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523863%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%3CP%3EOn%20behalf%20of%20Gopise%20Yuan.%3C%2FP%3E%0A%3CP%3EThis%20is%20an%20update%20for%20the%20DRM%20framebuffer%20capture%20tool%20I%20used%20to%20share%20with%20the%20team.%20Some%20enhancement%20added.%3C%2FP%3E%0A%3CP%3EMight%20be%20useful%20for%20debugging%20some%20display%20related%20issues.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSTRONG%3ESome%20special%20notes%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EBehavior%20of%20DRM%20subsystem%20is%20different%20between%20L4.x%20and%20L5.x.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20L4.x%2C%20you%20can%20capture%20the%20RGB%20buffer%20without%20any%20problem.%20But%2C%20there%E2%80%99%3CSPAN%3Es%20no%20API%20for%20YUV%20(multi-plane)%20buffer.%20To%20capture%20YUV%2C%20need%20to%20apply%20%3C%2FSPAN%3E%E2%80%9C%3CSPAN%3Ekernel_0001-drm-Add-getfb2-ioctl_L4.14.98.patch%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFor%20L5.x%2C%20mapping%2Fcapturing%20the%20internal%20buffer%20is%20not%20allowed%20by%20default%20due%20to%20security%20reason.%20A%20simple%20change%20in%20%E2%80%9C%3CSPAN%3E0001-drm-enable-mapping-of-internal-object-for-debugging_L5.x.patch%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E%20can%20disable%20this%20guard.%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3ECapture%20raw%20data%20only.%20RGB%20and%20YUV%20(packed%2Fplanar%2C%20420%2F422)%20supported.%3C%2FLI%3E%0A%3CLI%3ESupport%20de-tile%20on%20%E2%80%9C%3CSPAN%3EAmphion%20tile%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E%20(VPU%2C%20NV12%20only)%20and%20%3C%2FSPAN%3E%E2%80%9C%3CSPAN%3ESuper%20tile%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E%20(Vivante%20GPU).%20Please%20use%20%3C%2FSPAN%3E%E2%80%9C%3CSPAN%3E-t%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E%20to%20enable%20this.%20Other%20tile%20might%20not%20be%20supported.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3EThis%20is%20a%20static%20linked%20binary.%20You%20can%20run%20it%20on%20any%20ARM64%20based%20Linux%2FAndroid%20system%20in%20theory%20(prerequisites%20in%20item%20%231).%20If%20you%20need%20source%20code%2C%20come%20to%20me.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CBR%20%2F%3E%0A%3CP%3ETo%20get%20more%20details%20on%20how%20to%20use%20it%2C%20use%20%E2%80%9C%3CSPAN%3E-%3F%3C%2FSPAN%3E%E2%80%9D%3CSPAN%3E%20option%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EDRM%20screen%20capture%3C%2FP%3E%0A%3CP%3EDRM%20based%20screen%20capture%20program%3C%2FP%3E%0A%3CP%3EUsage%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.%2Fdrmfbcap%20%5BOP%5D%20%5BARG%5D%3C%2FP%3E%0A%3CP%3E%5BOP%5D%20OPeration%20(optional)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-v%20Show%20version.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-%3F%20Show%20help%20information.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-i%20Show%20information%20about%20target%20DRM%20device%20only%20(no%20capture).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-t%20Perform%20de-tile%20for%20tile%20format.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-d%20DRM%20device%20to%20open.%20%5BARG%5D%20should%20contain%20the%20path%20to%20the%20device%20node.%20Default%3A%20'%2Fdev%2Fdri%2Fcard0'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-o%20Output%20folder.%20%5BARG%5D%20should%20contain%20the%20path%20to%20the%20output%20folder.%20Default%3A%20'.'%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-p%20Specific%20plane%20%23%20to%20capture.%20%5BARG%5D%20should%20contain%20the%20plane%20number.%20If%20no%20'-p'%20specified%2C%20capture%20all%20planes%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EExample%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.%2Fdrmfbcap%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20Capture%20all%20planes%20on%20default%20DRM%20device.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.%2Fdrmfbcap%20-d%20%2Fdev%2Fdri%2FcontrolD64%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20Capture%20all%20planes%20on%20'%2Fdev%2Fdri%2FcontrolD64'%20device.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.%2Fdrmfbcap%20-p%2044%20-t%20-o%20%2Fsdcard%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20Capture%20plane%2044%2C%20do%20de-tile%20after%20capture%20and%20then%20output%20to%20%2Fsdcard%2F.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERaw%20buffer%20capture%20will%20be%20done%20for%20each%20enabled%2Ftarget%20plane%20and%20one%20file%20for%20each.%3C%2FP%3E%0A%3CP%3ECaptured%20file%20will%20be%20saved%20to%20'.%2F'%20if%20not%20specified.%3C%2FP%3E%0A%3CP%3E---%20By%20Gopise%2C%202022%2F08%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EUpdated_2023_10_16%3A%3C%2FP%3E%0A%3CP%3Econtinuous%20capture%20(repeat%20mode)%20support%20with%20this%20link%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FDRM-screen-capture-tool%2Fta-p%2F1725363%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FDRM-screen-capture-tool%2Fta-p%2F1725363%3C%2FA%3E%3C%2FP%3E%0A%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1523863%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EGraphics%20%26amp%3B%20Display%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
No ratings
Version history
Last update:
‎10-13-2023 07:18 AM
Updated by: