mtk_sync.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2011-2014 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify it under the terms of the
  5. * GNU General Public License version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  8. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. * See the GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License along with this program.
  12. * If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef _MTK_SYNC_H
  15. #define _MTK_SYNC_H
  16. /*
  17. * TIMEOUT_NEVER may be passed to the wait method to indicate that it
  18. * should wait indefinitely for the fence to signal.
  19. */
  20. #define TIMEOUT_NEVER -1
  21. /* --------------------------------------------------------------------------- */
  22. #ifdef __KERNEL__
  23. #include <linux/version.h>
  24. #include <../drivers/staging/android/sw_sync.h>
  25. /*
  26. * sync_timeline, sync_fence data structure
  27. */
  28. struct fence_data {
  29. __u32 value;
  30. char name[32];
  31. __s32 fence; /* fd of new fence */
  32. };
  33. /*
  34. * sync_timeline, sync_fence API
  35. */
  36. /**
  37. * timeline_create() - creates a sync object
  38. * @name: sync_timeline name
  39. *
  40. * The timeline_create() function creates a sync object named @name,
  41. * which represents a 32-bit monotonically increasing counter.
  42. */
  43. struct sw_sync_timeline *timeline_create(const char *name);
  44. /**
  45. * timeline_destroy() - releases a sync object
  46. * @obj: sync_timeline obj
  47. *
  48. * The timeline_destroy() function releases a sync object.
  49. * The remaining active points would be put into signaled list,
  50. * and their statuses are set to VENOENT.
  51. */
  52. void timeline_destroy(struct sw_sync_timeline *obj);
  53. /**
  54. * timeline_inc() - increases timeline
  55. * @obj: sync_timeline obj
  56. * @value: the increment to a sync object
  57. *
  58. * The timeline_inc() function increase the counter of @obj by @value
  59. * Each sync point contains a value. A sync point on a parent timeline transits
  60. * from active to signaled status when the counter of a timeline reaches
  61. * to that of a sync point.
  62. */
  63. void timeline_inc(struct sw_sync_timeline *obj, u32 value);
  64. /**
  65. * fence_create() - create a fence
  66. * @obj: sync_timeline obj
  67. * @data: fence struct with its name and the number a sync point bears
  68. *
  69. * The fence_create() function creates a new sync point with @data->value,
  70. * and assign the sync point to a newly created fence named @data->name.
  71. * A file descriptor binded with the fence is stored in @data->fence.
  72. */
  73. int fence_create(struct sw_sync_timeline *obj, struct fence_data *data);
  74. /**
  75. * fence_merge() - merge two fences into a new one
  76. * @name: fence name
  77. * @fd1: file descriptor of the first fence
  78. * @fd2: file descriptor of the second fence
  79. *
  80. * The fence_merge() function creates a new fence which contains copies of all
  81. * the sync_pts in both @fd1 and @fd2.
  82. * @fd1 and @fd2 remain valid, independent fences.
  83. * On success, the newly created fd is returned; Otherwise, a -errno is returned.
  84. */
  85. int fence_merge(char *const name, int fd1, int fd2);
  86. #endif /* __KERNEL __ */
  87. #endif /* _MTK_SYNC_H */