stv6110x_priv.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. STV6110(A) Silicon tuner driver
  3. Copyright (C) Manu Abraham <abraham.manu@gmail.com>
  4. Copyright (C) ST Microelectronics
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #ifndef __STV6110x_PRIV_H
  18. #define __STV6110x_PRIV_H
  19. #define FE_ERROR 0
  20. #define FE_NOTICE 1
  21. #define FE_INFO 2
  22. #define FE_DEBUG 3
  23. #define FE_DEBUGREG 4
  24. #define dprintk(__y, __z, format, arg...) do { \
  25. if (__z) { \
  26. if ((verbose > FE_ERROR) && (verbose > __y)) \
  27. printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
  28. else if ((verbose > FE_NOTICE) && (verbose > __y)) \
  29. printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
  30. else if ((verbose > FE_INFO) && (verbose > __y)) \
  31. printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
  32. else if ((verbose > FE_DEBUG) && (verbose > __y)) \
  33. printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
  34. } else { \
  35. if (verbose > __y) \
  36. printk(format, ##arg); \
  37. } \
  38. } while (0)
  39. #define STV6110x_SETFIELD(mask, bitf, val) \
  40. (mask = (mask & (~(((1 << STV6110x_WIDTH_##bitf) - 1) << \
  41. STV6110x_OFFST_##bitf))) | \
  42. (val << STV6110x_OFFST_##bitf))
  43. #define STV6110x_GETFIELD(bitf, val) \
  44. ((val >> STV6110x_OFFST_##bitf) & \
  45. ((1 << STV6110x_WIDTH_##bitf) - 1))
  46. #define MAKEWORD16(a, b) (((a) << 8) | (b))
  47. #define LSB(x) ((x & 0xff))
  48. #define MSB(y) ((y >> 8) & 0xff)
  49. #define TRIALS 10
  50. #define R_DIV(__div) (1 << (__div + 1))
  51. #define REFCLOCK_kHz (stv6110x->config->refclk / 1000)
  52. #define REFCLOCK_MHz (stv6110x->config->refclk / 1000000)
  53. struct stv6110x_state {
  54. struct i2c_adapter *i2c;
  55. const struct stv6110x_config *config;
  56. u8 regs[8];
  57. struct stv6110x_devctl *devctl;
  58. };
  59. #endif /* __STV6110x_PRIV_H */