amdgpu_mode.h 18 KB

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