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" 304562236bSHarry Wentland #include "bandwidth_calcs.h" 314562236bSHarry Wentland #include "ddc_service_types.h" 324562236bSHarry Wentland #include "dc_bios_types.h" 334562236bSHarry Wentland 344562236bSHarry Wentland struct core_stream; 354562236bSHarry Wentland /********* core_target *************/ 364562236bSHarry Wentland 374562236bSHarry Wentland #define CONST_DC_TARGET_TO_CORE(dc_target) \ 384562236bSHarry Wentland container_of(dc_target, const struct core_target, public) 394562236bSHarry Wentland #define DC_TARGET_TO_CORE(dc_target) \ 404562236bSHarry Wentland container_of(dc_target, struct core_target, public) 414562236bSHarry Wentland 424562236bSHarry Wentland #define MAX_PIPES 6 434562236bSHarry Wentland #define MAX_CLOCK_SOURCES 7 444562236bSHarry Wentland 454562236bSHarry Wentland struct core_target { 464562236bSHarry Wentland struct dc_target public; 474562236bSHarry Wentland 484562236bSHarry Wentland struct dc_context *ctx; 494562236bSHarry Wentland }; 504562236bSHarry Wentland 514562236bSHarry Wentland /********* core_surface **********/ 524562236bSHarry Wentland #define DC_SURFACE_TO_CORE(dc_surface) \ 534562236bSHarry Wentland container_of(dc_surface, struct core_surface, public) 544562236bSHarry Wentland 554562236bSHarry Wentland #define DC_GAMMA_TO_CORE(dc_gamma) \ 564562236bSHarry Wentland container_of(dc_gamma, struct core_gamma, public) 574562236bSHarry Wentland 5890e508baSAnthony Koo #define DC_TRANSFER_FUNC_TO_CORE(dc_transfer_func) \ 5990e508baSAnthony Koo container_of(dc_transfer_func, struct core_transfer_func, public) 6090e508baSAnthony Koo 614562236bSHarry Wentland struct core_surface { 624562236bSHarry Wentland struct dc_surface public; 634562236bSHarry Wentland struct dc_surface_status status; 644562236bSHarry Wentland struct dc_context *ctx; 654562236bSHarry Wentland }; 664562236bSHarry Wentland 674562236bSHarry Wentland struct core_gamma { 684562236bSHarry Wentland struct dc_gamma public; 694562236bSHarry Wentland struct dc_context *ctx; 704562236bSHarry Wentland }; 714562236bSHarry Wentland 72fb735a9fSAnthony Koo struct core_transfer_func { 73fb735a9fSAnthony Koo struct dc_transfer_func public; 74fb735a9fSAnthony Koo struct dc_context *ctx; 75fb735a9fSAnthony Koo }; 76fb735a9fSAnthony Koo 774562236bSHarry Wentland void enable_surface_flip_reporting(struct dc_surface *dc_surface, 784562236bSHarry Wentland uint32_t controller_id); 794562236bSHarry Wentland 804562236bSHarry Wentland /********* core_stream ************/ 814562236bSHarry Wentland #include "grph_object_id.h" 824562236bSHarry Wentland #include "link_encoder.h" 834562236bSHarry Wentland #include "stream_encoder.h" 844562236bSHarry Wentland #include "clock_source.h" 854562236bSHarry Wentland #include "audio.h" 864562236bSHarry Wentland #include "hw_sequencer_types.h" 874562236bSHarry Wentland #include "opp.h" 884562236bSHarry Wentland 894562236bSHarry Wentland #define DC_STREAM_TO_CORE(dc_stream) container_of( \ 904562236bSHarry Wentland dc_stream, struct core_stream, public) 914562236bSHarry Wentland 924562236bSHarry Wentland struct core_stream { 934562236bSHarry Wentland struct dc_stream public; 944562236bSHarry Wentland 954562236bSHarry Wentland /* field internal to DC */ 964562236bSHarry Wentland struct dc_context *ctx; 974562236bSHarry Wentland const struct core_sink *sink; 984562236bSHarry Wentland 994562236bSHarry Wentland /* used by DCP and FMT */ 1004562236bSHarry Wentland struct bit_depth_reduction_params bit_depth_params; 1014562236bSHarry Wentland struct clamping_and_pixel_encoding_params clamping; 1024562236bSHarry Wentland 1034562236bSHarry Wentland int phy_pix_clk; 1044562236bSHarry Wentland enum signal_type signal; 1054562236bSHarry Wentland 1064562236bSHarry Wentland struct dc_stream_status status; 1074562236bSHarry Wentland }; 1084562236bSHarry Wentland 1094562236bSHarry Wentland /************ core_sink *****************/ 1104562236bSHarry Wentland 1114562236bSHarry Wentland #define DC_SINK_TO_CORE(dc_sink) \ 1124562236bSHarry Wentland container_of(dc_sink, struct core_sink, public) 1134562236bSHarry Wentland 1144562236bSHarry Wentland struct core_sink { 1154562236bSHarry Wentland /** The public, read-only (for DM) area of sink. **/ 1164562236bSHarry Wentland struct dc_sink public; 1174562236bSHarry Wentland /** End-of-public area. **/ 1184562236bSHarry Wentland 1194562236bSHarry Wentland /** The 'protected' area - read/write access, for use only inside DC **/ 1204562236bSHarry Wentland /* not used for now */ 1214562236bSHarry Wentland struct core_link *link; 1224562236bSHarry Wentland struct dc_context *ctx; 1234562236bSHarry Wentland uint32_t dongle_max_pix_clk; 1244562236bSHarry Wentland bool converter_disable_audio; 1254562236bSHarry Wentland }; 1264562236bSHarry Wentland 1274562236bSHarry Wentland /************ link *****************/ 1284562236bSHarry Wentland #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public) 1294562236bSHarry Wentland 1304562236bSHarry Wentland struct link_init_data { 1314562236bSHarry Wentland const struct core_dc *dc; 1324562236bSHarry Wentland struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */ 1334562236bSHarry Wentland uint32_t connector_index; /* this will be mapped to the HPD pins */ 1344562236bSHarry Wentland uint32_t link_index; /* this is mapped to DAL display_index 1354562236bSHarry Wentland TODO: remove it when DC is complete. */ 1364562236bSHarry Wentland }; 1374562236bSHarry Wentland 1384562236bSHarry Wentland /* DP MST stream allocation (payload bandwidth number) */ 1394562236bSHarry Wentland struct link_mst_stream_allocation { 1404562236bSHarry Wentland /* DIG front */ 1414562236bSHarry Wentland const struct stream_encoder *stream_enc; 1424562236bSHarry Wentland /* associate DRM payload table with DC stream encoder */ 1434562236bSHarry Wentland uint8_t vcp_id; 1444562236bSHarry Wentland /* number of slots required for the DP stream in transport packet */ 1454562236bSHarry Wentland uint8_t slot_count; 1464562236bSHarry Wentland }; 1474562236bSHarry Wentland 1484562236bSHarry Wentland /* DP MST stream allocation table */ 1494562236bSHarry Wentland struct link_mst_stream_allocation_table { 1504562236bSHarry Wentland /* number of DP video streams */ 1514562236bSHarry Wentland int stream_count; 1524562236bSHarry Wentland /* array of stream allocations */ 1534562236bSHarry Wentland struct link_mst_stream_allocation 1544562236bSHarry Wentland stream_allocations[MAX_CONTROLLER_NUM]; 1554562236bSHarry Wentland }; 1564562236bSHarry Wentland 1574562236bSHarry Wentland struct core_link { 1584562236bSHarry Wentland struct dc_link public; 1594562236bSHarry Wentland const struct core_dc *dc; 1604562236bSHarry Wentland 1614562236bSHarry Wentland struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/ 1624562236bSHarry Wentland 1634562236bSHarry Wentland struct link_encoder *link_enc; 1644562236bSHarry Wentland struct ddc_service *ddc; 1654562236bSHarry Wentland struct graphics_object_id link_id; 1664562236bSHarry Wentland union ddi_channel_mapping ddi_channel_mapping; 1674562236bSHarry Wentland struct connector_device_tag_info device_tag; 1684562236bSHarry Wentland struct dpcd_caps dpcd_caps; 1694562236bSHarry Wentland unsigned int dpcd_sink_count; 1704562236bSHarry Wentland 1714562236bSHarry Wentland enum edp_revision edp_revision; 1724562236bSHarry Wentland 1734562236bSHarry Wentland /* MST record stream using this link */ 1744562236bSHarry Wentland struct link_flags { 1754562236bSHarry Wentland bool dp_keep_receiver_powered; 1764562236bSHarry Wentland } wa_flags; 1774562236bSHarry Wentland struct link_mst_stream_allocation_table mst_stream_alloc_table; 1784562236bSHarry Wentland 1794562236bSHarry Wentland struct dc_link_status link_status; 1804562236bSHarry Wentland }; 1814562236bSHarry Wentland 1824562236bSHarry Wentland #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public) 1834562236bSHarry Wentland 1844562236bSHarry Wentland struct core_link *link_create(const struct link_init_data *init_params); 1854562236bSHarry Wentland void link_destroy(struct core_link **link); 1864562236bSHarry Wentland 1874562236bSHarry Wentland enum dc_status dc_link_validate_mode_timing( 1884562236bSHarry Wentland const struct core_stream *stream, 1894562236bSHarry Wentland struct core_link *link, 1904562236bSHarry Wentland const struct dc_crtc_timing *timing); 1914562236bSHarry Wentland 1924562236bSHarry Wentland void core_link_resume(struct core_link *link); 1934562236bSHarry Wentland 1944562236bSHarry Wentland void core_link_enable_stream(struct pipe_ctx *pipe_ctx); 1954562236bSHarry Wentland 1964562236bSHarry Wentland void core_link_disable_stream(struct pipe_ctx *pipe_ctx); 1974562236bSHarry Wentland 1984562236bSHarry Wentland /********** DAL Core*********************/ 199e11b86adSDmytro Laktyushkin #include "display_clock.h" 2004562236bSHarry Wentland #include "transform.h" 2014562236bSHarry Wentland 2024562236bSHarry Wentland struct resource_pool; 2034562236bSHarry Wentland struct validate_context; 2044562236bSHarry Wentland struct resource_context; 2054562236bSHarry Wentland 2064562236bSHarry Wentland struct resource_funcs { 2074562236bSHarry Wentland void (*destroy)(struct resource_pool **pool); 2084562236bSHarry Wentland struct link_encoder *(*link_enc_create)( 2094562236bSHarry Wentland const struct encoder_init_data *init); 2104562236bSHarry Wentland enum dc_status (*validate_with_context)( 2114562236bSHarry Wentland const struct core_dc *dc, 2124562236bSHarry Wentland const struct dc_validation_set set[], 2134562236bSHarry Wentland int set_count, 2144562236bSHarry Wentland struct validate_context *context); 2154562236bSHarry Wentland 2164562236bSHarry Wentland enum dc_status (*validate_guaranteed)( 2174562236bSHarry Wentland const struct core_dc *dc, 2184562236bSHarry Wentland const struct dc_target *dc_target, 2194562236bSHarry Wentland struct validate_context *context); 2204562236bSHarry Wentland 2214562236bSHarry Wentland enum dc_status (*validate_bandwidth)( 2224562236bSHarry Wentland const struct core_dc *dc, 2234562236bSHarry Wentland struct validate_context *context); 2244562236bSHarry Wentland 2254562236bSHarry Wentland struct validate_context *(*apply_clk_constraints)( 2264562236bSHarry Wentland const struct core_dc *dc, 2274562236bSHarry Wentland struct validate_context *context); 2284562236bSHarry Wentland 2294562236bSHarry Wentland struct pipe_ctx *(*acquire_idle_pipe_for_layer)( 2304562236bSHarry Wentland struct resource_context *res_ctx, 2314562236bSHarry Wentland struct core_stream *stream); 2324562236bSHarry Wentland 2334562236bSHarry Wentland void (*build_bit_depth_reduction_params)( 2344562236bSHarry Wentland const struct core_stream *stream, 2354562236bSHarry Wentland struct bit_depth_reduction_params *fmt_bit_depth); 2364562236bSHarry Wentland }; 2374562236bSHarry Wentland 2384562236bSHarry Wentland struct audio_support{ 2394562236bSHarry Wentland bool dp_audio; 2404562236bSHarry Wentland bool hdmi_audio_on_dongle; 2414562236bSHarry Wentland bool hdmi_audio_native; 2424562236bSHarry Wentland }; 2434562236bSHarry Wentland 2444562236bSHarry Wentland struct resource_pool { 2454562236bSHarry Wentland struct mem_input *mis[MAX_PIPES]; 2464562236bSHarry Wentland struct input_pixel_processor *ipps[MAX_PIPES]; 2474562236bSHarry Wentland struct transform *transforms[MAX_PIPES]; 2484562236bSHarry Wentland struct output_pixel_processor *opps[MAX_PIPES]; 2494562236bSHarry Wentland struct timing_generator *timing_generators[MAX_PIPES]; 2504562236bSHarry Wentland struct stream_encoder *stream_enc[MAX_PIPES * 2]; 2514562236bSHarry Wentland 2524562236bSHarry Wentland unsigned int pipe_count; 2534562236bSHarry Wentland unsigned int underlay_pipe_index; 2544562236bSHarry Wentland unsigned int stream_enc_count; 2554562236bSHarry Wentland 2564562236bSHarry Wentland /* 2574562236bSHarry Wentland * reserved clock source for DP 2584562236bSHarry Wentland */ 2594562236bSHarry Wentland struct clock_source *dp_clock_source; 2604562236bSHarry Wentland 2614562236bSHarry Wentland struct clock_source *clock_sources[MAX_CLOCK_SOURCES]; 2624562236bSHarry Wentland unsigned int clk_src_count; 2634562236bSHarry Wentland 2644562236bSHarry Wentland struct audio *audios[MAX_PIPES]; 2654562236bSHarry Wentland unsigned int audio_count; 2664562236bSHarry Wentland struct audio_support audio_support; 2674562236bSHarry Wentland 2684562236bSHarry Wentland struct display_clock *display_clock; 2694562236bSHarry Wentland struct irq_service *irqs; 2704562236bSHarry Wentland 2714562236bSHarry Wentland const struct resource_funcs *funcs; 2724562236bSHarry Wentland const struct resource_caps *res_cap; 2734562236bSHarry Wentland }; 2744562236bSHarry Wentland 2754562236bSHarry Wentland struct pipe_ctx { 2764562236bSHarry Wentland struct core_surface *surface; 2774562236bSHarry Wentland struct core_stream *stream; 2784562236bSHarry Wentland 2794562236bSHarry Wentland struct mem_input *mi; 2804562236bSHarry Wentland struct input_pixel_processor *ipp; 2814562236bSHarry Wentland struct transform *xfm; 2824562236bSHarry Wentland struct output_pixel_processor *opp; 2834562236bSHarry Wentland struct timing_generator *tg; 2844562236bSHarry Wentland 2854562236bSHarry Wentland struct scaler_data scl_data; 2864562236bSHarry Wentland 2874562236bSHarry Wentland struct stream_encoder *stream_enc; 2884562236bSHarry Wentland struct display_clock *dis_clk; 2894562236bSHarry Wentland struct clock_source *clock_source; 2904562236bSHarry Wentland 2914562236bSHarry Wentland struct audio *audio; 2924562236bSHarry Wentland 2934562236bSHarry Wentland struct pixel_clk_params pix_clk_params; 2944562236bSHarry Wentland struct pll_settings pll_settings; 2954562236bSHarry Wentland 2964562236bSHarry Wentland /*fmt*/ 2974562236bSHarry Wentland struct encoder_info_frame encoder_info_frame; 2984562236bSHarry Wentland 2994562236bSHarry Wentland uint8_t pipe_idx; 3004562236bSHarry Wentland 3014562236bSHarry Wentland struct pipe_ctx *top_pipe; 3024562236bSHarry Wentland struct pipe_ctx *bottom_pipe; 3034562236bSHarry Wentland }; 3044562236bSHarry Wentland 3054562236bSHarry Wentland struct resource_context { 3064562236bSHarry Wentland const struct resource_pool *pool; 3074562236bSHarry Wentland struct pipe_ctx pipe_ctx[MAX_PIPES]; 3084562236bSHarry Wentland bool is_stream_enc_acquired[MAX_PIPES * 2]; 3094562236bSHarry Wentland bool is_audio_acquired[MAX_PIPES]; 3104562236bSHarry Wentland uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES]; 3114562236bSHarry Wentland uint8_t dp_clock_source_ref_count; 3124562236bSHarry Wentland }; 3134562236bSHarry Wentland 3144562236bSHarry Wentland struct validate_context { 3154562236bSHarry Wentland struct core_target *targets[MAX_PIPES]; 3164562236bSHarry Wentland struct dc_target_status target_status[MAX_PIPES]; 3174562236bSHarry Wentland uint8_t target_count; 3184562236bSHarry Wentland 3194562236bSHarry Wentland struct resource_context res_ctx; 3204562236bSHarry Wentland 3214562236bSHarry Wentland /* The output from BW and WM calculations. */ 3224562236bSHarry Wentland struct bw_calcs_output bw_results; 3235ea81b91SDmytro Laktyushkin /* Note: these are big structures, do *not* put on stack! */ 3244562236bSHarry Wentland struct dm_pp_display_configuration pp_display_cfg; 3254562236bSHarry Wentland }; 3264562236bSHarry Wentland 3274562236bSHarry Wentland #endif /* _CORE_TYPES_H_ */ 328