aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/videox/mt6735/mtkfb_fence.h
blob: 9082c9436cba1219b3a7879e4b017633c637efcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#ifndef __MTKFB_FENCE_H__
#define __MTKFB_FENCE_H__

#include <linux/mutex.h>
#include <linux/list.h>
#include "disp_session.h"
#include "disp_drv_platform.h"
#include "display_recorder.h"

#ifdef __cplusplus
extern "C" {
#endif


#define MTK_FB_INVALID_ION_FD	   (-1)
#define MTK_FB_INVALID_FENCE_FD    (-1)

#define MTK_FB_KERNEL_NO_ION_FD    (-99)

struct fb_overlay_buffer_t{
	//	Input
	int layer_id;
	unsigned int layer_en;
	int ion_fd;
	unsigned int cache_sync;
    // Output
	unsigned int index;
    int fence_fd;
};

typedef enum
{
    create,
    insert,
    reg_configed,
    reg_updated,
    read_done
} BUFFER_STATE;

struct mtkfb_fence_buf_info 
{
	struct list_head list;
	unsigned int idx;
	int fence;
	struct ion_handle *hnd;
	unsigned long mva;
	unsigned long va;
	unsigned int size;
	unsigned int mva_offset;
	BUFFER_STATE buf_state;
	unsigned int cache_sync;	
	unsigned int set_input_ticket;
	unsigned int trigger_ticket;		// we can't update trigger_ticket_end, because can't gurantee ticket being updated before cmdq callback
	unsigned int release_ticket;
	unsigned int enable;
	unsigned long long ts_create;
	unsigned long long ts_period_keep;
	unsigned int seq;
};

struct mtkfb_fence_sync_info 
{
	unsigned int inited;
	struct mutex mutex_lock;
	unsigned int layer_id;
	unsigned int fence_idx;
	unsigned int timeline_idx;
	unsigned int inc;
	unsigned int cur_idx;
	struct sw_sync_timeline *timeline;
	struct list_head buf_list;
};




// use another struct to avoid fence dependency with ddp_ovl.h
typedef struct
{
	unsigned int layer;
	unsigned int layer_en;
	unsigned int fmt;
	unsigned long addr;  
	unsigned long vaddr;
	unsigned int src_x;
	unsigned int src_y;
	unsigned int src_w;
	unsigned int src_h;
	unsigned int src_pitch;
	unsigned int dst_x;
	unsigned int dst_y;
	unsigned int dst_w;
	unsigned int dst_h;                  // clip region
	unsigned int keyEn;
	unsigned int key; 
	unsigned int aen; 
	unsigned char alpha;  

	unsigned int isDirty;

	unsigned int buff_idx;
	unsigned int security;
}FENCE_LAYER_INFO;

typedef struct 
{
	unsigned int inited;
	struct mutex sync_lock;
	unsigned int layer_id;
	unsigned int fence_idx;
	unsigned int timeline_idx;
	unsigned int fence_fd;
	unsigned int inc;
	unsigned int cur_idx;
	struct sw_sync_timeline *timeline;
	struct list_head buf_list;
	FENCE_LAYER_INFO cached_config;
}disp_sync_info;

typedef struct
{
	unsigned int session_id;
	disp_sync_info session_layer_info[DISP_SESSION_TIMELINE_COUNT];
	dprec_logger_event event_prepare;
	dprec_logger_event event_setinput;
	dprec_logger_event event_setoutput;	
	dprec_logger_event event_trigger;
	dprec_logger_event event_findidx;
	dprec_logger_event event_release;
	dprec_logger_event event_waitvsync;
	dprec_logger_event event_err;
}disp_session_sync_info;


void mtkfb_init_fence(void);
unsigned int mtkfb_query_buf_mva(unsigned int session_id, unsigned int layer_id, unsigned int idx);
unsigned int mtkfb_query_buf_va(unsigned int session_id, unsigned int layer_id, unsigned int idx) ;
unsigned int mtkfb_update_buf_ticket(unsigned int session_id, unsigned int layer_id, unsigned int idx, unsigned int ticket) ;
unsigned int mtkfb_query_idx_by_ticket(unsigned int session_id, unsigned int layer_id, unsigned int ticket) ;
unsigned int mtkfb_query_release_idx(unsigned int session_id, unsigned int layer_id, unsigned long phy_addr);
unsigned int mtkfb_query_frm_seq_by_addr(unsigned int session_id, unsigned int layer_id, unsigned int phy_addr) ;
bool mtkfb_update_buf_info(unsigned int session_id, unsigned int layer_id, unsigned int idx, unsigned int mva_offset, unsigned int seq);
struct mtkfb_fence_buf_info* mtkfb_init_buf_info(struct mtkfb_fence_buf_info *buf);
void mtkfb_release_fence(unsigned int session_id, unsigned int layer_id, int fence);
int mtkfb_find_fence_by_ticket(unsigned int session_id, int layer_id, int ticket);
void mtkfb_update_fence_set_input_ticket(unsigned int session_id, unsigned int layer_id, int fence, unsigned int ticket, int enable);
void mtkfb_update_present_fence_ticket(unsigned int session_id, int fence, unsigned int ticket);
void mtkfb_update_fence_trigger_ticket(unsigned int session_id, unsigned int layer_id, int fence, unsigned int ticket) ;
void mtkfb_release_present_fence(unsigned int session_id, int fence) ;
void mtkfb_release_layer_fence(unsigned int session_id, unsigned int layer_id);
//int mtkfb_get_present_fence(disp_present_fence_info *buf, unsigned int *fence_fd, unsigned int *idx);
int mtkfb_fence_clean_thread(void *data);
int mtkfb_fence_timeline_index();

struct mtkfb_fence_buf_info* disp_sync_prepare_buf(disp_buffer_info *buf);
int disp_sync_init(void) ;
int disp_sync_get_cached_layer_info(unsigned int session_id, unsigned int timeline_idx, unsigned int *layer_en, unsigned long *addr, unsigned int *fence_idx);
int disp_sync_put_cached_layer_info(unsigned int session_id, unsigned int timeline_idx, disp_input_config* src, unsigned long mva);

int disp_sync_convert_input_to_fence_layer_info(disp_input_config* src, FENCE_LAYER_INFO *dst, unsigned long dst_mva);
int disp_sync_find_fence_idx_by_addr(unsigned int session_id, unsigned int timeline_id, unsigned long phy_addr, unsigned int offset);
unsigned int disp_sync_query_buf_info(unsigned int session_id, unsigned int timeline_id, unsigned int idx, unsigned long *mva, unsigned int *size);
int disp_sync_get_debug_info(char* stringbuf, int buf_len);
int disp_sync_get_ovl_timeline_id(int layer_id);
int disp_sync_get_output_timeline_id(void);
int disp_sync_get_output_interface_timeline_id(void);
int disp_sync_get_present_timeline_id(void);
disp_session_sync_info *disp_get_session_sync_info_for_debug(unsigned int session_id);

#ifdef __cplusplus
}
#endif


#endif