dc.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. /*
  2. * Copyright 2012-14 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef DC_INTERFACE_H_
  26. #define DC_INTERFACE_H_
  27. #include "dc_types.h"
  28. #include "grph_object_defs.h"
  29. #include "logger_types.h"
  30. #include "gpio_types.h"
  31. #include "link_service_types.h"
  32. #define MAX_SURFACES 3
  33. #define MAX_STREAMS 6
  34. #define MAX_SINKS_PER_LINK 4
  35. /*******************************************************************************
  36. * Display Core Interfaces
  37. ******************************************************************************/
  38. struct dc_caps {
  39. uint32_t max_streams;
  40. uint32_t max_links;
  41. uint32_t max_audios;
  42. uint32_t max_slave_planes;
  43. uint32_t max_surfaces;
  44. uint32_t max_downscale_ratio;
  45. uint32_t i2c_speed_in_khz;
  46. unsigned int max_cursor_size;
  47. };
  48. struct dc_dcc_surface_param {
  49. struct dc_size surface_size;
  50. enum surface_pixel_format format;
  51. enum swizzle_mode_values swizzle_mode;
  52. enum dc_scan_direction scan;
  53. };
  54. struct dc_dcc_setting {
  55. unsigned int max_compressed_blk_size;
  56. unsigned int max_uncompressed_blk_size;
  57. bool independent_64b_blks;
  58. };
  59. struct dc_surface_dcc_cap {
  60. union {
  61. struct {
  62. struct dc_dcc_setting rgb;
  63. } grph;
  64. struct {
  65. struct dc_dcc_setting luma;
  66. struct dc_dcc_setting chroma;
  67. } video;
  68. };
  69. bool capable;
  70. bool const_color_support;
  71. };
  72. struct dc_static_screen_events {
  73. bool cursor_update;
  74. bool surface_update;
  75. bool overlay_update;
  76. };
  77. /* Forward declaration*/
  78. struct dc;
  79. struct dc_surface;
  80. struct validate_context;
  81. struct dc_cap_funcs {
  82. #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
  83. bool (*get_dcc_compression_cap)(const struct dc *dc,
  84. const struct dc_dcc_surface_param *input,
  85. struct dc_surface_dcc_cap *output);
  86. #else
  87. int i;
  88. #endif
  89. };
  90. struct dc_stream_funcs {
  91. bool (*adjust_vmin_vmax)(struct dc *dc,
  92. const struct dc_stream **stream,
  93. int num_streams,
  94. int vmin,
  95. int vmax);
  96. bool (*get_crtc_position)(struct dc *dc,
  97. const struct dc_stream **stream,
  98. int num_streams,
  99. unsigned int *v_pos,
  100. unsigned int *nom_v_pos);
  101. bool (*set_gamut_remap)(struct dc *dc,
  102. const struct dc_stream *stream);
  103. void (*set_static_screen_events)(struct dc *dc,
  104. const struct dc_stream **stream,
  105. int num_streams,
  106. const struct dc_static_screen_events *events);
  107. void (*set_dither_option)(const struct dc_stream *stream,
  108. enum dc_dither_option option);
  109. };
  110. struct link_training_settings;
  111. struct dc_link_funcs {
  112. void (*set_drive_settings)(struct dc *dc,
  113. struct link_training_settings *lt_settings,
  114. const struct dc_link *link);
  115. void (*perform_link_training)(struct dc *dc,
  116. struct dc_link_settings *link_setting,
  117. bool skip_video_pattern);
  118. void (*set_preferred_link_settings)(struct dc *dc,
  119. struct dc_link_settings *link_setting,
  120. const struct dc_link *link);
  121. void (*enable_hpd)(const struct dc_link *link);
  122. void (*disable_hpd)(const struct dc_link *link);
  123. void (*set_test_pattern)(
  124. const struct dc_link *link,
  125. enum dp_test_pattern test_pattern,
  126. const struct link_training_settings *p_link_settings,
  127. const unsigned char *p_custom_pattern,
  128. unsigned int cust_pattern_size);
  129. };
  130. /* Structure to hold configuration flags set by dm at dc creation. */
  131. struct dc_config {
  132. bool gpu_vm_support;
  133. bool disable_disp_pll_sharing;
  134. };
  135. struct dc_debug {
  136. bool surface_visual_confirm;
  137. bool max_disp_clk;
  138. bool surface_trace;
  139. bool timing_trace;
  140. bool clock_trace;
  141. bool validation_trace;
  142. bool disable_stutter;
  143. bool disable_dcc;
  144. bool disable_dfs_bypass;
  145. #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
  146. bool disable_dpp_power_gate;
  147. bool disable_hubp_power_gate;
  148. bool disable_pplib_wm_range;
  149. bool use_dml_wm;
  150. bool disable_pipe_split;
  151. int sr_exit_time_dpm0_ns;
  152. int sr_enter_plus_exit_time_dpm0_ns;
  153. int sr_exit_time_ns;
  154. int sr_enter_plus_exit_time_ns;
  155. int urgent_latency_ns;
  156. int percent_of_ideal_drambw;
  157. int dram_clock_change_latency_ns;
  158. int always_scale;
  159. #endif
  160. bool disable_pplib_clock_request;
  161. bool disable_clock_gate;
  162. bool disable_dmcu;
  163. bool disable_psr;
  164. bool force_abm_enable;
  165. };
  166. struct dc {
  167. struct dc_caps caps;
  168. struct dc_cap_funcs cap_funcs;
  169. struct dc_stream_funcs stream_funcs;
  170. struct dc_link_funcs link_funcs;
  171. struct dc_config config;
  172. struct dc_debug debug;
  173. };
  174. enum frame_buffer_mode {
  175. FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
  176. FRAME_BUFFER_MODE_ZFB_ONLY,
  177. FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
  178. } ;
  179. struct dchub_init_data {
  180. int64_t zfb_phys_addr_base;
  181. int64_t zfb_mc_base_addr;
  182. uint64_t zfb_size_in_byte;
  183. enum frame_buffer_mode fb_mode;
  184. bool dchub_initialzied;
  185. bool dchub_info_valid;
  186. };
  187. struct dc_init_data {
  188. struct hw_asic_id asic_id;
  189. void *driver; /* ctx */
  190. struct cgs_device *cgs_device;
  191. int num_virtual_links;
  192. /*
  193. * If 'vbios_override' not NULL, it will be called instead
  194. * of the real VBIOS. Intended use is Diagnostics on FPGA.
  195. */
  196. struct dc_bios *vbios_override;
  197. enum dce_environment dce_environment;
  198. struct dc_config flags;
  199. };
  200. struct dc *dc_create(const struct dc_init_data *init_params);
  201. void dc_destroy(struct dc **dc);
  202. bool dc_init_dchub(struct dc *dc, struct dchub_init_data *dh_data);
  203. /*******************************************************************************
  204. * Surface Interfaces
  205. ******************************************************************************/
  206. enum {
  207. TRANSFER_FUNC_POINTS = 1025
  208. };
  209. struct dc_hdr_static_metadata {
  210. /* display chromaticities and white point in units of 0.00001 */
  211. unsigned int chromaticity_green_x;
  212. unsigned int chromaticity_green_y;
  213. unsigned int chromaticity_blue_x;
  214. unsigned int chromaticity_blue_y;
  215. unsigned int chromaticity_red_x;
  216. unsigned int chromaticity_red_y;
  217. unsigned int chromaticity_white_point_x;
  218. unsigned int chromaticity_white_point_y;
  219. uint32_t min_luminance;
  220. uint32_t max_luminance;
  221. uint32_t maximum_content_light_level;
  222. uint32_t maximum_frame_average_light_level;
  223. bool hdr_supported;
  224. bool is_hdr;
  225. };
  226. enum dc_transfer_func_type {
  227. TF_TYPE_PREDEFINED,
  228. TF_TYPE_DISTRIBUTED_POINTS,
  229. TF_TYPE_BYPASS
  230. };
  231. struct dc_transfer_func_distributed_points {
  232. struct fixed31_32 red[TRANSFER_FUNC_POINTS];
  233. struct fixed31_32 green[TRANSFER_FUNC_POINTS];
  234. struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
  235. uint16_t end_exponent;
  236. uint16_t x_point_at_y1_red;
  237. uint16_t x_point_at_y1_green;
  238. uint16_t x_point_at_y1_blue;
  239. };
  240. enum dc_transfer_func_predefined {
  241. TRANSFER_FUNCTION_SRGB,
  242. TRANSFER_FUNCTION_BT709,
  243. TRANSFER_FUNCTION_PQ,
  244. TRANSFER_FUNCTION_LINEAR,
  245. };
  246. struct dc_transfer_func {
  247. struct dc_transfer_func_distributed_points tf_pts;
  248. enum dc_transfer_func_type type;
  249. enum dc_transfer_func_predefined tf;
  250. };
  251. struct dc_surface {
  252. struct dc_plane_address address;
  253. struct scaling_taps scaling_quality;
  254. struct rect src_rect;
  255. struct rect dst_rect;
  256. struct rect clip_rect;
  257. union plane_size plane_size;
  258. union dc_tiling_info tiling_info;
  259. struct dc_plane_dcc_param dcc;
  260. struct dc_hdr_static_metadata hdr_static_ctx;
  261. const struct dc_gamma *gamma_correction;
  262. const struct dc_transfer_func *in_transfer_func;
  263. enum dc_color_space color_space;
  264. enum surface_pixel_format format;
  265. enum dc_rotation_angle rotation;
  266. enum plane_stereo_format stereo_format;
  267. bool per_pixel_alpha;
  268. bool visible;
  269. bool flip_immediate;
  270. bool horizontal_mirror;
  271. };
  272. struct dc_plane_info {
  273. union plane_size plane_size;
  274. union dc_tiling_info tiling_info;
  275. struct dc_plane_dcc_param dcc;
  276. enum surface_pixel_format format;
  277. enum dc_rotation_angle rotation;
  278. enum plane_stereo_format stereo_format;
  279. enum dc_color_space color_space; /*todo: wrong place, fits in scaling info*/
  280. bool horizontal_mirror;
  281. bool visible;
  282. bool per_pixel_alpha;
  283. };
  284. struct dc_scaling_info {
  285. struct rect src_rect;
  286. struct rect dst_rect;
  287. struct rect clip_rect;
  288. struct scaling_taps scaling_quality;
  289. };
  290. struct dc_surface_update {
  291. const struct dc_surface *surface;
  292. /* isr safe update parameters. null means no updates */
  293. struct dc_flip_addrs *flip_addr;
  294. struct dc_plane_info *plane_info;
  295. struct dc_scaling_info *scaling_info;
  296. /* following updates require alloc/sleep/spin that is not isr safe,
  297. * null means no updates
  298. */
  299. /* gamma TO BE REMOVED */
  300. struct dc_gamma *gamma;
  301. struct dc_transfer_func *in_transfer_func;
  302. struct dc_hdr_static_metadata *hdr_static_metadata;
  303. };
  304. /*
  305. * This structure is filled in by dc_surface_get_status and contains
  306. * the last requested address and the currently active address so the called
  307. * can determine if there are any outstanding flips
  308. */
  309. struct dc_surface_status {
  310. struct dc_plane_address requested_address;
  311. struct dc_plane_address current_address;
  312. bool is_flip_pending;
  313. bool is_right_eye;
  314. };
  315. /*
  316. * Create a new surface with default parameters;
  317. */
  318. struct dc_surface *dc_create_surface(const struct dc *dc);
  319. const struct dc_surface_status *dc_surface_get_status(
  320. const struct dc_surface *dc_surface);
  321. void dc_surface_retain(const struct dc_surface *dc_surface);
  322. void dc_surface_release(const struct dc_surface *dc_surface);
  323. void dc_gamma_retain(const struct dc_gamma *dc_gamma);
  324. void dc_gamma_release(const struct dc_gamma **dc_gamma);
  325. struct dc_gamma *dc_create_gamma(void);
  326. void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
  327. void dc_transfer_func_release(const struct dc_transfer_func *dc_tf);
  328. struct dc_transfer_func *dc_create_transfer_func(void);
  329. /*
  330. * This structure holds a surface address. There could be multiple addresses
  331. * in cases such as Stereo 3D, Planar YUV, etc. Other per-flip attributes such
  332. * as frame durations and DCC format can also be set.
  333. */
  334. struct dc_flip_addrs {
  335. struct dc_plane_address address;
  336. bool flip_immediate;
  337. /* TODO: add flip duration for FreeSync */
  338. };
  339. /*
  340. * Set up surface attributes and associate to a stream
  341. * The surfaces parameter is an absolute set of all surface active for the stream.
  342. * If no surfaces are provided, the stream will be blanked; no memory read.
  343. * Any flip related attribute changes must be done through this interface.
  344. *
  345. * After this call:
  346. * Surfaces attributes are programmed and configured to be composed into stream.
  347. * This does not trigger a flip. No surface address is programmed.
  348. */
  349. bool dc_commit_surfaces_to_stream(
  350. struct dc *dc,
  351. const struct dc_surface **dc_surfaces,
  352. uint8_t surface_count,
  353. const struct dc_stream *stream);
  354. bool dc_post_update_surfaces_to_stream(
  355. struct dc *dc);
  356. void dc_update_surfaces_for_stream(struct dc *dc, struct dc_surface_update *updates,
  357. int surface_count, const struct dc_stream *stream);
  358. /* Surface update type is used by dc_update_surfaces_and_stream
  359. * The update type is determined at the very beginning of the function based
  360. * on parameters passed in and decides how much programming (or updating) is
  361. * going to be done during the call.
  362. *
  363. * UPDATE_TYPE_FAST is used for really fast updates that do not require much
  364. * logical calculations or hardware register programming. This update MUST be
  365. * ISR safe on windows. Currently fast update will only be used to flip surface
  366. * address.
  367. *
  368. * UPDATE_TYPE_MED is used for slower updates which require significant hw
  369. * re-programming however do not affect bandwidth consumption or clock
  370. * requirements. At present, this is the level at which front end updates
  371. * that do not require us to run bw_calcs happen. These are in/out transfer func
  372. * updates, viewport offset changes, recout size changes and pixel depth changes.
  373. * This update can be done at ISR, but we want to minimize how often this happens.
  374. *
  375. * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
  376. * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
  377. * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
  378. * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
  379. * a full update. This cannot be done at ISR level and should be a rare event.
  380. * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
  381. * underscan we don't expect to see this call at all.
  382. */
  383. enum surface_update_type {
  384. UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
  385. UPDATE_TYPE_MED, /* ISR safe, most of programming needed, no bw/clk change*/
  386. UPDATE_TYPE_FULL, /* may need to shuffle resources */
  387. };
  388. /*******************************************************************************
  389. * Stream Interfaces
  390. ******************************************************************************/
  391. struct dc_stream {
  392. const struct dc_sink *sink;
  393. struct dc_crtc_timing timing;
  394. struct rect src; /* composition area */
  395. struct rect dst; /* stream addressable area */
  396. struct audio_info audio_info;
  397. struct freesync_context freesync_ctx;
  398. const struct dc_transfer_func *out_transfer_func;
  399. struct colorspace_transform gamut_remap_matrix;
  400. struct csc_transform csc_color_matrix;
  401. enum signal_type output_signal;
  402. enum dc_color_space output_color_space;
  403. enum dc_dither_option dither_option;
  404. enum view_3d_format view_format;
  405. bool ignore_msa_timing_param;
  406. /* TODO: custom INFO packets */
  407. /* TODO: ABM info (DMCU) */
  408. /* TODO: PSR info */
  409. /* TODO: CEA VIC */
  410. };
  411. struct dc_stream_update {
  412. struct rect src;
  413. struct rect dst;
  414. struct dc_transfer_func *out_transfer_func;
  415. };
  416. /*
  417. * Setup stream attributes if no stream updates are provided
  418. * there will be no impact on the stream parameters
  419. *
  420. * Set up surface attributes and associate to a stream
  421. * The surfaces parameter is an absolute set of all surface active for the stream.
  422. * If no surfaces are provided, the stream will be blanked; no memory read.
  423. * Any flip related attribute changes must be done through this interface.
  424. *
  425. * After this call:
  426. * Surfaces attributes are programmed and configured to be composed into stream.
  427. * This does not trigger a flip. No surface address is programmed.
  428. *
  429. */
  430. void dc_update_surfaces_and_stream(struct dc *dc,
  431. struct dc_surface_update *surface_updates, int surface_count,
  432. const struct dc_stream *dc_stream,
  433. struct dc_stream_update *stream_update);
  434. /*
  435. * Log the current stream state.
  436. */
  437. void dc_stream_log(
  438. const struct dc_stream *stream,
  439. struct dal_logger *dc_logger,
  440. enum dc_log_type log_type);
  441. uint8_t dc_get_current_stream_count(const struct dc *dc);
  442. struct dc_stream *dc_get_stream_at_index(const struct dc *dc, uint8_t i);
  443. /*
  444. * Return the current frame counter.
  445. */
  446. uint32_t dc_stream_get_vblank_counter(const struct dc_stream *stream);
  447. /* TODO: Return parsed values rather than direct register read
  448. * This has a dependency on the caller (amdgpu_get_crtc_scanoutpos)
  449. * being refactored properly to be dce-specific
  450. */
  451. bool dc_stream_get_scanoutpos(const struct dc_stream *stream,
  452. uint32_t *v_blank_start,
  453. uint32_t *v_blank_end,
  454. uint32_t *h_position,
  455. uint32_t *v_position);
  456. /*
  457. * Structure to store surface/stream associations for validation
  458. */
  459. struct dc_validation_set {
  460. const struct dc_stream *stream;
  461. const struct dc_surface *surfaces[MAX_SURFACES];
  462. uint8_t surface_count;
  463. };
  464. /*
  465. * This function takes a set of resources and checks that they are cofunctional.
  466. *
  467. * After this call:
  468. * No hardware is programmed for call. Only validation is done.
  469. */
  470. struct validate_context *dc_get_validate_context(
  471. const struct dc *dc,
  472. const struct dc_validation_set set[],
  473. uint8_t set_count);
  474. bool dc_validate_resources(
  475. const struct dc *dc,
  476. const struct dc_validation_set set[],
  477. uint8_t set_count);
  478. /*
  479. * This function takes a stream and checks if it is guaranteed to be supported.
  480. * Guaranteed means that MAX_COFUNC similar streams are supported.
  481. *
  482. * After this call:
  483. * No hardware is programmed for call. Only validation is done.
  484. */
  485. bool dc_validate_guaranteed(
  486. const struct dc *dc,
  487. const struct dc_stream *stream);
  488. void dc_resource_validate_ctx_copy_construct(
  489. const struct validate_context *src_ctx,
  490. struct validate_context *dst_ctx);
  491. void dc_resource_validate_ctx_destruct(struct validate_context *context);
  492. /*
  493. * Set up streams and links associated to drive sinks
  494. * The streams parameter is an absolute set of all active streams.
  495. *
  496. * After this call:
  497. * Phy, Encoder, Timing Generator are programmed and enabled.
  498. * New streams are enabled with blank stream; no memory read.
  499. */
  500. bool dc_commit_streams(
  501. struct dc *dc,
  502. const struct dc_stream *streams[],
  503. uint8_t stream_count);
  504. /*
  505. * Enable stereo when commit_streams is not required,
  506. * for example, frame alternate.
  507. */
  508. bool dc_enable_stereo(
  509. struct dc *dc,
  510. struct validate_context *context,
  511. const struct dc_stream *streams[],
  512. uint8_t stream_count);
  513. /**
  514. * Create a new default stream for the requested sink
  515. */
  516. struct dc_stream *dc_create_stream_for_sink(const struct dc_sink *dc_sink);
  517. void dc_stream_retain(const struct dc_stream *dc_stream);
  518. void dc_stream_release(const struct dc_stream *dc_stream);
  519. struct dc_stream_status {
  520. int primary_otg_inst;
  521. int surface_count;
  522. const struct dc_surface *surfaces[MAX_SURFACE_NUM];
  523. /*
  524. * link this stream passes through
  525. */
  526. const struct dc_link *link;
  527. };
  528. const struct dc_stream_status *dc_stream_get_status(
  529. const struct dc_stream *dc_stream);
  530. enum surface_update_type dc_check_update_surfaces_for_stream(
  531. struct dc *dc,
  532. struct dc_surface_update *updates,
  533. int surface_count,
  534. struct dc_stream_update *stream_update,
  535. const struct dc_stream_status *stream_status);
  536. /*******************************************************************************
  537. * Link Interfaces
  538. ******************************************************************************/
  539. /*
  540. * A link contains one or more sinks and their connected status.
  541. * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
  542. */
  543. struct dc_link {
  544. const struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
  545. unsigned int sink_count;
  546. const struct dc_sink *local_sink;
  547. unsigned int link_index;
  548. enum dc_connection_type type;
  549. enum signal_type connector_signal;
  550. enum dc_irq_source irq_source_hpd;
  551. enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
  552. /* caps is the same as reported_link_cap. link_traing use
  553. * reported_link_cap. Will clean up. TODO
  554. */
  555. struct dc_link_settings reported_link_cap;
  556. struct dc_link_settings verified_link_cap;
  557. struct dc_link_settings max_link_setting;
  558. struct dc_link_settings cur_link_settings;
  559. struct dc_lane_settings cur_lane_setting;
  560. uint8_t ddc_hw_inst;
  561. uint8_t hpd_src;
  562. uint8_t link_enc_hw_inst;
  563. bool test_pattern_enabled;
  564. union compliance_test_state compliance_test_state;
  565. void *priv;
  566. struct ddc_service *ddc;
  567. bool aux_mode;
  568. };
  569. struct dpcd_caps {
  570. union dpcd_rev dpcd_rev;
  571. union max_lane_count max_ln_count;
  572. union max_down_spread max_down_spread;
  573. /* dongle type (DP converter, CV smart dongle) */
  574. enum display_dongle_type dongle_type;
  575. /* Dongle's downstream count. */
  576. union sink_count sink_count;
  577. /* If dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER,
  578. indicates 'Frame Sequential-to-lllFrame Pack' conversion capability.*/
  579. struct dc_dongle_caps dongle_caps;
  580. uint32_t sink_dev_id;
  581. uint32_t branch_dev_id;
  582. int8_t branch_dev_name[6];
  583. int8_t branch_hw_revision;
  584. bool allow_invalid_MSA_timing_param;
  585. bool panel_mode_edp;
  586. };
  587. struct dc_link_status {
  588. struct dpcd_caps *dpcd_caps;
  589. };
  590. const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
  591. /*
  592. * Return an enumerated dc_link. dc_link order is constant and determined at
  593. * boot time. They cannot be created or destroyed.
  594. * Use dc_get_caps() to get number of links.
  595. */
  596. const struct dc_link *dc_get_link_at_index(const struct dc *dc, uint32_t link_index);
  597. /* Return id of physical connector represented by a dc_link at link_index.*/
  598. const struct graphics_object_id dc_get_link_id_at_index(
  599. struct dc *dc, uint32_t link_index);
  600. /* Set backlight level of an embedded panel (eDP, LVDS). */
  601. bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
  602. uint32_t frame_ramp, const struct dc_stream *stream);
  603. bool dc_link_set_abm_disable(const struct dc_link *dc_link);
  604. bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable);
  605. bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state);
  606. bool dc_link_setup_psr(const struct dc_link *dc_link,
  607. const struct dc_stream *stream, struct psr_config *psr_config,
  608. struct psr_context *psr_context);
  609. /* Request DC to detect if there is a Panel connected.
  610. * boot - If this call is during initial boot.
  611. * Return false for any type of detection failure or MST detection
  612. * true otherwise. True meaning further action is required (status update
  613. * and OS notification).
  614. */
  615. bool dc_link_detect(const struct dc_link *dc_link, bool boot);
  616. /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
  617. * Return:
  618. * true - Downstream port status changed. DM should call DC to do the
  619. * detection.
  620. * false - no change in Downstream port status. No further action required
  621. * from DM. */
  622. bool dc_link_handle_hpd_rx_irq(const struct dc_link *dc_link);
  623. struct dc_sink_init_data;
  624. struct dc_sink *dc_link_add_remote_sink(
  625. const struct dc_link *dc_link,
  626. const uint8_t *edid,
  627. int len,
  628. struct dc_sink_init_data *init_data);
  629. void dc_link_remove_remote_sink(
  630. const struct dc_link *link,
  631. const struct dc_sink *sink);
  632. /* Used by diagnostics for virtual link at the moment */
  633. void dc_link_set_sink(const struct dc_link *link, struct dc_sink *sink);
  634. void dc_link_dp_set_drive_settings(
  635. const struct dc_link *link,
  636. struct link_training_settings *lt_settings);
  637. bool dc_link_dp_perform_link_training(
  638. struct dc_link *link,
  639. const struct dc_link_settings *link_setting,
  640. bool skip_video_pattern);
  641. void dc_link_dp_enable_hpd(const struct dc_link *link);
  642. void dc_link_dp_disable_hpd(const struct dc_link *link);
  643. bool dc_link_dp_set_test_pattern(
  644. const struct dc_link *link,
  645. enum dp_test_pattern test_pattern,
  646. const struct link_training_settings *p_link_settings,
  647. const unsigned char *p_custom_pattern,
  648. unsigned int cust_pattern_size);
  649. /*******************************************************************************
  650. * Sink Interfaces - A sink corresponds to a display output device
  651. ******************************************************************************/
  652. struct dc_container_id {
  653. // 128bit GUID in binary form
  654. unsigned char guid[16];
  655. // 8 byte port ID -> ELD.PortID
  656. unsigned int portId[2];
  657. // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
  658. unsigned short manufacturerName;
  659. // 2 byte product code -> ELD.ProductCode
  660. unsigned short productCode;
  661. };
  662. /*
  663. * The sink structure contains EDID and other display device properties
  664. */
  665. struct dc_sink {
  666. enum signal_type sink_signal;
  667. struct dc_edid dc_edid; /* raw edid */
  668. struct dc_edid_caps edid_caps; /* parse display caps */
  669. struct dc_container_id *dc_container_id;
  670. uint32_t dongle_max_pix_clk;
  671. void *priv;
  672. struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
  673. bool converter_disable_audio;
  674. };
  675. void dc_sink_retain(const struct dc_sink *sink);
  676. void dc_sink_release(const struct dc_sink *sink);
  677. const struct audio **dc_get_audios(struct dc *dc);
  678. struct dc_sink_init_data {
  679. enum signal_type sink_signal;
  680. const struct dc_link *link;
  681. uint32_t dongle_max_pix_clk;
  682. bool converter_disable_audio;
  683. };
  684. struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
  685. bool dc_sink_get_container_id(struct dc_sink *dc_sink, struct dc_container_id *container_id);
  686. bool dc_sink_set_container_id(struct dc_sink *dc_sink, const struct dc_container_id *container_id);
  687. /*******************************************************************************
  688. * Cursor interfaces - To manages the cursor within a stream
  689. ******************************************************************************/
  690. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  691. bool dc_stream_set_cursor_attributes(
  692. const struct dc_stream *stream,
  693. const struct dc_cursor_attributes *attributes);
  694. bool dc_stream_set_cursor_position(
  695. const struct dc_stream *stream,
  696. const struct dc_cursor_position *position);
  697. /* Newer interfaces */
  698. struct dc_cursor {
  699. struct dc_plane_address address;
  700. struct dc_cursor_attributes attributes;
  701. };
  702. /*******************************************************************************
  703. * Interrupt interfaces
  704. ******************************************************************************/
  705. enum dc_irq_source dc_interrupt_to_irq_source(
  706. struct dc *dc,
  707. uint32_t src_id,
  708. uint32_t ext_id);
  709. void dc_interrupt_set(const struct dc *dc, enum dc_irq_source src, bool enable);
  710. void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
  711. enum dc_irq_source dc_get_hpd_irq_source_at_index(
  712. struct dc *dc, uint32_t link_index);
  713. /*******************************************************************************
  714. * Power Interfaces
  715. ******************************************************************************/
  716. void dc_set_power_state(
  717. struct dc *dc,
  718. enum dc_acpi_cm_power_state power_state);
  719. void dc_resume(const struct dc *dc);
  720. /*
  721. * DPCD access interfaces
  722. */
  723. bool dc_read_aux_dpcd(
  724. struct dc *dc,
  725. uint32_t link_index,
  726. uint32_t address,
  727. uint8_t *data,
  728. uint32_t size);
  729. bool dc_write_aux_dpcd(
  730. struct dc *dc,
  731. uint32_t link_index,
  732. uint32_t address,
  733. const uint8_t *data,
  734. uint32_t size);
  735. bool dc_read_aux_i2c(
  736. struct dc *dc,
  737. uint32_t link_index,
  738. enum i2c_mot_mode mot,
  739. uint32_t address,
  740. uint8_t *data,
  741. uint32_t size);
  742. bool dc_write_aux_i2c(
  743. struct dc *dc,
  744. uint32_t link_index,
  745. enum i2c_mot_mode mot,
  746. uint32_t address,
  747. const uint8_t *data,
  748. uint32_t size);
  749. bool dc_query_ddc_data(
  750. struct dc *dc,
  751. uint32_t link_index,
  752. uint32_t address,
  753. uint8_t *write_buf,
  754. uint32_t write_size,
  755. uint8_t *read_buf,
  756. uint32_t read_size);
  757. bool dc_submit_i2c(
  758. struct dc *dc,
  759. uint32_t link_index,
  760. struct i2c_command *cmd);
  761. #endif /* DC_INTERFACE_H_ */