aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2011-10-04 14:13:25 -0400
committerDave Airlie <airlied@redhat.com>2011-10-05 05:17:16 -0400
commit44031d25ccface0ae647d664347ae3d3a8016f5f (patch)
tree4c360acace0d20beab71aa98783db31a14a8925d /drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
parent01e81419ce66c312db6855b5cb26cd50eb9a9b8b (diff)
vmwgfx: Place overlays in GMR area if we can
When we hae screen objects we are allowed to place the overlay source in the GMR area, do this as this will save precious VRAM. Signed-off-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c132
1 files changed, 74 insertions, 58 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
index 7a7abcdf1020..29481e1cace7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
@@ -97,68 +97,80 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
97 struct drm_vmw_control_stream_arg *arg, 97 struct drm_vmw_control_stream_arg *arg,
98 bool interruptible) 98 bool interruptible)
99{ 99{
100 struct vmw_escape_video_flush *flush;
101 size_t fifo_size;
102 uint32_t gmrId, offset;
103 bool have_so = dev_priv->sou_priv ? true : false;
104 int i, num_items;
105
100 struct { 106 struct {
101 struct vmw_escape_header escape; 107 struct vmw_escape_header escape;
102 struct { 108 struct {
103 struct { 109 uint32_t cmdType;
104 uint32_t cmdType; 110 uint32_t streamId;
105 uint32_t streamId; 111 } header;
106 } header;
107 struct {
108 uint32_t registerId;
109 uint32_t value;
110 } items[SVGA_VIDEO_PITCH_3 + 1];
111 } body;
112 struct vmw_escape_video_flush flush;
113 } *cmds; 112 } *cmds;
114 uint32_t offset; 113 struct {
115 int i, ret; 114 uint32_t registerId;
115 uint32_t value;
116 } *items;
116 117
117 for (;;) { 118 /* defines are a index needs + 1 */
118 cmds = vmw_fifo_reserve(dev_priv, sizeof(*cmds)); 119 if (have_so)
119 if (cmds) 120 num_items = SVGA_VIDEO_DST_SCREEN_ID + 1;
120 break; 121 else
122 num_items = SVGA_VIDEO_PITCH_3 + 1;
121 123
122 ret = vmw_fallback_wait(dev_priv, false, true, 0, 124 fifo_size = sizeof(*cmds) + sizeof(*flush) + sizeof(*items) * num_items;
123 interruptible, 3*HZ); 125
124 if (interruptible && ret == -ERESTARTSYS) 126 cmds = vmw_fifo_reserve(dev_priv, fifo_size);
125 return ret; 127 /* hardware has hung, can't do anything here */
126 else 128 if (!cmds)
127 BUG_ON(ret != 0); 129 return -ENOMEM;
130
131 items = (typeof(items))&cmds[1];
132 flush = (struct vmw_escape_video_flush *)&items[num_items];
133
134 /* the size is header + number of items */
135 fill_escape(&cmds->escape, sizeof(*items) * (num_items + 1));
136
137 cmds->header.cmdType = SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS;
138 cmds->header.streamId = arg->stream_id;
139
140 /* the IDs are neatly numbered */
141 for (i = 0; i < num_items; i++)
142 items[i].registerId = i;
143
144 vmw_dmabuf_get_id_offset(buf, &gmrId, &offset);
145 offset += arg->offset;
146
147 items[SVGA_VIDEO_ENABLED].value = true;
148 items[SVGA_VIDEO_FLAGS].value = arg->flags;
149 items[SVGA_VIDEO_DATA_OFFSET].value = offset;
150 items[SVGA_VIDEO_FORMAT].value = arg->format;
151 items[SVGA_VIDEO_COLORKEY].value = arg->color_key;
152 items[SVGA_VIDEO_SIZE].value = arg->size;
153 items[SVGA_VIDEO_WIDTH].value = arg->width;
154 items[SVGA_VIDEO_HEIGHT].value = arg->height;
155 items[SVGA_VIDEO_SRC_X].value = arg->src.x;
156 items[SVGA_VIDEO_SRC_Y].value = arg->src.y;
157 items[SVGA_VIDEO_SRC_WIDTH].value = arg->src.w;
158 items[SVGA_VIDEO_SRC_HEIGHT].value = arg->src.h;
159 items[SVGA_VIDEO_DST_X].value = arg->dst.x;
160 items[SVGA_VIDEO_DST_Y].value = arg->dst.y;
161 items[SVGA_VIDEO_DST_WIDTH].value = arg->dst.w;
162 items[SVGA_VIDEO_DST_HEIGHT].value = arg->dst.h;
163 items[SVGA_VIDEO_PITCH_1].value = arg->pitch[0];
164 items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1];
165 items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2];
166 if (have_so) {
167 items[SVGA_VIDEO_DATA_GMRID].value = gmrId;
168 items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID;
128 } 169 }
129 170
130 fill_escape(&cmds->escape, sizeof(cmds->body)); 171 fill_flush(flush, arg->stream_id);
131 cmds->body.header.cmdType = SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS;
132 cmds->body.header.streamId = arg->stream_id;
133
134 for (i = 0; i <= SVGA_VIDEO_PITCH_3; i++)
135 cmds->body.items[i].registerId = i;
136
137 offset = buf->base.offset + arg->offset;
138
139 cmds->body.items[SVGA_VIDEO_ENABLED].value = true;
140 cmds->body.items[SVGA_VIDEO_FLAGS].value = arg->flags;
141 cmds->body.items[SVGA_VIDEO_DATA_OFFSET].value = offset;
142 cmds->body.items[SVGA_VIDEO_FORMAT].value = arg->format;
143 cmds->body.items[SVGA_VIDEO_COLORKEY].value = arg->color_key;
144 cmds->body.items[SVGA_VIDEO_SIZE].value = arg->size;
145 cmds->body.items[SVGA_VIDEO_WIDTH].value = arg->width;
146 cmds->body.items[SVGA_VIDEO_HEIGHT].value = arg->height;
147 cmds->body.items[SVGA_VIDEO_SRC_X].value = arg->src.x;
148 cmds->body.items[SVGA_VIDEO_SRC_Y].value = arg->src.y;
149 cmds->body.items[SVGA_VIDEO_SRC_WIDTH].value = arg->src.w;
150 cmds->body.items[SVGA_VIDEO_SRC_HEIGHT].value = arg->src.h;
151 cmds->body.items[SVGA_VIDEO_DST_X].value = arg->dst.x;
152 cmds->body.items[SVGA_VIDEO_DST_Y].value = arg->dst.y;
153 cmds->body.items[SVGA_VIDEO_DST_WIDTH].value = arg->dst.w;
154 cmds->body.items[SVGA_VIDEO_DST_HEIGHT].value = arg->dst.h;
155 cmds->body.items[SVGA_VIDEO_PITCH_1].value = arg->pitch[0];
156 cmds->body.items[SVGA_VIDEO_PITCH_2].value = arg->pitch[1];
157 cmds->body.items[SVGA_VIDEO_PITCH_3].value = arg->pitch[2];
158
159 fill_flush(&cmds->flush, arg->stream_id);
160 172
161 vmw_fifo_commit(dev_priv, sizeof(*cmds)); 173 vmw_fifo_commit(dev_priv, fifo_size);
162 174
163 return 0; 175 return 0;
164} 176}
@@ -206,18 +218,22 @@ static int vmw_overlay_send_stop(struct vmw_private *dev_priv,
206} 218}
207 219
208/** 220/**
209 * Move a buffer to vram, and pin it if @pin. 221 * Move a buffer to vram or gmr if @pin is set, else unpin the buffer.
210 * 222 *
211 * XXX: This function is here to be changed at a later date. 223 * With the introduction of screen objects buffers could now be
224 * used with GMRs instead of being locked to vram.
212 */ 225 */
213static int vmw_overlay_move_buffer(struct vmw_private *dev_priv, 226static int vmw_overlay_move_buffer(struct vmw_private *dev_priv,
214 struct vmw_dma_buffer *buf, 227 struct vmw_dma_buffer *buf,
215 bool pin, bool inter) 228 bool pin, bool inter)
216{ 229{
217 if (pin) 230 if (!pin)
218 return vmw_dmabuf_to_vram(dev_priv, buf, true, inter);
219 else
220 return vmw_dmabuf_unpin(dev_priv, buf, inter); 231 return vmw_dmabuf_unpin(dev_priv, buf, inter);
232
233 if (!dev_priv->sou_priv)
234 return vmw_dmabuf_to_vram(dev_priv, buf, true, inter);
235
236 return vmw_dmabuf_to_vram_or_gmr(dev_priv, buf, true, inter);
221} 237}
222 238
223/** 239/**