summaryrefslogtreecommitdiff
path: root/drivers/video/wmt/vout.h
blob: 069cc32e1254e0a2d6ec052e87b59c9945ce128a (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
/*++
 * linux/drivers/video/wmt/vout.h
 * WonderMedia video post processor (VPP) driver
 *
 * Copyright c 2013  WonderMedia  Technologies, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that 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, see <http://www.gnu.org/licenses/>.
 *
 * WonderMedia Technologies, Inc.
 * 4F, 533, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C
--*/

#ifndef VOUT_H
/* To assert that only one occurrence is included */
#define VOUT_H
/*-------------------- MODULE DEPENDENCY -------------------------------------*/
#include "vpp.h"
#include "sw_i2c.h"
#include "edid.h"

/*	following is the C++ header	*/
#ifdef	__cplusplus
extern	"C" {
#endif

/*-------------------- EXPORTED PRIVATE CONSTANTS ----------------------------*/
/* #define  VO_XXXX  1    *//*Example*/
/* #define CONFIG_VOUT_EDID_ALLOC */
#define CONFIG_VOUT_REFACTORY

#define VOUT_INFO_DEFAULT_RESX	1024
#define VOUT_INFO_DEFAULT_RESY	768
#define VOUT_INFO_DEFAULT_FPS	60

/*-------------------- EXPORTED PRIVATE TYPES---------------------------------*/
/* typedef  void  vo_xxx_t;  *//*Example*/
typedef enum {
	VOUT_SD_ANALOG,
	VOUT_SD_DIGITAL,
	VOUT_LCD,
	VOUT_DVI,
	VOUT_HDMI,
	VOUT_DVO2HDMI,
	VOUT_LVDS,
	VOUT_VGA,
	VOUT_BOOT,
	VOUT_MODE_MAX,
	VOUT_MODE_ALL = VOUT_MODE_MAX
} vout_mode_t;

typedef enum {
	VOUT_DEV_VGA,
	VOUT_DEV_DVI,
	VOUT_DEV_LCD,
	VOUT_DEV_HDMI,
	VOUT_DEV_SDD,
	VOUT_DEV_LVDS,
	VOUT_DEV_MODE_MAX
} vout_dev_mode_t;

typedef enum {
	VOUT_INF_DVI,
	VOUT_INF_HDMI,
	VOUT_INF_LVDS,
	VOUT_INF_MODE_MAX
} vout_inf_mode_t;

typedef enum {
	TV_PAL,
	TV_NTSC,
	TV_UNDEFINED,
	TV_MAX
} vout_tvformat_t;

typedef struct {
	int num;
	unsigned int vo_mask;	/* vo bit mask for multi vout */
	int govr_mod;		/* govr module type */
	govrh_mod_t *govr;	/* govr pointer */

	int resx;
	int resy;
	int resx_virtual;
	int resy_virtual;
	int bpp;
	int fps;
	unsigned int pixclk;
	unsigned int option;

	struct fb_videomode *fixed_vmode;
	vdo_framebuf_t fb;
#ifdef CONFIG_UBOOT
	struct fb_videomode *p_vmode;
#endif
	vpp_dbg_timer_t pandisp_timer;
} vout_info_t;

typedef struct {
	int fmt; /* sample bits */
	int sample_rate; /* sample rate */
	int channel; /* channel count */
} vout_audio_t;

struct vout_s;
struct vout_inf_s;

#define VOUT_DEV_CAP_FIX_RES		0x1
#define VOUT_DEV_CAP_EDID		0x2
#define VOUT_DEV_CAP_AUDIO		0x4
#define VOUT_DEV_CAP_FIX_PLUG		0x8

typedef struct vout_dev_s {
	struct vout_dev_s *next;
	char name[10];
	vout_inf_mode_t mode;
	struct vout_s *vout;
	unsigned int capability;

	int (*init)(struct vout_s *vo);
	void (*set_power_down)(int enable);
	int (*set_mode)(unsigned int *option);
	int (*config)(vout_info_t *info);
	int (*check_plugin)(int hotplug);
	int (*get_edid)(char *buf);
	int (*set_audio)(vout_audio_t *arg);
	int (*interrupt)(void);
	void (*poll)(void);
} vout_dev_t;

typedef enum {
	VOUT_BLANK_UNBLANK, /* screen: unblanked, hsync: on,  vsync: on */
	VOUT_BLANK_NORMAL,  /* screen: blanked,   hsync: on,  vsync: on */
	VOUT_BLANK_VSYNC_SUSPEND,/* screen: blanked,   hsync: on,  vsync: off */
	VOUT_BLANK_HSYNC_SUSPEND,/* screen: blanked,   hsync: off, vsync: on */
	VOUT_BLANK_POWERDOWN /* screen: blanked,   hsync: off, vsync: off */
} vout_blank_t;

#define VOUT_CAP_INTERFACE	0x000000FF
#define VOUT_CAP_BUS		0x00000F00
#define VOUT_CAP_GOVR		0x0000F000
#define VOUT_CAP_EXT_DEV	0x00010000
#define VOUT_CAP_FIX_PLUG	0x00020000
#define VOUT_CAP_AUDIO		0x00040000
#define VOUT_CAP_EDID		0x00080000

typedef struct vout_s {
	int num;
	unsigned int fix_cap;
	unsigned int var_cap;
	struct vout_inf_s *inf;	/* interface ops */
	vout_dev_t *dev; /* device ops */
	vout_dev_t *ext_dev;
	govrh_mod_t *govr;
	int resx;
	int resy;
	int pixclk;
	unsigned int status;
#ifdef CONFIG_VOUT_EDID_ALLOC
	char *edid;
#else
	char edid[128*EDID_BLOCK_MAX];
#endif
	edid_info_t edid_info;
	unsigned int option[3];
	vout_blank_t pre_blank;
} vout_t;

#define VOUT_INF_CAP_FIX_PLUG	BIT(0)
typedef struct vout_inf_s {
	vout_inf_mode_t mode;
	unsigned int capability;

	/* function */
	int (*init)(vout_t *vo, int arg);
	int (*uninit)(vout_t *vo, int arg);
	int (*blank)(vout_t *vo, vout_blank_t arg);
	int (*config)(vout_t *vo, int arg);
	int (*chkplug)(vout_t *vo, int arg);
	int (*get_edid)(vout_t *vo, int arg);
/*	int (*ioctl)(vout_t *vo,int arg); */
} vout_inf_t;

/*-------------------- EXPORTED PRIVATE VARIABLES ---------------------------*/
#ifdef VOUT_C /* allocate memory for variables only in vout.c */
#define EXTERN

const char *vout_inf_str[] = {"DVI", "HDMI", "LVDS", "VGA", "SDA", "SDD"};
const char *vout_adpt_str[] = {"SD_DIGITAL", "SD_DIGITAL", "LCD", "DVI",
	"HDMI", "DVO2HDMI", "LVDS", "VGA", "BOOT"};

#else
#define EXTERN   extern

extern const char *vout_inf_str[];
extern const char *vout_adpt_str[];

#endif /* ifdef VOUT_C */

EXTERN vout_info_t vout_info[VPP_VOUT_INFO_NUM];

/* EXTERN int      vo_xxx; *//*Example*/
EXTERN int (*vout_board_info)(int arg);

#undef EXTERN

/*--------------------- EXPORTED PRIVATE MACROS -----------------------------*/
/* #define VO_XXX_YYY   xxxx *//*Example*/
/*--------------------- EXPORTED PRIVATE FUNCTIONS  -------------------------*/
/* extern void  vo_xxx(void); *//*Example*/

void vout_register(int no, vout_t *vo);
vout_t *vout_get_entry(int no);
vout_info_t *vout_get_info_entry(int no);
void vout_change_status(vout_t *vo, int mask, int sts);
int vout_query_inf_support(int no, vout_inf_mode_t mode);

int vout_inf_register(vout_inf_mode_t mode, vout_inf_t *inf);
vout_inf_t *vout_inf_get_entry(vout_inf_mode_t mode);

int vout_device_register(vout_dev_t *ops);
vout_dev_t *vout_get_device(vout_dev_t *ops);

vout_t *vout_get_entry_adapter(vout_mode_t mode);
vout_inf_t *vout_get_inf_entry_adapter(vout_mode_t mode);
int vout_info_add_entry(vout_t *vo);
vout_info_t *vout_info_get_entry(int no);
void vout_info_set_fixed_timing(int no, struct fb_videomode *vmode);
govrh_mod_t *vout_info_get_govr(int no);

int vout_config(unsigned int mask,
	vout_info_t *info, struct fb_videomode *vmode);
int vout_set_mode(int no, vout_inf_mode_t mode);
int vout_set_blank(unsigned int mask, vout_blank_t blank);
void vout_set_tg_enable(unsigned int mask, int enable);
void vout_set_framebuffer(unsigned int mask, vdo_framebuf_t *fb);
int vout_chkplug(int no);
void vout_set_int_type(int type);
char *vout_get_edid(int no);
int vout_get_edid_option(int no);
int vout_check_plugin(int clr_sts);

int vout_init(void);
int vout_exit(void);
int vo_i2c_proc(int id, unsigned int addr, unsigned int index,
	char *pdata, int len);
int vout_set_audio(vout_audio_t *arg);
int vout_find_edid_support_mode(edid_info_t *info,
	unsigned int *resx, unsigned int *resy, unsigned int *fps, int r_16_9);
int vout_check_ratio_16_9(unsigned int resx, unsigned int resy);
unsigned int vout_get_mask(vout_info_t *vo_info);
void vout_set_int_enable(int enable);
int vout_get_clr_int(void);
void vo_hdmi_set_clock(int enable);
#ifndef CONFIG_VPOST
int vout_find_match_mode(int fbnum,
		struct fb_videomode *vmode, int match);
#endif
#define VOUT_MODE_OPTION_LESS		BIT0
#define VOUT_MODE_OPTION_GREATER	BIT1
#define VOUT_MODE_OPTION_EDID		BIT2
#define VOUT_MODE_OPTION_INTERLACE	BIT3
#define VOUT_MODE_OPTION_PROGRESS	BIT4
struct fb_videomode *vout_get_video_mode(int vout_num,
			struct fb_videomode *vmode, int option);
void vo_hdmi_cp_set_enable_tmr(int sec);
#ifdef	__cplusplus
}
#endif

#endif /* ifndef VOUT_H */

/*=== END vout.h ==========================================================*/