Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
  3.  * All Rights Reserved.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the
  7.  * "Software"), to deal in the Software without restriction, including
  8.  * without limitation the rights to use, copy, modify, merge, publish,
  9.  * distribute, sub license, and/or sell copies of the Software, and to
  10.  * permit persons to whom the Software is furnished to do so, subject to
  11.  * the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the
  14.  * next paragraph) shall be included in all copies or substantial portions
  15.  * of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20.  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  21.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  *
  25.  *
  26.  * Author: Alan Hourihane <alanh@tungstengraphics.com>
  27.  * Author: Jakob Bornecrantz <wallbraker@gmail.com>
  28.  *
  29.  */
  30.  
  31. #include "../../state_trackers/xorg/xorg_winsys.h"
  32.  
  33. static void intel_xorg_identify(int flags);
  34. static Bool intel_xorg_pci_probe(DriverPtr driver,
  35.                                  int entity_num,
  36.                                  struct pci_device *device,
  37.                                  intptr_t match_data);
  38.  
  39. static const struct pci_id_match intel_xorg_device_match[] = {
  40.     {0x8086, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
  41.     {0, 0, 0},
  42. };
  43.  
  44. static SymTabRec intel_xorg_chipsets[] = {
  45.     {PCI_MATCH_ANY, "Intel Graphics Device"},
  46.     {-1, NULL}
  47. };
  48.  
  49. static PciChipsets intel_xorg_pci_devices[] = {
  50.     {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
  51.     {-1, -1, NULL}
  52. };
  53.  
  54. static XF86ModuleVersionInfo intel_xorg_version = {
  55.     "i915",
  56.     MODULEVENDORSTRING,
  57.     MODINFOSTRING1,
  58.     MODINFOSTRING2,
  59.     XORG_VERSION_CURRENT,
  60.     0, 1, 0, /* major, minor, patch */
  61.     ABI_CLASS_VIDEODRV,
  62.     ABI_VIDEODRV_VERSION,
  63.     MOD_CLASS_VIDEODRV,
  64.     {0, 0, 0, 0}
  65. };
  66.  
  67. /*
  68.  * Xorg driver exported structures
  69.  */
  70.  
  71. _X_EXPORT DriverRec modesetting = {
  72.     1,
  73.     "modesetting",
  74.     intel_xorg_identify,
  75.     NULL,
  76.     xorg_tracker_available_options,
  77.     NULL,
  78.     0,
  79.     NULL,
  80.     intel_xorg_device_match,
  81.     intel_xorg_pci_probe
  82. };
  83.  
  84. static MODULESETUPPROTO(intel_xorg_setup);
  85.  
  86. _X_EXPORT XF86ModuleData modesettingModuleData = {
  87.     &intel_xorg_version,
  88.     intel_xorg_setup,
  89.     NULL
  90. };
  91.  
  92. /*
  93.  * Xorg driver functions
  94.  */
  95.  
  96. static pointer
  97. intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
  98. {
  99.     static Bool setupDone = 0;
  100.  
  101.     /* This module should be loaded only once, but check to be sure.
  102.      */
  103.     if (!setupDone) {
  104.         setupDone = 1;
  105.         xf86AddDriver(&modesetting, module, HaveDriverFuncs);
  106.  
  107.         /*
  108.          * The return value must be non-NULL on success even though there
  109.          * is no TearDownProc.
  110.          */
  111.         return (pointer) 1;
  112.     } else {
  113.         if (errmaj)
  114.             *errmaj = LDR_ONCEONLY;
  115.         return NULL;
  116.     }
  117. }
  118.  
  119. static void
  120. intel_xorg_identify(int flags)
  121. {
  122.     xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
  123.                       intel_xorg_chipsets);
  124. }
  125.  
  126. static Bool
  127. intel_xorg_pci_probe(DriverPtr driver,
  128.           int entity_num, struct pci_device *device, intptr_t match_data)
  129. {
  130.     ScrnInfoPtr scrn = NULL;
  131.     EntityInfoPtr entity;
  132.  
  133.     scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
  134.                                NULL, NULL, NULL, NULL, NULL);
  135.     if (scrn != NULL) {
  136.         scrn->driverVersion = 1;
  137.         scrn->driverName = "i915";
  138.         scrn->name = "modesetting";
  139.         scrn->Probe = NULL;
  140.  
  141.         entity = xf86GetEntityInfo(entity_num);
  142.  
  143.         /* Use all the functions from the xorg tracker */
  144.         xorg_tracker_set_functions(scrn);
  145.     }
  146.     return scrn != NULL;
  147. }
  148.