vpu.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: LGPL-2.1 OR BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2022, 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. * Copyright (C) 2022 StarFive Technology Co., Ltd.
  27. */
  28. #ifndef __VPU_DRV_H__
  29. #define __VPU_DRV_H__
  30. #include <linux/fs.h>
  31. #include <linux/types.h>
  32. #include "../../../vpuapi/vpuconfig.h"
  33. #define USE_VMALLOC_FOR_INSTANCE_POOL_MEMORY
  34. #define VDI_IOCTL_MAGIC 'V'
  35. #define VDI_IOCTL_ALLOCATE_PHYSICAL_MEMORY _IO(VDI_IOCTL_MAGIC, 0)
  36. #define VDI_IOCTL_FREE_PHYSICALMEMORY _IO(VDI_IOCTL_MAGIC, 1)
  37. #define VDI_IOCTL_WAIT_INTERRUPT _IO(VDI_IOCTL_MAGIC, 2)
  38. #define VDI_IOCTL_SET_CLOCK_GATE _IO(VDI_IOCTL_MAGIC, 3)
  39. #define VDI_IOCTL_RESET _IO(VDI_IOCTL_MAGIC, 4)
  40. #define VDI_IOCTL_GET_INSTANCE_POOL _IO(VDI_IOCTL_MAGIC, 5)
  41. #define VDI_IOCTL_GET_COMMON_MEMORY _IO(VDI_IOCTL_MAGIC, 6)
  42. #define VDI_IOCTL_GET_RESERVED_VIDEO_MEMORY_INFO _IO(VDI_IOCTL_MAGIC, 8)
  43. #define VDI_IOCTL_OPEN_INSTANCE _IO(VDI_IOCTL_MAGIC, 9)
  44. #define VDI_IOCTL_CLOSE_INSTANCE _IO(VDI_IOCTL_MAGIC, 10)
  45. #define VDI_IOCTL_GET_INSTANCE_NUM _IO(VDI_IOCTL_MAGIC, 11)
  46. #define VDI_IOCTL_GET_REGISTER_INFO _IO(VDI_IOCTL_MAGIC, 12)
  47. #define VDI_IOCTL_GET_FREE_MEM_SIZE _IO(VDI_IOCTL_MAGIC, 13)
  48. #define VDI_IOCTL_FLUSH_DCACHE _IO(VDI_IOCTL_MAGIC, 14)
  49. #define VDI_IOCTL_GET_PHYSICAL_MEMORY _IO(VDI_IOCTL_MAGIC, 15)
  50. #define VDI_IOCTL_CPUFREQ_SAVEENV _IO(VDI_IOCTL_MAGIC, 16)
  51. #define VDI_IOCTL_CPUFREQ_PUTENV _IO(VDI_IOCTL_MAGIC, 17)
  52. #define DRAM_MEM2SYS(addr) ((addr) > 0x40000000 && (addr) < 0x43FFFFFFF ? ((addr)+0x400000000):(addr))
  53. #define ioremap_nocache ioremap
  54. typedef struct vpudrv_flush_cache_t {
  55. unsigned long start;
  56. unsigned long size;
  57. unsigned char flag;
  58. } vpudrv_flush_cache_t;
  59. typedef struct vpudrv_buffer_t {
  60. unsigned int size;
  61. unsigned long phys_addr;
  62. unsigned long base; /* kernel logical address in use kernel */
  63. unsigned long virt_addr; /* virtual user space address */
  64. } vpudrv_buffer_t;
  65. typedef struct vpu_bit_firmware_info_t {
  66. unsigned int size; /* size of this structure*/
  67. unsigned int core_idx;
  68. unsigned long reg_base_offset;
  69. unsigned short bit_code[512];
  70. } vpu_bit_firmware_info_t;
  71. typedef struct vpudrv_inst_info_t {
  72. unsigned int core_idx;
  73. unsigned int inst_idx;
  74. int inst_open_count; /* for output only*/
  75. } vpudrv_inst_info_t;
  76. typedef struct vpudrv_intr_info_t {
  77. unsigned int timeout;
  78. int intr_reason;
  79. #ifdef SUPPORT_MULTI_INST_INTR
  80. int intr_inst_index;
  81. #endif
  82. } vpudrv_intr_info_t;
  83. #endif