e4000_priv.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Elonics E4000 silicon tuner driver
  4. *
  5. * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  6. */
  7. #ifndef E4000_PRIV_H
  8. #define E4000_PRIV_H
  9. #include "e4000.h"
  10. #include <linux/math64.h>
  11. #include <media/v4l2-ctrls.h>
  12. #include <media/v4l2-subdev.h>
  13. #include <linux/regmap.h>
  14. struct e4000_dev {
  15. struct i2c_client *client;
  16. struct regmap *regmap;
  17. u32 clk;
  18. struct dvb_frontend *fe;
  19. struct v4l2_subdev sd;
  20. bool active;
  21. unsigned int f_frequency;
  22. unsigned int f_bandwidth;
  23. /* Controls */
  24. struct v4l2_ctrl_handler hdl;
  25. struct v4l2_ctrl *bandwidth_auto;
  26. struct v4l2_ctrl *bandwidth;
  27. struct v4l2_ctrl *lna_gain_auto;
  28. struct v4l2_ctrl *lna_gain;
  29. struct v4l2_ctrl *mixer_gain_auto;
  30. struct v4l2_ctrl *mixer_gain;
  31. struct v4l2_ctrl *if_gain_auto;
  32. struct v4l2_ctrl *if_gain;
  33. struct v4l2_ctrl *pll_lock;
  34. };
  35. struct e4000_pll {
  36. u32 freq;
  37. u8 div_out_reg;
  38. u8 div_out;
  39. };
  40. static const struct e4000_pll e4000_pll_lut[] = {
  41. /* VCO min VCO max */
  42. { 72400000, 0x0f, 48 }, /* .......... 3475200000 */
  43. { 81200000, 0x0e, 40 }, /* 2896000000 3248000000 */
  44. { 108300000, 0x0d, 32 }, /* 2598400000 3465600000 */
  45. { 162500000, 0x0c, 24 }, /* 2599200000 3900000000 */
  46. { 216600000, 0x0b, 16 }, /* 2600000000 3465600000 */
  47. { 325000000, 0x0a, 12 }, /* 2599200000 3900000000 */
  48. { 350000000, 0x09, 8 }, /* 2600000000 2800000000 */
  49. { 432000000, 0x03, 8 }, /* 2800000000 3456000000 */
  50. { 667000000, 0x02, 6 }, /* 2592000000 4002000000 */
  51. { 1200000000, 0x01, 4 }, /* 2668000000 4800000000 */
  52. { 0xffffffff, 0x00, 2 }, /* 2400000000 .......... */
  53. };
  54. struct e4000_lna_filter {
  55. u32 freq;
  56. u8 val;
  57. };
  58. static const struct e4000_lna_filter e400_lna_filter_lut[] = {
  59. { 370000000, 0 },
  60. { 392500000, 1 },
  61. { 415000000, 2 },
  62. { 437500000, 3 },
  63. { 462500000, 4 },
  64. { 490000000, 5 },
  65. { 522500000, 6 },
  66. { 557500000, 7 },
  67. { 595000000, 8 },
  68. { 642500000, 9 },
  69. { 695000000, 10 },
  70. { 740000000, 11 },
  71. { 800000000, 12 },
  72. { 865000000, 13 },
  73. { 930000000, 14 },
  74. { 1000000000, 15 },
  75. { 1310000000, 0 },
  76. { 1340000000, 1 },
  77. { 1385000000, 2 },
  78. { 1427500000, 3 },
  79. { 1452500000, 4 },
  80. { 1475000000, 5 },
  81. { 1510000000, 6 },
  82. { 1545000000, 7 },
  83. { 1575000000, 8 },
  84. { 1615000000, 9 },
  85. { 1650000000, 10 },
  86. { 1670000000, 11 },
  87. { 1690000000, 12 },
  88. { 1710000000, 13 },
  89. { 1735000000, 14 },
  90. { 0xffffffff, 15 },
  91. };
  92. struct e4000_band {
  93. u32 freq;
  94. u8 reg07_val;
  95. u8 reg78_val;
  96. };
  97. static const struct e4000_band e4000_band_lut[] = {
  98. { 140000000, 0x01, 0x03 },
  99. { 350000000, 0x03, 0x03 },
  100. { 1000000000, 0x05, 0x03 },
  101. { 0xffffffff, 0x07, 0x00 },
  102. };
  103. struct e4000_if_filter {
  104. u32 freq;
  105. u8 reg11_val;
  106. u8 reg12_val;
  107. };
  108. static const struct e4000_if_filter e4000_if_filter_lut[] = {
  109. { 4300000, 0xfd, 0x1f },
  110. { 4400000, 0xfd, 0x1e },
  111. { 4480000, 0xfc, 0x1d },
  112. { 4560000, 0xfc, 0x1c },
  113. { 4600000, 0xfc, 0x1b },
  114. { 4800000, 0xfc, 0x1a },
  115. { 4900000, 0xfc, 0x19 },
  116. { 5000000, 0xfc, 0x18 },
  117. { 5100000, 0xfc, 0x17 },
  118. { 5200000, 0xfc, 0x16 },
  119. { 5400000, 0xfc, 0x15 },
  120. { 5500000, 0xfc, 0x14 },
  121. { 5600000, 0xfc, 0x13 },
  122. { 5800000, 0xfb, 0x12 },
  123. { 5900000, 0xfb, 0x11 },
  124. { 6000000, 0xfb, 0x10 },
  125. { 6200000, 0xfb, 0x0f },
  126. { 6400000, 0xfa, 0x0e },
  127. { 6600000, 0xfa, 0x0d },
  128. { 6800000, 0xf9, 0x0c },
  129. { 7200000, 0xf9, 0x0b },
  130. { 7400000, 0xf9, 0x0a },
  131. { 7600000, 0xf8, 0x09 },
  132. { 7800000, 0xf8, 0x08 },
  133. { 8200000, 0xf8, 0x07 },
  134. { 8600000, 0xf7, 0x06 },
  135. { 8800000, 0xf7, 0x05 },
  136. { 9200000, 0xf7, 0x04 },
  137. { 9600000, 0xf6, 0x03 },
  138. { 10000000, 0xf6, 0x02 },
  139. { 10600000, 0xf5, 0x01 },
  140. { 11000000, 0xf5, 0x00 },
  141. { 0xffffffff, 0x00, 0x20 },
  142. };
  143. struct e4000_if_gain {
  144. u8 reg16_val;
  145. u8 reg17_val;
  146. };
  147. static const struct e4000_if_gain e4000_if_gain_lut[] = {
  148. {0x00, 0x00},
  149. {0x20, 0x00},
  150. {0x40, 0x00},
  151. {0x02, 0x00},
  152. {0x22, 0x00},
  153. {0x42, 0x00},
  154. {0x04, 0x00},
  155. {0x24, 0x00},
  156. {0x44, 0x00},
  157. {0x01, 0x00},
  158. {0x21, 0x00},
  159. {0x41, 0x00},
  160. {0x03, 0x00},
  161. {0x23, 0x00},
  162. {0x43, 0x00},
  163. {0x05, 0x00},
  164. {0x25, 0x00},
  165. {0x45, 0x00},
  166. {0x07, 0x00},
  167. {0x27, 0x00},
  168. {0x47, 0x00},
  169. {0x0f, 0x00},
  170. {0x2f, 0x00},
  171. {0x4f, 0x00},
  172. {0x17, 0x00},
  173. {0x37, 0x00},
  174. {0x57, 0x00},
  175. {0x1f, 0x00},
  176. {0x3f, 0x00},
  177. {0x5f, 0x00},
  178. {0x1f, 0x01},
  179. {0x3f, 0x01},
  180. {0x5f, 0x01},
  181. {0x1f, 0x02},
  182. {0x3f, 0x02},
  183. {0x5f, 0x02},
  184. {0x1f, 0x03},
  185. {0x3f, 0x03},
  186. {0x5f, 0x03},
  187. {0x1f, 0x04},
  188. {0x3f, 0x04},
  189. {0x5f, 0x04},
  190. {0x1f, 0x0c},
  191. {0x3f, 0x0c},
  192. {0x5f, 0x0c},
  193. {0x1f, 0x14},
  194. {0x3f, 0x14},
  195. {0x5f, 0x14},
  196. {0x1f, 0x1c},
  197. {0x3f, 0x1c},
  198. {0x5f, 0x1c},
  199. {0x1f, 0x24},
  200. {0x3f, 0x24},
  201. {0x5f, 0x24},
  202. {0x7f, 0x24},
  203. };
  204. #endif