hantrovcmd.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2014 - 2021 VERISILICON
  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) 2014 - 2021 VERISILICON
  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; if not, write to the Free Software Foundation,
  43. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  44. *
  45. *****************************************************************************
  46. *
  47. * Note: This software is released under dual MIT and GPL licenses. A
  48. * recipient may use this file under the terms of either the MIT license or
  49. * GPL License. If you wish to use only one license not the other, you can
  50. * indicate your decision by deleting one of the above license notices in your
  51. * version of this file.
  52. *
  53. *****************************************************************************/
  54. #ifndef _VC8000_VCMD_DRIVER_H_
  55. #define _VC8000_VCMD_DRIVER_H_
  56. #ifdef __FREERTOS__
  57. #include "basetype.h"
  58. #include "dev_common_freertos.h"
  59. #elif defined(__linux__)
  60. #include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
  61. #endif
  62. #ifdef __FREERTOS__
  63. //addr_t has been defined in basetype.h //Now the FreeRTOS mem need to support 64bit env
  64. #elif defined(__linux__)
  65. #undef addr_t
  66. #define addr_t ADDR_T_VCMD
  67. typedef size_t addr_t;
  68. #endif
  69. /* Use 'v' as magic number for vcmd */
  70. #define HANTRO_VCMD_IOC_MAGIC 'v'
  71. /*
  72. * S means "Set" through a ptr,
  73. * T means "Tell" directly with the argument value
  74. * G means "Get": reply by setting through a pointer
  75. * Q means "Query": response is on the return value
  76. * X means "eXchange": G and S atomically
  77. * H means "sHift": T and Q atomically
  78. */
  79. #define HANTRO_VCMD_IOCH_GET_CMDBUF_PARAMETER _IOWR(HANTRO_VCMD_IOC_MAGIC, 20,struct cmdbuf_mem_parameter *)
  80. #define HANTRO_VCMD_IOCH_GET_CMDBUF_POOL_SIZE _IOWR(HANTRO_VCMD_IOC_MAGIC, 21,unsigned long)
  81. #define HANTRO_VCMD_IOCH_SET_CMDBUF_POOL_BASE _IOWR(HANTRO_VCMD_IOC_MAGIC, 22,unsigned long)
  82. #define HANTRO_VCMD_IOCH_GET_VCMD_PARAMETER _IOWR(HANTRO_VCMD_IOC_MAGIC, 24, struct config_parameter *)
  83. #define HANTRO_VCMD_IOCH_RESERVE_CMDBUF _IOWR(HANTRO_VCMD_IOC_MAGIC, 25,struct exchange_parameter *)
  84. #define HANTRO_VCMD_IOCH_LINK_RUN_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 26,u16 *)
  85. #define HANTRO_VCMD_IOCH_WAIT_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 27,u16 *)
  86. #define HANTRO_VCMD_IOCH_RELEASE_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 28,u16 *)
  87. #define HANTRO_VCMD_IOCH_POLLING_CMDBUF _IOR(HANTRO_VCMD_IOC_MAGIC, 40,u16 *)
  88. #define HANTRO_VCMD_IOC_MAXNR 50
  89. /*priority support*/
  90. #define MAX_CMDBUF_PRIORITY_TYPE 2 //0:normal priority,1:high priority
  91. #define CMDBUF_PRIORITY_NORMAL 0
  92. #define CMDBUF_PRIORITY_HIGH 1
  93. #if 0
  94. #define OPCODE_WREG (0x01<<27)
  95. #define OPCODE_END (0x02<<27)
  96. #define OPCODE_NOP (0x03<<27)
  97. #define OPCODE_RREG (0x16<<27)
  98. #define OPCODE_INT (0x18<<27)
  99. #define OPCODE_JMP (0x19<<27)
  100. #define OPCODE_STALL (0x09<<27)
  101. #define OPCODE_CLRINT (0x1a<<27)
  102. #define OPCODE_JMP_RDY0 (0x19<<27)
  103. #define OPCODE_JMP_RDY1 ((0x19<<27)|(1<<26))
  104. #define JMP_IE_1 (1<<25)
  105. #define JMP_RDY_1 (1<<26)
  106. #define CLRINT_OPTYPE_READ_WRITE_1_CLEAR 0
  107. #define CLRINT_OPTYPE_READ_WRITE_0_CLEAR 1
  108. #define CLRINT_OPTYPE_READ_CLEAR 2
  109. #define VC8000E_FRAME_RDY_INT_MASK 0x0001
  110. #define VC8000E_CUTREE_RDY_INT_MASK 0x0002
  111. #define VC8000E_DEC400_INT_MASK 0x0004
  112. #define VC8000E_L2CACHE_INT_MASK 0x0008
  113. #define VC8000E_MMU_INT_MASK 0x0010
  114. #define VC8000D_FRAME_RDY_INT_MASK 0x0100
  115. #define VC8000D_DEC400_INT_MASK 0x0400
  116. #define VC8000D_L2CACHE_INT_MASK 0x0800
  117. #define VC8000D_MMU_INT_MASK 0x1000
  118. #endif
  119. #define HW_ID_1_0_C 0x43421001
  120. #define HW_ID_1_1_2 0x43421102
  121. #define ANY_CMDBUF_ID 0xFFFF
  122. /*module_type support*/
  123. enum vcmd_module_type{
  124. VCMD_TYPE_ENCODER = 0,
  125. VCMD_TYPE_CUTREE,
  126. VCMD_TYPE_DECODER,
  127. VCMD_TYPE_JPEG_ENCODER,
  128. VCMD_TYPE_JPEG_DECODER,
  129. MAX_VCMD_TYPE
  130. };
  131. struct cmdbuf_mem_parameter
  132. {
  133. u32 *virt_cmdbuf_addr;
  134. addr_t phy_cmdbuf_addr; //cmdbuf pool base physical address
  135. u32 mmu_phy_cmdbuf_addr; //cmdbuf pool base mmu mapping address
  136. u32 cmdbuf_total_size; //cmdbuf pool total size in bytes.
  137. u16 cmdbuf_unit_size; //one cmdbuf size in bytes. all cmdbuf have same size.
  138. u32 *virt_status_cmdbuf_addr;
  139. addr_t phy_status_cmdbuf_addr; //status cmdbuf pool base physical address
  140. u32 mmu_phy_status_cmdbuf_addr; //status cmdbuf pool base mmu mapping address
  141. u32 status_cmdbuf_total_size; //status cmdbuf pool total size in bytes.
  142. u16 status_cmdbuf_unit_size; //one status cmdbuf size in bytes. all status cmdbuf have same size.
  143. addr_t base_ddr_addr; //for pcie interface, hw can only access phy_cmdbuf_addr-pcie_base_ddr_addr.
  144. //for other interface, this value should be 0?
  145. };
  146. struct config_parameter
  147. {
  148. u16 module_type; //input vc8000e=0,cutree=1,vc8000d=2,jpege=3, jpegd=4
  149. u16 vcmd_core_num; //output, how many vcmd cores are there with corresponding module_type.
  150. u16 submodule_main_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
  151. u16 submodule_dec400_addr; //output ,if submodule addr == 0xffff, this submodule does not exist.
  152. u16 submodule_L2Cache_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
  153. u16 submodule_MMU_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
  154. u16 submodule_MMUWrite_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
  155. u16 submodule_axife_addr; //output,if submodule addr == 0xffff, this submodule does not exist.
  156. u16 config_status_cmdbuf_id; // output , this status comdbuf save the all register values read in driver init.//used for analyse configuration in cwl.
  157. u32 vcmd_hw_version_id;
  158. };
  159. /*need to consider how many memory should be allocated for status.*/
  160. struct exchange_parameter
  161. {
  162. u32 executing_time; //input ;executing_time=encoded_image_size*(rdoLevel+1)*(rdoq+1);
  163. u16 module_type; //input input vc8000e=0,IM=1,vc8000d=2, jpege=3, jpegd=4
  164. u16 cmdbuf_size; //input, reserve is not used; link and run is input.
  165. u16 priority; //input,normal=0, high/live=1
  166. u16 cmdbuf_id; //output, it is unique in driver.
  167. u16 core_id; //just used for polling.
  168. };
  169. #endif /* !_VC8000_VCMD_DRIVER_H_ */