2010-04-27 11:50:11 +02:00
|
|
|
/*
|
|
|
|
* qxl command logging -- for debug purposes
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* maintained by Gerd Hoffmann <kraxel@redhat.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 or
|
|
|
|
* (at your option) version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:13 +01:00
|
|
|
#include "qemu/osdep.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/timer.h"
|
2013-03-18 17:36:02 +01:00
|
|
|
#include "qxl.h"
|
2010-04-27 11:50:11 +02:00
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const qxl_type[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ QXL_CMD_NOP ] = "nop",
|
|
|
|
[ QXL_CMD_DRAW ] = "draw",
|
|
|
|
[ QXL_CMD_UPDATE ] = "update",
|
|
|
|
[ QXL_CMD_CURSOR ] = "cursor",
|
|
|
|
[ QXL_CMD_MESSAGE ] = "message",
|
|
|
|
[ QXL_CMD_SURFACE ] = "surface",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const qxl_draw_type[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ QXL_DRAW_NOP ] = "nop",
|
|
|
|
[ QXL_DRAW_FILL ] = "fill",
|
|
|
|
[ QXL_DRAW_OPAQUE ] = "opaque",
|
|
|
|
[ QXL_DRAW_COPY ] = "copy",
|
|
|
|
[ QXL_COPY_BITS ] = "copy-bits",
|
|
|
|
[ QXL_DRAW_BLEND ] = "blend",
|
|
|
|
[ QXL_DRAW_BLACKNESS ] = "blackness",
|
|
|
|
[ QXL_DRAW_WHITENESS ] = "whitemess",
|
|
|
|
[ QXL_DRAW_INVERS ] = "invers",
|
|
|
|
[ QXL_DRAW_ROP3 ] = "rop3",
|
|
|
|
[ QXL_DRAW_STROKE ] = "stroke",
|
|
|
|
[ QXL_DRAW_TEXT ] = "text",
|
|
|
|
[ QXL_DRAW_TRANSPARENT ] = "transparent",
|
|
|
|
[ QXL_DRAW_ALPHA_BLEND ] = "alpha-blend",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const qxl_draw_effect[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ QXL_EFFECT_BLEND ] = "blend",
|
|
|
|
[ QXL_EFFECT_OPAQUE ] = "opaque",
|
|
|
|
[ QXL_EFFECT_REVERT_ON_DUP ] = "revert-on-dup",
|
|
|
|
[ QXL_EFFECT_BLACKNESS_ON_DUP ] = "blackness-on-dup",
|
|
|
|
[ QXL_EFFECT_WHITENESS_ON_DUP ] = "whiteness-on-dup",
|
|
|
|
[ QXL_EFFECT_NOP_ON_DUP ] = "nop-on-dup",
|
|
|
|
[ QXL_EFFECT_NOP ] = "nop",
|
|
|
|
[ QXL_EFFECT_OPAQUE_BRUSH ] = "opaque-brush",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const qxl_surface_cmd[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ QXL_SURFACE_CMD_CREATE ] = "create",
|
|
|
|
[ QXL_SURFACE_CMD_DESTROY ] = "destroy",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const spice_surface_fmt[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ SPICE_SURFACE_FMT_INVALID ] = "invalid",
|
|
|
|
[ SPICE_SURFACE_FMT_1_A ] = "alpha/1",
|
|
|
|
[ SPICE_SURFACE_FMT_8_A ] = "alpha/8",
|
|
|
|
[ SPICE_SURFACE_FMT_16_555 ] = "555/16",
|
|
|
|
[ SPICE_SURFACE_FMT_16_565 ] = "565/16",
|
|
|
|
[ SPICE_SURFACE_FMT_32_xRGB ] = "xRGB/32",
|
|
|
|
[ SPICE_SURFACE_FMT_32_ARGB ] = "ARGB/32",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const qxl_cursor_cmd[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ QXL_CURSOR_SET ] = "set",
|
|
|
|
[ QXL_CURSOR_MOVE ] = "move",
|
|
|
|
[ QXL_CURSOR_HIDE ] = "hide",
|
|
|
|
[ QXL_CURSOR_TRAIL ] = "trail",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *const spice_cursor_type[] = {
|
2010-04-27 11:50:11 +02:00
|
|
|
[ SPICE_CURSOR_TYPE_ALPHA ] = "alpha",
|
|
|
|
[ SPICE_CURSOR_TYPE_MONO ] = "mono",
|
|
|
|
[ SPICE_CURSOR_TYPE_COLOR4 ] = "color4",
|
|
|
|
[ SPICE_CURSOR_TYPE_COLOR8 ] = "color8",
|
|
|
|
[ SPICE_CURSOR_TYPE_COLOR16 ] = "color16",
|
|
|
|
[ SPICE_CURSOR_TYPE_COLOR24 ] = "color24",
|
|
|
|
[ SPICE_CURSOR_TYPE_COLOR32 ] = "color32",
|
|
|
|
};
|
|
|
|
|
2015-06-11 15:17:56 +02:00
|
|
|
static const char *qxl_v2n(const char *const n[], size_t l, int v)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
if (v >= l || !n[v]) {
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
return n[v];
|
|
|
|
}
|
|
|
|
#define qxl_name(_list, _value) qxl_v2n(_list, ARRAY_SIZE(_list), _value)
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
static int qxl_log_image(PCIQXLDevice *qxl, QXLPHYSICAL addr, int group_id)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
QXLImage *image;
|
|
|
|
QXLImageDescriptor *desc;
|
|
|
|
|
2022-11-28 21:27:39 +01:00
|
|
|
image = qxl_phys2virt(qxl, addr, group_id, sizeof(QXLImage));
|
2012-04-25 11:13:18 +02:00
|
|
|
if (!image) {
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-27 11:50:11 +02:00
|
|
|
desc = &image->descriptor;
|
|
|
|
fprintf(stderr, " (id %" PRIx64 " type %d flags %d width %d height %d",
|
|
|
|
desc->id, desc->type, desc->flags, desc->width, desc->height);
|
|
|
|
switch (desc->type) {
|
|
|
|
case SPICE_IMAGE_TYPE_BITMAP:
|
|
|
|
fprintf(stderr, ", fmt %d flags %d x %d y %d stride %d"
|
|
|
|
" palette %" PRIx64 " data %" PRIx64,
|
|
|
|
image->bitmap.format, image->bitmap.flags,
|
|
|
|
image->bitmap.x, image->bitmap.y,
|
|
|
|
image->bitmap.stride,
|
|
|
|
image->bitmap.palette, image->bitmap.data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fprintf(stderr, ")");
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qxl_log_rect(QXLRect *rect)
|
|
|
|
{
|
|
|
|
fprintf(stderr, " %dx%d+%d+%d",
|
|
|
|
rect->right - rect->left,
|
|
|
|
rect->bottom - rect->top,
|
|
|
|
rect->left, rect->top);
|
|
|
|
}
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
static int qxl_log_cmd_draw_copy(PCIQXLDevice *qxl, QXLCopy *copy,
|
|
|
|
int group_id)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
2012-04-25 11:13:18 +02:00
|
|
|
int ret;
|
|
|
|
|
2010-04-27 11:50:11 +02:00
|
|
|
fprintf(stderr, " src %" PRIx64,
|
|
|
|
copy->src_bitmap);
|
2012-04-25 11:13:18 +02:00
|
|
|
ret = qxl_log_image(qxl, copy->src_bitmap, group_id);
|
|
|
|
if (ret != 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
2010-04-27 11:50:11 +02:00
|
|
|
fprintf(stderr, " area");
|
|
|
|
qxl_log_rect(©->src_area);
|
|
|
|
fprintf(stderr, " rop %d", copy->rop_descriptor);
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
static int qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable *draw, int group_id)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, ": surface_id %d type %s effect %s",
|
|
|
|
draw->surface_id,
|
|
|
|
qxl_name(qxl_draw_type, draw->type),
|
|
|
|
qxl_name(qxl_draw_effect, draw->effect));
|
|
|
|
switch (draw->type) {
|
|
|
|
case QXL_DRAW_COPY:
|
2012-04-25 11:13:18 +02:00
|
|
|
return qxl_log_cmd_draw_copy(qxl, &draw->u.copy, group_id);
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
static int qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, QXLCompatDrawable *draw,
|
|
|
|
int group_id)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, ": type %s effect %s",
|
|
|
|
qxl_name(qxl_draw_type, draw->type),
|
|
|
|
qxl_name(qxl_draw_effect, draw->effect));
|
|
|
|
if (draw->bitmap_offset) {
|
|
|
|
fprintf(stderr, ": bitmap %d",
|
|
|
|
draw->bitmap_offset);
|
|
|
|
qxl_log_rect(&draw->bitmap_area);
|
|
|
|
}
|
|
|
|
switch (draw->type) {
|
|
|
|
case QXL_DRAW_COPY:
|
2012-04-25 11:13:18 +02:00
|
|
|
return qxl_log_cmd_draw_copy(qxl, &draw->u.copy, group_id);
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qxl_log_cmd_surface(PCIQXLDevice *qxl, QXLSurfaceCmd *cmd)
|
|
|
|
{
|
|
|
|
fprintf(stderr, ": %s id %d",
|
|
|
|
qxl_name(qxl_surface_cmd, cmd->type),
|
|
|
|
cmd->surface_id);
|
|
|
|
if (cmd->type == QXL_SURFACE_CMD_CREATE) {
|
2020-11-19 03:58:51 +01:00
|
|
|
fprintf(stderr, " size %dx%d stride %d format %s (count %u, max %u)",
|
2010-04-27 11:50:11 +02:00
|
|
|
cmd->u.surface_create.width,
|
|
|
|
cmd->u.surface_create.height,
|
|
|
|
cmd->u.surface_create.stride,
|
|
|
|
qxl_name(spice_surface_fmt, cmd->u.surface_create.format),
|
|
|
|
qxl->guest_surfaces.count, qxl->guest_surfaces.max);
|
|
|
|
}
|
|
|
|
if (cmd->type == QXL_SURFACE_CMD_DESTROY) {
|
2020-11-19 03:58:51 +01:00
|
|
|
fprintf(stderr, " (count %u)", qxl->guest_surfaces.count);
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
int qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
QXLCursor *cursor;
|
|
|
|
|
|
|
|
fprintf(stderr, ": %s",
|
|
|
|
qxl_name(qxl_cursor_cmd, cmd->type));
|
|
|
|
switch (cmd->type) {
|
|
|
|
case QXL_CURSOR_SET:
|
|
|
|
fprintf(stderr, " +%d+%d visible %s, shape @ 0x%" PRIx64,
|
|
|
|
cmd->u.set.position.x,
|
|
|
|
cmd->u.set.position.y,
|
|
|
|
cmd->u.set.visible ? "yes" : "no",
|
|
|
|
cmd->u.set.shape);
|
2022-11-28 21:27:39 +01:00
|
|
|
cursor = qxl_phys2virt(qxl, cmd->u.set.shape, group_id,
|
|
|
|
sizeof(QXLCursor));
|
2012-04-25 11:13:18 +02:00
|
|
|
if (!cursor) {
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-27 11:50:11 +02:00
|
|
|
fprintf(stderr, " type %s size %dx%d hot-spot +%d+%d"
|
|
|
|
" unique 0x%" PRIx64 " data-size %d",
|
|
|
|
qxl_name(spice_cursor_type, cursor->header.type),
|
|
|
|
cursor->header.width, cursor->header.height,
|
|
|
|
cursor->header.hot_spot_x, cursor->header.hot_spot_y,
|
|
|
|
cursor->header.unique, cursor->data_size);
|
|
|
|
break;
|
|
|
|
case QXL_CURSOR_MOVE:
|
|
|
|
fprintf(stderr, " +%d+%d", cmd->u.position.x, cmd->u.position.y);
|
|
|
|
break;
|
|
|
|
}
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
|
2012-04-25 11:13:18 +02:00
|
|
|
int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
|
2010-04-27 11:50:11 +02:00
|
|
|
{
|
|
|
|
bool compat = ext->flags & QXL_COMMAND_FLAG_COMPAT;
|
|
|
|
void *data;
|
2022-11-28 21:27:39 +01:00
|
|
|
size_t datasz;
|
2012-04-25 11:13:18 +02:00
|
|
|
int ret;
|
2010-04-27 11:50:11 +02:00
|
|
|
|
|
|
|
if (!qxl->cmdlog) {
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
2013-08-21 17:03:08 +02:00
|
|
|
fprintf(stderr, "%" PRId64 " qxl-%d/%s:", qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
2011-06-29 13:57:13 +02:00
|
|
|
qxl->id, ring);
|
2010-04-27 11:50:11 +02:00
|
|
|
fprintf(stderr, " cmd @ 0x%" PRIx64 " %s%s", ext->cmd.data,
|
|
|
|
qxl_name(qxl_type, ext->cmd.type),
|
|
|
|
compat ? "(compat)" : "");
|
|
|
|
|
2022-11-28 21:27:37 +01:00
|
|
|
switch (ext->cmd.type) {
|
|
|
|
case QXL_CMD_DRAW:
|
2022-11-28 21:27:39 +01:00
|
|
|
datasz = compat ? sizeof(QXLCompatDrawable) : sizeof(QXLDrawable);
|
2022-11-28 21:27:37 +01:00
|
|
|
break;
|
|
|
|
case QXL_CMD_SURFACE:
|
2022-11-28 21:27:39 +01:00
|
|
|
datasz = sizeof(QXLSurfaceCmd);
|
2022-11-28 21:27:37 +01:00
|
|
|
break;
|
|
|
|
case QXL_CMD_CURSOR:
|
2022-11-28 21:27:39 +01:00
|
|
|
datasz = sizeof(QXLCursorCmd);
|
2022-11-28 21:27:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto out;
|
|
|
|
}
|
2022-11-28 21:27:39 +01:00
|
|
|
data = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id, datasz);
|
2012-04-25 11:13:18 +02:00
|
|
|
if (!data) {
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-27 11:50:11 +02:00
|
|
|
switch (ext->cmd.type) {
|
|
|
|
case QXL_CMD_DRAW:
|
|
|
|
if (!compat) {
|
2012-04-25 11:13:18 +02:00
|
|
|
ret = qxl_log_cmd_draw(qxl, data, ext->group_id);
|
2010-04-27 11:50:11 +02:00
|
|
|
} else {
|
2012-04-25 11:13:18 +02:00
|
|
|
ret = qxl_log_cmd_draw_compat(qxl, data, ext->group_id);
|
|
|
|
}
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case QXL_CMD_SURFACE:
|
|
|
|
qxl_log_cmd_surface(qxl, data);
|
|
|
|
break;
|
|
|
|
case QXL_CMD_CURSOR:
|
|
|
|
qxl_log_cmd_cursor(qxl, data, ext->group_id);
|
|
|
|
break;
|
|
|
|
}
|
2022-11-28 21:27:37 +01:00
|
|
|
out:
|
2010-04-27 11:50:11 +02:00
|
|
|
fprintf(stderr, "\n");
|
2012-04-25 11:13:18 +02:00
|
|
|
return 0;
|
2010-04-27 11:50:11 +02:00
|
|
|
}
|