si4713.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 <linux/platform_device.h>
  17. #include <linux/regulator/consumer.h>
  18. #include <linux/gpio/consumer.h>
  19. #include <media/v4l2-subdev.h>
  20. #include <media/v4l2-ctrls.h>
  21. #include <linux/platform_data/media/si4713.h>
  22. #define SI4713_PRODUCT_NUMBER 0x0D
  23. /* Command Timeouts */
  24. #define DEFAULT_TIMEOUT 500
  25. #define TIMEOUT_SET_PROPERTY 20
  26. #define TIMEOUT_TX_TUNE_POWER 30000
  27. #define TIMEOUT_TX_TUNE 110000
  28. #define TIMEOUT_POWER_UP 200000
  29. /*
  30. * Command and its arguments definitions
  31. */
  32. #define SI4713_PWUP_CTSIEN (1<<7)
  33. #define SI4713_PWUP_GPO2OEN (1<<6)
  34. #define SI4713_PWUP_PATCH (1<<5)
  35. #define SI4713_PWUP_XOSCEN (1<<4)
  36. #define SI4713_PWUP_FUNC_TX 0x02
  37. #define SI4713_PWUP_FUNC_PATCH 0x0F
  38. #define SI4713_PWUP_OPMOD_ANALOG 0x50
  39. #define SI4713_PWUP_OPMOD_DIGITAL 0x0F
  40. #define SI4713_PWUP_NARGS 2
  41. #define SI4713_PWUP_NRESP 1
  42. #define SI4713_CMD_POWER_UP 0x01
  43. #define SI4713_GETREV_NRESP 9
  44. #define SI4713_CMD_GET_REV 0x10
  45. #define SI4713_PWDN_NRESP 1
  46. #define SI4713_CMD_POWER_DOWN 0x11
  47. #define SI4713_SET_PROP_NARGS 5
  48. #define SI4713_SET_PROP_NRESP 1
  49. #define SI4713_CMD_SET_PROPERTY 0x12
  50. #define SI4713_GET_PROP_NARGS 3
  51. #define SI4713_GET_PROP_NRESP 4
  52. #define SI4713_CMD_GET_PROPERTY 0x13
  53. #define SI4713_GET_STATUS_NRESP 1
  54. #define SI4713_CMD_GET_INT_STATUS 0x14
  55. #define SI4713_CMD_PATCH_ARGS 0x15
  56. #define SI4713_CMD_PATCH_DATA 0x16
  57. #define SI4713_MAX_FREQ 10800
  58. #define SI4713_MIN_FREQ 7600
  59. #define SI4713_TXFREQ_NARGS 3
  60. #define SI4713_TXFREQ_NRESP 1
  61. #define SI4713_CMD_TX_TUNE_FREQ 0x30
  62. #define SI4713_MAX_POWER 120
  63. #define SI4713_MIN_POWER 88
  64. #define SI4713_MAX_ANTCAP 191
  65. #define SI4713_MIN_ANTCAP 0
  66. #define SI4713_TXPWR_NARGS 4
  67. #define SI4713_TXPWR_NRESP 1
  68. #define SI4713_CMD_TX_TUNE_POWER 0x31
  69. #define SI4713_TXMEA_NARGS 4
  70. #define SI4713_TXMEA_NRESP 1
  71. #define SI4713_CMD_TX_TUNE_MEASURE 0x32
  72. #define SI4713_INTACK_MASK 0x01
  73. #define SI4713_TXSTATUS_NARGS 1
  74. #define SI4713_TXSTATUS_NRESP 8
  75. #define SI4713_CMD_TX_TUNE_STATUS 0x33
  76. #define SI4713_OVERMOD_BIT (1 << 2)
  77. #define SI4713_IALH_BIT (1 << 1)
  78. #define SI4713_IALL_BIT (1 << 0)
  79. #define SI4713_ASQSTATUS_NARGS 1
  80. #define SI4713_ASQSTATUS_NRESP 5
  81. #define SI4713_CMD_TX_ASQ_STATUS 0x34
  82. #define SI4713_RDSBUFF_MODE_MASK 0x87
  83. #define SI4713_RDSBUFF_NARGS 7
  84. #define SI4713_RDSBUFF_NRESP 6
  85. #define SI4713_CMD_TX_RDS_BUFF 0x35
  86. #define SI4713_RDSPS_PSID_MASK 0x1F
  87. #define SI4713_RDSPS_NARGS 5
  88. #define SI4713_RDSPS_NRESP 1
  89. #define SI4713_CMD_TX_RDS_PS 0x36
  90. #define SI4713_CMD_GPO_CTL 0x80
  91. #define SI4713_CMD_GPO_SET 0x81
  92. /*
  93. * Bits from status response
  94. */
  95. #define SI4713_CTS (1<<7)
  96. #define SI4713_ERR (1<<6)
  97. #define SI4713_RDS_INT (1<<2)
  98. #define SI4713_ASQ_INT (1<<1)
  99. #define SI4713_STC_INT (1<<0)
  100. /*
  101. * Property definitions
  102. */
  103. #define SI4713_GPO_IEN 0x0001
  104. #define SI4713_DIG_INPUT_FORMAT 0x0101
  105. #define SI4713_DIG_INPUT_SAMPLE_RATE 0x0103
  106. #define SI4713_REFCLK_FREQ 0x0201
  107. #define SI4713_REFCLK_PRESCALE 0x0202
  108. #define SI4713_TX_COMPONENT_ENABLE 0x2100
  109. #define SI4713_TX_AUDIO_DEVIATION 0x2101
  110. #define SI4713_TX_PILOT_DEVIATION 0x2102
  111. #define SI4713_TX_RDS_DEVIATION 0x2103
  112. #define SI4713_TX_LINE_INPUT_LEVEL 0x2104
  113. #define SI4713_TX_LINE_INPUT_MUTE 0x2105
  114. #define SI4713_TX_PREEMPHASIS 0x2106
  115. #define SI4713_TX_PILOT_FREQUENCY 0x2107
  116. #define SI4713_TX_ACOMP_ENABLE 0x2200
  117. #define SI4713_TX_ACOMP_THRESHOLD 0x2201
  118. #define SI4713_TX_ACOMP_ATTACK_TIME 0x2202
  119. #define SI4713_TX_ACOMP_RELEASE_TIME 0x2203
  120. #define SI4713_TX_ACOMP_GAIN 0x2204
  121. #define SI4713_TX_LIMITER_RELEASE_TIME 0x2205
  122. #define SI4713_TX_ASQ_INTERRUPT_SOURCE 0x2300
  123. #define SI4713_TX_ASQ_LEVEL_LOW 0x2301
  124. #define SI4713_TX_ASQ_DURATION_LOW 0x2302
  125. #define SI4713_TX_ASQ_LEVEL_HIGH 0x2303
  126. #define SI4713_TX_ASQ_DURATION_HIGH 0x2304
  127. #define SI4713_TX_RDS_INTERRUPT_SOURCE 0x2C00
  128. #define SI4713_TX_RDS_PI 0x2C01
  129. #define SI4713_TX_RDS_PS_MIX 0x2C02
  130. #define SI4713_TX_RDS_PS_MISC 0x2C03
  131. #define SI4713_TX_RDS_PS_REPEAT_COUNT 0x2C04
  132. #define SI4713_TX_RDS_PS_MESSAGE_COUNT 0x2C05
  133. #define SI4713_TX_RDS_PS_AF 0x2C06
  134. #define SI4713_TX_RDS_FIFO_SIZE 0x2C07
  135. #define PREEMPHASIS_USA 75
  136. #define PREEMPHASIS_EU 50
  137. #define PREEMPHASIS_DISABLED 0
  138. #define FMPE_USA 0x00
  139. #define FMPE_EU 0x01
  140. #define FMPE_DISABLED 0x02
  141. #define POWER_UP 0x01
  142. #define POWER_DOWN 0x00
  143. #define MAX_RDS_PTY 31
  144. #define MAX_RDS_DEVIATION 90000
  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. /*
  151. * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group)
  152. * character sized (RDS Spec).
  153. * However, there is receivers which scroll them as well.
  154. */
  155. #define MAX_RDS_RADIO_TEXT 384
  156. #define MAX_LIMITER_RELEASE_TIME 102390
  157. #define MAX_LIMITER_DEVIATION 90000
  158. #define MAX_PILOT_DEVIATION 90000
  159. #define MAX_PILOT_FREQUENCY 19000
  160. #define MAX_ACOMP_RELEASE_TIME 1000000
  161. #define MAX_ACOMP_ATTACK_TIME 5000
  162. #define MAX_ACOMP_THRESHOLD 0
  163. #define MIN_ACOMP_THRESHOLD (-40)
  164. #define MAX_ACOMP_GAIN 20
  165. /*
  166. * si4713_device - private data
  167. */
  168. struct si4713_device {
  169. /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
  170. struct v4l2_subdev sd;
  171. struct v4l2_ctrl_handler ctrl_handler;
  172. /* private data structures */
  173. struct { /* si4713 control cluster */
  174. /* This is one big cluster since the mute control
  175. * powers off the device and after unmuting again all
  176. * controls need to be set at once. The only way of doing
  177. * that is by making it one big cluster. */
  178. struct v4l2_ctrl *mute;
  179. struct v4l2_ctrl *rds_ps_name;
  180. struct v4l2_ctrl *rds_radio_text;
  181. struct v4l2_ctrl *rds_pi;
  182. struct v4l2_ctrl *rds_deviation;
  183. struct v4l2_ctrl *rds_pty;
  184. struct v4l2_ctrl *rds_compressed;
  185. struct v4l2_ctrl *rds_art_head;
  186. struct v4l2_ctrl *rds_stereo;
  187. struct v4l2_ctrl *rds_ta;
  188. struct v4l2_ctrl *rds_tp;
  189. struct v4l2_ctrl *rds_ms;
  190. struct v4l2_ctrl *rds_dyn_pty;
  191. struct v4l2_ctrl *rds_alt_freqs_enable;
  192. struct v4l2_ctrl *rds_alt_freqs;
  193. struct v4l2_ctrl *compression_enabled;
  194. struct v4l2_ctrl *compression_threshold;
  195. struct v4l2_ctrl *compression_gain;
  196. struct v4l2_ctrl *compression_attack_time;
  197. struct v4l2_ctrl *compression_release_time;
  198. struct v4l2_ctrl *pilot_tone_enabled;
  199. struct v4l2_ctrl *pilot_tone_freq;
  200. struct v4l2_ctrl *pilot_tone_deviation;
  201. struct v4l2_ctrl *limiter_enabled;
  202. struct v4l2_ctrl *limiter_deviation;
  203. struct v4l2_ctrl *limiter_release_time;
  204. struct v4l2_ctrl *tune_preemphasis;
  205. struct v4l2_ctrl *tune_pwr_level;
  206. struct v4l2_ctrl *tune_ant_cap;
  207. };
  208. struct completion work;
  209. struct regulator *vdd;
  210. struct regulator *vio;
  211. struct gpio_desc *gpio_reset;
  212. struct platform_device *pd;
  213. u32 power_state;
  214. u32 rds_enabled;
  215. u32 frequency;
  216. u32 preemphasis;
  217. u32 stereo;
  218. u32 tune_rnl;
  219. };
  220. struct radio_si4713_platform_data {
  221. struct i2c_client *subdev;
  222. };
  223. #endif /* ifndef SI4713_I2C_H */