vtest: add VCMD_GET_PARAM

There is no parameter defined yet, but the command can be used to query
optional features.  It also allows new features to be introduced without
bumping up the protocol version.

This is similar to linux's DRM_IOCTL_VIRTGPU_GETPARAM.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
macos/master
Chia-I Wu 4 years ago
parent 48b67e83a1
commit 53aedf637f
  1. 3
      vtest/vtest.h
  2. 15
      vtest/vtest_protocol.h
  3. 32
      vtest/vtest_renderer.c
  4. 3
      vtest/vtest_server.c

@ -78,6 +78,9 @@ int vtest_poll(void);
int vtest_ping_protocol_version(uint32_t length_dw);
int vtest_protocol_version(uint32_t length_dw);
/* since protocol version 3 */
int vtest_get_param(uint32_t length_dw);
void vtest_set_max_length(uint32_t length);
#endif

@ -64,6 +64,11 @@
#define VCMD_TRANSFER_GET2 13
#define VCMD_TRANSFER_PUT2 14
#ifdef VIRGL_RENDERER_UNSTABLE_APIS
/* since protocol version 3 */
#define VCMD_GET_PARAM 15
#endif /* VIRGL_RENDERER_UNSTABLE_APIS */
#define VCMD_RES_CREATE_SIZE 10
#define VCMD_RES_CREATE_RES_HANDLE 0
#define VCMD_RES_CREATE_TARGET 1
@ -128,4 +133,12 @@
#define VCMD_PROTOCOL_VERSION_SIZE 1
#define VCMD_PROTOCOL_VERSION_VERSION 0
#endif
#ifdef VIRGL_RENDERER_UNSTABLE_APIS
#define VCMD_GET_PARAM_SIZE 1
#define VCMD_GET_PARAM_PARAM 0
/* resp param validity and value */
#endif /* VIRGL_RENDERER_UNSTABLE_APIS */
#endif /* VTEST_PROTOCOL */

@ -489,6 +489,38 @@ int vtest_protocol_version(UNUSED uint32_t length_dw)
return 0;
}
int vtest_get_param(UNUSED uint32_t length_dw)
{
struct vtest_context *ctx = vtest_get_current_context();
uint32_t get_param_buf[VCMD_GET_PARAM_SIZE];
uint32_t resp_buf[VTEST_HDR_SIZE + 2];
uint32_t param;
uint32_t *resp;
int ret;
ret = ctx->input->read(ctx->input, get_param_buf, sizeof(get_param_buf));
if (ret != sizeof(get_param_buf))
return -1;
param = get_param_buf[VCMD_GET_PARAM_PARAM];
resp_buf[VTEST_CMD_LEN] = 2;
resp_buf[VTEST_CMD_ID] = VCMD_GET_PARAM;
resp = &resp_buf[VTEST_CMD_DATA_START];
switch (param) {
default:
resp[0] = false;
resp[1] = 0;
break;
}
ret = vtest_block_write(ctx->out_fd, resp_buf, sizeof(resp_buf));
if (ret < 0)
return -1;
return 0;
}
int vtest_send_caps2(UNUSED uint32_t length_dw)
{
struct vtest_context *ctx = vtest_get_current_context();

@ -603,6 +603,9 @@ static const struct vtest_command {
[VCMD_RESOURCE_CREATE2] = { vtest_create_resource2, true },
[VCMD_TRANSFER_GET2] = { vtest_transfer_get2, true },
[VCMD_TRANSFER_PUT2] = { vtest_transfer_put2, true },
/* since protocol version 3 */
[VCMD_GET_PARAM] = { vtest_get_param, false },
};
static int vtest_client_dispatch_commands(struct vtest_client *client)

Loading…
Cancel
Save