tdmb.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. *
  3. * drivers/media/tdmb/tdmb.h
  4. *
  5. * tdmb driver
  6. *
  7. * Copyright (C) (2011, Samsung Electronics)
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #ifndef _TDMB_H_
  20. #define _TDMB_H_
  21. #include <linux/types.h>
  22. #include <linux/irq.h>
  23. #include <linux/interrupt.h>
  24. #include <mach/gpio.h>
  25. #define TDMB_DEBUG
  26. #ifdef TDMB_DEBUG
  27. #define DPRINTK(x...) printk(KERN_DEBUG "TDMB " x)
  28. #else
  29. #define DPRINTK(x...) /* null */
  30. #endif
  31. #define TDMB_DEV_NAME "tdmb"
  32. #define TDMB_DEV_MAJOR 225
  33. #define TDMB_DEV_MINOR 0
  34. #define DMB_TS_SIZE 188
  35. #define TDMB_RING_BUFFER_SIZE (188 * 150 + 4 + 4)
  36. #define TDMB_RING_BUFFER_MAPPING_SIZE \
  37. (((TDMB_RING_BUFFER_SIZE - 1) / PAGE_SIZE + 1) * PAGE_SIZE)
  38. /* commands */
  39. #define IOCTL_MAGIC 't'
  40. #define IOCTL_MAXNR 32
  41. #define IOCTL_TDMB_GET_DATA_BUFFSIZE _IO(IOCTL_MAGIC, 0)
  42. #define IOCTL_TDMB_GET_CMD_BUFFSIZE _IO(IOCTL_MAGIC, 1)
  43. #define IOCTL_TDMB_POWER_ON _IO(IOCTL_MAGIC, 2)
  44. #define IOCTL_TDMB_POWER_OFF _IO(IOCTL_MAGIC, 3)
  45. #define IOCTL_TDMB_SCAN_FREQ_ASYNC _IO(IOCTL_MAGIC, 4)
  46. #define IOCTL_TDMB_SCAN_FREQ_SYNC _IO(IOCTL_MAGIC, 5)
  47. #define IOCTL_TDMB_SCANSTOP _IO(IOCTL_MAGIC, 6)
  48. #define IOCTL_TDMB_ASSIGN_CH _IO(IOCTL_MAGIC, 7)
  49. #define IOCTL_TDMB_GET_DM _IO(IOCTL_MAGIC, 8)
  50. #define IOCTL_TDMB_ASSIGN_CH_TEST _IO(IOCTL_MAGIC, 9)
  51. #define IOCTL_TDMB_SET_AUTOSTART _IO(IOCTL_MAGIC, 10)
  52. struct tdmb_dm {
  53. unsigned int rssi;
  54. unsigned int ber;
  55. unsigned int per;
  56. unsigned int antenna;
  57. } ;
  58. #define SUB_CH_NUM_MAX 64
  59. #define ENSEMBLE_LABEL_MAX 16
  60. #define SVC_LABEL_MAX 16
  61. enum {
  62. TMID_MSC_STREAM_AUDIO = 0x00,
  63. TMID_MSC_STREAM_DATA = 0x01,
  64. TMID_FIDC = 0x02,
  65. TMID_MSC_PACKET_DATA = 0x03
  66. };
  67. enum {
  68. DSCTy_TDMB = 0x18,
  69. /* Used for All-Zero Test */
  70. DSCTy_UNSPECIFIED = 0x00
  71. };
  72. struct sub_ch_info_type {
  73. /* Sub Channel Information */
  74. unsigned char sub_ch_id; /* 6 bits */
  75. unsigned short start_addr; /* 10 bits */
  76. /* FIG 0/2 */
  77. unsigned char tmid; /* 2 bits */
  78. unsigned char svc_type; /* 6 bits */
  79. unsigned long svc_id; /* 16/32 bits */
  80. unsigned char svc_label[SVC_LABEL_MAX+1]; /* 16*8 bits */
  81. unsigned char ecc; /* 8 bits */
  82. unsigned char scids; /* 4 bits */
  83. } ;
  84. struct ensemble_info_type {
  85. unsigned long ensem_freq; /* 4 bytes */
  86. unsigned char tot_sub_ch; /* MAX: 64 */
  87. unsigned short ensem_id;
  88. unsigned char ensem_label[ENSEMBLE_LABEL_MAX+1];
  89. struct sub_ch_info_type sub_ch[SUB_CH_NUM_MAX];
  90. } ;
  91. #define TDMB_CMD_START_FLAG 0x7F
  92. #define TDMB_CMD_END_FLAG 0x7E
  93. #define TDMB_CMD_SIZE 30
  94. /* Result Value */
  95. #define DMB_FIC_RESULT_FAIL 0x00
  96. #define DMB_FIC_RESULT_DONE 0x01
  97. #define DMB_TS_PACKET_RESYNC 0x02
  98. irqreturn_t tdmb_irq_handler(int irq, void *dev_id);
  99. unsigned long tdmb_get_chinfo(void);
  100. void tdmb_pull_data(struct work_struct *work);
  101. bool tdmb_control_irq(bool set);
  102. void tdmb_control_gpio(bool poweron);
  103. bool tdmb_create_workqueue(void);
  104. bool tdmb_destroy_workqueue(void);
  105. bool tdmb_create_databuffer(unsigned long int_size);
  106. void tdmb_destroy_databuffer(void);
  107. void tdmb_init_data(void);
  108. #if defined(CONFIG_TDMB_ANT_DET)
  109. bool tdmb_ant_det_irq_set(bool set);
  110. #endif
  111. struct tdmb_if_gpio_func {
  112. void (*gpio_cfg_on) (void);
  113. void (*gpio_cfg_off) (void);
  114. };
  115. #if defined(CONFIG_TDMB_EBI)
  116. struct tdmb_ebi_dt_data {
  117. u32 cs_base;
  118. u32 mem_size;
  119. };
  120. #endif
  121. #if defined(CONFIG_TDMB_I2C)
  122. struct tdmb_i2c_dev {
  123. struct i2c_client *client;
  124. struct mutex lock;
  125. };
  126. #endif
  127. struct tdmb_dt_platform_data {
  128. int tdmb_irq;
  129. int tdmb_en;
  130. int tdmb_rst;
  131. int tdmb_use_rst;
  132. int tdmb_use_irq;
  133. #ifdef CONFIG_TDMB_ANT_DET
  134. int tdmb_ant_irq;
  135. #endif
  136. #ifdef CONFIG_TDMB_VREG_SUPPORT
  137. struct regulator *tdmb_vreg;
  138. const char *tdmb_vreg_name;
  139. #endif
  140. };
  141. unsigned char tdmb_make_result
  142. (
  143. unsigned char cmd,
  144. unsigned short data_len,
  145. unsigned char *data
  146. );
  147. bool tdmb_store_data(unsigned char *data, unsigned long len);
  148. struct tdmb_drv_func {
  149. bool (*init) (void);
  150. bool (*power_on) (void);
  151. void (*power_off) (void);
  152. bool (*scan_ch) (struct ensemble_info_type *ensembleInfo,
  153. unsigned long freq);
  154. void (*get_dm) (struct tdmb_dm *info);
  155. bool (*set_ch) (unsigned long freq, unsigned char subchid,
  156. bool factory_test);
  157. void (*pull_data) (void);
  158. unsigned long (*get_int_size) (void);
  159. };
  160. extern unsigned int *tdmb_ts_head;
  161. extern unsigned int *tdmb_ts_tail;
  162. extern char *tdmb_ts_buffer;
  163. extern unsigned int tdmb_ts_size;
  164. #if defined(CONFIG_TDMB_T3900) || defined(CONFIG_TDMB_T39F0)
  165. struct tdmb_drv_func *t3900_drv_func(void);
  166. #endif
  167. #if defined(CONFIG_TDMB_FC8050)
  168. struct tdmb_drv_func *fc8050_drv_func(void);
  169. #endif
  170. #if defined(CONFIG_TDMB_FC8080)
  171. struct tdmb_drv_func *fc8080_drv_func(void);
  172. #endif
  173. #if defined(CONFIG_TDMB_MTV318)
  174. struct tdmb_drv_func *mtv318_drv_func(void);
  175. #endif
  176. #if defined(CONFIG_TDMB_MTV319)
  177. struct tdmb_drv_func *mtv319_drv_func(void);
  178. #endif
  179. #if defined(CONFIG_TDMB_TCC3170)
  180. struct tdmb_drv_func *tcc3170_drv_func(void);
  181. extern struct tcbd_fic_ensbl *tcbd_fic_get_ensbl_info(s32 _disp);
  182. #endif
  183. extern unsigned long tdmb_get_if_handle(void);
  184. #if defined(CONFIG_TDMB_TSIF_SLSI) || defined(CONFIG_TDMB_TSIF_QC)
  185. extern int tdmb_tsi_start(void (*callback)(u8 *data, u32 length), int packet_cnt);
  186. extern int tdmb_tsi_stop(void);
  187. extern int tdmb_tsi_init(void);
  188. extern void tdmb_tsi_deinit(void);
  189. #endif
  190. #ifdef CONFIG_SAMSUNG_LPM_MODE
  191. extern int poweroff_charging;
  192. #endif
  193. #endif