Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 1 | #ifndef _GENLOCK_H_ |
| 2 | #define _GENLOCK_H_ |
| 3 | |
Jeff Boody | 6d9076f | 2012-04-26 11:12:44 -0600 | [diff] [blame^] | 4 | #include <linux/bitops.h> |
| 5 | |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 6 | #ifdef __KERNEL__ |
| 7 | |
| 8 | struct genlock; |
| 9 | struct genlock_handle; |
| 10 | |
| 11 | struct genlock_handle *genlock_get_handle(void); |
| 12 | struct genlock_handle *genlock_get_handle_fd(int fd); |
| 13 | void genlock_put_handle(struct genlock_handle *handle); |
| 14 | struct genlock *genlock_create_lock(struct genlock_handle *); |
| 15 | struct genlock *genlock_attach_lock(struct genlock_handle *, int fd); |
| 16 | int genlock_wait(struct genlock_handle *handle, u32 timeout); |
Jordan Crouse | 4df70a2 | 2012-01-25 14:40:51 -0700 | [diff] [blame] | 17 | /* genlock_release_lock was deprecated */ |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 18 | int genlock_lock(struct genlock_handle *handle, int op, int flags, |
| 19 | u32 timeout); |
| 20 | #endif |
| 21 | |
| 22 | #define GENLOCK_UNLOCK 0 |
| 23 | #define GENLOCK_WRLOCK 1 |
| 24 | #define GENLOCK_RDLOCK 2 |
| 25 | |
Jeff Boody | 6d9076f | 2012-04-26 11:12:44 -0600 | [diff] [blame^] | 26 | #define GENLOCK_NOBLOCK BIT(0) |
| 27 | #define GENLOCK_WRITE_TO_READ BIT(1) |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 28 | |
| 29 | struct genlock_lock { |
| 30 | int fd; |
| 31 | int op; |
| 32 | int flags; |
| 33 | int timeout; |
| 34 | }; |
| 35 | |
| 36 | #define GENLOCK_IOC_MAGIC 'G' |
| 37 | |
| 38 | #define GENLOCK_IOC_NEW _IO(GENLOCK_IOC_MAGIC, 0) |
| 39 | #define GENLOCK_IOC_EXPORT _IOR(GENLOCK_IOC_MAGIC, 1, \ |
| 40 | struct genlock_lock) |
| 41 | #define GENLOCK_IOC_ATTACH _IOW(GENLOCK_IOC_MAGIC, 2, \ |
| 42 | struct genlock_lock) |
Jeff Boody | 6d9076f | 2012-04-26 11:12:44 -0600 | [diff] [blame^] | 43 | |
| 44 | /* Deprecated */ |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 45 | #define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \ |
| 46 | struct genlock_lock) |
Jordan Crouse | 4df70a2 | 2012-01-25 14:40:51 -0700 | [diff] [blame] | 47 | |
| 48 | /* Deprecated */ |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 49 | #define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4) |
| 50 | #define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \ |
| 51 | struct genlock_lock) |
Jeff Boody | 6d9076f | 2012-04-26 11:12:44 -0600 | [diff] [blame^] | 52 | #define GENLOCK_IOC_DREADLOCK _IOW(GENLOCK_IOC_MAGIC, 6, \ |
| 53 | struct genlock_lock) |
Jordan Crouse | 29f66af | 2011-11-17 13:39:20 -0700 | [diff] [blame] | 54 | #endif |