1d38ceaf9SAlex Deucher /*
2d38ceaf9SAlex Deucher  * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
3d38ceaf9SAlex Deucher  *                VA Linux Systems Inc., Fremont, California.
4d38ceaf9SAlex Deucher  * Copyright 2008 Red Hat Inc.
5d38ceaf9SAlex Deucher  *
6d38ceaf9SAlex Deucher  * Permission is hereby granted, free of charge, to any person obtaining a
7d38ceaf9SAlex Deucher  * copy of this software and associated documentation files (the "Software"),
8d38ceaf9SAlex Deucher  * to deal in the Software without restriction, including without limitation
9d38ceaf9SAlex Deucher  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10d38ceaf9SAlex Deucher  * and/or sell copies of the Software, and to permit persons to whom the
11d38ceaf9SAlex Deucher  * Software is furnished to do so, subject to the following conditions:
12d38ceaf9SAlex Deucher  *
13d38ceaf9SAlex Deucher  * The above copyright notice and this permission notice shall be included in
14d38ceaf9SAlex Deucher  * all copies or substantial portions of the Software.
15d38ceaf9SAlex Deucher  *
16d38ceaf9SAlex Deucher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17d38ceaf9SAlex Deucher  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18d38ceaf9SAlex Deucher  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19d38ceaf9SAlex Deucher  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20d38ceaf9SAlex Deucher  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21d38ceaf9SAlex Deucher  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22d38ceaf9SAlex Deucher  * OTHER DEALINGS IN THE SOFTWARE.
23d38ceaf9SAlex Deucher  *
24d38ceaf9SAlex Deucher  * Original Authors:
25d38ceaf9SAlex Deucher  *   Kevin E. Martin, Rickard E. Faith, Alan Hourihane
26d38ceaf9SAlex Deucher  *
27d38ceaf9SAlex Deucher  * Kernel port Author: Dave Airlie
28d38ceaf9SAlex Deucher  */
29d38ceaf9SAlex Deucher 
30d38ceaf9SAlex Deucher #ifndef AMDGPU_MODE_H
31d38ceaf9SAlex Deucher #define AMDGPU_MODE_H
32d38ceaf9SAlex Deucher 
33d38ceaf9SAlex Deucher #include <drm/drm_crtc.h>
34d38ceaf9SAlex Deucher #include <drm/drm_edid.h>
359338203cSLaurent Pinchart #include <drm/drm_encoder.h>
36d38ceaf9SAlex Deucher #include <drm/drm_dp_helper.h>
37d38ceaf9SAlex Deucher #include <drm/drm_fixed.h>
38d38ceaf9SAlex Deucher #include <drm/drm_crtc_helper.h>
39b516a9efSDaniel Vetter #include <drm/drm_fb_helper.h>
40d38ceaf9SAlex Deucher #include <drm/drm_plane_helper.h>
414562236bSHarry Wentland #include <drm/drm_fb_helper.h>
42d38ceaf9SAlex Deucher #include <linux/i2c.h>
43d38ceaf9SAlex Deucher #include <linux/i2c-algo-bit.h>
4446ac3622SEmily Deng #include <linux/hrtimer.h>
4546ac3622SEmily Deng #include "amdgpu_irq.h"
46d38ceaf9SAlex Deucher 
474562236bSHarry Wentland #include <drm/drm_dp_mst_helper.h>
484562236bSHarry Wentland #include "modules/inc/mod_freesync.h"
494562236bSHarry Wentland 
50d38ceaf9SAlex Deucher struct amdgpu_bo;
51d38ceaf9SAlex Deucher struct amdgpu_device;
52d38ceaf9SAlex Deucher struct amdgpu_encoder;
53d38ceaf9SAlex Deucher struct amdgpu_router;
54d38ceaf9SAlex Deucher struct amdgpu_hpd;
55d38ceaf9SAlex Deucher 
56d38ceaf9SAlex Deucher #define to_amdgpu_crtc(x) container_of(x, struct amdgpu_crtc, base)
57d38ceaf9SAlex Deucher #define to_amdgpu_connector(x) container_of(x, struct amdgpu_connector, base)
58d38ceaf9SAlex Deucher #define to_amdgpu_encoder(x) container_of(x, struct amdgpu_encoder, base)
59d38ceaf9SAlex Deucher #define to_amdgpu_framebuffer(x) container_of(x, struct amdgpu_framebuffer, base)
6064d8b780SShirish S #define to_amdgpu_plane(x)	container_of(x, struct amdgpu_plane, base)
61d38ceaf9SAlex Deucher 
62d38ceaf9SAlex Deucher #define AMDGPU_MAX_HPD_PINS 6
63d38ceaf9SAlex Deucher #define AMDGPU_MAX_CRTCS 6
64d4e13b0dSAlex Deucher #define AMDGPU_MAX_PLANES 6
6522384459SAlex Deucher #define AMDGPU_MAX_AFMT_BLOCKS 9
66d38ceaf9SAlex Deucher 
67d38ceaf9SAlex Deucher enum amdgpu_rmx_type {
68d38ceaf9SAlex Deucher 	RMX_OFF,
69d38ceaf9SAlex Deucher 	RMX_FULL,
70d38ceaf9SAlex Deucher 	RMX_CENTER,
71d38ceaf9SAlex Deucher 	RMX_ASPECT
72d38ceaf9SAlex Deucher };
73d38ceaf9SAlex Deucher 
74d38ceaf9SAlex Deucher enum amdgpu_underscan_type {
75d38ceaf9SAlex Deucher 	UNDERSCAN_OFF,
76d38ceaf9SAlex Deucher 	UNDERSCAN_ON,
77d38ceaf9SAlex Deucher 	UNDERSCAN_AUTO,
78d38ceaf9SAlex Deucher };
79d38ceaf9SAlex Deucher 
80d38ceaf9SAlex Deucher #define AMDGPU_HPD_CONNECT_INT_DELAY_IN_MS 50
81d38ceaf9SAlex Deucher #define AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS 10
82d38ceaf9SAlex Deucher 
83d38ceaf9SAlex Deucher enum amdgpu_hpd_id {
84d38ceaf9SAlex Deucher 	AMDGPU_HPD_1 = 0,
85d38ceaf9SAlex Deucher 	AMDGPU_HPD_2,
86d38ceaf9SAlex Deucher 	AMDGPU_HPD_3,
87d38ceaf9SAlex Deucher 	AMDGPU_HPD_4,
88d38ceaf9SAlex Deucher 	AMDGPU_HPD_5,
89d38ceaf9SAlex Deucher 	AMDGPU_HPD_6,
90d38ceaf9SAlex Deucher 	AMDGPU_HPD_LAST,
91d38ceaf9SAlex Deucher 	AMDGPU_HPD_NONE = 0xff,
92d38ceaf9SAlex Deucher };
93d38ceaf9SAlex Deucher 
94d38ceaf9SAlex Deucher enum amdgpu_crtc_irq {
95d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK1 = 0,
96d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK2,
97d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK3,
98d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK4,
99d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK5,
100d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VBLANK6,
101d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE1,
102d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE2,
103d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE3,
104d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE4,
105d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE5,
106d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_VLINE6,
107d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_LAST,
108d38ceaf9SAlex Deucher 	AMDGPU_CRTC_IRQ_NONE = 0xff
109d38ceaf9SAlex Deucher };
110d38ceaf9SAlex Deucher 
111d38ceaf9SAlex Deucher enum amdgpu_pageflip_irq {
112d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D1 = 0,
113d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D2,
114d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D3,
115d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D4,
116d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D5,
117d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_D6,
118d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_LAST,
119d38ceaf9SAlex Deucher 	AMDGPU_PAGEFLIP_IRQ_NONE = 0xff
120d38ceaf9SAlex Deucher };
121d38ceaf9SAlex Deucher 
122d38ceaf9SAlex Deucher enum amdgpu_flip_status {
123d38ceaf9SAlex Deucher 	AMDGPU_FLIP_NONE,
124d38ceaf9SAlex Deucher 	AMDGPU_FLIP_PENDING,
125d38ceaf9SAlex Deucher 	AMDGPU_FLIP_SUBMITTED
126d38ceaf9SAlex Deucher };
127d38ceaf9SAlex Deucher 
128d38ceaf9SAlex Deucher #define AMDGPU_MAX_I2C_BUS 16
129d38ceaf9SAlex Deucher 
130d38ceaf9SAlex Deucher /* amdgpu gpio-based i2c
131d38ceaf9SAlex Deucher  * 1. "mask" reg and bits
132d38ceaf9SAlex Deucher  *    grabs the gpio pins for software use
133d38ceaf9SAlex Deucher  *    0=not held  1=held
134d38ceaf9SAlex Deucher  * 2. "a" reg and bits
135d38ceaf9SAlex Deucher  *    output pin value
136d38ceaf9SAlex Deucher  *    0=low 1=high
137d38ceaf9SAlex Deucher  * 3. "en" reg and bits
138d38ceaf9SAlex Deucher  *    sets the pin direction
139d38ceaf9SAlex Deucher  *    0=input 1=output
140d38ceaf9SAlex Deucher  * 4. "y" reg and bits
141d38ceaf9SAlex Deucher  *    input pin value
142d38ceaf9SAlex Deucher  *    0=low 1=high
143d38ceaf9SAlex Deucher  */
144d38ceaf9SAlex Deucher struct amdgpu_i2c_bus_rec {
145d38ceaf9SAlex Deucher 	bool valid;
146d38ceaf9SAlex Deucher 	/* id used by atom */
147d38ceaf9SAlex Deucher 	uint8_t i2c_id;
148d38ceaf9SAlex Deucher 	/* id used by atom */
149d38ceaf9SAlex Deucher 	enum amdgpu_hpd_id hpd;
150d38ceaf9SAlex Deucher 	/* can be used with hw i2c engine */
151d38ceaf9SAlex Deucher 	bool hw_capable;
152d38ceaf9SAlex Deucher 	/* uses multi-media i2c engine */
153d38ceaf9SAlex Deucher 	bool mm_i2c;
154d38ceaf9SAlex Deucher 	/* regs and bits */
155d38ceaf9SAlex Deucher 	uint32_t mask_clk_reg;
156d38ceaf9SAlex Deucher 	uint32_t mask_data_reg;
157d38ceaf9SAlex Deucher 	uint32_t a_clk_reg;
158d38ceaf9SAlex Deucher 	uint32_t a_data_reg;
159d38ceaf9SAlex Deucher 	uint32_t en_clk_reg;
160d38ceaf9SAlex Deucher 	uint32_t en_data_reg;
161d38ceaf9SAlex Deucher 	uint32_t y_clk_reg;
162d38ceaf9SAlex Deucher 	uint32_t y_data_reg;
163d38ceaf9SAlex Deucher 	uint32_t mask_clk_mask;
164d38ceaf9SAlex Deucher 	uint32_t mask_data_mask;
165d38ceaf9SAlex Deucher 	uint32_t a_clk_mask;
166d38ceaf9SAlex Deucher 	uint32_t a_data_mask;
167d38ceaf9SAlex Deucher 	uint32_t en_clk_mask;
168d38ceaf9SAlex Deucher 	uint32_t en_data_mask;
169d38ceaf9SAlex Deucher 	uint32_t y_clk_mask;
170d38ceaf9SAlex Deucher 	uint32_t y_data_mask;
171d38ceaf9SAlex Deucher };
172d38ceaf9SAlex Deucher 
173d38ceaf9SAlex Deucher #define AMDGPU_MAX_BIOS_CONNECTOR 16
174d38ceaf9SAlex Deucher 
175d38ceaf9SAlex Deucher /* pll flags */
176d38ceaf9SAlex Deucher #define AMDGPU_PLL_USE_BIOS_DIVS        (1 << 0)
177d38ceaf9SAlex Deucher #define AMDGPU_PLL_NO_ODD_POST_DIV      (1 << 1)
178d38ceaf9SAlex Deucher #define AMDGPU_PLL_USE_REF_DIV          (1 << 2)
179d38ceaf9SAlex Deucher #define AMDGPU_PLL_LEGACY               (1 << 3)
180d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_LOW_REF_DIV   (1 << 4)
181d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_HIGH_REF_DIV  (1 << 5)
182d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_LOW_FB_DIV    (1 << 6)
183d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_HIGH_FB_DIV   (1 << 7)
184d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_LOW_POST_DIV  (1 << 8)
185d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_HIGH_POST_DIV (1 << 9)
186d38ceaf9SAlex Deucher #define AMDGPU_PLL_USE_FRAC_FB_DIV      (1 << 10)
187d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_CLOSEST_LOWER (1 << 11)
188d38ceaf9SAlex Deucher #define AMDGPU_PLL_USE_POST_DIV         (1 << 12)
189d38ceaf9SAlex Deucher #define AMDGPU_PLL_IS_LCD               (1 << 13)
190d38ceaf9SAlex Deucher #define AMDGPU_PLL_PREFER_MINM_OVER_MAXP (1 << 14)
191d38ceaf9SAlex Deucher 
192d38ceaf9SAlex Deucher struct amdgpu_pll {
193d38ceaf9SAlex Deucher 	/* reference frequency */
194d38ceaf9SAlex Deucher 	uint32_t reference_freq;
195d38ceaf9SAlex Deucher 
196d38ceaf9SAlex Deucher 	/* fixed dividers */
197d38ceaf9SAlex Deucher 	uint32_t reference_div;
198d38ceaf9SAlex Deucher 	uint32_t post_div;
199d38ceaf9SAlex Deucher 
200d38ceaf9SAlex Deucher 	/* pll in/out limits */
201d38ceaf9SAlex Deucher 	uint32_t pll_in_min;
202d38ceaf9SAlex Deucher 	uint32_t pll_in_max;
203d38ceaf9SAlex Deucher 	uint32_t pll_out_min;
204d38ceaf9SAlex Deucher 	uint32_t pll_out_max;
205d38ceaf9SAlex Deucher 	uint32_t lcd_pll_out_min;
206d38ceaf9SAlex Deucher 	uint32_t lcd_pll_out_max;
207d38ceaf9SAlex Deucher 	uint32_t best_vco;
208d38ceaf9SAlex Deucher 
209d38ceaf9SAlex Deucher 	/* divider limits */
210d38ceaf9SAlex Deucher 	uint32_t min_ref_div;
211d38ceaf9SAlex Deucher 	uint32_t max_ref_div;
212d38ceaf9SAlex Deucher 	uint32_t min_post_div;
213d38ceaf9SAlex Deucher 	uint32_t max_post_div;
214d38ceaf9SAlex Deucher 	uint32_t min_feedback_div;
215d38ceaf9SAlex Deucher 	uint32_t max_feedback_div;
216d38ceaf9SAlex Deucher 	uint32_t min_frac_feedback_div;
217d38ceaf9SAlex Deucher 	uint32_t max_frac_feedback_div;
218d38ceaf9SAlex Deucher 
219d38ceaf9SAlex Deucher 	/* flags for the current clock */
220d38ceaf9SAlex Deucher 	uint32_t flags;
221d38ceaf9SAlex Deucher 
222d38ceaf9SAlex Deucher 	/* pll id */
223d38ceaf9SAlex Deucher 	uint32_t id;
224d38ceaf9SAlex Deucher };
225d38ceaf9SAlex Deucher 
226d38ceaf9SAlex Deucher struct amdgpu_i2c_chan {
227d38ceaf9SAlex Deucher 	struct i2c_adapter adapter;
228d38ceaf9SAlex Deucher 	struct drm_device *dev;
229d38ceaf9SAlex Deucher 	struct i2c_algo_bit_data bit;
230d38ceaf9SAlex Deucher 	struct amdgpu_i2c_bus_rec rec;
231d38ceaf9SAlex Deucher 	struct drm_dp_aux aux;
232d38ceaf9SAlex Deucher 	bool has_aux;
233d38ceaf9SAlex Deucher 	struct mutex mutex;
234d38ceaf9SAlex Deucher };
235d38ceaf9SAlex Deucher 
236d38ceaf9SAlex Deucher struct amdgpu_fbdev;
237d38ceaf9SAlex Deucher 
238d38ceaf9SAlex Deucher struct amdgpu_afmt {
239d38ceaf9SAlex Deucher 	bool enabled;
240d38ceaf9SAlex Deucher 	int offset;
241d38ceaf9SAlex Deucher 	bool last_buffer_filled_status;
242d38ceaf9SAlex Deucher 	int id;
243d38ceaf9SAlex Deucher 	struct amdgpu_audio_pin *pin;
244d38ceaf9SAlex Deucher };
245d38ceaf9SAlex Deucher 
246d38ceaf9SAlex Deucher /*
247d38ceaf9SAlex Deucher  * Audio
248d38ceaf9SAlex Deucher  */
249d38ceaf9SAlex Deucher struct amdgpu_audio_pin {
250d38ceaf9SAlex Deucher 	int			channels;
251d38ceaf9SAlex Deucher 	int			rate;
252d38ceaf9SAlex Deucher 	int			bits_per_sample;
253d38ceaf9SAlex Deucher 	u8			status_bits;
254d38ceaf9SAlex Deucher 	u8			category_code;
255d38ceaf9SAlex Deucher 	u32			offset;
256d38ceaf9SAlex Deucher 	bool			connected;
257d38ceaf9SAlex Deucher 	u32			id;
258d38ceaf9SAlex Deucher };
259d38ceaf9SAlex Deucher 
260d38ceaf9SAlex Deucher struct amdgpu_audio {
261d38ceaf9SAlex Deucher 	bool enabled;
262d38ceaf9SAlex Deucher 	struct amdgpu_audio_pin pin[AMDGPU_MAX_AFMT_BLOCKS];
263d38ceaf9SAlex Deucher 	int num_pins;
264d38ceaf9SAlex Deucher };
265d38ceaf9SAlex Deucher 
266d38ceaf9SAlex Deucher struct amdgpu_display_funcs {
267d38ceaf9SAlex Deucher 	/* display watermarks */
268d38ceaf9SAlex Deucher 	void (*bandwidth_update)(struct amdgpu_device *adev);
269d38ceaf9SAlex Deucher 	/* get frame count */
270d38ceaf9SAlex Deucher 	u32 (*vblank_get_counter)(struct amdgpu_device *adev, int crtc);
271d38ceaf9SAlex Deucher 	/* wait for vblank */
272d38ceaf9SAlex Deucher 	void (*vblank_wait)(struct amdgpu_device *adev, int crtc);
273d38ceaf9SAlex Deucher 	/* set backlight level */
274d38ceaf9SAlex Deucher 	void (*backlight_set_level)(struct amdgpu_encoder *amdgpu_encoder,
275d38ceaf9SAlex Deucher 				    u8 level);
276d38ceaf9SAlex Deucher 	/* get backlight level */
277d38ceaf9SAlex Deucher 	u8 (*backlight_get_level)(struct amdgpu_encoder *amdgpu_encoder);
278d38ceaf9SAlex Deucher 	/* hotplug detect */
279d38ceaf9SAlex Deucher 	bool (*hpd_sense)(struct amdgpu_device *adev, enum amdgpu_hpd_id hpd);
280d38ceaf9SAlex Deucher 	void (*hpd_set_polarity)(struct amdgpu_device *adev,
281d38ceaf9SAlex Deucher 				 enum amdgpu_hpd_id hpd);
282d38ceaf9SAlex Deucher 	u32 (*hpd_get_gpio_reg)(struct amdgpu_device *adev);
283d38ceaf9SAlex Deucher 	/* pageflipping */
284d38ceaf9SAlex Deucher 	void (*page_flip)(struct amdgpu_device *adev,
285cb9e59d7SAlex Deucher 			  int crtc_id, u64 crtc_base, bool async);
286d38ceaf9SAlex Deucher 	int (*page_flip_get_scanoutpos)(struct amdgpu_device *adev, int crtc,
287d38ceaf9SAlex Deucher 					u32 *vbl, u32 *position);
288d38ceaf9SAlex Deucher 	/* display topology setup */
289d38ceaf9SAlex Deucher 	void (*add_encoder)(struct amdgpu_device *adev,
290d38ceaf9SAlex Deucher 			    uint32_t encoder_enum,
291d38ceaf9SAlex Deucher 			    uint32_t supported_device,
292d38ceaf9SAlex Deucher 			    u16 caps);
293d38ceaf9SAlex Deucher 	void (*add_connector)(struct amdgpu_device *adev,
294d38ceaf9SAlex Deucher 			      uint32_t connector_id,
295d38ceaf9SAlex Deucher 			      uint32_t supported_device,
296d38ceaf9SAlex Deucher 			      int connector_type,
297d38ceaf9SAlex Deucher 			      struct amdgpu_i2c_bus_rec *i2c_bus,
298d38ceaf9SAlex Deucher 			      uint16_t connector_object_id,
299d38ceaf9SAlex Deucher 			      struct amdgpu_hpd *hpd,
300d38ceaf9SAlex Deucher 			      struct amdgpu_router *router);
3014562236bSHarry Wentland 	/* it is used to enter or exit into free sync mode */
3024562236bSHarry Wentland 	int (*notify_freesync)(struct drm_device *dev, void *data,
3034562236bSHarry Wentland 			       struct drm_file *filp);
3044562236bSHarry Wentland 	/* it is used to allow enablement of freesync mode */
3054562236bSHarry Wentland 	int (*set_freesync_property)(struct drm_connector *connector,
3064562236bSHarry Wentland 				     struct drm_property *property,
3074562236bSHarry Wentland 				     uint64_t val);
3084562236bSHarry Wentland 
3094562236bSHarry Wentland 
3104562236bSHarry Wentland };
3114562236bSHarry Wentland 
3124562236bSHarry Wentland struct amdgpu_framebuffer {
3134562236bSHarry Wentland 	struct drm_framebuffer base;
3144562236bSHarry Wentland 	struct drm_gem_object *obj;
315dd55d12cSAndrey Grodzovsky 
316dd55d12cSAndrey Grodzovsky 	/* caching for later use */
317dd55d12cSAndrey Grodzovsky 	uint64_t address;
3184562236bSHarry Wentland };
3194562236bSHarry Wentland 
3204562236bSHarry Wentland struct amdgpu_fbdev {
3214562236bSHarry Wentland 	struct drm_fb_helper helper;
3224562236bSHarry Wentland 	struct amdgpu_framebuffer rfb;
3234562236bSHarry Wentland 	struct list_head fbdev_list;
3244562236bSHarry Wentland 	struct amdgpu_device *adev;
325d38ceaf9SAlex Deucher };
326d38ceaf9SAlex Deucher 
327d38ceaf9SAlex Deucher struct amdgpu_mode_info {
328d38ceaf9SAlex Deucher 	struct atom_context *atom_context;
329d38ceaf9SAlex Deucher 	struct card_info *atom_card_info;
330d38ceaf9SAlex Deucher 	bool mode_config_initialized;
331f195038cSAlex Deucher 	struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS];
332d4e13b0dSAlex Deucher 	struct amdgpu_plane *planes[AMDGPU_MAX_PLANES];
333f195038cSAlex Deucher 	struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS];
334d38ceaf9SAlex Deucher 	/* DVI-I properties */
335d38ceaf9SAlex Deucher 	struct drm_property *coherent_mode_property;
336d38ceaf9SAlex Deucher 	/* DAC enable load detect */
337d38ceaf9SAlex Deucher 	struct drm_property *load_detect_property;
338d38ceaf9SAlex Deucher 	/* underscan */
339d38ceaf9SAlex Deucher 	struct drm_property *underscan_property;
340d38ceaf9SAlex Deucher 	struct drm_property *underscan_hborder_property;
341d38ceaf9SAlex Deucher 	struct drm_property *underscan_vborder_property;
342d38ceaf9SAlex Deucher 	/* audio */
343d38ceaf9SAlex Deucher 	struct drm_property *audio_property;
344d38ceaf9SAlex Deucher 	/* FMT dithering */
345d38ceaf9SAlex Deucher 	struct drm_property *dither_property;
346d38ceaf9SAlex Deucher 	/* hardcoded DFP edid from BIOS */
347d38ceaf9SAlex Deucher 	struct edid *bios_hardcoded_edid;
348d38ceaf9SAlex Deucher 	int bios_hardcoded_edid_size;
349d38ceaf9SAlex Deucher 
350d38ceaf9SAlex Deucher 	/* pointer to fbdev info structure */
351d38ceaf9SAlex Deucher 	struct amdgpu_fbdev *rfbdev;
352d38ceaf9SAlex Deucher 	/* firmware flags */
353d38ceaf9SAlex Deucher 	u16 firmware_flags;
354d38ceaf9SAlex Deucher 	/* pointer to backlight encoder */
355d38ceaf9SAlex Deucher 	struct amdgpu_encoder *bl_encoder;
356d38ceaf9SAlex Deucher 	struct amdgpu_audio	audio; /* audio stuff */
357d38ceaf9SAlex Deucher 	int			num_crtc; /* number of crtcs */
358d38ceaf9SAlex Deucher 	int			num_hpd; /* number of hpd pins */
359d38ceaf9SAlex Deucher 	int			num_dig; /* number of dig blocks */
360d38ceaf9SAlex Deucher 	int			disp_priority;
361d38ceaf9SAlex Deucher 	const struct amdgpu_display_funcs *funcs;
362d4e13b0dSAlex Deucher 	enum drm_plane_type *plane_type;
363d38ceaf9SAlex Deucher };
364d38ceaf9SAlex Deucher 
365d38ceaf9SAlex Deucher #define AMDGPU_MAX_BL_LEVEL 0xFF
366d38ceaf9SAlex Deucher 
367d38ceaf9SAlex Deucher #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
368d38ceaf9SAlex Deucher 
369d38ceaf9SAlex Deucher struct amdgpu_backlight_privdata {
370d38ceaf9SAlex Deucher 	struct amdgpu_encoder *encoder;
371d38ceaf9SAlex Deucher 	uint8_t negative;
372d38ceaf9SAlex Deucher };
373d38ceaf9SAlex Deucher 
374d38ceaf9SAlex Deucher #endif
375d38ceaf9SAlex Deucher 
376d38ceaf9SAlex Deucher struct amdgpu_atom_ss {
377d38ceaf9SAlex Deucher 	uint16_t percentage;
378d38ceaf9SAlex Deucher 	uint16_t percentage_divider;
379d38ceaf9SAlex Deucher 	uint8_t type;
380d38ceaf9SAlex Deucher 	uint16_t step;
381d38ceaf9SAlex Deucher 	uint8_t delay;
382d38ceaf9SAlex Deucher 	uint8_t range;
383d38ceaf9SAlex Deucher 	uint8_t refdiv;
384d38ceaf9SAlex Deucher 	/* asic_ss */
385d38ceaf9SAlex Deucher 	uint16_t rate;
386d38ceaf9SAlex Deucher 	uint16_t amount;
387d38ceaf9SAlex Deucher };
388d38ceaf9SAlex Deucher 
389d38ceaf9SAlex Deucher struct amdgpu_crtc {
390d38ceaf9SAlex Deucher 	struct drm_crtc base;
391d38ceaf9SAlex Deucher 	int crtc_id;
392d38ceaf9SAlex Deucher 	bool enabled;
393d38ceaf9SAlex Deucher 	bool can_tile;
394d38ceaf9SAlex Deucher 	uint32_t crtc_offset;
395d38ceaf9SAlex Deucher 	struct drm_gem_object *cursor_bo;
396d38ceaf9SAlex Deucher 	uint64_t cursor_addr;
39729275a9bSAlex Deucher 	int cursor_x;
39829275a9bSAlex Deucher 	int cursor_y;
39929275a9bSAlex Deucher 	int cursor_hot_x;
40029275a9bSAlex Deucher 	int cursor_hot_y;
401d38ceaf9SAlex Deucher 	int cursor_width;
402d38ceaf9SAlex Deucher 	int cursor_height;
403d38ceaf9SAlex Deucher 	int max_cursor_width;
404d38ceaf9SAlex Deucher 	int max_cursor_height;
405d38ceaf9SAlex Deucher 	enum amdgpu_rmx_type rmx_type;
406d38ceaf9SAlex Deucher 	u8 h_border;
407d38ceaf9SAlex Deucher 	u8 v_border;
408d38ceaf9SAlex Deucher 	fixed20_12 vsc;
409d38ceaf9SAlex Deucher 	fixed20_12 hsc;
410d38ceaf9SAlex Deucher 	struct drm_display_mode native_mode;
411d38ceaf9SAlex Deucher 	u32 pll_id;
412d38ceaf9SAlex Deucher 	/* page flipping */
413d38ceaf9SAlex Deucher 	struct amdgpu_flip_work *pflip_works;
414d38ceaf9SAlex Deucher 	enum amdgpu_flip_status pflip_status;
415d38ceaf9SAlex Deucher 	int deferred_flip_completion;
416d38ceaf9SAlex Deucher 	/* pll sharing */
417d38ceaf9SAlex Deucher 	struct amdgpu_atom_ss ss;
418d38ceaf9SAlex Deucher 	bool ss_enabled;
419d38ceaf9SAlex Deucher 	u32 adjusted_clock;
420d38ceaf9SAlex Deucher 	int bpc;
421d38ceaf9SAlex Deucher 	u32 pll_reference_div;
422d38ceaf9SAlex Deucher 	u32 pll_post_div;
423d38ceaf9SAlex Deucher 	u32 pll_flags;
424d38ceaf9SAlex Deucher 	struct drm_encoder *encoder;
425d38ceaf9SAlex Deucher 	struct drm_connector *connector;
426d38ceaf9SAlex Deucher 	/* for dpm */
427d38ceaf9SAlex Deucher 	u32 line_time;
428d38ceaf9SAlex Deucher 	u32 wm_low;
429d38ceaf9SAlex Deucher 	u32 wm_high;
4308e36f9d3SAlex Deucher 	u32 lb_vblank_lead_lines;
431d38ceaf9SAlex Deucher 	struct drm_display_mode hw_mode;
4320f66356dSEmily Deng 	/* for virtual dce */
4330f66356dSEmily Deng 	struct hrtimer vblank_timer;
4340f66356dSEmily Deng 	enum amdgpu_interrupt_state vsync_timer_enabled;
4354562236bSHarry Wentland 
4364562236bSHarry Wentland 	int otg_inst;
4374562236bSHarry Wentland 	uint32_t flip_flags;
438ab2541b6SAric Cyr 	/* After Set Mode stream will be non-NULL */
439ab2541b6SAric Cyr 	const struct dc_stream *stream;
440dd55d12cSAndrey Grodzovsky 	struct drm_pending_vblank_event *event;
441d38ceaf9SAlex Deucher };
442d38ceaf9SAlex Deucher 
44364d8b780SShirish S struct amdgpu_drm_plane_state {
44464d8b780SShirish S 	struct drm_plane_state base;
44564d8b780SShirish S 	unsigned int h_ratio;
44664d8b780SShirish S 	unsigned int v_ratio;
44764d8b780SShirish S };
44864d8b780SShirish S 
44964d8b780SShirish S static inline struct amdgpu_drm_plane_state *
45064d8b780SShirish S to_amdgpu_plane_state(struct drm_plane_state *state)
45164d8b780SShirish S {
45264d8b780SShirish S 	return container_of(state, struct amdgpu_drm_plane_state, base);
45364d8b780SShirish S }
45464d8b780SShirish S 
455d4e13b0dSAlex Deucher struct amdgpu_plane {
456d4e13b0dSAlex Deucher 	struct drm_plane base;
457d4e13b0dSAlex Deucher 	enum drm_plane_type plane_type;
458d4e13b0dSAlex Deucher };
459d4e13b0dSAlex Deucher 
460d38ceaf9SAlex Deucher struct amdgpu_encoder_atom_dig {
461d38ceaf9SAlex Deucher 	bool linkb;
462d38ceaf9SAlex Deucher 	/* atom dig */
463d38ceaf9SAlex Deucher 	bool coherent_mode;
464d38ceaf9SAlex Deucher 	int dig_encoder; /* -1 disabled, 0 DIGA, 1 DIGB, etc. */
465d38ceaf9SAlex Deucher 	/* atom lvds/edp */
466d38ceaf9SAlex Deucher 	uint32_t lcd_misc;
467d38ceaf9SAlex Deucher 	uint16_t panel_pwr_delay;
468d38ceaf9SAlex Deucher 	uint32_t lcd_ss_id;
469d38ceaf9SAlex Deucher 	/* panel mode */
470d38ceaf9SAlex Deucher 	struct drm_display_mode native_mode;
471d38ceaf9SAlex Deucher 	struct backlight_device *bl_dev;
472d38ceaf9SAlex Deucher 	int dpms_mode;
473d38ceaf9SAlex Deucher 	uint8_t backlight_level;
474d38ceaf9SAlex Deucher 	int panel_mode;
475d38ceaf9SAlex Deucher 	struct amdgpu_afmt *afmt;
476d38ceaf9SAlex Deucher };
477d38ceaf9SAlex Deucher 
478d38ceaf9SAlex Deucher struct amdgpu_encoder {
479d38ceaf9SAlex Deucher 	struct drm_encoder base;
480d38ceaf9SAlex Deucher 	uint32_t encoder_enum;
481d38ceaf9SAlex Deucher 	uint32_t encoder_id;
482d38ceaf9SAlex Deucher 	uint32_t devices;
483d38ceaf9SAlex Deucher 	uint32_t active_device;
484d38ceaf9SAlex Deucher 	uint32_t flags;
485d38ceaf9SAlex Deucher 	uint32_t pixel_clock;
486d38ceaf9SAlex Deucher 	enum amdgpu_rmx_type rmx_type;
487d38ceaf9SAlex Deucher 	enum amdgpu_underscan_type underscan_type;
488d38ceaf9SAlex Deucher 	uint32_t underscan_hborder;
489d38ceaf9SAlex Deucher 	uint32_t underscan_vborder;
490d38ceaf9SAlex Deucher 	struct drm_display_mode native_mode;
491d38ceaf9SAlex Deucher 	void *enc_priv;
492d38ceaf9SAlex Deucher 	int audio_polling_active;
493d38ceaf9SAlex Deucher 	bool is_ext_encoder;
494d38ceaf9SAlex Deucher 	u16 caps;
495d38ceaf9SAlex Deucher };
496d38ceaf9SAlex Deucher 
497d38ceaf9SAlex Deucher struct amdgpu_connector_atom_dig {
498d38ceaf9SAlex Deucher 	/* displayport */
499d38ceaf9SAlex Deucher 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
500d38ceaf9SAlex Deucher 	u8 dp_sink_type;
501d38ceaf9SAlex Deucher 	int dp_clock;
502d38ceaf9SAlex Deucher 	int dp_lane_count;
503d38ceaf9SAlex Deucher 	bool edp_on;
504d38ceaf9SAlex Deucher };
505d38ceaf9SAlex Deucher 
506d38ceaf9SAlex Deucher struct amdgpu_gpio_rec {
507d38ceaf9SAlex Deucher 	bool valid;
508d38ceaf9SAlex Deucher 	u8 id;
509d38ceaf9SAlex Deucher 	u32 reg;
510d38ceaf9SAlex Deucher 	u32 mask;
511d38ceaf9SAlex Deucher 	u32 shift;
512d38ceaf9SAlex Deucher };
513d38ceaf9SAlex Deucher 
514d38ceaf9SAlex Deucher struct amdgpu_hpd {
515d38ceaf9SAlex Deucher 	enum amdgpu_hpd_id hpd;
516d38ceaf9SAlex Deucher 	u8 plugged_state;
517d38ceaf9SAlex Deucher 	struct amdgpu_gpio_rec gpio;
518d38ceaf9SAlex Deucher };
519d38ceaf9SAlex Deucher 
520d38ceaf9SAlex Deucher struct amdgpu_router {
521d38ceaf9SAlex Deucher 	u32 router_id;
522d38ceaf9SAlex Deucher 	struct amdgpu_i2c_bus_rec i2c_info;
523d38ceaf9SAlex Deucher 	u8 i2c_addr;
524d38ceaf9SAlex Deucher 	/* i2c mux */
525d38ceaf9SAlex Deucher 	bool ddc_valid;
526d38ceaf9SAlex Deucher 	u8 ddc_mux_type;
527d38ceaf9SAlex Deucher 	u8 ddc_mux_control_pin;
528d38ceaf9SAlex Deucher 	u8 ddc_mux_state;
529d38ceaf9SAlex Deucher 	/* clock/data mux */
530d38ceaf9SAlex Deucher 	bool cd_valid;
531d38ceaf9SAlex Deucher 	u8 cd_mux_type;
532d38ceaf9SAlex Deucher 	u8 cd_mux_control_pin;
533d38ceaf9SAlex Deucher 	u8 cd_mux_state;
534d38ceaf9SAlex Deucher };
535d38ceaf9SAlex Deucher 
536d38ceaf9SAlex Deucher enum amdgpu_connector_audio {
537d38ceaf9SAlex Deucher 	AMDGPU_AUDIO_DISABLE = 0,
538d38ceaf9SAlex Deucher 	AMDGPU_AUDIO_ENABLE = 1,
539d38ceaf9SAlex Deucher 	AMDGPU_AUDIO_AUTO = 2
540d38ceaf9SAlex Deucher };
541d38ceaf9SAlex Deucher 
542d38ceaf9SAlex Deucher enum amdgpu_connector_dither {
543d38ceaf9SAlex Deucher 	AMDGPU_FMT_DITHER_DISABLE = 0,
544d38ceaf9SAlex Deucher 	AMDGPU_FMT_DITHER_ENABLE = 1,
545d38ceaf9SAlex Deucher };
546d38ceaf9SAlex Deucher 
5474562236bSHarry Wentland struct amdgpu_dm_dp_aux {
5484562236bSHarry Wentland 	struct drm_dp_aux aux;
5494562236bSHarry Wentland 	uint32_t link_index;
5504562236bSHarry Wentland };
5514562236bSHarry Wentland 
5524562236bSHarry Wentland struct amdgpu_i2c_adapter {
5534562236bSHarry Wentland 	struct i2c_adapter base;
5544562236bSHarry Wentland 	struct amdgpu_display_manager *dm;
5554562236bSHarry Wentland 	uint32_t link_index;
5564562236bSHarry Wentland };
5574562236bSHarry Wentland 
5584562236bSHarry Wentland #define TO_DM_AUX(x) container_of((x), struct amdgpu_dm_dp_aux, aux)
5594562236bSHarry Wentland 
560d38ceaf9SAlex Deucher struct amdgpu_connector {
561d38ceaf9SAlex Deucher 	struct drm_connector base;
562d38ceaf9SAlex Deucher 	uint32_t connector_id;
563d38ceaf9SAlex Deucher 	uint32_t devices;
564d38ceaf9SAlex Deucher 	struct amdgpu_i2c_chan *ddc_bus;
565d38ceaf9SAlex Deucher 	/* some systems have an hdmi and vga port with a shared ddc line */
566d38ceaf9SAlex Deucher 	bool shared_ddc;
567d38ceaf9SAlex Deucher 	bool use_digital;
568d38ceaf9SAlex Deucher 	/* we need to mind the EDID between detect
569d38ceaf9SAlex Deucher 	   and get modes due to analog/digital/tvencoder */
570d38ceaf9SAlex Deucher 	struct edid *edid;
5714562236bSHarry Wentland 	/* number of modes generated from EDID at 'dc_sink' */
5724562236bSHarry Wentland 	int num_modes;
5734562236bSHarry Wentland 	/* The 'old' sink - before an HPD.
5744562236bSHarry Wentland 	 * The 'current' sink is in dc_link->sink. */
5754562236bSHarry Wentland 	const struct dc_sink *dc_sink;
5764562236bSHarry Wentland 	const struct dc_link *dc_link;
5774562236bSHarry Wentland 	const struct dc_sink *dc_em_sink;
578ab2541b6SAric Cyr 	const struct dc_stream *stream;
579d38ceaf9SAlex Deucher 	void *con_priv;
580d38ceaf9SAlex Deucher 	bool dac_load_detect;
581d38ceaf9SAlex Deucher 	bool detected_by_load; /* if the connection status was determined by load */
582d38ceaf9SAlex Deucher 	uint16_t connector_object_id;
583d38ceaf9SAlex Deucher 	struct amdgpu_hpd hpd;
584d38ceaf9SAlex Deucher 	struct amdgpu_router router;
585d38ceaf9SAlex Deucher 	struct amdgpu_i2c_chan *router_bus;
586d38ceaf9SAlex Deucher 	enum amdgpu_connector_audio audio;
587d38ceaf9SAlex Deucher 	enum amdgpu_connector_dither dither;
588d38ceaf9SAlex Deucher 	unsigned pixelclock_for_modeset;
5894562236bSHarry Wentland 
5904562236bSHarry Wentland 	struct drm_dp_mst_topology_mgr mst_mgr;
5914562236bSHarry Wentland 	struct amdgpu_dm_dp_aux dm_dp_aux;
5924562236bSHarry Wentland 	struct drm_dp_mst_port *port;
5934562236bSHarry Wentland 	struct amdgpu_connector *mst_port;
5944562236bSHarry Wentland 	struct amdgpu_encoder *mst_encoder;
5954562236bSHarry Wentland 	struct semaphore mst_sem;
5964562236bSHarry Wentland 
5974562236bSHarry Wentland 	/* TODO see if we can merge with ddc_bus or make a dm_connector */
5984562236bSHarry Wentland 	struct amdgpu_i2c_adapter *i2c;
5994562236bSHarry Wentland 
6004562236bSHarry Wentland 	/* Monitor range limits */
6014562236bSHarry Wentland 	int min_vfreq ;
6024562236bSHarry Wentland 	int max_vfreq ;
6034562236bSHarry Wentland 	int pixel_clock_mhz;
6044562236bSHarry Wentland 
6054562236bSHarry Wentland 	/*freesync caps*/
6064562236bSHarry Wentland 	struct mod_freesync_caps caps;
6074562236bSHarry Wentland 
6084562236bSHarry Wentland 	struct mutex hpd_lock;
6094562236bSHarry Wentland 
610d38ceaf9SAlex Deucher };
611d38ceaf9SAlex Deucher 
6124562236bSHarry Wentland /* TODO: start to use this struct and remove same field from base one */
6134562236bSHarry Wentland struct amdgpu_mst_connector {
6144562236bSHarry Wentland 	struct amdgpu_connector base;
6154562236bSHarry Wentland 
6164562236bSHarry Wentland 	struct drm_dp_mst_topology_mgr mst_mgr;
6174562236bSHarry Wentland 	struct amdgpu_dm_dp_aux dm_dp_aux;
6184562236bSHarry Wentland 	struct drm_dp_mst_port *port;
6194562236bSHarry Wentland 	struct amdgpu_connector *mst_port;
6204562236bSHarry Wentland 	bool is_mst_connector;
6214562236bSHarry Wentland 	struct amdgpu_encoder *mst_encoder;
622d38ceaf9SAlex Deucher };
623d38ceaf9SAlex Deucher 
624d38ceaf9SAlex Deucher #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
625d38ceaf9SAlex Deucher 				((em) == ATOM_ENCODER_MODE_DP_MST))
626d38ceaf9SAlex Deucher 
6278e36f9d3SAlex Deucher /* Driver internal use only flags of amdgpu_get_crtc_scanoutpos() */
6281bf6ad62SDaniel Vetter #define DRM_SCANOUTPOS_VALID        (1 << 0)
6291bf6ad62SDaniel Vetter #define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
6301bf6ad62SDaniel Vetter #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
6318e36f9d3SAlex Deucher #define USE_REAL_VBLANKSTART		(1 << 30)
6328e36f9d3SAlex Deucher #define GET_DISTANCE_TO_VBLANKSTART	(1 << 31)
6338e36f9d3SAlex Deucher 
634d38ceaf9SAlex Deucher void amdgpu_link_encoder_connector(struct drm_device *dev);
635d38ceaf9SAlex Deucher 
636d38ceaf9SAlex Deucher struct drm_connector *
637d38ceaf9SAlex Deucher amdgpu_get_connector_for_encoder(struct drm_encoder *encoder);
638d38ceaf9SAlex Deucher struct drm_connector *
639d38ceaf9SAlex Deucher amdgpu_get_connector_for_encoder_init(struct drm_encoder *encoder);
640d38ceaf9SAlex Deucher bool amdgpu_dig_monitor_is_duallink(struct drm_encoder *encoder,
641d38ceaf9SAlex Deucher 				    u32 pixel_clock);
642d38ceaf9SAlex Deucher 
643d38ceaf9SAlex Deucher u16 amdgpu_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder);
644d38ceaf9SAlex Deucher struct drm_encoder *amdgpu_get_external_encoder(struct drm_encoder *encoder);
645d38ceaf9SAlex Deucher 
646d38ceaf9SAlex Deucher bool amdgpu_ddc_probe(struct amdgpu_connector *amdgpu_connector, bool use_aux);
647d38ceaf9SAlex Deucher 
648d38ceaf9SAlex Deucher void amdgpu_encoder_set_active_device(struct drm_encoder *encoder);
649d38ceaf9SAlex Deucher 
65088e72717SThierry Reding int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
65188e72717SThierry Reding 			       unsigned int flags, int *vpos, int *hpos,
65288e72717SThierry Reding 			       ktime_t *stime, ktime_t *etime,
6533bb403bfSVille Syrjälä 			       const struct drm_display_mode *mode);
654d38ceaf9SAlex Deucher 
655d38ceaf9SAlex Deucher int amdgpu_framebuffer_init(struct drm_device *dev,
656d38ceaf9SAlex Deucher 			     struct amdgpu_framebuffer *rfb,
6571eb83451SVille Syrjälä 			     const struct drm_mode_fb_cmd2 *mode_cmd,
658d38ceaf9SAlex Deucher 			     struct drm_gem_object *obj);
659d38ceaf9SAlex Deucher 
660d38ceaf9SAlex Deucher int amdgpufb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
661d38ceaf9SAlex Deucher 
662d38ceaf9SAlex Deucher void amdgpu_enc_destroy(struct drm_encoder *encoder);
663d38ceaf9SAlex Deucher void amdgpu_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj);
664d38ceaf9SAlex Deucher bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
665d38ceaf9SAlex Deucher 					const struct drm_display_mode *mode,
666d38ceaf9SAlex Deucher 					struct drm_display_mode *adjusted_mode);
667d38ceaf9SAlex Deucher void amdgpu_panel_mode_fixup(struct drm_encoder *encoder,
668d38ceaf9SAlex Deucher 			     struct drm_display_mode *adjusted_mode);
669d38ceaf9SAlex Deucher int amdgpu_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc);
670d38ceaf9SAlex Deucher 
671d38ceaf9SAlex Deucher /* fbdev layer */
672d38ceaf9SAlex Deucher int amdgpu_fbdev_init(struct amdgpu_device *adev);
673d38ceaf9SAlex Deucher void amdgpu_fbdev_fini(struct amdgpu_device *adev);
674d38ceaf9SAlex Deucher void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state);
675d38ceaf9SAlex Deucher int amdgpu_fbdev_total_size(struct amdgpu_device *adev);
676d38ceaf9SAlex Deucher bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj);
6778b7530b1SAlex Deucher void amdgpu_fbdev_restore_mode(struct amdgpu_device *adev);
678d38ceaf9SAlex Deucher 
679d38ceaf9SAlex Deucher void amdgpu_fb_output_poll_changed(struct amdgpu_device *adev);
680d38ceaf9SAlex Deucher 
681d38ceaf9SAlex Deucher 
682d38ceaf9SAlex Deucher int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tiled);
683d38ceaf9SAlex Deucher 
684d38ceaf9SAlex Deucher /* amdgpu_display.c */
685d38ceaf9SAlex Deucher void amdgpu_print_display_setup(struct drm_device *dev);
686d38ceaf9SAlex Deucher int amdgpu_modeset_create_props(struct amdgpu_device *adev);
687a4eff9aaSDaniel Vetter int amdgpu_crtc_set_config(struct drm_mode_set *set,
688a4eff9aaSDaniel Vetter 			   struct drm_modeset_acquire_ctx *ctx);
689325cbba1SMichel Dänzer int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
690d38ceaf9SAlex Deucher 				 struct drm_framebuffer *fb,
691d38ceaf9SAlex Deucher 				 struct drm_pending_vblank_event *event,
69241292b1fSDaniel Vetter 				 uint32_t page_flip_flags, uint32_t target,
69341292b1fSDaniel Vetter 				 struct drm_modeset_acquire_ctx *ctx);
694d38ceaf9SAlex Deucher extern const struct drm_mode_config_funcs amdgpu_mode_funcs;
695d38ceaf9SAlex Deucher 
696d38ceaf9SAlex Deucher #endif
697