14562236bSHarry Wentland /* 24562236bSHarry Wentland * Copyright 2012-15 Advanced Micro Devices, Inc. 34562236bSHarry Wentland * 44562236bSHarry Wentland * Permission is hereby granted, free of charge, to any person obtaining a 54562236bSHarry Wentland * copy of this software and associated documentation files (the "Software"), 64562236bSHarry Wentland * to deal in the Software without restriction, including without limitation 74562236bSHarry Wentland * the rights to use, copy, modify, merge, publish, distribute, sublicense, 84562236bSHarry Wentland * and/or sell copies of the Software, and to permit persons to whom the 94562236bSHarry Wentland * Software is furnished to do so, subject to the following conditions: 104562236bSHarry Wentland * 114562236bSHarry Wentland * The above copyright notice and this permission notice shall be included in 124562236bSHarry Wentland * all copies or substantial portions of the Software. 134562236bSHarry Wentland * 144562236bSHarry Wentland * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 154562236bSHarry Wentland * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 164562236bSHarry Wentland * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 174562236bSHarry Wentland * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 184562236bSHarry Wentland * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 194562236bSHarry Wentland * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 204562236bSHarry Wentland * OTHER DEALINGS IN THE SOFTWARE. 214562236bSHarry Wentland * 224562236bSHarry Wentland * Authors: AMD 234562236bSHarry Wentland * 244562236bSHarry Wentland */ 254562236bSHarry Wentland 264562236bSHarry Wentland /** 274562236bSHarry Wentland * This file defines helper functions provided by the Display Manager to 284562236bSHarry Wentland * Display Core. 294562236bSHarry Wentland */ 304562236bSHarry Wentland #ifndef __DM_HELPERS__ 314562236bSHarry Wentland #define __DM_HELPERS__ 324562236bSHarry Wentland 334562236bSHarry Wentland #include "dc_types.h" 344562236bSHarry Wentland #include "dc.h" 354562236bSHarry Wentland 368c5e9bbbSLyude Paul struct dc_dp_mst_stream_allocation_table; 3781927e28SJude Shih struct aux_payload; 3881927e28SJude Shih enum aux_return_code_type; 394562236bSHarry Wentland 4079037324SBhawanpreet Lakha /* 4179037324SBhawanpreet Lakha * Allocate memory accessible by the GPU 4279037324SBhawanpreet Lakha * 4379037324SBhawanpreet Lakha * frame buffer allocations must be aligned to a 4096-byte boundary 4479037324SBhawanpreet Lakha * 4579037324SBhawanpreet Lakha * Returns virtual address, sets addr to physical address 4679037324SBhawanpreet Lakha */ 4779037324SBhawanpreet Lakha void *dm_helpers_allocate_gpu_mem( 4879037324SBhawanpreet Lakha struct dc_context *ctx, 4979037324SBhawanpreet Lakha enum dc_gpu_mem_alloc_type type, 5079037324SBhawanpreet Lakha size_t size, 5179037324SBhawanpreet Lakha long long *addr); 5279037324SBhawanpreet Lakha 5379037324SBhawanpreet Lakha /* 5479037324SBhawanpreet Lakha * Free the GPU-accessible memory at the virtual address pvMem 5579037324SBhawanpreet Lakha */ 5679037324SBhawanpreet Lakha void dm_helpers_free_gpu_mem( 5779037324SBhawanpreet Lakha struct dc_context *ctx, 5879037324SBhawanpreet Lakha enum dc_gpu_mem_alloc_type type, 5979037324SBhawanpreet Lakha void *pvMem); 6079037324SBhawanpreet Lakha 614562236bSHarry Wentland enum dc_edid_status dm_helpers_parse_edid_caps( 623c021931SClaudio Suarez struct dc_link *link, 634562236bSHarry Wentland const struct dc_edid *edid, 644562236bSHarry Wentland struct dc_edid_caps *edid_caps); 654562236bSHarry Wentland 662068afe6SNikola Cornij 672068afe6SNikola Cornij /* 682068afe6SNikola Cornij * Update DP branch info 692068afe6SNikola Cornij */ 702068afe6SNikola Cornij void dm_helpers_dp_update_branch_info( 712068afe6SNikola Cornij struct dc_context *ctx, 722068afe6SNikola Cornij const struct dc_link *link); 732068afe6SNikola Cornij 744562236bSHarry Wentland /* 754562236bSHarry Wentland * Writes payload allocation table in immediate downstream device. 764562236bSHarry Wentland */ 774562236bSHarry Wentland bool dm_helpers_dp_mst_write_payload_allocation_table( 784562236bSHarry Wentland struct dc_context *ctx, 790971c40eSHarry Wentland const struct dc_stream_state *stream, 808c5e9bbbSLyude Paul struct dc_dp_mst_stream_allocation_table *proposed_table, 814562236bSHarry Wentland bool enable); 824562236bSHarry Wentland 834562236bSHarry Wentland /* 849cc032b2SMartin Tsai * poll pending down reply 8522051b63SMartin Tsai */ 8622051b63SMartin Tsai void dm_helpers_dp_mst_poll_pending_down_reply( 8722051b63SMartin Tsai struct dc_context *ctx, 8822051b63SMartin Tsai const struct dc_link *link); 8922051b63SMartin Tsai 9022051b63SMartin Tsai /* 91fd92ac1bSHersen Wu * Clear payload allocation table before enable MST DP link. 92fd92ac1bSHersen Wu */ 93fd92ac1bSHersen Wu void dm_helpers_dp_mst_clear_payload_allocation_table( 94fd92ac1bSHersen Wu struct dc_context *ctx, 95fd92ac1bSHersen Wu const struct dc_link *link); 96fd92ac1bSHersen Wu 97fd92ac1bSHersen Wu /* 984562236bSHarry Wentland * Polls for ACT (allocation change trigger) handled and 994562236bSHarry Wentland */ 10048af9b91SAlvin Lee enum act_return_status dm_helpers_dp_mst_poll_for_allocation_change_trigger( 1014562236bSHarry Wentland struct dc_context *ctx, 1020971c40eSHarry Wentland const struct dc_stream_state *stream); 1034562236bSHarry Wentland /* 1044562236bSHarry Wentland * Sends ALLOCATE_PAYLOAD message. 1054562236bSHarry Wentland */ 1064562236bSHarry Wentland bool dm_helpers_dp_mst_send_payload_allocation( 1074562236bSHarry Wentland struct dc_context *ctx, 1080971c40eSHarry Wentland const struct dc_stream_state *stream, 1094562236bSHarry Wentland bool enable); 1104562236bSHarry Wentland 1114562236bSHarry Wentland bool dm_helpers_dp_mst_start_top_mgr( 1124562236bSHarry Wentland struct dc_context *ctx, 1134562236bSHarry Wentland const struct dc_link *link, 1144562236bSHarry Wentland bool boot); 1154562236bSHarry Wentland 11687e298d6SIan Chen bool dm_helpers_dp_mst_stop_top_mgr( 1174562236bSHarry Wentland struct dc_context *ctx, 1183f16ae82SAurabindo Pillai struct dc_link *link); 119ea192af5SMichael Strauss 120ea192af5SMichael Strauss void dm_helpers_dp_mst_update_branch_bandwidth( 121ea192af5SMichael Strauss struct dc_context *ctx, 122ea192af5SMichael Strauss struct dc_link *link); 123ea192af5SMichael Strauss 1244562236bSHarry Wentland /** 1254562236bSHarry Wentland * OS specific aux read callback. 1264562236bSHarry Wentland */ 1274562236bSHarry Wentland bool dm_helpers_dp_read_dpcd( 1284562236bSHarry Wentland struct dc_context *ctx, 1294562236bSHarry Wentland const struct dc_link *link, 1304562236bSHarry Wentland uint32_t address, 1314562236bSHarry Wentland uint8_t *data, 1324562236bSHarry Wentland uint32_t size); 1334562236bSHarry Wentland 1344562236bSHarry Wentland /** 1354562236bSHarry Wentland * OS specific aux write callback. 1364562236bSHarry Wentland */ 1374562236bSHarry Wentland bool dm_helpers_dp_write_dpcd( 1384562236bSHarry Wentland struct dc_context *ctx, 1394562236bSHarry Wentland const struct dc_link *link, 1404562236bSHarry Wentland uint32_t address, 1414562236bSHarry Wentland const uint8_t *data, 1424562236bSHarry Wentland uint32_t size); 1434562236bSHarry Wentland 1444562236bSHarry Wentland bool dm_helpers_submit_i2c( 1454562236bSHarry Wentland struct dc_context *ctx, 1464562236bSHarry Wentland const struct dc_link *link, 1474562236bSHarry Wentland struct i2c_command *cmd); 1484562236bSHarry Wentland 14997bda032SHarry Wentland bool dm_helpers_dp_write_dsc_enable( 15097bda032SHarry Wentland struct dc_context *ctx, 15197bda032SHarry Wentland const struct dc_stream_state *stream, 15297bda032SHarry Wentland bool enable 15397bda032SHarry Wentland ); 154aac5db82SHarry Wentland bool dm_helpers_is_dp_sink_present( 155aac5db82SHarry Wentland struct dc_link *link); 156aac5db82SHarry Wentland 1576016cd9dSBing Guo void dm_helpers_mst_enable_stream_features(const struct dc_stream_state *stream); 1586016cd9dSBing Guo 1597c7f5b15SAndrey Grodzovsky enum dc_edid_status dm_helpers_read_local_edid( 1607c7f5b15SAndrey Grodzovsky struct dc_context *ctx, 1617c7f5b15SAndrey Grodzovsky struct dc_link *link, 1627c7f5b15SAndrey Grodzovsky struct dc_sink *sink); 1637c7f5b15SAndrey Grodzovsky 164028c4ccfSQingqing Zhuo bool dm_helpers_dp_handle_test_pattern_request( 165028c4ccfSQingqing Zhuo struct dc_context *ctx, 166028c4ccfSQingqing Zhuo const struct dc_link *link, 167028c4ccfSQingqing Zhuo union link_test_pattern dpcd_test_pattern, 168028c4ccfSQingqing Zhuo union test_misc dpcd_test_params); 169028c4ccfSQingqing Zhuo 17015cf3974SDmytro Laktyushkin void dm_set_dcn_clocks( 17115cf3974SDmytro Laktyushkin struct dc_context *ctx, 17215cf3974SDmytro Laktyushkin struct dc_clocks *clks); 1737c7f5b15SAndrey Grodzovsky 174ac02dc34SEric Yang void dm_helpers_enable_periodic_detection(struct dc_context *ctx, bool enable); 175ac02dc34SEric Yang 176f01ee019SFangzhi Zuo void dm_set_phyd32clk(struct dc_context *ctx, int freq_khz); 177f01ee019SFangzhi Zuo 17881927e28SJude Shih bool dm_helpers_dmub_outbox_interrupt_control(struct dc_context *ctx, bool enable); 17970732504SYongqiang Sun 180118a3315SNicholas Kazlauskas void dm_helpers_smu_timeout(struct dc_context *ctx, unsigned int msg_id, unsigned int param, unsigned int timeout_us); 181118a3315SNicholas Kazlauskas 182c1a20f70SIan Chen // 0x1 = Result_OK, 0xFE = Result_UnkmownCmd, 0x0 = Status_Busy 183118a3315SNicholas Kazlauskas #define IS_SMU_TIMEOUT(result) \ 184c1a20f70SIan Chen (result == 0x0) 185c17a34e0SIan Chen void dm_helpers_init_panel_settings( 186c17a34e0SIan Chen struct dc_context *ctx, 187eccff6cdSIan Chen struct dc_panel_config *config, 188eccff6cdSIan Chen struct dc_sink *sink); 189c17a34e0SIan Chen void dm_helpers_override_panel_settings( 190c17a34e0SIan Chen struct dc_context *ctx, 191c17a34e0SIan Chen struct dc_panel_config *config); 19281927e28SJude Shih int dm_helper_dmub_aux_transfer_sync( 19381927e28SJude Shih struct dc_context *ctx, 19481927e28SJude Shih const struct dc_link *link, 19581927e28SJude Shih struct aux_payload *payload, 19681927e28SJude Shih enum aux_return_code_type *operation_result); 19771af9d46SMeenakshikumar Somasundaram enum set_config_status; 19871af9d46SMeenakshikumar Somasundaram int dm_helpers_dmub_set_config_sync(struct dc_context *ctx, 19971af9d46SMeenakshikumar Somasundaram const struct dc_link *link, 20071af9d46SMeenakshikumar Somasundaram struct set_config_cmd_payload *payload, 20171af9d46SMeenakshikumar Somasundaram enum set_config_status *operation_result); 202*5b49da02SSung Joon Kim enum adaptive_sync_type dm_get_adaptive_sync_support_type(struct dc_link *link); 203575d0df6Sjinzh 204575d0df6Sjinzh enum dc_edid_status dm_helpers_get_sbios_edid(struct dc_link *link, struct dc_edid *edid); 205575d0df6Sjinzh 2064562236bSHarry Wentland #endif /* __DM_HELPERS__ */ 207