#!/bin/sh
#
# configure MPlayer's video settings
#
# runlevels: geexbox, debug, configure

echo "### Configuring MPlayer's video settings ###"

# set mplayer for X server
if [ -f /usr/bin/Xorg -a -f /var/use_xorg ]; then
  mp_set_option vo "xv,xvidix,x11"
  mp_set_option display ":0"
  mp_set_option vsync "no"
  mp_set_option fixed-vo "no"
  mp_set_option nomouseinput "yes"
  mp_set_option nograbpointer "yes"
  mp_set_option stop-xscreensaver "yes"
  exit 0
fi

# include tvout configuration file
#[ -f /etc/tvout ] && . /etc/tvout
. /settings

# set mplayer resolution when using offb
if [ -e /dev/fb0 ]; then
  RES=`/usr/sbin/fbset | sed -n 's/mode "\(.*\)-.*"/\1/p'`
  RESX=`echo $RES | cut -f1 -dx`
  RESY=`echo $RES | cut -f2 -dx`
else
  RESX=640
  RESY=480
fi
mp_set_option screenw "$RESX"
mp_set_option screenh "$RESY"
mp_set_option vf "scale=1:1:1" concat
mp_set_option vf "expand=$RESX:$RESY:-1:-1:1" concat

# set double to no for nvidia, sis and Kyro cards and VMWare
#for i in '0300: 10de:' '0300: 1039:' '0300: 104a:0010' '0300: 15ad:'; do
#  if grep -q "$i" /tmp/pci; then
#    if [ "$i" = '0300: 10de:' -a ! -f /etc/mplayer/no_unstable_vidix ]; then
#      # except if we want to try nvidia vidix
#      mp_set_option vf "format=yuy2" concat
#    elif [ "$i" = '0300: 1039:' -a ! -f /etc/mplayer/no_unstable_vidix ]; then
#      # or if we want to try sis vidix
#      echo > /dev/null # need a no-op here
#    else
#      mp_set_option vo "vesa"
#      mp_set_option double "no"
#      mp_set_option vf "expand=-1:-1:-1:-1:1" concat
#    fi
#  fi
#done

# Force -vo vesa for some ATI Mobility Radeons
#if grep -q '0300: 1002:4c59' /tmp/pci; then
#  mp_set_option vo "vesa"
#fi

# do not use VESA Direct Graphic Access on Intel cards
#grep -q -e '0300: 8086:' /tmp/pci && mp_set_option vo "vesa:nodga"

# set the tvout aspect
#mp_set_option monitoraspect "4:3"
[ -z "$MONITORASPECT" ] && MONITORASPECT=1
mp_set_option monitoraspect "$MONITORASPECT"

if [ "$VSYNC" = yes ]; then
  mp_set_option vsync yes
fi

exit 0
