sc.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * Copyright (c) 2013 Texas Instruments Inc.
  3. *
  4. * David Griego, <dagriego@biglakesoftware.com>
  5. * Dale Farnsworth, <dale@farnsworth.org>
  6. * Archit Taneja, <archit@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published by
  10. * the Free Software Foundation.
  11. */
  12. #ifndef TI_SC_H
  13. #define TI_SC_H
  14. /* Scaler regs */
  15. #define CFG_SC0 0x0
  16. #define CFG_INTERLACE_O (1 << 0)
  17. #define CFG_LINEAR (1 << 1)
  18. #define CFG_SC_BYPASS (1 << 2)
  19. #define CFG_INVT_FID (1 << 3)
  20. #define CFG_USE_RAV (1 << 4)
  21. #define CFG_ENABLE_EV (1 << 5)
  22. #define CFG_AUTO_HS (1 << 6)
  23. #define CFG_DCM_2X (1 << 7)
  24. #define CFG_DCM_4X (1 << 8)
  25. #define CFG_HP_BYPASS (1 << 9)
  26. #define CFG_INTERLACE_I (1 << 10)
  27. #define CFG_ENABLE_SIN2_VER_INTP (1 << 11)
  28. #define CFG_Y_PK_EN (1 << 14)
  29. #define CFG_TRIM (1 << 15)
  30. #define CFG_SELFGEN_FID (1 << 16)
  31. #define CFG_SC1 0x4
  32. #define CFG_ROW_ACC_INC_MASK 0x07ffffff
  33. #define CFG_ROW_ACC_INC_SHIFT 0
  34. #define CFG_SC2 0x08
  35. #define CFG_ROW_ACC_OFFSET_MASK 0x0fffffff
  36. #define CFG_ROW_ACC_OFFSET_SHIFT 0
  37. #define CFG_SC3 0x0c
  38. #define CFG_ROW_ACC_OFFSET_B_MASK 0x0fffffff
  39. #define CFG_ROW_ACC_OFFSET_B_SHIFT 0
  40. #define CFG_SC4 0x10
  41. #define CFG_TAR_H_MASK 0x07ff
  42. #define CFG_TAR_H_SHIFT 0
  43. #define CFG_TAR_W_MASK 0x07ff
  44. #define CFG_TAR_W_SHIFT 12
  45. #define CFG_LIN_ACC_INC_U_MASK 0x07
  46. #define CFG_LIN_ACC_INC_U_SHIFT 24
  47. #define CFG_NLIN_ACC_INIT_U_MASK 0x07
  48. #define CFG_NLIN_ACC_INIT_U_SHIFT 28
  49. #define CFG_SC5 0x14
  50. #define CFG_SRC_H_MASK 0x07ff
  51. #define CFG_SRC_H_SHIFT 0
  52. #define CFG_SRC_W_MASK 0x07ff
  53. #define CFG_SRC_W_SHIFT 12
  54. #define CFG_NLIN_ACC_INC_U_MASK 0x07
  55. #define CFG_NLIN_ACC_INC_U_SHIFT 24
  56. #define CFG_SC6 0x18
  57. #define CFG_ROW_ACC_INIT_RAV_MASK 0x03ff
  58. #define CFG_ROW_ACC_INIT_RAV_SHIFT 0
  59. #define CFG_ROW_ACC_INIT_RAV_B_MASK 0x03ff
  60. #define CFG_ROW_ACC_INIT_RAV_B_SHIFT 10
  61. #define CFG_SC8 0x20
  62. #define CFG_NLIN_LEFT_MASK 0x07ff
  63. #define CFG_NLIN_LEFT_SHIFT 0
  64. #define CFG_NLIN_RIGHT_MASK 0x07ff
  65. #define CFG_NLIN_RIGHT_SHIFT 12
  66. #define CFG_SC9 0x24
  67. #define CFG_LIN_ACC_INC CFG_SC9
  68. #define CFG_SC10 0x28
  69. #define CFG_NLIN_ACC_INIT CFG_SC10
  70. #define CFG_SC11 0x2c
  71. #define CFG_NLIN_ACC_INC CFG_SC11
  72. #define CFG_SC12 0x30
  73. #define CFG_COL_ACC_OFFSET_MASK 0x01ffffff
  74. #define CFG_COL_ACC_OFFSET_SHIFT 0
  75. #define CFG_SC13 0x34
  76. #define CFG_SC_FACTOR_RAV_MASK 0xff
  77. #define CFG_SC_FACTOR_RAV_SHIFT 0
  78. #define CFG_CHROMA_INTP_THR_MASK 0x03ff
  79. #define CFG_CHROMA_INTP_THR_SHIFT 12
  80. #define CFG_DELTA_CHROMA_THR_MASK 0x0f
  81. #define CFG_DELTA_CHROMA_THR_SHIFT 24
  82. #define CFG_SC17 0x44
  83. #define CFG_EV_THR_MASK 0x03ff
  84. #define CFG_EV_THR_SHIFT 12
  85. #define CFG_DELTA_LUMA_THR_MASK 0x0f
  86. #define CFG_DELTA_LUMA_THR_SHIFT 24
  87. #define CFG_DELTA_EV_THR_MASK 0x0f
  88. #define CFG_DELTA_EV_THR_SHIFT 28
  89. #define CFG_SC18 0x48
  90. #define CFG_HS_FACTOR_MASK 0x03ff
  91. #define CFG_HS_FACTOR_SHIFT 0
  92. #define CFG_CONF_DEFAULT_MASK 0x01ff
  93. #define CFG_CONF_DEFAULT_SHIFT 16
  94. #define CFG_SC19 0x4c
  95. #define CFG_HPF_COEFF0_MASK 0xff
  96. #define CFG_HPF_COEFF0_SHIFT 0
  97. #define CFG_HPF_COEFF1_MASK 0xff
  98. #define CFG_HPF_COEFF1_SHIFT 8
  99. #define CFG_HPF_COEFF2_MASK 0xff
  100. #define CFG_HPF_COEFF2_SHIFT 16
  101. #define CFG_HPF_COEFF3_MASK 0xff
  102. #define CFG_HPF_COEFF3_SHIFT 23
  103. #define CFG_SC20 0x50
  104. #define CFG_HPF_COEFF4_MASK 0xff
  105. #define CFG_HPF_COEFF4_SHIFT 0
  106. #define CFG_HPF_COEFF5_MASK 0xff
  107. #define CFG_HPF_COEFF5_SHIFT 8
  108. #define CFG_HPF_NORM_SHIFT_MASK 0x07
  109. #define CFG_HPF_NORM_SHIFT_SHIFT 16
  110. #define CFG_NL_LIMIT_MASK 0x1ff
  111. #define CFG_NL_LIMIT_SHIFT 20
  112. #define CFG_SC21 0x54
  113. #define CFG_NL_LO_THR_MASK 0x01ff
  114. #define CFG_NL_LO_THR_SHIFT 0
  115. #define CFG_NL_LO_SLOPE_MASK 0xff
  116. #define CFG_NL_LO_SLOPE_SHIFT 16
  117. #define CFG_SC22 0x58
  118. #define CFG_NL_HI_THR_MASK 0x01ff
  119. #define CFG_NL_HI_THR_SHIFT 0
  120. #define CFG_NL_HI_SLOPE_SH_MASK 0x07
  121. #define CFG_NL_HI_SLOPE_SH_SHIFT 16
  122. #define CFG_SC23 0x5c
  123. #define CFG_GRADIENT_THR_MASK 0x07ff
  124. #define CFG_GRADIENT_THR_SHIFT 0
  125. #define CFG_GRADIENT_THR_RANGE_MASK 0x0f
  126. #define CFG_GRADIENT_THR_RANGE_SHIFT 12
  127. #define CFG_MIN_GY_THR_MASK 0xff
  128. #define CFG_MIN_GY_THR_SHIFT 16
  129. #define CFG_MIN_GY_THR_RANGE_MASK 0x0f
  130. #define CFG_MIN_GY_THR_RANGE_SHIFT 28
  131. #define CFG_SC24 0x60
  132. #define CFG_ORG_H_MASK 0x07ff
  133. #define CFG_ORG_H_SHIFT 0
  134. #define CFG_ORG_W_MASK 0x07ff
  135. #define CFG_ORG_W_SHIFT 16
  136. #define CFG_SC25 0x64
  137. #define CFG_OFF_H_MASK 0x07ff
  138. #define CFG_OFF_H_SHIFT 0
  139. #define CFG_OFF_W_MASK 0x07ff
  140. #define CFG_OFF_W_SHIFT 16
  141. /* number of phases supported by the polyphase scalers */
  142. #define SC_NUM_PHASES 32
  143. /* number of taps used by horizontal polyphase scaler */
  144. #define SC_H_NUM_TAPS 7
  145. /* number of taps used by vertical polyphase scaler */
  146. #define SC_V_NUM_TAPS 5
  147. /* number of taps expected by the scaler in it's coefficient memory */
  148. #define SC_NUM_TAPS_MEM_ALIGN 8
  149. /*
  150. * coefficient memory size in bytes:
  151. * num phases x num sets(luma and chroma) x num taps(aligned) x coeff size
  152. */
  153. #define SC_COEF_SRAM_SIZE (SC_NUM_PHASES * 2 * SC_NUM_TAPS_MEM_ALIGN * 2)
  154. struct sc_data {
  155. void __iomem *base;
  156. struct resource *res;
  157. dma_addr_t loaded_coeff_h; /* loaded h coeffs in SC */
  158. dma_addr_t loaded_coeff_v; /* loaded v coeffs in SC */
  159. bool load_coeff_h; /* have new h SC coeffs */
  160. bool load_coeff_v; /* have new v SC coeffs */
  161. unsigned int hs_index; /* h SC coeffs selector */
  162. unsigned int vs_index; /* v SC coeffs selector */
  163. struct platform_device *pdev;
  164. };
  165. void sc_dump_regs(struct sc_data *sc);
  166. void sc_set_hs_coeffs(struct sc_data *sc, void *addr, unsigned int src_w,
  167. unsigned int dst_w);
  168. void sc_set_vs_coeffs(struct sc_data *sc, void *addr, unsigned int src_h,
  169. unsigned int dst_h);
  170. void sc_config_scaler(struct sc_data *sc, u32 *sc_reg0, u32 *sc_reg8,
  171. u32 *sc_reg17, unsigned int src_w, unsigned int src_h,
  172. unsigned int dst_w, unsigned int dst_h);
  173. struct sc_data *sc_create(struct platform_device *pdev);
  174. #endif