################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC; see the file COPYING.  If not, write to
#  the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

ACTION!="add|change", GOTO="end_video"

# xorg_start only does something for subsystem "pci" and "video" class.
SUBSYSTEM=="pci", ATTR{class}=="0x030000", GOTO="subsystem_pci"
SUBSYSTEM=="drivers", GOTO="subsystem_drivers"
GOTO="end_video"

# check for drivers dont use the pci substem
LABEL="subsystem_drivers"
KERNEL=="fglrx_pci",        ENV{xorg_driver}="fglrx",        GOTO="start_xorg"
KERNEL=="fglrx_legacy_pci", ENV{xorg_driver}="fglrx-legacy", GOTO="start_xorg"
KERNEL=="nvidia",           ENV{xorg_driver}="nvidia",       GOTO="start_xorg"
KERNEL=="vboxvideo",        ENV{xorg_driver}="vboxvideo",    GOTO="start_xorg"
KERNEL=="vmwgfx",           ENV{xorg_driver}="vmware",       GOTO="start_xorg"
GOTO="end_video"

# check for drivers using the pci substem
LABEL="subsystem_pci"
DRIVER=="i915",      ENV{xorg_driver}="i915",                GOTO="start_xorg"
DRIVER=="nouveau",   ENV{xorg_driver}="nouveau",             GOTO="start_xorg"
#DRIVER=="nvidia",    ENV{xorg_driver}="nvidia",              GOTO="start_xorg"
DRIVER=="radeon",    ENV{xorg_driver}="radeon",              GOTO="start_xorg"
GOTO="end_video"

# start Xorg
LABEL="start_xorg"
ENV{xorg_driver}=="?*", RUN+="xorg_start"

LABEL="end_video"
