gpu: pvr: pdumpfs: add stream_frames debugfs entry
[sgx.git] / pvr / pvr_events.h
1
2 #ifndef PVR_EVENTS_H
3 #define PVR_EVENTS_H
4
5 #include "servicesext.h"
6 #include "private_data.h"
7 #include <linux/list.h>
8 #include <linux/file.h>
9 #include <linux/poll.h>
10
11 /*
12  * Header for events written back to userspace on the drm fd. The
13  * type defines the type of event, the length specifies the total
14  * length of the event (including the header), and user_data is
15  * typically a 64 bit value passed with the ioctl that triggered the
16  * event.  A read on the drm fd will always only return complete
17  * events, that is, if for example the read buffer is 100 bytes, and
18  * there are two 64 byte events pending, only one will be returned.
19  */
20 struct pvr_event {
21         __u32 type;
22         __u32 length;
23 };
24
25 #define PVR_EVENT_SYNC 0x01
26 #define PVR_EVENT_FLIP 0x02
27 #define PVR_EVENT_UPDATE 0x03 /* also uses struct pvr_event_flip */
28
29 /*
30  * Every buffer used as a render target has a 'PVRSRV_KERNEL_SYNC_INFO'
31  * associated with it. This structure simply contains four counters, number of
32  * pending and completed read and write operations. Counters for pending
33  * operations are modified (incremented) by the kernel driver while the
34  * counters for completed operations are directly updated by the SGX micro
35  * kernel. Once both the read counters and the write counters mutually match,
36  * one has completed a full frame.
37  *
38  * Micro kernel issues interrupts whenever TA or 3D phases are completed. These
39  * interrupts, however, as such do not tell if any particular frame is
40  * completed. It is the responsibility of the kerner driver to determine this.
41  * Hence the core interrupt handler calls 'pvr_handle_sync_events' to check if
42  * one of the monitored render operations are finished. This is accomplished by
43  * examining the before-mentioned counters designated by the pending events.
44  */
45 struct pvr_event_sync {
46         struct pvr_event base;
47         const struct PVRSRV_KERNEL_SYNC_INFO *sync_info;
48         __u64 user_data;
49         __u32 tv_sec;
50         __u32 tv_usec;
51 };
52
53 struct pvr_event_flip {
54         struct pvr_event base;
55         __u64 user_data;
56         __u32 tv_sec;
57         __u32 tv_usec;
58         __u32 overlay;
59 };
60
61 /* Event queued up for userspace to read */
62 struct pvr_pending_event {
63         struct pvr_event *event;
64         struct list_head link;
65         struct PVRSRV_FILE_PRIVATE_DATA *file_priv;
66         void (*destroy)(struct pvr_pending_event *event);
67         u32 write_ops_pending;
68 };
69
70 struct pvr_pending_sync_event {
71         struct pvr_pending_event base;
72         struct pvr_event_sync event;
73 };
74
75 struct pvr_pending_flip_event {
76         struct pvr_pending_event base;
77         struct pvr_event_flip event;
78         unsigned int dss_event;
79 };
80
81 enum pvr_sync_wait_seq_type;
82
83 void pvr_init_events(void);
84 void pvr_exit_events(void);
85
86 int pvr_sync_event_req(struct PVRSRV_FILE_PRIVATE_DATA *priv,
87                         const struct PVRSRV_KERNEL_SYNC_INFO *sync_info,
88                         u64 user_data);
89 int pvr_flip_event_req(struct PVRSRV_FILE_PRIVATE_DATA *priv,
90                          unsigned int overlay,
91                          enum pvr_sync_wait_seq_type type, u64 user_data);
92 ssize_t pvr_read(struct file *filp, char __user *buf, size_t count,
93                 loff_t *off);
94 unsigned int pvr_poll(struct file *filp, struct poll_table_struct *wait);
95 void pvr_release_events(struct PVRSRV_FILE_PRIVATE_DATA *priv);
96
97 void pvr_handle_sync_events(void);
98
99 #endif /* PVR_EVENTS_H */