39 ((((
uint32_t) pbox->
y2 - 1) << 16) & 0x07ff0000);
40 if (scstart != dev_priv->
state.
s3d.scstart ||
41 scend != dev_priv->
state.
s3d.scend) {
48 dev_priv->
state.
s3d.scstart = scstart;
65 ((((
uint32_t) pbox->
y2 - 1) << 12) & 0x00fff000);
66 if (drawctrl0 != dev_priv->
state.
s4.drawctrl0 ||
67 drawctrl1 != dev_priv->
state.
s4.drawctrl1) {
74 dev_priv->
state.
s4.drawctrl0 = drawctrl0;
75 dev_priv->
state.
s4.drawctrl1 = drawctrl1;
84 if ((addr & 6) != 2) {
85 DRM_ERROR(
"bad texAddr%d %08x (reserved bits)\n", unit, addr);
93 (
"bad texAddr%d %08x (local addr out of range)\n",
99 DRM_ERROR(
"bad texAddr%d %08x (AGP not available)\n",
108 (
"bad texAddr%d %08x (AGP addr out of range)\n",
116 #define SAVE_STATE(reg,where) \
117 if(start <= reg && start+count > reg) \
118 dev_priv->state.where = regs[reg - start]
119 #define SAVE_STATE_MASK(reg,where,mask) do { \
120 if(start <= reg && start+count > reg) { \
122 tmp = regs[reg - start]; \
123 dev_priv->state.where = (tmp & (mask)) | \
124 (dev_priv->state.where & ~(mask)); \
134 DRM_ERROR(
"invalid register range (0x%04x-0x%04x)\n",
135 start, start + count - 1);
151 return savage_verify_texaddr(dev_priv, 0,
166 DRM_ERROR(
"invalid register range (0x%04x-0x%04x)\n",
167 start, start + count - 1);
184 ret |= savage_verify_texaddr(dev_priv, 0,
187 ret |= savage_verify_texaddr(dev_priv, 1,
195 #undef SAVE_STATE_MASK
201 unsigned int count = cmd_header->
state.count;
202 unsigned int start = cmd_header->
state.start;
204 unsigned int bci_size;
212 ret = savage_verify_state_s3d(dev_priv, start, count, regs);
229 ret = savage_verify_state_s4(dev_priv, start, count, regs);
248 bci_size = count + (count + 254) / 255 + count2 + (count2 + 254) / 255;
250 if (cmd_header->
state.global) {
260 unsigned int n = count < 255 ? count : 255;
280 const struct drm_buf * dmabuf)
283 unsigned int prim = cmd_header->
prim.prim;
284 unsigned int skip = cmd_header->
prim.skip;
285 unsigned int n = cmd_header->
prim.count;
286 unsigned int start = cmd_header->
prim.start;
291 DRM_ERROR(
"called without dma buffers!\n");
304 DRM_ERROR(
"wrong number of vertices %u in TRILIST\n",
313 (
"wrong number of vertices %u in TRIFAN/STRIP\n",
319 DRM_ERROR(
"invalid primitive type %u\n", prim);
325 DRM_ERROR(
"invalid skip flags 0x%04x for DMA\n", skip);
329 unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) -
330 (skip >> 2 & 1) - (skip >> 3 & 1) - (skip >> 4 & 1) -
331 (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1);
333 DRM_ERROR(
"invalid skip flags 0x%04x for DMA\n", skip);
337 DRM_ERROR(
"TRILIST_201 used on Savage4 hardware\n");
342 if (start + n > dmabuf->total / 32) {
343 DRM_ERROR(
"vertex indices (%u-%u) out of range (0-%u)\n",
344 start, start + n - 1, dmabuf->total / 32);
353 if (dmabuf->bus_address != dev_priv->
state.
common.vbaddr) {
357 dev_priv->
state.
common.vbaddr = dmabuf->bus_address;
366 for (i = 0; i < 63; ++
i)
374 unsigned int count = n > 255 ? 255 :
n;
379 int reorder[3] = { -1, -1, -1 };
380 reorder[start % 3] = 2;
385 for (i = start + 1; i + 1 < start +
count; i += 2)
388 reorder[(i + 1) % 3]) << 16));
389 if (i < start + count)
395 for (i = start + 1; i + 1 < start +
count; i += 2)
397 if (i < start + count)
403 for (i = start; i + 1 < start +
count; i += 2)
405 if (i < start + count)
420 const uint32_t *vtxbuf,
unsigned int vb_size,
421 unsigned int vb_stride)
423 unsigned char reorder = 0;
424 unsigned int prim = cmd_header->
prim.prim;
425 unsigned int skip = cmd_header->
prim.skip;
426 unsigned int n = cmd_header->
prim.count;
427 unsigned int start = cmd_header->
prim.start;
428 unsigned int vtx_size;
441 DRM_ERROR(
"wrong number of vertices %u in TRILIST\n",
450 (
"wrong number of vertices %u in TRIFAN/STRIP\n",
456 DRM_ERROR(
"invalid primitive type %u\n", prim);
462 DRM_ERROR(
"invalid skip flags 0x%04x\n", skip);
468 DRM_ERROR(
"invalid skip flags 0x%04x\n", skip);
474 vtx_size -= (skip & 1) + (skip >> 1 & 1) +
475 (skip >> 2 & 1) + (skip >> 3 & 1) + (skip >> 4 & 1) +
476 (skip >> 5 & 1) + (skip >> 6 & 1) + (skip >> 7 & 1);
478 if (vtx_size > vb_stride) {
479 DRM_ERROR(
"vertex size greater than vb stride (%u > %u)\n",
480 vtx_size, vb_stride);
484 if (start + n > vb_size / (vb_stride * 4)) {
485 DRM_ERROR(
"vertex indices (%u-%u) out of range (0-%u)\n",
486 start, start + n - 1, vb_size / (vb_stride * 4));
493 unsigned int count = n > 255 ? 255 :
n;
498 int reorder[3] = { -1, -1, -1 };
499 reorder[start % 3] = 2;
504 for (i = start; i < start +
count; ++
i) {
505 unsigned int j = i + reorder[i % 3];
506 DMA_COPY(&vtxbuf[vb_stride * j], vtx_size);
514 if (vb_stride == vtx_size) {
515 DMA_COPY(&vtxbuf[vb_stride * start],
518 for (i = start; i < start +
count; ++
i) {
539 const struct drm_buf * dmabuf)
541 unsigned char reorder = 0;
542 unsigned int prim = cmd_header->
idx.prim;
543 unsigned int skip = cmd_header->
idx.skip;
544 unsigned int n = cmd_header->
idx.count;
549 DRM_ERROR(
"called without dma buffers!\n");
562 DRM_ERROR(
"wrong number of indices %u in TRILIST\n", n);
570 (
"wrong number of indices %u in TRIFAN/STRIP\n", n);
575 DRM_ERROR(
"invalid primitive type %u\n", prim);
581 DRM_ERROR(
"invalid skip flags 0x%04x for DMA\n", skip);
585 unsigned int size = 10 - (skip & 1) - (skip >> 1 & 1) -
586 (skip >> 2 & 1) - (skip >> 3 & 1) - (skip >> 4 & 1) -
587 (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1);
589 DRM_ERROR(
"invalid skip flags 0x%04x for DMA\n", skip);
593 DRM_ERROR(
"TRILIST_201 used on Savage4 hardware\n");
603 if (dmabuf->bus_address != dev_priv->
state.
common.vbaddr) {
607 dev_priv->
state.
common.vbaddr = dmabuf->bus_address;
616 for (i = 0; i < 63; ++
i)
624 unsigned int count = n > 255 ? 255 :
n;
627 for (i = 0; i <
count; ++
i) {
628 if (idx[i] > dmabuf->total / 32) {
629 DRM_ERROR(
"idx[%u]=%u out of range (0-%u)\n",
630 i, idx[i], dmabuf->total / 32);
639 int reorder[3] = { 2, -1, -1 };
644 for (i = 1; i + 1 <
count; i += 2)
647 reorder[(i + 1) % 3]] << 16));
654 for (i = 1; i + 1 <
count; i += 2)
662 for (i = 0; i + 1 <
count; i += 2)
681 unsigned int vb_size,
unsigned int vb_stride)
683 unsigned char reorder = 0;
684 unsigned int prim = cmd_header->
idx.prim;
685 unsigned int skip = cmd_header->
idx.skip;
686 unsigned int n = cmd_header->
idx.count;
687 unsigned int vtx_size;
700 DRM_ERROR(
"wrong number of indices %u in TRILIST\n", n);
708 (
"wrong number of indices %u in TRIFAN/STRIP\n", n);
713 DRM_ERROR(
"invalid primitive type %u\n", prim);
719 DRM_ERROR(
"invalid skip flags 0x%04x\n", skip);
725 DRM_ERROR(
"invalid skip flags 0x%04x\n", skip);
731 vtx_size -= (skip & 1) + (skip >> 1 & 1) +
732 (skip >> 2 & 1) + (skip >> 3 & 1) + (skip >> 4 & 1) +
733 (skip >> 5 & 1) + (skip >> 6 & 1) + (skip >> 7 & 1);
735 if (vtx_size > vb_stride) {
736 DRM_ERROR(
"vertex size greater than vb stride (%u > %u)\n",
737 vtx_size, vb_stride);
744 unsigned int count = n > 255 ? 255 :
n;
747 for (i = 0; i <
count; ++
i) {
748 if (idx[i] > vb_size / (vb_stride * 4)) {
749 DRM_ERROR(
"idx[%u]=%u out of range (0-%u)\n",
750 i, idx[i], vb_size / (vb_stride * 4));
759 int reorder[3] = { 2, -1, -1 };
764 for (i = 0; i <
count; ++
i) {
765 unsigned int j = idx[i + reorder[i % 3]];
766 DMA_COPY(&vtxbuf[vb_stride * j], vtx_size);
774 for (i = 0; i <
count; ++
i) {
775 unsigned int j = idx[
i];
776 DMA_COPY(&vtxbuf[vb_stride * j], vtx_size);
798 unsigned int clear_cmd;
799 unsigned int i, nbufs;
814 if (data->
clear1.mask != 0xffffffff) {
821 for (i = 0; i < nbox; ++
i) {
822 unsigned int x,
y,
w,
h;
824 x = boxes[
i].
x1, y = boxes[
i].
y1;
825 w = boxes[
i].
x2 - boxes[
i].
x1;
826 h = boxes[
i].
y2 - boxes[
i].
y1;
852 if (data->
clear1.mask != 0xffffffff) {
866 unsigned int swap_cmd;
877 for (i = 0; i < nbox; ++
i) {
885 boxes[i].y2 - boxes[i].y1));
895 const struct drm_buf * dmabuf,
896 const unsigned int *vtxbuf,
897 unsigned int vb_size,
unsigned int vb_stride,
904 for (i = 0; i < nbox; ++
i) {
909 while (cmdbuf < end) {
913 switch (cmd_header.
cmd.cmd) {
915 ret = savage_dispatch_dma_prim(
916 dev_priv, &cmd_header, dmabuf);
919 ret = savage_dispatch_vb_prim(
920 dev_priv, &cmd_header,
921 vtxbuf, vb_size, vb_stride);
924 j = (cmd_header.
idx.count + 3) / 4;
926 ret = savage_dispatch_dma_idx(dev_priv,
927 &cmd_header, (
const uint16_t *)cmdbuf,
932 j = (cmd_header.
idx.count + 3) / 4;
934 ret = savage_dispatch_vb_idx(dev_priv,
935 &cmd_header, (
const uint16_t *)cmdbuf,
942 DRM_ERROR(
"IMPLEMENTATION ERROR: "
943 "non-drawing-command %d\n",
959 struct drm_device_dma *
dma = dev->dma;
960 struct drm_buf *dmabuf;
964 unsigned int *kvb_addr =
NULL;
971 LOCK_TEST_WITH_RETURN(dev, file_priv);
973 if (dma && dma->buflist) {
974 if (cmdbuf->
dma_idx > dma->buf_count) {
976 (
"vertex buffer index %u out of range (0-%u)\n",
977 cmdbuf->
dma_idx, dma->buf_count - 1);
980 dmabuf = dma->buflist[cmdbuf->
dma_idx];
992 if (kcmd_addr ==
NULL)
1005 if (kvb_addr ==
NULL) {
1020 if (kbox_addr ==
NULL) {
1042 first_draw_cmd =
NULL;
1043 while (i < cmdbuf->size) {
1052 switch (cmd_header.
cmd.cmd) {
1055 j = (cmd_header.
idx.count + 3) / 4;
1056 if (i + j > cmdbuf->
size) {
1057 DRM_ERROR(
"indexed drawing command extends "
1058 "beyond end of command buffer\n");
1066 if (!first_draw_cmd)
1067 first_draw_cmd = cmdbuf->
cmd_addr - 1;
1072 if (first_draw_cmd) {
1073 ret = savage_dispatch_draw(
1074 dev_priv, first_draw_cmd,
1081 first_draw_cmd =
NULL;
1087 switch (cmd_header.
cmd.cmd) {
1089 j = (cmd_header.
state.count + 1) / 2;
1090 if (i + j > cmdbuf->
size) {
1091 DRM_ERROR(
"command SAVAGE_CMD_STATE extends "
1092 "beyond end of command buffer\n");
1097 ret = savage_dispatch_state(dev_priv, &cmd_header,
1103 if (i + 1 > cmdbuf->
size) {
1104 DRM_ERROR(
"command SAVAGE_CMD_CLEAR extends "
1105 "beyond end of command buffer\n");
1110 ret = savage_dispatch_clear(dev_priv, &cmd_header,
1118 ret = savage_dispatch_swap(dev_priv, cmdbuf->
nbox,
1122 DRM_ERROR(
"invalid command 0x%x\n",
1123 cmd_header.
cmd.cmd);
1135 if (first_draw_cmd) {
1136 ret = savage_dispatch_draw (
1137 dev_priv, first_draw_cmd, cmdbuf->
cmd_addr, dmabuf,
1148 if (dmabuf && cmdbuf->
discard) {