diff options
author | Ilija Hadzic <ihadzic@research.bell-labs.com> | 2013-01-02 18:27:41 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-01-31 16:24:42 -0500 |
commit | c38f34b53e74dec4e58fef0c895d9e6df7da1190 (patch) | |
tree | 0e1cd86a565d02cf7d4bb73a09869a4296ea2241 /drivers/gpu/drm/radeon/r100.c | |
parent | 4db013110cd3da05e4cf7e1119468817709cb9db (diff) |
drm/radeon: use common cs packet parse function
We now have a common radeon_cs_packet_parse function
that is good for all ASICs. Hook it up and eliminate
ASIC-specific versions.
Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/r100.c')
-rw-r--r-- | drivers/gpu/drm/radeon/r100.c | 55 |
1 files changed, 4 insertions, 51 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 40c0318b1eef..7842447da4fb 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -1370,53 +1370,6 @@ void r100_cs_dump_packet(struct radeon_cs_parser *p, | |||
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | /** | 1372 | /** |
1373 | * r100_cs_packet_parse() - parse cp packet and point ib index to next packet | ||
1374 | * @parser: parser structure holding parsing context. | ||
1375 | * @pkt: where to store packet informations | ||
1376 | * | ||
1377 | * Assume that chunk_ib_index is properly set. Will return -EINVAL | ||
1378 | * if packet is bigger than remaining ib size. or if packets is unknown. | ||
1379 | **/ | ||
1380 | int r100_cs_packet_parse(struct radeon_cs_parser *p, | ||
1381 | struct radeon_cs_packet *pkt, | ||
1382 | unsigned idx) | ||
1383 | { | ||
1384 | struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx]; | ||
1385 | uint32_t header; | ||
1386 | |||
1387 | if (idx >= ib_chunk->length_dw) { | ||
1388 | DRM_ERROR("Can not parse packet at %d after CS end %d !\n", | ||
1389 | idx, ib_chunk->length_dw); | ||
1390 | return -EINVAL; | ||
1391 | } | ||
1392 | header = radeon_get_ib_value(p, idx); | ||
1393 | pkt->idx = idx; | ||
1394 | pkt->type = CP_PACKET_GET_TYPE(header); | ||
1395 | pkt->count = CP_PACKET_GET_COUNT(header); | ||
1396 | switch (pkt->type) { | ||
1397 | case PACKET_TYPE0: | ||
1398 | pkt->reg = CP_PACKET0_GET_REG(header); | ||
1399 | pkt->one_reg_wr = CP_PACKET0_GET_ONE_REG_WR(header); | ||
1400 | break; | ||
1401 | case PACKET_TYPE3: | ||
1402 | pkt->opcode = CP_PACKET3_GET_OPCODE(header); | ||
1403 | break; | ||
1404 | case PACKET_TYPE2: | ||
1405 | pkt->count = -1; | ||
1406 | break; | ||
1407 | default: | ||
1408 | DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx); | ||
1409 | return -EINVAL; | ||
1410 | } | ||
1411 | if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) { | ||
1412 | DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n", | ||
1413 | pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw); | ||
1414 | return -EINVAL; | ||
1415 | } | ||
1416 | return 0; | ||
1417 | } | ||
1418 | |||
1419 | /** | ||
1420 | * r100_cs_packet_next_vline() - parse userspace VLINE packet | 1373 | * r100_cs_packet_next_vline() - parse userspace VLINE packet |
1421 | * @parser: parser structure holding parsing context. | 1374 | * @parser: parser structure holding parsing context. |
1422 | * | 1375 | * |
@@ -1444,7 +1397,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
1444 | ib = p->ib.ptr; | 1397 | ib = p->ib.ptr; |
1445 | 1398 | ||
1446 | /* parse the wait until */ | 1399 | /* parse the wait until */ |
1447 | r = r100_cs_packet_parse(p, &waitreloc, p->idx); | 1400 | r = radeon_cs_packet_parse(p, &waitreloc, p->idx); |
1448 | if (r) | 1401 | if (r) |
1449 | return r; | 1402 | return r; |
1450 | 1403 | ||
@@ -1461,7 +1414,7 @@ int r100_cs_packet_parse_vline(struct radeon_cs_parser *p) | |||
1461 | } | 1414 | } |
1462 | 1415 | ||
1463 | /* jump over the NOP */ | 1416 | /* jump over the NOP */ |
1464 | r = r100_cs_packet_parse(p, &p3reloc, p->idx + waitreloc.count + 2); | 1417 | r = radeon_cs_packet_parse(p, &p3reloc, p->idx + waitreloc.count + 2); |
1465 | if (r) | 1418 | if (r) |
1466 | return r; | 1419 | return r; |
1467 | 1420 | ||
@@ -1531,7 +1484,7 @@ int r100_cs_packet_next_reloc(struct radeon_cs_parser *p, | |||
1531 | } | 1484 | } |
1532 | *cs_reloc = NULL; | 1485 | *cs_reloc = NULL; |
1533 | relocs_chunk = &p->chunks[p->chunk_relocs_idx]; | 1486 | relocs_chunk = &p->chunks[p->chunk_relocs_idx]; |
1534 | r = r100_cs_packet_parse(p, &p3reloc, p->idx); | 1487 | r = radeon_cs_packet_parse(p, &p3reloc, p->idx); |
1535 | if (r) { | 1488 | if (r) { |
1536 | return r; | 1489 | return r; |
1537 | } | 1490 | } |
@@ -2100,7 +2053,7 @@ int r100_cs_parse(struct radeon_cs_parser *p) | |||
2100 | r100_cs_track_clear(p->rdev, track); | 2053 | r100_cs_track_clear(p->rdev, track); |
2101 | p->track = track; | 2054 | p->track = track; |
2102 | do { | 2055 | do { |
2103 | r = r100_cs_packet_parse(p, &pkt, p->idx); | 2056 | r = radeon_cs_packet_parse(p, &pkt, p->idx); |
2104 | if (r) { | 2057 | if (r) { |
2105 | return r; | 2058 | return r; |
2106 | } | 2059 | } |