jdi.h 4.8 KB

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