dib3000-common.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * .h-files for the common use of the frontend drivers made by DiBcom
  3. * DiBcom 3000M-B/C, 3000P
  4. *
  5. * DiBcom (http://www.dibcom.fr/)
  6. *
  7. * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
  8. *
  9. * based on GPL code from DibCom, which has
  10. *
  11. * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation, version 2.
  16. *
  17. * Acknowledgements
  18. *
  19. * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
  20. * sources, on which this driver (and the dvb-dibusb) are based.
  21. *
  22. * see Documentation/dvb/README.dibusb for more information
  23. *
  24. */
  25. #ifndef DIB3000_COMMON_H
  26. #define DIB3000_COMMON_H
  27. #include "dvb_frontend.h"
  28. #include "dib3000.h"
  29. /* info and err, taken from usb.h, if there is anything available like by default. */
  30. #define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)
  31. #define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)
  32. #define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)
  33. /* frontend state */
  34. struct dib3000_state {
  35. struct i2c_adapter* i2c;
  36. struct dvb_frontend_ops ops;
  37. /* configuration settings */
  38. struct dib3000_config config;
  39. struct dvb_frontend frontend;
  40. int timing_offset;
  41. int timing_offset_comp_done;
  42. fe_bandwidth_t last_tuned_bw;
  43. u32 last_tuned_freq;
  44. };
  45. /* commonly used methods by the dib3000mb/mc/p frontend */
  46. extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
  47. extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
  48. extern int dib3000_search_status(u16 irq,u16 lock);
  49. /* handy shortcuts */
  50. #define rd(reg) dib3000_read_reg(state,reg)
  51. #define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
  52. { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
  53. #define wr_foreach(a,v) { int i; \
  54. if (sizeof(a) != sizeof(v)) \
  55. err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\
  56. for (i=0; i < sizeof(a)/sizeof(u16); i++) \
  57. wr(a[i],v[i]); \
  58. }
  59. #define set_or(reg,val) wr(reg,rd(reg) | val)
  60. #define set_and(reg,val) wr(reg,rd(reg) & val)
  61. /* debug */
  62. #ifdef CONFIG_DVB_DIBCOM_DEBUG
  63. #define dprintk(level,args...) \
  64. do { if ((debug & level)) { printk(args); } } while (0)
  65. #else
  66. #define dprintk(args...) do { } while (0)
  67. #endif
  68. /* mask for enabling a specific pid for the pid_filter */
  69. #define DIB3000_ACTIVATE_PID_FILTERING (0x2000)
  70. /* common values for tuning */
  71. #define DIB3000_ALPHA_0 ( 0)
  72. #define DIB3000_ALPHA_1 ( 1)
  73. #define DIB3000_ALPHA_2 ( 2)
  74. #define DIB3000_ALPHA_4 ( 4)
  75. #define DIB3000_CONSTELLATION_QPSK ( 0)
  76. #define DIB3000_CONSTELLATION_16QAM ( 1)
  77. #define DIB3000_CONSTELLATION_64QAM ( 2)
  78. #define DIB3000_GUARD_TIME_1_32 ( 0)
  79. #define DIB3000_GUARD_TIME_1_16 ( 1)
  80. #define DIB3000_GUARD_TIME_1_8 ( 2)
  81. #define DIB3000_GUARD_TIME_1_4 ( 3)
  82. #define DIB3000_TRANSMISSION_MODE_2K ( 0)
  83. #define DIB3000_TRANSMISSION_MODE_8K ( 1)
  84. #define DIB3000_SELECT_LP ( 0)
  85. #define DIB3000_SELECT_HP ( 1)
  86. #define DIB3000_FEC_1_2 ( 1)
  87. #define DIB3000_FEC_2_3 ( 2)
  88. #define DIB3000_FEC_3_4 ( 3)
  89. #define DIB3000_FEC_5_6 ( 5)
  90. #define DIB3000_FEC_7_8 ( 7)
  91. #define DIB3000_HRCH_OFF ( 0)
  92. #define DIB3000_HRCH_ON ( 1)
  93. #define DIB3000_DDS_INVERSION_OFF ( 0)
  94. #define DIB3000_DDS_INVERSION_ON ( 1)
  95. #define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))
  96. #define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))
  97. /* for auto search */
  98. extern u16 dib3000_seq[2][2][2];
  99. #define DIB3000_REG_MANUFACTOR_ID ( 1025)
  100. #define DIB3000_I2C_ID_DIBCOM (0x01b3)
  101. #define DIB3000_REG_DEVICE_ID ( 1026)
  102. #define DIB3000MB_DEVICE_ID (0x3000)
  103. #define DIB3000MC_DEVICE_ID (0x3001)
  104. #define DIB3000P_DEVICE_ID (0x3002)
  105. #endif // DIB3000_COMMON_H