mtk-dma-contig.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2016 MediaTek Inc.
  3. * Author: Rick Chang <rick.chang@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef _MEDIA_MTK_DMA_CONTIG_H
  15. #define _MEDIA_MTK_DMA_CONTIG_H
  16. #include <media/videobuf2-v4l2.h>
  17. #include <linux/dma-mapping.h>
  18. #include <media/videobuf2-v4l2.h>
  19. #include <media/videobuf2-memops.h>
  20. struct vb2_dc_buf {
  21. struct device *dev;
  22. void *vaddr;
  23. unsigned long size;
  24. void *cookie;
  25. dma_addr_t dma_addr;
  26. unsigned long attrs;
  27. enum dma_data_direction dma_dir;
  28. struct sg_table *dma_sgt;
  29. struct frame_vector *vec;
  30. /* MMAP related */
  31. struct vb2_vmarea_handler handler;
  32. atomic_t refcount;
  33. struct sg_table *sgt_base;
  34. /* DMABUF related */
  35. struct dma_buf_attachment *db_attach;
  36. };
  37. static inline dma_addr_t
  38. mtk_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
  39. {
  40. dma_addr_t *addr = vb2_plane_cookie(vb, plane_no);
  41. return *addr;
  42. }
  43. int mtk_dma_contig_set_max_seg_size(struct device *dev, unsigned int size);
  44. void mtk_dma_contig_clear_max_seg_size(struct device *dev);
  45. void mtk_dma_contig_set_secure_mode(struct device *dev, int secure_mode);
  46. extern const struct vb2_mem_ops mtk_dma_contig_memops;
  47. #endif