Commit c84dec2f authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Break out amdgpu_dm_connector

Stop using amdgpu_connector and roll our own. There is no overlap
with amdgpu.
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarAndrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e9475143
...@@ -147,6 +147,50 @@ struct amdgpu_display_manager { ...@@ -147,6 +147,50 @@ struct amdgpu_display_manager {
#endif #endif
}; };
struct amdgpu_dm_connector {
struct drm_connector base;
uint32_t connector_id;
/* we need to mind the EDID between detect
and get modes due to analog/digital/tvencoder */
struct edid *edid;
/* shared with amdgpu */
struct amdgpu_hpd hpd;
/* number of modes generated from EDID at 'dc_sink' */
int num_modes;
/* The 'old' sink - before an HPD.
* The 'current' sink is in dc_link->sink. */
struct dc_sink *dc_sink;
struct dc_link *dc_link;
struct dc_sink *dc_em_sink;
/* DM only */
struct drm_dp_mst_topology_mgr mst_mgr;
struct amdgpu_dm_dp_aux dm_dp_aux;
struct drm_dp_mst_port *port;
struct amdgpu_dm_connector *mst_port;
struct amdgpu_encoder *mst_encoder;
/* TODO see if we can merge with ddc_bus or make a dm_connector */
struct amdgpu_i2c_adapter *i2c;
/* Monitor range limits */
int min_vfreq ;
int max_vfreq ;
int pixel_clock_mhz;
/*freesync caps*/
struct mod_freesync_caps caps;
struct mutex hpd_lock;
};
#define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
/* basic init/fini API */ /* basic init/fini API */
int amdgpu_dm_init(struct amdgpu_device *adev); int amdgpu_dm_init(struct amdgpu_device *adev);
...@@ -178,9 +222,9 @@ void amdgpu_dm_register_backlight_device(struct amdgpu_display_manager *dm); ...@@ -178,9 +222,9 @@ void amdgpu_dm_register_backlight_device(struct amdgpu_display_manager *dm);
extern const struct amdgpu_ip_block_version dm_ip_block; extern const struct amdgpu_ip_block_version dm_ip_block;
void amdgpu_dm_update_connector_after_detect( void amdgpu_dm_update_connector_after_detect(
struct amdgpu_connector *aconnector); struct amdgpu_dm_connector *aconnector);
struct amdgpu_connector *amdgpu_dm_find_first_crct_matching_connector( struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
struct drm_atomic_state *state, struct drm_atomic_state *state,
struct drm_crtc *crtc, struct drm_crtc *crtc,
bool from_state_var); bool from_state_var);
...@@ -193,7 +237,6 @@ struct dc_plane_state; ...@@ -193,7 +237,6 @@ struct dc_plane_state;
/* TODO rename to dc_stream_state */ /* TODO rename to dc_stream_state */
struct dc_stream; struct dc_stream;
struct dm_plane_state { struct dm_plane_state {
struct drm_plane_state base; struct drm_plane_state base;
struct dc_plane_state *dc_state; struct dc_plane_state *dc_state;
...@@ -223,7 +266,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm, ...@@ -223,7 +266,7 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
struct drm_plane *plane, 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_dm_connector *amdgpu_dm_connector,
uint32_t link_index, uint32_t link_index,
struct amdgpu_encoder *amdgpu_encoder); struct amdgpu_encoder *amdgpu_encoder);
int amdgpu_dm_encoder_init( int amdgpu_dm_encoder_init(
...@@ -267,7 +310,7 @@ int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev); ...@@ -267,7 +310,7 @@ int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
void amdgpu_dm_connector_init_helper( void amdgpu_dm_connector_init_helper(
struct amdgpu_display_manager *dm, struct amdgpu_display_manager *dm,
struct amdgpu_connector *aconnector, struct amdgpu_dm_connector *aconnector,
int connector_type, int connector_type,
struct dc_link *link, struct dc_link *link,
int link_index); int link_index);
......
...@@ -133,7 +133,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( ...@@ -133,7 +133,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
} }
static void get_payload_table( static void get_payload_table(
struct amdgpu_connector *aconnector, struct amdgpu_dm_connector *aconnector,
struct dp_mst_stream_allocation_table *proposed_table) struct dp_mst_stream_allocation_table *proposed_table)
{ {
int i; int i;
...@@ -178,7 +178,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( ...@@ -178,7 +178,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
struct dp_mst_stream_allocation_table *proposed_table, struct dp_mst_stream_allocation_table *proposed_table,
bool enable) bool enable)
{ {
struct amdgpu_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_dp_mst_topology_mgr *mst_mgr; struct drm_dp_mst_topology_mgr *mst_mgr;
struct drm_dp_mst_port *mst_port; struct drm_dp_mst_port *mst_port;
int slots = 0; int slots = 0;
...@@ -266,7 +266,7 @@ bool dm_helpers_dp_mst_poll_for_allocation_change_trigger( ...@@ -266,7 +266,7 @@ bool dm_helpers_dp_mst_poll_for_allocation_change_trigger(
struct dc_context *ctx, struct dc_context *ctx,
const struct dc_stream_state *stream) const struct dc_stream_state *stream)
{ {
struct amdgpu_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_dp_mst_topology_mgr *mst_mgr; struct drm_dp_mst_topology_mgr *mst_mgr;
int ret; int ret;
...@@ -293,7 +293,7 @@ bool dm_helpers_dp_mst_send_payload_allocation( ...@@ -293,7 +293,7 @@ bool dm_helpers_dp_mst_send_payload_allocation(
const struct dc_stream_state *stream, const struct dc_stream_state *stream,
bool enable) bool enable)
{ {
struct amdgpu_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_dp_mst_topology_mgr *mst_mgr; struct drm_dp_mst_topology_mgr *mst_mgr;
struct drm_dp_mst_port *mst_port; struct drm_dp_mst_port *mst_port;
int ret; int ret;
...@@ -341,7 +341,7 @@ bool dm_helpers_dp_mst_start_top_mgr( ...@@ -341,7 +341,7 @@ bool dm_helpers_dp_mst_start_top_mgr(
const struct dc_link *link, const struct dc_link *link,
bool boot) bool boot)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
if (!aconnector) { if (!aconnector) {
DRM_ERROR("Failed to found connector for link!"); DRM_ERROR("Failed to found connector for link!");
...@@ -364,7 +364,7 @@ void dm_helpers_dp_mst_stop_top_mgr( ...@@ -364,7 +364,7 @@ void dm_helpers_dp_mst_stop_top_mgr(
struct dc_context *ctx, struct dc_context *ctx,
const struct dc_link *link) const struct dc_link *link)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
if (!aconnector) { if (!aconnector) {
DRM_ERROR("Failed to found connector for link!"); DRM_ERROR("Failed to found connector for link!");
...@@ -386,7 +386,7 @@ bool dm_helpers_dp_read_dpcd( ...@@ -386,7 +386,7 @@ bool dm_helpers_dp_read_dpcd(
uint32_t size) uint32_t size)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
if (!aconnector) { if (!aconnector) {
DRM_ERROR("Failed to found connector for link!"); DRM_ERROR("Failed to found connector for link!");
...@@ -404,7 +404,7 @@ bool dm_helpers_dp_write_dpcd( ...@@ -404,7 +404,7 @@ bool dm_helpers_dp_write_dpcd(
const uint8_t *data, const uint8_t *data,
uint32_t size) uint32_t size)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
if (!aconnector) { if (!aconnector) {
DRM_ERROR("Failed to found connector for link!"); DRM_ERROR("Failed to found connector for link!");
...@@ -420,7 +420,7 @@ bool dm_helpers_submit_i2c( ...@@ -420,7 +420,7 @@ bool dm_helpers_submit_i2c(
const struct dc_link *link, const struct dc_link *link,
struct i2c_command *cmd) struct i2c_command *cmd)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
struct i2c_msg *msgs; struct i2c_msg *msgs;
int i = 0; int i = 0;
int num = cmd->number_of_payloads; int num = cmd->number_of_payloads;
...@@ -455,7 +455,7 @@ enum dc_edid_status dm_helpers_read_local_edid( ...@@ -455,7 +455,7 @@ enum dc_edid_status dm_helpers_read_local_edid(
struct dc_link *link, struct dc_link *link,
struct dc_sink *sink) struct dc_sink *sink)
{ {
struct amdgpu_connector *aconnector = link->priv; struct amdgpu_dm_connector *aconnector = link->priv;
struct i2c_adapter *ddc; struct i2c_adapter *ddc;
int retry = 3; int retry = 3;
enum dc_edid_status edid_status; enum dc_edid_status edid_status;
......
...@@ -787,10 +787,10 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) ...@@ -787,10 +787,10 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev)
struct drm_connector *connector; struct drm_connector *connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
struct amdgpu_connector *amdgpu_connector = struct amdgpu_dm_connector *amdgpu_dm_connector =
to_amdgpu_connector(connector); to_amdgpu_dm_connector(connector);
const struct dc_link *dc_link = amdgpu_connector->dc_link; const struct dc_link *dc_link = amdgpu_dm_connector->dc_link;
if (DC_IRQ_SOURCE_INVALID != dc_link->irq_source_hpd) { if (DC_IRQ_SOURCE_INVALID != dc_link->irq_source_hpd) {
dc_interrupt_set(adev->dm.dc, dc_interrupt_set(adev->dm.dc,
...@@ -820,9 +820,9 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev) ...@@ -820,9 +820,9 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev)
struct drm_connector *connector; struct drm_connector *connector;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
struct amdgpu_connector *amdgpu_connector = struct amdgpu_dm_connector *amdgpu_dm_connector =
to_amdgpu_connector(connector); to_amdgpu_dm_connector(connector);
const struct dc_link *dc_link = amdgpu_connector->dc_link; const struct dc_link *dc_link = amdgpu_dm_connector->dc_link;
dc_interrupt_set(adev->dm.dc, dc_link->irq_source_hpd, false); dc_interrupt_set(adev->dm.dc, dc_link->irq_source_hpd, false);
......
...@@ -137,8 +137,8 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg ...@@ -137,8 +137,8 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg
static enum drm_connector_status static enum drm_connector_status
dm_dp_mst_detect(struct drm_connector *connector, bool force) dm_dp_mst_detect(struct drm_connector *connector, bool force)
{ {
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector); struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
struct amdgpu_connector *master = aconnector->mst_port; struct amdgpu_dm_connector *master = aconnector->mst_port;
enum drm_connector_status status = enum drm_connector_status status =
drm_dp_mst_detect_port( drm_dp_mst_detect_port(
...@@ -152,13 +152,13 @@ dm_dp_mst_detect(struct drm_connector *connector, bool force) ...@@ -152,13 +152,13 @@ dm_dp_mst_detect(struct drm_connector *connector, bool force)
static void static void
dm_dp_mst_connector_destroy(struct drm_connector *connector) dm_dp_mst_connector_destroy(struct drm_connector *connector)
{ {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector);
struct amdgpu_encoder *amdgpu_encoder = amdgpu_connector->mst_encoder; struct amdgpu_encoder *amdgpu_encoder = amdgpu_dm_connector->mst_encoder;
drm_encoder_cleanup(&amdgpu_encoder->base); drm_encoder_cleanup(&amdgpu_encoder->base);
kfree(amdgpu_encoder); kfree(amdgpu_encoder);
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
kfree(amdgpu_connector); kfree(amdgpu_dm_connector);
} }
static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { static const struct drm_connector_funcs dm_dp_mst_connector_funcs = {
...@@ -174,7 +174,7 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = { ...@@ -174,7 +174,7 @@ static const struct drm_connector_funcs dm_dp_mst_connector_funcs = {
static int dm_dp_mst_get_modes(struct drm_connector *connector) static int dm_dp_mst_get_modes(struct drm_connector *connector)
{ {
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector); struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
int ret = 0; int ret = 0;
ret = drm_add_edid_modes(&aconnector->base, aconnector->edid); ret = drm_add_edid_modes(&aconnector->base, aconnector->edid);
...@@ -186,9 +186,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) ...@@ -186,9 +186,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
static struct drm_encoder *dm_mst_best_encoder(struct drm_connector *connector) static struct drm_encoder *dm_mst_best_encoder(struct drm_connector *connector)
{ {
struct amdgpu_connector *amdgpu_connector = to_amdgpu_connector(connector); struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector);
return &amdgpu_connector->mst_encoder->base; return &amdgpu_dm_connector->mst_encoder->base;
} }
static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs = { static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs = {
...@@ -198,7 +198,7 @@ static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs ...@@ -198,7 +198,7 @@ static const struct drm_connector_helper_funcs dm_dp_mst_connector_helper_funcs
}; };
static struct amdgpu_encoder * static struct amdgpu_encoder *
dm_dp_create_fake_mst_encoder(struct amdgpu_connector *connector) dm_dp_create_fake_mst_encoder(struct amdgpu_dm_connector *connector)
{ {
struct drm_device *dev = connector->base.dev; struct drm_device *dev = connector->base.dev;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
...@@ -233,15 +233,15 @@ static struct drm_connector *dm_dp_add_mst_connector(struct drm_dp_mst_topology_ ...@@ -233,15 +233,15 @@ static struct drm_connector *dm_dp_add_mst_connector(struct drm_dp_mst_topology_
struct drm_dp_mst_port *port, struct drm_dp_mst_port *port,
const char *pathprop) const char *pathprop)
{ {
struct amdgpu_connector *master = container_of(mgr, struct amdgpu_connector, mst_mgr); struct amdgpu_dm_connector *master = container_of(mgr, struct amdgpu_dm_connector, mst_mgr);
struct drm_device *dev = master->base.dev; struct drm_device *dev = master->base.dev;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct drm_connector *connector; struct drm_connector *connector;
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
aconnector = to_amdgpu_connector(connector); aconnector = to_amdgpu_dm_connector(connector);
if (aconnector->mst_port == master if (aconnector->mst_port == master
&& !aconnector->port) { && !aconnector->port) {
DRM_INFO("DM_MST: reusing connector: %p [id: %d] [master: %p]\n", DRM_INFO("DM_MST: reusing connector: %p [id: %d] [master: %p]\n",
...@@ -315,7 +315,7 @@ static void dm_dp_destroy_mst_connector( ...@@ -315,7 +315,7 @@ static void dm_dp_destroy_mst_connector(
struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_topology_mgr *mgr,
struct drm_connector *connector) struct drm_connector *connector)
{ {
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector); struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
DRM_INFO("DM_MST: Disabling connector: %p [id: %d] [master: %p]\n", DRM_INFO("DM_MST: Disabling connector: %p [id: %d] [master: %p]\n",
aconnector, connector->base.id, aconnector->mst_port); aconnector, connector->base.id, aconnector->mst_port);
...@@ -339,17 +339,17 @@ static void dm_dp_destroy_mst_connector( ...@@ -339,17 +339,17 @@ static void dm_dp_destroy_mst_connector(
static void dm_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) static void dm_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr)
{ {
struct amdgpu_connector *master = container_of(mgr, struct amdgpu_connector, mst_mgr); struct amdgpu_dm_connector *master = container_of(mgr, struct amdgpu_dm_connector, mst_mgr);
struct drm_device *dev = master->base.dev; struct drm_device *dev = master->base.dev;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct drm_connector *connector; struct drm_connector *connector;
struct amdgpu_connector *aconnector; struct amdgpu_dm_connector *aconnector;
struct edid *edid; struct edid *edid;
struct dc_sink *dc_sink; struct dc_sink *dc_sink;
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
aconnector = to_amdgpu_connector(connector); aconnector = to_amdgpu_dm_connector(connector);
if (aconnector->port && if (aconnector->port &&
aconnector->port->pdt != DP_PEER_DEVICE_NONE && aconnector->port->pdt != DP_PEER_DEVICE_NONE &&
aconnector->port->pdt != DP_PEER_DEVICE_MST_BRANCHING && aconnector->port->pdt != DP_PEER_DEVICE_MST_BRANCHING &&
...@@ -440,7 +440,7 @@ static const struct drm_dp_mst_topology_cbs dm_mst_cbs = { ...@@ -440,7 +440,7 @@ static const struct drm_dp_mst_topology_cbs dm_mst_cbs = {
void amdgpu_dm_initialize_dp_connector( void amdgpu_dm_initialize_dp_connector(
struct amdgpu_display_manager *dm, struct amdgpu_display_manager *dm,
struct amdgpu_connector *aconnector) struct amdgpu_dm_connector *aconnector)
{ {
aconnector->dm_dp_aux.aux.name = "dmdc"; aconnector->dm_dp_aux.aux.name = "dmdc";
aconnector->dm_dp_aux.aux.dev = dm->adev->dev; aconnector->dm_dp_aux.aux.dev = dm->adev->dev;
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#define __DAL_AMDGPU_DM_MST_TYPES_H__ #define __DAL_AMDGPU_DM_MST_TYPES_H__
struct amdgpu_display_manager; struct amdgpu_display_manager;
struct amdgpu_connector; struct amdgpu_dm_connector;
void amdgpu_dm_initialize_dp_connector( void amdgpu_dm_initialize_dp_connector(
struct amdgpu_display_manager *dm, struct amdgpu_display_manager *dm,
struct amdgpu_connector *aconnector); struct amdgpu_dm_connector *aconnector);
#endif #endif
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