nv40_fb.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #include "drmP.h"
  2. #include "drm.h"
  3. #include "nouveau_drv.h"
  4. #include "nouveau_drm.h"
  5. void
  6. nv40_fb_set_tile_region(struct drm_device *dev, int i)
  7. {
  8. struct drm_nouveau_private *dev_priv = dev->dev_private;
  9. struct nouveau_tile_reg *tile = &dev_priv->tile.reg[i];
  10. switch (dev_priv->chipset) {
  11. case 0x40:
  12. nv_wr32(dev, NV10_PFB_TLIMIT(i), tile->limit);
  13. nv_wr32(dev, NV10_PFB_TSIZE(i), tile->pitch);
  14. nv_wr32(dev, NV10_PFB_TILE(i), tile->addr);
  15. break;
  16. default:
  17. nv_wr32(dev, NV40_PFB_TLIMIT(i), tile->limit);
  18. nv_wr32(dev, NV40_PFB_TSIZE(i), tile->pitch);
  19. nv_wr32(dev, NV40_PFB_TILE(i), tile->addr);
  20. break;
  21. }
  22. }
  23. static void
  24. nv40_fb_init_gart(struct drm_device *dev)
  25. {
  26. struct drm_nouveau_private *dev_priv = dev->dev_private;
  27. struct nouveau_gpuobj *gart = dev_priv->gart_info.sg_ctxdma;
  28. if (dev_priv->gart_info.type != NOUVEAU_GART_HW) {
  29. nv_wr32(dev, 0x100800, 0x00000001);
  30. return;
  31. }
  32. nv_wr32(dev, 0x100800, gart->pinst | 0x00000002);
  33. nv_mask(dev, 0x10008c, 0x00000100, 0x00000100);
  34. nv_wr32(dev, 0x100820, 0x00000000);
  35. }
  36. static void
  37. nv44_fb_init_gart(struct drm_device *dev)
  38. {
  39. struct drm_nouveau_private *dev_priv = dev->dev_private;
  40. struct nouveau_gpuobj *gart = dev_priv->gart_info.sg_ctxdma;
  41. u32 vinst;
  42. if (dev_priv->gart_info.type != NOUVEAU_GART_HW) {
  43. nv_wr32(dev, 0x100850, 0x80000000);
  44. nv_wr32(dev, 0x100800, 0x00000001);
  45. return;
  46. }
  47. /* calculate vram address of this PRAMIN block, object
  48. * must be allocated on 512KiB alignment, and not exceed
  49. * a total size of 512KiB for this to work correctly
  50. */
  51. vinst = nv_rd32(dev, 0x10020c);
  52. vinst -= ((gart->pinst >> 19) + 1) << 19;
  53. nv_wr32(dev, 0x100850, 0x80000000);
  54. nv_wr32(dev, 0x100818, dev_priv->gart_info.dummy.addr);
  55. nv_wr32(dev, 0x100804, dev_priv->gart_info.aper_size);
  56. nv_wr32(dev, 0x100850, 0x00008000);
  57. nv_mask(dev, 0x10008c, 0x00000200, 0x00000200);
  58. nv_wr32(dev, 0x100820, 0x00000000);
  59. nv_wr32(dev, 0x10082c, 0x00000001);
  60. nv_wr32(dev, 0x100800, vinst | 0x00000010);
  61. }
  62. int
  63. nv40_fb_init(struct drm_device *dev)
  64. {
  65. struct drm_nouveau_private *dev_priv = dev->dev_private;
  66. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  67. uint32_t tmp;
  68. int i;
  69. if (dev_priv->chipset != 0x40 && dev_priv->chipset != 0x45) {
  70. if (nv44_graph_class(dev))
  71. nv44_fb_init_gart(dev);
  72. else
  73. nv40_fb_init_gart(dev);
  74. }
  75. switch (dev_priv->chipset) {
  76. case 0x40:
  77. case 0x45:
  78. tmp = nv_rd32(dev, NV10_PFB_CLOSE_PAGE2);
  79. nv_wr32(dev, NV10_PFB_CLOSE_PAGE2, tmp & ~(1 << 15));
  80. pfb->num_tiles = NV10_PFB_TILE__SIZE;
  81. break;
  82. case 0x46: /* G72 */
  83. case 0x47: /* G70 */
  84. case 0x49: /* G71 */
  85. case 0x4b: /* G73 */
  86. case 0x4c: /* C51 (G7X version) */
  87. pfb->num_tiles = NV40_PFB_TILE__SIZE_1;
  88. break;
  89. default:
  90. pfb->num_tiles = NV40_PFB_TILE__SIZE_0;
  91. break;
  92. }
  93. /* Turn all the tiling regions off. */
  94. for (i = 0; i < pfb->num_tiles; i++)
  95. pfb->set_tile_region(dev, i);
  96. return 0;
  97. }
  98. void
  99. nv40_fb_takedown(struct drm_device *dev)
  100. {
  101. }