00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "i915_context.h"
00030 #include "i915_winsys.h"
00031 #include "i915_blit.h"
00032 #include "i915_reg.h"
00033 #include "i915_batch.h"
00034 #include "i915_debug.h"
00035
00036 #define FILE_DEBUG_FLAG DEBUG_BLIT
00037
00038 void
00039 i915_fill_blit(struct i915_context *i915,
00040 unsigned cpp,
00041 short dst_pitch,
00042 struct pipe_buffer *dst_buffer,
00043 unsigned dst_offset,
00044 short x, short y,
00045 short w, short h,
00046 unsigned color)
00047 {
00048 unsigned BR13, CMD;
00049
00050 switch (cpp) {
00051 case 1:
00052 case 2:
00053 case 3:
00054 BR13 = dst_pitch | (0xF0 << 16) | (1 << 24);
00055 CMD = XY_COLOR_BLT_CMD;
00056 break;
00057 case 4:
00058 BR13 = dst_pitch | (0xF0 << 16) | (1 << 24) | (1 << 25);
00059 CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA |
00060 XY_COLOR_BLT_WRITE_RGB);
00061 break;
00062 default:
00063 return;
00064 }
00065
00066
00067
00068
00069
00070 if (!BEGIN_BATCH(6, 1)) {
00071 FLUSH_BATCH(NULL);
00072 assert(BEGIN_BATCH(6, 1));
00073 }
00074 OUT_BATCH(CMD);
00075 OUT_BATCH(BR13);
00076 OUT_BATCH((y << 16) | x);
00077 OUT_BATCH(((y + h) << 16) | (x + w));
00078 OUT_RELOC( dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
00079 OUT_BATCH(color);
00080 }
00081
00082
00083 void
00084 i915_copy_blit( struct i915_context *i915,
00085 unsigned do_flip,
00086 unsigned cpp,
00087 short src_pitch,
00088 struct pipe_buffer *src_buffer,
00089 unsigned src_offset,
00090 short dst_pitch,
00091 struct pipe_buffer *dst_buffer,
00092 unsigned dst_offset,
00093 short src_x, short src_y,
00094 short dst_x, short dst_y,
00095 short w, short h )
00096 {
00097 unsigned CMD, BR13;
00098 int dst_y2 = dst_y + h;
00099 int dst_x2 = dst_x + w;
00100
00101
00102 I915_DBG(i915,
00103 "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
00104 __FUNCTION__,
00105 src_buffer, src_pitch, src_offset, src_x, src_y,
00106 dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
00107
00108 src_pitch *= (short) cpp;
00109 dst_pitch *= (short) cpp;
00110
00111 switch (cpp) {
00112 case 1:
00113 case 2:
00114 case 3:
00115 BR13 = (((int) dst_pitch) & 0xffff) |
00116 (0xCC << 16) | (1 << 24);
00117 CMD = XY_SRC_COPY_BLT_CMD;
00118 break;
00119 case 4:
00120 BR13 =
00121 (((int) dst_pitch) & 0xffff) |
00122 (0xCC << 16) | (1 << 24) | (1 << 25);
00123 CMD =
00124 (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
00125 XY_SRC_COPY_BLT_WRITE_RGB);
00126 break;
00127 default:
00128 return;
00129 }
00130
00131 if (dst_y2 < dst_y ||
00132 dst_x2 < dst_x) {
00133 return;
00134 }
00135
00136
00137
00138
00139
00140 assert (dst_pitch > 0 && src_pitch > 0);
00141
00142
00143 if (!BEGIN_BATCH(8, 2)) {
00144 FLUSH_BATCH(NULL);
00145 assert(BEGIN_BATCH(8, 2));
00146 }
00147 OUT_BATCH(CMD);
00148 OUT_BATCH(BR13);
00149 OUT_BATCH((dst_y << 16) | dst_x);
00150 OUT_BATCH((dst_y2 << 16) | dst_x2);
00151 OUT_RELOC(dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
00152 OUT_BATCH((src_y << 16) | src_x);
00153 OUT_BATCH(((int) src_pitch & 0xffff));
00154 OUT_RELOC(src_buffer, I915_BUFFER_ACCESS_READ, src_offset);
00155 }
00156
00157