aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2014-07-17 23:30:05 -0400
committerDave Airlie <airlied@redhat.com>2014-07-18 00:25:23 -0400
commitb957f457fbce30cc4901dc28f2b56f2b15dfe84a (patch)
treeb0c1f3cb6e8611a727cefa7645271255e4cba133 /drivers/gpu/drm
parent7707e6535f43328e05e4729ac96eee864b90e8a4 (diff)
drm/radeon: use helpers
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/radeon/r100.c6
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c66
3 files changed, 22 insertions, 56 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 1544efcf1c3a..ebdce08cfefc 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1401,7 +1401,6 @@ int r100_cs_parse_packet0(struct radeon_cs_parser *p,
1401 */ 1401 */
1402int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) 1402int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
1403{ 1403{
1404 struct drm_mode_object *obj;
1405 struct drm_crtc *crtc; 1404 struct drm_crtc *crtc;
1406 struct radeon_crtc *radeon_crtc; 1405 struct radeon_crtc *radeon_crtc;
1407 struct radeon_cs_packet p3reloc, waitreloc; 1406 struct radeon_cs_packet p3reloc, waitreloc;
@@ -1441,12 +1440,11 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
1441 header = radeon_get_ib_value(p, h_idx); 1440 header = radeon_get_ib_value(p, h_idx);
1442 crtc_id = radeon_get_ib_value(p, h_idx + 5); 1441 crtc_id = radeon_get_ib_value(p, h_idx + 5);
1443 reg = R100_CP_PACKET0_GET_REG(header); 1442 reg = R100_CP_PACKET0_GET_REG(header);
1444 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); 1443 crtc = drm_crtc_find(p->rdev->ddev, crtc_id);
1445 if (!obj) { 1444 if (!crtc) {
1446 DRM_ERROR("cannot find crtc %d\n", crtc_id); 1445 DRM_ERROR("cannot find crtc %d\n", crtc_id);
1447 return -ENOENT; 1446 return -ENOENT;
1448 } 1447 }
1449 crtc = obj_to_crtc(obj);
1450 radeon_crtc = to_radeon_crtc(crtc); 1448 radeon_crtc = to_radeon_crtc(crtc);
1451 crtc_id = radeon_crtc->crtc_id; 1449 crtc_id = radeon_crtc->crtc_id;
1452 1450
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 12511bb5fd6f..c47537a1ddba 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -825,7 +825,6 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p,
825 uint32_t *vline_start_end, 825 uint32_t *vline_start_end,
826 uint32_t *vline_status) 826 uint32_t *vline_status)
827{ 827{
828 struct drm_mode_object *obj;
829 struct drm_crtc *crtc; 828 struct drm_crtc *crtc;
830 struct radeon_crtc *radeon_crtc; 829 struct radeon_crtc *radeon_crtc;
831 struct radeon_cs_packet p3reloc, wait_reg_mem; 830 struct radeon_cs_packet p3reloc, wait_reg_mem;
@@ -887,12 +886,11 @@ int r600_cs_common_vline_parse(struct radeon_cs_parser *p,
887 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1); 886 crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
888 reg = R600_CP_PACKET0_GET_REG(header); 887 reg = R600_CP_PACKET0_GET_REG(header);
889 888
890 obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC); 889 crtc = drm_crtc_find(p->rdev->ddev, crtc_id);
891 if (!obj) { 890 if (!crtc) {
892 DRM_ERROR("cannot find crtc %d\n", crtc_id); 891 DRM_ERROR("cannot find crtc %d\n", crtc_id);
893 return -ENOENT; 892 return -ENOENT;
894 } 893 }
895 crtc = obj_to_crtc(obj);
896 radeon_crtc = to_radeon_crtc(crtc); 894 radeon_crtc = to_radeon_crtc(crtc);
897 crtc_id = radeon_crtc->crtc_id; 895 crtc_id = radeon_crtc->crtc_id;
898 896
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 8137b7a34696..c667c43f1c1f 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -216,7 +216,6 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
216 struct drm_encoder *best_encoder = NULL; 216 struct drm_encoder *best_encoder = NULL;
217 struct drm_encoder *encoder = NULL; 217 struct drm_encoder *encoder = NULL;
218 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 218 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
219 struct drm_mode_object *obj;
220 bool connected; 219 bool connected;
221 int i; 220 int i;
222 221
@@ -226,14 +225,11 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
226 if (connector->encoder_ids[i] == 0) 225 if (connector->encoder_ids[i] == 0)
227 break; 226 break;
228 227
229 obj = drm_mode_object_find(connector->dev, 228 encoder = drm_encoder_find(connector->dev,
230 connector->encoder_ids[i], 229 connector->encoder_ids[i]);
231 DRM_MODE_OBJECT_ENCODER); 230 if (!encoder)
232 if (!obj)
233 continue; 231 continue;
234 232
235 encoder = obj_to_encoder(obj);
236
237 if ((encoder == best_encoder) && (status == connector_status_connected)) 233 if ((encoder == best_encoder) && (status == connector_status_connected))
238 connected = true; 234 connected = true;
239 else 235 else
@@ -249,7 +245,6 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
249 245
250static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) 246static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type)
251{ 247{
252 struct drm_mode_object *obj;
253 struct drm_encoder *encoder; 248 struct drm_encoder *encoder;
254 int i; 249 int i;
255 250
@@ -257,11 +252,10 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,
257 if (connector->encoder_ids[i] == 0) 252 if (connector->encoder_ids[i] == 0)
258 break; 253 break;
259 254
260 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 255 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
261 if (!obj) 256 if (!encoder)
262 continue; 257 continue;
263 258
264 encoder = obj_to_encoder(obj);
265 if (encoder->encoder_type == encoder_type) 259 if (encoder->encoder_type == encoder_type)
266 return encoder; 260 return encoder;
267 } 261 }
@@ -271,17 +265,9 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,
271static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) 265static struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector)
272{ 266{
273 int enc_id = connector->encoder_ids[0]; 267 int enc_id = connector->encoder_ids[0];
274 struct drm_mode_object *obj;
275 struct drm_encoder *encoder;
276
277 /* pick the encoder ids */ 268 /* pick the encoder ids */
278 if (enc_id) { 269 if (enc_id)
279 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); 270 return drm_encoder_find(connector->dev, enc_id);
280 if (!obj)
281 return NULL;
282 encoder = obj_to_encoder(obj);
283 return encoder;
284 }
285 return NULL; 271 return NULL;
286} 272}
287 273
@@ -1048,7 +1034,6 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1048 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1034 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1049 struct drm_encoder *encoder = NULL; 1035 struct drm_encoder *encoder = NULL;
1050 struct drm_encoder_helper_funcs *encoder_funcs; 1036 struct drm_encoder_helper_funcs *encoder_funcs;
1051 struct drm_mode_object *obj;
1052 int i, r; 1037 int i, r;
1053 enum drm_connector_status ret = connector_status_disconnected; 1038 enum drm_connector_status ret = connector_status_disconnected;
1054 bool dret = false, broken_edid = false; 1039 bool dret = false, broken_edid = false;
@@ -1153,14 +1138,11 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1153 if (connector->encoder_ids[i] == 0) 1138 if (connector->encoder_ids[i] == 0)
1154 break; 1139 break;
1155 1140
1156 obj = drm_mode_object_find(connector->dev, 1141 encoder = drm_encoder_find(connector->dev,
1157 connector->encoder_ids[i], 1142 connector->encoder_ids[i]);
1158 DRM_MODE_OBJECT_ENCODER); 1143 if (!encoder)
1159 if (!obj)
1160 continue; 1144 continue;
1161 1145
1162 encoder = obj_to_encoder(obj);
1163
1164 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC && 1146 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC &&
1165 encoder->encoder_type != DRM_MODE_ENCODER_TVDAC) 1147 encoder->encoder_type != DRM_MODE_ENCODER_TVDAC)
1166 continue; 1148 continue;
@@ -1225,19 +1207,16 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
1225{ 1207{
1226 int enc_id = connector->encoder_ids[0]; 1208 int enc_id = connector->encoder_ids[0];
1227 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1209 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1228 struct drm_mode_object *obj;
1229 struct drm_encoder *encoder; 1210 struct drm_encoder *encoder;
1230 int i; 1211 int i;
1231 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1212 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
1232 if (connector->encoder_ids[i] == 0) 1213 if (connector->encoder_ids[i] == 0)
1233 break; 1214 break;
1234 1215
1235 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 1216 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
1236 if (!obj) 1217 if (!encoder)
1237 continue; 1218 continue;
1238 1219
1239 encoder = obj_to_encoder(obj);
1240
1241 if (radeon_connector->use_digital == true) { 1220 if (radeon_connector->use_digital == true) {
1242 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) 1221 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)
1243 return encoder; 1222 return encoder;
@@ -1252,13 +1231,8 @@ static struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
1252 1231
1253 /* then check use digitial */ 1232 /* then check use digitial */
1254 /* pick the first one */ 1233 /* pick the first one */
1255 if (enc_id) { 1234 if (enc_id)
1256 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); 1235 return drm_encoder_find(connector->dev, enc_id);
1257 if (!obj)
1258 return NULL;
1259 encoder = obj_to_encoder(obj);
1260 return encoder;
1261 }
1262 return NULL; 1236 return NULL;
1263} 1237}
1264 1238
@@ -1391,7 +1365,6 @@ static int radeon_dp_get_modes(struct drm_connector *connector)
1391 1365
1392u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector) 1366u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *connector)
1393{ 1367{
1394 struct drm_mode_object *obj;
1395 struct drm_encoder *encoder; 1368 struct drm_encoder *encoder;
1396 struct radeon_encoder *radeon_encoder; 1369 struct radeon_encoder *radeon_encoder;
1397 int i; 1370 int i;
@@ -1400,11 +1373,10 @@ u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *conn
1400 if (connector->encoder_ids[i] == 0) 1373 if (connector->encoder_ids[i] == 0)
1401 break; 1374 break;
1402 1375
1403 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 1376 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
1404 if (!obj) 1377 if (!encoder)
1405 continue; 1378 continue;
1406 1379
1407 encoder = obj_to_encoder(obj);
1408 radeon_encoder = to_radeon_encoder(encoder); 1380 radeon_encoder = to_radeon_encoder(encoder);
1409 1381
1410 switch (radeon_encoder->encoder_id) { 1382 switch (radeon_encoder->encoder_id) {
@@ -1421,7 +1393,6 @@ u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector *conn
1421 1393
1422bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector) 1394bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
1423{ 1395{
1424 struct drm_mode_object *obj;
1425 struct drm_encoder *encoder; 1396 struct drm_encoder *encoder;
1426 struct radeon_encoder *radeon_encoder; 1397 struct radeon_encoder *radeon_encoder;
1427 int i; 1398 int i;
@@ -1431,11 +1402,10 @@ bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector)
1431 if (connector->encoder_ids[i] == 0) 1402 if (connector->encoder_ids[i] == 0)
1432 break; 1403 break;
1433 1404
1434 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); 1405 encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
1435 if (!obj) 1406 if (!encoder)
1436 continue; 1407 continue;
1437 1408
1438 encoder = obj_to_encoder(obj);
1439 radeon_encoder = to_radeon_encoder(encoder); 1409 radeon_encoder = to_radeon_encoder(encoder);
1440 if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2) 1410 if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2)
1441 found = true; 1411 found = true;