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 364562236bSHarry Wentland #define MAX_PIPES 6 374562236bSHarry Wentland #define MAX_CLOCK_SOURCES 7 384562236bSHarry Wentland 394562236bSHarry Wentland 404562236bSHarry Wentland /********* core_surface **********/ 414562236bSHarry Wentland #define DC_SURFACE_TO_CORE(dc_surface) \ 424562236bSHarry Wentland container_of(dc_surface, struct core_surface, public) 434562236bSHarry Wentland 444562236bSHarry Wentland #define DC_GAMMA_TO_CORE(dc_gamma) \ 454562236bSHarry Wentland container_of(dc_gamma, struct core_gamma, public) 464562236bSHarry Wentland 4790e508baSAnthony Koo #define DC_TRANSFER_FUNC_TO_CORE(dc_transfer_func) \ 4890e508baSAnthony Koo container_of(dc_transfer_func, struct core_transfer_func, public) 4990e508baSAnthony Koo 504562236bSHarry Wentland struct core_surface { 514562236bSHarry Wentland struct dc_surface public; 524562236bSHarry Wentland struct dc_surface_status status; 534562236bSHarry Wentland struct dc_context *ctx; 544562236bSHarry Wentland }; 554562236bSHarry Wentland 564562236bSHarry Wentland struct core_gamma { 574562236bSHarry Wentland struct dc_gamma public; 584562236bSHarry Wentland struct dc_context *ctx; 594562236bSHarry Wentland }; 604562236bSHarry Wentland 61fb735a9fSAnthony Koo struct core_transfer_func { 62fb735a9fSAnthony Koo struct dc_transfer_func public; 63fb735a9fSAnthony Koo struct dc_context *ctx; 64fb735a9fSAnthony Koo }; 65fb735a9fSAnthony Koo 664562236bSHarry Wentland void enable_surface_flip_reporting(struct dc_surface *dc_surface, 674562236bSHarry Wentland uint32_t controller_id); 684562236bSHarry Wentland 694562236bSHarry Wentland /********* core_stream ************/ 704562236bSHarry Wentland #include "grph_object_id.h" 714562236bSHarry Wentland #include "link_encoder.h" 724562236bSHarry Wentland #include "stream_encoder.h" 734562236bSHarry Wentland #include "clock_source.h" 744562236bSHarry Wentland #include "audio.h" 754562236bSHarry Wentland #include "hw_sequencer_types.h" 764562236bSHarry Wentland #include "opp.h" 774562236bSHarry Wentland 784562236bSHarry Wentland #define DC_STREAM_TO_CORE(dc_stream) container_of( \ 794562236bSHarry Wentland dc_stream, struct core_stream, public) 804562236bSHarry Wentland 814562236bSHarry Wentland struct core_stream { 824562236bSHarry Wentland struct dc_stream public; 834562236bSHarry Wentland 844562236bSHarry Wentland /* field internal to DC */ 854562236bSHarry Wentland struct dc_context *ctx; 864562236bSHarry Wentland const struct core_sink *sink; 874562236bSHarry Wentland 884562236bSHarry Wentland /* used by DCP and FMT */ 894562236bSHarry Wentland struct bit_depth_reduction_params bit_depth_params; 904562236bSHarry Wentland struct clamping_and_pixel_encoding_params clamping; 914562236bSHarry Wentland 924562236bSHarry Wentland int phy_pix_clk; 934562236bSHarry Wentland enum signal_type signal; 944562236bSHarry Wentland 954562236bSHarry Wentland struct dc_stream_status status; 964562236bSHarry Wentland }; 974562236bSHarry Wentland 984562236bSHarry Wentland /************ core_sink *****************/ 994562236bSHarry Wentland 1004562236bSHarry Wentland #define DC_SINK_TO_CORE(dc_sink) \ 1014562236bSHarry Wentland container_of(dc_sink, struct core_sink, public) 1024562236bSHarry Wentland 1034562236bSHarry Wentland struct core_sink { 1044562236bSHarry Wentland /** The public, read-only (for DM) area of sink. **/ 1054562236bSHarry Wentland struct dc_sink public; 1064562236bSHarry Wentland /** End-of-public area. **/ 1074562236bSHarry Wentland 1084562236bSHarry Wentland /** The 'protected' area - read/write access, for use only inside DC **/ 1094562236bSHarry Wentland /* not used for now */ 1104562236bSHarry Wentland struct core_link *link; 1114562236bSHarry Wentland struct dc_context *ctx; 1124562236bSHarry Wentland uint32_t dongle_max_pix_clk; 1134562236bSHarry Wentland bool converter_disable_audio; 1144562236bSHarry Wentland }; 1154562236bSHarry Wentland 1164562236bSHarry Wentland /************ link *****************/ 1174562236bSHarry Wentland #define DC_LINK_TO_CORE(dc_link) container_of(dc_link, struct core_link, public) 1184562236bSHarry Wentland 1194562236bSHarry Wentland struct link_init_data { 1204562236bSHarry Wentland const struct core_dc *dc; 1214562236bSHarry Wentland struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */ 1224562236bSHarry Wentland uint32_t connector_index; /* this will be mapped to the HPD pins */ 1234562236bSHarry Wentland uint32_t link_index; /* this is mapped to DAL display_index 1244562236bSHarry Wentland TODO: remove it when DC is complete. */ 1254562236bSHarry Wentland }; 1264562236bSHarry Wentland 1274562236bSHarry Wentland /* DP MST stream allocation (payload bandwidth number) */ 1284562236bSHarry Wentland struct link_mst_stream_allocation { 1294562236bSHarry Wentland /* DIG front */ 1304562236bSHarry Wentland const struct stream_encoder *stream_enc; 1314562236bSHarry Wentland /* associate DRM payload table with DC stream encoder */ 1324562236bSHarry Wentland uint8_t vcp_id; 1334562236bSHarry Wentland /* number of slots required for the DP stream in transport packet */ 1344562236bSHarry Wentland uint8_t slot_count; 1354562236bSHarry Wentland }; 1364562236bSHarry Wentland 1374562236bSHarry Wentland /* DP MST stream allocation table */ 1384562236bSHarry Wentland struct link_mst_stream_allocation_table { 1394562236bSHarry Wentland /* number of DP video streams */ 1404562236bSHarry Wentland int stream_count; 1414562236bSHarry Wentland /* array of stream allocations */ 1424562236bSHarry Wentland struct link_mst_stream_allocation 1434562236bSHarry Wentland stream_allocations[MAX_CONTROLLER_NUM]; 1444562236bSHarry Wentland }; 1454562236bSHarry Wentland 1464562236bSHarry Wentland struct core_link { 1474562236bSHarry Wentland struct dc_link public; 1484562236bSHarry Wentland const struct core_dc *dc; 1494562236bSHarry Wentland 1504562236bSHarry Wentland struct dc_context *ctx; /* TODO: AUTO remove 'dal' when DC is complete*/ 1514562236bSHarry Wentland 1524562236bSHarry Wentland struct link_encoder *link_enc; 1534562236bSHarry Wentland struct ddc_service *ddc; 1544562236bSHarry Wentland struct graphics_object_id link_id; 1554562236bSHarry Wentland union ddi_channel_mapping ddi_channel_mapping; 1564562236bSHarry Wentland struct connector_device_tag_info device_tag; 1574562236bSHarry Wentland struct dpcd_caps dpcd_caps; 1584562236bSHarry Wentland unsigned int dpcd_sink_count; 1594562236bSHarry Wentland 1604562236bSHarry Wentland enum edp_revision edp_revision; 1614562236bSHarry Wentland 1624562236bSHarry Wentland /* MST record stream using this link */ 1634562236bSHarry Wentland struct link_flags { 1644562236bSHarry Wentland bool dp_keep_receiver_powered; 1654562236bSHarry Wentland } wa_flags; 1664562236bSHarry Wentland struct link_mst_stream_allocation_table mst_stream_alloc_table; 1674562236bSHarry Wentland 1684562236bSHarry Wentland struct dc_link_status link_status; 1694562236bSHarry Wentland }; 1704562236bSHarry Wentland 1714562236bSHarry Wentland #define DC_LINK_TO_LINK(dc_link) container_of(dc_link, struct core_link, public) 1724562236bSHarry Wentland 1734562236bSHarry Wentland struct core_link *link_create(const struct link_init_data *init_params); 1744562236bSHarry Wentland void link_destroy(struct core_link **link); 1754562236bSHarry Wentland 1764562236bSHarry Wentland enum dc_status dc_link_validate_mode_timing( 1774562236bSHarry Wentland const struct core_stream *stream, 1784562236bSHarry Wentland struct core_link *link, 1794562236bSHarry Wentland const struct dc_crtc_timing *timing); 1804562236bSHarry Wentland 1814562236bSHarry Wentland void core_link_resume(struct core_link *link); 1824562236bSHarry Wentland 1834562236bSHarry Wentland void core_link_enable_stream(struct pipe_ctx *pipe_ctx); 1844562236bSHarry Wentland 1854562236bSHarry Wentland void core_link_disable_stream(struct pipe_ctx *pipe_ctx); 1864562236bSHarry Wentland 1874562236bSHarry Wentland /********** DAL Core*********************/ 188e11b86adSDmytro Laktyushkin #include "display_clock.h" 1894562236bSHarry Wentland #include "transform.h" 1904562236bSHarry Wentland 1914562236bSHarry Wentland struct resource_pool; 1924562236bSHarry Wentland struct validate_context; 1934562236bSHarry Wentland struct resource_context; 1944562236bSHarry Wentland 1954562236bSHarry Wentland struct resource_funcs { 1964562236bSHarry Wentland void (*destroy)(struct resource_pool **pool); 1974562236bSHarry Wentland struct link_encoder *(*link_enc_create)( 1984562236bSHarry Wentland const struct encoder_init_data *init); 1994562236bSHarry Wentland enum dc_status (*validate_with_context)( 2004562236bSHarry Wentland const struct core_dc *dc, 2014562236bSHarry Wentland const struct dc_validation_set set[], 2024562236bSHarry Wentland int set_count, 2034562236bSHarry Wentland struct validate_context *context); 2044562236bSHarry Wentland 2054562236bSHarry Wentland enum dc_status (*validate_guaranteed)( 2064562236bSHarry Wentland const struct core_dc *dc, 207ab2541b6SAric Cyr const struct dc_stream *stream, 2084562236bSHarry Wentland struct validate_context *context); 2094562236bSHarry Wentland 21045209ef7SDmytro Laktyushkin bool (*validate_bandwidth)( 2114562236bSHarry Wentland const struct core_dc *dc, 2124562236bSHarry Wentland struct validate_context *context); 2134562236bSHarry Wentland 2144562236bSHarry Wentland struct pipe_ctx *(*acquire_idle_pipe_for_layer)( 2154562236bSHarry Wentland struct resource_context *res_ctx, 2164562236bSHarry Wentland struct core_stream *stream); 2174562236bSHarry Wentland 2184562236bSHarry Wentland void (*build_bit_depth_reduction_params)( 2194562236bSHarry Wentland const struct core_stream *stream, 2204562236bSHarry Wentland struct bit_depth_reduction_params *fmt_bit_depth); 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; 2615e7773a2SAnthony Koo 2624562236bSHarry Wentland const struct resource_funcs *funcs; 2634562236bSHarry Wentland const struct resource_caps *res_cap; 2644562236bSHarry Wentland }; 2654562236bSHarry Wentland 2664562236bSHarry Wentland struct pipe_ctx { 2674562236bSHarry Wentland struct core_surface *surface; 2684562236bSHarry Wentland struct core_stream *stream; 2694562236bSHarry Wentland 2704562236bSHarry Wentland struct mem_input *mi; 2714562236bSHarry Wentland struct input_pixel_processor *ipp; 2724562236bSHarry Wentland struct transform *xfm; 2734562236bSHarry Wentland struct output_pixel_processor *opp; 2744562236bSHarry Wentland struct timing_generator *tg; 2754562236bSHarry Wentland 2764562236bSHarry Wentland struct scaler_data scl_data; 2774562236bSHarry Wentland 2784562236bSHarry Wentland struct stream_encoder *stream_enc; 2794562236bSHarry Wentland struct display_clock *dis_clk; 2804562236bSHarry Wentland struct clock_source *clock_source; 2814562236bSHarry Wentland 2824562236bSHarry Wentland struct audio *audio; 2834562236bSHarry Wentland 2844562236bSHarry Wentland struct pixel_clk_params pix_clk_params; 2854562236bSHarry Wentland struct pll_settings pll_settings; 2864562236bSHarry Wentland 2874562236bSHarry Wentland /*fmt*/ 2884562236bSHarry Wentland struct encoder_info_frame encoder_info_frame; 2894562236bSHarry Wentland 2904562236bSHarry Wentland uint8_t pipe_idx; 2914562236bSHarry Wentland 2924562236bSHarry Wentland struct pipe_ctx *top_pipe; 2934562236bSHarry Wentland struct pipe_ctx *bottom_pipe; 2944562236bSHarry Wentland }; 2954562236bSHarry Wentland 2964562236bSHarry Wentland struct resource_context { 2974562236bSHarry Wentland const struct resource_pool *pool; 2984562236bSHarry Wentland struct pipe_ctx pipe_ctx[MAX_PIPES]; 2994562236bSHarry Wentland bool is_stream_enc_acquired[MAX_PIPES * 2]; 3004562236bSHarry Wentland bool is_audio_acquired[MAX_PIPES]; 3014562236bSHarry Wentland uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES]; 3024562236bSHarry Wentland uint8_t dp_clock_source_ref_count; 3034562236bSHarry Wentland }; 3044562236bSHarry Wentland 3054562236bSHarry Wentland struct validate_context { 306ab2541b6SAric Cyr struct core_stream *streams[MAX_PIPES]; 307ab2541b6SAric Cyr struct dc_stream_status stream_status[MAX_PIPES]; 308ab2541b6SAric Cyr uint8_t stream_count; 3094562236bSHarry Wentland 3104562236bSHarry Wentland struct resource_context res_ctx; 3114562236bSHarry Wentland 3124562236bSHarry Wentland /* The output from BW and WM calculations. */ 3134562236bSHarry Wentland struct bw_calcs_output bw_results; 3145ea81b91SDmytro Laktyushkin /* Note: these are big structures, do *not* put on stack! */ 3154562236bSHarry Wentland struct dm_pp_display_configuration pp_display_cfg; 3160f56b418SDmytro Laktyushkin int dispclk_khz; 3174562236bSHarry Wentland }; 3184562236bSHarry Wentland 3194562236bSHarry Wentland #endif /* _CORE_TYPES_H_ */ 320