• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * drivers/gpu/drm/sunxi/sunxi_device/sunxi_tv/sunxi_tv.h
3  *
4  * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
5  * Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
6  * Author: zhengwanyu <zhengwanyu@allwinnertech.com>
7  *
8  * sunxi tvout driver include cvbs out, YPbPr and VGA out
9  *
10  * This software is licensed under the terms of the GNU General Public
11  * License version 2, as published by the Free Software Foundation, and
12  * may be copied, distributed, and modified under those terms.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  */
20 #ifndef _SUNXI_TV_H
21 #define _SUNXI_TV_H
22 
23 #include <linux/clk.h>
24 #include <de_tvec.h>
25 #include "de/include.h"
26 
27 #define MAX_TV_COUNT	3
28 
29 struct sunxi_tv_work_mode {
30 	unsigned int color_fmt;
31 };
32 
33 /**
34  * sunxi_tv device class
35  */
36 struct sunxi_tv {
37 	struct platform_device *pdev;
38 
39 	/**
40 	 * @id:index of tve (hardware)
41 	 * */
42 	unsigned int id;
43 
44 	/**
45 	 * @tv_mode:support resolution id
46 	 * */
47 	enum disp_tv_mode tv_mode;
48 
49 	/**
50 	 * @base_addr:sunxi tve phyical address
51 	 * */
52 	void __iomem *base_addr;
53 
54 	/*tve clk in ccmu*/
55 	struct clk *mclk;
56 
57 	/*tve's parent clk in ccmu*/
58 	struct clk *mclk_parent;
59 
60 	/**
61 	 * @top_addr:sunxi tve top phyical address
62 	 * */
63 	void __iomem *top_addr;
64 
65 	/*tve top clk in ccmu*/
66 	struct clk *top_clk;
67 
68 	/**
69 	 * @dac_no: index of dac
70 	 * */
71 	unsigned int dac_no[TVE_DAC_NUM];
72 
73 	/**
74 	 * @dac_type:data source type of dac.
75 	 * i.e. 0:composite,1:luma,2:chroma,3:reserved,4:y/green,
76 	 * 5:u/pb/blue,6:v/pr/red
77 	 * */
78 	enum disp_tv_dac_source dac_type[TVE_DAC_NUM];
79 
80 	/**
81 	 * @dac_num: total number of dac to be used
82 	 * for current device.
83 	 * i.e. 1 for CVBS, 3 for VGA and YPbPr
84 	 * */
85 	unsigned int dac_num;
86 
87 	/**
88 	 * @cali: cali value for calibrating dac
89 	 * */
90 	unsigned int cali[TVE_DAC_NUM];
91 
92 	/**
93 	 * @cali: cali value for calibrating dac
94 	 * */
95 	int cali_offset[TVE_DAC_NUM];
96 
97 	/**
98 	 * @enable: enable status of current tv device
99 	 * */
100 	bool enable;
101 
102 	/**
103 	 * @mlcok:mutex lock for setting mode, enable or
104 	 * disable tv
105 	 * */
106 	struct mutex mlock;
107 
108 	/**
109 	 * @tv_type:output interface of current device
110 	 * decided by [tv0] & [tv1] in sys_config.fex
111 	 * */
112 	enum disp_tv_output tv_type;
113 
114 	/**
115 	 * @tv_power:name of axp power
116 	 * */
117 	const char *p_tv_power;
118 
119 	struct disp_video_timings *video_info;
120 
121 };
122 
123 
124 /**
125  * @set_mode:call back for setting current mode
126  * */
127 int sunxi_tv_set_mode(int tv_id, enum disp_tv_mode tv_mode);
128 
129 /**
130  * @enable:call back for enabling tv
131  * */
132 int sunxi_tv_enable(int tv_id);
133 
134 /**
135  * @enable:call back for disabling tv
136  * */
137 int sunxi_tv_disable(int tv_id);
138 
139 int  sunxi_tv_get_working_mode(int tv_id,
140 		struct sunxi_tv_work_mode *work_mode);
141 
142 /**
143  * @get_input_csc:call back for setting deflick function
144  * @mode: 0-->deflick off, 1-->deflick mode 1, 2-->deflick mode 2
145  */
146 int sunxi_tv_set_enhance_mode(int tv_id, unsigned int mode);
147 
148 /**
149  * @get_connect_status:call back for getting tv connect status
150  * @return:0:unconnected; 1:connected
151  */
152 int sunxi_tv_get_connect_status(int tv_id);
153 
154 /**
155  * @get_video_mode_info:call back for getting disp video timing
156  * info of specified mode
157  */
158 int sunxi_tv_get_video_mode_info(int tv_id,
159 			   struct disp_video_timings **video_info,
160 			   enum disp_tv_mode tv_mode);
161 /**
162  * @mode_support:call back for determining if a mode is supported or
163  * not.
164  */
165 int sunxi_tv_mode_support(int tv_id, enum disp_tv_mode tv_mode);
166 
167 /**
168  * @name       :get_video_timing_info
169  * @brief      :call back for getting disp video timing info
170  * @param[OUT] :num: store the totoal number of support mode
171  * @param[OUT] :video_info:pointer of first item in timing_info array
172  * @return     :0 if success, -1 else
173  */
174 int sunxi_tv_get_video_timing_info(int tv_id, unsigned int *num,
175 			     struct disp_video_timings **video_info);
176 struct disp_video_timings *
177 	sunxi_tv_get_video_timing(
178 			int tv_id, unsigned int tv_mode);
179 
180 
181 /**
182  * @name       :sunxi_tv_get_tv_count
183  * @brief      :get the number of sunxi tv
184  * @return     :the number of sunxi tv
185  */
186 int sunxi_tv_get_tv_count(void);
187 
188 void sunxi_tv_module_exit(void);
189 int sunxi_tv_module_init(void);
190 
191 #define TV_DBG(fmt, arg...)   DRM_DEBUG_KMS("[SUNXI-TV] %s()%d - "fmt, __func__, __LINE__, ##arg)
192 #define TV_INFO(fmt, arg...)   DRM_INFO("[SUNXI-TV] %s()%d - "fmt, __func__, __LINE__, ##arg)
193 #define TV_ERR(fmt, arg...)   DRM_ERROR("[SUNXI-TV] %s()%d - "fmt, __func__, __LINE__, ##arg)
194 
195 #endif /*End of file*/
196