Matrox G400 Dual Head

From DirectFBWiki

成功不是将来才有的,而是从决定去做的那一刻起,持续累积而成。数据恢复 (http://www.kuaihuilai.com/)Google优化排名 (http://www.daydaytop.cn/)窃听器 (http://www.315live.cn/)手机窃听器 (http://www.315live.cn/)Google排名 (http://www.yenovo.cn/)数据恢复 (http://www.haoquchu.cn/)监听器 (http://www.yenovo.cn/2/)手机监听器 (http://www.yenovo.cn/1/)留学 (http://www.cheeredu.com.cn/)荷兰留学 (http://www.cheeredu.com.cn/sjbl/01/)英国留学 (http://www.cheeredu.com.cn/sjbl/02/)加拿大留学 (http://www.cheeredu.com.cn/sjbl/03/)澳大利亚留学 (http://www.cheeredu.com.cn/sjbl/04/)美国留学 (http://www.cheeredu.com.cn/sjbl/05/)法国留学 (http://www.cheeredu.com.cn/sjbl/06/)英国签证 (http://www.cheeredu.com.cn/sjbl/07/)加拿大签证 (http://www.cheeredu.com.cn/sjbl/08/)英国大学排名 (http://www.cheeredu.com.cn/sjbl/09/)专升本 (http://www.cheeredu.com.cn/sjbl/10/)留学中介 (http://www.cheeredu.com.cn/sjbl/11/)鹿特丹商学院 (http://www.cheeredu.com.cn/sjbl/12/)留学英国 (http://www.cheeredu.com.cn/sjbl/c6/)英国高中 (http://www.cheeredu.com.cn/sjbl/c7/)留学荷兰 (http://www.cheeredu.com.cn/sjbl/c8/)留学法国 (http://www.cheeredu.com.cn/sjbl/c9/)留学澳大利亚 (http://www.cheeredu.com.cn/sjbl/c10/)留学加拿大 (http://www.cheeredu.com.cn/sjbl/c11/)新加坡留学 (http://www.cheeredu.com.cn/sjbl/c12/)留学新加坡 (http://www.cheeredu.com.cn/sjbl/c13/)莫那什大学 (http://www.cheeredu.com.cn/sjbl/c14/)留学美国 (http://www.cheeredu.com.cn/sjbl/c15/)雅思考试 (http://www.cheeredu.com.cn/sjbl/c16/)出国留学 (http://www.cheeredu.com.cn/sjbl/c17/)托福考试 (http://www.cheeredu.com.cn/sjbl/c18/)阿姆斯特丹商学院 (http://www.cheeredu.com.cn/sjbl/c31/)出国 (http://www.cheeredu.com.cn/)英国硕士 (http://www.cheeredu.com.cn/sjbl/13/)美国签证 (http://www.cheeredu.com.cn/sjbl/14/)瑞典留学 (http://www.cheeredu.com.cn/sjbl/15/)留学瑞典 (http://www.cheeredu.com.cn/sjbl/16/)澳洲留学 (http://www.cheeredu.com.cn/sjbl/17/)留学澳洲 (http://www.cheeredu.com.cn/sjbl/18/)美国大学排名 (http://www.cheeredu.com.cn/sjbl/19/)印刷 (http://www.ruibaozhichun.com/)印刷厂 (http://www.ruibaozhichun.com/1.html)北京印刷 (http://www.ruibaozhichun.com/2.html)北京印刷厂 (http://www.ruibaozhichun.com/3.html)窃听器 (http://www.daydaytop.cn/html/2006-04/16.htm)手机窃听器 (http://www.daydaytop.cn/html/2006-04/17.htm)监听器 (http://www.315live.cn/post/12.html)手机监听器 (http://www.315live.cn/post/13.html)电话窃听器 (http://www.315live.cn/post/1.html)电话监听器 (http://www.315live.cn/post/2.html)无线窃听器 (http://www.315live.cn/post/3.html)无线监听器 (http://www.315live.cn/post/4.html)小灵通窃听器 (http://www.315live.cn/post/5.html)监听器 (http://www.daydaytop.cn/2006/02/)手机监听器 (http://www.daydaytop.cn/2006/01/)监听器 (http://www.daydaytop.com.cn/1/)手机监听器 (http://www.daydaytop.com.cn/2/)门禁系统 (http://www.kapaza.cn)保洁 (http://www.micropoints.cn)婚庆公司 (http://www.aijiablog.com.cn/)保洁公司into (http://www.micropoints.cn) /usr/local. I'm using a Linux From Scratch (http://www.linuxfromscratch.org) system, so I prefer /usr.

Script: build.sh
#! /bin/bash
red="\033[01;31m"
green="\033[01;32m"
yellow="\033[01;33m"
function message () {
  colour=${2:-${green}}
  normal="\033[00m"
  title_begin="\033]0;"
  title_end="\007"
  if [ "${TERM}" != "linux" ]; then
    echo -en "${title_begin}$1${title_end}"
  fi
  echo -e "${colour}* $1${normal}"
}
installdir=/build/Installed/ &&
installname=$(basename `pwd`)-cvs &&
pushd . &&
message "Running configure" &&
(
export CFLAGS="-O2 -march=pentium3 -pipe" &&
export CXXFLAGS=$CFLAGS &&
./autogen.sh \
  --prefix=/usr \
  --infodir=/usr/share/info \
  --mandir=/usr/share/man \
  --sysconfdir=/etc \
  --libexecdir=/usr/sbin \
  --enable-x11 \
  --enable-multi \
  --enable-sysfs \
  --enable-zlib \
  --enable-video4linux \
  --enable-video4linux2 \
  --enable-debug \
  --disable-osx \
  2>&1 | tee .configure.out && exit $PIPESTATUS
) &&
message "Running make" &&
make &&
message "Press enter when ready to install" ${yellow} &&
read ENTER &&
message "Finding files before installing ${installname}" &&
(find /bin /etc /lib /opt /sbin /usr /var -depth -print 2> /dev/null > .before-${installname}) &&
message "Running make install" &&
make install &&
message "Finding files after installing ${installname}" &&
(find /bin /etc /lib /opt /sbin /usr /var -depth -print 2> /dev/null > .after-${installname}) &&
echo "${installname} built on $(date +"%d.%b.%Y %H:%M")" >> ${installdir}${installname} &&
if ! diff .before-${installname} .after-${installname} | grep '>' >> ${installdir}${installname}; then
  echo "No additions" >> ${installdir}${installname}
fi &&
rm -f .before-${installname} .after-${installname} &&
message "Running make clean" &&
make clean &&
message "Running ldconfig" &&
/sbin/ldconfig &&
message "Changing permissions" &&
chown -R root:root . &&
popd &&
cat ${installdir}${installname} &&
message "DONE\007"

The script includes a very simple package management system that reports when new files have been added to the system.

You may need either a ~/.directfbrc or a /etc/directfbrc, e.g.:

~/.directfbrc
no-debug
#no-banner
#matrox-sgram
matrox-crtc2
matrox-tv-standard=pal
#matrox-tv-standard=ntsc
matrox-cable-type=composite
primary-layer=2
#log-file=/var/log/directfb.log

DirectFB info

The dfbinfo command generates the following output

# dfbinfo
Screen (00) FBDev Primary Screen            (primary screen)
  Caps: VSYNC POWER_MANAGEMENT

    Layer (00) FBDev Primary Layer
       Type:    GRAPHICS
       Caps:    SURFACE BRIGHTNESS CONTRAST SATURATION

    Layer (01) Matrox Backend Scaler
       Type:    GRAPHICS VIDEO STILL_PICTURE
       Caps:    SURFACE SCREEN_LOCATION DEINTERLACING DST_COLORKEY BRIGHTNESS CONTRAST SCREEN_POSITION SCREEN_SIZE

Screen (01) Matrox CRTC2 Screen
  Caps: VSYNC ENCODERS OUTPUTS

  Encoder (0)
    Type:           TV
    Caps:           TV_STANDARDS
    TV Standards:   PAL NTSC


  Output (0)
    Caps:       CONNECTORS SIGNAL_SEL CONNECTOR_SEL
    Connectors: SCART YC CVBS
    Signals:    YC CVBS RGB


    Layer (02) Matrox CRTC2 Layer             (primary layer)
       Type:    GRAPHICS VIDEO STILL_PICTURE
       Caps:    SURFACE FLICKER_FILTERING BRIGHTNESS CONTRAST HUE SATURATION FIELD_PARITY ALPHA_RAMP

    Layer (03) Matrox CRTC2 Sub-Picture
       Type:    GRAPHICS VIDEO STILL_PICTURE
       Caps:    SURFACE OPACITY ALPHACHANNEL


Input (01) IMPS/2 Mouse                    (primary mouse)
  Type: MOUSE
  Caps: AXES BUTTONS
  Max. Axis: 2
  Max. Button: 2

Input (03) LIRC Device                     (primary remote control)
  Type: REMOTE
  Caps: KEYS

Input (00) AT Translated Set 2 keyboard    (primary keyboard)
  Type: KEYBOARD
  Caps: KEYS

Input (10) ImPS/2 Generic Wheel Mouse
  Type: MOUSE
  Caps: AXES BUTTONS
  Max. Axis: 2
  Max. Button: 2

Input (12) Keyboard
  Type: KEYBOARD
  Caps: KEYS

You'll notice that the default primary layer has been attached to the secondary head.

TV-out

See Linux TV-out HowTo (http://www.realh.co.uk/linux_tv_howto/ar01s06.html) and DirectFB Matrox G400/G450/G550 TV-out HowTo (http://www.sci.fi/~syrjala/directfb/matrox-tv-out-howto) they provide the information that is needed.

Not mentioned in either HowTo is that you need to specify either the option crtc2 to MPlayer's dfbmga video output or set primary-layer=2 in the .directfbrc

MPlayer
mplayer MyVideoFile.avi -vo dfbmga:crtc2 -ao oss -fs (for oss sound)

or

mplayer MyVideoFile.avi -vo dfbmga:crtc2 -ao alsa:device=hw=0.0 -fs (for alsa sound)

If the video appears like this screen shot (http://www.linuxowl.com/images/screenshot-1.jpg), it seems to be caused by /dev/fb0 being set at 1024x768, changing the framebuffer to 1600x1200 before running MPlayer resolves this issue.

MPlayer
fbset "1600x1200 60Hz 16bit"
mplayer MyVideoFile.avi -vo dfbmga:crtc2 -ao oss -fs
fbset "1024x768 60Hz 16bit"

However, this patch from Ville Syrjälä when applied to the linux kernel fixed this problem:

# patch -Np1
diff -urN linux/drivers/video/matrox/matroxfb_DAC1064.c linux/drivers/video/matrox/matroxfb_DAC1064.c
--- linux/drivers/video/matrox/matroxfb_DAC1064.c	2005-10-29 12:57:05.000000000 +0300
+++ linux/drivers/video/matrox/matroxfb_DAC1064.c	2005-10-29 12:57:35.000000000 +0300
@@ -980,7 +980,7 @@
 				hw->MXoptionReg |= 0x40;	/* FIXME... */
 				pci_write_config_dword(ACCESS_FBINFO(pcidev), PCI_OPTION_REG, hw->MXoptionReg);
 			}
-			mga_setr(M_EXTVGA_INDEX, 0x06, 0x50);
+			mga_setr(M_EXTVGA_INDEX, 0x06, 0x00);
 		}
 	}
 	if (ACCESS_FBINFO(devflags.g450dac)) {

You will need to use valid modes in your /etc/fb.modes file.

Matroxset

matroxset (ftp://platan.vc.cvut.cz/pub/linux/matrox-latest/) is a command for controlling which frame buffer is sent to which head and the video signal from the head.

There is little documentation on matroxset except the build in help.

# matroxset -h
usage: matroxset [-f fbdev] [-o output] [-m] [value]

where -f fbdev  is fbdev device (default /dev/fb1)
      -o output is output number to investigate (0=primary, 1=secondary=default)
      -m        says that CRTC->output mapping should be changed/retrieved
      -p        print information about blanking
      -l        list controls
      -c        get/set control value
      -e        edit controls (interactively)
      value     if present, value is set, if missing, value is retrieved

For output mode, 128 means monitor, 1 = PAL TV, 2 = NTSC TV

The matroxset -o commands are global options, with one argument it gets the value for the primary (0) or secondary (1) heads. When two arguments are passed then it sets the values to PAL (1), NTSC (2) or monitor (128).

The matroxset -m commands apply to a specific frame buffer. The values are bit-mapped and a value of 0 turns off the outputs.

  • CRTC1
  • 1
  • CRTC2
  • 2
  • DVI/Pixel buffer
  • 4

First, you need the modules i2c_matroxfb and matroxfb_maven loaded. Load them with: modprobe i2c_matroxfb && modprobe matroxfb_maven

Run this script to print out the settings.

Script: fb-info
#! /bin/bash
# Begin fb-info

red="\033[01;31m"
green="\033[01;32m"
yellow="\033[01;33m"
function message () {
  colour=${2:-${green}}
  normal="\033[00m"
  title_begin="\033]0;"
  title_end="\007"
  if [ "${colour}" != "none" ]; then
    if [ "${TERM}" != "linux" ]; then
      echo -en "${title_begin}$1${title_end}"
    fi
    echo -e "${colour}$ $1${normal}"
  else
    echo -e "$ $1"
  fi
}
colour=${1:-${green}}

message "lsmod | grep '^i2c_matroxfb'" ${colour}
lsmod | grep '^i2c_matroxfb'
echo ""
message "lsmod | grep '^matroxfb_maven'" ${colour}
lsmod | grep '^matroxfb_maven'
echo ""
message "cat ~/.directfbrc" ${colour}
cat ~/.directfbrc
echo ""
message "grep 'mode ' /etc/fb.modes" ${colour}
grep 'mode ' /etc/fb.modes
echo ""
echo ""
message "fbset -i -fb /dev/fb0" ${colour}
fbset -i -fb /dev/fb0
echo ""
echo ""
message "fbset -i -fb /dev/fb1" ${colour}
fbset -i -fb /dev/fb1
echo ""
message "matroxset -f /dev/fb0 -l" ${colour}
matroxset -f /dev/fb0 -l
echo ""
message "matroxset -f /dev/fb1 -l" ${colour}
matroxset -f /dev/fb1 -l
echo ""
message "matroxset -f /dev/fb0 -m" ${colour}
matroxset -f /dev/fb0 -m
echo ""
message "matroxset -f /dev/fb1 -m" ${colour}
matroxset -f /dev/fb1 -m
echo ""
message "matroxset -o 0" ${colour}
matroxset -o 0
echo ""
message "matroxset -o 1" ${colour}
matroxset -o 1
echo ""
message "matroxset -o 2" ${colour}
matroxset -o 2

# End fb-info

The default frame buffer modes are printed out early on. Put the output from these commands in to your /etc/fb.modes. The /etc/fb.modes should include something like:

/etc/fb.modes
mode "1024x768-60"
    geometry 1024 768 1024 8192 16
    timings 15386 160 32 30 4 128 4
    accel true
endmode
mode "640x480-60"
    geometry 640 480 640 480 32
    timings 39721 48 16 33 10 96 2
endmode

This script moves the console from the primary head to the secondary head and sets the video mode to PAL.

Script: fb-console
#! /bin/bash
# Begin fb-console

modprobe matroxfb_maven

# reset everything
fbset -fb /dev/fb0 "1024x768-60"
fbset -fb /dev/fb1 "640x480-60"
matroxset -f /dev/fb0 -m 0
matroxset -f /dev/fb1 -m 0
matroxset -o 0 128
matroxset -o 1 128
matroxset -o 2 128
# set everything
matroxset -f /dev/fb0 -m 3          # sends fb0 output to both heads
#matroxset -f /dev/fb0 -m 2         # sends fb0 output to secondary head
matroxset -f /dev/fb1 -m 2          # turns off fb1 
#matroxset -f /dev/fb1 -m 1         # sends fb1 output to primary head
matroxset -o 0 128                  # set output 0 to pc
matroxset -o 1 1                    # set output 1 to pal (-o 1 2 is for NTSC)
matroxset -o 2 128                  # set output 2 to pc

# End fb-console

This script sets the framebuffers back to normal

Script: fb-normal
#! /bin/bash
# Begin fb-normal

matroxset -f /dev/fb0 -m 0
matroxset -f /dev/fb1 -m 0
matroxset -f /dev/fb0 -m 1
matroxset -f /dev/fb1 -m 0
matroxset -o 0 128
matroxset -o 1 128
matroxset -o 2 128
fbset -fb /dev/fb0 "1024x768-60"
fbset -fb /dev/fb1 "640x480-60"

rmmod matroxfb_maven

# End fb-normal