accdet.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _ACCDEH_H_
  2. #define _ACCDEH_H_
  3. #include <linux/kernel.h>
  4. #include <linux/module.h>
  5. #include <linux/init.h>
  6. #include <linux/device.h>
  7. #include <linux/slab.h>
  8. #include <linux/fs.h>
  9. #include <linux/mm.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/vmalloc.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/miscdevice.h>
  14. #include <linux/wait.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/ctype.h>
  17. #include <linux/semaphore.h>
  18. #include <linux/uaccess.h>
  19. #include <linux/io.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/switch.h>
  22. #include <linux/delay.h>
  23. #include <linux/device.h>
  24. #include <linux/kdev_t.h>
  25. #include <linux/fs.h>
  26. #include <linux/cdev.h>
  27. #include <linux/uaccess.h>
  28. #include <linux/kthread.h>
  29. #include <linux/input.h>
  30. #include <linux/wakelock.h>
  31. #include <linux/time.h>
  32. #include <linux/string.h>
  33. #include <reg_accdet.h>
  34. /*----------------------------------------------------------------------
  35. IOCTL
  36. ----------------------------------------------------------------------*/
  37. #define ACCDET_DEVNAME "accdet"
  38. #define ACCDET_IOC_MAGIC 'A'
  39. #define ACCDET_INIT _IO(ACCDET_IOC_MAGIC, 0)
  40. #define SET_CALL_STATE _IO(ACCDET_IOC_MAGIC, 1)
  41. #define GET_BUTTON_STATUS _IO(ACCDET_IOC_MAGIC, 2)
  42. /*define for phone call state*/
  43. #define CALL_IDLE 0
  44. #define CALL_RINGING 1
  45. #define CALL_ACTIVE 2
  46. #define KEY_CALL KEY_SEND
  47. #define KEY_ENDCALL KEY_HANGEUL
  48. #define ACCDET_TIME_OUT 0x61A80 /*400us*/
  49. extern s32 pwrap_read(u32 adr, u32 *rdata);
  50. extern s32 pwrap_write(u32 adr, u32 wdata);
  51. extern const struct file_operations *accdet_get_fops(void);/*from accdet_drv.c*/
  52. extern struct platform_driver accdet_driver_func(void); /*from accdet_drv.c*/
  53. extern struct headset_mode_settings *get_cust_headset_settings(void);
  54. extern struct headset_key_custom *get_headset_key_custom_setting(void);
  55. extern void accdet_create_attr_func(void); /*from accdet_drv.c*/
  56. #if defined(CONFIG_TS3A225E_ACCDET)
  57. extern struct i2c_client *ts3a225e_i2c_client;
  58. extern int ts3a225e_read_byte(unsigned char cmd, unsigned char *returnData);
  59. extern int ts3a225e_write_byte(unsigned char cmd, unsigned char writeData);
  60. #endif
  61. extern struct of_device_id accdet_of_match[];
  62. void mt_accdet_remove(void);
  63. void mt_accdet_suspend(void);
  64. void mt_accdet_resume(void);
  65. void mt_accdet_pm_restore_noirq(void);
  66. long mt_accdet_unlocked_ioctl(unsigned int cmd, unsigned long arg);
  67. int mt_accdet_probe(struct platform_device *dev);
  68. int accdet_get_cable_type(void);
  69. /****************************************************
  70. globle ACCDET variables
  71. ****************************************************/
  72. enum accdet_report_state {
  73. NO_DEVICE = 0,
  74. HEADSET_MIC = 1,
  75. HEADSET_NO_MIC = 2,
  76. /*HEADSET_ILEGAL = 3,*/
  77. /*DOUBLE_CHECK_TV = 4*/
  78. };
  79. enum accdet_status {
  80. PLUG_OUT = 0,
  81. MIC_BIAS = 1,
  82. /*DOUBLE_CHECK = 2,*/
  83. HOOK_SWITCH = 2,
  84. /*MIC_BIAS_ILLEGAL =3,*/
  85. /*TV_OUT = 5,*/
  86. STAND_BY = 4
  87. };
  88. enum hook_switch_result {
  89. DO_NOTHING = 0,
  90. ANSWER_CALL = 1,
  91. REJECT_CALL = 2
  92. };
  93. struct headset_mode_settings {
  94. int pwm_width; /*pwm frequence*/
  95. int pwm_thresh; /*pwm duty*/
  96. int fall_delay; /*falling stable time*/
  97. int rise_delay; /*rising stable time*/
  98. int debounce0; /*hook switch or double check debounce*/
  99. int debounce1; /*mic bias debounce*/
  100. int debounce3; /*plug out debounce*/
  101. };
  102. struct three_key_threshold {
  103. int mid_key;
  104. int up_key;
  105. int down_key;
  106. };
  107. struct four_key_threshold {
  108. int mid_key_four;
  109. int voice_key_four;
  110. int up_key_four;
  111. int down_key_four;
  112. };
  113. struct head_dts_data {
  114. int mic_mode_vol;
  115. struct headset_mode_settings headset_debounce;
  116. int accdet_plugout_debounce;
  117. int accdet_mic_mode;
  118. struct three_key_threshold three_key;
  119. struct four_key_threshold four_key;
  120. };
  121. #ifdef CONFIG_ACCDET_EINT
  122. extern struct platform_device accdet_device;
  123. #endif
  124. #endif