Commit a0d078d0 authored by Tian Tao's avatar Tian Tao

drm/hisilicon: Features to support reading resolutions from EDID

Use drm_get_edid to get the resolution, if that fails, set it to
a fixed resolution. Rewrite the desrtoy callback function to release
resources.
Signed-off-by: default avatarTian Tao <tiantao6@hisilicon.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/1600778670-60370-3-git-send-email-tiantao6@hisilicon.com
parent 4eb4d99d
...@@ -21,12 +21,24 @@ ...@@ -21,12 +21,24 @@
static int hibmc_connector_get_modes(struct drm_connector *connector) static int hibmc_connector_get_modes(struct drm_connector *connector)
{ {
int count; int count;
void *edid;
struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector);
edid = drm_get_edid(connector, &hibmc_connector->adapter);
if (edid) {
drm_connector_update_edid_property(connector, edid);
count = drm_add_edid_modes(connector, edid);
if (count)
goto out;
}
count = drm_add_modes_noedid(connector, count = drm_add_modes_noedid(connector,
connector->dev->mode_config.max_width, connector->dev->mode_config.max_width,
connector->dev->mode_config.max_height); connector->dev->mode_config.max_height);
drm_set_preferred_mode(connector, 1024, 768); drm_set_preferred_mode(connector, 1024, 768);
out:
kfree(edid);
return count; return count;
} }
...@@ -36,6 +48,14 @@ static enum drm_mode_status hibmc_connector_mode_valid(struct drm_connector *con ...@@ -36,6 +48,14 @@ static enum drm_mode_status hibmc_connector_mode_valid(struct drm_connector *con
return MODE_OK; return MODE_OK;
} }
static void hibmc_connector_destroy(struct drm_connector *connector)
{
struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector);
i2c_del_adapter(&hibmc_connector->adapter);
drm_connector_cleanup(connector);
}
static const struct drm_connector_helper_funcs static const struct drm_connector_helper_funcs
hibmc_connector_helper_funcs = { hibmc_connector_helper_funcs = {
.get_modes = hibmc_connector_get_modes, .get_modes = hibmc_connector_get_modes,
...@@ -44,7 +64,7 @@ static const struct drm_connector_helper_funcs ...@@ -44,7 +64,7 @@ static const struct drm_connector_helper_funcs
static const struct drm_connector_funcs hibmc_connector_funcs = { static const struct drm_connector_funcs hibmc_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.destroy = drm_connector_cleanup, .destroy = hibmc_connector_destroy,
.reset = drm_atomic_helper_connector_reset, .reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
...@@ -77,10 +97,17 @@ static const struct drm_encoder_funcs hibmc_encoder_funcs = { ...@@ -77,10 +97,17 @@ static const struct drm_encoder_funcs hibmc_encoder_funcs = {
int hibmc_vdac_init(struct hibmc_drm_private *priv) int hibmc_vdac_init(struct hibmc_drm_private *priv)
{ {
struct drm_device *dev = priv->dev; struct drm_device *dev = priv->dev;
struct hibmc_connector *hibmc_connector = &priv->connector;
struct drm_encoder *encoder = &priv->encoder; struct drm_encoder *encoder = &priv->encoder;
struct drm_connector *connector = &priv->connector; struct drm_connector *connector = &hibmc_connector->base;
int ret; int ret;
ret = hibmc_ddc_create(dev, hibmc_connector);
if (ret) {
drm_err(dev, "failed to create ddc: %d\n", ret);
return ret;
}
encoder->possible_crtcs = 0x1; encoder->possible_crtcs = 0x1;
ret = drm_encoder_init(dev, encoder, &hibmc_encoder_funcs, ret = drm_encoder_init(dev, encoder, &hibmc_encoder_funcs,
DRM_MODE_ENCODER_DAC, NULL); DRM_MODE_ENCODER_DAC, NULL);
...@@ -91,12 +118,15 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) ...@@ -91,12 +118,15 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv)
drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs);
ret = drm_connector_init(dev, connector, &hibmc_connector_funcs, ret = drm_connector_init_with_ddc(dev, connector,
DRM_MODE_CONNECTOR_VGA); &hibmc_connector_funcs,
DRM_MODE_CONNECTOR_VGA,
&hibmc_connector->adapter);
if (ret) { if (ret) {
drm_err(dev, "failed to init connector: %d\n", ret); drm_err(dev, "failed to init connector: %d\n", ret);
return ret; return ret;
} }
drm_connector_helper_add(connector, &hibmc_connector_helper_funcs); drm_connector_helper_add(connector, &hibmc_connector_helper_funcs);
drm_connector_attach_encoder(connector, encoder); drm_connector_attach_encoder(connector, encoder);
......
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