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

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

# include tvout configuration file
. /etc/tvout

# 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`
  mp_set_option screenw "$RESX"
  mp_set_option screenh "$RESY"
else
  mp_set_option screenw 800
  mp_set_option screenh 600
fi

# set double to no for nvidia, sis and Kyro cards, VMWare, and some ATI cards
for i in 'Class 0300:.*10de:' 'Class 0300:.*1039:' 'Class 0300:.*104a:0010' 'Class 0300:.*15ad:' 'Class 0300:.*1002:4c59'; do
  if grep -q "$i" /proc/pci; then
    # except if we want to try nvidia vidix
    if [ "$i" = 'Class 0300:.*10de:' -a ! -f /etc/mplayer/no_nvidia_vidix ]; then
      mp_set_option vf "format=yuy2" concat
    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

# do not use VESA Direct Graphic Access on Intel i855, i865, i910 and
# i915 cards
if grep -q -e 'Class 0300:.*8086:3582' -e 'Class 0300:.*8086:2572' -e 'Class 0300:.*8086:2592' -e 'Class 0300:.*8086:2582' /proc/pci; then
  mp_set_option vo "vesa:nodga"
fi

# set the tvout aspect
mp_set_option monitoraspect "$TVOUT_ASPECT"

exit 0
