diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-01-16 11:37:43 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-01-21 09:21:47 -0500 |
commit | 07259f8b9fbd30fcef595e872deeea5ffab934ed (patch) | |
tree | fb83e3543f0ac9c877e8adfde97dbccecf8b6d09 | |
parent | 288ffc73f6e9be6334ca491994cc01110bebfc96 (diff) |
drm/i2c: tda998x: use drm_do_get_edid()
Replace the internal EDID read implementation by a call to the new EDID
read core function.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Tested-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | drivers/gpu/drm/i2c/tda998x_drv.c | 86 |
1 files changed, 18 insertions, 68 deletions
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c index d853ab5ba472..43d5d91fe880 100644 --- a/drivers/gpu/drm/i2c/tda998x_drv.c +++ b/drivers/gpu/drm/i2c/tda998x_drv.c | |||
@@ -1012,8 +1012,9 @@ tda998x_encoder_detect(struct tda998x_priv *priv) | |||
1012 | connector_status_disconnected; | 1012 | connector_status_disconnected; |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk) | 1015 | static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t length) |
1016 | { | 1016 | { |
1017 | struct tda998x_priv *priv = data; | ||
1017 | uint8_t offset, segptr; | 1018 | uint8_t offset, segptr; |
1018 | int ret, i; | 1019 | int ret, i; |
1019 | 1020 | ||
@@ -1057,8 +1058,8 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk) | |||
1057 | return -ETIMEDOUT; | 1058 | return -ETIMEDOUT; |
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | ret = reg_read_range(priv, REG_EDID_DATA_0, buf, EDID_LENGTH); | 1061 | ret = reg_read_range(priv, REG_EDID_DATA_0, buf, length); |
1061 | if (ret != EDID_LENGTH) { | 1062 | if (ret != length) { |
1062 | dev_err(&priv->hdmi->dev, "failed to read edid block %d: %d\n", | 1063 | dev_err(&priv->hdmi->dev, "failed to read edid block %d: %d\n", |
1063 | blk, ret); | 1064 | blk, ret); |
1064 | return ret; | 1065 | return ret; |
@@ -1067,82 +1068,31 @@ static int read_edid_block(struct tda998x_priv *priv, uint8_t *buf, int blk) | |||
1067 | return 0; | 1068 | return 0; |
1068 | } | 1069 | } |
1069 | 1070 | ||
1070 | static uint8_t *do_get_edid(struct tda998x_priv *priv) | 1071 | static int |
1072 | tda998x_encoder_get_modes(struct tda998x_priv *priv, | ||
1073 | struct drm_connector *connector) | ||
1071 | { | 1074 | { |
1072 | int j, valid_extensions = 0; | 1075 | struct edid *edid; |
1073 | uint8_t *block, *new; | 1076 | int n; |
1074 | bool print_bad_edid = drm_debug & DRM_UT_KMS; | ||
1075 | |||
1076 | if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) | ||
1077 | return NULL; | ||
1078 | 1077 | ||
1079 | if (priv->rev == TDA19988) | 1078 | if (priv->rev == TDA19988) |
1080 | reg_clear(priv, REG_TX4, TX4_PD_RAM); | 1079 | reg_clear(priv, REG_TX4, TX4_PD_RAM); |
1081 | 1080 | ||
1082 | /* base block fetch */ | 1081 | edid = drm_do_get_edid(connector, read_edid_block, priv); |
1083 | if (read_edid_block(priv, block, 0)) | ||
1084 | goto fail; | ||
1085 | |||
1086 | if (!drm_edid_block_valid(block, 0, print_bad_edid)) | ||
1087 | goto fail; | ||
1088 | |||
1089 | /* if there's no extensions, we're done */ | ||
1090 | if (block[0x7e] == 0) | ||
1091 | goto done; | ||
1092 | |||
1093 | new = krealloc(block, (block[0x7e] + 1) * EDID_LENGTH, GFP_KERNEL); | ||
1094 | if (!new) | ||
1095 | goto fail; | ||
1096 | block = new; | ||
1097 | |||
1098 | for (j = 1; j <= block[0x7e]; j++) { | ||
1099 | uint8_t *ext_block = block + (valid_extensions + 1) * EDID_LENGTH; | ||
1100 | if (read_edid_block(priv, ext_block, j)) | ||
1101 | goto fail; | ||
1102 | |||
1103 | if (!drm_edid_block_valid(ext_block, j, print_bad_edid)) | ||
1104 | goto fail; | ||
1105 | 1082 | ||
1106 | valid_extensions++; | ||
1107 | } | ||
1108 | |||
1109 | if (valid_extensions != block[0x7e]) { | ||
1110 | block[EDID_LENGTH-1] += block[0x7e] - valid_extensions; | ||
1111 | block[0x7e] = valid_extensions; | ||
1112 | new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); | ||
1113 | if (!new) | ||
1114 | goto fail; | ||
1115 | block = new; | ||
1116 | } | ||
1117 | |||
1118 | done: | ||
1119 | if (priv->rev == TDA19988) | 1083 | if (priv->rev == TDA19988) |
1120 | reg_set(priv, REG_TX4, TX4_PD_RAM); | 1084 | reg_set(priv, REG_TX4, TX4_PD_RAM); |
1121 | 1085 | ||
1122 | return block; | 1086 | if (!edid) { |
1123 | 1087 | dev_warn(&priv->hdmi->dev, "failed to read EDID\n"); | |
1124 | fail: | 1088 | return 0; |
1125 | if (priv->rev == TDA19988) | ||
1126 | reg_set(priv, REG_TX4, TX4_PD_RAM); | ||
1127 | dev_warn(&priv->hdmi->dev, "failed to read EDID\n"); | ||
1128 | kfree(block); | ||
1129 | return NULL; | ||
1130 | } | ||
1131 | |||
1132 | static int | ||
1133 | tda998x_encoder_get_modes(struct tda998x_priv *priv, | ||
1134 | struct drm_connector *connector) | ||
1135 | { | ||
1136 | struct edid *edid = (struct edid *)do_get_edid(priv); | ||
1137 | int n = 0; | ||
1138 | |||
1139 | if (edid) { | ||
1140 | drm_mode_connector_update_edid_property(connector, edid); | ||
1141 | n = drm_add_edid_modes(connector, edid); | ||
1142 | priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid); | ||
1143 | kfree(edid); | ||
1144 | } | 1089 | } |
1145 | 1090 | ||
1091 | drm_mode_connector_update_edid_property(connector, edid); | ||
1092 | n = drm_add_edid_modes(connector, edid); | ||
1093 | priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid); | ||
1094 | kfree(edid); | ||
1095 | |||
1146 | return n; | 1096 | return n; |
1147 | } | 1097 | } |
1148 | 1098 | ||