#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "overlay_params.h"
+#include "util/os_socket.h"
+
static enum overlay_param_position
parse_position(const char *str)
{
return LAYER_POSITION_TOP_LEFT;
}
+static FILE *
+parse_output_file(const char *str)
+{
+ return fopen(str, "w+");
+}
+
+static int
+parse_control(const char *str)
+{
+ int ret = os_socket_listen_abstract(str, 1);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR: Couldn't create socket pipe at '%s'\n", str);
+ fprintf(stderr, "ERROR: '%s'\n", strerror(errno));
+ return ret;
+ }
+
+ os_socket_block(ret, false);
+
+ return ret;
+}
+
+static uint32_t
+parse_fps_sampling_period(const char *str)
+{
+ return strtol(str, NULL, 0) * 1000;
+}
+
+static bool
+parse_no_display(const char *str)
+{
+ return strtol(str, NULL, 0) != 0;
+}
+
+static unsigned
+parse_unsigned(const char *str)
+{
+ return strtol(str, NULL, 0);
+}
+
+#define parse_width(s) parse_unsigned(s)
+#define parse_height(s) parse_unsigned(s)
+
static bool
parse_help(const char *str)
{
fprintf(stderr, "Layer params using VK_LAYER_MESA_OVERLAY_CONFIG=\n");
#define OVERLAY_PARAM_BOOL(name) \
- fprintf(stderr, "\t%s=0/1\n", #name);
+ fprintf(stderr, "\t%s=0|1\n", #name);
#define OVERLAY_PARAM_CUSTOM(name)
OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM
- fprintf(stderr, "\tposition=\n"
- "\t\ttop-left\n"
- "\t\ttop-right\n"
- "\t\tbottom-left\n"
- "\t\tbottom-right\n");
+ fprintf(stderr, "\tposition=top-left|top-right|bottom-left|bottom-right\n");
+ fprintf(stderr, "\tfps_sampling_period=number-of-milliseconds\n");
+ fprintf(stderr, "\tno_display=0|1\n");
+ fprintf(stderr, "\toutput_file=/path/to/output.txt\n");
+ fprintf(stderr, "\twidth=width-in-pixels\n");
+ fprintf(stderr, "\theight=height-in-pixels\n");
return true;
}
i++;
for (; !is_delimiter(*s); s++, out_value++, i++)
*out_value = *s;
- }
+ } else
+ *(out_value++) = '1';
*out_value = 0;
if (*s && is_delimiter(*s)) {
/* Visible by default */
params->enabled[OVERLAY_PARAM_ENABLED_fps] = true;
params->enabled[OVERLAY_PARAM_ENABLED_frame_timing] = true;
+ params->fps_sampling_period = 500000; /* 500ms */
+ params->width = params->height = 300;
+ params->control = -1;
if (!env)
return;
#define OVERLAY_PARAM_BOOL(name) \
if (!strcmp(#name, key)) { \
- params->enabled[OVERLAY_PARAM_ENABLED_##name] = strtol(value, NULL, 0); \
+ params->enabled[OVERLAY_PARAM_ENABLED_##name] = \
+ strtol(value, NULL, 0); \
continue; \
}
-#define OVERLAY_PARAM_CUSTOM(name) \
- if (!strcmp(#name, key)) { \
+#define OVERLAY_PARAM_CUSTOM(name) \
+ if (!strcmp(#name, key)) { \
params->name = parse_##name(value); \
continue; \
}