vvdefs.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_VVDEFS_H_
  54. #define _ISP_VVDEFS_H_
  55. #define viv_check_retval(x)\
  56. do {\
  57. if ((x))\
  58. return -EIO;\
  59. } while (0)
  60. #ifndef VIV_MEDIA_PIX_FMT
  61. #define VIV_MEDIA_PIX_FMT
  62. enum {
  63. MEDIA_PIX_FMT_YUV422SP = 0,
  64. MEDIA_PIX_FMT_YUV422I,
  65. MEDIA_PIX_FMT_YUV420SP,
  66. MEDIA_PIX_FMT_YUV444P,
  67. MEDIA_PIX_FMT_YUV444I,
  68. MEDIA_PIX_FMT_RGB888,
  69. MEDIA_PIX_FMT_RGB888P,
  70. MEDIA_PIX_FMT_BGR888P,
  71. MEDIA_PIX_FMT_RAW8,
  72. MEDIA_PIX_FMT_RAW10,
  73. MEDIA_PIX_FMT_RAW12,
  74. };
  75. #endif
  76. #ifndef __KERNEL__
  77. #include <stdlib.h>
  78. #include <stdint.h>
  79. #include <stdbool.h>
  80. #include <errno.h>
  81. #include <stdio.h>
  82. typedef uint8_t u8;
  83. typedef uint16_t u16;
  84. typedef uint32_t u32;
  85. typedef uint64_t u64;
  86. #define pr_info(...) printf(__VA_ARGS__)
  87. #define pr_err(...) printf(__VA_ARGS__)
  88. #define pr_debug(...) printf(__VA_ARGS__)
  89. #define __user
  90. #define __iomem
  91. #else /* __KERNEL__ */
  92. /* if v4l2 */
  93. #include <linux/clk.h>
  94. #include <linux/interrupt.h>
  95. #include <linux/completion.h>
  96. #include <linux/io.h>
  97. #include <linux/list.h>
  98. #include <linux/delay.h>
  99. #include <media/v4l2-subdev.h>
  100. #include <linux/platform_device.h>
  101. enum STATE_CODE {
  102. STATE_STOPPED = 0,
  103. STATE_STREAM_STARTED = 1 << 1,
  104. STATE_DRIVER_STARTED = 1 << 2,
  105. };
  106. #endif
  107. #ifndef MIN
  108. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  109. #endif
  110. #ifndef MAX
  111. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  112. #endif
  113. #ifndef ALIGN_UP
  114. #define ALIGN_UP(x, align) (((x) + ((align) - 1)) & ~((align)-1))
  115. #endif
  116. #define ISP_COMPAT_NAME "fsl,imx8mp-isp"
  117. #define DWE_COMPAT_NAME "fsl,imx8mp-dwe"
  118. #define ISP_DEVICE_NAME "vvcam-isp"
  119. #define DWE_DEVICE_NAME "vvcam-dwe"
  120. #define ISP_PAD_SOURCE (0)
  121. #define ISP_PADS_NUM (1)
  122. #define DWE_PAD_SOURCE (0)
  123. #define DWE_PAD_SINK (1)
  124. #define DWE_PADS_NUM (2)
  125. #define RESV_STREAMID_ISP(id) \
  126. ((id) ? RESV_STREAMID_ISP1 : RESV_STREAMID_ISP0)
  127. #define RESV_STREAMID_ISP0 (-2)
  128. #define RESV_STREAMID_ISP1 (-3)
  129. #define RESV_STREAMID_DWE (-4)
  130. #endif /* _ISP_VVDEFS_H_ */