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