-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 329599 b: refs/heads/master c: aa4cc5d h: refs/heads/master i: 329597: 81bd348 329595: 4ecdb18 329591: 3f9d310 329583: 2982122 329567: 7765a22 329535: d4a1da2 329471: c541d92 v: v3
- Loading branch information
Ben Skeggs
committed
Oct 3, 2012
1 parent
7e3dce0
commit 86f2f8f
Showing
8 changed files
with
174 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 02a841d434513c7b3620250271c372fabce56de5 | ||
refs/heads/master: aa4cc5d274c09909fe32861825c2377d0ccb3bfd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#include <linux/module.h> | ||
|
||
#include "drmP.h" | ||
#include "drm.h" | ||
|
||
#include "nouveau_drv.h" | ||
#include "nouveau_agp.h" | ||
|
||
#if __OS_HAS_AGP | ||
MODULE_PARM_DESC(agpmode, "AGP mode (0 to disable AGP)"); | ||
static int nouveau_agpmode = -1; | ||
module_param_named(agpmode, nouveau_agpmode, int, 0400); | ||
|
||
static unsigned long | ||
get_agp_mode(struct drm_device *dev, unsigned long mode) | ||
{ | ||
struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
|
||
/* | ||
* FW seems to be broken on nv18, it makes the card lock up | ||
* randomly. | ||
*/ | ||
if (dev_priv->chipset == 0x18) | ||
mode &= ~PCI_AGP_COMMAND_FW; | ||
|
||
/* | ||
* AGP mode set in the command line. | ||
*/ | ||
if (nouveau_agpmode > 0) { | ||
bool agpv3 = mode & 0x8; | ||
int rate = agpv3 ? nouveau_agpmode / 4 : nouveau_agpmode; | ||
|
||
mode = (mode & ~0x7) | (rate & 0x7); | ||
} | ||
|
||
return mode; | ||
} | ||
|
||
static bool | ||
nouveau_agp_enabled(struct drm_device *dev) | ||
{ | ||
struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
|
||
if (!drm_pci_device_is_agp(dev) || !dev->agp) | ||
return false; | ||
|
||
switch (dev_priv->gart_info.type) { | ||
case NOUVEAU_GART_NONE: | ||
if (!nouveau_agpmode) | ||
return false; | ||
break; | ||
case NOUVEAU_GART_AGP: | ||
break; | ||
default: | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
#endif | ||
|
||
void | ||
nouveau_agp_reset(struct drm_device *dev) | ||
{ | ||
#if __OS_HAS_AGP | ||
u32 save[2]; | ||
int ret; | ||
|
||
if (!nouveau_agp_enabled(dev)) | ||
return; | ||
|
||
/* First of all, disable fast writes, otherwise if it's | ||
* already enabled in the AGP bridge and we disable the card's | ||
* AGP controller we might be locking ourselves out of it. */ | ||
if ((nv_rd32(dev, NV04_PBUS_PCI_NV_19) | | ||
dev->agp->mode) & PCI_AGP_COMMAND_FW) { | ||
struct drm_agp_info info; | ||
struct drm_agp_mode mode; | ||
|
||
ret = drm_agp_info(dev, &info); | ||
if (ret) | ||
return; | ||
|
||
mode.mode = get_agp_mode(dev, info.mode); | ||
mode.mode &= ~PCI_AGP_COMMAND_FW; | ||
|
||
ret = drm_agp_enable(dev, mode); | ||
if (ret) | ||
return; | ||
} | ||
|
||
|
||
/* clear busmaster bit, and disable AGP */ | ||
save[0] = nv_mask(dev, NV04_PBUS_PCI_NV_1, 0x00000004, 0x00000000); | ||
nv_wr32(dev, NV04_PBUS_PCI_NV_19, 0); | ||
|
||
/* reset PGRAPH, PFIFO and PTIMER */ | ||
save[1] = nv_mask(dev, 0x000200, 0x00011100, 0x00000000); | ||
nv_mask(dev, 0x000200, 0x00011100, save[1]); | ||
|
||
/* and restore bustmaster bit (gives effect of resetting AGP) */ | ||
nv_wr32(dev, NV04_PBUS_PCI_NV_1, save[0]); | ||
#endif | ||
} | ||
|
||
void | ||
nouveau_agp_init(struct drm_device *dev) | ||
{ | ||
#if __OS_HAS_AGP | ||
struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
struct drm_agp_info info; | ||
struct drm_agp_mode mode; | ||
int ret; | ||
|
||
if (!nouveau_agp_enabled(dev)) | ||
return; | ||
|
||
ret = drm_agp_acquire(dev); | ||
if (ret) { | ||
NV_ERROR(dev, "Unable to acquire AGP: %d\n", ret); | ||
return; | ||
} | ||
|
||
ret = drm_agp_info(dev, &info); | ||
if (ret) { | ||
NV_ERROR(dev, "Unable to get AGP info: %d\n", ret); | ||
return; | ||
} | ||
|
||
/* see agp.h for the AGPSTAT_* modes available */ | ||
mode.mode = get_agp_mode(dev, info.mode); | ||
|
||
ret = drm_agp_enable(dev, mode); | ||
if (ret) { | ||
NV_ERROR(dev, "Unable to enable AGP: %d\n", ret); | ||
return; | ||
} | ||
|
||
dev_priv->gart_info.type = NOUVEAU_GART_AGP; | ||
dev_priv->gart_info.aper_base = info.aperture_base; | ||
dev_priv->gart_info.aper_size = info.aperture_size; | ||
#endif | ||
} | ||
|
||
void | ||
nouveau_agp_fini(struct drm_device *dev) | ||
{ | ||
#if __OS_HAS_AGP | ||
if (dev->agp && dev->agp->acquired) | ||
drm_agp_release(dev); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef __NOUVEAU_AGP_H__ | ||
#define __NOUVEAU_AGP_H__ | ||
|
||
void nouveau_agp_reset(struct drm_device *); | ||
void nouveau_agp_init(struct drm_device *); | ||
void nouveau_agp_fini(struct drm_device *); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.