ECE497 Lab12 The Display SubSystem (DSS)

From eLinux.org
(Redirected from ECE497 Lab12 DSS)
Jump to: navigation, search


Use EBC Exercise 10 The Display SubSystem (DSS) Writing to the Framebuffer instead.

This page explains, with examples, how the Display Subsystem (DSS) on the OMAP3530 on the BeagleBoard works. It's based on the materials used in TI's DaVinci System Integration using Linux Workshop. The workshop is based on the DVEVM. I've converted those materials to the BeagleBoard. What I'm called Lab 11 is Lab 7 in these materials.

The Student Materials (page 7-1) for the workshop are very complete; however the workshop is based on the DVEVM and not the BeagleBoard. Here I'll walk you through Lab 11/7 on the Beagle.

VideoThru.tar.gz are my files for Lab 11/7. You can get them off the class dfs site. You may not need to download this since the SPEd image we have been using already had the files loaded on it. Look in the VideoThru directory. You can do all your compilation on the Beagle, however I suggest you make frequency backups. Do this by installing git on your Beagle and setting up a repository on github.

Lab 11/7 has four parts.

  1. OSD Setup (Take a bmp file, convert it to r16 format and display it on the GFX frame buffer (/dev/fb0).)
  2. Video Record (Read video from a web cam and store it in a file.)
  3. Video Playback (Read the file from above and display it on one of the video frame buffers (/dev/fb1).)
  4. Video Loopthru (Combine the previous two labs to read the live video and display it.)

Here is a nice set of slides that explain the OMAP3530 DSS. I found a reference to it here. It's worth going through the slides before doing these labs.

Lab 12/7a OSD Setup

This lab is a straight forward inspection lab that starts on page 200. Look at video_thread.c and video_osd.c and see how they work. The lab has you create a 720 by 60 bmp file that is converted to RGB565 format. Instead, create a 640 x 480 file that has a white background. In Lab 12/7c we will use the OMAP DSS to superimpose the video on this image. I've already changed some #defines to work with the 640 by 480 image.

I see that my display is 1280x720. Check your display size with:

$ cat /sys/devices/platform/omapdss/overlay0/output_size

Scale your overlay image to match the size of your display.

The Beagle code differs from the original workshop code in the the OMAP3530 doesn't have an attribute frame. All that code has been removed.

Lab 11/7b Video Record

This is also a straight forward inspection lab. It starts on page 206. I'm using at PS3 EYE eb cam. /dev/video0 will appear when you plug the EYE into the USB of the Beagle. Look at video_thread.c and video_input.c and see how they work. I've set them up to capture a 640 by 480 image.

Ditto on the attribute frame. Capture some video here. You will use it in the next lab. The video is stored in /tmp. I suggest you move it to your working directory, otherwise it will disappear when you reboot.

Lab 11/7c Video Playback

Here we really depart from the workshop code. The lab starts on page 209. video_osd.c writes the the image your created in lab 7a on frame buffer 0 (/dev/fb0). This is called the graphics buffer (FBVID_GFX). video_output.c reads the video from lab 7b and writes it to frame buffer 1 (/dev/fb1), which is one of the two video buffers.

You Beagle needs to be told you are using multiple video buffers. If you are using the SPEd image you booted with:

$ cat /proc/cmdline 
console=ttyS2,115200n8 mem=80M@0x80000000 mem=384M@0x88000000 mpurate=1000 buddy=none camera=lbcm3m1 vram=16M omapfb.vram=0:8M,1:4M,2:4M omapfb.mode=dvi:hd720 omapdss.def_disp=dvi root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait

vram=16M says you want 16M for the video ram and omapfb.vram=0:8M,1:4M,2:4M says how much each frame buffer gets.

If you are running a different image or have changed your u-boot, but sure these are set.

DSS2 Details

Before doing the video playback lab it's important to have a good understanding of how the Display SubSystem works and how it's accessed via the DSS2 drivers. Here are some DSS things to explore on your BeagleBoard. Details can be found at .../Documentation/arm/OMAP/DSS.

The documentation says this is the default setup on OMAP3. All planes go to LCD. DVI and TV-out are not in use. The columns from left to right are:

  • framebuffers,
  • overlays,
  • overlay managers,
  • displays.
fb0 --- gfx-\            DVI
fb1 --- vid1 --+- lcd ---- lcd
fb2 --- vid2 -/   tv ----- tv

Framebuffers are handled by omapfb, and the rest by the DSS.

Let's see if this is true for the BeagleBoard running Angstrom. The following shows you how to discover the current connections. Once you learn that you can draw the diagram for your Beagle. Could you write a script that would automatically generate the diagram above for current setup?

framebuffers

The framebuffers are in /sys/class/graphics/. Explore them:

# cd /sys/class/graphics/; ls -F
# cd fb0; ls -F

What do you see? Explore them.

# cat *

Can you guess what the different value mean?

overlays, managers and displays

The overlays, managers and displays are in /sys/devices/platform/omapdss/. Explore them:

# cd /sys/devices/platform/omapdss/ ; ls -F

What do you see? Explore them.

# cd overlay0; ls -F
# cat position
# cat manager
# cat output_size

The contents of manager tells which manager overlay0 is attached to. Explore all the displays, managers, etc. and draw a diagram like:

fb0 --- gfx-\            DVI
fb1 --- vid1 --+- lcd ---- lcd
fb2 --- vid2 -/   tv ----- tv

for your Beagle. Is it the same as above?

mplayer and framebuffers

Discover how mplayer uses DSS.

  • Start BigBuckBunny
# cd /sys/devices/platform/omapdss; ls -F
# cd overlay0
# cat enabled

Is overlay0 enabled? Repeat for overlays 1 and 2 Which are being used? cd to it.

# cd /sys/devices/platform/omapdss/overlay?
# cat position
# echo 100,100 >  position
# cat output_size
# echo 320,400 > output_size

What happens? Try dragging the display. What happens?

Try enabling the unused overlay and getting the movie to display in two places on your screen. Make one scaled to a different size. Put your commands in a shell script.

Try transparency

# echo 127 > global_alpha
# cd ../manager0
# echo 1 > alpha_blending_enabled
# echo 1 > trans_key_enabled
# echo 65535 > trans_key_value

What happens? What commands turn transparency off?

showOSD

After working through the above examples you should be able to understand the following script. The following is from the file ShowOSD in the VideoThru directory. It sets up the DSS so the graphics buffer is in front of the video buffer. The graphics are at 50% transparency and white is transparent. This will let the video show through the graphics.

Study the script. Notice the overlays are 'disabled' before the values are changed. Some values can't be changed unless this is done.

Write a similar script that restores the display back to what it was.


#!/bin/bash
# /etc/init.d/gpe-dm stop
# Here are the bootargs that are needed
# set mmcargs 'setenv bootargs console=${console} vram=${vram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=${mmcroot} rootfstype=${mmcrootfstype} ${optargs}'
# setenv optargs omapfb.vram=0:10M,1:10M vram=20M 
# omapfb.test=y
# saveenv

video_size=640,480

ovl0=/sys/devices/platform/omapdss/overlay0
ovl1=/sys/devices/platform/omapdss/overlay1
ovl2=/sys/devices/platform/omapdss/overlay2

mgr0=/sys/devices/platform/omapdss/manager0
mgr1=/sys/devices/platform/omapdss/manager1

lcd=/sys/devices/platform/omapdss/display0
tv=/sys/devices/platform/omapdss/display1

fb0=/sys/class/graphics/fb0
fb1=/sys/class/graphics/fb1
fb2=/sys/class/graphics/fb2

# Disable the overlays
echo "0" > $ovl0/enabled
echo "0" > $ovl1/enabled

# Connect fb0 to ovl0
echo "0" > $fb0/overlays
echo "1" > $fb1/overlays
echo $video_size > $fb1/virtual_size

# Point both overlays to the lcd manager
echo "lcd" > $ovl0/manager
echo "lcd" > $ovl1/manager

# echo $ovl0/output_size > $ovl1/output_size
echo 0,0 > $ovl0/position
echo $video_size > $ovl1/output_size
echo 100,100 > $ovl1/position

echo 128 > $ovl0/global_alpha
echo   1 > $mgr0/alpha_blending_enabled

# Turn on transparency, make white (65535) transparent
echo   1 > $mgr0/trans_key_enabled
echo 65535 > $mgr0/trans_key_value
# echo video-source > $mgr0/trans_key_type
echo gfx-destination > $mgr0/trans_key_type

# Set the video mode to YUV (not need since the c-code does it)
# http://groups.google.com/group/beagleboard/browse_thread/thread/9bc347f5f0853aa1/907f1ac3554b1a19?lnk=gst&q=fbset#907f1ac3554b1a19
# /usr/sbin/fbset -fb /dev/fb1 -nonstd 8

echo "1" > $ovl0/enabled
echo "1" > $ovl1/enabled

You should now have enough background to do Lab07c.

Lab 11/7d Video Loopthru

The Video Loopthru is the most interesting part of this lab. Unfortunately I left a working solution on the SPEd image.

Ignore my solution and see if you can create your own solution based on the instructions on pages 213-218.

The DM 3730 has two video framebuffers. For an extra challenge, write some code that will take the input from 2 web cams and display one in each buffer.