xilinx-dma.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Xilinx Video DMA
  3. *
  4. * Copyright (C) 2013-2015 Ideas on Board
  5. * Copyright (C) 2013-2015 Xilinx, Inc.
  6. *
  7. * Contacts: Hyun Kwon <hyun.kwon@xilinx.com>
  8. * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __XILINX_VIP_DMA_H__
  15. #define __XILINX_VIP_DMA_H__
  16. #include <linux/dmaengine.h>
  17. #include <linux/mutex.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/videodev2.h>
  20. #include <media/media-entity.h>
  21. #include <media/v4l2-dev.h>
  22. #include <media/videobuf2-v4l2.h>
  23. struct dma_chan;
  24. struct xvip_composite_device;
  25. struct xvip_video_format;
  26. /**
  27. * struct xvip_pipeline - Xilinx Video IP pipeline structure
  28. * @pipe: media pipeline
  29. * @lock: protects the pipeline @stream_count
  30. * @use_count: number of DMA engines using the pipeline
  31. * @stream_count: number of DMA engines currently streaming
  32. * @num_dmas: number of DMA engines in the pipeline
  33. * @output: DMA engine at the output of the pipeline
  34. */
  35. struct xvip_pipeline {
  36. struct media_pipeline pipe;
  37. struct mutex lock;
  38. unsigned int use_count;
  39. unsigned int stream_count;
  40. unsigned int num_dmas;
  41. struct xvip_dma *output;
  42. };
  43. static inline struct xvip_pipeline *to_xvip_pipeline(struct media_entity *e)
  44. {
  45. return container_of(e->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. * @alloc_ctx: allocation context for the vb2 @queue
  60. * @sequence: V4L2 buffers sequence number
  61. * @queued_bufs: list of queued buffers
  62. * @queued_lock: protects the buf_queued list
  63. * @dma: DMA engine channel
  64. * @align: transfer alignment required by the DMA channel (in bytes)
  65. * @xt: dma interleaved template for dma configuration
  66. * @sgl: data chunk structure for dma_interleaved_template
  67. */
  68. struct xvip_dma {
  69. struct list_head list;
  70. struct video_device video;
  71. struct media_pad pad;
  72. struct xvip_composite_device *xdev;
  73. struct xvip_pipeline pipe;
  74. unsigned int port;
  75. struct mutex lock;
  76. struct v4l2_pix_format format;
  77. const struct xvip_video_format *fmtinfo;
  78. struct vb2_queue queue;
  79. void *alloc_ctx;
  80. unsigned int sequence;
  81. struct list_head queued_bufs;
  82. spinlock_t queued_lock;
  83. struct dma_chan *dma;
  84. unsigned int align;
  85. struct dma_interleaved_template xt;
  86. struct data_chunk sgl[1];
  87. };
  88. #define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
  89. int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
  90. enum v4l2_buf_type type, unsigned int port);
  91. void xvip_dma_cleanup(struct xvip_dma *dma);
  92. #endif /* __XILINX_VIP_DMA_H__ */