ftsTime.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * FTS Capacitive touch screen controller (FingerTipS)
  4. *
  5. * Copyright (C) 2016-2019, STMicroelectronics Limited.
  6. * Authors: AMG(Analog Mems Group) <[email protected]>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. *
  23. **************************************************************************
  24. ** STMicroelectronics **
  25. **************************************************************************
  26. ** [email protected] **
  27. **************************************************************************
  28. * *
  29. * FTS Utility for mesuring/handling the time *
  30. * *
  31. **************************************************************************
  32. ***************************************************************************
  33. */
  34. #include <linux/init.h>
  35. #include <linux/errno.h>
  36. #include <linux/platform_device.h>
  37. #include <linux/kernel.h>
  38. #include <linux/module.h>
  39. #include <linux/slab.h>
  40. #include <linux/string.h>
  41. #include <stdarg.h>
  42. #include <linux/input.h>
  43. #include <linux/interrupt.h>
  44. #include <linux/serio.h>
  45. #include <linux/time.h>
  46. #include <linux/pm.h>
  47. #include <linux/delay.h>
  48. #include <linux/ctype.h>
  49. #include <linux/gpio.h>
  50. #include <linux/i2c.h>
  51. #include <linux/i2c-dev.h>
  52. #include <linux/fs.h>
  53. #include <linux/uaccess.h>
  54. #include <linux/power_supply.h>
  55. #include <linux/firmware.h>
  56. #include <linux/regulator/consumer.h>
  57. #include <linux/of_gpio.h>
  58. #include <linux/timekeeping.h>
  59. //#include <linux/sec_sysfs.h>
  60. #include "ftsCrossCompile.h"
  61. #include "ftsTime.h"
  62. void startStopWatch(struct StopWatch *w)
  63. {
  64. w->start = ktime_to_timespec64(ktime_get());
  65. }
  66. void stopStopWatch(struct StopWatch *w)
  67. {
  68. w->end = ktime_to_timespec64(ktime_get());
  69. }
  70. int elapsedMillisecond(struct StopWatch *w)
  71. {
  72. int result;
  73. result = ((w->end.tv_sec - w->start.tv_sec) * 1000)
  74. + (w->end.tv_nsec - w->start.tv_nsec) / 1000000;
  75. return result;
  76. }
  77. int elapsedNanosecond(struct StopWatch *w)
  78. {
  79. int result;
  80. result = ((w->end.tv_sec - w->start.tv_sec) * 1000000000)
  81. + (w->end.tv_nsec - w->start.tv_nsec);
  82. return result;
  83. }
  84. char *timestamp()
  85. {
  86. char *result = NULL;
  87. result = (char *)kmalloc_array(1, sizeof(char), GFP_KERNEL);
  88. if (result == NULL)
  89. return NULL;
  90. result[0] = ' ';
  91. return result;
  92. }
  93. void stdelay(unsigned long ms)
  94. {
  95. msleep(ms);
  96. }