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" 34f3e43418SHarry Wentland #if defined(CONFIG_DRM_AMD_DC_DCN1_0) 35ff5ef992SAlex Deucher #include "mem_input.h" 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 5290e508baSAnthony Koo #define DC_TRANSFER_FUNC_TO_CORE(dc_transfer_func) \ 5390e508baSAnthony Koo container_of(dc_transfer_func, struct core_transfer_func, public) 5490e508baSAnthony Koo 554562236bSHarry Wentland struct core_surface { 564562236bSHarry Wentland struct dc_surface public; 574562236bSHarry Wentland struct dc_surface_status status; 584562236bSHarry Wentland struct dc_context *ctx; 594562236bSHarry Wentland }; 604562236bSHarry Wentland 614562236bSHarry Wentland struct core_gamma { 624562236bSHarry Wentland struct dc_gamma public; 634562236bSHarry Wentland struct dc_context *ctx; 644562236bSHarry Wentland }; 654562236bSHarry Wentland 66fb735a9fSAnthony Koo struct core_transfer_func { 67fb735a9fSAnthony Koo struct dc_transfer_func public; 68fb735a9fSAnthony Koo struct dc_context *ctx; 69fb735a9fSAnthony Koo }; 70fb735a9fSAnthony Koo 714562236bSHarry Wentland void enable_surface_flip_reporting(struct dc_surface *dc_surface, 724562236bSHarry Wentland uint32_t controller_id); 734562236bSHarry Wentland 744562236bSHarry Wentland /********* core_stream ************/ 754562236bSHarry Wentland #include "grph_object_id.h" 764562236bSHarry Wentland #include "link_encoder.h" 774562236bSHarry Wentland #include "stream_encoder.h" 784562236bSHarry Wentland #include "clock_source.h" 794562236bSHarry Wentland #include "audio.h" 804562236bSHarry Wentland #include "hw_sequencer_types.h" 814562236bSHarry Wentland #include "opp.h" 824562236bSHarry Wentland 834562236bSHarry Wentland #define DC_STREAM_TO_CORE(dc_stream) container_of( \ 844562236bSHarry Wentland dc_stream, struct core_stream, public) 854562236bSHarry Wentland 864562236bSHarry Wentland struct core_stream { 874562236bSHarry Wentland struct dc_stream public; 884562236bSHarry Wentland 894562236bSHarry Wentland /* field internal to DC */ 904562236bSHarry Wentland struct dc_context *ctx; 914562236bSHarry Wentland const struct core_sink *sink; 924562236bSHarry Wentland 934562236bSHarry Wentland /* used by DCP and FMT */ 944562236bSHarry Wentland struct bit_depth_reduction_params bit_depth_params; 954562236bSHarry Wentland struct clamping_and_pixel_encoding_params clamping; 964562236bSHarry Wentland 974562236bSHarry Wentland int phy_pix_clk; 984562236bSHarry Wentland enum signal_type signal; 994562236bSHarry Wentland 1004562236bSHarry Wentland struct dc_stream_status status; 1014562236bSHarry Wentland }; 1024562236bSHarry Wentland 1034562236bSHarry Wentland /************ core_sink *****************/ 1044562236bSHarry Wentland 1054562236bSHarry Wentland #define DC_SINK_TO_CORE(dc_sink) \ 1064562236bSHarry Wentland container_of(dc_sink, struct core_sink, public) 1074562236bSHarry Wentland 1084562236bSHarry Wentland struct core_sink { 1094562236bSHarry Wentland /** The public, read-only (for DM) area of sink. **/ 1104562236bSHarry Wentland struct dc_sink public; 1114562236bSHarry Wentland /** End-of-public area. **/ 1124562236bSHarry Wentland 1134562236bSHarry Wentland /** The 'protected' area - read/write access, for use only inside DC **/ 1144562236bSHarry Wentland /* not used for now */ 1154562236bSHarry Wentland struct core_link *link; 1164562236bSHarry Wentland struct dc_context *ctx; 1174562236bSHarry Wentland }; 1184562236bSHarry Wentland 1194562236bSHarry Wentland /************ link *****************/ 1204562236bSHarry Wentland #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public) 1214562236bSHarry Wentland 1224562236bSHarry Wentland struct link_init_data { 1234562236bSHarry Wentland const struct core_dc *dc; 1244562236bSHarry Wentland struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */ 1254562236bSHarry Wentland uint32_t connector_index; /* this will be mapped to the HPD pins */ 1264562236bSHarry Wentland uint32_t link_index; /* this is mapped to DAL display_index 1274562236bSHarry Wentland TODO: remove it when DC is complete. */ 1284562236bSHarry Wentland }; 1294562236bSHarry Wentland 1304562236bSHarry Wentland /* DP MST stream allocation (payload bandwidth number) */ 1314562236bSHarry Wentland struct link_mst_stream_allocation { 1324562236bSHarry Wentland /* DIG front */ 1334562236bSHarry Wentland const struct stream_encoder *stream_enc; 1344562236bSHarry Wentland /* associate DRM payload table with DC stream encoder */ 1354562236bSHarry Wentland uint8_t vcp_id; 1364562236bSHarry Wentland /* number of slots required for the DP stream in transport packet */ 1374562236bSHarry Wentland uint8_t slot_count; 1384562236bSHarry Wentland }; 1394562236bSHarry Wentland 1404562236bSHarry Wentland /* DP MST stream allocation table */ 1414562236bSHarry Wentland struct link_mst_stream_allocation_table { 1424562236bSHarry Wentland /* number of DP video streams */ 1434562236bSHarry Wentland int stream_count; 1444562236bSHarry Wentland /* array of stream allocations */ 1454562236bSHarry Wentland struct link_mst_stream_allocation 1464562236bSHarry Wentland stream_allocations[MAX_CONTROLLER_NUM]; 1474562236bSHarry Wentland }; 1484562236bSHarry Wentland 1494562236bSHarry Wentland struct core_link { 1504562236bSHarry Wentland struct dc_link public; 1514562236bSHarry Wentland const struct core_dc *dc; 1524562236bSHarry Wentland 1534562236bSHarry Wentland struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/ 1544562236bSHarry Wentland 1554562236bSHarry Wentland struct link_encoder *link_enc; 1564562236bSHarry Wentland struct graphics_object_id link_id; 1574562236bSHarry Wentland union ddi_channel_mapping ddi_channel_mapping; 1584562236bSHarry Wentland struct connector_device_tag_info device_tag; 1594562236bSHarry Wentland struct dpcd_caps dpcd_caps; 1604562236bSHarry Wentland unsigned int dpcd_sink_count; 1614562236bSHarry Wentland 1624562236bSHarry Wentland enum edp_revision edp_revision; 16394267b3dSSylvia Tsai bool psr_enabled; 1644562236bSHarry Wentland 1654562236bSHarry Wentland /* MST record stream using this link */ 1664562236bSHarry Wentland struct link_flags { 1674562236bSHarry Wentland bool dp_keep_receiver_powered; 1684562236bSHarry Wentland } wa_flags; 1694562236bSHarry Wentland struct link_mst_stream_allocation_table mst_stream_alloc_table; 1704562236bSHarry Wentland 1714562236bSHarry Wentland struct dc_link_status link_status; 1724562236bSHarry Wentland }; 1734562236bSHarry Wentland 1744562236bSHarry Wentland #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public) 1754562236bSHarry Wentland 1764562236bSHarry Wentland struct core_link *link_create(const struct link_init_data *init_params); 1774562236bSHarry Wentland void link_destroy(struct core_link **link); 1784562236bSHarry Wentland 1794562236bSHarry Wentland enum dc_status dc_link_validate_mode_timing( 1804562236bSHarry Wentland const struct core_stream *stream, 1814562236bSHarry Wentland struct core_link *link, 1824562236bSHarry Wentland const struct dc_crtc_timing *timing); 1834562236bSHarry Wentland 1844562236bSHarry Wentland void core_link_resume(struct core_link *link); 1854562236bSHarry Wentland 1864562236bSHarry Wentland void core_link_enable_stream(struct pipe_ctx *pipe_ctx); 1874562236bSHarry Wentland 1884562236bSHarry Wentland void core_link_disable_stream(struct pipe_ctx *pipe_ctx); 1894562236bSHarry Wentland 1904562236bSHarry Wentland /********** DAL Core*********************/ 191e11b86adSDmytro Laktyushkin #include "display_clock.h" 1924562236bSHarry Wentland #include "transform.h" 1934562236bSHarry Wentland 1944562236bSHarry Wentland struct resource_pool; 1954562236bSHarry Wentland struct validate_context; 1964562236bSHarry Wentland struct resource_context; 1974562236bSHarry Wentland 1984562236bSHarry Wentland struct resource_funcs { 1994562236bSHarry Wentland void (*destroy)(struct resource_pool **pool); 2004562236bSHarry Wentland struct link_encoder *(*link_enc_create)( 2014562236bSHarry Wentland const struct encoder_init_data *init); 2024562236bSHarry Wentland enum dc_status (*validate_with_context)( 2034562236bSHarry Wentland const struct core_dc *dc, 2044562236bSHarry Wentland const struct dc_validation_set set[], 2054562236bSHarry Wentland int set_count, 2064562236bSHarry Wentland struct validate_context *context); 2074562236bSHarry Wentland 2084562236bSHarry Wentland enum dc_status (*validate_guaranteed)( 2094562236bSHarry Wentland const struct core_dc *dc, 210ab2541b6SAric Cyr const struct dc_stream *stream, 2114562236bSHarry Wentland struct validate_context *context); 2124562236bSHarry Wentland 21345209ef7SDmytro Laktyushkin bool (*validate_bandwidth)( 2144562236bSHarry Wentland const struct core_dc *dc, 2154562236bSHarry Wentland struct validate_context *context); 2164562236bSHarry Wentland 2174562236bSHarry Wentland struct pipe_ctx *(*acquire_idle_pipe_for_layer)( 218745cc746SDmytro Laktyushkin struct validate_context *context, 219a2b8659dSTony Cheng const struct resource_pool *pool, 2204562236bSHarry Wentland struct core_stream *stream); 2214562236bSHarry Wentland }; 2224562236bSHarry Wentland 2234562236bSHarry Wentland struct audio_support{ 2244562236bSHarry Wentland bool dp_audio; 2254562236bSHarry Wentland bool hdmi_audio_on_dongle; 2264562236bSHarry Wentland bool hdmi_audio_native; 2274562236bSHarry Wentland }; 2284562236bSHarry Wentland 229f0e3db90SHarry Wentland #define NO_UNDERLAY_PIPE -1 230f0e3db90SHarry Wentland 2314562236bSHarry Wentland struct resource_pool { 2324562236bSHarry Wentland struct mem_input *mis[MAX_PIPES]; 2334562236bSHarry Wentland struct input_pixel_processor *ipps[MAX_PIPES]; 2344562236bSHarry Wentland struct transform *transforms[MAX_PIPES]; 2354562236bSHarry Wentland struct output_pixel_processor *opps[MAX_PIPES]; 2364562236bSHarry Wentland struct timing_generator *timing_generators[MAX_PIPES]; 2374562236bSHarry Wentland struct stream_encoder *stream_enc[MAX_PIPES * 2]; 2384562236bSHarry Wentland 2394562236bSHarry Wentland unsigned int pipe_count; 2404562236bSHarry Wentland unsigned int underlay_pipe_index; 2414562236bSHarry Wentland unsigned int stream_enc_count; 2425ac3d3c9SCharlene Liu unsigned int ref_clock_inKhz; 2434562236bSHarry Wentland 2444562236bSHarry Wentland /* 2454562236bSHarry Wentland * reserved clock source for DP 2464562236bSHarry Wentland */ 2474562236bSHarry Wentland struct clock_source *dp_clock_source; 2484562236bSHarry Wentland 2494562236bSHarry Wentland struct clock_source *clock_sources[MAX_CLOCK_SOURCES]; 2504562236bSHarry Wentland unsigned int clk_src_count; 2514562236bSHarry Wentland 2524562236bSHarry Wentland struct audio *audios[MAX_PIPES]; 2534562236bSHarry Wentland unsigned int audio_count; 2544562236bSHarry Wentland struct audio_support audio_support; 2554562236bSHarry Wentland 2564562236bSHarry Wentland struct display_clock *display_clock; 2574562236bSHarry Wentland struct irq_service *irqs; 2584562236bSHarry Wentland 2595e7773a2SAnthony Koo struct abm *abm; 2605e7773a2SAnthony Koo struct dmcu *dmcu; 261f3e43418SHarry Wentland #if defined(CONFIG_DRM_AMD_DC_DCN1_0) 262ff5ef992SAlex Deucher struct mpc *mpc; 263f3e43418SHarry Wentland #endif 2645e7773a2SAnthony Koo 2654562236bSHarry Wentland const struct resource_funcs *funcs; 2664562236bSHarry Wentland const struct resource_caps *res_cap; 2674562236bSHarry Wentland }; 2684562236bSHarry Wentland 2694562236bSHarry Wentland struct pipe_ctx { 2704562236bSHarry Wentland struct core_surface *surface; 2714562236bSHarry Wentland struct core_stream *stream; 2724562236bSHarry Wentland 2734562236bSHarry Wentland struct mem_input *mi; 2744562236bSHarry Wentland struct input_pixel_processor *ipp; 2754562236bSHarry Wentland struct transform *xfm; 2764562236bSHarry Wentland struct output_pixel_processor *opp; 2774562236bSHarry Wentland struct timing_generator *tg; 2784562236bSHarry Wentland 2794562236bSHarry Wentland struct scaler_data scl_data; 2804562236bSHarry Wentland 2814562236bSHarry Wentland struct stream_encoder *stream_enc; 2824562236bSHarry Wentland struct display_clock *dis_clk; 2834562236bSHarry Wentland struct clock_source *clock_source; 2844562236bSHarry Wentland 2854562236bSHarry Wentland struct audio *audio; 2864562236bSHarry Wentland 2874562236bSHarry Wentland struct pixel_clk_params pix_clk_params; 2884562236bSHarry Wentland struct pll_settings pll_settings; 2894562236bSHarry Wentland 2904562236bSHarry Wentland /*fmt*/ 2914562236bSHarry Wentland struct encoder_info_frame encoder_info_frame; 2924562236bSHarry Wentland 2934562236bSHarry Wentland uint8_t pipe_idx; 2944562236bSHarry Wentland 2954562236bSHarry Wentland struct pipe_ctx *top_pipe; 2964562236bSHarry Wentland struct pipe_ctx *bottom_pipe; 297ff5ef992SAlex Deucher #ifdef CONFIG_DRM_AMD_DC_DCN1_0 298ff5ef992SAlex Deucher uint8_t mpc_idx; 299ff5ef992SAlex Deucher struct _vcs_dpi_display_dlg_regs_st dlg_regs; 300ff5ef992SAlex Deucher struct _vcs_dpi_display_ttu_regs_st ttu_regs; 301ff5ef992SAlex Deucher struct _vcs_dpi_display_rq_regs_st rq_regs; 302ff5ef992SAlex Deucher struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param; 303ff5ef992SAlex Deucher #endif 3044562236bSHarry Wentland }; 3054562236bSHarry Wentland 3064562236bSHarry Wentland struct resource_context { 3074562236bSHarry Wentland struct pipe_ctx pipe_ctx[MAX_PIPES]; 308ff5ef992SAlex Deucher #ifdef CONFIG_DRM_AMD_DC_DCN1_0 309ff5ef992SAlex Deucher struct mpc_tree_cfg mpc_tree[MAX_PIPES]; 310ff5ef992SAlex Deucher #endif 3114562236bSHarry Wentland bool is_stream_enc_acquired[MAX_PIPES * 2]; 3124562236bSHarry Wentland bool is_audio_acquired[MAX_PIPES]; 3134562236bSHarry Wentland uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES]; 3144562236bSHarry Wentland uint8_t dp_clock_source_ref_count; 3154562236bSHarry Wentland }; 3164562236bSHarry Wentland 3174562236bSHarry Wentland struct validate_context { 318ab2541b6SAric Cyr struct core_stream *streams[MAX_PIPES]; 319ab2541b6SAric Cyr struct dc_stream_status stream_status[MAX_PIPES]; 320ab2541b6SAric Cyr uint8_t stream_count; 3214562236bSHarry Wentland 3224562236bSHarry Wentland struct resource_context res_ctx; 3234562236bSHarry Wentland 3244562236bSHarry Wentland /* The output from BW and WM calculations. */ 3254562236bSHarry Wentland struct bw_calcs_output bw_results; 3265ea81b91SDmytro Laktyushkin /* Note: these are big structures, do *not* put on stack! */ 3274562236bSHarry Wentland struct dm_pp_display_configuration pp_display_cfg; 3280f56b418SDmytro Laktyushkin int dispclk_khz; 329ff5ef992SAlex Deucher #ifdef CONFIG_DRM_AMD_DC_DCN1_0 330ff5ef992SAlex Deucher int dppclk_khz; 331ff5ef992SAlex Deucher bool dppclk_div; 332ff5ef992SAlex Deucher int dcfclk_khz; 333ff5ef992SAlex Deucher int dcfclk_deep_sleep_khz; 334ff5ef992SAlex Deucher int socclk_khz; 335ff5ef992SAlex Deucher int fclk_khz; 336ff5ef992SAlex Deucher int dram_ccm_us; 337ff5ef992SAlex Deucher int min_active_dram_ccm_us; 338ff5ef992SAlex Deucher struct dcn_watermark_set watermarks; 339ff5ef992SAlex Deucher struct dcn_bw_internal_vars dcn_bw_vars; 340ff5ef992SAlex Deucher #endif 3414562236bSHarry Wentland }; 3424562236bSHarry Wentland 3434562236bSHarry Wentland #endif /* _CORE_TYPES_H_ */ 344