msm_gem_prime.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "msm_drv.h"
  18. #include "msm_gem.h"
  19. struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
  20. {
  21. struct msm_gem_object *msm_obj = to_msm_bo(obj);
  22. BUG_ON(!msm_obj->sgt); /* should have already pinned! */
  23. return msm_obj->sgt;
  24. }
  25. void *msm_gem_prime_vmap(struct drm_gem_object *obj)
  26. {
  27. return msm_gem_vaddr(obj);
  28. }
  29. void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
  30. {
  31. /* TODO msm_gem_vunmap() */
  32. }
  33. struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
  34. size_t size, struct sg_table *sg)
  35. {
  36. return msm_gem_import(dev, size, sg);
  37. }
  38. int msm_gem_prime_pin(struct drm_gem_object *obj)
  39. {
  40. if (!obj->import_attach)
  41. msm_gem_get_pages(obj);
  42. return 0;
  43. }
  44. void msm_gem_prime_unpin(struct drm_gem_object *obj)
  45. {
  46. if (!obj->import_attach)
  47. msm_gem_put_pages(obj);
  48. }