Commit d4e13b0d authored by Alex Deucher's avatar Alex Deucher

drm/amd/display: decouple per-crtc-plane model

Current design has per-crtc-plane model.
As a result, for asic's that support underlay,
are unable to expose it to user space for modesetting.

To enable this, the drm driver intialisation now runs
for number of surfaces instead of stream/crtc.

This patch plumbs surface capabilities to drm framework
so that it can be effectively used by user space.

Tests: (On Chromium OS for Stoney Only)
* 'modetest -p'  now shows additional plane
  with YUV capabilities in case of CZ and ST.
* 'plane_test' fails with below error:
  [drm:amdgpu_dm_connector_atomic_set_property [amdgpu]] *ERROR* Unsupported screen depth 0
  as ther is no support for YUYV
* Checked multimonitor display works fine
Signed-off-by: default avatarShirish S <shirish.s@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 4e3133c7
...@@ -60,6 +60,7 @@ struct amdgpu_hpd; ...@@ -60,6 +60,7 @@ struct amdgpu_hpd;
#define AMDGPU_MAX_HPD_PINS 6 #define AMDGPU_MAX_HPD_PINS 6
#define AMDGPU_MAX_CRTCS 6 #define AMDGPU_MAX_CRTCS 6
#define AMDGPU_MAX_PLANES 6
#define AMDGPU_MAX_AFMT_BLOCKS 9 #define AMDGPU_MAX_AFMT_BLOCKS 9
enum amdgpu_rmx_type { enum amdgpu_rmx_type {
...@@ -327,6 +328,7 @@ struct amdgpu_mode_info { ...@@ -327,6 +328,7 @@ struct amdgpu_mode_info {
struct card_info *atom_card_info; struct card_info *atom_card_info;
bool mode_config_initialized; bool mode_config_initialized;
struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS]; struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS];
struct amdgpu_plane *planes[AMDGPU_MAX_PLANES];
struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS]; struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS];
/* DVI-I properties */ /* DVI-I properties */
struct drm_property *coherent_mode_property; struct drm_property *coherent_mode_property;
...@@ -356,6 +358,7 @@ struct amdgpu_mode_info { ...@@ -356,6 +358,7 @@ struct amdgpu_mode_info {
int num_dig; /* number of dig blocks */ int num_dig; /* number of dig blocks */
int disp_priority; int disp_priority;
const struct amdgpu_display_funcs *funcs; const struct amdgpu_display_funcs *funcs;
enum drm_plane_type *plane_type;
}; };
#define AMDGPU_MAX_BL_LEVEL 0xFF #define AMDGPU_MAX_BL_LEVEL 0xFF
...@@ -436,6 +439,11 @@ struct amdgpu_crtc { ...@@ -436,6 +439,11 @@ struct amdgpu_crtc {
struct drm_pending_vblank_event *event; struct drm_pending_vblank_event *event;
}; };
struct amdgpu_plane {
struct drm_plane base;
enum drm_plane_type plane_type;
};
struct amdgpu_encoder_atom_dig { struct amdgpu_encoder_atom_dig {
bool linkb; bool linkb;
/* atom dig */ /* atom dig */
......
...@@ -49,6 +49,28 @@ ...@@ -49,6 +49,28 @@
#include "modules/inc/mod_freesync.h" #include "modules/inc/mod_freesync.h"
static enum drm_plane_type dm_surfaces_type_default[AMDGPU_MAX_PLANES] = {
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
};
static enum drm_plane_type dm_surfaces_type_carizzo[AMDGPU_MAX_PLANES] = {
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_OVERLAY,/* YUV Capable Underlay */
};
static enum drm_plane_type dm_surfaces_type_stoney[AMDGPU_MAX_PLANES] = {
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_PRIMARY,
DRM_PLANE_TYPE_OVERLAY, /* YUV Capable Underlay */
};
/* /*
* dm_vblank_get_counter * dm_vblank_get_counter
* *
...@@ -1051,30 +1073,34 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) ...@@ -1051,30 +1073,34 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
uint32_t i; uint32_t i;
struct amdgpu_connector *aconnector; struct amdgpu_connector *aconnector;
struct amdgpu_encoder *aencoder; struct amdgpu_encoder *aencoder;
struct amdgpu_crtc *acrtc; struct amdgpu_mode_info *mode_info = &adev->mode_info;
uint32_t link_cnt; uint32_t link_cnt;
link_cnt = dm->dc->caps.max_links; link_cnt = dm->dc->caps.max_links;
if (amdgpu_dm_mode_config_init(dm->adev)) { if (amdgpu_dm_mode_config_init(dm->adev)) {
DRM_ERROR("DM: Failed to initialize mode config\n"); DRM_ERROR("DM: Failed to initialize mode config\n");
return -1; goto fail;
} }
for (i = 0; i < dm->dc->caps.max_streams; i++) { for (i = 0; i < dm->dc->caps.max_surfaces; i++) {
acrtc = kzalloc(sizeof(struct amdgpu_crtc), GFP_KERNEL); mode_info->planes[i] = kzalloc(sizeof(struct amdgpu_plane),
if (!acrtc) GFP_KERNEL);
goto fail; if (!mode_info->planes[i]) {
DRM_ERROR("KMS: Failed to allocate surface\n");
goto fail_free_planes;
}
mode_info->planes[i]->plane_type = mode_info->plane_type[i];
if (amdgpu_dm_plane_init(dm, mode_info->planes[i], 1)) {
DRM_ERROR("KMS: Failed to initialize plane\n");
goto fail_free_planes;
}
}
if (amdgpu_dm_crtc_init( for (i = 0; i < dm->dc->caps.max_streams; i++)
dm, if (amdgpu_dm_crtc_init(dm, &mode_info->planes[i]->base, i)) {
acrtc,
i)) {
DRM_ERROR("KMS: Failed to initialize crtc\n"); DRM_ERROR("KMS: Failed to initialize crtc\n");
kfree(acrtc); goto fail_free_planes;
goto fail;
} }
}
dm->display_indexes_num = dm->dc->caps.max_streams; dm->display_indexes_num = dm->dc->caps.max_streams;
...@@ -1125,12 +1151,12 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) ...@@ -1125,12 +1151,12 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
case CHIP_VEGA10: case CHIP_VEGA10:
if (dce110_register_irq_handlers(dm->adev)) { if (dce110_register_irq_handlers(dm->adev)) {
DRM_ERROR("DM: Failed to initialize IRQ\n"); DRM_ERROR("DM: Failed to initialize IRQ\n");
return -1; goto fail_free_encoder;
} }
break; break;
default: default:
DRM_ERROR("Usupported ASIC type: 0x%X\n", adev->asic_type); DRM_ERROR("Usupported ASIC type: 0x%X\n", adev->asic_type);
return -1; goto fail_free_encoder;
} }
drm_mode_config_reset(dm->ddev); drm_mode_config_reset(dm->ddev);
...@@ -1140,6 +1166,9 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) ...@@ -1140,6 +1166,9 @@ int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
kfree(aencoder); kfree(aencoder);
fail_free_connector: fail_free_connector:
kfree(aconnector); kfree(aconnector);
fail_free_planes:
for (i = 0; i < dm->dc->caps.max_surfaces; i++)
kfree(mode_info->planes[i]);
fail: fail:
return -1; return -1;
} }
...@@ -1361,33 +1390,39 @@ static int dm_early_init(void *handle) ...@@ -1361,33 +1390,39 @@ static int dm_early_init(void *handle)
adev->mode_info.num_crtc = 6; adev->mode_info.num_crtc = 6;
adev->mode_info.num_hpd = 6; adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 6; adev->mode_info.num_dig = 6;
adev->mode_info.plane_type = dm_surfaces_type_default;
break; break;
case CHIP_FIJI: case CHIP_FIJI:
case CHIP_TONGA: case CHIP_TONGA:
adev->mode_info.num_crtc = 6; adev->mode_info.num_crtc = 6;
adev->mode_info.num_hpd = 6; adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 7; adev->mode_info.num_dig = 7;
adev->mode_info.plane_type = dm_surfaces_type_default;
break; break;
case CHIP_CARRIZO: case CHIP_CARRIZO:
adev->mode_info.num_crtc = 3; adev->mode_info.num_crtc = 3;
adev->mode_info.num_hpd = 6; adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 9; adev->mode_info.num_dig = 9;
adev->mode_info.plane_type = dm_surfaces_type_carizzo;
break; break;
case CHIP_STONEY: case CHIP_STONEY:
adev->mode_info.num_crtc = 2; adev->mode_info.num_crtc = 2;
adev->mode_info.num_hpd = 6; adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 9; adev->mode_info.num_dig = 9;
adev->mode_info.plane_type = dm_surfaces_type_stoney;
break; break;
case CHIP_POLARIS11: case CHIP_POLARIS11:
case CHIP_POLARIS12: case CHIP_POLARIS12:
adev->mode_info.num_crtc = 5; adev->mode_info.num_crtc = 5;
adev->mode_info.num_hpd = 5; adev->mode_info.num_hpd = 5;
adev->mode_info.num_dig = 5; adev->mode_info.num_dig = 5;
adev->mode_info.plane_type = dm_surfaces_type_default;
break; break;
case CHIP_POLARIS10: case CHIP_POLARIS10:
adev->mode_info.num_crtc = 6; adev->mode_info.num_crtc = 6;
adev->mode_info.num_hpd = 6; adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 6; adev->mode_info.num_dig = 6;
adev->mode_info.plane_type = dm_surfaces_type_default;
break; break;
case CHIP_VEGA10: case CHIP_VEGA10:
adev->mode_info.num_crtc = 6; adev->mode_info.num_crtc = 6;
......
...@@ -1446,6 +1446,8 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = { ...@@ -1446,6 +1446,8 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
}; };
static const struct drm_plane_funcs dm_plane_funcs = { static const struct drm_plane_funcs dm_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.reset = drm_atomic_helper_plane_reset, .reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state .atomic_destroy_state = drm_atomic_helper_plane_destroy_state
...@@ -1577,38 +1579,67 @@ static uint32_t rgb_formats[] = { ...@@ -1577,38 +1579,67 @@ static uint32_t rgb_formats[] = {
DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR2101010,
}; };
int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm, static uint32_t yuv_formats[] = {
struct amdgpu_crtc *acrtc, DRM_FORMAT_YUYV,
uint32_t crtc_index) DRM_FORMAT_YVYU,
DRM_FORMAT_UYVY,
DRM_FORMAT_VYUY,
};
int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
struct amdgpu_plane *aplane,
unsigned long possible_crtcs)
{ {
int res = -ENOMEM; int res = -EPERM;
struct drm_plane *primary_plane = switch (aplane->plane_type) {
kzalloc(sizeof(*primary_plane), GFP_KERNEL); case DRM_PLANE_TYPE_PRIMARY:
aplane->base.format_default = true;
if (!primary_plane) res = drm_universal_plane_init(
goto fail_plane; dm->adev->ddev,
&aplane->base,
possible_crtcs,
&dm_plane_funcs,
rgb_formats,
ARRAY_SIZE(rgb_formats),
NULL, aplane->plane_type, NULL);
break;
case DRM_PLANE_TYPE_OVERLAY:
res = drm_universal_plane_init(
dm->adev->ddev,
&aplane->base,
possible_crtcs,
&dm_plane_funcs,
yuv_formats,
ARRAY_SIZE(yuv_formats),
NULL, aplane->plane_type, NULL);
break;
case DRM_PLANE_TYPE_CURSOR:
DRM_ERROR("KMS: Cursor plane not implemented.");
break;
}
primary_plane->format_default = true; drm_plane_helper_add(&aplane->base, &dm_plane_helper_funcs);
res = drm_universal_plane_init( return res;
dm->adev->ddev, }
primary_plane,
0,
&dm_plane_funcs,
rgb_formats,
ARRAY_SIZE(rgb_formats),
NULL,
DRM_PLANE_TYPE_PRIMARY, NULL);
primary_plane->crtc = &acrtc->base; int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
struct drm_plane *plane,
uint32_t crtc_index)
{
struct amdgpu_crtc *acrtc;
int res = -ENOMEM;
drm_plane_helper_add(primary_plane, &dm_plane_helper_funcs); acrtc = kzalloc(sizeof(struct amdgpu_crtc), GFP_KERNEL);
if (!acrtc)
goto fail;
res = drm_crtc_init_with_planes( res = drm_crtc_init_with_planes(
dm->ddev, dm->ddev,
&acrtc->base, &acrtc->base,
primary_plane, plane,
NULL, NULL,
&amdgpu_dm_crtc_funcs, NULL); &amdgpu_dm_crtc_funcs, NULL);
...@@ -1628,8 +1659,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm, ...@@ -1628,8 +1659,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
return 0; return 0;
fail: fail:
kfree(primary_plane); kfree(acrtc);
fail_plane:
acrtc->crtc_id = -1; acrtc->crtc_id = -1;
return res; return res;
} }
......
...@@ -34,8 +34,11 @@ struct dc_validation_set; ...@@ -34,8 +34,11 @@ struct dc_validation_set;
struct dc_surface; struct dc_surface;
/*TODO Jodan Hersen use the one in amdgpu_dm*/ /*TODO Jodan Hersen use the one in amdgpu_dm*/
int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
struct amdgpu_plane *aplane,
unsigned long possible_crtcs);
int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm, int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
struct amdgpu_crtc *amdgpu_crtc, struct drm_plane *plane,
uint32_t link_index); uint32_t link_index);
int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm, int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
struct amdgpu_connector *amdgpu_connector, struct amdgpu_connector *amdgpu_connector,
......
...@@ -45,6 +45,7 @@ struct dc_caps { ...@@ -45,6 +45,7 @@ struct dc_caps {
uint32_t max_links; uint32_t max_links;
uint32_t max_audios; uint32_t max_audios;
uint32_t max_slave_planes; uint32_t max_slave_planes;
uint32_t max_surfaces;
uint32_t max_downscale_ratio; uint32_t max_downscale_ratio;
uint32_t i2c_speed_in_khz; uint32_t i2c_speed_in_khz;
......
...@@ -1035,6 +1035,8 @@ static bool construct( ...@@ -1035,6 +1035,8 @@ static bool construct(
} }
} }
dc->public.caps.max_surfaces = pool->base.pipe_count;
if (!resource_construct(num_virtual_links, dc, &pool->base, if (!resource_construct(num_virtual_links, dc, &pool->base,
&res_create_funcs)) &res_create_funcs))
goto res_create_fail; goto res_create_fail;
......
...@@ -1455,6 +1455,8 @@ static bool construct( ...@@ -1455,6 +1455,8 @@ static bool construct(
if (!dce110_hw_sequencer_construct(dc)) if (!dce110_hw_sequencer_construct(dc))
goto res_create_fail; goto res_create_fail;
dc->public.caps.max_surfaces = pool->base.pipe_count;
bw_calcs_init(&dc->bw_dceip, &dc->bw_vbios, dc->ctx->asic_id); bw_calcs_init(&dc->bw_dceip, &dc->bw_vbios, dc->ctx->asic_id);
bw_calcs_data_update_from_pplib(dc); bw_calcs_data_update_from_pplib(dc);
......
...@@ -1409,6 +1409,8 @@ static bool construct( ...@@ -1409,6 +1409,8 @@ static bool construct(
&res_create_funcs)) &res_create_funcs))
goto res_create_fail; goto res_create_fail;
dc->public.caps.max_surfaces = pool->base.pipe_count;
/* Create hardware sequencer */ /* Create hardware sequencer */
if (!dce112_hw_sequencer_construct(dc)) if (!dce112_hw_sequencer_construct(dc))
goto res_create_fail; goto res_create_fail;
......
...@@ -1060,6 +1060,8 @@ static bool construct( ...@@ -1060,6 +1060,8 @@ static bool construct(
if (!dce120_hw_sequencer_create(dc)) if (!dce120_hw_sequencer_create(dc))
goto controller_create_fail; goto controller_create_fail;
dc->public.caps.max_surfaces = pool->base.pipe_count;
bw_calcs_init(&dc->bw_dceip, &dc->bw_vbios, dc->ctx->asic_id); bw_calcs_init(&dc->bw_dceip, &dc->bw_vbios, dc->ctx->asic_id);
bw_calcs_data_update_from_pplib(dc); bw_calcs_data_update_from_pplib(dc);
......
...@@ -1043,6 +1043,8 @@ static bool construct( ...@@ -1043,6 +1043,8 @@ static bool construct(
} }
} }
dc->public.caps.max_surfaces = pool->base.pipe_count;
if (!resource_construct(num_virtual_links, dc, &pool->base, if (!resource_construct(num_virtual_links, dc, &pool->base,
&res_create_funcs)) &res_create_funcs))
goto res_create_fail; goto res_create_fail;
......
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