ssp_sensorhub.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 2013, Samsung Electronics Co. Ltd. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __SSP_SENSORHUB__
  16. #define __SSP_SENSORHUB__
  17. #include <linux/completion.h>
  18. #include <linux/kfifo.h>
  19. #include <linux/kthread.h>
  20. #include <linux/list.h>
  21. #include <linux/spinlock.h>
  22. #include "ssp.h"
  23. /* 'LIST_SIZE' should be be rounded-up to a power of 2 */
  24. #define LIST_SIZE 4
  25. #define MAX_DATA_COPY_TRY 2
  26. #define WAKE_LOCK_TIMEOUT (3*HZ)
  27. #define COMPLETION_TIMEOUT (2*HZ)
  28. #define DATA REL_RX
  29. #define BIG_DATA REL_RY
  30. #define NOTICE REL_RZ
  31. #define BIG_DATA_SIZE 256
  32. #define PRINT_TRUNCATE 6
  33. #define BIN_PATH_SIZE 100
  34. #define SENSORHUB_IOCTL_MAGIC 'S'
  35. #define IOCTL_READ_BIG_CONTEXT_DATA _IOR(SENSORHUB_IOCTL_MAGIC, 3, char *)
  36. #define sensorhub_info(str, args...) \
  37. pr_info("[SSP]: %s - " str, __func__, ##args)
  38. #define sensorhub_debug(str, args...) \
  39. pr_debug("[SSP]: %s - " str, __func__, ##args)
  40. #define sensorhub_err(str, args...) \
  41. pr_err("[SSP]: %s - " str, __func__, ##args)
  42. struct sensorhub_event {
  43. char *library_data;
  44. int library_length;
  45. };
  46. struct ssp_sensorhub_data {
  47. struct ssp_data *ssp_data;
  48. struct input_dev *sensorhub_input_dev;
  49. struct task_struct *sensorhub_task;
  50. struct miscdevice sensorhub_device;
  51. struct wake_lock sensorhub_wake_lock;
  52. struct completion read_done;
  53. struct completion big_read_done;
  54. struct completion big_write_done;
  55. struct sensorhub_event events[LIST_SIZE];
  56. struct sensorhub_event big_events;
  57. struct sensorhub_event big_send_events;
  58. struct kfifo fifo;
  59. bool is_big_event;
  60. int event_number;
  61. int pcm_cnt;
  62. wait_queue_head_t sensorhub_wq;
  63. spinlock_t sensorhub_lock;
  64. };
  65. int ssp_sensorhub_pcm_dump(struct ssp_sensorhub_data *hub_data);
  66. void ssp_sensorhub_report_notice(struct ssp_data *ssp_data, char notice);
  67. int ssp_sensorhub_handle_data(struct ssp_data *ssp_data, char *dataframe,
  68. int start, int end);
  69. int ssp_sensorhub_initialize(struct ssp_data *ssp_data);
  70. void ssp_sensorhub_remove(struct ssp_data *ssp_data);
  71. #endif