si4713-i2c.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * drivers/media/radio/si4713-i2c.h
  3. *
  4. * Property and commands definitions for Si4713 radio transmitter chip.
  5. *
  6. * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
  7. * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public License
  10. * version 2. This program is licensed "as is" without any warranty of any
  11. * kind, whether express or implied.
  12. *
  13. */
  14. #ifndef SI4713_I2C_H
  15. #define SI4713_I2C_H
  16. #include <media/v4l2-subdev.h>
  17. #include <media/si4713.h>
  18. #define SI4713_PRODUCT_NUMBER 0x0D
  19. /* Command Timeouts */
  20. #define DEFAULT_TIMEOUT 500
  21. #define TIMEOUT_SET_PROPERTY 20
  22. #define TIMEOUT_TX_TUNE_POWER 30000
  23. #define TIMEOUT_TX_TUNE 110000
  24. #define TIMEOUT_POWER_UP 200000
  25. /*
  26. * Command and its arguments definitions
  27. */
  28. #define SI4713_PWUP_CTSIEN (1<<7)
  29. #define SI4713_PWUP_GPO2OEN (1<<6)
  30. #define SI4713_PWUP_PATCH (1<<5)
  31. #define SI4713_PWUP_XOSCEN (1<<4)
  32. #define SI4713_PWUP_FUNC_TX 0x02
  33. #define SI4713_PWUP_FUNC_PATCH 0x0F
  34. #define SI4713_PWUP_OPMOD_ANALOG 0x50
  35. #define SI4713_PWUP_OPMOD_DIGITAL 0x0F
  36. #define SI4713_PWUP_NARGS 2
  37. #define SI4713_PWUP_NRESP 1
  38. #define SI4713_CMD_POWER_UP 0x01
  39. #define SI4713_GETREV_NRESP 9
  40. #define SI4713_CMD_GET_REV 0x10
  41. #define SI4713_PWDN_NRESP 1
  42. #define SI4713_CMD_POWER_DOWN 0x11
  43. #define SI4713_SET_PROP_NARGS 5
  44. #define SI4713_SET_PROP_NRESP 1
  45. #define SI4713_CMD_SET_PROPERTY 0x12
  46. #define SI4713_GET_PROP_NARGS 3
  47. #define SI4713_GET_PROP_NRESP 4
  48. #define SI4713_CMD_GET_PROPERTY 0x13
  49. #define SI4713_GET_STATUS_NRESP 1
  50. #define SI4713_CMD_GET_INT_STATUS 0x14
  51. #define SI4713_CMD_PATCH_ARGS 0x15
  52. #define SI4713_CMD_PATCH_DATA 0x16
  53. #define SI4713_MAX_FREQ 10800
  54. #define SI4713_MIN_FREQ 7600
  55. #define SI4713_TXFREQ_NARGS 3
  56. #define SI4713_TXFREQ_NRESP 1
  57. #define SI4713_CMD_TX_TUNE_FREQ 0x30
  58. #define SI4713_MAX_POWER 120
  59. #define SI4713_MIN_POWER 88
  60. #define SI4713_MAX_ANTCAP 191
  61. #define SI4713_MIN_ANTCAP 0
  62. #define SI4713_TXPWR_NARGS 4
  63. #define SI4713_TXPWR_NRESP 1
  64. #define SI4713_CMD_TX_TUNE_POWER 0x31
  65. #define SI4713_TXMEA_NARGS 4
  66. #define SI4713_TXMEA_NRESP 1
  67. #define SI4713_CMD_TX_TUNE_MEASURE 0x32
  68. #define SI4713_INTACK_MASK 0x01
  69. #define SI4713_TXSTATUS_NARGS 1
  70. #define SI4713_TXSTATUS_NRESP 8
  71. #define SI4713_CMD_TX_TUNE_STATUS 0x33
  72. #define SI4713_OVERMOD_BIT (1 << 2)
  73. #define SI4713_IALH_BIT (1 << 1)
  74. #define SI4713_IALL_BIT (1 << 0)
  75. #define SI4713_ASQSTATUS_NARGS 1
  76. #define SI4713_ASQSTATUS_NRESP 5
  77. #define SI4713_CMD_TX_ASQ_STATUS 0x34
  78. #define SI4713_RDSBUFF_MODE_MASK 0x87
  79. #define SI4713_RDSBUFF_NARGS 7
  80. #define SI4713_RDSBUFF_NRESP 6
  81. #define SI4713_CMD_TX_RDS_BUFF 0x35
  82. #define SI4713_RDSPS_PSID_MASK 0x1F
  83. #define SI4713_RDSPS_NARGS 5
  84. #define SI4713_RDSPS_NRESP 1
  85. #define SI4713_CMD_TX_RDS_PS 0x36
  86. #define SI4713_CMD_GPO_CTL 0x80
  87. #define SI4713_CMD_GPO_SET 0x81
  88. /*
  89. * Bits from status response
  90. */
  91. #define SI4713_CTS (1<<7)
  92. #define SI4713_ERR (1<<6)
  93. #define SI4713_RDS_INT (1<<2)
  94. #define SI4713_ASQ_INT (1<<1)
  95. #define SI4713_STC_INT (1<<0)
  96. /*
  97. * Property definitions
  98. */
  99. #define SI4713_GPO_IEN 0x0001
  100. #define SI4713_DIG_INPUT_FORMAT 0x0101
  101. #define SI4713_DIG_INPUT_SAMPLE_RATE 0x0103
  102. #define SI4713_REFCLK_FREQ 0x0201
  103. #define SI4713_REFCLK_PRESCALE 0x0202
  104. #define SI4713_TX_COMPONENT_ENABLE 0x2100
  105. #define SI4713_TX_AUDIO_DEVIATION 0x2101
  106. #define SI4713_TX_PILOT_DEVIATION 0x2102
  107. #define SI4713_TX_RDS_DEVIATION 0x2103
  108. #define SI4713_TX_LINE_INPUT_LEVEL 0x2104
  109. #define SI4713_TX_LINE_INPUT_MUTE 0x2105
  110. #define SI4713_TX_PREEMPHASIS 0x2106
  111. #define SI4713_TX_PILOT_FREQUENCY 0x2107
  112. #define SI4713_TX_ACOMP_ENABLE 0x2200
  113. #define SI4713_TX_ACOMP_THRESHOLD 0x2201
  114. #define SI4713_TX_ACOMP_ATTACK_TIME 0x2202
  115. #define SI4713_TX_ACOMP_RELEASE_TIME 0x2203
  116. #define SI4713_TX_ACOMP_GAIN 0x2204
  117. #define SI4713_TX_LIMITER_RELEASE_TIME 0x2205
  118. #define SI4713_TX_ASQ_INTERRUPT_SOURCE 0x2300
  119. #define SI4713_TX_ASQ_LEVEL_LOW 0x2301
  120. #define SI4713_TX_ASQ_DURATION_LOW 0x2302
  121. #define SI4713_TX_ASQ_LEVEL_HIGH 0x2303
  122. #define SI4713_TX_ASQ_DURATION_HIGH 0x2304
  123. #define SI4713_TX_RDS_INTERRUPT_SOURCE 0x2C00
  124. #define SI4713_TX_RDS_PI 0x2C01
  125. #define SI4713_TX_RDS_PS_MIX 0x2C02
  126. #define SI4713_TX_RDS_PS_MISC 0x2C03
  127. #define SI4713_TX_RDS_PS_REPEAT_COUNT 0x2C04
  128. #define SI4713_TX_RDS_PS_MESSAGE_COUNT 0x2C05
  129. #define SI4713_TX_RDS_PS_AF 0x2C06
  130. #define SI4713_TX_RDS_FIFO_SIZE 0x2C07
  131. #define PREEMPHASIS_USA 75
  132. #define PREEMPHASIS_EU 50
  133. #define PREEMPHASIS_DISABLED 0
  134. #define FMPE_USA 0x00
  135. #define FMPE_EU 0x01
  136. #define FMPE_DISABLED 0x02
  137. #define POWER_UP 0x01
  138. #define POWER_DOWN 0x00
  139. struct rds_info {
  140. u32 pi;
  141. #define MAX_RDS_PTY 31
  142. u32 pty;
  143. #define MAX_RDS_DEVIATION 90000
  144. u32 deviation;
  145. /*
  146. * PSNAME is known to be defined as 8 character sized (RDS Spec).
  147. * However, there is receivers which scroll PSNAME 8xN sized.
  148. */
  149. #define MAX_RDS_PS_NAME 96
  150. u8 ps_name[MAX_RDS_PS_NAME + 1];
  151. /*
  152. * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group)
  153. * character sized (RDS Spec).
  154. * However, there is receivers which scroll them as well.
  155. */
  156. #define MAX_RDS_RADIO_TEXT 384
  157. u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
  158. u32 enabled;
  159. };
  160. struct limiter_info {
  161. #define MAX_LIMITER_RELEASE_TIME 102390
  162. u32 release_time;
  163. #define MAX_LIMITER_DEVIATION 90000
  164. u32 deviation;
  165. u32 enabled;
  166. };
  167. struct pilot_info {
  168. #define MAX_PILOT_DEVIATION 90000
  169. u32 deviation;
  170. #define MAX_PILOT_FREQUENCY 19000
  171. u32 frequency;
  172. u32 enabled;
  173. };
  174. struct acomp_info {
  175. #define MAX_ACOMP_RELEASE_TIME 1000000
  176. u32 release_time;
  177. #define MAX_ACOMP_ATTACK_TIME 5000
  178. u32 attack_time;
  179. #define MAX_ACOMP_THRESHOLD 0
  180. #define MIN_ACOMP_THRESHOLD (-40)
  181. s32 threshold;
  182. #define MAX_ACOMP_GAIN 20
  183. u32 gain;
  184. u32 enabled;
  185. };
  186. #define SI4713_NUM_SUPPLIES 2
  187. /*
  188. * si4713_device - private data
  189. */
  190. struct si4713_device {
  191. /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
  192. struct v4l2_subdev sd;
  193. /* private data structures */
  194. struct mutex mutex;
  195. struct completion work;
  196. struct rds_info rds_info;
  197. struct limiter_info limiter_info;
  198. struct pilot_info pilot_info;
  199. struct acomp_info acomp_info;
  200. struct regulator_bulk_data supplies[SI4713_NUM_SUPPLIES];
  201. int gpio_reset;
  202. u32 frequency;
  203. u32 preemphasis;
  204. u32 mute;
  205. u32 power_level;
  206. u32 power_state;
  207. u32 antenna_capacitor;
  208. u32 stereo;
  209. u32 tune_rnl;
  210. };
  211. #endif /* ifndef SI4713_I2C_H */