drm/amd/display: Add function to copy DC streams
authorWenjing Liu <Wenjing.Liu@amd.com>
Fri, 29 Mar 2019 22:22:16 +0000 (18:22 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Apr 2019 22:27:45 +0000 (17:27 -0500)
We'll need the ability to copy a dc_stream_state for some features.
Implement it here.

Signed-off-by: Wenjing Liu <Wenjing.Liu@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_stream.c
drivers/gpu/drm/amd/display/dc/dc_stream.h

index e10479d58c11ecae0c988044f4d1258690a62e4b..09d765f359b0cd26e7f99a54845b1809ba3d0cc6 100644 (file)
@@ -163,6 +163,27 @@ struct dc_stream_state *dc_create_stream_for_sink(
        return stream;
 }
 
+struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream)
+{
+       struct dc_stream_state *new_stream;
+
+       new_stream = kzalloc(sizeof(struct dc_stream_state), GFP_KERNEL);
+       if (stream == NULL)
+               return NULL;
+
+       memcpy(new_stream, stream, sizeof(struct dc_stream_state));
+
+       if (new_stream->sink)
+               dc_sink_retain(new_stream->sink);
+
+       if (new_stream->out_transfer_func)
+               dc_transfer_func_retain(new_stream->out_transfer_func);
+
+       kref_init(&new_stream->refcount);
+
+       return new_stream;
+}
+
 /**
  * dc_stream_get_status_from_state - Get stream status from given dc state
  * @state: DC state to find the stream status in
index 17fa3bf6cf7b03a1f4d930b33608bf05f83eddd5..189bdab929a55651c40245c3de205c6ef65b5fdb 100644 (file)
@@ -307,6 +307,8 @@ enum surface_update_type dc_check_update_surfaces_for_stream(
  */
 struct dc_stream_state *dc_create_stream_for_sink(struct dc_sink *dc_sink);
 
+struct dc_stream_state *dc_copy_stream(const struct dc_stream_state *stream);
+
 void update_stream_signal(struct dc_stream_state *stream, struct dc_sink *sink);
 
 void dc_stream_retain(struct dc_stream_state *dc_stream);