amdgpu_mode.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
  3. * VA Linux Systems Inc., Fremont, California.
  4. * Copyright 2008 Red Hat Inc.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Original Authors:
  25. * Kevin E. Martin, Rickard E. Faith, Alan Hourihane
  26. *
  27. * Kernel port Author: Dave Airlie
  28. */
  29. #ifndef AMDGPU_MODE_H
  30. #define AMDGPU_MODE_H
  31. #include <drm/drm_crtc.h>
  32. #include <drm/drm_edid.h>
  33. #include <drm/drm_encoder.h>
  34. #include <drm/drm_dp_helper.h>
  35. #include <drm/drm_fixed.h>
  36. #include <drm/drm_crtc_helper.h>
  37. #include <drm/drm_fb_helper.h>
  38. #include <drm/drm_plane_helper.h>
  39. #include <drm/drm_fb_helper.h>
  40. #include <linux/i2c.h>
  41. #include <linux/i2c-algo-bit.h>
  42. #include <linux/hrtimer.h>
  43. #include "amdgpu_irq.h"
  44. #include <drm/drm_dp_mst_helper.h>
  45. #include "modules/inc/mod_freesync.h"
  46. struct amdgpu_bo;
  47. struct amdgpu_device;
  48. struct amdgpu_encoder;
  49. struct amdgpu_router;
  50. struct amdgpu_hpd;
  51. #define to_amdgpu_crtc(x) container_of(x, struct amdgpu_crtc, base)
  52. #define to_amdgpu_connector(x) container_of(x, struct amdgpu_connector, base)
  53. #define to_amdgpu_encoder(x) container_of(x, struct amdgpu_encoder, base)
  54. #define to_amdgpu_framebuffer(x) container_of(x, struct amdgpu_framebuffer, base)
  55. #define to_amdgpu_plane(x) container_of(x, struct amdgpu_plane, base)
  56. #define to_dm_plane_state(x) container_of(x, struct dm_plane_state, base);
  57. #define AMDGPU_MAX_HPD_PINS 6
  58. #define AMDGPU_MAX_CRTCS 6
  59. #define AMDGPU_MAX_PLANES 6
  60. #define AMDGPU_MAX_AFMT_BLOCKS 9
  61. enum amdgpu_rmx_type {
  62. RMX_OFF,
  63. RMX_FULL,
  64. RMX_CENTER,
  65. RMX_ASPECT
  66. };
  67. enum amdgpu_underscan_type {
  68. UNDERSCAN_OFF,
  69. UNDERSCAN_ON,
  70. UNDERSCAN_AUTO,
  71. };
  72. #define AMDGPU_HPD_CONNECT_INT_DELAY_IN_MS 50
  73. #define AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS 10
  74. enum amdgpu_hpd_id {
  75. AMDGPU_HPD_1 = 0,
  76. AMDGPU_HPD_2,
  77. AMDGPU_HPD_3,
  78. AMDGPU_HPD_4,
  79. AMDGPU_HPD_5,
  80. AMDGPU_HPD_6,
  81. AMDGPU_HPD_NONE = 0xff,
  82. };
  83. enum amdgpu_crtc_irq {
  84. AMDGPU_CRTC_IRQ_VBLANK1 = 0,
  85. AMDGPU_CRTC_IRQ_VBLANK2,
  86. AMDGPU_CRTC_IRQ_VBLANK3,
  87. AMDGPU_CRTC_IRQ_VBLANK4,
  88. AMDGPU_CRTC_IRQ_VBLANK5,
  89. AMDGPU_CRTC_IRQ_VBLANK6,
  90. AMDGPU_CRTC_IRQ_VLINE1,
  91. AMDGPU_CRTC_IRQ_VLINE2,
  92. AMDGPU_CRTC_IRQ_VLINE3,
  93. AMDGPU_CRTC_IRQ_VLINE4,
  94. AMDGPU_CRTC_IRQ_VLINE5,
  95. AMDGPU_CRTC_IRQ_VLINE6,
  96. AMDGPU_CRTC_IRQ_NONE = 0xff
  97. };
  98. enum amdgpu_pageflip_irq {
  99. AMDGPU_PAGEFLIP_IRQ_D1 = 0,
  100. AMDGPU_PAGEFLIP_IRQ_D2,
  101. AMDGPU_PAGEFLIP_IRQ_D3,
  102. AMDGPU_PAGEFLIP_IRQ_D4,
  103. AMDGPU_PAGEFLIP_IRQ_D5,
  104. AMDGPU_PAGEFLIP_IRQ_D6,
  105. AMDGPU_PAGEFLIP_IRQ_NONE = 0xff
  106. };
  107. enum amdgpu_flip_status {
  108. AMDGPU_FLIP_NONE,
  109. AMDGPU_FLIP_PENDING,
  110. AMDGPU_FLIP_SUBMITTED
  111. };
  112. #define AMDGPU_MAX_I2C_BUS 16
  113. /* amdgpu gpio-based i2c
  114. * 1. "mask" reg and bits
  115. * grabs the gpio pins for software use
  116. * 0=not held 1=held
  117. * 2. "a" reg and bits
  118. * output pin value
  119. * 0=low 1=high
  120. * 3. "en" reg and bits
  121. * sets the pin direction
  122. * 0=input 1=output
  123. * 4. "y" reg and bits
  124. * input pin value
  125. * 0=low 1=high
  126. */
  127. struct amdgpu_i2c_bus_rec {
  128. bool valid;
  129. /* id used by atom */
  130. uint8_t i2c_id;
  131. /* id used by atom */
  132. enum amdgpu_hpd_id hpd;
  133. /* can be used with hw i2c engine */
  134. bool hw_capable;
  135. /* uses multi-media i2c engine */
  136. bool mm_i2c;
  137. /* regs and bits */
  138. uint32_t mask_clk_reg;
  139. uint32_t mask_data_reg;
  140. uint32_t a_clk_reg;
  141. uint32_t a_data_reg;
  142. uint32_t en_clk_reg;
  143. uint32_t en_data_reg;
  144. uint32_t y_clk_reg;
  145. uint32_t y_data_reg;
  146. uint32_t mask_clk_mask;
  147. uint32_t mask_data_mask;
  148. uint32_t a_clk_mask;
  149. uint32_t a_data_mask;
  150. uint32_t en_clk_mask;
  151. uint32_t en_data_mask;
  152. uint32_t y_clk_mask;
  153. uint32_t y_data_mask;
  154. };
  155. #define AMDGPU_MAX_BIOS_CONNECTOR 16
  156. /* pll flags */
  157. #define AMDGPU_PLL_USE_BIOS_DIVS (1 << 0)
  158. #define AMDGPU_PLL_NO_ODD_POST_DIV (1 << 1)
  159. #define AMDGPU_PLL_USE_REF_DIV (1 << 2)
  160. #define AMDGPU_PLL_LEGACY (1 << 3)
  161. #define AMDGPU_PLL_PREFER_LOW_REF_DIV (1 << 4)
  162. #define AMDGPU_PLL_PREFER_HIGH_REF_DIV (1 << 5)
  163. #define AMDGPU_PLL_PREFER_LOW_FB_DIV (1 << 6)
  164. #define AMDGPU_PLL_PREFER_HIGH_FB_DIV (1 << 7)
  165. #define AMDGPU_PLL_PREFER_LOW_POST_DIV (1 << 8)
  166. #define AMDGPU_PLL_PREFER_HIGH_POST_DIV (1 << 9)
  167. #define AMDGPU_PLL_USE_FRAC_FB_DIV (1 << 10)
  168. #define AMDGPU_PLL_PREFER_CLOSEST_LOWER (1 << 11)
  169. #define AMDGPU_PLL_USE_POST_DIV (1 << 12)
  170. #define AMDGPU_PLL_IS_LCD (1 << 13)
  171. #define AMDGPU_PLL_PREFER_MINM_OVER_MAXP (1 << 14)
  172. struct amdgpu_pll {
  173. /* reference frequency */
  174. uint32_t reference_freq;
  175. /* fixed dividers */
  176. uint32_t reference_div;
  177. uint32_t post_div;
  178. /* pll in/out limits */
  179. uint32_t pll_in_min;
  180. uint32_t pll_in_max;
  181. uint32_t pll_out_min;
  182. uint32_t pll_out_max;
  183. uint32_t lcd_pll_out_min;
  184. uint32_t lcd_pll_out_max;
  185. uint32_t best_vco;
  186. /* divider limits */
  187. uint32_t min_ref_div;
  188. uint32_t max_ref_div;
  189. uint32_t min_post_div;
  190. uint32_t max_post_div;
  191. uint32_t min_feedback_div;
  192. uint32_t max_feedback_div;
  193. uint32_t min_frac_feedback_div;
  194. uint32_t max_frac_feedback_div;
  195. /* flags for the current clock */
  196. uint32_t flags;
  197. /* pll id */
  198. uint32_t id;
  199. };
  200. struct amdgpu_i2c_chan {
  201. struct i2c_adapter adapter;
  202. struct drm_device *dev;
  203. struct i2c_algo_bit_data bit;
  204. struct amdgpu_i2c_bus_rec rec;
  205. struct drm_dp_aux aux;
  206. bool has_aux;
  207. struct mutex mutex;
  208. };
  209. struct amdgpu_fbdev;
  210. struct amdgpu_afmt {
  211. bool enabled;
  212. int offset;
  213. bool last_buffer_filled_status;
  214. int id;
  215. struct amdgpu_audio_pin *pin;
  216. };
  217. /*
  218. * Audio
  219. */
  220. struct amdgpu_audio_pin {
  221. int channels;
  222. int rate;
  223. int bits_per_sample;
  224. u8 status_bits;
  225. u8 category_code;
  226. u32 offset;
  227. bool connected;
  228. u32 id;
  229. };
  230. struct amdgpu_audio {
  231. bool enabled;
  232. struct amdgpu_audio_pin pin[AMDGPU_MAX_AFMT_BLOCKS];
  233. int num_pins;
  234. };
  235. struct amdgpu_display_funcs {
  236. /* display watermarks */
  237. void (*bandwidth_update)(struct amdgpu_device *adev);
  238. /* get frame count */
  239. u32 (*vblank_get_counter)(struct amdgpu_device *adev, int crtc);
  240. /* wait for vblank */
  241. void (*vblank_wait)(struct amdgpu_device *adev, int crtc);
  242. /* set backlight level */
  243. void (*backlight_set_level)(struct amdgpu_encoder *amdgpu_encoder,
  244. u8 level);
  245. /* get backlight level */
  246. u8 (*backlight_get_level)(struct amdgpu_encoder *amdgpu_encoder);
  247. /* hotplug detect */
  248. bool (*hpd_sense)(struct amdgpu_device *adev, enum amdgpu_hpd_id hpd);
  249. void (*hpd_set_polarity)(struct amdgpu_device *adev,
  250. enum amdgpu_hpd_id hpd);
  251. u32 (*hpd_get_gpio_reg)(struct amdgpu_device *adev);
  252. /* pageflipping */
  253. void (*page_flip)(struct amdgpu_device *adev,
  254. int crtc_id, u64 crtc_base, bool async);
  255. int (*page_flip_get_scanoutpos)(struct amdgpu_device *adev, int crtc,
  256. u32 *vbl, u32 *position);
  257. /* display topology setup */
  258. void (*add_encoder)(struct amdgpu_device *adev,
  259. uint32_t encoder_enum,
  260. uint32_t supported_device,
  261. u16 caps);
  262. void (*add_connector)(struct amdgpu_device *adev,
  263. uint32_t connector_id,
  264. uint32_t supported_device,
  265. int connector_type,
  266. struct amdgpu_i2c_bus_rec *i2c_bus,
  267. uint16_t connector_object_id,
  268. struct amdgpu_hpd *hpd,
  269. struct amdgpu_router *router);
  270. /* it is used to enter or exit into free sync mode */
  271. int (*notify_freesync)(struct drm_device *dev, void *data,
  272. struct drm_file *filp);
  273. /* it is used to allow enablement of freesync mode */
  274. int (*set_freesync_property)(struct drm_connector *connector,
  275. struct drm_property *property,
  276. uint64_t val);
  277. };
  278. struct amdgpu_framebuffer {
  279. struct drm_framebuffer base;
  280. struct drm_gem_object *obj;
  281. /* caching for later use */
  282. uint64_t address;
  283. };
  284. struct amdgpu_fbdev {
  285. struct drm_fb_helper helper;
  286. struct amdgpu_framebuffer rfb;
  287. struct list_head fbdev_list;
  288. struct amdgpu_device *adev;
  289. };
  290. struct amdgpu_mode_info {
  291. struct atom_context *atom_context;
  292. struct card_info *atom_card_info;
  293. bool mode_config_initialized;
  294. struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS];
  295. struct amdgpu_plane *planes[AMDGPU_MAX_PLANES];
  296. struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS];
  297. /* DVI-I properties */
  298. struct drm_property *coherent_mode_property;
  299. /* DAC enable load detect */
  300. struct drm_property *load_detect_property;
  301. /* underscan */
  302. struct drm_property *underscan_property;
  303. struct drm_property *underscan_hborder_property;
  304. struct drm_property *underscan_vborder_property;
  305. /* audio */
  306. struct drm_property *audio_property;
  307. /* FMT dithering */
  308. struct drm_property *dither_property;
  309. /* hardcoded DFP edid from BIOS */
  310. struct edid *bios_hardcoded_edid;
  311. int bios_hardcoded_edid_size;
  312. /* pointer to fbdev info structure */
  313. struct amdgpu_fbdev *rfbdev;
  314. /* firmware flags */
  315. u16 firmware_flags;
  316. /* pointer to backlight encoder */
  317. struct amdgpu_encoder *bl_encoder;
  318. u8 bl_level; /* saved backlight level */
  319. struct amdgpu_audio audio; /* audio stuff */
  320. int num_crtc; /* number of crtcs */
  321. int num_hpd; /* number of hpd pins */
  322. int num_dig; /* number of dig blocks */
  323. int disp_priority;
  324. const struct amdgpu_display_funcs *funcs;
  325. const enum drm_plane_type *plane_type;
  326. };
  327. #define AMDGPU_MAX_BL_LEVEL 0xFF
  328. #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
  329. struct amdgpu_backlight_privdata {
  330. struct amdgpu_encoder *encoder;
  331. uint8_t negative;
  332. };
  333. #endif
  334. struct amdgpu_atom_ss {
  335. uint16_t percentage;
  336. uint16_t percentage_divider;
  337. uint8_t type;
  338. uint16_t step;
  339. uint8_t delay;
  340. uint8_t range;
  341. uint8_t refdiv;
  342. /* asic_ss */
  343. uint16_t rate;
  344. uint16_t amount;
  345. };
  346. struct amdgpu_crtc {
  347. struct drm_crtc base;
  348. int crtc_id;
  349. bool enabled;
  350. bool can_tile;
  351. uint32_t crtc_offset;
  352. struct drm_gem_object *cursor_bo;
  353. uint64_t cursor_addr;
  354. int cursor_x;
  355. int cursor_y;
  356. int cursor_hot_x;
  357. int cursor_hot_y;
  358. int cursor_width;
  359. int cursor_height;
  360. int max_cursor_width;
  361. int max_cursor_height;
  362. enum amdgpu_rmx_type rmx_type;
  363. u8 h_border;
  364. u8 v_border;
  365. fixed20_12 vsc;
  366. fixed20_12 hsc;
  367. struct drm_display_mode native_mode;
  368. u32 pll_id;
  369. /* page flipping */
  370. struct amdgpu_flip_work *pflip_works;
  371. enum amdgpu_flip_status pflip_status;
  372. int deferred_flip_completion;
  373. /* pll sharing */
  374. struct amdgpu_atom_ss ss;
  375. bool ss_enabled;
  376. u32 adjusted_clock;
  377. int bpc;
  378. u32 pll_reference_div;
  379. u32 pll_post_div;
  380. u32 pll_flags;
  381. struct drm_encoder *encoder;
  382. struct drm_connector *connector;
  383. /* for dpm */
  384. u32 line_time;
  385. u32 wm_low;
  386. u32 wm_high;
  387. u32 lb_vblank_lead_lines;
  388. struct drm_display_mode hw_mode;
  389. /* for virtual dce */
  390. struct hrtimer vblank_timer;
  391. enum amdgpu_interrupt_state vsync_timer_enabled;
  392. int otg_inst;
  393. struct drm_pending_vblank_event *event;
  394. };
  395. struct amdgpu_plane {
  396. struct drm_plane base;
  397. enum drm_plane_type plane_type;
  398. };
  399. struct amdgpu_encoder_atom_dig {
  400. bool linkb;
  401. /* atom dig */
  402. bool coherent_mode;
  403. int dig_encoder; /* -1 disabled, 0 DIGA, 1 DIGB, etc. */
  404. /* atom lvds/edp */
  405. uint32_t lcd_misc;
  406. uint16_t panel_pwr_delay;
  407. uint32_t lcd_ss_id;
  408. /* panel mode */
  409. struct drm_display_mode native_mode;
  410. struct backlight_device *bl_dev;
  411. int dpms_mode;
  412. uint8_t backlight_level;
  413. int panel_mode;
  414. struct amdgpu_afmt *afmt;
  415. };
  416. struct amdgpu_encoder {
  417. struct drm_encoder base;
  418. uint32_t encoder_enum;
  419. uint32_t encoder_id;
  420. uint32_t devices;
  421. uint32_t active_device;
  422. uint32_t flags;
  423. uint32_t pixel_clock;
  424. enum amdgpu_rmx_type rmx_type;
  425. enum amdgpu_underscan_type underscan_type;
  426. uint32_t underscan_hborder;
  427. uint32_t underscan_vborder;
  428. struct drm_display_mode native_mode;
  429. void *enc_priv;
  430. int audio_polling_active;
  431. bool is_ext_encoder;
  432. u16 caps;
  433. };
  434. struct amdgpu_connector_atom_dig {
  435. /* displayport */
  436. u8 dpcd[DP_RECEIVER_CAP_SIZE];
  437. u8 dp_sink_type;
  438. int dp_clock;
  439. int dp_lane_count;
  440. bool edp_on;
  441. };
  442. struct amdgpu_gpio_rec {
  443. bool valid;
  444. u8 id;
  445. u32 reg;
  446. u32 mask;
  447. u32 shift;
  448. };
  449. struct amdgpu_hpd {
  450. enum amdgpu_hpd_id hpd;
  451. u8 plugged_state;
  452. struct amdgpu_gpio_rec gpio;
  453. };
  454. struct amdgpu_router {
  455. u32 router_id;
  456. struct amdgpu_i2c_bus_rec i2c_info;
  457. u8 i2c_addr;
  458. /* i2c mux */
  459. bool ddc_valid;
  460. u8 ddc_mux_type;
  461. u8 ddc_mux_control_pin;
  462. u8 ddc_mux_state;
  463. /* clock/data mux */
  464. bool cd_valid;
  465. u8 cd_mux_type;
  466. u8 cd_mux_control_pin;
  467. u8 cd_mux_state;
  468. };
  469. enum amdgpu_connector_audio {
  470. AMDGPU_AUDIO_DISABLE = 0,
  471. AMDGPU_AUDIO_ENABLE = 1,
  472. AMDGPU_AUDIO_AUTO = 2
  473. };
  474. enum amdgpu_connector_dither {
  475. AMDGPU_FMT_DITHER_DISABLE = 0,
  476. AMDGPU_FMT_DITHER_ENABLE = 1,
  477. };
  478. struct amdgpu_dm_dp_aux {
  479. struct drm_dp_aux aux;
  480. struct ddc_service *ddc_service;
  481. };
  482. struct amdgpu_i2c_adapter {
  483. struct i2c_adapter base;
  484. struct ddc_service *ddc_service;
  485. };
  486. #define TO_DM_AUX(x) container_of((x), struct amdgpu_dm_dp_aux, aux)
  487. struct amdgpu_connector {
  488. struct drm_connector base;
  489. uint32_t connector_id;
  490. uint32_t devices;
  491. struct amdgpu_i2c_chan *ddc_bus;
  492. /* some systems have an hdmi and vga port with a shared ddc line */
  493. bool shared_ddc;
  494. bool use_digital;
  495. /* we need to mind the EDID between detect
  496. and get modes due to analog/digital/tvencoder */
  497. struct edid *edid;
  498. /* number of modes generated from EDID at 'dc_sink' */
  499. int num_modes;
  500. /* The 'old' sink - before an HPD.
  501. * The 'current' sink is in dc_link->sink. */
  502. struct dc_sink *dc_sink;
  503. struct dc_link *dc_link;
  504. struct dc_sink *dc_em_sink;
  505. const struct dc_stream *stream;
  506. void *con_priv;
  507. bool dac_load_detect;
  508. bool detected_by_load; /* if the connection status was determined by load */
  509. uint16_t connector_object_id;
  510. struct amdgpu_hpd hpd;
  511. struct amdgpu_router router;
  512. struct amdgpu_i2c_chan *router_bus;
  513. enum amdgpu_connector_audio audio;
  514. enum amdgpu_connector_dither dither;
  515. unsigned pixelclock_for_modeset;
  516. struct drm_dp_mst_topology_mgr mst_mgr;
  517. struct amdgpu_dm_dp_aux dm_dp_aux;
  518. struct drm_dp_mst_port *port;
  519. struct amdgpu_connector *mst_port;
  520. struct amdgpu_encoder *mst_encoder;
  521. struct semaphore mst_sem;
  522. /* TODO see if we can merge with ddc_bus or make a dm_connector */
  523. struct amdgpu_i2c_adapter *i2c;
  524. /* Monitor range limits */
  525. int min_vfreq ;
  526. int max_vfreq ;
  527. int pixel_clock_mhz;
  528. /*freesync caps*/
  529. struct mod_freesync_caps caps;
  530. struct mutex hpd_lock;
  531. };
  532. /* TODO: start to use this struct and remove same field from base one */
  533. struct amdgpu_mst_connector {
  534. struct amdgpu_connector base;
  535. struct drm_dp_mst_topology_mgr mst_mgr;
  536. struct amdgpu_dm_dp_aux dm_dp_aux;
  537. struct drm_dp_mst_port *port;
  538. struct amdgpu_connector *mst_port;
  539. bool is_mst_connector;
  540. struct amdgpu_encoder *mst_encoder;
  541. };
  542. #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
  543. ((em) == ATOM_ENCODER_MODE_DP_MST))
  544. /* Driver internal use only flags of amdgpu_get_crtc_scanoutpos() */
  545. #define DRM_SCANOUTPOS_VALID (1 << 0)
  546. #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
  547. #define DRM_SCANOUTPOS_ACCURATE (1 << 2)
  548. #define USE_REAL_VBLANKSTART (1 << 30)
  549. #define GET_DISTANCE_TO_VBLANKSTART (1 << 31)
  550. void amdgpu_link_encoder_connector(struct drm_device *dev);
  551. struct drm_connector *
  552. amdgpu_get_connector_for_encoder(struct drm_encoder *encoder);
  553. struct drm_connector *
  554. amdgpu_get_connector_for_encoder_init(struct drm_encoder *encoder);
  555. bool amdgpu_dig_monitor_is_duallink(struct drm_encoder *encoder,
  556. u32 pixel_clock);
  557. u16 amdgpu_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder);
  558. struct drm_encoder *amdgpu_get_external_encoder(struct drm_encoder *encoder);
  559. bool amdgpu_ddc_probe(struct amdgpu_connector *amdgpu_connector, bool use_aux);
  560. void amdgpu_encoder_set_active_device(struct drm_encoder *encoder);
  561. int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,
  562. unsigned int flags, int *vpos, int *hpos,
  563. ktime_t *stime, ktime_t *etime,
  564. const struct drm_display_mode *mode);
  565. int amdgpu_framebuffer_init(struct drm_device *dev,
  566. struct amdgpu_framebuffer *rfb,
  567. const struct drm_mode_fb_cmd2 *mode_cmd,
  568. struct drm_gem_object *obj);
  569. int amdgpufb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
  570. void amdgpu_enc_destroy(struct drm_encoder *encoder);
  571. void amdgpu_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj);
  572. bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
  573. const struct drm_display_mode *mode,
  574. struct drm_display_mode *adjusted_mode);
  575. void amdgpu_panel_mode_fixup(struct drm_encoder *encoder,
  576. struct drm_display_mode *adjusted_mode);
  577. int amdgpu_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc);
  578. /* fbdev layer */
  579. int amdgpu_fbdev_init(struct amdgpu_device *adev);
  580. void amdgpu_fbdev_fini(struct amdgpu_device *adev);
  581. void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state);
  582. int amdgpu_fbdev_total_size(struct amdgpu_device *adev);
  583. bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj);
  584. int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tiled);
  585. /* amdgpu_display.c */
  586. void amdgpu_print_display_setup(struct drm_device *dev);
  587. int amdgpu_modeset_create_props(struct amdgpu_device *adev);
  588. int amdgpu_crtc_set_config(struct drm_mode_set *set,
  589. struct drm_modeset_acquire_ctx *ctx);
  590. int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
  591. struct drm_framebuffer *fb,
  592. struct drm_pending_vblank_event *event,
  593. uint32_t page_flip_flags, uint32_t target,
  594. struct drm_modeset_acquire_ctx *ctx);
  595. extern const struct drm_mode_config_funcs amdgpu_mode_funcs;
  596. #endif