jdi.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (c) 2018, Chips&Media
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  18. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef _JDI_HPI_H_
  26. #define _JDI_HPI_H_
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <stdarg.h>
  31. #ifdef USE_FEEDING_METHOD_BUFFER
  32. #include "codaj12/jpuapi/jpuconfig.h"
  33. #include "codaj12/jdi/mm.h"
  34. #include "codaj12/jpuapi/jputypes.h"
  35. #else
  36. #include "../jpuapi/jpuconfig.h"
  37. #include "mm.h"
  38. #include "jputypes.h"
  39. #endif
  40. #define MAX_JPU_BUFFER_POOL 32
  41. #define JpuWriteInstReg( INST_IDX, ADDR, DATA ) jdi_write_register( ((unsigned long)INST_IDX*NPT_REG_SIZE)+ADDR, DATA ) // system register write with instance index
  42. #define JpuReadInstReg( INST_IDX, ADDR ) jdi_read_register( ((unsigned long)INST_IDX*NPT_REG_SIZE)+ADDR ) // system register write with instance index
  43. #define JpuWriteReg( ADDR, DATA ) jdi_write_register( ADDR, DATA ) // system register write
  44. #define JpuReadReg( ADDR ) jdi_read_register( ADDR ) // system register write
  45. #define JpuWriteMem( ADDR, DATA, LEN, ENDIAN ) jdi_write_memory( ADDR, DATA, LEN, ENDIAN ) // system memory write
  46. #define JpuReadMem( ADDR, DATA, LEN, ENDIAN ) jdi_read_memory( ADDR, DATA, LEN, ENDIAN ) // system memory write
  47. typedef struct jpu_buffer_t {
  48. unsigned int size;
  49. unsigned long phys_addr;
  50. unsigned long base;
  51. unsigned long virt_addr;
  52. } jpu_buffer_t;
  53. typedef struct jpu_instance_pool_t {
  54. unsigned char jpgInstPool[MAX_NUM_INSTANCE][MAX_INST_HANDLE_SIZE];
  55. Int32 jpu_instance_num;
  56. BOOL instance_pool_inited;
  57. void* instPendingInst[MAX_NUM_INSTANCE];
  58. jpeg_mm_t vmem;
  59. } jpu_instance_pool_t;
  60. typedef enum {
  61. JDI_LITTLE_ENDIAN = 0,
  62. JDI_BIG_ENDIAN,
  63. JDI_32BIT_LITTLE_ENDIAN,
  64. JDI_32BIT_BIG_ENDIAN,
  65. } EndianMode;
  66. typedef enum {
  67. JDI_LOG_CMD_PICRUN = 0,
  68. JDI_LOG_CMD_INIT = 1,
  69. JDI_LOG_CMD_RESET = 2,
  70. JDI_LOG_CMD_PAUSE_INST_CTRL = 3,
  71. JDI_LOG_CMD_MAX
  72. } jdi_log_cmd;
  73. #if defined (__cplusplus)
  74. extern "C" {
  75. #endif
  76. int jdi_probe();
  77. /* @brief It returns the number of task using JDI.
  78. */
  79. int jdi_get_task_num();
  80. int jdi_init();
  81. int jdi_release(); //this function may be called only at system off.
  82. jpu_instance_pool_t *jdi_get_instance_pool();
  83. int jdi_allocate_dma_memory(jpu_buffer_t *vb);
  84. void jdi_free_dma_memory(jpu_buffer_t *vb);
  85. int jdi_wait_interrupt(int timeout, unsigned int addr_int_reason, unsigned long instIdx);
  86. int jdi_hw_reset();
  87. int jdi_wait_inst_ctrl_busy(int timeout, unsigned int addr_flag_reg, unsigned int flag);
  88. int jdi_set_clock_gate(int enable);
  89. int jdi_get_clock_gate();
  90. int jdi_open_instance(unsigned long instIdx);
  91. int jdi_close_instance(unsigned long instIdx);
  92. int jdi_get_instance_num();
  93. void jdi_write_register(unsigned long addr, unsigned long data);
  94. unsigned long jdi_read_register(unsigned long addr);
  95. int jdi_write_memory(unsigned long addr, unsigned char *data, int len, int endian);
  96. int jdi_read_memory(unsigned long addr, unsigned char *data, int len, int endian);
  97. int jdi_attach_dma_memory(jpu_buffer_t *vb);
  98. int jdi_lock();
  99. void jdi_unlock();
  100. void jdi_log(int cmd, int step, int inst);
  101. void jdi_flush_ddr(unsigned long start,unsigned long size,unsigned char flag);
  102. #define ACLK_MAX 300
  103. #define ACLK_MIN 16
  104. #define CCLK_MAX 300
  105. #define CCLK_MIN 16
  106. #if defined (__cplusplus)
  107. }
  108. #endif
  109. #endif //#ifndef _JDI_HPI_H_