scale.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #ifndef __SCALE_H__
  2. #define __SCALE_H__
  3. #include <linux/list.h>
  4. #include <linux/clk.h>
  5. typedef unsigned char u8_t;
  6. typedef unsigned short u16_t;
  7. typedef unsigned int u32_t;
  8. #define AXI_SCALE_EN 0x0
  9. #define AXI_SCALE_WB_START 0x4
  10. #define AXI_SCALE_CONTROL 0x8
  11. #define AXI_SCALE_VIDEO_ADDR1 0xC
  12. #define AXI_SCALE_VIDEO_ADDR2 0x10
  13. #define AXI_SCALE_VIDEO_ADDR3 0x14
  14. #define AXI_SCALE_VIDEO_SOURCE_SIZE 0x18
  15. #define AXI_SCALE_VIDEO_WINDOW_POINT 0x1c
  16. #define AXI_SCALE_VIDEO_WINDOW_SIZE 0x20
  17. #define AXI_SCALE_VIDEO_SIZE 0x24
  18. #define AXI_SCALE_SCALE_CTL 0x28
  19. #define AXI_SCALE_SCALE_VXMOD 0x2c
  20. #define AXI_SCALE_SCALE_CTL0 0x30
  21. #define AXI_SCALE_SCALE_CTL1 0x34
  22. #define AXI_SCALE_RIGHT_BOTTOM_CUT_NUM 0x38
  23. #define AXI_SCALE_SCALE_CTL2 0x3c
  24. #define AXI_SCALE_SCALE_CTL3 0x40
  25. #define AXI_SCALE_SCALE_CTL4 0x44
  26. #define AXI_SCALE_HSCAL_COS_VALUE 0x48
  27. #define AXI_SCALE_WB_DEST_YADDR 0x4c
  28. #define AXI_SCALE_WB_DEST_UADDR 0x50
  29. #define AXI_SCALE_WB_DEST_VADDR 0x54
  30. #define AXI_SCALE_WB_DATA_HSIZE_RAM 0x58
  31. #define AXI_SCALE_RESERVED 0x5c
  32. #define AXI_SCALE_INT_CTL 0x60
  33. #define AXI_SCALE_INT_STATUS 0x64
  34. #define AXI_SCALE_CLCD_INT_CLR 0x68
  35. #define AXI_SCALE_WR_Y_VCNT 0x6C
  36. #define AXI_SCALE_WR_UV_VCNT 0x70
  37. /* for ark1668e as follows. */
  38. #define AXI_SCALE_VFILTER_CLR 0x70
  39. #define AXI_SCALE_VFILTER_COEFF 0x74
  40. //Rotate Register
  41. #define AXI_SCALE_ROTATA_CTL 0x78
  42. #define AXI_SCALE_ROTATA_IMG_SIZE 0x7C
  43. #define AXI_SCALE_ROTATA_Y_FADR 0x80
  44. #define AXI_SCALE_ROTATA_C_FADR 0x84
  45. #define AXI_SCALE_ROTATA_CTL_REG 0x88
  46. #define AXI_SCALE_ROTYX_WIDTH 0x4C
  47. #define AXI_SCALE_ROTCX_FADR 0x50
  48. //Peaking&Denoise Register
  49. #define AXI_SCALE_PD_CTL1 0x8c
  50. #define AXI_SCALE_PD_CTL2 0x90
  51. #define AXI_SCALE_DENOISE_CTL3 0x94
  52. #define AXI_SCALE_PEAKING_CTL4 0x98
  53. #define AXI_SCALE_PEAKING_CTL5 0x9C
  54. #define AXI_SCALE_PEAKING_CTL6 0xA0
  55. /*************************************************************************
  56. * Ioctl command definition
  57. *************************************************************************/
  58. #define SCALE_IOCTL_BASE 0x99
  59. //Only for compate arkn141 scale interface. You'd better not use the old one, please use new SCALE_IOCTL_START.
  60. #define ARKN141_SCALE_IOCTL_START_OLD _IOW(SCALE_IOCTL_BASE, 0, struct ark_scale_param_old)
  61. #define SCALE_IOCTL_START _IOW(SCALE_IOCTL_BASE, 0, struct ark_scale_param)
  62. #define SCALE_IOCTL_START_NO_WAIT _IOW(SCALE_IOCTL_BASE, 1, struct ark_scale_param)
  63. #define SCALE_IOCTL_WAIT_IDLE _IO(SCALE_IOCTL_BASE, 2)
  64. #define SCALE_IOCTL_GET_BUSY_SYATUS _IOR(SCALE_IOCTL_BASE, 3, int)
  65. enum {
  66. SOC_TYPE_ARKN141,
  67. SOC_TYPE_ARK1668,
  68. SOC_TYPE_ARK1668E,
  69. SOC_TYPE_END
  70. };
  71. typedef enum ark_scale_rotate{
  72. SCALE_ROTATE_0,
  73. SCALE_ROTATE_90,
  74. SCALE_ROTATE_180,
  75. SCALE_ROTATE_270,
  76. SCALE_ROTATE_0_MIRROR,
  77. SCALE_ROTATE_90_MIRROR,
  78. SCALE_ROTATE_180_MIRROR,
  79. SCALE_ROTATE_270_MIRROR,
  80. SCALE_ROTATE_END
  81. }scalar_rotate;
  82. enum scale_result {
  83. SCALE_RET_OK = 0,
  84. SCALE_RET_TIMEOUT = 1,
  85. SCALE_RET_INV_PARA = 2,
  86. SCALE_RET_DATA_ERROR = 2,
  87. SCALE_RET_HW_ERROR = 4,
  88. SCALE_RET_SYSTEM_ERROR = 5,
  89. SCALE_RET_HW_RESET = 6,
  90. SCALE_RET_FAILED = 7,
  91. SCALE_RET_MALLOC_FAILED = 8,
  92. SCALE_RET_COMPARE_NG = 9
  93. };
  94. typedef enum ark_scalar_format {
  95. SCALE_FORMAT_YUV422 = 0,
  96. SCALE_FORMAT_Y_UV422 = (1 << 8) | SCALE_FORMAT_YUV422,
  97. SCALE_FORMAT_YUV420 = 1,
  98. SCALE_FORMAT_Y_UV420 = (1 << 8) | SCALE_FORMAT_YUV420,
  99. SCALE_FORMAT_YUYV = 2,
  100. SCALE_FORMAT_YVYU = (1 << 8) | SCALE_FORMAT_YUYV,
  101. SCALE_FORMAT_UYVY = (2 << 8) | SCALE_FORMAT_YUYV,
  102. SCALE_FORMAT_VYUY = (3 << 8) | SCALE_FORMAT_YUYV,
  103. SCALE_FORMAT_YUV = 3,
  104. }scalar_in_format;
  105. typedef enum ark_scalar_output_format {
  106. SCALE_OUT_FORMAT_Y_UV422 = (1 << 8) | SCALE_FORMAT_YUV422,
  107. SCALE_OUT_FORMAT_Y_UV420 = (1 << 8) | SCALE_FORMAT_YUV420,
  108. SCALE_OUT_FORMAT_YUYV = 2,
  109. SCALE_OUT_FORMAT_END
  110. }scalar_out_format;
  111. #define scalar_in_format unsigned int
  112. #define scalar_out_format unsigned int
  113. #define scalar_rotate unsigned int
  114. struct ark_scale_param {
  115. unsigned int iyaddr;
  116. unsigned int iuaddr;
  117. unsigned int ivaddr;
  118. scalar_in_format iformat;
  119. unsigned int iwidth;
  120. unsigned int iheight;
  121. unsigned int ix;
  122. unsigned int iy;
  123. unsigned int iwinwidth;
  124. unsigned int iwinheight;
  125. unsigned int left_cut;
  126. unsigned int right_cut;
  127. unsigned int up_cut;
  128. unsigned int bottom_cut;
  129. unsigned int owidth;
  130. unsigned int oheight;
  131. unsigned int oyaddr;
  132. unsigned int ouaddr;
  133. unsigned int ovaddr;
  134. scalar_out_format oformat; //Only ark1668e.
  135. scalar_rotate rotate; //Only ark1668e.
  136. };
  137. #if 1//You had better do not use it. Only for compatible for arkn141.
  138. struct ark_scale_param_old {
  139. unsigned int iyaddr;
  140. unsigned int iuaddr;
  141. unsigned int ivaddr;
  142. unsigned int iformat;
  143. unsigned int iwidth;
  144. unsigned int iheight;
  145. unsigned int ix;
  146. unsigned int iy;
  147. unsigned int iwinwidth;
  148. unsigned int iwinheight;
  149. unsigned int left_cut;
  150. unsigned int right_cut;
  151. unsigned int up_cut;
  152. unsigned int bottom_cut;
  153. unsigned int owidth;
  154. unsigned int oheight;
  155. unsigned int oyaddr;
  156. unsigned int ouaddr;
  157. unsigned int ovaddr;
  158. };
  159. #endif
  160. struct ark_scale_context {
  161. int irq;
  162. struct device *dev;
  163. void __iomem *mmio_base;
  164. void __iomem *sys_base;
  165. struct clk *clk;
  166. spinlock_t lock;
  167. wait_queue_head_t waitq;
  168. int busy;
  169. int softreset_reg;
  170. int softreset_offset;
  171. int soc_type;
  172. struct semaphore scale_sem;
  173. };
  174. struct ark_scale_device {
  175. const char *driver_name;
  176. const char *name;
  177. int major;
  178. int minor_start;
  179. int minor_num;
  180. int num;
  181. int irq;
  182. struct cdev cdev;
  183. struct class *scale_class;
  184. struct device *scale_device;
  185. struct fasync_struct *async_queue_wb;
  186. struct ark_scale_context context;
  187. };
  188. int ark_scale_start(struct ark_scale_context *context, struct ark_scale_param *param);
  189. int ark_scale_start_nowait(struct ark_scale_context *context, struct ark_scale_param *param);
  190. int ark_scale_wait_idle(struct ark_scale_context *context);
  191. int ark_scale_get_busy_status(struct ark_scale_context *context);
  192. int ark_scale_dev_init(struct ark_scale_context *context);
  193. irqreturn_t ark_scale_intr_handler(int irq, void *dev_id);
  194. #endif