aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-08-27 09:33:26 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 16:20:09 -0400
commit3e921f980fdd5b972efb7f368b2a847a01804184 (patch)
treeb554b1699b81976938358fed03649c9981cfbccd /drivers/char/agp
parent1784a5fb4f7a41b9a5ea066f7782418bfe170c04 (diff)
intel-gtt: generic intel_fake_agp_fetch_size
This uses the new mappable gtt size detection from the previous patch. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char/agp')
-rw-r--r--drivers/char/agp/intel-gtt.c77
1 files changed, 24 insertions, 53 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 932ede81e726..a997a202832e 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -815,6 +815,25 @@ static int intel_gtt_init(void)
815 return 0; 815 return 0;
816} 816}
817 817
818static int intel_fake_agp_fetch_size(void)
819{
820 unsigned int aper_size;
821 int i;
822 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
823
824 aper_size = (intel_private.base.gtt_mappable_entries << PAGE_SHIFT)
825 / MB(1);
826
827 for (i = 0; i < num_sizes; i++) {
828 if (aper_size == intel_i830_sizes[i].size) {
829 agp_bridge->current_size = intel_i830_sizes + i;
830 return aper_size;
831 }
832 }
833
834 return 0;
835}
836
818static void intel_i830_fini_flush(void) 837static void intel_i830_fini_flush(void)
819{ 838{
820 kunmap(intel_private.i8xx_page); 839 kunmap(intel_private.i8xx_page);
@@ -906,36 +925,6 @@ static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge)
906 return 0; 925 return 0;
907} 926}
908 927
909static int intel_i830_fetch_size(void)
910{
911 u16 gmch_ctrl;
912 struct aper_size_info_fixed *values;
913
914 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
915
916 if (intel_private.bridge_dev->device != PCI_DEVICE_ID_INTEL_82830_HB &&
917 intel_private.bridge_dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) {
918 /* 855GM/852GM/865G has 128MB aperture size */
919 agp_bridge->current_size = (void *) values;
920 agp_bridge->aperture_size_idx = 0;
921 return values[0].size;
922 }
923
924 pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl);
925
926 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
927 agp_bridge->current_size = (void *) values;
928 agp_bridge->aperture_size_idx = 0;
929 return values[0].size;
930 } else {
931 agp_bridge->current_size = (void *) (values + 1);
932 agp_bridge->aperture_size_idx = 1;
933 return values[1].size;
934 }
935
936 return 0;
937}
938
939static int intel_i830_configure(void) 928static int intel_i830_configure(void)
940{ 929{
941 struct aper_size_info_fixed *current_size; 930 struct aper_size_info_fixed *current_size;
@@ -1283,24 +1272,6 @@ static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start,
1283 * described in the spec of the MSAC registers is just changing of the 1272 * described in the spec of the MSAC registers is just changing of the
1284 * resource size. 1273 * resource size.
1285 */ 1274 */
1286static int intel_i9xx_fetch_size(void)
1287{
1288 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
1289 int aper_size; /* size in megabytes */
1290 int i;
1291
1292 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
1293
1294 for (i = 0; i < num_sizes; i++) {
1295 if (aper_size == intel_i830_sizes[i].size) {
1296 agp_bridge->current_size = intel_i830_sizes + i;
1297 return aper_size;
1298 }
1299 }
1300
1301 return 0;
1302}
1303
1304static int intel_i915_get_gtt_size(void) 1275static int intel_i915_get_gtt_size(void)
1305{ 1276{
1306 int size; 1277 int size;
@@ -1542,7 +1513,7 @@ static const struct agp_bridge_driver intel_830_driver = {
1542 .num_aperture_sizes = 4, 1513 .num_aperture_sizes = 4,
1543 .needs_scratch_page = true, 1514 .needs_scratch_page = true,
1544 .configure = intel_i830_configure, 1515 .configure = intel_i830_configure,
1545 .fetch_size = intel_i830_fetch_size, 1516 .fetch_size = intel_fake_agp_fetch_size,
1546 .cleanup = intel_i830_cleanup, 1517 .cleanup = intel_i830_cleanup,
1547 .mask_memory = intel_i810_mask_memory, 1518 .mask_memory = intel_i810_mask_memory,
1548 .masks = intel_i810_masks, 1519 .masks = intel_i810_masks,
@@ -1569,7 +1540,7 @@ static const struct agp_bridge_driver intel_915_driver = {
1569 .num_aperture_sizes = 4, 1540 .num_aperture_sizes = 4,
1570 .needs_scratch_page = true, 1541 .needs_scratch_page = true,
1571 .configure = intel_i9xx_configure, 1542 .configure = intel_i9xx_configure,
1572 .fetch_size = intel_i9xx_fetch_size, 1543 .fetch_size = intel_fake_agp_fetch_size,
1573 .cleanup = intel_i915_cleanup, 1544 .cleanup = intel_i915_cleanup,
1574 .mask_memory = intel_i810_mask_memory, 1545 .mask_memory = intel_i810_mask_memory,
1575 .masks = intel_i810_masks, 1546 .masks = intel_i810_masks,
@@ -1602,7 +1573,7 @@ static const struct agp_bridge_driver intel_i965_driver = {
1602 .num_aperture_sizes = 4, 1573 .num_aperture_sizes = 4,
1603 .needs_scratch_page = true, 1574 .needs_scratch_page = true,
1604 .configure = intel_i9xx_configure, 1575 .configure = intel_i9xx_configure,
1605 .fetch_size = intel_i9xx_fetch_size, 1576 .fetch_size = intel_fake_agp_fetch_size,
1606 .cleanup = intel_i915_cleanup, 1577 .cleanup = intel_i915_cleanup,
1607 .mask_memory = intel_i965_mask_memory, 1578 .mask_memory = intel_i965_mask_memory,
1608 .masks = intel_i810_masks, 1579 .masks = intel_i810_masks,
@@ -1635,7 +1606,7 @@ static const struct agp_bridge_driver intel_gen6_driver = {
1635 .num_aperture_sizes = 4, 1606 .num_aperture_sizes = 4,
1636 .needs_scratch_page = true, 1607 .needs_scratch_page = true,
1637 .configure = intel_i9xx_configure, 1608 .configure = intel_i9xx_configure,
1638 .fetch_size = intel_i9xx_fetch_size, 1609 .fetch_size = intel_fake_agp_fetch_size,
1639 .cleanup = intel_i915_cleanup, 1610 .cleanup = intel_i915_cleanup,
1640 .mask_memory = intel_gen6_mask_memory, 1611 .mask_memory = intel_gen6_mask_memory,
1641 .masks = intel_gen6_masks, 1612 .masks = intel_gen6_masks,
@@ -1668,7 +1639,7 @@ static const struct agp_bridge_driver intel_g33_driver = {
1668 .num_aperture_sizes = 4, 1639 .num_aperture_sizes = 4,
1669 .needs_scratch_page = true, 1640 .needs_scratch_page = true,
1670 .configure = intel_i9xx_configure, 1641 .configure = intel_i9xx_configure,
1671 .fetch_size = intel_i9xx_fetch_size, 1642 .fetch_size = intel_fake_agp_fetch_size,
1672 .cleanup = intel_i915_cleanup, 1643 .cleanup = intel_i915_cleanup,
1673 .mask_memory = intel_i965_mask_memory, 1644 .mask_memory = intel_i965_mask_memory,
1674 .masks = intel_i810_masks, 1645 .masks = intel_i810_masks,