Subversion Repositories Kolibri OS

Rev

Rev 2326 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
  3.  */
  4. /*
  5.  *
  6.  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  7.  * All Rights Reserved.
  8.  *
  9.  * Permission is hereby granted, free of charge, to any person obtaining a
  10.  * copy of this software and associated documentation files (the
  11.  * "Software"), to deal in the Software without restriction, including
  12.  * without limitation the rights to use, copy, modify, merge, publish,
  13.  * distribute, sub license, and/or sell copies of the Software, and to
  14.  * permit persons to whom the Software is furnished to do so, subject to
  15.  * the following conditions:
  16.  *
  17.  * The above copyright notice and this permission notice (including the
  18.  * next paragraph) shall be included in all copies or substantial portions
  19.  * of the Software.
  20.  *
  21.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  24.  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  25.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  26.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  27.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28.  *
  29.  */
  30.  
  31. #include <drm/drmP.h>
  32. #include <drm/drm.h>
  33.  
  34. #include <linux/kernel.h>
  35. #include <linux/module.h>
  36. #include <linux/mod_devicetable.h>
  37. #include <errno-base.h>
  38. #include <linux/pci.h>
  39.  
  40.  
  41. enum {
  42.     RCS = 0x0,
  43.     VCS,
  44.     BCS,
  45.     I915_NUM_RINGS,
  46. };
  47.  
  48.  
  49. #include "i915_drv.h"
  50. #include <syscall.h>
  51.  
  52. #define INTEL_VGA_DEVICE(id, info) {        \
  53.     .class = PCI_CLASS_DISPLAY_VGA << 8,    \
  54.     .class_mask = 0xff0000,                 \
  55.     .vendor = 0x8086,                       \
  56.     .device = id,                           \
  57.     .subvendor = PCI_ANY_ID,                \
  58.     .subdevice = PCI_ANY_ID,                \
  59.     .driver_data = (unsigned long) info }
  60.  
  61. static const struct intel_device_info intel_sandybridge_d_info = {
  62.     .gen = 6,
  63.     .need_gfx_hws = 1,
  64.     .has_hotplug  = 1,
  65.     .has_bsd_ring = 1,
  66.     .has_blt_ring = 1,
  67. };
  68.  
  69. static const struct intel_device_info intel_sandybridge_m_info = {
  70.     .gen = 6,
  71.     .is_mobile    = 1,
  72.     .need_gfx_hws = 1,
  73.     .has_hotplug  = 1,
  74.     .has_fbc      = 1,
  75.     .has_bsd_ring = 1,
  76.     .has_blt_ring = 1,
  77. };
  78.  
  79.  
  80. static const struct pci_device_id pciidlist[] = {       /* aka */
  81.     INTEL_VGA_DEVICE(0x0102, &intel_sandybridge_d_info),
  82.     INTEL_VGA_DEVICE(0x0112, &intel_sandybridge_d_info),
  83.     INTEL_VGA_DEVICE(0x0122, &intel_sandybridge_d_info),
  84.     INTEL_VGA_DEVICE(0x0106, &intel_sandybridge_m_info),
  85.     INTEL_VGA_DEVICE(0x0116, &intel_sandybridge_m_info),
  86.     INTEL_VGA_DEVICE(0x0126, &intel_sandybridge_m_info),
  87.     INTEL_VGA_DEVICE(0x010A, &intel_sandybridge_d_info),
  88.     {0, 0, 0}
  89. };
  90.  
  91.  
  92. int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent);
  93.  
  94. int i915_init(void)
  95. {
  96.     static pci_dev_t device;
  97.     const struct pci_device_id  *ent;
  98.     int  err;
  99.  
  100.     if( init_agp() != 0)
  101.     {
  102.         DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
  103.         return 0;
  104.     };
  105.  
  106.     ent = find_pci_device(&device, pciidlist);
  107.  
  108.     if( unlikely(ent == NULL) )
  109.     {
  110.         dbgprintf("device not found\n");
  111.         return 0;
  112.     };
  113.  
  114.     dbgprintf("device %x:%x\n", device.pci_dev.vendor,
  115.                                 device.pci_dev.device);
  116.  
  117.     err = drm_get_dev(&device.pci_dev, ent);
  118.  
  119.     return err;
  120. }
  121.  
  122. int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent)
  123. {
  124.     static struct drm_device *dev;
  125.     int ret;
  126.  
  127.     ENTER();
  128.  
  129.     dev = kzalloc(sizeof(*dev), 0);
  130.     if (!dev)
  131.         return -ENOMEM;
  132.  
  133.  //   ret = pci_enable_device(pdev);
  134.  //   if (ret)
  135.  //       goto err_g1;
  136.  
  137.  //   pci_set_master(pdev);
  138.  
  139.  //   if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
  140.  //       printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
  141.  //       goto err_g2;
  142.  //   }
  143.  
  144.     dev->pdev = pdev;
  145.     dev->pci_device = pdev->device;
  146.     dev->pci_vendor = pdev->vendor;
  147.  
  148.     INIT_LIST_HEAD(&dev->filelist);
  149.     INIT_LIST_HEAD(&dev->ctxlist);
  150.     INIT_LIST_HEAD(&dev->vmalist);
  151.     INIT_LIST_HEAD(&dev->maplist);
  152.  
  153.     spin_lock_init(&dev->count_lock);
  154.     mutex_init(&dev->struct_mutex);
  155.     mutex_init(&dev->ctxlist_mutex);
  156.  
  157. //int i915_driver_load(struct drm_device *dev, unsigned long flags)
  158.  
  159. //    ret = radeon_driver_load_kms(dev, ent->driver_data );
  160. //    if (ret)
  161. //        goto err_g4;
  162.  
  163. //    if( radeon_modeset )
  164. //        init_display_kms(dev->dev_private, &usermode);
  165. //    else
  166. //        init_display(dev->dev_private, &usermode);
  167.  
  168.     LEAVE();
  169.  
  170.     return 0;
  171.  
  172. err_g4:
  173. //    drm_put_minor(&dev->primary);
  174. //err_g3:
  175. //    if (drm_core_check_feature(dev, DRIVER_MODESET))
  176. //        drm_put_minor(&dev->control);
  177. //err_g2:
  178. //    pci_disable_device(pdev);
  179. //err_g1:
  180.     free(dev);
  181.  
  182.     LEAVE();
  183.  
  184.     return ret;
  185. }
  186.  
  187.  
  188.