aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/samsung/tvout/s5p_tvout_common_lib.h
blob: 467ab1d627455bdb78c516d48c808c93478c76e6 (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
/* linux/drivers/media/video/samsung/tvout/s5p_tvout_common_lib.h
 *
 * Copyright (c) 2009 Samsung Electronics
 *		http://www.samsung.com/
 *
 * Header file of common library for SAMSUNG TVOUT driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _S5P_TVOUT_COMMON_LIB_H_
#define _S5P_TVOUT_COMMON_LIB_H_

#include <linux/stddef.h>
#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include <linux/interrupt.h>

/*****************************************************************************
 * This file includes declarations for TVOUT driver's common library.
 * All files in TVOUT driver can access function or definition in this file.
 ****************************************************************************/

#define DRV_NAME	"TVOUT"

#define tvout_err(fmt, ...)					\
		printk(KERN_ERR "[%s] %s(): " fmt,		\
			DRV_NAME, __func__, ##__VA_ARGS__)

#define CONFIG_TVOUT_DEBUG

#ifndef tvout_dbg
#ifdef CONFIG_TVOUT_DEBUG
#define tvout_dbg(fmt, ...)					\
do {								\
	if (unlikely(tvout_dbg_flag & (1 << DBG_FLAG_TVOUT))) {	\
		printk(KERN_INFO "[%s] %s(): " fmt,		\
			DRV_NAME, __func__, ##__VA_ARGS__);	\
	}							\
} while (0)
#else
#define tvout_dbg(fmt, ...)
#endif
#endif

/*
#if defined(CONFIG_MACH_T0) || defined(CONFIG_MACH_M3)
#define	__CONFIG_HDMI_SUPPORT_FULL_RANGE__
#endif
*/

#define S5PTV_FB_CNT	2
#define S5PTV_VP_BUFF_CNT	4
#define S5PTV_VP_BUFF_SIZE	(4*1024*1024)

#define to_tvout_plat(d) (to_platform_device(d)->dev.platform_data)

#define HDMI_START_NUM 0x1000

#ifdef CONFIG_CPU_EXYNOS4210
#define CLOCK_GATING_ON_EARLY_SUSPEND
#endif

enum s5p_tvout_disp_mode {
	TVOUT_NTSC_M = 0,
	TVOUT_PAL_BDGHI,
	TVOUT_PAL_M,
	TVOUT_PAL_N,
	TVOUT_PAL_NC,
	TVOUT_PAL_60,
	TVOUT_NTSC_443,

	TVOUT_480P_60_16_9 = HDMI_START_NUM,
	TVOUT_480P_60_4_3,
	TVOUT_480P_59,

	TVOUT_576P_50_16_9,
	TVOUT_576P_50_4_3,

	TVOUT_720P_60,
	TVOUT_720P_50,
	TVOUT_720P_59,

	TVOUT_1080P_60,
	TVOUT_1080P_50,
	TVOUT_1080P_59,
	TVOUT_1080P_30,

	TVOUT_1080I_60,
	TVOUT_1080I_50,
	TVOUT_1080I_59,
#ifdef CONFIG_HDMI_14A_3D
	TVOUT_720P_60_SBS_HALF,
	TVOUT_720P_59_SBS_HALF,
	TVOUT_720P_50_TB,
	TVOUT_1080P_24_TB,
	TVOUT_1080P_23_TB,
#endif
	TVOUT_INIT_DISP_VALUE
};

#ifdef CONFIG_HDMI_14A_3D
enum s5p_tvout_3d_type {
	HDMI_3D_FP_FORMAT,
	HDMI_3D_SSH_FORMAT,
	HDMI_3D_TB_FORMAT,
	HDMI_2D_FORMAT,
};
#endif

enum s5p_tvout_o_mode {
	TVOUT_COMPOSITE,
	TVOUT_HDMI,
	TVOUT_HDMI_RGB,
	TVOUT_DVI,
	TVOUT_INIT_O_VALUE
};

enum s5p_mixer_burst_mode {
	MIXER_BURST_8 = 0,
	MIXER_BURST_16 = 1
};

enum s5ptv_audio_channel {
	TVOUT_AUDIO_2CH = 0,
	TVOUT_AUDIO_5_1CH = 1,
	TVOUT_AUDIO_2CH_VAL = 2,
	TVOUT_AUDIO_5_1CH_VAL = 6,
};

enum s5ptvfb_data_path_t {
	DATA_PATH_FIFO = 0,
	DATA_PATH_DMA = 1,
};

enum s5ptvfb_alpha_t {
	LAYER_BLENDING,
	PIXEL_BLENDING,
	NONE_BLENDING,
};

enum s5ptvfb_ver_scaling_t {
	VERTICAL_X1,
	VERTICAL_X2,
};

enum s5ptvfb_hor_scaling_t {
	HORIZONTAL_X1,
	HORIZONTAL_X2,
};

struct s5ptvfb_alpha {
	enum s5ptvfb_alpha_t	mode;
	int			channel;
	unsigned int		value;
};

struct s5ptvfb_chroma {
	int		enabled;
	unsigned int	key;
};

struct s5ptvfb_user_window {
	int x;
	int y;
};

struct s5ptvfb_user_plane_alpha {
	int		channel;
	unsigned char	alpha;
};

struct s5ptvfb_user_chroma {
	int		enabled;
	unsigned char	red;
	unsigned char	green;
	unsigned char	blue;
};

struct s5ptvfb_user_scaling {
	enum s5ptvfb_ver_scaling_t ver;
	enum s5ptvfb_hor_scaling_t hor;
};

struct s5p_tvout_status {
	struct clk *i2c_phy_clk;
	struct clk *sclk_hdmiphy;
	struct clk *sclk_pixel;
	struct clk *sclk_dac;
	struct clk *sclk_hdmi;
	spinlock_t tvout_lock;
};

struct s5p_tvout_vp_buff {
	unsigned int        phy_base;
	unsigned int        vir_base;
	unsigned int        size;
};

struct s5p_tvout_vp_bufferinfo {
	struct s5p_tvout_vp_buff    vp_buffs[S5PTV_VP_BUFF_CNT];
	unsigned int                copy_buff_idxs[S5PTV_VP_BUFF_CNT - 1];
	unsigned int                curr_copy_idx;
	unsigned int                vp_access_buff_idx;
	unsigned int                size;
};

struct s5ptv_vp_buf_info {
	unsigned int                buff_cnt;
	struct s5p_tvout_vp_buff    *buffs;
};

struct reg_mem_info {
	char		*name;
	struct resource *res;
	void __iomem	*base;
};

struct irq_info {
	char		*name;
	irq_handler_t	handler;
	int		no;
};

struct s5p_tvout_clk_info {
	char		*name;
	struct clk	*ptr;
};

#ifdef CONFIG_TVOUT_DEBUG
enum tvout_dbg_flag_bit_num {
	DBG_FLAG_HDCP = 0,
	DBG_FLAG_TVOUT,
	DBG_FLAG_HPD,
	DBG_FLAG_HDMI
};

extern int tvout_dbg_flag;
#endif

extern struct s5p_tvout_status s5ptv_status;

extern int s5p_tvout_vcm_create_unified(void);

extern int s5p_tvout_vcm_init(void);

extern void s5p_tvout_vcm_activate(void);

extern void s5p_tvout_vcm_deactivate(void);

extern int s5p_tvout_map_resource_mem(
		struct platform_device *pdev, char *name,
		void __iomem **base, struct resource **res);
extern void s5p_tvout_unmap_resource_mem(
		void __iomem *base, struct resource *res);

extern void s5p_tvout_pm_runtime_enable(struct device *dev);
extern void s5p_tvout_pm_runtime_disable(struct device *dev);
extern void s5p_tvout_pm_runtime_get(void);
extern void s5p_tvout_pm_runtime_put(void);

extern void s5p_hdmi_ctrl_clock(bool on);
extern bool on_stop_process;
extern bool on_start_process;
extern struct s5p_tvout_vp_bufferinfo s5ptv_vp_buff;
#ifdef CONFIG_HAS_EARLYSUSPEND
extern unsigned int suspend_status;
extern int s5p_hpd_get_status(void);
extern void s5p_tvout_mutex_lock(void);
extern void s5p_tvout_mutex_unlock(void);
#endif
#ifdef CONFIG_PM
extern void s5p_hdmi_ctrl_phy_power_resume(void);
#endif

#endif /* _S5P_TVOUT_COMMON_LIB_H_ */