video.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. *
  25. *****************************************************************************
  26. *
  27. * The GPL License (GPL)
  28. *
  29. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  30. *
  31. * This program is free software; you can redistribute it and/or
  32. * modify it under the terms of the GNU General Public License
  33. * as published by the Free Software Foundation; either version 2
  34. * of the License, or (at your option) any later version.
  35. *
  36. * This program is distributed in the hope that it will be useful,
  37. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  39. * GNU General Public License for more details.
  40. *
  41. * You should have received a copy of the GNU General Public License
  42. * along with this program;
  43. *
  44. *****************************************************************************
  45. *
  46. * Note: This software is released under dual MIT and GPL licenses. A
  47. * recipient may use this file under the terms of either the MIT license or
  48. * GPL License. If you wish to use only one license not the other, you can
  49. * indicate your decision by deleting one of the above license notices in your
  50. * version of this file.
  51. *
  52. *****************************************************************************/
  53. #ifndef _ISP_VIDEO_H_
  54. #define _ISP_VIDEO_H_
  55. #include <linux/list.h>
  56. #include <linux/videodev2.h>
  57. #include <media/media-device.h>
  58. #include <media/v4l2-async.h>
  59. #include <media/v4l2-ctrls.h>
  60. #include <media/v4l2-fh.h>
  61. #include "viv_video_kevent.h"
  62. #include "vvbuf.h"
  63. #define MAX_SUBDEVS_NUM (8)
  64. #define VIDEO_NODE_NUM (2)
  65. struct viv_custom_ctrls {
  66. struct v4l2_ctrl_handler handler;
  67. struct v4l2_ctrl *request;
  68. uint64_t buf_pa;
  69. void __iomem *buf_va;
  70. struct completion wait;
  71. };
  72. struct viv_video_fmt {
  73. int fourcc;
  74. int depth;
  75. int bpp;
  76. };
  77. struct viv_video_device {
  78. struct vvbuf_ctx bctx;
  79. struct video_device *video;
  80. struct v4l2_device *v4l2_dev;
  81. struct v4l2_async_notifier subdev_notifier;
  82. struct v4l2_subdev *subdevs[MAX_SUBDEVS_NUM];
  83. int sdcount;
  84. struct v4l2_async_subdev *asd[MAX_SUBDEVS_NUM];
  85. int asdcount;
  86. struct media_device *mdev;
  87. struct media_pad pad;
  88. struct v4l2_format fmt;
  89. struct v4l2_fract timeperframe;
  90. struct v4l2_rect crop, compose;
  91. struct viv_custom_ctrls ctrls;
  92. struct vvcam_constant_modeinfo modeinfo[20];
  93. int modeinfocount;
  94. struct viv_video_fmt formats[20];
  95. int formatscount;
  96. int id;
  97. struct viv_caps_mode_s caps_mode;
  98. int event_result;
  99. bool dweEnabled;
  100. struct viv_caps_supports caps_supports;
  101. u64 duration, last_ts, frameCnt[VIDEO_NODE_NUM];
  102. u32 loop_cnt[VIDEO_NODE_NUM];
  103. struct completion subscribed_wait;
  104. int subscribed_cnt;
  105. int active;
  106. void *rmem;
  107. bool frame_flag;
  108. };
  109. struct viv_video_file {
  110. struct v4l2_fh vfh;
  111. int streamid;
  112. int state; /* 0-free,1-ready,2-streaming,-1-closed */
  113. int sequence;
  114. bool req;
  115. bool capsqueried;
  116. struct vb2_queue queue;
  117. struct mutex event_mutex;
  118. struct mutex buffer_mutex;
  119. struct completion wait;
  120. struct list_head entry;
  121. struct viv_video_device *vdev;
  122. #ifdef CONFIG_VIDEOBUF2_DMA_CONTIG
  123. struct list_head extdmaqueue;
  124. #endif
  125. struct {
  126. uint64_t pa;
  127. void *va;
  128. } event_buf;
  129. };
  130. #define priv_to_handle(priv) container_of(priv, struct viv_video_file, vfh)
  131. #define queue_to_handle(__q) container_of(__q, struct viv_video_file, queue)
  132. #endif /* _ISP_VIDEO_H_ */