mantis_vp1033.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. Mantis VP-1033 driver
  3. Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "mantis_common.h"
  17. #include "mantis_vp1033.h"
  18. u8 lgtdqcs001f_inittab[] = {
  19. 0x01, 0x15,
  20. 0x02, 0x00,
  21. 0x03, 0x00,
  22. 0x04, 0x2a,
  23. 0x05, 0x85,
  24. 0x06, 0x02,
  25. 0x07, 0x00,
  26. 0x08, 0x00,
  27. 0x0c, 0x01,
  28. 0x0d, 0x81,
  29. 0x0e, 0x44,
  30. 0x0f, 0x94,
  31. 0x10, 0x3c,
  32. 0x11, 0x84,
  33. 0x12, 0xb9,
  34. 0x13, 0xb5,
  35. 0x14, 0x4f,
  36. 0x15, 0xc9,
  37. 0x16, 0x80,
  38. 0x17, 0x36,
  39. 0x18, 0xfb,
  40. 0x19, 0xcf,
  41. 0x1a, 0xbc,
  42. 0x1c, 0x2b,
  43. 0x1d, 0x27,
  44. 0x1e, 0x00,
  45. 0x1f, 0x0b,
  46. 0x20, 0xa1,
  47. 0x21, 0x60,
  48. 0x22, 0x00,
  49. 0x23, 0x00,
  50. 0x28, 0x00,
  51. 0x29, 0x28,
  52. 0x2a, 0x14,
  53. 0x2b, 0x0f,
  54. 0x2c, 0x09,
  55. 0x2d, 0x05,
  56. 0x31, 0x1f,
  57. 0x32, 0x19,
  58. 0x33, 0xfc,
  59. 0x34, 0x13,
  60. 0xff, 0xff,
  61. };
  62. struct stv0299_config lgtdqcs001f_config = {
  63. .demod_address = 0x68,
  64. .inittab = lgtdqcs001f_inittab,
  65. .mclk = 88000000UL,
  66. // .invert = 0,
  67. .invert = 1,
  68. // .enhanced_tuning = 0,
  69. .skip_reinit = 0,
  70. .lock_output = STV0229_LOCKOUTPUT_0,
  71. .volt13_op0_op1 = STV0299_VOLT13_OP0,
  72. .min_delay_ms = 100,
  73. .set_symbol_rate = lgtdqcs001f_set_symbol_rate,
  74. // .pll_set = lgtdqcs001f_pll_set,
  75. };
  76. #define MANTIS_MODEL_NAME "VP-1033"
  77. #define MANTIS_DEV_TYPE "DVB-S/DSS"
  78. struct mantis_hwconfig vp1033_mantis_config = {
  79. .model_name = MANTIS_MODEL_NAME,
  80. .dev_type = MANTIS_DEV_TYPE,
  81. .ts_size = MANTIS_TS_204,
  82. };
  83. int lgtdqcs001f_tuner_set(struct dvb_frontend *fe,
  84. struct dvb_frontend_parameters *params)
  85. {
  86. u8 buf[4];
  87. u32 div;
  88. struct mantis_pci *mantis = fe->dvb->priv;
  89. struct i2c_msg msg = {
  90. .addr = 0x61,
  91. .flags = 0,
  92. .buf = buf,
  93. .len = sizeof (buf)
  94. };
  95. div = params->frequency / 250;
  96. buf[0] = (div >> 8) & 0x7f;
  97. buf[1] = div & 0xff;
  98. buf[2] = 0x83;
  99. buf[3] = 0xc0;
  100. if (params->frequency < 1531000)
  101. buf[3] |= 0x04;
  102. else
  103. buf[3] &= ~0x04;
  104. if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
  105. dprintk(verbose, MANTIS_ERROR, 1, "Write: I2C Transfer failed");
  106. return -EIO;
  107. }
  108. msleep_interruptible(100);
  109. return 0;
  110. }
  111. int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
  112. u32 srate, u32 ratio)
  113. {
  114. u8 aclk = 0;
  115. u8 bclk = 0;
  116. if (srate < 1500000) {
  117. aclk = 0xb7;
  118. bclk = 0x47;
  119. } else if (srate < 3000000) {
  120. aclk = 0xb7;
  121. bclk = 0x4b;
  122. } else if (srate < 7000000) {
  123. aclk = 0xb7;
  124. bclk = 0x4f;
  125. } else if (srate < 14000000) {
  126. aclk = 0xb7;
  127. bclk = 0x53;
  128. } else if (srate < 30000000) {
  129. aclk = 0xb6;
  130. bclk = 0x53;
  131. } else if (srate < 45000000) {
  132. aclk = 0xb4;
  133. bclk = 0x51;
  134. }
  135. stv0299_writereg (fe, 0x13, aclk);
  136. stv0299_writereg (fe, 0x14, bclk);
  137. stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
  138. stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
  139. stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
  140. return 0;
  141. }