gtt.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**************************************************************************
  2. * Copyright (c) 2007-2008, Intel Corporation.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. **************************************************************************/
  19. #ifndef _PSB_GTT_H_
  20. #define _PSB_GTT_H_
  21. #include <drm/drmP.h>
  22. /* This wants cleaning up with respect to the psb_dev and un-needed stuff */
  23. struct psb_gtt {
  24. uint32_t gatt_start;
  25. uint32_t mmu_gatt_start;
  26. uint32_t gtt_start;
  27. uint32_t gtt_phys_start;
  28. unsigned gtt_pages;
  29. unsigned gatt_pages;
  30. unsigned long stolen_size;
  31. unsigned long vram_stolen_size;
  32. struct rw_semaphore sem;
  33. };
  34. /* Exported functions */
  35. extern int psb_gtt_init(struct drm_device *dev, int resume);
  36. extern void psb_gtt_takedown(struct drm_device *dev);
  37. /* Each gtt_range describes an allocation in the GTT area */
  38. struct gtt_range {
  39. struct resource resource; /* Resource for our allocation */
  40. u32 offset; /* GTT offset of our object */
  41. struct drm_gem_object gem; /* GEM high level stuff */
  42. int in_gart; /* Currently in the GART (ref ct) */
  43. bool stolen; /* Backed from stolen RAM */
  44. bool mmapping; /* Is mmappable */
  45. struct page **pages; /* Backing pages if present */
  46. int npage; /* Number of backing pages */
  47. int roll; /* Roll applied to the GTT entries */
  48. };
  49. extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
  50. const char *name, int backed);
  51. extern void psb_gtt_kref_put(struct gtt_range *gt);
  52. extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
  53. extern int psb_gtt_pin(struct gtt_range *gt);
  54. extern void psb_gtt_unpin(struct gtt_range *gt);
  55. extern void psb_gtt_roll(struct drm_device *dev,
  56. struct gtt_range *gt, int roll);
  57. #endif