nv30_fb.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2010 Francisco Jerez.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include "drmP.h"
  27. #include "drm.h"
  28. #include "nouveau_drv.h"
  29. #include "nouveau_drm.h"
  30. static int
  31. calc_ref(int b, int l, int i)
  32. {
  33. int j, x = 0;
  34. for (j = 0; j < 4; j++) {
  35. int n = (b >> (8 * j) & 0xf);
  36. int m = (l >> (8 * i) & 0xff) + 2 * (n & 0x8 ? n - 0x10 : n);
  37. x |= (0x80 | (m & 0x1f)) << (8 * j);
  38. }
  39. return x;
  40. }
  41. int
  42. nv30_fb_init(struct drm_device *dev)
  43. {
  44. struct drm_nouveau_private *dev_priv = dev->dev_private;
  45. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  46. int i, j;
  47. pfb->num_tiles = NV10_PFB_TILE__SIZE;
  48. /* Turn all the tiling regions off. */
  49. for (i = 0; i < pfb->num_tiles; i++)
  50. pfb->set_region_tiling(dev, i, 0, 0, 0);
  51. /* Init the memory timing regs at 0x10037c/0x1003ac */
  52. if (dev_priv->chipset == 0x30 ||
  53. dev_priv->chipset == 0x31 ||
  54. dev_priv->chipset == 0x35) {
  55. /* Related to ROP count */
  56. int n = (dev_priv->chipset == 0x31 ? 2 : 4);
  57. int b = (dev_priv->chipset > 0x30 ?
  58. nv_rd32(dev, 0x122c) & 0xf : 0);
  59. int l = nv_rd32(dev, 0x1003d0);
  60. for (i = 0; i < n; i++) {
  61. for (j = 0; j < 3; j++)
  62. nv_wr32(dev, 0x10037c + 0xc * i + 0x4 * j,
  63. calc_ref(b, l, j));
  64. for (j = 0; j < 2; j++)
  65. nv_wr32(dev, 0x1003ac + 0x8 * i + 0x4 * j,
  66. calc_ref(b, l, j));
  67. }
  68. }
  69. return 0;
  70. }
  71. void
  72. nv30_fb_takedown(struct drm_device *dev)
  73. {
  74. }