cxd2820r.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Sony CXD2820R demodulator driver
  4. *
  5. * Copyright (C) 2010 Antti Palosaari <[email protected]>
  6. */
  7. #ifndef CXD2820R_H
  8. #define CXD2820R_H
  9. #include <linux/dvb/frontend.h>
  10. #define CXD2820R_GPIO_D (0 << 0) /* disable */
  11. #define CXD2820R_GPIO_E (1 << 0) /* enable */
  12. #define CXD2820R_GPIO_O (0 << 1) /* output */
  13. #define CXD2820R_GPIO_I (1 << 1) /* input */
  14. #define CXD2820R_GPIO_L (0 << 2) /* output low */
  15. #define CXD2820R_GPIO_H (1 << 2) /* output high */
  16. #define CXD2820R_TS_SERIAL 0x08
  17. #define CXD2820R_TS_SERIAL_MSB 0x28
  18. #define CXD2820R_TS_PARALLEL 0x30
  19. #define CXD2820R_TS_PARALLEL_MSB 0x70
  20. /*
  21. * I2C address: 0x6c, 0x6d
  22. */
  23. /**
  24. * struct cxd2820r_platform_data - Platform data for the cxd2820r driver
  25. * @ts_mode: TS mode.
  26. * @ts_clk_inv: TS clock inverted.
  27. * @if_agc_polarity: IF AGC polarity.
  28. * @spec_inv: Input spectrum inverted.
  29. * @gpio_chip_base: GPIO.
  30. * @get_dvb_frontend: Get DVB frontend.
  31. */
  32. struct cxd2820r_platform_data {
  33. u8 ts_mode;
  34. bool ts_clk_inv;
  35. bool if_agc_polarity;
  36. bool spec_inv;
  37. int **gpio_chip_base;
  38. struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
  39. /* private: For legacy media attach wrapper. Do not set value. */
  40. bool attach_in_use;
  41. };
  42. /**
  43. * struct cxd2820r_config - configuration for cxd2020r demod
  44. *
  45. * @i2c_address: Demodulator I2C address. Driver determines DVB-C slave I2C
  46. * address automatically from master address.
  47. * Default: none, must set. Values: 0x6c, 0x6d.
  48. * @ts_mode: TS output mode. Default: none, must set. Values: FIXME?
  49. * @ts_clock_inv: TS clock inverted. Default: 0. Values: 0, 1.
  50. * @if_agc_polarity: Default: 0. Values: 0, 1
  51. * @spec_inv: Spectrum inversion. Default: 0. Values: 0, 1.
  52. */
  53. struct cxd2820r_config {
  54. /* Demodulator I2C address.
  55. * Driver determines DVB-C slave I2C address automatically from master
  56. * address.
  57. * Default: none, must set
  58. * Values: 0x6c, 0x6d
  59. */
  60. u8 i2c_address;
  61. /* TS output mode.
  62. * Default: none, must set.
  63. * Values:
  64. */
  65. u8 ts_mode;
  66. /* TS clock inverted.
  67. * Default: 0
  68. * Values: 0, 1
  69. */
  70. bool ts_clock_inv;
  71. /* IF AGC polarity.
  72. * Default: 0
  73. * Values: 0, 1
  74. */
  75. bool if_agc_polarity;
  76. /* Spectrum inversion.
  77. * Default: 0
  78. * Values: 0, 1
  79. */
  80. bool spec_inv;
  81. };
  82. #if IS_REACHABLE(CONFIG_DVB_CXD2820R)
  83. /**
  84. * cxd2820r_attach - Attach a cxd2820r demod
  85. *
  86. * @config: pointer to &struct cxd2820r_config with demod configuration.
  87. * @i2c: i2c adapter to use.
  88. * @gpio_chip_base: if zero, disables GPIO setting. Otherwise, if
  89. * CONFIG_GPIOLIB is set dynamically allocate
  90. * gpio base; if is not set, use its value to
  91. * setup the GPIO pins.
  92. *
  93. * return: FE pointer on success, NULL on failure.
  94. */
  95. extern struct dvb_frontend *cxd2820r_attach(
  96. const struct cxd2820r_config *config,
  97. struct i2c_adapter *i2c,
  98. int *gpio_chip_base
  99. );
  100. #else
  101. static inline struct dvb_frontend *cxd2820r_attach(
  102. const struct cxd2820r_config *config,
  103. struct i2c_adapter *i2c,
  104. int *gpio_chip_base
  105. )
  106. {
  107. printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
  108. return NULL;
  109. }
  110. #endif
  111. #endif /* CXD2820R_H */