vsp1_video.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * vsp1_video.h -- R-Car VSP1 Video Node
  3. *
  4. * Copyright (C) 2013-2015 Renesas Electronics Corporation
  5. *
  6. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef __VSP1_VIDEO_H__
  14. #define __VSP1_VIDEO_H__
  15. #include <linux/list.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/wait.h>
  18. #include <media/media-entity.h>
  19. #include <media/videobuf2-v4l2.h>
  20. struct vsp1_video;
  21. /*
  22. * struct vsp1_format_info - VSP1 video format description
  23. * @mbus: media bus format code
  24. * @fourcc: V4L2 pixel format FCC identifier
  25. * @planes: number of planes
  26. * @bpp: bits per pixel
  27. * @hwfmt: VSP1 hardware format
  28. * @swap_yc: the Y and C components are swapped (Y comes before C)
  29. * @swap_uv: the U and V components are swapped (V comes before U)
  30. * @hsub: horizontal subsampling factor
  31. * @vsub: vertical subsampling factor
  32. * @alpha: has an alpha channel
  33. */
  34. struct vsp1_format_info {
  35. u32 fourcc;
  36. unsigned int mbus;
  37. unsigned int hwfmt;
  38. unsigned int swap;
  39. unsigned int planes;
  40. unsigned int bpp[3];
  41. bool swap_yc;
  42. bool swap_uv;
  43. unsigned int hsub;
  44. unsigned int vsub;
  45. bool alpha;
  46. };
  47. enum vsp1_pipeline_state {
  48. VSP1_PIPELINE_STOPPED,
  49. VSP1_PIPELINE_RUNNING,
  50. VSP1_PIPELINE_STOPPING,
  51. };
  52. /*
  53. * struct vsp1_pipeline - A VSP1 hardware pipeline
  54. * @media: the media pipeline
  55. * @irqlock: protects the pipeline state
  56. * @lock: protects the pipeline use count and stream count
  57. */
  58. struct vsp1_pipeline {
  59. struct media_pipeline pipe;
  60. spinlock_t irqlock;
  61. enum vsp1_pipeline_state state;
  62. wait_queue_head_t wq;
  63. struct mutex lock;
  64. unsigned int use_count;
  65. unsigned int stream_count;
  66. unsigned int buffers_ready;
  67. unsigned int num_video;
  68. unsigned int num_inputs;
  69. struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
  70. struct vsp1_rwpf *output;
  71. struct vsp1_entity *bru;
  72. struct vsp1_entity *lif;
  73. struct vsp1_entity *uds;
  74. struct vsp1_entity *uds_input;
  75. struct list_head entities;
  76. };
  77. static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
  78. {
  79. if (likely(e->pipe))
  80. return container_of(e->pipe, struct vsp1_pipeline, pipe);
  81. else
  82. return NULL;
  83. }
  84. struct vsp1_video_buffer {
  85. struct vb2_v4l2_buffer buf;
  86. struct list_head queue;
  87. dma_addr_t addr[3];
  88. unsigned int length[3];
  89. };
  90. static inline struct vsp1_video_buffer *
  91. to_vsp1_video_buffer(struct vb2_v4l2_buffer *vbuf)
  92. {
  93. return container_of(vbuf, struct vsp1_video_buffer, buf);
  94. }
  95. struct vsp1_video_operations {
  96. void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
  97. };
  98. struct vsp1_video {
  99. struct vsp1_device *vsp1;
  100. struct vsp1_entity *rwpf;
  101. const struct vsp1_video_operations *ops;
  102. struct video_device video;
  103. enum v4l2_buf_type type;
  104. struct media_pad pad;
  105. struct mutex lock;
  106. struct v4l2_pix_format_mplane format;
  107. const struct vsp1_format_info *fmtinfo;
  108. struct vsp1_pipeline pipe;
  109. unsigned int pipe_index;
  110. struct vb2_queue queue;
  111. void *alloc_ctx;
  112. spinlock_t irqlock;
  113. struct list_head irqqueue;
  114. unsigned int sequence;
  115. };
  116. static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
  117. {
  118. return container_of(vdev, struct vsp1_video, video);
  119. }
  120. int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
  121. void vsp1_video_cleanup(struct vsp1_video *video);
  122. void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
  123. void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
  124. struct vsp1_entity *input,
  125. unsigned int alpha);
  126. void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
  127. void vsp1_pipelines_resume(struct vsp1_device *vsp1);
  128. #endif /* __VSP1_VIDEO_H__ */