diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig index 4c35625..d070f43 100644 --- a/drivers/gpu/drm/amd/display/Kconfig +++ b/drivers/gpu/drm/amd/display/Kconfig @@ -10,6 +10,16 @@ config DRM_AMD_DC support for AMDGPU. This adds required support for Vega and Raven ASICs. +config DRM_AMD_DC_FBC + bool "AMD FBC - Enable Frame Buffer Compression" + depends on DRM_AMD_DC + help + Choose this option if you want to use frame buffer compression + support. + This is a power optimisation feature, check its availability + on your hardware before enabling this option. + + config DRM_AMD_DC_DCN1_0 def_bool n help diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index a1c912b..9fbd93f 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -348,6 +348,7 @@ static void hotplug_notify_work_func(struct work_struct *work) drm_kms_helper_hotplug_event(dev); } +#if defined(CONFIG_DRM_AMD_DC_FBC) /* Allocate memory for FBC compressed data */ static void amdgpu_dm_fbc_init(struct drm_connector *connector) { @@ -388,6 +389,7 @@ static void amdgpu_dm_fbc_init(struct drm_connector *connector) } } +#endif /* Init display KMS @@ -3602,8 +3604,9 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector) amdgpu_dm_connector_ddc_get_modes(connector, edid); amdgpu_dm_connector_add_common_modes(encoder, connector); } +#if defined(CONFIG_DRM_AMD_DC_FBC) amdgpu_dm_fbc_init(connector); - +#endif return amdgpu_dm_connector->num_modes; } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index a29dc35..d5aa89a 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -72,11 +72,13 @@ struct irq_list_head { struct work_struct work; }; +#if defined(CONFIG_DRM_AMD_DC_FBC) struct dm_comressor_info { void *cpu_addr; struct amdgpu_bo *bo_ptr; uint64_t gpu_addr; }; +#endif struct amdgpu_display_manager { @@ -127,8 +129,9 @@ struct amdgpu_display_manager { * Caches device atomic state for suspend/resume */ struct drm_atomic_state *cached_state; - +#if defined(CONFIG_DRM_AMD_DC_FBC) struct dm_comressor_info compressor; +#endif }; struct amdgpu_dm_connector { diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 7ebce76..2c47848 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -314,7 +314,9 @@ struct dc { bool apply_edp_fast_boot_optimization; /* FBC compressor */ +#if defined(CONFIG_DRM_AMD_DC_FBC) struct compressor *fbc_compressor; +#endif struct dc_debug_data debug_data; }; diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index c96e526..b7dbb44e 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h @@ -91,7 +91,9 @@ struct dc_context { struct gpio_service *gpio_service; struct i2caux *i2caux; uint32_t dc_sink_id_count; +#if defined(CONFIG_DRM_AMD_DC_FBC) uint64_t fbc_gpu_addr; +#endif }; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_compressor.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_compressor.c index df02701..111c492 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_compressor.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_compressor.c @@ -551,7 +551,9 @@ void dce110_compressor_construct(struct dce110_compressor *compressor, compressor->base.lpt_channels_num = 0; compressor->base.attached_inst = 0; compressor->base.is_enabled = false; +#if defined(CONFIG_DRM_AMD_DC_FBC) compressor->base.funcs = &dce110_compressor_funcs; +#endif } diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index 353ffcb..e34d3663 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -34,7 +34,9 @@ #include "dce/dce_hwseq.h" #include "gpio_service_interface.h" +#if defined(CONFIG_DRM_AMD_DC_FBC) #include "dce110_compressor.h" +#endif #include "bios/bios_parser_helper.h" #include "timing_generator.h" @@ -1509,8 +1511,10 @@ static void power_down_all_hw_blocks(struct dc *dc) power_down_clock_sources(dc); +#if defined(CONFIG_DRM_AMD_DC_FBC) if (dc->fbc_compressor) dc->fbc_compressor->funcs->disable_fbc(dc->fbc_compressor); +#endif } static void disable_vga_and_power_gate_all_controllers( @@ -1759,7 +1763,9 @@ static void set_static_screen_control(struct pipe_ctx **pipe_ctx, if (events->force_trigger) value |= 0x1; +#if defined(CONFIG_DRM_AMD_DC_FBC) value |= 0x84; +#endif for (i = 0; i < num_pipes; i++) pipe_ctx[i]->stream_res.tg->funcs-> @@ -1794,6 +1800,8 @@ static void apply_min_clocks( return max_pix_clk; } +#if defined(CONFIG_DRM_AMD_DC_FBC) + /* * Check if FBC can be enabled */ @@ -1872,6 +1880,7 @@ static void enable_fbc(struct dc *dc, compr->funcs->enable_fbc(compr, ¶ms); } } +#endif static void dce110_reset_hw_ctx_wrap( struct dc *dc, @@ -2047,9 +2056,10 @@ enum dc_status dce110_apply_ctx_to_hw( PIPE_GATING_CONTROL_DISABLE); } +#if defined(CONFIG_DRM_AMD_DC_FBC) if (dc->fbc_compressor) dc->fbc_compressor->funcs->disable_fbc(dc->fbc_compressor); - +#endif dce110_setup_audio_dto(dc, context); for (i = 0; i < dc->res_pool->pipe_count; i++) { @@ -2080,9 +2090,12 @@ enum dc_status dce110_apply_ctx_to_hw( dcb->funcs->set_scratch_critical_state(dcb, false); +#if defined(CONFIG_DRM_AMD_DC_FBC) if (dc->fbc_compressor) enable_fbc(dc, context); +#endif + return DC_OK; } @@ -2397,9 +2410,10 @@ static void init_hw(struct dc *dc) abm->funcs->init_backlight(abm); abm->funcs->abm_init(abm); } - +#if defined(CONFIG_DRM_AMD_DC_FBC) if (dc->fbc_compressor) dc->fbc_compressor->funcs->power_up_fbc(dc->fbc_compressor); +#endif } @@ -2590,7 +2604,9 @@ static void dce110_program_front_end_for_pipe( struct dc_plane_state *plane_state = pipe_ctx->plane_state; struct xfm_grph_csc_adjustment adjust; struct out_csc_color_matrix tbl_entry; +#if defined(CONFIG_DRM_AMD_DC_FBC) unsigned int underlay_idx = dc->res_pool->underlay_pipe_index; +#endif unsigned int i; DC_LOGGER_INIT(); memset(&tbl_entry, 0, sizeof(tbl_entry)); @@ -2631,6 +2647,7 @@ static void dce110_program_front_end_for_pipe( program_scaler(dc, pipe_ctx); +#if defined(CONFIG_DRM_AMD_DC_FBC) /* fbc not applicable on Underlay pipe */ if (dc->fbc_compressor && old_pipe->stream && pipe_ctx->pipe_idx != underlay_idx) { @@ -2639,6 +2656,7 @@ static void dce110_program_front_end_for_pipe( else enable_fbc(dc, dc->current_state); } +#endif mi->funcs->mem_input_program_surface_config( mi, diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c index 20c0290..ee33786 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c @@ -55,8 +55,9 @@ #define DC_LOGGER \ dc->ctx->logger - +#if defined(CONFIG_DRM_AMD_DC_FBC) #include "dce110/dce110_compressor.h" +#endif #include "reg_helper.h" @@ -1305,8 +1306,12 @@ static bool construct( } } +#if defined(CONFIG_DRM_AMD_DC_FBC) dc->fbc_compressor = dce110_compressor_create(ctx); + + +#endif if (!underlay_create(ctx, &pool->base)) goto res_create_fail;