Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Intel AGPGART routines.
  3.  */
  4.  
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/mod_devicetable.h>
  8. #include <errno-base.h>
  9. #include <linux/pci.h>
  10.  
  11. //#include <linux/agp_backend.h>
  12. //#include <asm/smp.h>
  13. #include <linux/spinlock.h>
  14.  
  15. #include "agp.h"
  16. #include "intel-agp.h"
  17.  
  18. #include <syscall.h>
  19.  
  20. #define __devinit
  21. #define PCI_VENDOR_ID_INTEL             0x8086
  22.  
  23.  
  24. int intel_gmch_probe(struct pci_dev *pdev,
  25.                       struct agp_bridge_data *bridge);
  26.  
  27. int intel_agp_enabled;
  28.  
  29. struct agp_bridge_data *agp_alloc_bridge(void)
  30. {
  31.     struct agp_bridge_data *bridge;
  32.  
  33.     bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
  34.     if (!bridge)
  35.         return NULL;
  36.  
  37.     atomic_set(&bridge->agp_in_use, 0);
  38.     atomic_set(&bridge->current_memory_agp, 0);
  39.  
  40. //    if (list_empty(&agp_bridges))
  41. //      agp_bridge = bridge;
  42.  
  43.     return bridge;
  44. }
  45.  
  46. static int __devinit agp_intel_probe(struct pci_dev *pdev,
  47.                      const struct pci_device_id *ent)
  48. {
  49.     struct agp_bridge_data *bridge;
  50.     u8 cap_ptr = 0;
  51.     int err = -ENODEV;
  52.  
  53.     cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
  54.  
  55.     bridge = agp_alloc_bridge();
  56.     if (!bridge)
  57.         return -ENOMEM;
  58.  
  59.     bridge->capndx = cap_ptr;
  60.  
  61.     if (intel_gmch_probe(pdev, bridge))
  62.     {
  63. //        pci_set_drvdata(pdev, bridge);
  64. //        err = agp_add_bridge(bridge);
  65. //        if (!err)
  66.         intel_agp_enabled = 1;
  67.         err = 0;
  68.     }
  69.  
  70.     return err;
  71. }
  72.  
  73. static struct pci_device_id agp_intel_pci_table[] = {
  74. #define ID(x)                       \
  75.     {                       \
  76.     .class      = (PCI_CLASS_BRIDGE_HOST << 8), \
  77.     .class_mask = ~0,               \
  78.     .vendor     = PCI_VENDOR_ID_INTEL,      \
  79.     .device     = x,                \
  80.     .subvendor  = PCI_ANY_ID,           \
  81.     .subdevice  = PCI_ANY_ID,           \
  82.     }
  83.     ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB),
  84.     ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB),
  85.     ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_HB),
  86.     { }
  87. };
  88.  
  89. static pci_dev_t agp_device;
  90.  
  91. int init_agp(void)
  92. {
  93.     const struct pci_device_id  *ent;
  94.  
  95.     ent = find_pci_device(&agp_device, agp_intel_pci_table);
  96.  
  97.     if( unlikely(ent == NULL) )
  98.     {
  99.         dbgprintf("host controller not found\n");
  100.         return -ENODEV;
  101.     };
  102.  
  103.     return agp_intel_probe(&agp_device.pci_dev, ent);
  104. }
  105.  
  106.  
  107.