hx170dec.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Decoder device driver (kernel module headers)
  3. *
  4. * Copyright (C) 2009 Hantro Products Oy.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef _HX170DEC_H_
  20. #define _HX170DEC_H_
  21. #include <linux/ioctl.h>
  22. #include <linux/types.h>
  23. struct core_desc
  24. {
  25. __u32 id; /* id of the core */
  26. __u32 *regs; /* pointer to user registers */
  27. __u32 size; /* size of register space */
  28. };
  29. /* Use 'k' as magic number */
  30. #define HX170DEC_IOC_MAGIC 'k'
  31. /*
  32. * S means "Set" through a ptr,
  33. * T means "Tell" directly with the argument value
  34. * G means "Get": reply by setting through a pointer
  35. * Q means "Query": response is on the return value
  36. * X means "eXchange": G and S atomically
  37. * H means "sHift": T and Q atomically
  38. */
  39. #define HX170DEC_IOCGHWOFFSET _IOR(HX170DEC_IOC_MAGIC, 3, unsigned long *)
  40. #define HX170DEC_IOCGHWIOSIZE _IOR(HX170DEC_IOC_MAGIC, 4, unsigned int *)
  41. #define HX170DEC_IOC_MC_OFFSETS _IOR(HX170DEC_IOC_MAGIC, 7, unsigned long *)
  42. #define HX170DEC_IOC_MC_CORES _IOR(HX170DEC_IOC_MAGIC, 8, unsigned int *)
  43. #define HX170DEC_IOCS_DEC_PUSH_REG _IOW(HX170DEC_IOC_MAGIC, 9, struct core_desc *)
  44. #define HX170DEC_IOCS_PP_PUSH_REG _IOW(HX170DEC_IOC_MAGIC, 10, struct core_desc *)
  45. #define HX170DEC_IOCH_DEC_RESERVE _IO(HX170DEC_IOC_MAGIC, 11)
  46. #define HX170DEC_IOCT_DEC_RELEASE _IO(HX170DEC_IOC_MAGIC, 12)
  47. #define HX170DEC_IOCQ_PP_RESERVE _IO(HX170DEC_IOC_MAGIC, 13)
  48. #define HX170DEC_IOCT_PP_RELEASE _IO(HX170DEC_IOC_MAGIC, 14)
  49. #define HX170DEC_IOCX_DEC_WAIT _IOWR(HX170DEC_IOC_MAGIC, 15, struct core_desc *)
  50. #define HX170DEC_IOCX_PP_WAIT _IOWR(HX170DEC_IOC_MAGIC, 16, struct core_desc *)
  51. #define HX170DEC_IOCS_DEC_PULL_REG _IOWR(HX170DEC_IOC_MAGIC, 17, struct core_desc *)
  52. #define HX170DEC_IOCS_PP_PULL_REG _IOWR(HX170DEC_IOC_MAGIC, 18, struct core_desc *)
  53. #define HX170DEC_IOX_ASIC_ID _IOWR(HX170DEC_IOC_MAGIC, 20, __u32 *)
  54. /*
  55. * Following are not used yet:
  56. *
  57. * #define HX170DEC_PP_INSTANCE _IO(HX170DEC_IOC_MAGIC, 1)
  58. * #define HX170DEC_HW_PERFORMANCE _IO(HX170DEC_IOC_MAGIC, 2)
  59. * #define HX170DEC_IOC_CLI _IO(HX170DEC_IOC_MAGIC, 5)
  60. * #define HX170DEC_IOC_STI _IO(HX170DEC_IOC_MAGIC, 6)
  61. * #define HX170DEC_IOCG_CORE_WAIT _IOR(HX170DEC_IOC_MAGIC, 19, int *)
  62. * #define HX170DEC_DEBUG_STATUS _IO(HX170DEC_IOC_MAGIC, 29)
  63. */
  64. #define HX170DEC_IOC_MAXNR 29
  65. //mfc 中jpeg解码
  66. struct mfc_jpeg_context {
  67. struct device *dev;
  68. unsigned int intr_status;
  69. unsigned int file_size;
  70. unsigned int src_width;
  71. unsigned int src_height;
  72. unsigned int out_width;
  73. unsigned int out_height;
  74. unsigned int format;
  75. int read_buf_mode;
  76. int anmation_stats;
  77. unsigned int dst_width;
  78. unsigned int dst_height;
  79. void *buf_base_virt;
  80. unsigned int buf_base_phys;
  81. unsigned int buf_size;
  82. void *decode_buf_base_virt;
  83. unsigned int decode_buf_base_phys;
  84. unsigned int decode_buf_size;
  85. unsigned int repeat_scaler;
  86. unsigned int repeat_src_width;
  87. unsigned int repeat_src_height;
  88. unsigned int repeat_src_image_addr;
  89. unsigned int animation_data_phyaddr;
  90. unsigned int animation_data_virtaddr;
  91. unsigned int animation_data_size;
  92. unsigned int animation_display_phyaddr;
  93. unsigned int animation_display_virtaddr;
  94. unsigned int animation_display_size;
  95. unsigned int animation_display_index;
  96. unsigned int animation_file_phyaddr;
  97. unsigned int animation_file_virtaddr;
  98. struct work_struct animation_work;
  99. struct workqueue_struct *animation_queue;
  100. struct timer_list animation_timer;
  101. bool animation_end;
  102. bool animation_dec_finish;
  103. bool animation_initdisplay;
  104. };
  105. #define VDEC_MAX_CORES 1 /* number of cores of the hardware IP */
  106. #define VDEC_NUM_REGS_DEC 60 /* number of registers of the Decoder part */
  107. #define VDEC_NUM_REGS_PP 41 /* number of registers of the Post Processor part */
  108. #define VDEC_DEC_FIRST_REG 0 /* first register (0-based) index */
  109. #define VDEC_DEC_LAST_REG 59 /* last register (0-based) index */
  110. #define VDEC_PP_FIRST_REG 60
  111. #define VDEC_PP_LAST_REG 100
  112. struct vdec_device {
  113. void __iomem *mmio_base;
  114. struct clk *clk;
  115. struct device *dev;
  116. int irq;
  117. int num_cores;
  118. unsigned long iobaseaddr;
  119. unsigned long iosize;
  120. wait_queue_head_t dec_wq;
  121. wait_queue_head_t pp_wq;
  122. bool dec_irq_done;
  123. bool pp_irq_done;
  124. struct semaphore dec_sem;
  125. struct semaphore pp_sem;
  126. struct file *dec_owner;
  127. struct file *pp_owner;
  128. u32 regs[VDEC_NUM_REGS_DEC + VDEC_NUM_REGS_PP];
  129. struct mfc_jpeg_context context;
  130. };
  131. #endif /* !_HX170DEC_H_ */