dc_stream.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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_STREAM_H_
  26. #define DC_STREAM_H_
  27. #include "dc_types.h"
  28. #include "grph_object_defs.h"
  29. /*******************************************************************************
  30. * Stream Interfaces
  31. ******************************************************************************/
  32. struct timing_sync_info {
  33. int group_id;
  34. int group_size;
  35. bool master;
  36. };
  37. struct mall_stream_config {
  38. /* MALL stream config to indicate if the stream is phantom or not.
  39. * We will use a phantom stream to indicate that the pipe is phantom.
  40. */
  41. enum mall_stream_type type;
  42. struct dc_stream_state *paired_stream; // master / slave stream
  43. };
  44. struct dc_stream_status {
  45. int primary_otg_inst;
  46. int stream_enc_inst;
  47. /**
  48. * @plane_count: Total of planes attached to a single stream
  49. */
  50. int plane_count;
  51. int audio_inst;
  52. struct timing_sync_info timing_sync_info;
  53. struct dc_plane_state *plane_states[MAX_SURFACES];
  54. bool is_abm_supported;
  55. struct mall_stream_config mall_stream_config;
  56. bool fpo_in_use;
  57. };
  58. enum hubp_dmdata_mode {
  59. DMDATA_SW_MODE,
  60. DMDATA_HW_MODE
  61. };
  62. struct dc_dmdata_attributes {
  63. /* Specifies whether dynamic meta data will be updated by software
  64. * or has to be fetched by hardware (DMA mode)
  65. */
  66. enum hubp_dmdata_mode dmdata_mode;
  67. /* Specifies if current dynamic meta data is to be used only for the current frame */
  68. bool dmdata_repeat;
  69. /* Specifies the size of Dynamic Metadata surface in byte. Size of 0 means no Dynamic metadata is fetched */
  70. uint32_t dmdata_size;
  71. /* Specifies if a new dynamic meta data should be fetched for an upcoming frame */
  72. bool dmdata_updated;
  73. /* If hardware mode is used, the base address where DMDATA surface is located */
  74. PHYSICAL_ADDRESS_LOC address;
  75. /* Specifies whether QOS level will be provided by TTU or it will come from DMDATA_QOS_LEVEL */
  76. bool dmdata_qos_mode;
  77. /* If qos_mode = 1, this is the QOS value to be used: */
  78. uint32_t dmdata_qos_level;
  79. /* Specifies the value in unit of REFCLK cycles to be added to the
  80. * current time to produce the Amortized deadline for Dynamic Metadata chunk request
  81. */
  82. uint32_t dmdata_dl_delta;
  83. /* An unbounded array of uint32s, represents software dmdata to be loaded */
  84. uint32_t *dmdata_sw_data;
  85. };
  86. struct dc_writeback_info {
  87. bool wb_enabled;
  88. int dwb_pipe_inst;
  89. struct dc_dwb_params dwb_params;
  90. struct mcif_buf_params mcif_buf_params;
  91. struct mcif_warmup_params mcif_warmup_params;
  92. /* the plane that is the input to TOP_MUX for MPCC that is the DWB source */
  93. struct dc_plane_state *writeback_source_plane;
  94. /* source MPCC instance. for use by internally by dc */
  95. int mpcc_inst;
  96. };
  97. struct dc_writeback_update {
  98. unsigned int num_wb_info;
  99. struct dc_writeback_info writeback_info[MAX_DWB_PIPES];
  100. };
  101. enum vertical_interrupt_ref_point {
  102. START_V_UPDATE = 0,
  103. START_V_SYNC,
  104. INVALID_POINT
  105. //For now, only v_update interrupt is used.
  106. //START_V_BLANK,
  107. //START_V_ACTIVE
  108. };
  109. struct periodic_interrupt_config {
  110. enum vertical_interrupt_ref_point ref_point;
  111. int lines_offset;
  112. };
  113. struct dc_mst_stream_bw_update {
  114. bool is_increase; // is bandwidth reduced or increased
  115. uint32_t mst_stream_bw; // new mst bandwidth in kbps
  116. };
  117. union stream_update_flags {
  118. struct {
  119. uint32_t scaling:1;
  120. uint32_t out_tf:1;
  121. uint32_t out_csc:1;
  122. uint32_t abm_level:1;
  123. uint32_t dpms_off:1;
  124. uint32_t gamut_remap:1;
  125. uint32_t wb_update:1;
  126. uint32_t dsc_changed : 1;
  127. uint32_t mst_bw : 1;
  128. uint32_t crtc_timing_adjust : 1;
  129. uint32_t fams_changed : 1;
  130. uint32_t scaler_sharpener : 1;
  131. } bits;
  132. uint32_t raw;
  133. };
  134. struct test_pattern {
  135. enum dp_test_pattern type;
  136. enum dp_test_pattern_color_space color_space;
  137. struct link_training_settings const *p_link_settings;
  138. unsigned char const *p_custom_pattern;
  139. unsigned int cust_pattern_size;
  140. };
  141. #define SUBVP_DRR_MARGIN_US 100 // 100us for DRR margin (SubVP + DRR)
  142. struct dc_stream_debug_options {
  143. char force_odm_combine_segments;
  144. /*
  145. * When force_odm_combine_segments is non zero, allow dc to
  146. * temporarily transition to ODM bypass when minimal transition state
  147. * is required to prevent visual glitches showing on the screen
  148. */
  149. char allow_transition_for_forced_odm;
  150. };
  151. #define LUMINANCE_DATA_TABLE_SIZE 10
  152. struct luminance_data {
  153. bool is_valid;
  154. int refresh_rate_hz[LUMINANCE_DATA_TABLE_SIZE];
  155. int luminance_millinits[LUMINANCE_DATA_TABLE_SIZE];
  156. int flicker_criteria_milli_nits_GAMING;
  157. int flicker_criteria_milli_nits_STATIC;
  158. int nominal_refresh_rate;
  159. int dm_max_decrease_from_nominal;
  160. };
  161. struct dc_stream_state {
  162. // sink is deprecated, new code should not reference
  163. // this pointer
  164. struct dc_sink *sink;
  165. struct dc_link *link;
  166. /* For dynamic link encoder assignment, update the link encoder assigned to
  167. * a stream via the volatile dc_state rather than the static dc_link.
  168. */
  169. struct link_encoder *link_enc;
  170. struct dc_stream_debug_options debug;
  171. struct dc_panel_patch sink_patches;
  172. struct dc_crtc_timing timing;
  173. struct dc_crtc_timing_adjust adjust;
  174. struct dc_info_packet vrr_infopacket;
  175. struct dc_info_packet vsc_infopacket;
  176. struct dc_info_packet vsp_infopacket;
  177. struct dc_info_packet hfvsif_infopacket;
  178. struct dc_info_packet vtem_infopacket;
  179. struct dc_info_packet adaptive_sync_infopacket;
  180. uint8_t dsc_packed_pps[128];
  181. struct rect src; /* composition area */
  182. struct rect dst; /* stream addressable area */
  183. struct audio_info audio_info;
  184. struct dc_info_packet hdr_static_metadata;
  185. PHYSICAL_ADDRESS_LOC dmdata_address;
  186. bool use_dynamic_meta;
  187. struct dc_transfer_func out_transfer_func;
  188. struct colorspace_transform gamut_remap_matrix;
  189. struct dc_csc_transform csc_color_matrix;
  190. enum dc_color_space output_color_space;
  191. enum display_content_type content_type;
  192. enum dc_dither_option dither_option;
  193. enum view_3d_format view_format;
  194. bool use_vsc_sdp_for_colorimetry;
  195. bool ignore_msa_timing_param;
  196. /**
  197. * @allow_freesync:
  198. *
  199. * It say if Freesync is enabled or not.
  200. */
  201. bool allow_freesync;
  202. /**
  203. * @vrr_active_variable:
  204. *
  205. * It describes if VRR is in use.
  206. */
  207. bool vrr_active_variable;
  208. bool freesync_on_desktop;
  209. bool vrr_active_fixed;
  210. bool converter_disable_audio;
  211. uint8_t qs_bit;
  212. uint8_t qy_bit;
  213. /* TODO: custom INFO packets */
  214. /* TODO: ABM info (DMCU) */
  215. /* TODO: CEA VIC */
  216. /* DMCU info */
  217. unsigned int abm_level;
  218. struct periodic_interrupt_config periodic_interrupt;
  219. /* from core_stream struct */
  220. struct dc_context *ctx;
  221. /* used by DCP and FMT */
  222. struct bit_depth_reduction_params bit_depth_params;
  223. struct clamping_and_pixel_encoding_params clamping;
  224. int phy_pix_clk;
  225. enum signal_type signal;
  226. bool dpms_off;
  227. void *dm_stream_context;
  228. struct dc_cursor_attributes cursor_attributes;
  229. struct dc_cursor_position cursor_position;
  230. bool hw_cursor_req;
  231. uint32_t sdr_white_level; // for boosting (SDR) cursor in HDR mode
  232. /* from stream struct */
  233. struct kref refcount;
  234. struct crtc_trigger_info triggered_crtc_reset;
  235. /* writeback */
  236. unsigned int num_wb_info;
  237. struct dc_writeback_info writeback_info[MAX_DWB_PIPES];
  238. const struct dc_transfer_func *func_shaper;
  239. const struct dc_3dlut *lut3d_func;
  240. /* Computed state bits */
  241. bool mode_changed : 1;
  242. /* Output from DC when stream state is committed or altered
  243. * DC may only access these values during:
  244. * dc_commit_state, dc_commit_state_no_check, dc_commit_streams
  245. * values may not change outside of those calls
  246. */
  247. struct {
  248. // For interrupt management, some hardware instance
  249. // offsets need to be exposed to DM
  250. uint8_t otg_offset;
  251. } out;
  252. bool apply_edp_fast_boot_optimization;
  253. bool apply_seamless_boot_optimization;
  254. uint32_t apply_boot_odm_mode;
  255. uint32_t stream_id;
  256. struct test_pattern test_pattern;
  257. union stream_update_flags update_flags;
  258. bool has_non_synchronizable_pclk;
  259. bool vblank_synchronized;
  260. bool is_phantom;
  261. struct luminance_data lumin_data;
  262. bool scaler_sharpener_update;
  263. };
  264. #define ABM_LEVEL_IMMEDIATE_DISABLE 255
  265. struct dc_stream_update {
  266. struct dc_stream_state *stream;
  267. struct rect src;
  268. struct rect dst;
  269. struct dc_transfer_func *out_transfer_func;
  270. struct dc_info_packet *hdr_static_metadata;
  271. unsigned int *abm_level;
  272. struct periodic_interrupt_config *periodic_interrupt;
  273. struct dc_info_packet *vrr_infopacket;
  274. struct dc_info_packet *vsc_infopacket;
  275. struct dc_info_packet *vsp_infopacket;
  276. struct dc_info_packet *hfvsif_infopacket;
  277. struct dc_info_packet *vtem_infopacket;
  278. struct dc_info_packet *adaptive_sync_infopacket;
  279. bool *dpms_off;
  280. bool integer_scaling_update;
  281. bool *allow_freesync;
  282. bool *vrr_active_variable;
  283. bool *vrr_active_fixed;
  284. struct colorspace_transform *gamut_remap;
  285. enum dc_color_space *output_color_space;
  286. enum dc_dither_option *dither_option;
  287. struct dc_csc_transform *output_csc_transform;
  288. struct dc_writeback_update *wb_update;
  289. struct dc_dsc_config *dsc_config;
  290. struct dc_mst_stream_bw_update *mst_bw_update;
  291. struct dc_transfer_func *func_shaper;
  292. struct dc_3dlut *lut3d_func;
  293. struct test_pattern *pending_test_pattern;
  294. struct dc_crtc_timing_adjust *crtc_timing_adjust;
  295. struct dc_cursor_attributes *cursor_attributes;
  296. struct dc_cursor_position *cursor_position;
  297. bool *hw_cursor_req;
  298. bool *scaler_sharpener_update;
  299. };
  300. bool dc_is_stream_unchanged(
  301. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  302. bool dc_is_stream_scaling_unchanged(
  303. struct dc_stream_state *old_stream, struct dc_stream_state *stream);
  304. /*
  305. * Setup stream attributes if no stream updates are provided
  306. * there will be no impact on the stream parameters
  307. *
  308. * Set up surface attributes and associate to a stream
  309. * The surfaces parameter is an absolute set of all surface active for the stream.
  310. * If no surfaces are provided, the stream will be blanked; no memory read.
  311. * Any flip related attribute changes must be done through this interface.
  312. *
  313. * After this call:
  314. * Surfaces attributes are programmed and configured to be composed into stream.
  315. * This does not trigger a flip. No surface address is programmed.
  316. *
  317. */
  318. bool dc_update_planes_and_stream(struct dc *dc,
  319. struct dc_surface_update *surface_updates, int surface_count,
  320. struct dc_stream_state *dc_stream,
  321. struct dc_stream_update *stream_update);
  322. /*
  323. * Set up surface attributes and associate to a stream
  324. * The surfaces parameter is an absolute set of all surface active for the stream.
  325. * If no surfaces are provided, the stream will be blanked; no memory read.
  326. * Any flip related attribute changes must be done through this interface.
  327. *
  328. * After this call:
  329. * Surfaces attributes are programmed and configured to be composed into stream.
  330. * This does not trigger a flip. No surface address is programmed.
  331. */
  332. void dc_commit_updates_for_stream(struct dc *dc,
  333. struct dc_surface_update *srf_updates,
  334. int surface_count,
  335. struct dc_stream_state *stream,
  336. struct dc_stream_update *stream_update,
  337. struct dc_state *state);
  338. /*
  339. * Log the current stream state.
  340. */
  341. void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);
  342. uint8_t dc_get_current_stream_count(struct dc *dc);
  343. struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
  344. /*
  345. * Return the current frame counter.
  346. */
  347. uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
  348. /*
  349. * Send dp sdp message.
  350. */
  351. bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,
  352. const uint8_t *custom_sdp_message,
  353. unsigned int sdp_message_size);
  354. /* TODO: Return parsed values rather than direct register read
  355. * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)
  356. * being refactored properly to be dce-specific
  357. */
  358. bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
  359. uint32_t *v_blank_start,
  360. uint32_t *v_blank_end,
  361. uint32_t *h_position,
  362. uint32_t *v_position);
  363. bool dc_stream_add_writeback(struct dc *dc,
  364. struct dc_stream_state *stream,
  365. struct dc_writeback_info *wb_info);
  366. bool dc_stream_fc_disable_writeback(struct dc *dc,
  367. struct dc_stream_state *stream,
  368. uint32_t dwb_pipe_inst);
  369. bool dc_stream_remove_writeback(struct dc *dc,
  370. struct dc_stream_state *stream,
  371. uint32_t dwb_pipe_inst);
  372. enum dc_status dc_stream_add_dsc_to_resource(struct dc *dc,
  373. struct dc_state *state,
  374. struct dc_stream_state *stream);
  375. bool dc_stream_warmup_writeback(struct dc *dc,
  376. int num_dwb,
  377. struct dc_writeback_info *wb_info);
  378. bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream);
  379. bool dc_stream_set_dynamic_metadata(struct dc *dc,
  380. struct dc_stream_state *stream,
  381. struct dc_dmdata_attributes *dmdata_attr);
  382. enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream);
  383. /*
  384. * Enable stereo when commit_streams is not required,
  385. * for example, frame alternate.
  386. */
  387. void dc_enable_stereo(
  388. struct dc *dc,
  389. struct dc_state *context,
  390. struct dc_stream_state *streams[],
  391. uint8_t stream_count);
  392. /* Triggers multi-stream synchronization. */
  393. void dc_trigger_sync(struct dc *dc, struct dc_state *context);
  394. enum surface_update_type dc_check_update_surfaces_for_stream(
  395. struct dc *dc,
  396. struct dc_surface_update *updates,
  397. int surface_count,
  398. struct dc_stream_update *stream_update,
  399. const struct dc_stream_status *stream_status);
  400. /**
  401. * Create a new default stream for the requested sink
  402. */
  403. struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
  404. struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream);
  405. void update_stream_signal(struct dc_stream_state *stream, struct dc_sink *sink);
  406. void dc_stream_retain(struct dc_stream_state *dc_stream);
  407. void dc_stream_release(struct dc_stream_state *dc_stream);
  408. struct dc_stream_status *dc_stream_get_status(
  409. struct dc_stream_state *dc_stream);
  410. /*******************************************************************************
  411. * Cursor interfaces - To manages the cursor within a stream
  412. ******************************************************************************/
  413. /* TODO: Deprecated once we switch to dc_set_cursor_position */
  414. void program_cursor_attributes(
  415. struct dc *dc,
  416. struct dc_stream_state *stream);
  417. void program_cursor_position(
  418. struct dc *dc,
  419. struct dc_stream_state *stream);
  420. bool dc_stream_set_cursor_attributes(
  421. struct dc_stream_state *stream,
  422. const struct dc_cursor_attributes *attributes);
  423. bool dc_stream_program_cursor_attributes(
  424. struct dc_stream_state *stream,
  425. const struct dc_cursor_attributes *attributes);
  426. bool dc_stream_set_cursor_position(
  427. struct dc_stream_state *stream,
  428. const struct dc_cursor_position *position);
  429. bool dc_stream_program_cursor_position(
  430. struct dc_stream_state *stream,
  431. const struct dc_cursor_position *position);
  432. bool dc_stream_adjust_vmin_vmax(struct dc *dc,
  433. struct dc_stream_state *stream,
  434. struct dc_crtc_timing_adjust *adjust);
  435. bool dc_stream_get_last_used_drr_vtotal(struct dc *dc,
  436. struct dc_stream_state *stream,
  437. uint32_t *refresh_rate);
  438. bool dc_stream_get_crtc_position(struct dc *dc,
  439. struct dc_stream_state **stream,
  440. int num_streams,
  441. unsigned int *v_pos,
  442. unsigned int *nom_v_pos);
  443. #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
  444. bool dc_stream_forward_crc_window(struct dc_stream_state *stream,
  445. struct rect *rect,
  446. bool is_stop);
  447. #endif
  448. bool dc_stream_configure_crc(struct dc *dc,
  449. struct dc_stream_state *stream,
  450. struct crc_params *crc_window,
  451. bool enable,
  452. bool continuous);
  453. bool dc_stream_get_crc(struct dc *dc,
  454. struct dc_stream_state *stream,
  455. uint32_t *r_cr,
  456. uint32_t *g_y,
  457. uint32_t *b_cb);
  458. void dc_stream_set_static_screen_params(struct dc *dc,
  459. struct dc_stream_state **stream,
  460. int num_streams,
  461. const struct dc_static_screen_params *params);
  462. void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream,
  463. enum dc_dynamic_expansion option);
  464. void dc_stream_set_dither_option(struct dc_stream_state *stream,
  465. enum dc_dither_option option);
  466. bool dc_stream_set_gamut_remap(struct dc *dc,
  467. const struct dc_stream_state *stream);
  468. bool dc_stream_program_csc_matrix(struct dc *dc,
  469. struct dc_stream_state *stream);
  470. bool dc_stream_get_crtc_position(struct dc *dc,
  471. struct dc_stream_state **stream,
  472. int num_streams,
  473. unsigned int *v_pos,
  474. unsigned int *nom_v_pos);
  475. struct pipe_ctx *dc_stream_get_pipe_ctx(struct dc_stream_state *stream);
  476. void dc_dmub_update_dirty_rect(struct dc *dc,
  477. int surface_count,
  478. struct dc_stream_state *stream,
  479. struct dc_surface_update *srf_updates,
  480. struct dc_state *context);
  481. #endif /* DC_STREAM_H_ */