14562236bSHarry Wentland /* 24562236bSHarry Wentland * Copyright 2015 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 #ifndef _CORE_TYPES_H_ 274562236bSHarry Wentland #define _CORE_TYPES_H_ 284562236bSHarry Wentland 294562236bSHarry Wentland #include "dc.h" 305e141de4SHarry Wentland #include "dce_calcs.h" 31ff5ef992SAlex Deucher #include "dcn_calcs.h" 324562236bSHarry Wentland #include "ddc_service_types.h" 334562236bSHarry Wentland #include "dc_bios_types.h" 34ff5ef992SAlex Deucher #include "mem_input.h" 359037d802SDmytro Laktyushkin #if defined(CONFIG_DRM_AMD_DC_DCN1_0) 36ff5ef992SAlex Deucher #include "mpc.h" 37f3e43418SHarry Wentland #endif 384562236bSHarry Wentland 394562236bSHarry Wentland struct core_stream; 404562236bSHarry Wentland 414562236bSHarry Wentland #define MAX_PIPES 6 424562236bSHarry Wentland #define MAX_CLOCK_SOURCES 7 434562236bSHarry Wentland 444562236bSHarry Wentland 454562236bSHarry Wentland /********* core_surface **********/ 464562236bSHarry Wentland #define DC_SURFACE_TO_CORE(dc_surface) \ 474562236bSHarry Wentland container_of(dc_surface, struct core_surface, public) 484562236bSHarry Wentland 494562236bSHarry Wentland #define DC_GAMMA_TO_CORE(dc_gamma) \ 504562236bSHarry Wentland container_of(dc_gamma, struct core_gamma, public) 514562236bSHarry Wentland 524562236bSHarry Wentland struct core_surface { 534562236bSHarry Wentland struct dc_surface public; 544562236bSHarry Wentland struct dc_surface_status status; 554562236bSHarry Wentland struct dc_context *ctx; 564562236bSHarry Wentland }; 574562236bSHarry Wentland 584562236bSHarry Wentland struct core_gamma { 594562236bSHarry Wentland struct dc_gamma public; 604562236bSHarry Wentland struct dc_context *ctx; 614562236bSHarry Wentland }; 624562236bSHarry Wentland 634562236bSHarry Wentland void enable_surface_flip_reporting(struct dc_surface *dc_surface, 644562236bSHarry Wentland uint32_t controller_id); 654562236bSHarry Wentland 664562236bSHarry Wentland /********* core_stream ************/ 674562236bSHarry Wentland #include "grph_object_id.h" 684562236bSHarry Wentland #include "link_encoder.h" 694562236bSHarry Wentland #include "stream_encoder.h" 704562236bSHarry Wentland #include "clock_source.h" 714562236bSHarry Wentland #include "audio.h" 724562236bSHarry Wentland #include "hw_sequencer_types.h" 734562236bSHarry Wentland #include "opp.h" 744562236bSHarry Wentland 754562236bSHarry Wentland #define DC_STREAM_TO_CORE(dc_stream) container_of( \ 764562236bSHarry Wentland dc_stream, struct core_stream, public) 774562236bSHarry Wentland 784562236bSHarry Wentland struct core_stream { 794562236bSHarry Wentland struct dc_stream public; 804562236bSHarry Wentland 814562236bSHarry Wentland /* field internal to DC */ 824562236bSHarry Wentland struct dc_context *ctx; 834562236bSHarry Wentland const struct core_sink *sink; 844562236bSHarry Wentland 854562236bSHarry Wentland /* used by DCP and FMT */ 864562236bSHarry Wentland struct bit_depth_reduction_params bit_depth_params; 874562236bSHarry Wentland struct clamping_and_pixel_encoding_params clamping; 884562236bSHarry Wentland 894562236bSHarry Wentland int phy_pix_clk; 904562236bSHarry Wentland enum signal_type signal; 914562236bSHarry Wentland 924562236bSHarry Wentland struct dc_stream_status status; 934562236bSHarry Wentland }; 944562236bSHarry Wentland 954562236bSHarry Wentland /************ core_sink *****************/ 964562236bSHarry Wentland 974562236bSHarry Wentland #define DC_SINK_TO_CORE(dc_sink) \ 984562236bSHarry Wentland container_of(dc_sink, struct core_sink, public) 994562236bSHarry Wentland 1004562236bSHarry Wentland struct core_sink { 1014562236bSHarry Wentland /** The public, read-only (for DM) area of sink. **/ 1024562236bSHarry Wentland struct dc_sink public; 1034562236bSHarry Wentland /** End-of-public area. **/ 1044562236bSHarry Wentland 1054562236bSHarry Wentland /** The 'protected' area - read/write access, for use only inside DC **/ 1064562236bSHarry Wentland /* not used for now */ 1074562236bSHarry Wentland struct core_link *link; 1084562236bSHarry Wentland struct dc_context *ctx; 1094562236bSHarry Wentland }; 1104562236bSHarry Wentland 1114562236bSHarry Wentland /************ link *****************/ 1124562236bSHarry Wentland #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public) 1134562236bSHarry Wentland 1144562236bSHarry Wentland struct link_init_data { 1154562236bSHarry Wentland const struct core_dc *dc; 1164562236bSHarry Wentland struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */ 1174562236bSHarry Wentland uint32_t connector_index; /* this will be mapped to the HPD pins */ 1184562236bSHarry Wentland uint32_t link_index; /* this is mapped to DAL display_index 1194562236bSHarry Wentland TODO: remove it when DC is complete. */ 1204562236bSHarry Wentland }; 1214562236bSHarry Wentland 1224562236bSHarry Wentland /* DP MST stream allocation (payload bandwidth number) */ 1234562236bSHarry Wentland struct link_mst_stream_allocation { 1244562236bSHarry Wentland /* DIG front */ 1254562236bSHarry Wentland const struct stream_encoder *stream_enc; 1264562236bSHarry Wentland /* associate DRM payload table with DC stream encoder */ 1274562236bSHarry Wentland uint8_t vcp_id; 1284562236bSHarry Wentland /* number of slots required for the DP stream in transport packet */ 1294562236bSHarry Wentland uint8_t slot_count; 1304562236bSHarry Wentland }; 1314562236bSHarry Wentland 1324562236bSHarry Wentland /* DP MST stream allocation table */ 1334562236bSHarry Wentland struct link_mst_stream_allocation_table { 1344562236bSHarry Wentland /* number of DP video streams */ 1354562236bSHarry Wentland int stream_count; 1364562236bSHarry Wentland /* array of stream allocations */ 1374562236bSHarry Wentland struct link_mst_stream_allocation 1384562236bSHarry Wentland stream_allocations[MAX_CONTROLLER_NUM]; 1394562236bSHarry Wentland }; 1404562236bSHarry Wentland 1414562236bSHarry Wentland struct core_link { 1424562236bSHarry Wentland struct dc_link public; 1434562236bSHarry Wentland const struct core_dc *dc; 1444562236bSHarry Wentland 1454562236bSHarry Wentland struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/ 1464562236bSHarry Wentland 1474562236bSHarry Wentland struct link_encoder *link_enc; 1484562236bSHarry Wentland struct graphics_object_id link_id; 1494562236bSHarry Wentland union ddi_channel_mapping ddi_channel_mapping; 1504562236bSHarry Wentland struct connector_device_tag_info device_tag; 1514562236bSHarry Wentland struct dpcd_caps dpcd_caps; 1524562236bSHarry Wentland unsigned int dpcd_sink_count; 1534562236bSHarry Wentland 1544562236bSHarry Wentland enum edp_revision edp_revision; 15594267b3dSSylvia Tsai bool psr_enabled; 1564562236bSHarry Wentland 1574562236bSHarry Wentland /* MST record stream using this link */ 1584562236bSHarry Wentland struct link_flags { 1594562236bSHarry Wentland bool dp_keep_receiver_powered; 1604562236bSHarry Wentland } wa_flags; 1614562236bSHarry Wentland struct link_mst_stream_allocation_table mst_stream_alloc_table; 1624562236bSHarry Wentland 1634562236bSHarry Wentland struct dc_link_status link_status; 1644562236bSHarry Wentland }; 1654562236bSHarry Wentland 1664562236bSHarry Wentland #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public) 1674562236bSHarry Wentland 1684562236bSHarry Wentland struct core_link *link_create(const struct link_init_data *init_params); 1694562236bSHarry Wentland void link_destroy(struct core_link **link); 1704562236bSHarry Wentland 1714562236bSHarry Wentland enum dc_status dc_link_validate_mode_timing( 1724562236bSHarry Wentland const struct core_stream *stream, 1734562236bSHarry Wentland struct core_link *link, 1744562236bSHarry Wentland const struct dc_crtc_timing *timing); 1754562236bSHarry Wentland 1764562236bSHarry Wentland void core_link_resume(struct core_link *link); 1774562236bSHarry Wentland 1784562236bSHarry Wentland void core_link_enable_stream(struct pipe_ctx *pipe_ctx); 1794562236bSHarry Wentland 1804562236bSHarry Wentland void core_link_disable_stream(struct pipe_ctx *pipe_ctx); 1814562236bSHarry Wentland 18215e17335SCharlene Liu void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable); 1834562236bSHarry Wentland /********** DAL Core*********************/ 184e11b86adSDmytro Laktyushkin #include "display_clock.h" 1854562236bSHarry Wentland #include "transform.h" 1864562236bSHarry Wentland 1874562236bSHarry Wentland struct resource_pool; 1884562236bSHarry Wentland struct validate_context; 1894562236bSHarry Wentland struct resource_context; 1904562236bSHarry Wentland 1914562236bSHarry Wentland struct resource_funcs { 1924562236bSHarry Wentland void (*destroy)(struct resource_pool **pool); 1934562236bSHarry Wentland struct link_encoder *(*link_enc_create)( 1944562236bSHarry Wentland const struct encoder_init_data *init); 1954562236bSHarry Wentland enum dc_status (*validate_with_context)( 1964562236bSHarry Wentland const struct core_dc *dc, 1974562236bSHarry Wentland const struct dc_validation_set set[], 1984562236bSHarry Wentland int set_count, 199430ef426SDmytro Laktyushkin struct validate_context *context, 200430ef426SDmytro Laktyushkin struct validate_context *old_context); 2014562236bSHarry Wentland 2024562236bSHarry Wentland enum dc_status (*validate_guaranteed)( 2034562236bSHarry Wentland const struct core_dc *dc, 204ab2541b6SAric Cyr const struct dc_stream *stream, 2054562236bSHarry Wentland struct validate_context *context); 2064562236bSHarry Wentland 20745209ef7SDmytro Laktyushkin bool (*validate_bandwidth)( 2084562236bSHarry Wentland const struct core_dc *dc, 2094562236bSHarry Wentland struct validate_context *context); 2104562236bSHarry Wentland 2114562236bSHarry Wentland struct pipe_ctx *(*acquire_idle_pipe_for_layer)( 212745cc746SDmytro Laktyushkin struct validate_context *context, 213a2b8659dSTony Cheng const struct resource_pool *pool, 2144562236bSHarry Wentland struct core_stream *stream); 2154562236bSHarry Wentland }; 2164562236bSHarry Wentland 2174562236bSHarry Wentland struct audio_support{ 2184562236bSHarry Wentland bool dp_audio; 2194562236bSHarry Wentland bool hdmi_audio_on_dongle; 2204562236bSHarry Wentland bool hdmi_audio_native; 2214562236bSHarry Wentland }; 2224562236bSHarry Wentland 223f0e3db90SHarry Wentland #define NO_UNDERLAY_PIPE -1 224f0e3db90SHarry Wentland 2254562236bSHarry Wentland struct resource_pool { 2264562236bSHarry Wentland struct mem_input *mis[MAX_PIPES]; 2274562236bSHarry Wentland struct input_pixel_processor *ipps[MAX_PIPES]; 2284562236bSHarry Wentland struct transform *transforms[MAX_PIPES]; 2294562236bSHarry Wentland struct output_pixel_processor *opps[MAX_PIPES]; 2304562236bSHarry Wentland struct timing_generator *timing_generators[MAX_PIPES]; 2314562236bSHarry Wentland struct stream_encoder *stream_enc[MAX_PIPES * 2]; 232f0558542SDmytro Laktyushkin #ifdef CONFIG_DRM_AMD_DC_DCN1_0 233f0558542SDmytro Laktyushkin struct mpcc *mpcc[MAX_PIPES]; 234f0558542SDmytro Laktyushkin #endif 2354562236bSHarry Wentland 2364562236bSHarry Wentland unsigned int pipe_count; 2374562236bSHarry Wentland unsigned int underlay_pipe_index; 2384562236bSHarry Wentland unsigned int stream_enc_count; 2395ac3d3c9SCharlene Liu unsigned int ref_clock_inKhz; 2404562236bSHarry Wentland 2414562236bSHarry Wentland /* 2424562236bSHarry Wentland * reserved clock source for DP 2434562236bSHarry Wentland */ 2444562236bSHarry Wentland struct clock_source *dp_clock_source; 2454562236bSHarry Wentland 2464562236bSHarry Wentland struct clock_source *clock_sources[MAX_CLOCK_SOURCES]; 2474562236bSHarry Wentland unsigned int clk_src_count; 2484562236bSHarry Wentland 2494562236bSHarry Wentland struct audio *audios[MAX_PIPES]; 2504562236bSHarry Wentland unsigned int audio_count; 2514562236bSHarry Wentland struct audio_support audio_support; 2524562236bSHarry Wentland 2534562236bSHarry Wentland struct display_clock *display_clock; 2544562236bSHarry Wentland struct irq_service *irqs; 2554562236bSHarry Wentland 2565e7773a2SAnthony Koo struct abm *abm; 2575e7773a2SAnthony Koo struct dmcu *dmcu; 2585e7773a2SAnthony Koo 2594562236bSHarry Wentland const struct resource_funcs *funcs; 2604562236bSHarry Wentland const struct resource_caps *res_cap; 2614562236bSHarry Wentland }; 2624562236bSHarry Wentland 2634562236bSHarry Wentland struct pipe_ctx { 2644562236bSHarry Wentland struct core_surface *surface; 2654562236bSHarry Wentland struct core_stream *stream; 2664562236bSHarry Wentland 2674562236bSHarry Wentland struct mem_input *mi; 2684562236bSHarry Wentland struct input_pixel_processor *ipp; 2694562236bSHarry Wentland struct transform *xfm; 2704562236bSHarry Wentland struct output_pixel_processor *opp; 2714562236bSHarry Wentland struct timing_generator *tg; 2724562236bSHarry Wentland 2734562236bSHarry Wentland struct scaler_data scl_data; 2744562236bSHarry Wentland 2754562236bSHarry Wentland struct stream_encoder *stream_enc; 2764562236bSHarry Wentland struct display_clock *dis_clk; 2774562236bSHarry Wentland struct clock_source *clock_source; 2784562236bSHarry Wentland 2794562236bSHarry Wentland struct audio *audio; 2804562236bSHarry Wentland 2814562236bSHarry Wentland struct pixel_clk_params pix_clk_params; 2824562236bSHarry Wentland struct pll_settings pll_settings; 2834562236bSHarry Wentland 2844562236bSHarry Wentland /*fmt*/ 2854562236bSHarry Wentland struct encoder_info_frame encoder_info_frame; 2864562236bSHarry Wentland 2874562236bSHarry Wentland uint8_t pipe_idx; 2884562236bSHarry Wentland 2894562236bSHarry Wentland struct pipe_ctx *top_pipe; 2904562236bSHarry Wentland struct pipe_ctx *bottom_pipe; 291f0558542SDmytro Laktyushkin 292ff5ef992SAlex Deucher #ifdef CONFIG_DRM_AMD_DC_DCN1_0 293f0558542SDmytro Laktyushkin struct mpcc *mpcc; 294ff5ef992SAlex Deucher struct _vcs_dpi_display_dlg_regs_st dlg_regs; 295ff5ef992SAlex Deucher struct _vcs_dpi_display_ttu_regs_st ttu_regs; 296ff5ef992SAlex Deucher struct _vcs_dpi_display_rq_regs_st rq_regs; 297ff5ef992SAlex Deucher struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param; 298ff5ef992SAlex Deucher #endif 2994562236bSHarry Wentland }; 3004562236bSHarry Wentland 3014562236bSHarry Wentland struct resource_context { 3024562236bSHarry Wentland struct pipe_ctx pipe_ctx[MAX_PIPES]; 3034562236bSHarry Wentland bool is_stream_enc_acquired[MAX_PIPES * 2]; 3044562236bSHarry Wentland bool is_audio_acquired[MAX_PIPES]; 3054562236bSHarry Wentland uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES]; 3064562236bSHarry Wentland uint8_t dp_clock_source_ref_count; 3074562236bSHarry Wentland }; 3084562236bSHarry Wentland 3099037d802SDmytro Laktyushkin struct dce_bw_output { 3109037d802SDmytro Laktyushkin bool cpuc_state_change_enable; 3119037d802SDmytro Laktyushkin bool cpup_state_change_enable; 3129037d802SDmytro Laktyushkin bool stutter_mode_enable; 3139037d802SDmytro Laktyushkin bool nbp_state_change_enable; 3149037d802SDmytro Laktyushkin bool all_displays_in_sync; 3159037d802SDmytro Laktyushkin struct dce_watermarks urgent_wm_ns[MAX_PIPES]; 3169037d802SDmytro Laktyushkin struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES]; 3179037d802SDmytro Laktyushkin struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES]; 3189037d802SDmytro Laktyushkin int sclk_khz; 3199037d802SDmytro Laktyushkin int sclk_deep_sleep_khz; 3209037d802SDmytro Laktyushkin int yclk_khz; 3219037d802SDmytro Laktyushkin int dispclk_khz; 3229037d802SDmytro Laktyushkin int blackout_recovery_time_us; 3239037d802SDmytro Laktyushkin }; 3249037d802SDmytro Laktyushkin 3259037d802SDmytro Laktyushkin #ifdef CONFIG_DRM_AMD_DC_DCN1_0 3269037d802SDmytro Laktyushkin struct dcn_bw_clocks { 3279037d802SDmytro Laktyushkin int dispclk_khz; 3289037d802SDmytro Laktyushkin bool dppclk_div; 3299037d802SDmytro Laktyushkin int dcfclk_khz; 3309037d802SDmytro Laktyushkin int dcfclk_deep_sleep_khz; 3319037d802SDmytro Laktyushkin int fclk_khz; 3329037d802SDmytro Laktyushkin int dram_ccm_us; 3339037d802SDmytro Laktyushkin int min_active_dram_ccm_us; 3349037d802SDmytro Laktyushkin }; 3359037d802SDmytro Laktyushkin 3369037d802SDmytro Laktyushkin struct dcn_bw_output { 3379037d802SDmytro Laktyushkin struct dcn_bw_clocks cur_clk; 3389037d802SDmytro Laktyushkin struct dcn_bw_clocks calc_clk; 3399037d802SDmytro Laktyushkin struct dcn_watermark_set watermarks; 3409037d802SDmytro Laktyushkin }; 3419037d802SDmytro Laktyushkin #endif 3429037d802SDmytro Laktyushkin 3439037d802SDmytro Laktyushkin union bw_context { 3449037d802SDmytro Laktyushkin #ifdef CONFIG_DRM_AMD_DC_DCN1_0 3459037d802SDmytro Laktyushkin struct dcn_bw_output dcn; 3469037d802SDmytro Laktyushkin #endif 3479037d802SDmytro Laktyushkin struct dce_bw_output dce; 3489037d802SDmytro Laktyushkin }; 3499037d802SDmytro Laktyushkin 3504562236bSHarry Wentland struct validate_context { 351ab2541b6SAric Cyr struct core_stream *streams[MAX_PIPES]; 352ab2541b6SAric Cyr struct dc_stream_status stream_status[MAX_PIPES]; 353ab2541b6SAric Cyr uint8_t stream_count; 3544562236bSHarry Wentland 3554562236bSHarry Wentland struct resource_context res_ctx; 3564562236bSHarry Wentland 3574562236bSHarry Wentland /* The output from BW and WM calculations. */ 3589037d802SDmytro Laktyushkin union bw_context bw; 3599037d802SDmytro Laktyushkin 3605ea81b91SDmytro Laktyushkin /* Note: these are big structures, do *not* put on stack! */ 3614562236bSHarry Wentland struct dm_pp_display_configuration pp_display_cfg; 362ff5ef992SAlex Deucher #ifdef CONFIG_DRM_AMD_DC_DCN1_0 363ff5ef992SAlex Deucher struct dcn_bw_internal_vars dcn_bw_vars; 364ff5ef992SAlex Deucher #endif 3658a76708eSAndrey Grodzovsky 3668a76708eSAndrey Grodzovsky int ref_count; 3674562236bSHarry Wentland }; 3684562236bSHarry Wentland 3694562236bSHarry Wentland #endif /* _CORE_TYPES_H_ */ 370