ssp_sensorhub.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/kthread.h>
  19. #include <linux/list.h>
  20. #include <linux/spinlock.h>
  21. #include "ssp.h"
  22. #define LIST_SIZE 5
  23. #define MAX_DATA_COPY_TRY 2
  24. #define WAKE_LOCK_TIMEOUT (3*HZ)
  25. #define COMPLETION_TIMEOUT (2*HZ)
  26. #define DATA REL_RX
  27. #define LARGE_DATA REL_RY
  28. #define NOTICE REL_RZ
  29. #define SENSORHUB_IOCTL_MAGIC 'S'
  30. #define IOCTL_READ_LARGE_CONTEXT_DATA _IOR(SENSORHUB_IOCTL_MAGIC, 3, char *)
  31. #define sensorhub_info(str, args...) pr_info("%s: " str, __func__, ##args)
  32. #define sensorhub_debug(str, args...) pr_debug("%s: " str, __func__, ##args)
  33. #define sensorhub_err(str, args...) pr_err("%s: " str, __func__, ##args)
  34. struct sensorhub_event {
  35. char *library_data;
  36. int library_length;
  37. struct list_head list;
  38. };
  39. struct ssp_sensorhub_data {
  40. struct ssp_data *ssp_data;
  41. struct input_dev *sensorhub_input_dev;
  42. struct miscdevice sensorhub_device;
  43. struct wake_lock sensorhub_wake_lock;
  44. struct completion sensorhub_completion;
  45. struct task_struct *sensorhub_task;
  46. struct sensorhub_event events_head;
  47. struct sensorhub_event events[LIST_SIZE];
  48. struct sensorhub_event *first_event;
  49. char *large_library_data;
  50. int large_library_length;
  51. int event_number;
  52. wait_queue_head_t sensorhub_wq;
  53. spinlock_t sensorhub_lock;
  54. };
  55. void ssp_sensorhub_report_notice(struct ssp_data *ssp_data, char notice);
  56. int ssp_sensorhub_handle_data(struct ssp_data *ssp_data, char *dataframe,
  57. int start, int end);
  58. int ssp_sensorhub_handle_large_data(struct ssp_data *ssp_data, u8 sub_cmd);
  59. int ssp_sensorhub_initialize(struct ssp_data *ssp_data);
  60. void ssp_sensorhub_remove(struct ssp_data *ssp_data);
  61. #endif