[PATCH 031/120] drm/amd/display: Roll core_sink into dc_sink

Harry Wentland harry.wentland at amd.com
Wed Aug 9 15:01:17 UTC 2017


Change-Id: Ib17c7153e1b6d3be8056c1b7951ca133eb529a9d
Signed-off-by: Harry Wentland <harry.wentland at amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |  4 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    |  4 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c           |  4 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c      | 60 +++++++++++-----------
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c  |  2 +-
 drivers/gpu/drm/amd/display/dc/core/dc_sink.c      | 30 +++++------
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c    | 15 +++---
 drivers/gpu/drm/amd/display/dc/dc.h                | 19 ++++---
 .../amd/display/dc/dce110/dce110_hw_sequencer.c    |  2 +-
 drivers/gpu/drm/amd/display/dc/inc/core_types.h    | 21 +-------
 11 files changed, 72 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index f57a5134a327..cb173678f7df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -567,9 +567,9 @@ struct amdgpu_connector {
 	int num_modes;
 	/* The 'old' sink - before an HPD.
 	 * The 'current' sink is in dc_link->sink. */
-	const struct dc_sink *dc_sink;
+	struct dc_sink *dc_sink;
 	struct dc_link *dc_link;
-	const struct dc_sink *dc_em_sink;
+	struct dc_sink *dc_em_sink;
 	const struct dc_stream *stream;
 	void *con_priv;
 	bool dac_load_detect;
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 8f1805841150..71178c88e39f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -697,7 +697,7 @@ void amdgpu_dm_update_connector_after_detect(
 {
 	struct drm_connector *connector = &aconnector->base;
 	struct drm_device *dev = connector->dev;
-	const struct dc_sink *sink;
+	struct dc_sink *sink;
 
 	/* MST handled by drm_mst framework */
 	if (aconnector->mst_mgr.mst_state == true)
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 456f66573ede..b7c01f353d33 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
@@ -1409,7 +1409,7 @@ int amdgpu_dm_connector_mode_valid(
 		struct drm_display_mode *mode)
 {
 	int result = MODE_ERROR;
-	const struct dc_sink *dc_sink;
+	struct dc_sink *dc_sink;
 	struct amdgpu_device *adev = connector->dev->dev_private;
 	struct dc_validation_set val_set = { 0 };
 	/* TODO: Unhardcode stream count */
@@ -1679,7 +1679,7 @@ int dm_create_validation_set_for_connector(struct drm_connector *connector,
 		struct drm_display_mode *mode, struct dc_validation_set *val_set)
 {
 	int result = MODE_ERROR;
-	const struct dc_sink *dc_sink =
+	struct dc_sink *dc_sink =
 			to_amdgpu_connector(connector)->dc_sink;
 	/* TODO: Unhardcode stream count */
 	struct dc_stream *stream;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 73740e2a5819..30374ffaae0b 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -939,7 +939,7 @@ static bool dc_commit_context_no_check(struct dc *dc, struct validate_context *c
 	program_timing_sync(core_dc, context);
 
 	for (i = 0; i < context->stream_count; i++) {
-		const struct core_sink *sink = context->streams[i]->sink;
+		const struct dc_sink *sink = context->streams[i]->sink;
 
 		for (j = 0; j < context->stream_status[i].surface_count; j++) {
 			const struct dc_surface *surface =
@@ -1984,7 +1984,7 @@ void dc_link_set_sink(struct dc_link *link, struct dc_sink *sink)
 	}
 }
 
-void dc_link_remove_remote_sink(struct dc_link *link, const struct dc_sink *sink)
+void dc_link_remove_remote_sink(struct dc_link *link, struct dc_sink *sink)
 {
 	int i;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index 428dbff8505b..e7062069d9a1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -541,8 +541,7 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 	struct audio_support *aud_support = &link->dc->res_pool->audio_support;
 	enum dc_edid_status edid_status;
 	struct dc_context *dc_ctx = link->ctx;
-	struct dc_sink *dc_sink;
-	struct core_sink *sink = NULL;
+	struct dc_sink *sink;
 	enum dc_connection_type new_connection_type = dc_connection_none;
 
 	if (link->connector_signal == SIGNAL_TYPE_VIRTUAL)
@@ -637,22 +636,21 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 		sink_init_data.link = link;
 		sink_init_data.sink_signal = sink_caps.signal;
 
-		dc_sink = dc_sink_create(&sink_init_data);
-		if (!dc_sink) {
+		sink = dc_sink_create(&sink_init_data);
+		if (!sink) {
 			DC_ERROR("Failed to create sink!\n");
 			return false;
 		}
 
-		dc_sink->dongle_max_pix_clk = sink_caps.max_hdmi_pixel_clock;
-		dc_sink->converter_disable_audio = converter_disable_audio;
+		sink->dongle_max_pix_clk = sink_caps.max_hdmi_pixel_clock;
+		sink->converter_disable_audio = converter_disable_audio;
 
-		sink = DC_SINK_TO_CORE(dc_sink);
-		link->local_sink = &sink->public;
+		link->local_sink = sink;
 
 		edid_status = dm_helpers_read_local_edid(
 				link->ctx,
 				link,
-				&sink->public);
+				sink);
 
 		switch (edid_status) {
 		case EDID_BAD_CHECKSUM:
@@ -669,16 +667,16 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 		}
 
 		/* HDMI-DVI Dongle */
-		if (dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A &&
-				!dc_sink->edid_caps.edid_hdmi)
-			dc_sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
+		if (sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A &&
+				!sink->edid_caps.edid_hdmi)
+			sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
 
 		/* Connectivity log: detection */
-		for (i = 0; i < sink->public.dc_edid.length / EDID_BLOCK_SIZE; i++) {
+		for (i = 0; i < sink->dc_edid.length / EDID_BLOCK_SIZE; i++) {
 			CONN_DATA_DETECT(link,
-					&sink->public.dc_edid.raw_edid[i * EDID_BLOCK_SIZE],
+					&sink->dc_edid.raw_edid[i * EDID_BLOCK_SIZE],
 					EDID_BLOCK_SIZE,
-					"%s: [Block %d] ", sink->public.edid_caps.display_name, i);
+					"%s: [Block %d] ", sink->edid_caps.display_name, i);
 		}
 
 		dm_logger_write(link->ctx->logger, LOG_DETECTION_EDID_PARSER,
@@ -692,16 +690,16 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 			"speaker_flag = %d, "
 			"audio_mode_count = %d\n",
 			__func__,
-			sink->public.edid_caps.manufacturer_id,
-			sink->public.edid_caps.product_id,
-			sink->public.edid_caps.serial_number,
-			sink->public.edid_caps.manufacture_week,
-			sink->public.edid_caps.manufacture_year,
-			sink->public.edid_caps.display_name,
-			sink->public.edid_caps.speaker_flags,
-			sink->public.edid_caps.audio_mode_count);
-
-		for (i = 0; i < sink->public.edid_caps.audio_mode_count; i++) {
+			sink->edid_caps.manufacturer_id,
+			sink->edid_caps.product_id,
+			sink->edid_caps.serial_number,
+			sink->edid_caps.manufacture_week,
+			sink->edid_caps.manufacture_year,
+			sink->edid_caps.display_name,
+			sink->edid_caps.speaker_flags,
+			sink->edid_caps.audio_mode_count);
+
+		for (i = 0; i < sink->edid_caps.audio_mode_count; i++) {
 			dm_logger_write(link->ctx->logger, LOG_DETECTION_EDID_PARSER,
 				"%s: mode number = %d, "
 				"format_code = %d, "
@@ -710,10 +708,10 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 				"sample_size = %d\n",
 				__func__,
 				i,
-				sink->public.edid_caps.audio_modes[i].format_code,
-				sink->public.edid_caps.audio_modes[i].channel_count,
-				sink->public.edid_caps.audio_modes[i].sample_rate,
-				sink->public.edid_caps.audio_modes[i].sample_size);
+				sink->edid_caps.audio_modes[i].format_code,
+				sink->edid_caps.audio_modes[i].channel_count,
+				sink->edid_caps.audio_modes[i].sample_rate,
+				sink->edid_caps.audio_modes[i].sample_size);
 		}
 
 	} else {
@@ -732,7 +730,7 @@ bool dc_link_detect(struct dc_link *link, bool boot)
 	}
 
 	LINK_INFO("link=%d, dc_sink_in=%p is now %s\n",
-		link->link_index, &sink->public,
+		link->link_index, sink,
 		(sink_caps.signal == SIGNAL_TYPE_NONE ?
 			"Disconnected":"Connected"));
 
@@ -1347,7 +1345,7 @@ enum dc_status dc_link_validate_mode_timing(
 		struct dc_link *link,
 		const struct dc_crtc_timing *timing)
 {
-	uint32_t max_pix_clk = stream->sink->public.dongle_max_pix_clk;
+	uint32_t max_pix_clk = stream->sink->dongle_max_pix_clk;
 
 	/* A hack to avoid failing any modes for EDID override feature on
 	 * topology change such as lower quality cable for DP or different dongle
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index ec4714eab2be..71723fbda7f8 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -1528,7 +1528,7 @@ enum dc_status resource_map_pool_resources(
 			pipe_ctx->stream_enc);
 
 		/* TODO: Add check if ASIC support and EDID audio */
-		if (!stream->sink->public.converter_disable_audio &&
+		if (!stream->sink->converter_disable_audio &&
 			dc_is_audio_capable_signal(pipe_ctx->stream->signal) &&
 			stream->public.audio_info.mode_count) {
 			pipe_ctx->audio = find_first_free_audio(
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index 1f7985ad5dba..a83f1243a9d1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -31,15 +31,15 @@
  * Private functions
  ******************************************************************************/
 
-static void destruct(struct core_sink *sink)
+static void destruct(struct dc_sink *sink)
 {
-	if (sink->public.dc_container_id) {
-		dm_free(sink->public.dc_container_id);
-		sink->public.dc_container_id = NULL;
+	if (sink->dc_container_id) {
+		dm_free(sink->dc_container_id);
+		sink->dc_container_id = NULL;
 	}
 }
 
-static bool construct(struct core_sink *sink, const struct dc_sink_init_data *init_params)
+static bool construct(struct dc_sink *sink, const struct dc_sink_init_data *init_params)
 {
 
 	struct dc_link *link = init_params->link;
@@ -47,12 +47,12 @@ static bool construct(struct core_sink *sink, const struct dc_sink_init_data *in
 	if (!link)
 		return false;
 
-	sink->public.sink_signal = init_params->sink_signal;
+	sink->sink_signal = init_params->sink_signal;
 	sink->link = link;
 	sink->ctx = link->ctx;
-	sink->public.dongle_max_pix_clk = init_params->dongle_max_pix_clk;
-	sink->public.converter_disable_audio = init_params->converter_disable_audio;
-	sink->public.dc_container_id = NULL;
+	sink->dongle_max_pix_clk = init_params->dongle_max_pix_clk;
+	sink->converter_disable_audio = init_params->converter_disable_audio;
+	sink->dc_container_id = NULL;
 
 	return true;
 }
@@ -61,18 +61,14 @@ static bool construct(struct core_sink *sink, const struct dc_sink_init_data *in
  * Public functions
  ******************************************************************************/
 
-void dc_sink_retain(const struct dc_sink *dc_sink)
+void dc_sink_retain(struct dc_sink *sink)
 {
-	struct core_sink *sink = DC_SINK_TO_CORE(dc_sink);
-
 	ASSERT(sink->ref_count > 0);
 	++sink->ref_count;
 }
 
-void dc_sink_release(const struct dc_sink *dc_sink)
+void dc_sink_release(struct dc_sink *sink)
 {
-	struct core_sink *sink = DC_SINK_TO_CORE(dc_sink);
-
 	ASSERT(sink->ref_count > 0);
 	--sink->ref_count;
 
@@ -84,7 +80,7 @@ void dc_sink_release(const struct dc_sink *dc_sink)
 
 struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
 {
-	struct core_sink *sink = dm_alloc(sizeof(*sink));
+	struct dc_sink *sink = dm_alloc(sizeof(*sink));
 
 	if (NULL == sink)
 		goto alloc_fail;
@@ -94,7 +90,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
 
 	++sink->ref_count;
 
-	return &sink->public;
+	return sink;
 
 construct_fail:
 	dm_free(sink);
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index a329709de360..5b356ddf5614 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -46,11 +46,11 @@ struct stream {
  ******************************************************************************/
 
 static bool construct(struct core_stream *stream,
-	const struct dc_sink *dc_sink_data)
+	struct dc_sink *dc_sink_data)
 {
 	uint32_t i = 0;
 
-	stream->sink = DC_SINK_TO_CORE(dc_sink_data);
+	stream->sink = dc_sink_data;
 	stream->ctx = stream->sink->ctx;
 	stream->public.sink = dc_sink_data;
 
@@ -97,7 +97,7 @@ static bool construct(struct core_stream *stream,
 
 static void destruct(struct core_stream *stream)
 {
-	dc_sink_release(&stream->sink->public);
+	dc_sink_release(stream->sink);
 	if (stream->public.out_transfer_func != NULL) {
 		dc_transfer_func_release(
 				stream->public.out_transfer_func);
@@ -130,9 +130,8 @@ void dc_stream_release(const struct dc_stream *public)
 }
 
 struct dc_stream *dc_create_stream_for_sink(
-		const struct dc_sink *dc_sink)
+		struct dc_sink *sink)
 {
-	struct core_sink *sink = DC_SINK_TO_CORE(dc_sink);
 	struct stream *stream;
 
 	if (sink == NULL)
@@ -143,7 +142,7 @@ struct dc_stream *dc_create_stream_for_sink(
 	if (NULL == stream)
 		goto alloc_fail;
 
-	if (false == construct(&stream->protected, dc_sink))
+	if (false == construct(&stream->protected, sink))
 			goto construct_fail;
 
 	stream->ref_count++;
@@ -350,8 +349,8 @@ void dc_stream_log(
 	dm_logger_write(dm_logger,
 			log_type,
 			"\tsink name: %s, serial: %d\n",
-			core_stream->sink->public.edid_caps.display_name,
-			core_stream->sink->public.edid_caps.serial_number);
+			core_stream->sink->edid_caps.display_name,
+			core_stream->sink->edid_caps.serial_number);
 	dm_logger_write(dm_logger,
 			log_type,
 			"\tlink: %d\n",
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index e15e8fb1eefe..77bd54659a8b 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -629,7 +629,7 @@ bool dc_enable_stereo(
 /**
  * Create a new default stream for the requested sink
  */
-struct dc_stream *dc_create_stream_for_sink(const struct dc_sink *dc_sink);
+struct dc_stream *dc_create_stream_for_sink(struct dc_sink *dc_sink);
 
 void dc_stream_retain(const struct dc_stream *dc_stream);
 void dc_stream_release(const struct dc_stream *dc_stream);
@@ -712,9 +712,9 @@ struct link_mst_stream_allocation_table {
  * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
  */
 struct dc_link {
-	const struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
+	struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
 	unsigned int sink_count;
-	const struct dc_sink *local_sink;
+	struct dc_sink *local_sink;
 	unsigned int link_index;
 	enum dc_connection_type type;
 	enum signal_type connector_signal;
@@ -825,7 +825,7 @@ struct dc_sink *dc_link_add_remote_sink(
 
 void dc_link_remove_remote_sink(
 	struct dc_link *link,
-	const struct dc_sink *sink);
+	struct dc_sink *sink);
 
 /* Used by diagnostics for virtual link at the moment */
 void dc_link_set_sink(struct dc_link *link, struct dc_sink *sink);
@@ -879,10 +879,17 @@ struct dc_sink {
 	void *priv;
 	struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
 	bool converter_disable_audio;
+
+	/* private to DC core */
+	struct dc_link *link;
+	struct dc_context *ctx;
+
+	/* private to dc_sink.c */
+	int ref_count;
 };
 
-void dc_sink_retain(const struct dc_sink *sink);
-void dc_sink_release(const struct dc_sink *sink);
+void dc_sink_retain(struct dc_sink *sink);
+void dc_sink_release(struct dc_sink *sink);
 
 const struct audio **dc_get_audios(struct dc *dc);
 
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 fe8084e290a3..58701fdb7c94 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
@@ -657,7 +657,7 @@ static enum dc_status bios_parser_crtc_source_select(
 	 * encoder block
 	 * note: video bios clears all FMT setting here. */
 	struct bp_crtc_source_select crtc_source_select = {0};
-	const struct core_sink *sink = pipe_ctx->stream->sink;
+	const struct dc_sink *sink = pipe_ctx->stream->sink;
 
 	crtc_source_select.engine_id = pipe_ctx->stream_enc->id;
 	crtc_source_select.controller_id = pipe_ctx->pipe_idx + 1;
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
index eed31a827a90..1d733c837854 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
@@ -68,7 +68,7 @@ struct core_stream {
 
 	/* field internal to DC */
 	struct dc_context *ctx;
-	const struct core_sink *sink;
+	struct dc_sink *sink;
 
 	/* used by DCP and FMT */
 	struct bit_depth_reduction_params bit_depth_params;
@@ -80,25 +80,6 @@ struct core_stream {
 	struct dc_stream_status status;
 };
 
-/************ core_sink *****************/
-
-#define DC_SINK_TO_CORE(dc_sink) \
-	container_of(dc_sink, struct core_sink, public)
-
-struct core_sink {
-	/** The public, read-only (for DM) area of sink. **/
-	struct dc_sink public;
-	/** End-of-public area. **/
-
-	/** The 'protected' area - read/write access, for use only inside DC **/
-	/* not used for now */
-	struct dc_link *link;
-	struct dc_context *ctx;
-
-	/* private to dc_sink.c */
-	int ref_count;
-};
-
 /************ link *****************/
 struct link_init_data {
 	const struct core_dc *dc;
-- 
2.11.0



More information about the amd-gfx mailing list