vsp1_video.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * vsp1_video.h -- R-Car VSP1 Video Node
  3. *
  4. * Copyright (C) 2013 Renesas 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-core.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. */
  33. struct vsp1_format_info {
  34. u32 fourcc;
  35. unsigned int mbus;
  36. unsigned int hwfmt;
  37. unsigned int swap;
  38. unsigned int planes;
  39. unsigned int bpp[3];
  40. bool swap_yc;
  41. bool swap_uv;
  42. unsigned int hsub;
  43. unsigned int vsub;
  44. };
  45. enum vsp1_pipeline_state {
  46. VSP1_PIPELINE_STOPPED,
  47. VSP1_PIPELINE_RUNNING,
  48. VSP1_PIPELINE_STOPPING,
  49. };
  50. /*
  51. * struct vsp1_pipeline - A VSP1 hardware pipeline
  52. * @media: the media pipeline
  53. * @irqlock: protects the pipeline state
  54. * @lock: protects the pipeline use count and stream count
  55. */
  56. struct vsp1_pipeline {
  57. struct media_pipeline pipe;
  58. spinlock_t irqlock;
  59. enum vsp1_pipeline_state state;
  60. wait_queue_head_t wq;
  61. struct mutex lock;
  62. unsigned int use_count;
  63. unsigned int stream_count;
  64. unsigned int buffers_ready;
  65. unsigned int num_video;
  66. unsigned int num_inputs;
  67. struct vsp1_rwpf *inputs[VPS1_MAX_RPF];
  68. struct vsp1_rwpf *output;
  69. struct vsp1_entity *lif;
  70. struct list_head entities;
  71. };
  72. static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
  73. {
  74. if (likely(e->pipe))
  75. return container_of(e->pipe, struct vsp1_pipeline, pipe);
  76. else
  77. return NULL;
  78. }
  79. struct vsp1_video_buffer {
  80. struct vsp1_video *video;
  81. struct vb2_buffer buf;
  82. struct list_head queue;
  83. dma_addr_t addr[3];
  84. unsigned int length[3];
  85. };
  86. static inline struct vsp1_video_buffer *
  87. to_vsp1_video_buffer(struct vb2_buffer *vb)
  88. {
  89. return container_of(vb, struct vsp1_video_buffer, buf);
  90. }
  91. struct vsp1_video_operations {
  92. void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
  93. };
  94. struct vsp1_video {
  95. struct vsp1_device *vsp1;
  96. struct vsp1_entity *rwpf;
  97. const struct vsp1_video_operations *ops;
  98. struct video_device video;
  99. enum v4l2_buf_type type;
  100. struct media_pad pad;
  101. struct mutex lock;
  102. struct v4l2_pix_format_mplane format;
  103. const struct vsp1_format_info *fmtinfo;
  104. struct vsp1_pipeline pipe;
  105. unsigned int pipe_index;
  106. struct vb2_queue queue;
  107. void *alloc_ctx;
  108. spinlock_t irqlock;
  109. struct list_head irqqueue;
  110. unsigned int sequence;
  111. };
  112. static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
  113. {
  114. return container_of(vdev, struct vsp1_video, video);
  115. }
  116. int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
  117. void vsp1_video_cleanup(struct vsp1_video *video);
  118. void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
  119. #endif /* __VSP1_VIDEO_H__ */