AM35xx/47xx Graphics Display Getting Started Guide

From Texas Instruments Wiki
Jump to: navigation, search

TIBanner.png

Introduction

TI SOCs like DRA7Xxx and AM57xx are enabled with 3D cores, capable of accelerating 3D operations with dedicated hardware. The dedicated hardware is based on SGX series of devices from Imagination Technologies. The graphics cores only accelerate graphics operations, and do not perform video decode operations. For video acceleration, refer to respective Technical Reference Manuals for the SOCs.

Since the 3D accelerator (SGX core) is outside the ARM core, the Graphics drivers run on ARM core, and contain OS specific driver code to memory map the SGX core and program the engine from the OS running on the ARM core.

This Graphics and Display Getting started Guide page will cover the following topics:

  • Software architecture of Graphics
  • Instructions on how to run graphics demos
  • Instructions on how to run DSS application


Software Architecture

The picture below shows the software architecture of Graphics in Processor SDK.

Graphics software stack.png

Graphics Demos Available via Matrix

The following 3D Graphics demos are available via Matrix on AM57xx EVM (X15 board with LCD). The table below provides a list of these demos, with a brief description.

Demo Name Details
ChameleonMan This demo shows a matrix skinned character in combination with bump mapping.
CoverFlow This is a demonstration of a coverflow style effect
ExampleUI This demo shows how to efficiently render sprites and interface elements.
Navigation This is a demonstration of how to implement rendering algorithms for Navigation software.
Kmscube This demo shows how to render and display multi-colored spinning cube

Note that some of the 3D Graphics demos are from Imagination's PowerVR SDK.

Running OMAP DRM DSS Examples

The drmclone, drmextended, and modetest examples demonstrates how to create a CRTC (i.e. FB) and display planes (overlays) on the CRTC. Additionally, drmtest demonstrates similar functionality as the previously mentioned demos, along with dynamic plane updates for 2 CRTCs.

Retrieve the omapdrm-tests source

 git clone https://github.com/tomba/omapdrm-tests.git
 cd omapdrm-tests

Run (or example planescale)

./planescale

Graphics Demos from Command Line

The graphics driver and userspace libraries and binaries are distributed along with the SDK.

Graphic demos can also run from command line. In order to do so, exit Weston by pressing Ctrl-Alt-Backspace from the keyboard which connects to the EVM. Then, if the LCD screen stays in "Please wait...", press Ctrl-Alt-F1 to go to the command line on LCD console. After that, the command line can be used from serial console, SSH console, or LCD console.

Please make sure the board is connected to atleast one display before running these demos.

Finding Connector ID

Note: Most of the applications used in the Demos would require the user to pass a connector id. A connector id is a number that is assigned to each of the display devices connected to the system. To get the list of the display devices connected and the corresponding connector id one can use the modetest application (shipped with the file system) as mentioned below:

  target #  modetest

Look for the display device for which the connector ID is required - such as HDMI, LCD etc.

Connectors:
id      encoder status          type    size (mm)       modes   encoders
4       3       connected       HDMI-A  480x270         20      3
  modes:
        name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  1920x1080 60 1920 2008 2052 2200 1080 1084 1089 1125 flags: phsync, pvsync; type: preferred, driver
...
16      15      connected       unknown 0x0             1       15
  modes:
        name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  800x480 60 800 1010 1040 1056 480 502 515 525 flags: nhsync, nvsync; type: preferred, driver

Usually, LCD is assigned 16 (800x480), and HDMI is assigned 4 (multiple resolutions).

Finding Plane ID

To find the Plane ID, run the modetest command:

  target #  modetest

Look for the section called Planes. (Sample truncated output of the Planes section is given below)

Planes:
id      crtc    fb      CRTC x,y        x,y     gamma size
19      0       0       0,0             0,0     0
 formats: RG16 RX12 XR12 RA12 AR12 XR15 AR15 RG24 RX24 XR24 RA24 AR24 NV12 YUYV UYVY
 props:
 ...
20      0       0       0,0             0,0     0
 formats: RG16 RX12 XR12 RA12 AR12 XR15 AR15 RG24 RX24 XR24 RA24 AR24 NV12 YUYV UYVY
 props:
 ...

kmscube

Run kmscube on default display (HDMI):

  target # kmscube

Run kmscube on secondary display (LCD):

  target # kmscube -c <connector-id>
  target # kmscube -c 16 #Usually, the connector id for LCD is 16.

Run kmscube on all connected displays (LCD & HDMI):

  target # kmscube -a

kmscube with video

This demo allows a video frame to be applied as a texture onto the surface of the kmscube. The user can invoke the demo by following the syntax below:

  target # viddec3test <path_to_the_file> --kmscube --connector <connector_number>


Run kmscube with video on default display (HDMI):

  target # viddec3test <path_to_the_file> --kmscube

Run kmscube with video on secondary display (LCD):

  target # viddec3test <path_to_the_file> --kmscube --connector 16 #Usually, the connector id for HDMI is 16.

Additionally, to change the field of view of the rotating cube, the user can specify the same on the command line like below:

  target # viddec3test <path_to_the_file> --kmscube --connector <connector_number> --fov <number>


Wayland/Weston

The supported Wayland/Weston version brings in the multiple display support in extended desktop mode and the ability to drag-and-drop windows from one display to the other.


To launch weston without using systemd init scripts, do the following:


On default display (HDMI):

  target # weston --tty=1 --connector=4

On secondary display (LCD):

  target # weston --tty=1 --connector=16

On all connected displays (LCD and HDMI):

  target # weston --tty=1

By default, the screensaver timeout is configured to 300 seconds.

The user can change the screensaver timeout using a command line option

 --idle-time=<number of seconds>

To disable the screen timeout and to configure weston configured to display on all connectors, use the option with "0" as the input:

 --idle-time=0


The filesystem comes with a preconfigured weston.ini file which will be located in /etc/weston.ini

Running weston clients

Weston client examples can run from the command line on serial port console or SSH console. After launching weston, the user should be able to use the keyboard and the mouse for various controls.

       # /usr/bin/weston-flower
       # /usr/bin/weston-clickdot
       # /usr/bin/weston-cliptest
       # /usr/bin/weston-dnd
       # /usr/bin/weston-editor
       # /usr/bin/weston-eventdemo
       # /usr/bin/weston-image /usr/share/weston/terminal.png
       # /usr/bin/weston-resizor
       # /usr/bin/weston-simple-egl
       # /usr/bin/weston-simple-shm
       # /usr/bin/weston-simple-touch
       # /usr/bin/weston-smoke
       # /usr/bin/weston-info
       # /usr/bin/weston-terminal


Running multimedia with Wayland sink

The GStreamer video sink for Wayland is the waylandsink. To use this video-sink for video playback:

  target # gst-launch-1.0 playbin uri=file://<path-to-file-name> video-sink=waylandsink


Exiting weston

Terminate all Weston clients before exiting Weston. If you have invoked Weston from the serial console, exit Weston by pressing Ctrl-C.

It is also possible to invoke Weston from the native console, exit Weston by using pressing Ctrl-Alt-Backspace.

Using IVI shell feature

The SDK also has support for configuring weston ivi-shell. The default shell that is configured in the SDK is the desktop-shell.

To change the shell to ivi-shell, the user will have to add the following lines into the /etc/weston.ini.

To switch back to the desktop-shell can be done by commenting these lines in the /etc/weston.ini (comments begin with a '#' at the start of line).

[core]
shell=ivi-shell.so

[ivi-shell]
ivi-module=ivi-controller.so
ivi-input-module=ivi-input-controller.so

After the above configuration is completed, we can restart weston by running the following commands

target# /etc/init.d/weston stop
target# /etc/init.d/weston start

NOTE: When weston starts with ivi-shell, the default background is black, this is different from the desktop-shell that brings up a window with background.

With ivi-shell configured for weston, wayland client applications use ivi-application protocol to be managed by a central HMI window management. The wayland-ivi-extension provides ivi-controller.so to manage properties of surfaces/layers/screens and it also provides the ivi-input-controller.so to manage the input focus on a surface.

Applications must support the ivi-application protocol to be managed by the HMI central controller with an unique numeric ID.

Some important references to wayland-ivi-extension can be found at the following links: https://at.projects.genivi.org/wiki/display/WIE/01.+Quick+start https://at.projects.genivi.org/wiki/display/PROJ/Wayland+IVI+Extension+Design


Running weston’s sample client applications with ivi-shell

All the sample client applications in the weston package like weston-simple-egl, weston-simple-shm, weston-flower etc also have support for ivi-shell. The SDK includes the application called layer-add-surfaces which is part of the wayland-ivi-extension. This application allows the user to invoke the various functionalities of the ivi-shell and control the applications.

The following is an example sequence of commands and the corresponding effect on the target.

After launching the weston with the ivi-shell, please run the below sequence of commands:

target# weston-simple-shm &

At this point nothing is displayed on the screen, some additional commands are required.

target# layer_add_surfaces 0 1000 2 &

This command creates a layer with ID 1000 and to add maximum 2 surfaces to this layer on the screen 0 (which is usually the LCD).
At this point, the user can see weston-simple-shm running on LCD. This also prints the numericID (surfaceID) to which client’s surface is mapped as shown below:

 CreateWithDimension: layer ID (1000), Width (1280), Height (800)
 SetVisibility      : layer ID (1000), ILM_TRUE
 layer: 1000 created
 surface                : 10369 created
 SetDestinationRectangle: surface ID (10369), Width (250), Height (250)
 SetSourceRectangle     : surface ID (10369), Width (250), Height (250)
 SetVisibility          : surface ID (10369), ILM_TRUE
 layerAddSurface        : surface ID (10369) is added to layer ID (1000)

Here 10369 is the number to which weston-simple-shm application’s surface is mapped.

User can launch one more client application which allows layer_add_surfaces to add second surface to the layer 1000 as shown below.

target# weston-flower &

User can control the properties of the above surfaces using LayerManagerControl as shown below to set the position, resize, opacity and visibility respectively.

target# LayerManagerControl set surface 10369 position 100 100
target# LayerManagerControl set surface 10369 destination region 150 150 300 300
target# LayerManagerControl set surface 10369 opacity 0.5
target# LayerManagerControl set surface 10369 visibility 1
target# LayerManagerControl  help  

The help option prints all possible control operations with the LayerManagerControl binary, please refer to the available options.

IMG PowerVR Demos

The Processor SDK Linux Automotive filesystem comes packaged with example OpenGLES applications. Both DRM and Wayland based applications are packaged as part of the filesystem.

The examples running on Wayland can be invoked using the below commands.

 target # /usr/bin/SGX/demos/Wayland/OGLES2ChameleonMan
 target # /usr/bin/SGX/demos/Wayland/OGLES2Navigation

The examples running on DRM/KMS can be invoked using the below commands.

 target # /usr/bin/SGX/demos/Raw/OGLES2ChameleonMan
 target # /usr/bin/SGX/demos/Raw/OGLES2Navigation

After you see the output on the display interface, hit q to terminate the application.


Using the PowerVR Tools

Please refer to http://community.imgtec.com/developers/powervr/graphics-sdk/ for additional details on the tools and detailed documentation.

The target file system includes tools such as PVRScope and PVRTrace recorder libraries from Imagination PowerVR SDK to profile and trace SGX activities. In addition, it also includes PVRPerfServerDeveloper tool.

PVRTune

PVRPerfServerDeveloper tool can be used along with the PVRTune running on the PC to gather data on the SGX loading and activity threads. You can invoke the tool with the below command:

target # /opt/img-powervr-sdk/PVRHub/PVRPerfServer/PVRPerfServerDeveloper

PVRTrace

The default filesystem contains helper scripts to obtain the PVRTrace of the graphics application. This trace can then be played back on the PC using the PVRTrace Utility.

To start tracing, use the below commands as reference:

target # cp /opt/img-powervr-sdk/PVRHub/Scripts/start_tracing.sh ~/.
target # ./start_tracing.sh <log-filename> <application-to-be-traced>

Example:

target # ./start_tracing.sh westonapp weston-simple-egl

The above command will do the following:

  1. Setup the required environment for the tracing
  2. Create a directory under the current working directory called pvrtrace
  3. Launch the application specified by the user
  4. Start tracing the PVR Interactions and record the same to the log-filename

To end the tracing, user can invoke the Ctrl-C and the trace file path will be displayed.

The trace file can then be transferred to a PC and we can visualize the application using the host side PVRTrace utility. Please refer to the link at the beginning of this section for more details.

Testing DSS WB pipeline

Memory to Memory (M2M)

  1. Identify the WB pipeline M2M device.

    # ls /sys/class/video4linux/
    Video0 video10 video11
    # cat  /sys/class/video4linux/video10/name
    omapwb-m2m
  2. Look at list of formats supported.

    # v4l2-ctl -d /dev/video10 --list-formats
    ioctl: VIDIOC_ENUM_FMT
            Index       : 0
            Type        : Video Capture Multiplanar
            Pixel Format: 'NV12'
            Name        : Y/CbCr 4:2:0
    
            Index       : 1
            Type        : Video Capture Multiplanar
            Pixel Format: 'YUYV'
            Name        : YUYV 4:2:2
    
            Index       : 2
            Type        : Video Capture Multiplanar
            Pixel Format: 'UYVY'
            Name        : UYVY 4:2:2
    
            Index       : 3
            Type        : Video Capture Multiplanar
            Pixel Format: 'XR24'
            Name        : 32-bit BGRX 8-8-8-8
  3. Use v4l2-ctl command to test the input output. Below command converts from NV12 to YUYV using WB pipeline in M2M mode.

    # v4l2-ctl -d /dev/video10 --set-fmt-video-out=width=1920,height=1080,pixelformat=NV12  \
    --stream-from=test/BigBuckBunny_1920_1080_24fps_100frames.nv12 \
    --set-fmt-video=width=1920,height=1080,pixelformat=YUYV \
    --stream-to=out/video_test_file.yuyv --stream-mmap=3 --stream-out-mmap=3 --stream-count=70 --stream-poll

Capture

  1. Identify the WB pipeline capture device.

    # ls /sys/class/video4linux/
    Video0 video10 video11
    # cat  /sys/class/video4linux/video11/name
    omapwb-cap
  2. Look at list of formats supported.

    # v4l2-ctl -d /dev/video11 --list-formats
    ioctl: VIDIOC_ENUM_FMT
            Index       : 0
            Type        : Video Capture Multiplanar
            Pixel Format: 'NV12'
            Name        : Y/CbCr 4:2:0
    
            Index       : 1
            Type        : Video Capture Multiplanar
            Pixel Format: 'YUYV'
            Name        : YUYV 4:2:2
    
            Index       : 2
            Type        : Video Capture Multiplanar
            Pixel Format: 'UYVY'
            Name        : UYVY 4:2:2
    
            Index       : 3
            Type        : Video Capture Multiplanar
            Pixel Format: 'XR24'
            Name        : 32-bit BGRX 8-8-8-8
    
  3. Use v4l2-ctl command to test the input output. Below command converts from NV12 to YUYV using WB pipeline in M2M mode.

    # v4l2-ctl -d /dev/video11 -i 0 --set-fmt-video=pixelformat=NV12 \
    --stream-to=/test/video_test_file.yuv --stream-mmap=6 --stream-count=10 --stream-poll
    Video input set to 0 (CRTC#0 - LCD1: ok)
    <<<<<<<<< 7.84 fps
    <
    # v4l2-ctl -d /dev/video11 -i 1 --set-fmt-video=pixelformat=NV12 --stream-to=/test/video
    _test_file.yuv --stream-mmap=6 --stream-count=10 --stream-poll
    Video input set to 1 (CRTC#1 - DIGIT/TV: ok)
    <<<<<<<<<< 8.65 fps

Running DSS application

DSS applications are omapdrm based. These will demonstrate the clone mode, extended mode, overlay window, z-order and alpha blending features. To demonstrate clone and extended mode, HDMI display must be connected to board. Application requires the supported mode information of connected displays and plane ids. One can get these information by running the modetest application in the filesystem.

  target #  modetest

Running drmclone application

This displays same test pattern on both LCD and HDMI (clone). Overlay window also displayed on LCD. To test clone mode, execute the following command:

  target #  drmclone -l <lcd_w>x<lcd_h> -p <plane_w>x<plane_h>:<x>+<y> -h <hdmi_w>x<hdmi_h>
e.g.: target # drmclone -l 1280x800 -p 320x240:0+0 -h 640x480

We can change position of overlay window by changing x+y values. eg. 240+120 will show @ center

Running drmextended application

This displays different test pattern on LCD and HDMI. Overlay window also displayed on LCD. To test extended mode, execute the following command:

  target # drmextended -l <lcd_w>x<lcd_h> -p <plane_w>x<plane_h>:<x>+<y> -h <hdmi_w>x<hdmi_h>
e.g.: target # drmextended -l 1280x800 -p 320x240:0+0 -h 640x480

Running drmzalpha application

Z-order:

It determines, which overlay window appears on top of the other.

Range: 0 to 3

lowest value for bottom

highest value for top

Alpha Blend:

It determines transparency level of image as a result of both global alpha & pre multiplied alpha value.

Global alpha range: 0 to 255

0 - fully transparent

127 - semi transparent

255 - fully opaque

Pre multipled alpha value: 0 or 1

0 - source is not premultiply with alpha

1 - source is premultiply with alpha

To test drmzalpha, execute the following command:

  target # drmzalpha -s <crtc_w>x<crtc_h> -w <plane1_id>:<z_val>:<glo_alpha>:<pre_mul_alpha> -w <plane2_id>:<z_val>:<glo_alpha>:<pre_mul_alpha>
e.g.: target # drmzalpha -s 1280x800 -w 19:1:255:1 -w 20:2:255:1