jpu.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 __JPU_DRV_H__
  29. #define __JPU_DRV_H__
  30. #include <linux/fs.h>
  31. #include <linux/types.h>
  32. #define JDI_IOCTL_MAGIC 'J'
  33. #define JDI_IOCTL_ALLOCATE_PHYSICAL_MEMORY _IO(JDI_IOCTL_MAGIC, 0)
  34. #define JDI_IOCTL_FREE_PHYSICALMEMORY _IO(JDI_IOCTL_MAGIC, 1)
  35. #define JDI_IOCTL_WAIT_INTERRUPT _IO(JDI_IOCTL_MAGIC, 2)
  36. #define JDI_IOCTL_SET_CLOCK_GATE _IO(JDI_IOCTL_MAGIC, 3)
  37. #define JDI_IOCTL_RESET _IO(JDI_IOCTL_MAGIC, 4)
  38. #define JDI_IOCTL_GET_INSTANCE_POOL _IO(JDI_IOCTL_MAGIC, 5)
  39. #define JDI_IOCTL_GET_RESERVED_VIDEO_MEMORY_INFO _IO(JDI_IOCTL_MAGIC, 6)
  40. #define JDI_IOCTL_GET_REGISTER_INFO _IO(JDI_IOCTL_MAGIC, 7)
  41. #define JDI_IOCTL_OPEN_INSTANCE _IO(JDI_IOCTL_MAGIC, 8)
  42. #define JDI_IOCTL_CLOSE_INSTANCE _IO(JDI_IOCTL_MAGIC, 9)
  43. #define JDI_IOCTL_GET_INSTANCE_NUM _IO(JDI_IOCTL_MAGIC, 10)
  44. #define JDI_IOCTL_FLUSH_DCACHE _IO(JDI_IOCTL_MAGIC, 11)
  45. #define JDI_IOCTL_GET_PHYSICAL_MEMORY _IO(JDI_IOCTL_MAGIC, 12)
  46. #define MEM2SYS(addr) ((addr) > 0x40000000 && (addr) < 0x240000000 ? ((addr)+0x400000000):(addr))
  47. #ifndef PTHREAD_MUTEX_ROBUST_NP
  48. #define PTHREAD_MUTEX_ROBUST_NP 1
  49. #endif
  50. typedef struct jpudrv_flush_cache_t {
  51. unsigned long start;
  52. unsigned long size;
  53. unsigned char flag;
  54. } jpudrv_flush_cache_t;
  55. typedef struct jpudrv_buffer_t {
  56. unsigned int size;
  57. unsigned long phys_addr;
  58. unsigned long base; /* kernel logical address in use kernel */
  59. unsigned long virt_addr; /* virtual user space address */
  60. } jpudrv_buffer_t;
  61. typedef struct jpudrv_inst_info_t {
  62. unsigned int inst_idx;
  63. int inst_open_count; /* for output only*/
  64. } jpudrv_inst_info_t;
  65. typedef struct jpudrv_intr_info_t {
  66. unsigned int timeout;
  67. int intr_reason;
  68. unsigned int inst_idx;
  69. } jpudrv_intr_info_t;
  70. #endif