xilinx-dma.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Xilinx Video DMA
  4. *
  5. * Copyright (C) 2013-2015 Ideas on Board
  6. * Copyright (C) 2013-2015 Xilinx, Inc.
  7. *
  8. * Contacts: Hyun Kwon <[email protected]>
  9. * Laurent Pinchart <[email protected]>
  10. */
  11. #ifndef __XILINX_VIP_DMA_H__
  12. #define __XILINX_VIP_DMA_H__
  13. #include <linux/dmaengine.h>
  14. #include <linux/mutex.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/videodev2.h>
  17. #include <media/media-entity.h>
  18. #include <media/v4l2-dev.h>
  19. #include <media/videobuf2-v4l2.h>
  20. struct dma_chan;
  21. struct xvip_composite_device;
  22. struct xvip_video_format;
  23. /**
  24. * struct xvip_pipeline - Xilinx Video IP pipeline structure
  25. * @pipe: media pipeline
  26. * @lock: protects the pipeline @stream_count
  27. * @use_count: number of DMA engines using the pipeline
  28. * @stream_count: number of DMA engines currently streaming
  29. * @num_dmas: number of DMA engines in the pipeline
  30. * @output: DMA engine at the output of the pipeline
  31. */
  32. struct xvip_pipeline {
  33. struct media_pipeline pipe;
  34. struct mutex lock;
  35. unsigned int use_count;
  36. unsigned int stream_count;
  37. unsigned int num_dmas;
  38. struct xvip_dma *output;
  39. };
  40. static inline struct xvip_pipeline *to_xvip_pipeline(struct video_device *vdev)
  41. {
  42. struct media_pipeline *pipe = video_device_pipeline(vdev);
  43. if (!pipe)
  44. return NULL;
  45. return container_of(pipe, struct xvip_pipeline, pipe);
  46. }
  47. /**
  48. * struct xvip_dma - Video DMA channel
  49. * @list: list entry in a composite device dmas list
  50. * @video: V4L2 video device associated with the DMA channel
  51. * @pad: media pad for the video device entity
  52. * @xdev: composite device the DMA channel belongs to
  53. * @pipe: pipeline belonging to the DMA channel
  54. * @port: composite device DT node port number for the DMA channel
  55. * @lock: protects the @format, @fmtinfo and @queue fields
  56. * @format: active V4L2 pixel format
  57. * @fmtinfo: format information corresponding to the active @format
  58. * @queue: vb2 buffers queue
  59. * @sequence: V4L2 buffers sequence number
  60. * @queued_bufs: list of queued buffers
  61. * @queued_lock: protects the buf_queued list
  62. * @dma: DMA engine channel
  63. * @align: transfer alignment required by the DMA channel (in bytes)
  64. * @xt: dma interleaved template for dma configuration
  65. * @sgl: data chunk structure for dma_interleaved_template
  66. */
  67. struct xvip_dma {
  68. struct list_head list;
  69. struct video_device video;
  70. struct media_pad pad;
  71. struct xvip_composite_device *xdev;
  72. struct xvip_pipeline pipe;
  73. unsigned int port;
  74. struct mutex lock;
  75. struct v4l2_pix_format format;
  76. const struct xvip_video_format *fmtinfo;
  77. struct vb2_queue queue;
  78. unsigned int sequence;
  79. struct list_head queued_bufs;
  80. spinlock_t queued_lock;
  81. struct dma_chan *dma;
  82. unsigned int align;
  83. struct dma_interleaved_template xt;
  84. struct data_chunk sgl[1];
  85. };
  86. #define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
  87. int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
  88. enum v4l2_buf_type type, unsigned int port);
  89. void xvip_dma_cleanup(struct xvip_dma *dma);
  90. #endif /* __XILINX_VIP_DMA_H__ */