nv40_fb.c 1.8 KB
Newer Older
1 2 3 4 5
#include "drmP.h"
#include "drm.h"
#include "nouveau_drv.h"
#include "nouveau_drm.h"

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
void
nv40_fb_set_region_tiling(struct drm_device *dev, int i, uint32_t addr,
			  uint32_t size, uint32_t pitch)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	uint32_t limit = max(1u, addr + size) - 1;

	if (pitch)
		addr |= 1;

	switch (dev_priv->chipset) {
	case 0x40:
		nv_wr32(dev, NV10_PFB_TLIMIT(i), limit);
		nv_wr32(dev, NV10_PFB_TSIZE(i), pitch);
		nv_wr32(dev, NV10_PFB_TILE(i), addr);
		break;

	default:
		nv_wr32(dev, NV40_PFB_TLIMIT(i), limit);
		nv_wr32(dev, NV40_PFB_TSIZE(i), pitch);
		nv_wr32(dev, NV40_PFB_TILE(i), addr);
		break;
	}
}

31 32 33 34
int
nv40_fb_init(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
35 36
	struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
	uint32_t tmp;
37 38 39 40 41 42 43 44 45 46 47 48 49 50
	int i;

	/* This is strictly a NV4x register (don't know about NV5x). */
	/* The blob sets these to all kinds of values, and they mess up our setup. */
	/* I got value 0x52802 instead. For some cards the blob even sets it back to 0x1. */
	/* Note: the blob doesn't read this value, so i'm pretty sure this is safe for all cards. */
	/* Any idea what this is? */
	nv_wr32(dev, NV40_PFB_UNK_800, 0x1);

	switch (dev_priv->chipset) {
	case 0x40:
	case 0x45:
		tmp = nv_rd32(dev, NV10_PFB_CLOSE_PAGE2);
		nv_wr32(dev, NV10_PFB_CLOSE_PAGE2, tmp & ~(1 << 15));
51
		pfb->num_tiles = NV10_PFB_TILE__SIZE;
52 53 54 55 56 57
		break;
	case 0x46: /* G72 */
	case 0x47: /* G70 */
	case 0x49: /* G71 */
	case 0x4b: /* G73 */
	case 0x4c: /* C51 (G7X version) */
58
		pfb->num_tiles = NV40_PFB_TILE__SIZE_1;
59 60
		break;
	default:
61
		pfb->num_tiles = NV40_PFB_TILE__SIZE_0;
62 63 64
		break;
	}

65 66 67
	/* Turn all the tiling regions off. */
	for (i = 0; i < pfb->num_tiles; i++)
		pfb->set_region_tiling(dev, i, 0, 0, 0);
68 69 70 71 72 73 74 75

	return 0;
}

void
nv40_fb_takedown(struct drm_device *dev)
{
}