The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]




Версия для распечатки Пред. тема | След. тема
Новые ответы [ Отслеживать ]
Настройка xorg.conf на лету при загрузке, !*! den23513, 14-Май-07, 23:26  [смотреть все]
Доброе время суток!
Я сделал свой Linux-livecd но у меня глюки с автоматическим определением графических карточек.
Сначала я написал такой скриптик, который вызывается всегда при запуске startx или kdm демона, и фаил /etc/X11/xorg.conf не найден:

# Detect video card
HOME=/tmp Xorg -configure >/dev/null 2>&1
NEW_XORG_CONFIG_FILE="/etc/X11/xorg.conf"
    
# Create config directory if not exists
if ! [ -e /etc/X11 ]; then
   install -m755 -d /etc/X11
fi
    
# Get detected parameters from temporary file
VIDEO_DRIVER=`cat /tmp/xorg.conf.new | awk '/^Section "Device"/,/EndSection/ {print}' | tail -5 | head -1 | awk '{print $2}'`
HSYNC=`cat /tmp/xorg.conf.new | awk '/^Section "Monitor"/,/EndSection/ {print}' | grep 'HorizSync' | awk -F'#' '{print $2}'`
VREFRESH=`cat /tmp/xorg.conf.new | awk '/^Section "Monitor"/,/EndSection/ {print}' | grep 'VertRefresh' | awk -F'#' '{print $2}'`
    
# Set default parameters if video not detected
if [ "${HSYNC}" = "" ]; then
   HSYNC="HorizSync    31.5 - 81.1"
fi
if [ "${VREFRESH}" = "" ]; then
   VREFRESH="VertRefresh    56-75"
fi
    
# If detected vmware driver - change it to vesa (it work better)
if [ "${VIDEO_DRIVER}" = "\"vmware\"" ]; then
   VIDEO_DRIVER="\"vesa\""
fi
    
# Create config file
cat > ${NEW_XORG_CONFIG_FILE} << EOF
Section "ServerLayout"
    Identifier    "DeniX"
    Screen 0    "Screen0"    0 0
    InputDevice    "Mouse0"    "CorePointer"
    InputDevice    "Keyboard0"    "CoreKeyboard"
EndSection

Section "Files"
    RgbPath        "/usr/share/X11/rgb"
    ModulePath    "/usr/lib/X11/modules"
    FontPath    "/usr/lib/X11/fonts/misc/"
    FontPath    "/usr/lib/X11/fonts/TTF/"
    FontPath    "/usr/lib/X11/fonts/OTF"
    FontPath    "/usr/lib/X11/fonts/Type1/"
    FontPath    "/usr/lib/X11/fonts/CID/"
    FontPath    "/usr/lib/X11/fonts/100dpi/"
    FontPath    "/usr/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
    Load        "extmod"
    Load        "glx"
    Load        "dri"
    Load        "dbe"
    Load        "GLcore"
    #Load        "v4l"
    Load        "record"
    Load        "xtrap"
    Load        "type1"
    Load        "freetype"
EndSection

Section "InputDevice"
    Identifier    "Keyboard0"
    Driver        "kbd"
    Option        "XkbModel"    "pc105"
    Option        "XkbLayout"    "us,ru,il"
    Option        "XkbVariant"    ",phonetic,"
    Option        "XkbOptions"    "grp:lwin_toggle,grp_led:scroll"
    Option        "Autorepeat"    "250 30"
EndSection

Section "InputDevice"
    Identifier    "Mouse0"
    Driver        "mouse"
    Option        "Protocol" "IMPS/2"
    Option        "Device" "/dev/input/mice"
    Option            "ZAxisMapping" "4 5"
    Option        "Buttons"    "5"
EndSection

Section "Monitor"
    Identifier    "Monitor0"
    VendorName    "Monitor Vendor"
    ModelName    "Monitor Model"
    ${HSYNC}
    ${VREFRESH}
    Option        "DPMS"    "true"
    #DisplaySize    400    300
    #Option        "StandbyTime"    "10"
    #Option        "SuspendTime"    "20"
    #Option        "Offtime"    "30"
EndSection

Section "Device"
    Identifier    "Card0"
    Driver        ${VIDEO_DRIVER}
EndSection

Section "Extensions"
    Option        "Composite"    "0"
    Option        "RENDER"    "Enable"
EndSection

Section "Screen"
    Identifier    "Screen0"
    Device        "Card0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection "Display"
        Viewport   0 0
        Depth      1
        Modes      "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth      4
        Modes      "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth      8
        Modes      "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth      15
        Modes       "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth      16
        Modes       "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth      24
        Modes       "1024x768" "800x600" "640x480"
    EndSubSection
EndSection
EOF
# Remove temporary config file
rm -rf /tmp/xorg.conf.new

Работает на ура, НО не на всех железяках.
Например если в компе карточка с чипсетом nvidia, после выполнения скрипта мусор на экране и система виснет.
Если с чипсетом brookdale, черный экран, и нифига невидно. Система не виснет. если повторно попытаться запустить - все работает.
В wmware этот скрипт ваще отказывается выполняться грит мол screens not found или что-то в таком роде.
После кучи бессонных ночей я понял что ошибок в скрипте нет и если его выполнить отдельно (в ручную) перезапустить комп, то иксы поднимаются без проблем с конфигом, который мой скрипт создал.
Косяк в самом xogr который у меня версии 7.1 (собирал сам из исходников)
Что получается: если выполнить Xorg -configure а потом startx все пучком, а если создать такой скрипт:
#! /bin/sh
Xorg -configure
startx

то иногда работает, а иногда - черный экран (в лучшем случае, в худшем - виснет)

Вобщем я решил отказаться от вышепредставленного скрипта и решить эту проблему по другой схеме.
Не запускать Xorg -configure вообще
Создать шаблон под xorg.conf
С помощью lspci узнать данные о граф. адаптере
Используя эти данные sedом заменить драйвер в файле конфигурации.
И наконец вопрос:
Существует ли база данных с графическими адаптерами и модулями которую я мог бы использовать при данной схеме только для xorg сервера? (Ну что-то типа pci.ids из пакета pciutils)
Или может ваще существуют более простые решения данной задачи?
Заранее благодарен!

  • Настройка xorg.conf на лету при загрузке, !*! GloryS, 16:32 , 15-Май-07 (1)
    • Настройка xorg.conf на лету при загрузке, !*! den23513, 19:26 , 15-Май-07 (2)
      >А что мешает юзать файл /usr/X11R6/lib/X11/Cards
      >(у меня, правда, X - 6.9)


      А как его юзать? Там нет никаких данных совместимых с lspci базой...

      • Настройка xorg.conf на лету при загрузке, !*! den23513, 19:22 , 20-Май-07 (3)
        >>А что мешает юзать файл /usr/X11R6/lib/X11/Cards
        >>(у меня, правда, X - 6.9)
        >
        >
        >А как его юзать? Там нет никаких данных совместимых с lspci базой...
        >

        Я вот что имел ввиду...
        Такая база данных: (я сам ее начал составлять)

        файл: /usr/share/video_cards.db
        vmware:VMware Inc [VMware SVGA II] PCI Display Adapter
        flgrx:ATI Technologies Inc RV410 [Radeon X700 Pro (PCIE)]
        fglrx:ATI Technologies Inc RV370 [Sapphire X550 Silent]
        nv:nVidia Corporation NV17 [GeForce4 MX 440] (rev a3)
        nv:nVidia Corporation NV18 [GeForce4 MX 440 AGP 8x] (rev a2)
        i810:Intel Corporation 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device (rev 01)
        i810:Intel Corporation 82815 CGC [Chipset Graphics Controller] (rev 04)
        vesa:VIA Technologies, Inc. UniChrome Pro IGP (rev 01)
        ati:ATI Technologies Inc Rage XL (rev 27)

        и скрипт mkxconfig, который запускается при старте xorg и юзает эту БД:
        #! /bin/sh

        # If xorg already configured then exit
        if [ -f /etc/X11/xorg.conf ]; then
            exit 1
        fi

        NEW_XORG_CONFIG_FILE="/etc/X11/xorg.conf"
        VIDEO_CARDS_DB="/usr/share/video_cards.db"

        # Create config directory if not exists
        if ! [ -e /etc/X11 ]; then
            install -m755 -d /etc/X11
        fi

        HSYNC="HorizSync    31.5 - 81.1"
        VREFRESH="VertRefresh    56-75"
        ADAPTER=`lspci | grep "VGA compatible controller" | awk -F': ' '{print $2}'`
        SANITIZED_ADAPTER=$(echo ${ADAPTER} | sed -e 's/\[/\\[/' -e 's/\]/\\]/')
        VIDEO_DRIVER=`cat ${VIDEO_CARDS_DB} | grep "${SANITIZED_ADAPTER}" | awk -F: '{print $1}'`

        if [ "${VIDEO_DRIVER}" = "" ]; then
            VIDEO_DRIVER="vesa"
        fi
            
        # Create config file
        cat > ${NEW_XORG_CONFIG_FILE} << EOF
        Section "ServerLayout"
            Identifier    "DeniX"
            Screen 0    "Screen0"    0 0
            InputDevice    "Mouse0"    "CorePointer"
            InputDevice    "Keyboard0"    "CoreKeyboard"
        EndSection

        Section "Files"
            RgbPath        "/usr/share/X11/rgb"
            ModulePath    "/usr/lib/X11/modules"
            FontPath    "/usr/lib/X11/fonts/misc/"
            FontPath    "/usr/lib/X11/fonts/TTF/"
            FontPath    "/usr/lib/X11/fonts/OTF"
            FontPath    "/usr/lib/X11/fonts/Type1/"
            FontPath    "/usr/lib/X11/fonts/CID/"
            FontPath    "/usr/lib/X11/fonts/100dpi/"
            FontPath    "/usr/lib/X11/fonts/75dpi/"
        EndSection

        Section "Module"
            Load        "extmod"
            Load        "glx"
            Load        "dri"
            Load        "dbe"
            Load        "GLcore"
            Load        "v4l"
            Load        "record"
            Load        "xtrap"
            Load        "type1"
            Load        "freetype"
        EndSection

        Section "InputDevice"
            Identifier    "Keyboard0"
            Driver        "kbd"
            Option        "XkbModel"    "pc105"
            Option        "XkbLayout"    "us,ru,il"
            Option        "XkbVariant"    ",phonetic,"
            Option        "XkbOptions"    "grp:lwin_toggle,grp_led:scroll"
            Option        "Autorepeat"    "250 30"
        EndSection

        Section "InputDevice"
            Identifier    "Mouse0"
            Driver        "mouse"
            Option        "Protocol" "IMPS/2"
            Option        "Device" "/dev/input/mice"
            Option            "ZAxisMapping" "4 5"
            Option        "Buttons"    "5"
        EndSection

        Section "Monitor"
            Identifier    "Monitor0"
            VendorName    "Monitor Vendor"
            ModelName    "Monitor Model"
            ${HSYNC}
            ${VREFRESH}
            Option        "DPMS"    "true"
            #DisplaySize    400    300
            #Option        "StandbyTime"    "10"
            #Option        "SuspendTime"    "20"
            #Option        "Offtime"    "30"
        EndSection

        Section "Device"
            Identifier    "${ADAPTER}"
            Driver        "${VIDEO_DRIVER}"
        EndSection

        Section "Extensions"
            Option        "Composite"    "0"
            Option        "RENDER"    "Enable"
        EndSection

        Section "Screen"
            Identifier    "Screen0"
            Device        "${ADAPTER}"
            Monitor        "Monitor0"
            DefaultDepth    24
            SubSection "Display"
                Viewport   0 0
                Depth      1
                Modes      "1024x768" "800x600" "640x480"
            EndSubSection
            SubSection "Display"
                Viewport   0 0
                Depth      4
                Modes      "1024x768" "800x600" "640x480"
            EndSubSection
            SubSection "Display"
                Viewport   0 0
                Depth      8
                Modes      "1024x768" "800x600" "640x480"
            EndSubSection
            SubSection "Display"
                Viewport   0 0
                Depth      15
                Modes       "1024x768" "800x600" "640x480"
            EndSubSection
            SubSection "Display"
                Viewport   0 0
                Depth      16
                Modes       "1024x768" "800x600" "640x480"
            EndSubSection
            SubSection "Display"
                Viewport   0 0
                Depth      24
                Modes       "1024x768" "800x600" "640x480"
            EndSubSection
        EndSection
        EOF

        Только если мне самому придется такую БД составлять, мне это лет 10 займет...
        Может есть уже готовая где-то?
        Весь инет прогуглил.... ниче не нашел :-(




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру