• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 Allwinnertech Co.Ltd
3  * Authors: zhengwanyu
4  *
5  * This program is free software; you can redistribute  it and/or modify it
6  * under  the terms of  the GNU General  Public License as published by the
7  * Free Software Foundation;  either version 2 of the  License, or (at your
8  * option) any later version.
9  *
10 */
11 #ifndef _SUNXI_DE_H_
12 #define _SUNXI_DE_H_
13 #include <linux/clk.h>
14 #include "sunxi_config.h"
15 #include "de/include.h"
16 #include "sunxi_common.h"
17 
18 #define DE_NUM_MAX	4
19 #define DE_CHN_MAX  4
20 #define DE_LAYER_MAX  4
21 
22 struct sunxi_de_funcs {
23 	bool (*is_support_tcon)(int nr, int tcon_id);
24 	unsigned long (*get_freq)(int nr);
25 
26 	int (*get_layer_count)(int nr);
27 	int (*get_vi_layer_count)(int nr);
28 	int (*get_ui_layer_count)(int nr);
29 	int (*get_layer_channel_id)(int nr, int layer_id);
30 	int (*get_layer_id_within_chanel)(int nr, int top_layer_id);
31 	int (*get_layer_formats)(int nr, unsigned int layer_id,
32 					 const unsigned int **formats,
33 					 unsigned int *count);
34 	int (*single_layer_apply)(int nr, struct disp_layer_config_data *data);
35 	int (*multi_layers_apply)(int nr, struct disp_layer_config_data *data,
36 					unsigned int layer_num);
37 	bool (*is_enable)(int nr);
38 	int (*enable)(int nr, struct disp_manager_data *data);
39 	void (*disable)(int nr, struct disp_manager_data *data);
40 
41 	bool (*is_use_irq)(int nr);
42 	unsigned int (*get_irq_no)(int nr);
43 	int (*query_irq)(int nr);
44 	int (*event_proc)(int nr, bool update);
45 
46 	/*enhance*/
47 	int (*set_enhance)(int nr, int mode, bool enable,
48 			int width, int height, int conn_type);
49 	void (*get_enhance)(int nr,
50 			int *mode, bool *enable, int *width, int *height);
51 
52 	/*smbl*/
53 	bool (*is_support_smbl)(int nr);
54 	int (*set_smbl)(int nr, bool enable,
55 			struct disp_rect *rect);
56 	void (*get_smbl)(int nr, bool *enable,
57 			struct disp_rect *rect);
58 
59 };
60 
61 struct sunxi_de {
62 	/*id(or number) of this de*/
63 	int			id;
64 
65 	/* channel count
66 	* vichannel: video channel, support yuv/rgb inputs
67 	* uichannel: UI channel, only support rgb inputs
68 	*/
69 	unsigned int		vichannel_cnt;
70 	unsigned int		uichannel_cnt;
71 
72 	/*layers per channel*/
73 	/*NOTE: this two members designed below is NOT perfect,
74 	* We assume that the layers counts of all vi channel are same, so are
75 	* the ui channel. it is order to reduce the complexity of codes.
76 	* But if the layers of channels in DE HW is different from each other,
77 	* there will CAUSE BUG!!!!!!
78 	*/
79 	unsigned int		layers_per_vichannel;
80 	unsigned int		layers_per_uichannel;
81 
82 	bool layer_enabled[DE_CHN_MAX][DE_LAYER_MAX];
83 
84 	/*interrupt resource*/
85 	bool 			irq_enable;
86 	bool 			irq_used;
87 	unsigned int 		irq_no;
88 	bool use_rcq;
89 
90 	/*indicate that this de has been designed to a tcon
91 	* and can NOT be assigned to others
92 	*/
93 	bool			enable;
94 	/*show how this de working, this structrue is referred from
95 	 * sunxi_display
96 	*/
97 	struct disp_manager_info	info;
98 
99 	struct disp_layer_config_data *layer_config_data;
100 
101 	/*enhance*/
102 	struct disp_enhance_config enhance_config;
103 	struct disp_smbl_info smbl_info;
104 
105 	const struct sunxi_de_funcs *funcs;
106 };
107 
108 /*
109 * NOTE: The hardware de0 and de1 is designed to one hardware module,
110 * so they have same clk resources
111 */
112 struct sunxi_de_drv {
113 	struct platform_device *pdev;
114 	struct drv_model_info  drv_model;
115 
116 	/*the counts of de that this platform device has*/
117 	unsigned char		de_cnt;
118 
119 	/*register base, the lowlevel sw layer of de will differ the
120 	* reg_base of de0 and de1, so we just need to provide one reg_base
121 	*/
122 	uintptr_t		reg_base;
123 
124 	/*clock resource*/
125 	struct clk 		*mclk;/*module clk*/
126 	struct clk      *mclk_bus;/*module bus clk*/
127 
128 	unsigned int irq_no;
129 #if defined(CONFIG_AW_DRM_DE_V33X)
130 	/*only used int de_v33x*/
131 	unsigned int chn_cfg_mode;
132 #endif
133 	struct reset_control *rst_bus_de;
134 	struct sunxi_de hwde[DE_NUM_MAX];
135 };
136 
137 int sunxi_de_get_count(void);
138 struct sunxi_de_funcs *sunxi_de_get_funcs(int nr);
139 
140 int sunxi_de_module_init(void);
141 void sunxi_de_module_exit(void);
142 #endif
143