Skip to content

Commit a0d078d

Browse files
author
Tian Tao
committed
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: Tian Tao <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4eb4d99 commit a0d078d

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@
2121
static int hibmc_connector_get_modes(struct drm_connector *connector)
2222
{
2323
int count;
24+
void *edid;
25+
struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector);
26+
27+
edid = drm_get_edid(connector, &hibmc_connector->adapter);
28+
if (edid) {
29+
drm_connector_update_edid_property(connector, edid);
30+
count = drm_add_edid_modes(connector, edid);
31+
if (count)
32+
goto out;
33+
}
2434

2535
count = drm_add_modes_noedid(connector,
2636
connector->dev->mode_config.max_width,
2737
connector->dev->mode_config.max_height);
2838
drm_set_preferred_mode(connector, 1024, 768);
2939

40+
out:
41+
kfree(edid);
3042
return count;
3143
}
3244

@@ -36,6 +48,14 @@ static enum drm_mode_status hibmc_connector_mode_valid(struct drm_connector *con
3648
return MODE_OK;
3749
}
3850

51+
static void hibmc_connector_destroy(struct drm_connector *connector)
52+
{
53+
struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector);
54+
55+
i2c_del_adapter(&hibmc_connector->adapter);
56+
drm_connector_cleanup(connector);
57+
}
58+
3959
static const struct drm_connector_helper_funcs
4060
hibmc_connector_helper_funcs = {
4161
.get_modes = hibmc_connector_get_modes,
@@ -44,7 +64,7 @@ static const struct drm_connector_helper_funcs
4464

4565
static const struct drm_connector_funcs hibmc_connector_funcs = {
4666
.fill_modes = drm_helper_probe_single_connector_modes,
47-
.destroy = drm_connector_cleanup,
67+
.destroy = hibmc_connector_destroy,
4868
.reset = drm_atomic_helper_connector_reset,
4969
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
5070
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -77,10 +97,17 @@ static const struct drm_encoder_funcs hibmc_encoder_funcs = {
7797
int hibmc_vdac_init(struct hibmc_drm_private *priv)
7898
{
7999
struct drm_device *dev = priv->dev;
100+
struct hibmc_connector *hibmc_connector = &priv->connector;
80101
struct drm_encoder *encoder = &priv->encoder;
81-
struct drm_connector *connector = &priv->connector;
102+
struct drm_connector *connector = &hibmc_connector->base;
82103
int ret;
83104

105+
ret = hibmc_ddc_create(dev, hibmc_connector);
106+
if (ret) {
107+
drm_err(dev, "failed to create ddc: %d\n", ret);
108+
return ret;
109+
}
110+
84111
encoder->possible_crtcs = 0x1;
85112
ret = drm_encoder_init(dev, encoder, &hibmc_encoder_funcs,
86113
DRM_MODE_ENCODER_DAC, NULL);
@@ -91,12 +118,15 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv)
91118

92119
drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs);
93120

94-
ret = drm_connector_init(dev, connector, &hibmc_connector_funcs,
95-
DRM_MODE_CONNECTOR_VGA);
121+
ret = drm_connector_init_with_ddc(dev, connector,
122+
&hibmc_connector_funcs,
123+
DRM_MODE_CONNECTOR_VGA,
124+
&hibmc_connector->adapter);
96125
if (ret) {
97126
drm_err(dev, "failed to init connector: %d\n", ret);
98127
return ret;
99128
}
129+
100130
drm_connector_helper_add(connector, &hibmc_connector_helper_funcs);
101131

102132
drm_connector_attach_encoder(connector, encoder);

0 commit comments

Comments
 (0)