Release 4.17 drivers/gpu/drm/amd/display/dc/core/dc_stream.c
  
  
  
/*
 * Copyright 2012-15 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */
#include "dm_services.h"
#include "dc.h"
#include "core_types.h"
#include "resource.h"
#include "ipp.h"
#include "timing_generator.h"
/*******************************************************************************
 * Private functions
 ******************************************************************************/
void update_stream_signal(struct dc_stream_state *stream)
{
	struct dc_sink *dc_sink = stream->sink;
	if (dc_sink->sink_signal == SIGNAL_TYPE_NONE)
		stream->signal = stream->sink->link->connector_signal;
	else
		stream->signal = dc_sink->sink_signal;
	if (dc_is_dvi_signal(stream->signal)) {
		if (stream->ctx->dc->caps.dual_link_dvi &&
		    stream->timing.pix_clk_khz > TMDS_MAX_PIXEL_CLOCK &&
		    stream->sink->sink_signal != SIGNAL_TYPE_DVI_SINGLE_LINK)
			stream->signal = SIGNAL_TYPE_DVI_DUAL_LINK;
		else
			stream->signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
	}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Jerry (Fangzhi) Zuo | 89 | 89.00% | 1 | 33.33% | 
| Harry Wentland | 11 | 11.00% | 2 | 66.67% | 
| Total | 100 | 100.00% | 3 | 100.00% | 
static void construct(struct dc_stream_state *stream,
	struct dc_sink *dc_sink_data)
{
	uint32_t i = 0;
	stream->sink = dc_sink_data;
	stream->ctx = stream->sink->ctx;
	dc_sink_retain(dc_sink_data);
	/* Copy audio modes */
	/* TODO - Remove this translation */
	for (i = 0; i < (dc_sink_data->edid_caps.audio_mode_count); i++)
	{
		stream->audio_info.modes[i].channel_count = dc_sink_data->edid_caps.audio_modes[i].channel_count;
		stream->audio_info.modes[i].format_code = dc_sink_data->edid_caps.audio_modes[i].format_code;
		stream->audio_info.modes[i].sample_rates.all = dc_sink_data->edid_caps.audio_modes[i].sample_rate;
		stream->audio_info.modes[i].sample_size = dc_sink_data->edid_caps.audio_modes[i].sample_size;
	}
	stream->audio_info.mode_count = dc_sink_data->edid_caps.audio_mode_count;
	stream->audio_info.audio_latency = dc_sink_data->edid_caps.audio_latency;
	stream->audio_info.video_latency = dc_sink_data->edid_caps.video_latency;
	memmove(
		stream->audio_info.display_name,
		dc_sink_data->edid_caps.display_name,
		AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
	stream->audio_info.manufacture_id = dc_sink_data->edid_caps.manufacturer_id;
	stream->audio_info.product_id = dc_sink_data->edid_caps.product_id;
	stream->audio_info.flags.all = dc_sink_data->edid_caps.speaker_flags;
	if (dc_sink_data->dc_container_id != NULL) {
		struct dc_container_id *dc_container_id = dc_sink_data->dc_container_id;
		stream->audio_info.port_id[0] = dc_container_id->portId[0];
		stream->audio_info.port_id[1] = dc_container_id->portId[1];
	} else {
		/* TODO - WindowDM has implemented,
                other DMs need Unhardcode port_id */
		stream->audio_info.port_id[0] = 0x5558859e;
		stream->audio_info.port_id[1] = 0xd989449;
	}
	/* EDID CAP translation for HDMI 2.0 */
	stream->timing.flags.LTE_340MCSC_SCRAMBLE = dc_sink_data->edid_caps.lte_340mcsc_scramble;
	stream->status.link = stream->sink->link;
	update_stream_signal(stream);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Harry Wentland | 294 | 82.82% | 2 | 40.00% | 
| Duke Du | 55 | 15.49% | 1 | 20.00% | 
| Jerry (Fangzhi) Zuo | 5 | 1.41% | 1 | 20.00% | 
| Dave Airlie | 1 | 0.28% | 1 | 20.00% | 
| Total | 355 | 100.00% | 5 | 100.00% | 
static void destruct(struct dc_stream_state *stream)
{
	dc_sink_release(stream->sink);
	if (stream->out_transfer_func != NULL) {
		dc_transfer_func_release(
				stream->out_transfer_func);
		stream->out_transfer_func = NULL;
	}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Harry Wentland | 18 | 43.90% | 2 | 50.00% | 
| Anthony Koo | 15 | 36.59% | 1 | 25.00% | 
| Yongqiang Sun | 8 | 19.51% | 1 | 25.00% | 
| Total | 41 | 100.00% | 4 | 100.00% | 
void dc_stream_retain(struct dc_stream_state *stream)
{
	kref_get(&stream->refcount);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Harry Wentland | 8 | 44.44% | 2 | 33.33% | 
| Dave Airlie | 4 | 22.22% | 1 | 16.67% | 
| Jerry (Fangzhi) Zuo | 3 | 16.67% | 1 | 16.67% | 
| Andrey Grodzovsky | 2 | 11.11% | 1 | 16.67% | 
| Leo (Sunpeng) Li | 1 | 5.56% | 1 | 16.67% | 
| Total | 18 | 100.00% | 6 | 100.00% | 
static void dc_stream_free(struct kref *kref)
{
	struct dc_stream_state *stream = container_of(kref, struct dc_stream_state, refcount);
	destruct(stream);
	kfree(stream);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Dave Airlie | 29 | 80.56% | 1 | 25.00% | 
| Harry Wentland | 3 | 8.33% | 1 | 25.00% | 
| Jerry (Fangzhi) Zuo | 2 | 5.56% | 1 | 25.00% | 
| Andrey Grodzovsky | 2 | 5.56% | 1 | 25.00% | 
| Total | 36 | 100.00% | 4 | 100.00% | 
void dc_stream_release(struct dc_stream_state *stream)
{
	if (stream != NULL) {
		kref_put(&stream->refcount, dc_stream_free);
	}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Harry Wentland | 18 | 64.29% | 2 | 33.33% | 
| Dave Airlie | 4 | 14.29% | 1 | 16.67% | 
| Andrey Grodzovsky | 2 | 7.14% | 1 | 16.67% | 
| Leo (Sunpeng) Li | 2 | 7.14% | 1 | 16.67% | 
| Jerry (Fangzhi) Zuo | 2 | 7.14% | 1 | 16.67% | 
| Total | 28 | 100.00% | 6 | 100.00% | 
struct dc_stream_state *dc_create_stream_for_sink(
		struct dc_sink *sink)
{
	struct dc_stream_state *stream;
	if (sink == NULL)
		return NULL;
	stream = kzalloc(sizeof(struct dc_stream_state), GFP_KERNEL);
	if (stream == NULL)
		return NULL;
	construct(stream, sink);
	kref_init(&stream->refcount);
	return stream;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Harry Wentland | 52 | 78.79% | 4 | 57.14% | 
| Dave Airlie | 11 | 16.67% | 2 | 28.57% | 
| Jerry (Fangzhi) Zuo | 3 | 4.55% | 1 | 14.29% | 
| Total | 66 | 100.00% | 7 | 100.00% | 
struct dc_stream_status *dc_stream_get_status(
	struct dc_stream_state *stream)
{
	uint8_t i;
	struct dc  *dc = stream->ctx->dc;
	for (i = 0; i < dc->current_state->stream_count; i++) {
		if (stream == dc->current_state->streams[i])
			return &dc->current_state->stream_status[i];
	}
	return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 64 | 88.89% | 1 | 16.67% | 
| Jerry (Fangzhi) Zuo | 3 | 4.17% | 1 | 16.67% | 
| Harry Wentland | 3 | 4.17% | 2 | 33.33% | 
| Bhawanpreet Lakha | 1 | 1.39% | 1 | 16.67% | 
| Leo (Sunpeng) Li | 1 | 1.39% | 1 | 16.67% | 
| Total | 72 | 100.00% | 6 | 100.00% | 
/**
 * Update the cursor attributes and set cursor surface address
 */
bool dc_stream_set_cursor_attributes(
	struct dc_stream_state *stream,
	const struct dc_cursor_attributes *attributes)
{
	int i;
	struct dc  *core_dc;
	struct resource_context *res_ctx;
	if (NULL == stream) {
		dm_error("DC: dc_stream is NULL!\n");
		return false;
	}
	if (NULL == attributes) {
		dm_error("DC: attributes is NULL!\n");
		return false;
	}
	if (attributes->address.quad_part == 0) {
		dm_output_to_console("DC: Cursor address is 0!\n");
		return false;
	}
	core_dc = stream->ctx->dc;
	res_ctx = &core_dc->current_state->res_ctx;
	stream->cursor_attributes = *attributes;
	for (i = 0; i < MAX_PIPES; i++) {
		struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
		if (pipe_ctx->stream != stream)
			continue;
		if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state)
			continue;
		core_dc->hwss.set_cursor_attribute(pipe_ctx);
	}
	return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 110 | 64.33% | 1 | 8.33% | 
| Yongqiang Sun | 19 | 11.11% | 1 | 8.33% | 
| Dmytro Laktyushkin | 17 | 9.94% | 1 | 8.33% | 
| Eric Yang | 10 | 5.85% | 1 | 8.33% | 
| Yue Hin Lau | 6 | 3.51% | 1 | 8.33% | 
| Harry Wentland | 3 | 1.75% | 2 | 16.67% | 
| Leo (Sunpeng) Li | 2 | 1.17% | 1 | 8.33% | 
| Leon Elazar | 1 | 0.58% | 1 | 8.33% | 
| Andrew Jiang | 1 | 0.58% | 1 | 8.33% | 
| Bhawanpreet Lakha | 1 | 0.58% | 1 | 8.33% | 
| Jerry (Fangzhi) Zuo | 1 | 0.58% | 1 | 8.33% | 
| Total | 171 | 100.00% | 12 | 100.00% | 
bool dc_stream_set_cursor_position(
	struct dc_stream_state *stream,
	const struct dc_cursor_position *position)
{
	int i;
	struct dc  *core_dc;
	struct resource_context *res_ctx;
	if (NULL == stream) {
		dm_error("DC: dc_stream is NULL!\n");
		return false;
	}
	if (NULL == position) {
		dm_error("DC: cursor position is NULL!\n");
		return false;
	}
	core_dc = stream->ctx->dc;
	res_ctx = &core_dc->current_state->res_ctx;
	stream->cursor_position = *position;
	for (i = 0; i < MAX_PIPES; i++) {
		struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
		if (pipe_ctx->stream != stream ||
				(!pipe_ctx->plane_res.mi  && !pipe_ctx->plane_res.hubp) ||
				!pipe_ctx->plane_state ||
				(!pipe_ctx->plane_res.xfm && !pipe_ctx->plane_res.dpp) ||
				!pipe_ctx->plane_res.ipp)
			continue;
		core_dc->hwss.set_cursor_position(pipe_ctx);
	}
	return true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 102 | 57.30% | 1 | 6.67% | 
| Yue Hin Lau | 30 | 16.85% | 4 | 26.67% | 
| Dmytro Laktyushkin | 16 | 8.99% | 1 | 6.67% | 
| Eric Yang | 10 | 5.62% | 1 | 6.67% | 
| Shirish S | 7 | 3.93% | 1 | 6.67% | 
| Yongqiang Sun | 5 | 2.81% | 1 | 6.67% | 
| Harry Wentland | 4 | 2.25% | 3 | 20.00% | 
| Leo (Sunpeng) Li | 2 | 1.12% | 1 | 6.67% | 
| Bhawanpreet Lakha | 1 | 0.56% | 1 | 6.67% | 
| Jerry (Fangzhi) Zuo | 1 | 0.56% | 1 | 6.67% | 
| Total | 178 | 100.00% | 15 | 100.00% | 
uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream)
{
	uint8_t i;
	struct dc  *core_dc = stream->ctx->dc;
	struct resource_context *res_ctx =
		&core_dc->current_state->res_ctx;
	for (i = 0; i < MAX_PIPES; i++) {
		struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg;
		if (res_ctx->pipe_ctx[i].stream != stream)
			continue;
		return tg->funcs->get_frame_count(tg);
	}
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 89 | 93.68% | 1 | 16.67% | 
| Harry Wentland | 3 | 3.16% | 2 | 33.33% | 
| Leo (Sunpeng) Li | 1 | 1.05% | 1 | 16.67% | 
| Jerry (Fangzhi) Zuo | 1 | 1.05% | 1 | 16.67% | 
| Bhawanpreet Lakha | 1 | 1.05% | 1 | 16.67% | 
| Total | 95 | 100.00% | 6 | 100.00% | 
bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
				  uint32_t *v_blank_start,
				  uint32_t *v_blank_end,
				  uint32_t *h_position,
				  uint32_t *v_position)
{
	uint8_t i;
	bool ret = false;
	struct dc  *core_dc = stream->ctx->dc;
	struct resource_context *res_ctx =
		&core_dc->current_state->res_ctx;
	for (i = 0; i < MAX_PIPES; i++) {
		struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg;
		if (res_ctx->pipe_ctx[i].stream != stream)
			continue;
		tg->funcs->get_scanoutpos(tg,
					  v_blank_start,
					  v_blank_end,
					  h_position,
					  v_position);
		ret = true;
		break;
	}
	return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 93 | 72.66% | 1 | 14.29% | 
| Sylvia Tsai | 29 | 22.66% | 1 | 14.29% | 
| Harry Wentland | 3 | 2.34% | 2 | 28.57% | 
| Leo (Sunpeng) Li | 1 | 0.78% | 1 | 14.29% | 
| Bhawanpreet Lakha | 1 | 0.78% | 1 | 14.29% | 
| Jerry (Fangzhi) Zuo | 1 | 0.78% | 1 | 14.29% | 
| Total | 128 | 100.00% | 7 | 100.00% | 
void dc_stream_log(
	const struct dc_stream_state *stream,
	struct dal_logger *dm_logger,
	enum dc_log_type log_type)
{
	dm_logger_write(dm_logger,
			log_type,
			"core_stream 0x%x: src: %d, %d, %d, %d; dst: %d, %d, %d, %d, colorSpace:%d\n",
			stream,
			stream->src.x,
			stream->src.y,
			stream->src.width,
			stream->src.height,
			stream->dst.x,
			stream->dst.y,
			stream->dst.width,
			stream->dst.height,
			stream->output_color_space);
	dm_logger_write(dm_logger,
			log_type,
			"\tpix_clk_khz: %d, h_total: %d, v_total: %d, pixelencoder:%d, displaycolorDepth:%d\n",
			stream->timing.pix_clk_khz,
			stream->timing.h_total,
			stream->timing.v_total,
			stream->timing.pixel_encoding,
			stream->timing.display_color_depth);
	dm_logger_write(dm_logger,
			log_type,
			"\tsink name: %s, serial: %d\n",
			stream->sink->edid_caps.display_name,
			stream->sink->edid_caps.serial_number);
	dm_logger_write(dm_logger,
			log_type,
			"\tlink: %d\n",
			stream->sink->link->link_index);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 130 | 79.27% | 1 | 25.00% | 
| Leo (Sunpeng) Li | 18 | 10.98% | 1 | 25.00% | 
| Charlene Liu | 15 | 9.15% | 1 | 25.00% | 
| Harry Wentland | 1 | 0.61% | 1 | 25.00% | 
| Total | 164 | 100.00% | 4 | 100.00% | 
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Aric Cyr | 595 | 40.39% | 1 | 2.78% | 
| Harry Wentland | 435 | 29.53% | 10 | 27.78% | 
| Jerry (Fangzhi) Zuo | 111 | 7.54% | 3 | 8.33% | 
| Duke Du | 55 | 3.73% | 1 | 2.78% | 
| Dave Airlie | 49 | 3.33% | 2 | 5.56% | 
| Yue Hin Lau | 36 | 2.44% | 4 | 11.11% | 
| Dmytro Laktyushkin | 33 | 2.24% | 1 | 2.78% | 
| Yongqiang Sun | 32 | 2.17% | 3 | 8.33% | 
| Sylvia Tsai | 29 | 1.97% | 1 | 2.78% | 
| Leo (Sunpeng) Li | 28 | 1.90% | 2 | 5.56% | 
| Eric Yang | 20 | 1.36% | 1 | 2.78% | 
| Anthony Koo | 15 | 1.02% | 1 | 2.78% | 
| Charlene Liu | 15 | 1.02% | 1 | 2.78% | 
| Shirish S | 7 | 0.48% | 1 | 2.78% | 
| Andrey Grodzovsky | 6 | 0.41% | 1 | 2.78% | 
| Bhawanpreet Lakha | 5 | 0.34% | 1 | 2.78% | 
| Andrew Jiang | 1 | 0.07% | 1 | 2.78% | 
| Leon Elazar | 1 | 0.07% | 1 | 2.78% | 
| Total | 1473 | 100.00% | 36 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.