amdgpu/display: remove link/stream functions abstraction.

Submitted by Dave Airlie on Dec. 15, 2016, 11:49 p.m.

Details

Message ID 20161215234950.17422-1-airlied@gmail.com
State New
Headers show
Series "amdgpu/display: remove link/stream functions abstraction." ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Dave Airlie Dec. 15, 2016, 11:49 p.m.
From: Dave Airlie <airlied@redhat.com>

Most of these weren't used in the driver, but I can't see why you need
this table instead of just providing direct API, it's not hiding anything.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    |   2 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c           | 232 +--------------------
 drivers/gpu/drm/amd/display/dc/dc.h                |  54 +----
 .../drm/amd/display/modules/freesync/freesync.c    |  48 ++---
 4 files changed, 31 insertions(+), 305 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index e73c658..59a6bef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -630,7 +630,7 @@  static void update_stream_scaling_settings(
 		dst.height -= dm_state->underscan_vborder;
 	}
 
-	adev->dm.dc->stream_funcs.stream_update_scaling(adev->dm.dc, stream, &src, &dst);
+	dc_stream_update_scaling(adev->dm.dc, stream, &src, &dst);
 
 	DRM_DEBUG_KMS("Destination Rectangle x:%d  y:%d  width:%d  height:%d\n",
 			dst.x, dst.y, dst.width, dst.height);
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 8697d7c..07033b9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -158,9 +158,9 @@  failed_alloc:
 	return false;
 }
 
-static bool stream_adjust_vmin_vmax(struct dc *dc,
-		const struct dc_stream **stream, int num_streams,
-		int vmin, int vmax)
+bool dc_stream_adjust_vmin_vmax(struct dc *dc,
+				const struct dc_stream **stream, int num_streams,
+				int vmin, int vmax)
 {
 	/* TODO: Support multiple streams */
 	struct core_dc *core_dc = DC_TO_CORE(dc);
@@ -188,39 +188,14 @@  static bool stream_adjust_vmin_vmax(struct dc *dc,
 	return ret;
 }
 
-
-static bool set_gamut_remap(struct dc *dc,
-			const struct dc_stream **stream, int num_streams)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	struct core_stream *core_stream = DC_STREAM_TO_CORE(stream[0]);
-	int i = 0;
-	bool ret = false;
-	struct pipe_ctx *pipes;
-
-	for (i = 0; i < MAX_PIPES; i++) {
-		if (core_dc->current_context->res_ctx.pipe_ctx[i].stream
-				== core_stream) {
-
-			pipes = &core_dc->current_context->res_ctx.pipe_ctx[i];
-			core_dc->hwss.set_plane_config(core_dc, pipes,
-					&core_dc->current_context->res_ctx);
-			ret = true;
-		}
-	}
-
-	return ret;
-}
-
 /* This function is not expected to fail, proper implementation of
  * validation will prevent this from ever being called for unsupported
  * configurations.
  */
-static void stream_update_scaling(
-		const struct dc *dc,
-		const struct dc_stream *dc_stream,
-		const struct rect *src,
-		const struct rect *dst)
+void dc_stream_update_scaling(const struct dc *dc,
+			      const struct dc_stream *dc_stream,
+			      const struct rect *src,
+			      const struct rect *dst)
 {
 	struct core_stream *stream = DC_STREAM_TO_CORE(dc_stream);
 	struct core_dc *core_dc = DC_TO_CORE(dc);
@@ -255,197 +230,6 @@  static void stream_update_scaling(
 	}
 }
 
-static bool set_backlight(struct dc *dc, unsigned int backlight_level,
-			unsigned int frame_ramp, const struct dc_stream *stream)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	if (stream->sink->sink_signal == SIGNAL_TYPE_EDP) {
-		for (i = 0; i < core_dc->link_count; i++)
-			dc_link_set_backlight_level(&core_dc->links[i]->public,
-					backlight_level, frame_ramp, stream);
-	}
-
-	return true;
-
-}
-
-static bool init_dmcu_backlight_settings(struct dc *dc)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++)
-		dc_link_init_dmcu_backlight_settings
-			(&core_dc->links[i]->public);
-
-	return true;
-}
-
-
-static bool set_abm_level(struct dc *dc, unsigned int abm_level)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++)
-		dc_link_set_abm_level(&core_dc->links[i]->public,
-				abm_level);
-
-	return true;
-}
-
-static bool set_psr_enable(struct dc *dc, bool enable)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++)
-		dc_link_set_psr_enable(&core_dc->links[i]->public,
-				enable);
-
-	return true;
-}
-
-
-static bool setup_psr(struct dc *dc, const struct dc_stream *stream)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	struct core_stream *core_stream = DC_STREAM_TO_CORE(stream);
-	struct pipe_ctx *pipes;
-	int i;
-	unsigned int underlay_idx = core_dc->res_pool->underlay_pipe_index;
-
-	for (i = 0; i < core_dc->link_count; i++) {
-		if (core_stream->sink->link == core_dc->links[i])
-			dc_link_setup_psr(&core_dc->links[i]->public,
-					stream);
-	}
-
-	for (i = 0; i < MAX_PIPES; i++) {
-		if (core_dc->current_context->res_ctx.pipe_ctx[i].stream
-				== core_stream && i != underlay_idx) {
-			pipes = &core_dc->current_context->res_ctx.pipe_ctx[i];
-			core_dc->hwss.set_static_screen_control(&pipes, 1,
-					0x182);
-		}
-	}
-
-	return true;
-}
-
-static void set_drive_settings(struct dc *dc,
-		struct link_training_settings *lt_settings)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++)
-		dc_link_dp_set_drive_settings(&core_dc->links[i]->public,
-				lt_settings);
-}
-
-static void perform_link_training(struct dc *dc,
-		struct dc_link_settings *link_setting,
-		bool skip_video_pattern)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++)
-		dc_link_dp_perform_link_training(
-			&core_dc->links[i]->public,
-			link_setting,
-			skip_video_pattern);
-}
-
-static void set_preferred_link_settings(struct dc *dc,
-		struct dc_link_settings *link_setting)
-{
-	struct core_dc *core_dc = DC_TO_CORE(dc);
-	int i;
-
-	for (i = 0; i < core_dc->link_count; i++) {
-		core_dc->links[i]->public.verified_link_cap.lane_count =
-				link_setting->lane_count;
-		core_dc->links[i]->public.verified_link_cap.link_rate =
-				link_setting->link_rate;
-	}
-}
-
-static void enable_hpd(const struct dc_link *link)
-{
-	dc_link_dp_enable_hpd(link);
-}
-
-static void disable_hpd(const struct dc_link *link)
-{
-	dc_link_dp_disable_hpd(link);
-}
-
-
-static void set_test_pattern(
-		const struct dc_link *link,
-		enum dp_test_pattern test_pattern,
-		const struct link_training_settings *p_link_settings,
-		const unsigned char *p_custom_pattern,
-		unsigned int cust_pattern_size)
-{
-	if (link != NULL)
-		dc_link_dp_set_test_pattern(
-			link,
-			test_pattern,
-			p_link_settings,
-			p_custom_pattern,
-			cust_pattern_size);
-}
-
-static void allocate_dc_stream_funcs(struct core_dc *core_dc)
-{
-	core_dc->public.stream_funcs.stream_update_scaling = stream_update_scaling;
-	if (core_dc->hwss.set_drr != NULL) {
-		core_dc->public.stream_funcs.adjust_vmin_vmax =
-				stream_adjust_vmin_vmax;
-	}
-
-	core_dc->public.stream_funcs.set_gamut_remap =
-			set_gamut_remap;
-
-	core_dc->public.stream_funcs.set_backlight =
-			set_backlight;
-
-	core_dc->public.stream_funcs.init_dmcu_backlight_settings =
-			init_dmcu_backlight_settings;
-
-	core_dc->public.stream_funcs.set_abm_level =
-			set_abm_level;
-
-	core_dc->public.stream_funcs.set_psr_enable =
-			set_psr_enable;
-
-	core_dc->public.stream_funcs.setup_psr =
-			setup_psr;
-
-	core_dc->public.link_funcs.set_drive_settings =
-			set_drive_settings;
-
-	core_dc->public.link_funcs.perform_link_training =
-			perform_link_training;
-
-	core_dc->public.link_funcs.set_preferred_link_settings =
-			set_preferred_link_settings;
-
-	core_dc->public.link_funcs.enable_hpd =
-			enable_hpd;
-
-	core_dc->public.link_funcs.disable_hpd =
-			disable_hpd;
-
-	core_dc->public.link_funcs.set_test_pattern =
-			set_test_pattern;
-}
-
 static void destruct(struct core_dc *dc)
 {
 	resource_validate_ctx_destruct(dc->current_context);
@@ -570,8 +354,6 @@  static bool construct(struct core_dc *dc,
 	if (!create_links(dc, init_params->num_virtual_links))
 		goto create_links_fail;
 
-	allocate_dc_stream_funcs(dc);
-
 	return true;
 
 	/**** error handling here ****/
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 376981e..563cf3d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -84,51 +84,8 @@  struct dc;
 struct dc_surface;
 struct validate_context;
 
-struct dc_cap_funcs {
-	int i;
-};
-
-struct dc_stream_funcs {
-	bool (*adjust_vmin_vmax)(struct dc *dc,
-			const struct dc_stream **stream,
-			int num_streams,
-			int vmin,
-			int vmax);
-
-	void (*stream_update_scaling)(const struct dc *dc,
-			const struct dc_stream *dc_stream,
-			const struct rect *src,
-			const struct rect *dst);
-	bool (*set_gamut_remap)(struct dc *dc,
-			const struct dc_stream **stream, int num_streams);
-	bool (*set_backlight)(struct dc *dc, unsigned int backlight_level,
-		unsigned int frame_ramp, const struct dc_stream *stream);
-	bool (*init_dmcu_backlight_settings)(struct dc *dc);
-	bool (*set_abm_level)(struct dc *dc, unsigned int abm_level);
-	bool (*set_psr_enable)(struct dc *dc, bool enable);
-	bool (*setup_psr)(struct dc *dc, const struct dc_stream *stream);
-};
-
 struct link_training_settings;
 
-struct dc_link_funcs {
-	void (*set_drive_settings)(struct dc *dc,
-			struct link_training_settings *lt_settings);
-	void (*perform_link_training)(struct dc *dc,
-			struct dc_link_settings *link_setting,
-			bool skip_video_pattern);
-	void (*set_preferred_link_settings)(struct dc *dc,
-			struct dc_link_settings *link_setting);
-	void (*enable_hpd)(const struct dc_link *link);
-	void (*disable_hpd)(const struct dc_link *link);
-	void (*set_test_pattern)(
-			const struct dc_link *link,
-			enum dp_test_pattern test_pattern,
-			const struct link_training_settings *p_link_settings,
-			const unsigned char *p_custom_pattern,
-			unsigned int cust_pattern_size);
-};
-
 /* Structure to hold configuration flags set by dm at dc creation. */
 struct dc_config {
 	bool gpu_vm_support;
@@ -150,9 +107,6 @@  struct dc_debug {
 
 struct dc {
 	struct dc_caps caps;
-	struct dc_cap_funcs cap_funcs;
-	struct dc_stream_funcs stream_funcs;
-	struct dc_link_funcs link_funcs;
 	struct dc_config config;
 	struct dc_debug debug;
 };
@@ -350,6 +304,14 @@  bool dc_post_update_surfaces_to_target(
 void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *updates,
 		int surface_count, struct dc_target *dc_target);
 
+
+bool dc_stream_adjust_vmin_vmax(struct dc *dc,
+				const struct dc_stream **stream, int num_streams,
+				int vmin, int vmax);
+void dc_stream_update_scaling(const struct dc *dc,
+			      const struct dc_stream *dc_stream,
+			      const struct rect *src,
+			      const struct rect *dst);
 /*******************************************************************************
  * Target Interfaces
  ******************************************************************************/
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 8892e8b..8c927ed 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -108,14 +108,6 @@  struct core_freesync {
 #define MOD_FREESYNC_TO_CORE(mod_freesync)\
 		container_of(mod_freesync, struct core_freesync, public)
 
-static bool check_dc_support(const struct dc *dc)
-{
-	if (dc->stream_funcs.adjust_vmin_vmax == NULL)
-		return false;
-
-	return true;
-}
-
 struct mod_freesync *mod_freesync_create(struct dc *dc)
 {
 	struct core_freesync *core_freesync =
@@ -146,9 +138,6 @@  struct mod_freesync *mod_freesync_create(struct dc *dc)
 
 	core_freesync->dc = dc;
 
-	if (!check_dc_support(dc))
-		goto fail_construct;
-
 	/* Create initial module folder in registry for freesync enable data */
 	flag.save_per_edid = true;
 	flag.save_per_link = false;
@@ -494,10 +483,9 @@  static bool set_freesync_on_streams(struct core_freesync *core_freesync,
 				update_stream_freesync_context(core_freesync,
 						streams[stream_idx]);
 
-				core_freesync->dc->stream_funcs.
-				adjust_vmin_vmax(core_freesync->dc, streams,
-						num_streams, v_total_min,
-						v_total_max);
+				dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
+							   num_streams, v_total_min,
+							   v_total_max);
 
 				return true;
 
@@ -520,8 +508,7 @@  static bool set_freesync_on_streams(struct core_freesync *core_freesync,
 						core_freesync,
 						streams[stream_idx]);
 
-					core_freesync->dc->stream_funcs.
-					adjust_vmin_vmax(
+					dc_stream_adjust_vmin_vmax(
 						core_freesync->dc, streams,
 						num_streams, v_total_nominal,
 						v_total_nominal);
@@ -540,8 +527,7 @@  static bool set_freesync_on_streams(struct core_freesync *core_freesync,
 					core_freesync,
 					streams[stream_idx]);
 
-				core_freesync->dc->stream_funcs.
-						adjust_vmin_vmax(
+				dc_stream_adjust_vmin_vmax(
 						core_freesync->dc, streams,
 						num_streams, v_total_nominal,
 						v_total_nominal);
@@ -560,8 +546,7 @@  static bool set_freesync_on_streams(struct core_freesync *core_freesync,
 			 * not support freesync because a former stream has
 			 * be programmed
 			 */
-			core_freesync->dc->stream_funcs.
-					adjust_vmin_vmax(
+			dc_stream_adjust_vmin_vmax(
 					core_freesync->dc, streams,
 					num_streams, v_total_nominal,
 					v_total_nominal);
@@ -680,10 +665,9 @@  void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
 		update_stream_freesync_context(core_freesync, streams[0]);
 
 		/* Program static screen ramp values */
-		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
-					core_freesync->dc, streams,
-					num_streams, v_total,
-					v_total);
+		dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
+					   num_streams, v_total,
+					   v_total);
 	}
 }
 
@@ -1068,10 +1052,9 @@  static void apply_below_the_range(struct core_freesync *core_freesync,
 		vmax = inserted_frame_v_total;
 
 		/* Program V_TOTAL */
-		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
-			core_freesync->dc, &stream,
-			1, vmin,
-			vmax);
+		dc_stream_adjust_vmin_vmax(core_freesync->dc, &stream,
+					   1, vmin,
+					   vmax);
 
 		/* Cache the calculated variables */
 		state->btr.inserted_frame_duration_in_us =
@@ -1106,10 +1089,9 @@  static void apply_fixed_refresh(struct core_freesync *core_freesync,
 
 		vmax = vmin;
 
-		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
-				core_freesync->dc, &stream,
-				1, vmin,
-				vmax);
+		dc_stream_adjust_vmin_vmax(core_freesync->dc, &stream,
+					   1, vmin,
+					   vmax);
 	}
 }
 

Comments

On 16 December 2016 at 09:49, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> Most of these weren't used in the driver, but I can't see why you need
> this table instead of just providing direct API, it's not hiding anything.

I realised the power module uses some of these, but since that module
isn't in the build.

I'd still think direct calls makes sense for all of this instead of callbacks.

Dave.