vvnative_cfg.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. #include <linux/module.h> /* Module support */
  54. #include "vvnative_cfg.h"
  55. char vvcam_driver_name [][8]=
  56. {
  57. #ifdef WITH_VVISP /* devid 0 */
  58. VVNATIVE_ISP,
  59. #else
  60. VVNATIVE_NA,
  61. #endif
  62. #ifdef WITH_VVISP_DUAL /* devid 1 */
  63. VVNATIVE_ISP,
  64. #else
  65. VVNATIVE_NA,
  66. #endif
  67. #ifdef WITH_VVCSI /* devid 2 */
  68. VVNATIVE_CSI,
  69. #else
  70. VVNATIVE_NA,
  71. #endif
  72. #ifdef WITH_VVCSI_DUAL /* devid 3 */
  73. VVNATIVE_CSI,
  74. #else
  75. VVNATIVE_NA,
  76. #endif
  77. #ifdef WITH_VVCAM /* devid 4 */
  78. VVNATIVE_SENSOR,
  79. #else
  80. VVNATIVE_NA,
  81. #endif
  82. #ifdef WITH_VVCAM_DUAL /* devid 5 */
  83. VVNATIVE_SENSOR,
  84. #else
  85. VVNATIVE_NA,
  86. #endif
  87. #ifdef WITH_VVDWE /* devid 6 */
  88. VVNATIVE_DWE,
  89. #else
  90. VVNATIVE_NA,
  91. #endif
  92. #ifdef WITH_VVVSE /* devid 7 */
  93. VVNATIVE_VSE,
  94. #else
  95. VVNATIVE_NA,
  96. #endif
  97. #ifdef WITH_VVCTL /* devid 8 */
  98. VVNATIVE_SOC,
  99. #else
  100. VVNATIVE_NA,
  101. #endif
  102. };
  103. char * vvnative_get_dev_name_by_idx(int devidx)
  104. {
  105. if((devidx > VVCAM_ISP_DEVICES)||(devidx < 0))
  106. {
  107. return VVNATIVE_NA;
  108. }
  109. return vvcam_driver_name[devidx];
  110. }
  111. /* Parameters that can be set with 'insmod' */
  112. /* ISP */
  113. static ulong vvisp0_reg_base = VVISP0_BASE;
  114. module_param(vvisp0_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
  115. MODULE_PARM_DESC(vvisp0_reg_base, "VVISP0 Reg Base address of AHB register");
  116. static ulong vvisp1_reg_base = VVISP1_BASE;
  117. module_param(vvisp1_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
  118. MODULE_PARM_DESC(vvisp1_reg_base, "VVISP1 Reg Base address of AHB register");
  119. static ulong vvisp_reg_size = VVISP_SIZE;
  120. module_param(vvisp_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  121. MODULE_PARM_DESC(vvisp_reg_size, "VVISP0/1 Reg address range of AHB register");
  122. /* CSI */
  123. static ulong vvcsi0_reg_base = VVCSI0_BASE;
  124. module_param(vvcsi0_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  125. MODULE_PARM_DESC(vvcsi0_reg_base, "VVCSI0 Reg Base address of AHB register");
  126. static ulong vvcsi1_reg_base = VVCSI1_BASE;
  127. module_param(vvcsi1_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  128. MODULE_PARM_DESC(vvcsi1_reg_base, "VVCSI1 Reg Base address of AHB register");
  129. static ulong vvcsi_reg_size = VVCSI_SIZE;
  130. module_param(vvcsi_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  131. MODULE_PARM_DESC(vvcsi_reg_size, "VVCSI0/1 Reg address range of AHB register");
  132. /* Sensor */
  133. static ulong vvcam0_reg_base = VVCAM0_BASE;
  134. module_param(vvcam0_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  135. MODULE_PARM_DESC(vvcam0_reg_base, "VVCAM0 Reg Base address of AHB register");
  136. static ulong vvcam1_reg_base = VVCAM1_BASE;
  137. module_param(vvcam1_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  138. MODULE_PARM_DESC(vvcam1_reg_base, "VVCAM1 Reg Base address of AHB register");
  139. static ulong vvcam_reg_size = VVCAM_SIZE;
  140. module_param(vvcam_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  141. MODULE_PARM_DESC(vvcam_reg_size, "VVCAM0/1 Reg address range of AHB register");
  142. /* Dwe */
  143. static ulong vvdwe_reg_base = VVDWE_BASE;
  144. module_param(vvdwe_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  145. MODULE_PARM_DESC(vvdwe_reg_base, "VVDWE Reg Base address of AHB register");
  146. static ulong vvdwe_reg_size = VVDWE_SIZE;
  147. module_param(vvdwe_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  148. MODULE_PARM_DESC(vvdwe_reg_size, "VVDWE Reg address range of AHB register");
  149. /* Vse */
  150. static ulong vvvse_reg_base = VVVSE_BASE;
  151. module_param(vvvse_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  152. MODULE_PARM_DESC(vvvse_reg_base, "VVVSE Reg Base address of AHB register");
  153. static ulong vvvse_reg_size = VVVSE_SIZE;
  154. module_param(vvvse_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  155. MODULE_PARM_DESC(vvvse_reg_size, "VVVSE Reg address range of AHB register");
  156. /* Crtl */
  157. static ulong vvctl_reg_base = VVCTRL_BASE;
  158. module_param(vvctl_reg_base, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  159. MODULE_PARM_DESC(vvctl_reg_base, "VVCTRL Reg Base address of AHB register");
  160. static ulong vvctl_reg_size = VVCTRL_SIZE;
  161. module_param(vvctl_reg_size, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  162. MODULE_PARM_DESC(vvctl_reg_size, "VVCTRL Reg address range of AHB register");
  163. static ulong vvImgBufBase = 0x10000000;
  164. module_param(vvImgBufBase, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  165. MODULE_PARM_DESC(vvImgBufBase, "Base addrss of memory reserved for ISP");
  166. static ulong vvImgBufSize = 0x10000000;
  167. module_param(vvImgBufSize, ulong, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
  168. MODULE_PARM_DESC(vvImgBufSize, "Size of memory reserved for ISP");
  169. ulong* reg_base_size_array[] =
  170. {
  171. &vvisp0_reg_base, /* devid 0 */
  172. &vvisp_reg_size,
  173. &vvisp1_reg_base, /* devid 1 */
  174. &vvisp_reg_size,
  175. &vvcsi0_reg_base, /* devid 2 */
  176. &vvcsi_reg_size,
  177. &vvcsi1_reg_base, /* devid 3 */
  178. &vvcsi_reg_size,
  179. &vvcam0_reg_base, /* devid 4 */
  180. &vvcam_reg_size,
  181. &vvcam1_reg_base, /* devid 5 */
  182. &vvcam_reg_size,
  183. &vvdwe_reg_base, /* devid 6 */
  184. &vvdwe_reg_size,
  185. &vvvse_reg_base, /* devid 7 */
  186. &vvvse_reg_size,
  187. &vvctl_reg_base, /* devid 8 */
  188. &vvctl_reg_size,
  189. };
  190. ulong vvnative_get_reg_base_by_idx(int devidx)
  191. {
  192. if((devidx > VVCAM_ISP_DEVICES)||(devidx < 0))
  193. {
  194. return 0;
  195. }
  196. return *reg_base_size_array[devidx*2];
  197. }
  198. ulong vvnative_get_reg_size_by_idx(int devidx)
  199. {
  200. if((devidx > VVCAM_ISP_DEVICES)||(devidx < 0))
  201. {
  202. return 0;
  203. }
  204. return *reg_base_size_array[devidx*2 + 1];
  205. }
  206. int reg_dev_idx_array[] =
  207. {
  208. 0, /* devid 0 isp0*/
  209. 1, /* devid 1 isp1 */
  210. 0, /* devid 2 csi0*/
  211. 1, /* devid 3 csi1*/
  212. 0, /* devid 4 cam0*/
  213. 1, /* devid 5 cam1*/
  214. 0, /* devid 6 dwe0*/
  215. 0, /* devid 7 vse0*/
  216. 0, /* devid 8 ctrl0*/
  217. };
  218. int vvnative_get_dev_idx(int devidx)
  219. {
  220. if((devidx > VVCAM_ISP_DEVICES)||(devidx < 0))
  221. {
  222. return -1;
  223. }
  224. return reg_dev_idx_array[devidx];
  225. }
  226. ulong vvnative_get_img_buf_base(void)
  227. {
  228. return vvImgBufBase;
  229. }
  230. ulong vvnative_get_img_buf_size(void)
  231. {
  232. return vvImgBufSize;
  233. }