scale.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #define AXI_SCALE_VFILTER_CLR 0x70
  38. #define AXI_SCALE_VFILTER_COEFF 0x74
  39. #define AXI_SCALE_VBY_SEL 0x78
  40. struct ark_scale_context {
  41. int irq;
  42. struct device *dev;
  43. void __iomem *mmio_base;
  44. void __iomem *sys_base;
  45. struct clk *clk;
  46. spinlock_t lock;
  47. wait_queue_head_t waitq;
  48. int busy;
  49. };
  50. struct ark_scale_device {
  51. const char *driver_name;
  52. const char *name;
  53. int major;
  54. int minor_start;
  55. int minor_num;
  56. int num;
  57. int irq;
  58. struct cdev cdev;
  59. struct class *scale_class;
  60. struct device *scale_device;
  61. struct fasync_struct *async_queue_wb;
  62. struct ark_scale_context context;
  63. };
  64. struct ark_scale_param {
  65. unsigned int iyaddr;
  66. unsigned int iuaddr;
  67. unsigned int ivaddr;
  68. unsigned int iformat;
  69. unsigned int iwidth;
  70. unsigned int iheight;
  71. unsigned int ix;
  72. unsigned int iy;
  73. unsigned int iwinwidth;
  74. unsigned int iwinheight;
  75. unsigned int left_cut;
  76. unsigned int right_cut;
  77. unsigned int up_cut;
  78. unsigned int bottom_cut;
  79. unsigned int owidth;
  80. unsigned int oheight;
  81. unsigned int oyaddr;
  82. unsigned int ouaddr;
  83. unsigned int ovaddr;
  84. };
  85. enum scale_result {
  86. SCALE_RET_OK = 0,
  87. SCALE_RET_TIMEOUT = 1,
  88. SCALE_RET_INV_PARA = 2,
  89. SCALE_RET_DATA_ERROR = 2,
  90. SCALE_RET_HW_ERROR = 4,
  91. SCALE_RET_SYSTEM_ERROR = 5,
  92. SCALE_RET_HW_RESET = 6,
  93. SCALE_RET_FAILED = 7,
  94. SCALE_RET_MALLOC_FAILED = 8,
  95. SCALE_RET_COMPARE_NG = 9
  96. };
  97. enum scale_format {
  98. SCALE_FORMAT_YUV422 = 0,
  99. SCALE_FORMAT_Y_UV422 = (1 << 8) | SCALE_FORMAT_YUV422,
  100. SCALE_FORMAT_YUV420 = 1,
  101. SCALE_FORMAT_Y_UV420 = (1 << 8) | SCALE_FORMAT_YUV420,
  102. SCALE_FORMAT_YUYV = 2,
  103. SCALE_FORMAT_YVYU = (1 << 8) | SCALE_FORMAT_YUYV,
  104. SCALE_FORMAT_UYVY = (2 << 8) | SCALE_FORMAT_YUYV,
  105. SCALE_FORMAT_VYUY = (3 << 8) | SCALE_FORMAT_YUYV,
  106. SCALE_FORMAT_YUV = 3,
  107. };
  108. /*************************************************************************
  109. * Ioctl command definition
  110. *************************************************************************/
  111. #define SCALE_IOCTL_BASE 0x99
  112. #define SCALE_IOCTL_START _IOW(SCALE_IOCTL_BASE, 0, struct ark_scale_param)
  113. #define SCALE_IOCTL_START_NO_WAIT _IOW(SCALE_IOCTL_BASE, 1, struct ark_scale_param)
  114. #define SCALE_IOCTL_WAIT_IDLE _IO(SCALE_IOCTL_BASE, 2)
  115. #define SCALE_IOCTL_START_4CH_DISPLAY _IOW(SCALE_IOCTL_BASE, 3, struct ark_scale_param)
  116. void scale_softreset(struct ark_scale_context *context);
  117. int ark_scale_start(struct ark_scale_context *context, struct ark_scale_param *param);
  118. int ark_scale_start_nowait(struct ark_scale_context *context, struct ark_scale_param *param);
  119. int ark_scale_4ch_display(struct ark_scale_context *context, struct ark_scale_param *param, int display_width);
  120. int ark_scale_wait_idle(struct ark_scale_context *context);
  121. int ark_scale_dev_init(struct ark_scale_context *context);
  122. irqreturn_t ark_scale_intr_handler(int irq, void *dev_id);
  123. #endif