Commit 5d918018 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Use drm_connector in create_stream_for_sink

[WHAT]
We need to use this function for both amdgpu_dm_connectors
and drm_writeback_connectors. Modify it to operate on
a drm_connector as a common base.
Reviewed-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0021d70a
...@@ -5598,6 +5598,7 @@ static void fill_stream_properties_from_drm_display_mode( ...@@ -5598,6 +5598,7 @@ static void fill_stream_properties_from_drm_display_mode(
&& stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) && stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
else if (drm_mode_is_420_also(info, mode_in) else if (drm_mode_is_420_also(info, mode_in)
&& aconnector
&& aconnector->force_yuv420_output) && aconnector->force_yuv420_output)
timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420; timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444) else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444)
...@@ -5633,7 +5634,7 @@ static void fill_stream_properties_from_drm_display_mode( ...@@ -5633,7 +5634,7 @@ static void fill_stream_properties_from_drm_display_mode(
timing_out->hdmi_vic = hv_frame.vic; timing_out->hdmi_vic = hv_frame.vic;
} }
if (is_freesync_video_mode(mode_in, aconnector)) { if (aconnector && is_freesync_video_mode(mode_in, aconnector)) {
timing_out->h_addressable = mode_in->hdisplay; timing_out->h_addressable = mode_in->hdisplay;
timing_out->h_total = mode_in->htotal; timing_out->h_total = mode_in->htotal;
timing_out->h_sync_width = mode_in->hsync_end - mode_in->hsync_start; timing_out->h_sync_width = mode_in->hsync_end - mode_in->hsync_start;
...@@ -6110,14 +6111,14 @@ static void apply_dsc_policy_for_stream(struct amdgpu_dm_connector *aconnector, ...@@ -6110,14 +6111,14 @@ static void apply_dsc_policy_for_stream(struct amdgpu_dm_connector *aconnector,
} }
static struct dc_stream_state * static struct dc_stream_state *
create_stream_for_sink(struct amdgpu_dm_connector *aconnector, create_stream_for_sink(struct drm_connector *connector,
const struct drm_display_mode *drm_mode, const struct drm_display_mode *drm_mode,
const struct dm_connector_state *dm_state, const struct dm_connector_state *dm_state,
const struct dc_stream_state *old_stream, const struct dc_stream_state *old_stream,
int requested_bpc) int requested_bpc)
{ {
struct amdgpu_dm_connector *aconnector = NULL;
struct drm_display_mode *preferred_mode = NULL; struct drm_display_mode *preferred_mode = NULL;
struct drm_connector *drm_connector;
const struct drm_connector_state *con_state = &dm_state->base; const struct drm_connector_state *con_state = &dm_state->base;
struct dc_stream_state *stream = NULL; struct dc_stream_state *stream = NULL;
struct drm_display_mode mode; struct drm_display_mode mode;
...@@ -6136,20 +6137,22 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6136,20 +6137,22 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
drm_mode_init(&mode, drm_mode); drm_mode_init(&mode, drm_mode);
memset(&saved_mode, 0, sizeof(saved_mode)); memset(&saved_mode, 0, sizeof(saved_mode));
if (aconnector == NULL) { if (connector == NULL) {
DRM_ERROR("aconnector is NULL!\n"); DRM_ERROR("connector is NULL!\n");
return stream; return stream;
} }
drm_connector = &aconnector->base; if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) {
aconnector = NULL;
if (!aconnector->dc_sink) { aconnector = to_amdgpu_dm_connector(connector);
sink = create_fake_sink(aconnector); if (!aconnector->dc_sink) {
if (!sink) sink = create_fake_sink(aconnector);
return stream; if (!sink)
} else { return stream;
sink = aconnector->dc_sink; } else {
dc_sink_retain(sink); sink = aconnector->dc_sink;
dc_sink_retain(sink);
}
} }
stream = dc_create_stream_for_sink(sink); stream = dc_create_stream_for_sink(sink);
...@@ -6159,12 +6162,13 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6159,12 +6162,13 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
goto finish; goto finish;
} }
/* We leave this NULL for writeback connectors */
stream->dm_stream_context = aconnector; stream->dm_stream_context = aconnector;
stream->timing.flags.LTE_340MCSC_SCRAMBLE = stream->timing.flags.LTE_340MCSC_SCRAMBLE =
drm_connector->display_info.hdmi.scdc.scrambling.low_rates; connector->display_info.hdmi.scdc.scrambling.low_rates;
list_for_each_entry(preferred_mode, &aconnector->base.modes, head) { list_for_each_entry(preferred_mode, &connector->modes, head) {
/* Search for preferred mode */ /* Search for preferred mode */
if (preferred_mode->type & DRM_MODE_TYPE_PREFERRED) { if (preferred_mode->type & DRM_MODE_TYPE_PREFERRED) {
native_mode_found = true; native_mode_found = true;
...@@ -6173,7 +6177,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6173,7 +6177,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
} }
if (!native_mode_found) if (!native_mode_found)
preferred_mode = list_first_entry_or_null( preferred_mode = list_first_entry_or_null(
&aconnector->base.modes, &connector->modes,
struct drm_display_mode, struct drm_display_mode,
head); head);
...@@ -6187,7 +6191,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6187,7 +6191,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
* and the modelist may not be filled in time. * and the modelist may not be filled in time.
*/ */
DRM_DEBUG_DRIVER("No preferred mode found\n"); DRM_DEBUG_DRIVER("No preferred mode found\n");
} else { } else if (aconnector) {
recalculate_timing = is_freesync_video_mode(&mode, aconnector); recalculate_timing = is_freesync_video_mode(&mode, aconnector);
if (recalculate_timing) { if (recalculate_timing) {
freesync_mode = get_highest_refresh_rate_mode(aconnector, false); freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
...@@ -6210,13 +6214,17 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6210,13 +6214,17 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
*/ */
if (!scale || mode_refresh != preferred_refresh) if (!scale || mode_refresh != preferred_refresh)
fill_stream_properties_from_drm_display_mode( fill_stream_properties_from_drm_display_mode(
stream, &mode, &aconnector->base, con_state, NULL, stream, &mode, connector, con_state, NULL,
requested_bpc); requested_bpc);
else else
fill_stream_properties_from_drm_display_mode( fill_stream_properties_from_drm_display_mode(
stream, &mode, &aconnector->base, con_state, old_stream, stream, &mode, connector, con_state, old_stream,
requested_bpc); requested_bpc);
/* The rest isn't needed for writeback connectors */
if (!aconnector)
goto finish;
if (aconnector->timing_changed) { if (aconnector->timing_changed) {
drm_dbg(aconnector->base.dev, drm_dbg(aconnector->base.dev,
"overriding timing for automated test, bpc %d, changing to %d\n", "overriding timing for automated test, bpc %d, changing to %d\n",
...@@ -6234,7 +6242,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6234,7 +6242,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
fill_audio_info( fill_audio_info(
&stream->audio_info, &stream->audio_info,
drm_connector, connector,
sink); sink);
update_stream_signal(stream, sink); update_stream_signal(stream, sink);
...@@ -6697,7 +6705,7 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -6697,7 +6705,7 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
enum dc_status dc_result = DC_OK; enum dc_status dc_result = DC_OK;
do { do {
stream = create_stream_for_sink(aconnector, drm_mode, stream = create_stream_for_sink(connector, drm_mode,
dm_state, old_stream, dm_state, old_stream,
requested_bpc); requested_bpc);
if (stream == NULL) { if (stream == NULL) {
...@@ -9450,15 +9458,16 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, ...@@ -9450,15 +9458,16 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
acrtc = to_amdgpu_crtc(crtc); acrtc = to_amdgpu_crtc(crtc);
connector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc); connector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
aconnector = to_amdgpu_dm_connector(connector); if (connector && connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
aconnector = to_amdgpu_dm_connector(connector);
/* TODO This hack should go away */ /* TODO This hack should go away */
if (aconnector && enable) { if (connector && enable) {
/* Make sure fake sink is created in plug-in scenario */ /* Make sure fake sink is created in plug-in scenario */
drm_new_conn_state = drm_atomic_get_new_connector_state(state, drm_new_conn_state = drm_atomic_get_new_connector_state(state,
&aconnector->base); connector);
drm_old_conn_state = drm_atomic_get_old_connector_state(state, drm_old_conn_state = drm_atomic_get_old_connector_state(state,
&aconnector->base); connector);
if (IS_ERR(drm_new_conn_state)) { if (IS_ERR(drm_new_conn_state)) {
ret = PTR_ERR_OR_ZERO(drm_new_conn_state); ret = PTR_ERR_OR_ZERO(drm_new_conn_state);
...@@ -9605,7 +9614,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, ...@@ -9605,7 +9614,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
* added MST connectors not found in existing crtc_state in the chained mode * added MST connectors not found in existing crtc_state in the chained mode
* TODO: need to dig out the root cause of that * TODO: need to dig out the root cause of that
*/ */
if (!aconnector) if (!connector)
goto skip_modeset; goto skip_modeset;
if (modereset_required(new_crtc_state)) if (modereset_required(new_crtc_state))
...@@ -9648,7 +9657,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, ...@@ -9648,7 +9657,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
* We want to do dc stream updates that do not require a * We want to do dc stream updates that do not require a
* full modeset below. * full modeset below.
*/ */
if (!(enable && aconnector && new_crtc_state->active)) if (!(enable && connector && new_crtc_state->active))
return 0; return 0;
/* /*
* Given above conditions, the dc state cannot be NULL because: * Given above conditions, the dc state cannot be NULL because:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment