aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/emgd/display/mode/cmn/mode_dispatch.h
blob: 0d2d99573208b39e30c5b2313ec60c6c9e7fcbeb (plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: mode_dispatch.h
 * $Revision: 1.9 $
 *-----------------------------------------------------------------------------
 * Copyright © 2002-2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *-----------------------------------------------------------------------------
 * Description:
 *  This header file defined the interface between the DI layer of the mode
 *  module and the DD layer. Additionally it defines the interface between
 *  the different DI object files within the mode module.
 *-----------------------------------------------------------------------------
 */

#ifndef _MODE_DISPATCH_H
#define _MODE_DISPATCH_H

#include <mode.h>

typedef struct _mode_full_dispatch {
	int (*alter_cursor_pos)(igd_display_h display_handle,
		igd_cursor_info_t *cursor_info);
	int (*set_palette_entries)(igd_display_h display_handle,
		unsigned long *palette_colors, unsigned int start_index,
		unsigned int count);
	int (*wait_vsync)(igd_display_h display_handle);
	int (*query_in_vblank)(igd_display_h display_handle);
	int (*get_scanline)(igd_display_h display_handle, int *scanline);
	int (*set_display_base)(igd_display_context_t *display,
		igd_framebuffer_info_t *fb, unsigned long *x, unsigned long *y);
	void (*program_cursor)(igd_display_context_t *display,
		unsigned long status);
	int (*set_color_correct)(igd_display_context_t *display);
	int (*get_surface)(igd_display_h display_handle, igd_buffertype_t type,
		igd_surface_t *surface, igd_appcontext_h appcontext);
	int (*set_surface)(igd_display_h display_handle, int priority,
		igd_buffertype_t type, igd_surface_t *surface,
		igd_appcontext_h appcontext, unsigned long flags);
	int (*query_event)(igd_display_h display_handle, igd_event_t event,
		unsigned long *status);

	int (*set_flip_pending)(unsigned char *mmio,
		unsigned long pipe_status_reg);
	int (*check_flip_pending)(unsigned char *mmio,
		unsigned long pipe_status_reg);

	int (*get_plane_info)(void); /* dispatch routines that gets fw info */
	int (*get_pipe_info)(igd_display_h *display );
	int (*get_port_info)(void);
	/* Implementation of "public" igd_dispatch_t.register_vblank_callback(). */
	emgd_vblank_callback_h (*register_vblank_callback)(
		emgd_process_vblank_interrupt_t callback,
		void *priv,
		unsigned long port_number);
	/* Implementation of "public" igd_dispatch_t.unregister_vblank_callback().
	 */
	void (*unregister_vblank_callback)(
		emgd_vblank_callback_h callback_h);
	/* Implementation of "public" igd_dispatch_t.enable_vblank_callback(). */
	int (*enable_vblank_callback)(emgd_vblank_callback_h callback_h);
	/* Implementation of "public" igd_dispatch_t.disable_vblank_callback(). */
	void (*disable_vblank_callback)(
		emgd_vblank_callback_h callback_h);
	/*!
	 * Implementation of "protected" function (i.e. for use within the mode
	 * module) to request VBlank interrupts for a particular purpose & port.
	 * Based upon the outstanding requests, this function decides whether to
	 * touch registers, register the interrupt handler, etc.
	 *
	 * @param request_for (IN).  A bit that identifies a who and what (e.g.
	 *  VBINT_REQUEST(VBINT_WAIT, VBINT_PORT4)).
	 *
	 * @param mmio (IN).  A pointer to the start of memory-mapped IO, to access
	 * registers.
	 *
	 * @return Zero for success, non-zero for failure.
	 */
	int (*request_vblanks)(unsigned long request_for, unsigned char *mmio);
	/*!
	 * Implementation of "protected" function (i.e. for use within the mode
	 * module) to end a previous request VBlank interrupts for a particular
	 * purpose & port.  Based upon the outstanding requests, this function
	 * decides whether to touch registers, unregister the interrupt handler,
	 * etc.
	 *
	 * @param request_for (IN).  A bit that identifies a who and what (e.g.
	 *  VBINT_REQUEST(VBINT_WAIT, VBINT_PORT4)).
	 *
	 * @param mmio (IN).  A pointer to the start of memory-mapped IO, to access
	 * registers.
	 *
	 * @return Zero for success, non-zero for failure.
	 */
	int (*end_request)(unsigned long request_for, unsigned char *mmio);
	/*!
	 * Implementation of "protected" function (i.e. for use within the mode
	 * module) to check whether a requested VBlank interrupt occured.
	 *
	 * @param request_for (IN).  A bit that identifies a who and what (e.g.
	 *  VBINT_REQUEST(VBINT_WAIT, VBINT_PORT4)).
	 *
	 * @return Non-zero if the requested VBlank occured, zero if not.
	 */
	int (*vblank_occured)(unsigned long request_for);
} mode_full_dispatch_t;

typedef struct _mode_dispatch {
	int (*set_palette_entry)(igd_display_h display_handle,
		unsigned long palette_entry, unsigned long palette_color);
	int (*get_palette_entry)(igd_display_h display_handle,
		unsigned long palette_entry, unsigned long *palette_color);
	int (*wait_vblank)(igd_display_h display_handle);
	void (*program_plane)(igd_display_context_t *display,
		unsigned long status);
	void (*program_pipe)(igd_display_context_t *display, unsigned long status);
	int (*program_port)(igd_display_context_t *display,
		unsigned short port_number, unsigned long status);
	int (*post_program_port)(igd_display_context_t *display,
		unsigned short port_number, unsigned long status);
	int (*program_clock)(igd_display_context_t *display,
		igd_clock_t *clock, unsigned long dclk);
	void (*reset_plane_pipe_ports)(igd_context_t *context);
	unsigned long (*get_gpio_sets)(unsigned long **);
	void (*filter_modes)(igd_context_t *context,
		igd_display_port_t *port, pd_timing_t *in_list);
	int (*check_display)(igd_display_context_t *display,
		unsigned short port_number, unsigned long status);
	int (*get_dd_timing)(igd_display_context_t *display,
		pd_timing_t *in_list); 
	int (*check_port_supported)(void *port_tmp);
	int (*get_refresh_in_border)(pd_timing_t *in_list);
	mode_full_dispatch_t *full;
} mode_dispatch_t;


/*
 * Firmware(VBIOS or EFI Video Driver) related information
 * that needs to be populated  before the driver re-programs
 * the Hardware Registers. This information is needed to provide
 * seamless transition from firmware to driver.
 */
typedef struct _fw_info {

	/* TODO: Fill this up */
	unsigned long fw_dc; /* The dsp module already has this value */

	/* Plane information */
	igd_framebuffer_info_t fb_info[2]; /* one for each plane */

	/* Pipe information */
	igd_display_info_t timing_arr[2]; /* one for each pipe */

	/* Port information */

	/* if the plane registers needs an update, set this field to 1 */
	int program_plane;

} fw_info_t;

typedef struct _mode_context {
	/*
	 * All of the below values will be initialized in mode module
	 * init function mode_init().
	 */
	unsigned long  first_alter;
	mode_dispatch_t *dispatch;

	igd_context_t *context;
	unsigned long display_color;
	fw_info_t* fw_info; /* This needs to be zero for VBIOS */

    /* quickboot options */
    unsigned long quickboot;
    int seamless;
    unsigned long video_input;
    int splash;
} mode_context_t;

extern int full_mode_init(igd_context_t *context,
	mode_context_t *mode_context);

extern int full_mode_query(igd_driver_h driver_handle, unsigned long dc,
	igd_display_info_t **mode_list, igd_display_port_t *port);

extern void full_clear_fb(mode_context_t *mode_context,
	igd_framebuffer_info_t *fb_info,
	unsigned char *fb);

extern int query_seamless(unsigned long dc,
		int index,
		igd_timing_info_t *pt,
		igd_framebuffer_info_t *pf,
		unsigned long flags);

extern void swap_fb_cursor( void );

extern int set_color_correct(igd_display_context_t *display,
	const igd_range_attr_t *attr_to_set);

extern mode_context_t mode_context[];

/*
 * NOTE: Some of these externs are declared with the struct name because the
 * contents of that struct are unavailable at the DI layer. The symbol
 * is used as the generic mode_dispatch_t which is a subset.
 */


extern mode_dispatch_t mode_dispatch_plb;
extern mode_dispatch_t mode_dispatch_tnc;


/*******************************************************************************
 *
 * The following macros provide part of the "protected" interface to support
 * mode-module "requests" for VBlank interrupts.
 *
 * Requests are for a "who" and "what."  The "who" is what type of code is
 * making the request, and the "what" is the port that the requestor wants to
 * know about VBlanks for.  Here is additional information:
 *
 * - Who - which software is asking:
 *   - WAIT - The code that implements the wait_vblank() function pointer.
 *            When interrupts are requested for WAIT, the interrupt handler
 *            makes note of when VBlanks occur.  The WAIT code queries (polls)
 *            whether a VBlank has occured since its request.
 *   - FLIP - The code that implements the {check|set}_flip_pending() function
 *            pointers.  When interrupts are requested for FLIP, the interrupt
 *            handler makes note of when VBlanks occur.  The FLIP code queries
 *            (polls) whether a VBlank has occured since its request.
 *   - CB -   The non-HAL code that registers a VBlank interrupt "callback"
 *            (CB).  When interrupts are requested for CB, the interrupt
 *            handler calls the callback when VBlanks occur.
 *
 * - What - which port (Note: space is reserve for 4 ports, even only two exist
 *   at this time):
 *   - PORT2 (Port 2, Pipe A, SDVO-B)
 *   - PORT4 (Port 4, Pipe B, Int-LVDS)
 *
 * Note: internally, the requests are stored in bits within an unsigned long.
 * This helps explain the way the macros are implemented:
 *
 ******************************************************************************/

/* A requestor uses this macro to generate the bit request for who and what: */
#define VBINT_REQUEST(who,port) ((port) << (who))

/* A requestor uses one of these macros to specify a what (i.e. port): */
#define VBINT_PORT2 0x01
#define VBINT_PORT4 0x02
/* Note: the following 2 macros reserve space for 2 more (future) ports: */
#define VBINT_PORTn 0x04
#define VBINT_PORTm 0x08

/* A requestor uses one of these macros to identify itself (the what): */
/* Note: Each "who" has 4 bits (for 4 ports); the value is a shift amount: */
#define VBINT_WAIT 0
#define VBINT_FLIP 4
#define VBINT_CB   8


/*******************************************************************************
 *
 * The following macros provide part of the "private" interface to support
 * mode-module "requests" for VBlank interrupts.  The VBlank-interrupt code
 * uses these macros to manage requests, and to record VBlanks that occur
 * (a.k.a. "answers").
 *
 * Other parts of the "mode" module should not use these macros.
 *
 ******************************************************************************/

/* Answers for a request are stored in bits to the left of the request bits: */
#define VBINT_ANSWER_SHIFT 12
#define VBINT_ANSWER(who,port) (((port) << (who)) << VBINT_ANSWER_SHIFT)
#define VBINT_ANSWER4_REQUEST(request) ((request) << VBINT_ANSWER_SHIFT)

/* The following special bit is used by disable_vblank_interrupts_{plb|tnc}() to
 * disable the hardware, but not unregister the never-registered interrupt
 * handler:
 */
#define VBLANK_DISABLE_HW_ONLY BIT31

/* The following macros aggregate all of the who's can enable interrupts for a
 * given port:
 */
#define VBLANK_INT4_PORT2 (VBINT_REQUEST(VBINT_WAIT, VBINT_PORT2) | \
	VBINT_REQUEST(VBINT_FLIP, VBINT_PORT2) |						\
	VBINT_REQUEST(VBINT_CB, VBINT_PORT2))
#define VBLANK_INT4_PORT4 (VBINT_REQUEST(VBINT_WAIT, VBINT_PORT4) | \
	VBINT_REQUEST(VBINT_FLIP, VBINT_PORT4) |						\
	VBINT_REQUEST(VBINT_CB, VBINT_PORT4))

/* The following macros aggregate all of the whats (ports) that can enable
 * interrupts for a given who (they aren't used, but do help document that
 * 4 bits are reserved for each "who"):
 */
/* FIXME -- KEEP THESE??? */
#define VBLANK_INT4_WAIT 0x0000000f
#define VBLANK_INT4_FLIP 0x000000f0
#define VBLANK_INT4_CB   0x00000f00

/* The following macros tell whether interrupts are enabled, either in general,
 * or for a certain port.
 */
#define VBLANK_INTERRUPTS_ENABLED \
	(vblank_interrupt_state & (VBLANK_INT4_PORT2 | VBLANK_INT4_PORT4 | \
		VBLANK_DISABLE_HW_ONLY))
#define VBLANK_INTERRUPTS_ENABLED4_PORT2 \
	(vblank_interrupt_state & VBLANK_INT4_PORT2)
#define VBLANK_INTERRUPTS_ENABLED4_PORT4 \
	(vblank_interrupt_state & VBLANK_INT4_PORT4)

#endif