mantis_vp1034.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Mantis VP-1034 driver
  3. Copyright (C) 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 <linux/signal.h>
  17. #include <linux/sched.h>
  18. #include <linux/interrupt.h>
  19. #include "dmxdev.h"
  20. #include "dvbdev.h"
  21. #include "dvb_demux.h"
  22. #include "dvb_frontend.h"
  23. #include "dvb_net.h"
  24. #include "mb86a16.h"
  25. #include "mantis_common.h"
  26. #include "mantis_ioc.h"
  27. #include "mantis_dvb.h"
  28. #include "mantis_vp1034.h"
  29. #include "mantis_reg.h"
  30. struct mb86a16_config vp1034_mb86a16_config = {
  31. .demod_address = 0x08,
  32. .set_voltage = vp1034_set_voltage,
  33. };
  34. #define MANTIS_MODEL_NAME "VP-1034"
  35. #define MANTIS_DEV_TYPE "DVB-S/DSS"
  36. int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  37. {
  38. struct mantis_pci *mantis = fe->dvb->priv;
  39. switch (voltage) {
  40. case SEC_VOLTAGE_13:
  41. dprintk(MANTIS_ERROR, 1, "Polarization=[13V]");
  42. mantis_gpio_set_bits(mantis, 13, 1);
  43. mantis_gpio_set_bits(mantis, 14, 0);
  44. break;
  45. case SEC_VOLTAGE_18:
  46. dprintk(MANTIS_ERROR, 1, "Polarization=[18V]");
  47. mantis_gpio_set_bits(mantis, 13, 1);
  48. mantis_gpio_set_bits(mantis, 14, 1);
  49. break;
  50. case SEC_VOLTAGE_OFF:
  51. dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN");
  52. break;
  53. default:
  54. dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage);
  55. return -EINVAL;
  56. }
  57. mmwrite(0x00, MANTIS_GPIF_DOUT);
  58. return 0;
  59. }
  60. static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe)
  61. {
  62. struct i2c_adapter *adapter = &mantis->adapter;
  63. int err = 0;
  64. err = mantis_frontend_power(mantis, POWER_ON);
  65. if (err == 0) {
  66. mantis_frontend_soft_reset(mantis);
  67. msleep(250);
  68. dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)");
  69. fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter);
  70. if (fe) {
  71. dprintk(MANTIS_ERROR, 1,
  72. "found MB86A16 DVB-S/DSS frontend @0x%02x",
  73. vp1034_mb86a16_config.demod_address);
  74. } else {
  75. return -1;
  76. }
  77. } else {
  78. dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>",
  79. adapter->name,
  80. err);
  81. return -EIO;
  82. }
  83. mantis->fe = fe;
  84. dprintk(MANTIS_ERROR, 1, "Done!");
  85. return 0;
  86. }
  87. struct mantis_hwconfig vp1034_config = {
  88. .model_name = MANTIS_MODEL_NAME,
  89. .dev_type = MANTIS_DEV_TYPE,
  90. .ts_size = MANTIS_TS_204,
  91. .baud_rate = MANTIS_BAUD_9600,
  92. .parity = MANTIS_PARITY_NONE,
  93. .bytes = 0,
  94. .frontend_init = vp1034_frontend_init,
  95. .power = GPIF_A12,
  96. .reset = GPIF_A13,
  97. };