#include <tbm_surface.h>
#include <tbm_surface_internal.h>
-#include <tdm.h>
-#include <tdm_log.h>
-#include <tdm_list.h>
-#include <tdm_helper.h>
-#include <tdm_backend.h>
+#include "tdm.h"
+#include "tdm_log.h"
+#include "tdm_list.h"
+#include "tdm_helper.h"
+#include "tdm_backend.h"
#include "tdm_macro.h"
#include "tdm_private.h"
},
{
OPT_TST, "c", "catpure a output object or a layer object.\n\t\t'-l' is used to show the result on screen.",
- "<output_idx>[,<layer_idx>]~<w>x<h>[+<x>+<y>][,<h>x<v>][@<format>][*<transform>]", NULL
+ "<output_idx>[,<layer_idx>]~<w>x<h>[+<x>+<y>][,<h>x<v>][@<format>][*<transform>][^stream]", NULL
},
{
OPT_GEN, "w", "set the property of a object",
"<prop_name>:<value>", NULL
},
{
- OPT_GEN, "b", "set the fill(smtpe,tiles,plane) and framebuffer type(scanout,noncachable,wc)",
+ OPT_GEN, "b", "set the fill(smtpe,tiles,plain) and framebuffer type(scanout,noncachable,wc)",
"<fill>[:<buf_flag>[,<buf_flag2>[,...]]]", NULL
},
{
},
};
+struct usagestring {
+ const char *string;
+ const char *desc;
+};
+
+static struct usagestring usages[] = {
+ {
+ "-q",
+ NULL
+ },
+ {
+ "-a -b plain",
+ "test all outputs, layers with plain buffers"
+ },
+ {
+ "-o 0@1920x1080",
+ "Set the \"1920x1080\" mode to the output 0. And show a buffer via a primary layer of the output 0"
+ },
+ {
+ "-o 0@1920x1080 -l 1~640x480+50+100",
+ "Create the 640x480 buffer and show it in the (50,100) pos of screen via the layer 1"
+ },
+ {
+ "-p 320x240@NV12~480x360+80+40,640x480@AR24 -l 1~640x480+50+100",
+ "Convert the 320x240@NV12 buffer to the 640x480@AR24 buffer(480x360+80+40) and show the result via the layer 1"
+ },
+};
+
static void
usage(char *app_name)
{
int type_size = sizeof(typestrs) / sizeof(struct typestrings);
int opt_size = sizeof(optstrs) / sizeof(struct optstrings);
+ int usages_size = sizeof(usages) / sizeof(struct usagestring);
int t;
printf("usage: %s \n\n", app_name);
printf("\n");
}
- exit(0);
+ printf(" For example)\n\n");
+
+ for (t = 0; t < usages_size; t++) {
+ printf(" $ %s %s\n", app_name, usages[t].string);
+ printf("\t%s\n", usages[t].desc);
+ }
+ printf("\n");
}
////////////////////////////////////////////////////////////////////////////////
};
TDM_BIT_NAME_FB(buf_flag)
+#define DEFAULT_FORMAT TBM_FORMAT_ARGB8888
+
#define print_size(s) \
printf("%dx%d", (s)->h, (s)->v)
#define print_pos(p) \
typedef struct _tdm_test_server_buffer {
/* variables for test */
- tbm_surface_h buffer;
+ tbm_surface_h b;
int in_use;
tdm_test_server_layer *l;
struct list_head layer_list;
tdm_test_server *data;
tdm_output *output;
+
+ int fill_primary_layer;
} tdm_test_server_output;
typedef struct _tdm_test_server_pp {
tdm_test_server *data;
tdm_test_server_layer *l;
tdm_pp *pp;
- tdm_test_server_buffer *bufs[6];
+ tbm_surface_h bufs[6];
int buf_idx;
tdm_event_loop_source *timer_source;
int is_primary;
tdm_test_server_pp *owner_p;
tdm_test_server_capture *owner_c;
- tdm_test_server_buffer *bufs[3];
+ tbm_surface_h bufs[3];
int buf_idx;
};
tdm_display *display;
};
+static void destroy(tdm_test_server *data);
static void run_test(tdm_test_server *data);
static void output_setup(tdm_test_server_output *o);
-static void layer_show_buffer(tdm_test_server_layer *l, tdm_test_server_buffer *b);
-static void capture_attach(tdm_test_server_capture *c, tdm_test_server_buffer *b);
+static void layer_show_buffer(tdm_test_server_layer *l, tbm_surface_h b);
+static void capture_attach(tdm_test_server_capture *c, tbm_surface_h b);
static char*
parse_size(tdm_size *size, char *arg)
arg = end + 1;
capture_info->transform = strtol(arg, &end, 10);
}
+ if (*end == '^') {
+ arg = end + 1;
+ if (strtol(arg, &end, 10) > 0)
+ capture_info->type = TDM_CAPTURE_TYPE_STREAM;
+ else
+ capture_info->type = TDM_CAPTURE_TYPE_ONESHOT;
+ }
}
static void
if (argc < 2) {
usage(argv[0]);
+ destroy(data);
exit(0);
}
LIST_INITHEAD(&o->prop_list);
LIST_ADDTAIL(&o->link, &data->output_list);
parse_arg_o(o, argv[++i]);
- last_option = o;
last_object = o;
} else if (!strncmp(argv[i] + 1, "p", 1)) {
TDM_GOTO_IF_FAIL(data->do_all == 0, all);
p = calloc(1, sizeof * p);
TDM_EXIT_IF_FAIL(p != NULL);
p->data = data;
- p->fps = 30;
+ p->fps = 30; /* default 30 fps */
LIST_ADDTAIL(&p->link, &data->pp_list);
parse_arg_p(p, argv[++i]);
last_option = p;
- last_object = o;
} else if (!strncmp(argv[i] + 1, "c", 1)) {
TDM_GOTO_IF_FAIL(data->do_all == 0, all);
c = calloc(1, sizeof * c);
LIST_ADDTAIL(&c->link, &data->capture_list);
parse_arg_c(c, argv[++i]);
last_option = c;
- last_object = o;
} else if (!strncmp(argv[i] + 1, "l", 1)) {
TDM_GOTO_IF_FAIL(data->do_all == 0, all);
- if (!o)
- goto no_output;
+ if (!o) {
+ o = calloc(1, sizeof * o);
+ TDM_EXIT_IF_FAIL(o != NULL);
+ o->data = data;
+ LIST_INITHEAD(&o->layer_list);
+ LIST_INITHEAD(&o->prop_list);
+ LIST_ADDTAIL(&o->link, &data->output_list);
+ }
l = calloc(1, sizeof * l);
TDM_EXIT_IF_FAIL(l != NULL);
LIST_INITHEAD(&l->prop_list);
if (p && last_option == p) {
p->l = l;
l->owner_p = p;
- }
- else if (c && last_option == c) {
+ } else if (c && last_option == c) {
c->l = l;
l->owner_c = c;
}
- last_object = o;
+ last_object = l;
} else if (!strncmp(argv[i] + 1, "w", 1)) {
TDM_GOTO_IF_FAIL(data->do_all == 0, all);
if (!last_object)
data->do_vblank = 1;
} else {
usage(argv[0]);
+ destroy(data);
exit(0);
}
}
+
+ LIST_FOR_EACH_ENTRY(p, &data->pp_list, link) {
+ if (!p->l)
+ goto no_layer;
+ }
+ LIST_FOR_EACH_ENTRY(c, &data->capture_list, link) {
+ if (!c->l)
+ goto no_layer;
+ }
+
return;
-no_output:
- printf("Use '-o' to set a output first.\n");
+no_layer:
+ printf("Use '-l' to set a layer for '-p' or '-c'.\n");
exit(0);
no_object:
- printf("Use '-o' or '-l' or '-p' or '-c' to set a object first.\n");
+ printf("Use '-o' or '-l' to set a object first.\n");
exit(0);
all:
printf("Can't use '-%s' with '-a'.\n", argv[i] + 1);
tdm_test_server_layer *l = NULL;
tdm_error ret;
+ /* create the objects of outputs */
if (data->do_all) {
int i, output_count;
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
for (i = 0; i < output_count; i++) {
- tdm_output *output;
- int j, layer_count;
+ tdm_output *output = tdm_display_get_output(data->display, i, NULL);
+ tdm_output_conn_status status;
+ ret = tdm_output_get_conn_status(output, &status);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
o = calloc(1, sizeof * o);
TDM_EXIT_IF_FAIL(o != NULL);
o->data = data;
LIST_INITHEAD(&o->prop_list);
LIST_ADDTAIL(&o->link, &data->output_list);
o->idx = i;
-
- output = tdm_display_get_output(data->display, i, &ret);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- ret = tdm_output_get_layer_count(output, &layer_count);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
-
- for (j = 0; j < layer_count; j++) {
- tdm_layer *layer;
- tdm_layer_capability capabilities;
-
- l = calloc(1, sizeof * l);
- TDM_EXIT_IF_FAIL(l != NULL);
- LIST_INITHEAD(&l->prop_list);
- LIST_ADDTAIL(&l->link, &o->layer_list);
- l->o = o;
- l->idx = j;
-
- layer = tdm_output_get_layer(output, j, &ret);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- ret = tdm_layer_get_capabilities(layer, &capabilities);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
-
- if (capabilities & TDM_LAYER_CAPABILITY_PRIMARY)
- l->is_primary = 1;
- }
+ o->fill_primary_layer = 1;
}
}
- /* fill layer information */
+ /* check if the primary layer object exists */
LIST_FOR_EACH_ENTRY(o, &data->output_list, link) {
tdm_output *output;
const tdm_output_mode *mode;
- int minw, minh, maxw, maxh;
- int layer_count, i = 1;
+ int j, layer_count, primary_index = 0;
+ tdm_test_server_layer *primary_l = NULL;
output_setup(o);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
ret = tdm_output_get_layer_count(output, &layer_count);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- ret = tdm_output_get_available_size(output, &minw, &minh, &maxw, &maxh, NULL);
+ ret = tdm_output_get_primary_index(output, &primary_index);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- if (LIST_IS_EMPTY(&o->layer_list)) {
- ret = tdm_output_get_layer_count(output, &layer_count);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
-
- for (i = 0; i < layer_count; i++) {
- tdm_layer *layer;
- tdm_layer_capability capabilities;
-
- layer = tdm_output_get_layer(output, i, &ret);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- ret = tdm_layer_get_capabilities(layer, &capabilities);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ if (LIST_IS_EMPTY(&o->layer_list))
+ o->fill_primary_layer = 1;
+ else {
+ LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
+ if (l->idx == primary_index) {
+ l->is_primary = 1;
+ o->fill_primary_layer = 1;
+ primary_l = l;
+ break;
+ }
+ }
+ }
- if (!(capabilities & TDM_LAYER_CAPABILITY_PRIMARY))
+ if (!primary_l || data->do_all) {
+ for (j = 0; j < layer_count; j++) {
+ if (j != primary_index && !data->do_all)
continue;
-
l = calloc(1, sizeof * l);
TDM_EXIT_IF_FAIL(l != NULL);
LIST_INITHEAD(&l->prop_list);
LIST_ADDTAIL(&l->link, &o->layer_list);
+ l->data = data;
l->o = o;
- l->idx = i;
- l->is_primary = 1;
- l->info.src_config.pos.w = l->info.src_config.size.h = mode->hdisplay;
- l->info.src_config.pos.h = l->info.src_config.size.v = mode->vdisplay;
- l->info.dst_pos = l->info.src_config.pos;
- }
- } else {
- LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
- if (l->info.dst_pos.w == 0) {
- TDM_EXIT_IF_FAIL(!l->owner_p && !l->owner_c);
- if (l->is_primary) {
- l->info.dst_pos.w = mode->hdisplay;
- l->info.dst_pos.h = mode->vdisplay;
- } else {
- l->info.dst_pos.w = TDM_ALIGN(mode->hdisplay / 3, 2);
- l->info.dst_pos.h = TDM_ALIGN(mode->vdisplay / 3, 2);
- l->info.dst_pos.x = TDM_ALIGN(((mode->hdisplay / 3) / layer_count) * i, 2);
- l->info.dst_pos.y = TDM_ALIGN(((mode->vdisplay / 3) / layer_count) * i, 2);
- i++;
- }
- }
- if (minw > 0 && minh > 0) {
- TDM_EXIT_IF_FAIL(l->info.dst_pos.w >= minw);
- TDM_EXIT_IF_FAIL(l->info.dst_pos.h >= minh);
- }
- if (maxw > 0 && maxh > 0) {
- TDM_EXIT_IF_FAIL(l->info.dst_pos.w <= maxw);
- TDM_EXIT_IF_FAIL(l->info.dst_pos.h <= maxh);
- }
- if (l->owner_p) {
- l->info.src_config = l->owner_p->info.dst_config;
- } else if (l->owner_c) {
- l->info.src_config = l->owner_c->info.dst_config;
+ l->idx = j;
+ if (j == primary_index) {
+ l->is_primary = 1;
+ l->info.dst_pos.w = mode->hdisplay;
+ l->info.dst_pos.h = mode->vdisplay;
+ primary_l = l;
} else {
- if (l->info.src_config.pos.w == 0) {
- l->info.src_config.pos.w = l->info.dst_pos.w;
- l->info.src_config.pos.h = l->info.dst_pos.h;
- }
+ l->info.dst_pos.w = TDM_ALIGN(mode->hdisplay / 3, 2);
+ l->info.dst_pos.h = TDM_ALIGN(mode->vdisplay / 3, 2);
+ l->info.dst_pos.x = TDM_ALIGN(((mode->hdisplay / 3) / layer_count) * j, 2);
+ l->info.dst_pos.y = TDM_ALIGN(((mode->vdisplay / 3) / layer_count) * j, 2);
}
}
}
- }
-}
-
-static void
-print_args(tdm_test_server *data)
-{
- tdm_test_server_output *o = NULL;
- tdm_test_server_layer *l = NULL;
- tdm_test_server_pp *p = NULL;
- tdm_test_server_capture *c = NULL;
- tdm_test_server_prop *w = NULL;
- if (data->do_query) {
- printf("query\n");
- return;
+ TDM_EXIT_IF_FAIL(primary_l != NULL);
+ LIST_DEL(&primary_l->link);
+ LIST_ADD(&primary_l->link, &o->layer_list);
}
+
+ /* fill the empty information of layers */
LIST_FOR_EACH_ENTRY(o, &data->output_list, link) {
- printf("output %d: %s", o->idx, o->mode);
- if (o->refresh > 0)
- printf(" %d\n", o->refresh);
- else
- printf("\n");
- if (!LIST_IS_EMPTY(&o->prop_list)) {
- printf("\tprops: ");
- LIST_FOR_EACH_ENTRY(w, &o->prop_list, link) {
- print_prop(w);
- printf(" ");
- }
- printf("\n");
- }
+ tdm_output *output;
+ int minw, minh, maxw, maxh;
+
+ output = tdm_display_get_output(data->display, o->idx, &ret);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ ret = tdm_output_get_available_size(output, &minw, &minh, &maxw, &maxh, NULL);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ /* l->info.src_config.size will be decided when a buffer shows really */
LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
- printf("\t");
- printf("layer %d: ", l->idx);
- print_config(&l->info.src_config);
- printf(" ! ");
- print_pos(&l->info.dst_pos);
- printf(" trans(%d)\n", l->info.transform);
- if (!LIST_IS_EMPTY(&l->prop_list)) {
- printf("\t\tprops: ");
- LIST_FOR_EACH_ENTRY(w, &l->prop_list, link) {
- print_prop(w);
- printf(" ");
+ if (minw > 0 && minh > 0) {
+ TDM_EXIT_IF_FAIL(l->info.dst_pos.w >= minw);
+ TDM_EXIT_IF_FAIL(l->info.dst_pos.h >= minh);
+ }
+ if (maxw > 0 && maxh > 0) {
+ TDM_EXIT_IF_FAIL(l->info.dst_pos.w <= maxw);
+ TDM_EXIT_IF_FAIL(l->info.dst_pos.h <= maxh);
+ }
+
+ if (l->owner_p) {
+ l->info.src_config.format = l->owner_p->info.dst_config.format;
+ if (l->info.src_config.pos.w == 0) {
+ TDM_EXIT_IF_FAIL(l->owner_p->info.dst_config.size.h > 0);
+ l->info.src_config.pos.w = l->owner_p->info.dst_config.size.h;
+ l->info.src_config.pos.h = l->owner_p->info.dst_config.size.v;
+ }
+ } else if (l->owner_c) {
+ l->info.src_config.format = l->owner_c->info.dst_config.format;
+ if (l->info.src_config.pos.w == 0) {
+ TDM_EXIT_IF_FAIL(l->owner_c->info.dst_config.size.h > 0);
+ l->info.src_config.pos.w = l->owner_c->info.dst_config.size.h;
+ l->info.src_config.pos.h = l->owner_c->info.dst_config.size.v;
+ }
+ } else {
+ if (l->info.src_config.pos.w == 0) {
+ TDM_EXIT_IF_FAIL(l->info.dst_pos.w > 0);
+ l->info.src_config.pos.w = l->info.dst_pos.w;
+ l->info.src_config.pos.h = l->info.dst_pos.h;
}
- printf("\n");
}
}
}
- LIST_FOR_EACH_ENTRY(p, &data->pp_list, link) {
- printf("pp: ");
- print_config(&p->info.src_config);
- printf(" ! ");
- print_config(&p->info.dst_config);
- printf(" fps(%d) trans(%d)\n", p->fps, p->info.transform);
- if (p->l)
- printf("\toutput_idx(%d) layer_idx(%d)\n", p->l->o->idx, p->l->idx);
- }
- LIST_FOR_EACH_ENTRY(c, &data->capture_list, link) {
- printf("capture: o(%d) l(%d) ", c->output_idx, c->layer_idx);
- print_config(&c->info.dst_config);
- printf(" trans(%d)\n", c->info.transform);
- if (c->l)
- printf("\toutput_idx(%d) layer_idx(%d)\n", c->l->o->idx, c->l->idx);
- }
- if (data->bflags != 0) {
- printf("buffer: ");
- char temp[256];
- char *p = temp;
- int len = sizeof temp;
- tdm_buf_flag_str(data->bflags, &p, &len);
- printf(" (%s)\n", temp);
- }
}
static tdm_test_server tts_data;
+static int tts_buffer_key;
+#define TTS_BUFFER_KEY ((unsigned long)&tts_buffer_key)
+
+static tbm_surface_h
+buffer_allocate(int width, int height, int format, int flags)
+{
+ tdm_test_server_buffer *tb = calloc(1, sizeof *tb);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+ tb->b = tbm_surface_internal_create_with_flags(width, height, format, flags);
+ TDM_EXIT_IF_FAIL(tb->b != NULL);
+ tdm_helper_clear_buffer(tb->b);
+ tbm_surface_internal_add_user_data(tb->b, TTS_BUFFER_KEY, free);
+ tbm_surface_internal_set_user_data(tb->b, TTS_BUFFER_KEY, tb);
+ return tb->b;
+}
+
+static tdm_test_server_buffer*
+get_tts_buffer(tbm_surface_h b)
+{
+ tdm_test_server_buffer *tb = NULL;
+ tbm_surface_internal_get_user_data(b, TTS_BUFFER_KEY, (void **)&tb);
+ return tb;
+}
static void
-exit_test(int sig)
+destroy(tdm_test_server *data)
{
- tdm_test_server *data = &tts_data;
tdm_test_server_output *o = NULL, *oo = NULL;
tdm_test_server_layer *l = NULL, *ll = NULL;
tdm_test_server_pp *p = NULL, *pp = NULL;
tdm_test_server_capture *c = NULL, *cc = NULL;
tdm_test_server_prop *w = NULL, *ww = NULL;
+ tdm_error ret;
int i;
- printf("got signal: %d\n", sig);
+ LIST_FOR_EACH_ENTRY_SAFE(c, cc, &data->capture_list, link) {
+ LIST_DEL(&c->link);
+ tdm_capture_destroy(c->capture);
+ free(c);
+ }
- LIST_FOR_EACH_ENTRY_SAFE(o, oo, &data->output_list, link) {
- LIST_DEL(&o->link);
+ LIST_FOR_EACH_ENTRY_SAFE(p, pp, &data->pp_list, link) {
+ tdm_display_lock(data->display);
+ tdm_event_loop_source_remove(p->timer_source);
+ tdm_display_unlock(data->display);
+ tdm_pp_destroy(p->pp);
+ }
+
+ LIST_FOR_EACH_ENTRY_SAFE(o, oo, &data->output_list, link) {
LIST_FOR_EACH_ENTRY_SAFE(l, ll, &o->layer_list, link) {
- LIST_DEL(&l->link);
+ ret = tdm_layer_unset_buffer(l->layer);
+ TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE);
+ }
+ ret = tdm_layer_commit(l->layer, NULL, NULL);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ }
- tdm_layer_unset_buffer(l->layer);
+ LIST_FOR_EACH_ENTRY_SAFE(p, pp, &data->pp_list, link) {
+ LIST_DEL(&p->link);
+ for (i = 0; i < TDM_ARRAY_SIZE(p->bufs); i++)
+ tbm_surface_destroy(p->bufs[i]);
+ free(p);
+ }
+ LIST_FOR_EACH_ENTRY_SAFE(o, oo, &data->output_list, link) {
+ LIST_DEL(&o->link);
+ LIST_FOR_EACH_ENTRY_SAFE(l, ll, &o->layer_list, link) {
+ LIST_DEL(&l->link);
LIST_FOR_EACH_ENTRY_SAFE(w, ww, &l->prop_list, link) {
LIST_DEL(&w->link);
free(w);
}
- for (i = 0; i < TDM_ARRAY_SIZE(l->bufs); i++) {
- tbm_surface_destroy(l->bufs[i]->buffer);
- free(l->bufs[i]);
- }
+ for (i = 0; i < TDM_ARRAY_SIZE(l->bufs); i++)
+ tbm_surface_destroy(l->bufs[i]);
free(l);
}
-
- tdm_output_commit(o->output, 0, NULL, NULL);
-
LIST_FOR_EACH_ENTRY_SAFE(w, ww, &o->prop_list, link) {
LIST_DEL(&w->link);
free(w);
free(o);
}
-
- LIST_FOR_EACH_ENTRY_SAFE(p, pp, &data->pp_list, link) {
- LIST_DEL(&p->link);
-
- tdm_display_lock(data->display);
- tdm_event_loop_source_remove(p->timer_source);
- tdm_display_unlock(data->display);
-
- tdm_pp_destroy(p->pp);
- for (i = 0; i < TDM_ARRAY_SIZE(p->bufs); i++) {
- tbm_surface_destroy(p->bufs[i]->buffer);
- free(p->bufs[i]);
- }
- free(p);
- }
-
- LIST_FOR_EACH_ENTRY_SAFE(c, cc, &data->capture_list, link) {
- LIST_DEL(&c->link);
- tdm_capture_destroy(c->capture);
- free(c);
- }
-
if (data->display)
tdm_display_deinit(data->display);
int len = sizeof temp;
tdm_error ret;
- signal(SIGINT, exit_test); /* 2 */
- signal(SIGSEGV, exit_test); /* 11 */
- signal(SIGTERM, exit_test); /* 15 */
+#if 1 /* for testing */
+ const char *s = (const char*)getenv("XDG_RUNTIME_DIR");
+ if (!s) {
+ char buf[32];
+ snprintf(buf, sizeof(buf), "/run");
+ int ret = setenv("XDG_RUNTIME_DIR", (const char*)buf, 1);
+ if (ret != 0)
+ exit(0);
+ }
+
+ s = (const char*)getenv("TBM_DISPLAY_SERVER");
+ if (!s) {
+ char buf[32];
+ snprintf(buf, sizeof(buf), "1");
+ int ret = setenv("TBM_DISPLAY_SERVER", (const char*)buf, 1);
+ if (ret != 0)
+ exit(0);
+ }
+#endif
memset(data, 0, sizeof * data);
LIST_INITHEAD(&data->output_list);
parse_args(data, argc, argv);
interpret_args(data);
- print_args(data);
if (data->do_query) {
tdm_helper_get_display_information(data->display, temp, &len);
}
if (!best)
best = &modes[i];
- if (modes[i].flags & TDM_OUTPUT_MODE_TYPE_PREFERRED)
+ if (modes[i].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
prefer = &modes[i];
}
if (!found && prefer) {
ret = tdm_output_set_mode(o->output, found);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ printf("output %d: %s %d\n", o->idx, found->name, found->vrefresh);
+
ret = tdm_output_get_available_properties(o->output, &props, &count);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
continue;
ret = tdm_output_set_property(o->output, props[i].id, w->value);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ printf("\tprop '%s': %d\n", props[i].name, w->value.u32);
break;
}
}
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
}
-static tdm_test_server_buffer*
+static tbm_surface_h
layer_get_buffer(tdm_test_server_layer *l)
{
int i, size = TDM_ARRAY_SIZE(l->bufs);
if (!l->bufs[0]) {
for (i = 0; i < size; i++) {
- int width = (l->info.src_config.size.h)?:l->info.src_config.pos.w;
- int height = (l->info.src_config.size.v)?:l->info.src_config.pos.h;
- unsigned int format = (l->info.src_config.format)?:TBM_FORMAT_ARGB8888;
+ int width = (l->info.src_config.size.h) ? : l->info.src_config.pos.w;
+ int height = (l->info.src_config.size.v) ? : l->info.src_config.pos.h;
+ unsigned int format = (l->info.src_config.format) ? : DEFAULT_FORMAT;
int flags = l->o->data->bflags;
- tdm_test_server_buffer *b = calloc(1, sizeof *b);
+ tbm_surface_h b = buffer_allocate(width, height, format, flags);
TDM_EXIT_IF_FAIL(b != NULL);
- b->buffer = tbm_surface_internal_create_with_flags(width, height, format, flags);
- TDM_EXIT_IF_FAIL(b->buffer != NULL);
l->bufs[i] = b;
}
}
for (i = 0; i < size; i++) {
- if (!l->bufs[i]->in_use) {
- tdm_test_buffer_fill(l->bufs[i]->buffer, l->data->b_fill);
+ tdm_test_server_buffer *tb = get_tts_buffer(l->bufs[i]);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+ if (!tb->in_use)
return l->bufs[i];
- }
}
printf("no available layer buffer.\n");
exit(0);
}
static void
-layer_cb_commit(tdm_output *output, unsigned int sequence,
+layer_cb_commit(tdm_layer *layer, unsigned int sequence,
unsigned int tv_sec, unsigned int tv_usec,
void *user_data)
{
tdm_test_server_layer *l = user_data;
- tdm_test_server_buffer *b = layer_get_buffer(l);
-
+ tbm_surface_h b = layer_get_buffer(l);
TDM_EXIT_IF_FAIL(b != NULL);
- layer_show_buffer(l, b);
+
+ if (!l->is_primary || l->o->fill_primary_layer)
+ tdm_test_buffer_fill(b, l->data->b_fill);
+
+ if (!l->is_primary || l->o->fill_primary_layer)
+ layer_show_buffer(l, b);
}
static void
-layer_cb_buffer_release(tbm_surface_h buffer, void *user_data)
+layer_cb_buffer_release(tbm_surface_h b, void *user_data)
{
- tdm_test_server_buffer *b = user_data;
- b->in_use = 0;
- tdm_buffer_remove_release_handler(b->buffer, layer_cb_buffer_release, b);
- if (b->done)
- b->done(buffer, user_data);
+ tdm_test_server_buffer *tb = get_tts_buffer(b);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+
+ tb->in_use = 0;
+ tdm_buffer_remove_release_handler(b, layer_cb_buffer_release, NULL);
+ if (tb->done)
+ tb->done(b, user_data);
}
static void
-layer_show_buffer(tdm_test_server_layer *l, tdm_test_server_buffer *b)
+layer_show_buffer(tdm_test_server_layer *l, tbm_surface_h b)
{
tdm_test_server *data = l->o->data;
+ tdm_test_server_buffer *tb;
tdm_error ret;
- ret = tdm_layer_set_buffer(l->layer, b->buffer);
+ ret = tdm_layer_set_buffer(l->layer, b);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- b->in_use = 1;
- tdm_buffer_add_release_handler(b->buffer, layer_cb_buffer_release, b);
+ tb = get_tts_buffer(b);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+
+ tb->in_use = 1;
+ ret = tdm_buffer_add_release_handler(b, layer_cb_buffer_release, NULL);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
if (data->do_vblank)
- ret = tdm_output_commit(l->o->output, 0, layer_cb_commit, l);
+ ret = tdm_layer_commit(l->layer, layer_cb_commit, l);
else
- ret = tdm_output_commit(l->o->output, 0, NULL, NULL);
+ ret = tdm_layer_commit(l->layer, NULL, NULL);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
printf("show:\tl(%p) b(%p)\n", l, b);
}
static void
-layer_setup(tdm_test_server_layer *l, tdm_test_server_buffer *b)
+layer_setup(tdm_test_server_layer *l, tbm_surface_h b)
{
tdm_test_server_prop *w = NULL;
const tdm_prop *props;
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
/* The size and format information should be same with buffer's */
- tbm_surface_get_info(b->buffer, &info);
+ tbm_surface_get_info(b, &info);
if (IS_RGB(info.format)) {
l->info.src_config.size.h = info.planes[0].stride >> 2;
l->info.src_config.size.v = info.height;
ret = tdm_layer_set_info(l->layer, &l->info);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ printf("layer %d: output(%d) ", l->idx, l->o->idx);
+ print_config(&l->info.src_config);
+ printf(" ! ");
+ print_pos(&l->info.dst_pos);
+ printf(" transform(%s)\n", tdm_transform_str(l->info.transform));
+
ret = tdm_layer_get_available_properties(l->layer, &props, &count);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
continue;
ret = tdm_layer_set_property(l->layer, props[i].id, w->value);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ printf("\tprop '%s': %d\n", props[i].name, w->value.u32);
break;
}
}
}
-static tdm_test_server_buffer*
+static tbm_surface_h
pp_get_buffer(tdm_test_server_pp *p)
{
int i, size = TDM_ARRAY_SIZE(p->bufs);
if (!p->bufs[0]) {
for (i = 0; i < size; i++) {
- int width = (p->info.src_config.size.h)?:p->info.src_config.pos.w;
- int height = (p->info.src_config.size.v)?:p->info.src_config.pos.h;
- unsigned int format = (p->info.src_config.format)?:TBM_FORMAT_ARGB8888;
- int flags = p->l->o->data->bflags;
- tdm_test_server_buffer *b = calloc(1, sizeof *b);
+ int width = (p->info.src_config.size.h) ? : p->info.src_config.pos.w;
+ int height = (p->info.src_config.size.v) ? : p->info.src_config.pos.h;
+ unsigned int format = (p->info.src_config.format) ? : DEFAULT_FORMAT;
+ tbm_surface_h b = buffer_allocate(width, height, format, 0);
TDM_EXIT_IF_FAIL(b != NULL);
- b->buffer = tbm_surface_internal_create_with_flags(width, height, format, flags);
- TDM_EXIT_IF_FAIL(b->buffer != NULL);
p->bufs[i] = b;
}
}
for (i = 0; i < size; i++) {
- if (!p->bufs[i]->in_use) {
- tdm_test_buffer_fill(p->bufs[i]->buffer, p->data->b_fill);
+ tdm_test_server_buffer *tb = get_tts_buffer(p->bufs[i]);
+
+ if (tb == NULL)
+ continue;
+
+ if (!tb->in_use) {
+ tdm_test_buffer_fill(p->bufs[i], p->data->b_fill);
return p->bufs[i];
}
}
}
static void
-pp_cb_sb_release(tbm_surface_h buffer, void *user_data)
+pp_cb_done(tdm_pp *pp, tbm_surface_h sb, tbm_surface_h db, void *user_data)
{
- tdm_test_server_buffer *b = user_data;
- b->in_use = 0;
- tdm_buffer_remove_release_handler(b->buffer, pp_cb_sb_release, b);
-}
+ tdm_test_server_buffer *stb, *dtb;
-static void
-pp_cb_db_release(tbm_surface_h buffer, void *user_data)
-{
- tdm_test_server_buffer *b = user_data;
- b->in_use = 0;
- tdm_buffer_remove_release_handler(b->buffer, pp_cb_db_release, b);
- layer_show_buffer(b->l, b);
+ stb = get_tts_buffer(sb);
+ TDM_EXIT_IF_FAIL(stb != NULL);
+
+ dtb = get_tts_buffer(db);
+ TDM_EXIT_IF_FAIL(dtb != NULL);
+
+ stb->in_use = dtb->in_use = 0;
+
+ layer_show_buffer(dtb->l, db);
}
static void
-pp_convert_buffer(tdm_test_server_pp *p, tdm_test_server_buffer *sb, tdm_test_server_buffer *db)
+pp_convert_buffer(tdm_test_server_pp *p, tbm_surface_h sb, tbm_surface_h db)
{
+ tdm_test_server_buffer *stb, *dtb;
tdm_error ret;
- ret = tdm_pp_attach(p->pp, sb->buffer, db->buffer);
- TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ stb = get_tts_buffer(sb);
+ TDM_EXIT_IF_FAIL(stb != NULL);
+
+ dtb = get_tts_buffer(db);
+ TDM_EXIT_IF_FAIL(dtb != NULL);
- sb->in_use = db->in_use = 1;
- db->l = p->l;
- tdm_buffer_add_release_handler(sb->buffer, pp_cb_sb_release, sb);
- tdm_buffer_add_release_handler(db->buffer, pp_cb_db_release, db);
+ stb->in_use = dtb->in_use = 1;
+ dtb->l = p->l;
+
+ ret = tdm_pp_attach(p->pp, sb, db);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
ret = tdm_pp_commit(p->pp);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
{
tdm_test_server_pp *p = user_data;
tdm_test_server *data = p->l->o->data;
- tdm_test_server_buffer *sb, *db;
+ tbm_surface_h sb, db;
tdm_error ret;
tdm_display_unlock(data->display);
}
static void
-pp_setup(tdm_test_server_pp *p, tdm_test_server_buffer *sb, tdm_test_server_buffer *db)
+pp_setup(tdm_test_server_pp *p, tbm_surface_h sb, tbm_surface_h db)
{
- tdm_test_server *data = p->l->o->data;
+ tdm_test_server *data;
tbm_surface_info_s info;
tdm_error ret;
+ if (!p || !p->l || !p->l->o || !p->l->o->data) {
+ TDM_ERR("invalid parameter failed");
+ exit(0);
+ }
+ data = p->l->o->data;
+
p->pp = tdm_display_create_pp(data->display, &ret);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
/* The size and format information should be same with buffer's */
- tbm_surface_get_info(sb->buffer, &info);
+ tbm_surface_get_info(sb, &info);
if (IS_RGB(info.format)) {
p->info.src_config.size.h = info.planes[0].stride >> 2;
p->info.src_config.size.v = info.height;
p->info.src_config.format = info.format;
/* The size and format information should be same with buffer's */
- tbm_surface_get_info(db->buffer, &info);
+ tbm_surface_get_info(db, &info);
if (IS_RGB(info.format)) {
p->info.dst_config.size.h = info.planes[0].stride >> 2;
p->info.dst_config.size.v = info.height;
ret = tdm_pp_set_info(p->pp, &p->info);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ ret = tdm_pp_set_done_handler(p->pp, pp_cb_done, NULL);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ printf("pp: ");
+ print_config(&p->info.src_config);
+ printf(" ! ");
+ print_config(&p->info.dst_config);
+ printf(" fps(%d) transform(%s)\n", p->fps, tdm_transform_str(p->info.transform));
+ printf("\toutput_idx(%d) layer_idx(%d)\n", p->l->o->idx, p->l->idx);
+
layer_setup(p->l, db);
/* tdm_event_loop_xxx() function is not for the display server. It's for TDM
}
static void
-capture_cb_buffer_done(tbm_surface_h buffer, void *user_data)
+capture_cb_buffer_done(tbm_surface_h b, void *user_data)
{
- tdm_test_server_buffer *b = user_data;
- capture_attach(b->c, b);
+ tdm_test_server_buffer *tb;
+
+ tb = get_tts_buffer(b);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+
+ capture_attach(tb->c, b);
}
static void
-capture_cb_buffer_release(tbm_surface_h buffer, void *user_data)
+capture_cb_done(tdm_capture *capture, tbm_surface_h b, void *user_data)
{
- tdm_test_server_buffer *b = user_data;
- b->in_use = 0;
- tdm_buffer_remove_release_handler(b->buffer, capture_cb_buffer_release, b);
- b->done = capture_cb_buffer_done;
- layer_show_buffer(b->l, b);
+ tdm_test_server_buffer *tb;
+
+ tb = get_tts_buffer(b);
+ TDM_EXIT_IF_FAIL(tb != NULL);
+
+ tb->in_use = 0;
+
+ tb->done = capture_cb_buffer_done;
+ layer_show_buffer(tb->l, b);
}
static void
-capture_attach(tdm_test_server_capture *c, tdm_test_server_buffer *b)
+capture_attach(tdm_test_server_capture *c, tbm_surface_h b)
{
tdm_error ret;
+ tdm_test_server_buffer *tb;
+
+ tb = get_tts_buffer(b);
+ TDM_EXIT_IF_FAIL(tb != NULL);
- ret = tdm_capture_attach(c->capture, b->buffer);
+ tb->in_use = 1;
+ tb->l = c->l;
+ tb->c = c;
+
+ ret = tdm_capture_attach(c->capture, b);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
- b->in_use = 1;
- b->l = c->l;
- b->c = c;
- tdm_buffer_add_release_handler(b->buffer, capture_cb_buffer_release, b);
printf("capture:\tc(%p) b(%p)\n", c, b);
ret = tdm_capture_commit(c->capture);
}
static void
-capture_setup(tdm_test_server_capture *c, tdm_test_server_buffer *b)
+capture_setup(tdm_test_server_capture *c, tbm_surface_h b)
{
- tdm_test_server *data = c->l->o->data;
+ tdm_test_server *data;
tdm_output *output;
tdm_layer *layer;
tbm_surface_info_s info;
tdm_error ret;
+ if (!c || !c->l || !c->l->o || !c->l->o->data) {
+ TDM_ERR("invalid parameter failed");
+ exit(0);
+ }
+ data = c->l->o->data;
+
if (c->output_idx != -1 && c->layer_idx == -1) {
output = tdm_display_get_output(data->display, c->output_idx, &ret);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
TDM_EXIT_IF_FAIL(c->capture != NULL);
/* The size and format information should be same with buffer's */
- tbm_surface_get_info(b->buffer, &info);
+ tbm_surface_get_info(b, &info);
if (IS_RGB(info.format)) {
c->info.dst_config.size.h = info.planes[0].stride >> 2;
c->info.dst_config.size.v = info.height;
c->info.dst_config.size.v = info.height;
}
c->info.dst_config.format = info.format;
+ c->info.type = TDM_CAPTURE_TYPE_ONESHOT;
ret = tdm_capture_set_info(c->capture, &c->info);
TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ ret = tdm_capture_set_done_handler(c->capture, capture_cb_done, NULL);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ printf("capture: o(%d) l(%d) ", c->output_idx, c->layer_idx);
+ print_config(&c->info.dst_config);
+ printf(" transform(%s)\n", tdm_transform_str(c->info.transform));
+ printf("\toutput_idx(%d) layer_idx(%d)\n", c->l->o->idx, c->l->idx);
+
layer_setup(c->l, b);
}
LIST_FOR_EACH_ENTRY(o, &data->output_list, link) {
LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
if (!l->owner_p && !l->owner_c) {
- tdm_test_server_buffer *b;
+ tbm_surface_h b;
b = layer_get_buffer(l);
+ if (!l->is_primary || l->o->fill_primary_layer)
+ tdm_test_buffer_fill(b, data->b_fill);
layer_setup(l, b);
layer_show_buffer(l, b);
}
}
LIST_FOR_EACH_ENTRY(p, &data->pp_list, link) {
- tdm_test_server_buffer *sb, *db;
+ tbm_surface_h sb, db;
TDM_GOTO_IF_FAIL(caps & TDM_DISPLAY_CAPABILITY_PP, no_pp);
sb = pp_get_buffer(p);
TDM_EXIT_IF_FAIL(sb != NULL);
LIST_FOR_EACH_ENTRY(c, &data->capture_list, link) {
TDM_GOTO_IF_FAIL(caps & TDM_DISPLAY_CAPABILITY_CAPTURE, no_capture);
- tdm_test_server_buffer *b;
+ tbm_surface_h b;
b = layer_get_buffer(c->l);
capture_setup(c, b);
capture_attach(c, b);
printf("enter test loop\n");
- while (1)
- tdm_display_handle_events(data->display);
+ while (1) {
+ ret = tdm_display_handle_events(data->display);
+ TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE);
+ }
+
+ destroy(data);
return;
no_pp: