msm_gem_prime.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <linux/dma-buf.h>
  20. struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
  21. {
  22. struct msm_gem_object *msm_obj = to_msm_bo(obj);
  23. BUG_ON(!msm_obj->sgt); /* should have already pinned! */
  24. return msm_obj->sgt;
  25. }
  26. void *msm_gem_prime_vmap(struct drm_gem_object *obj)
  27. {
  28. return msm_gem_vaddr(obj);
  29. }
  30. void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
  31. {
  32. /* TODO msm_gem_vunmap() */
  33. }
  34. struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
  35. struct dma_buf_attachment *attach, struct sg_table *sg)
  36. {
  37. return msm_gem_import(dev, attach->dmabuf->size, sg);
  38. }
  39. int msm_gem_prime_pin(struct drm_gem_object *obj)
  40. {
  41. if (!obj->import_attach)
  42. msm_gem_get_pages(obj);
  43. return 0;
  44. }
  45. void msm_gem_prime_unpin(struct drm_gem_object *obj)
  46. {
  47. if (!obj->import_attach)
  48. msm_gem_put_pages(obj);
  49. }