X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.c;h=2571d1745a3cc9aea47c3be4f3242786192423d2;hb=9af061296dbe0eb542567d0eb991474948933e27;hp=306ad6eace70c4aa23d00214785f4acecc640424;hpb=978c7f8c63d118a0fa8fcaab8d1d7d141be4767c;p=src%2Fagl-compositor.git diff --git a/src/main.c b/src/main.c index 306ad6e..2571d17 100644 --- a/src/main.c +++ b/src/main.c @@ -46,12 +46,17 @@ #include #include #include +#include #include "shared/os-compatibility.h" #include "shared/helpers.h" #include "agl-shell-server-protocol.h" +#ifdef HAVE_REMOTING +#include "remote.h" +#endif + static int cached_tm_mday = -1; static struct weston_log_scope *log_scope; @@ -85,6 +90,20 @@ to_ivi_output(struct weston_output *o) return output; } +static void +ivi_output_configure_app_id(struct ivi_output *ivi_output) +{ + if (ivi_output->config) { + if (ivi_output->app_id != NULL) + return; + + weston_config_section_get_string(ivi_output->config, + "agl-shell-app-id", + &ivi_output->app_id, + NULL); + } +} + static struct ivi_output * ivi_ensure_output(struct ivi_compositor *ivi, char *name, struct weston_config_section *config) @@ -119,6 +138,7 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, &output->output_destroy); wl_list_insert(&ivi->outputs, &output->link); + ivi_output_configure_app_id(output); return output; } @@ -532,6 +552,198 @@ heads_changed(struct wl_listener *listener, void *arg) } } +#ifdef HAVE_REMOTING +static int +drm_backend_remoted_output_configure(struct weston_output *output, + struct weston_config_section *section, + char *modeline, + const struct weston_remoting_api *api) +{ + char *gbm_format = NULL; + char *seat = NULL; + char *host = NULL; + char *pipeline = NULL; + int port, ret; + int32_t scale = 1; + uint32_t transform = WL_OUTPUT_TRANSFORM_NORMAL; + char *trans; + + ret = api->set_mode(output, modeline); + if (ret < 0) { + weston_log("Cannot configure an output \"%s\" using " + "weston_remoting_api. Invalid mode\n", + output->name); + return -1; + } + + weston_config_section_get_int(section, "scale", &scale, 1); + weston_output_set_scale(output, scale); + + weston_config_section_get_string(section, "transform", &trans, "normal"); + if (parse_transform(trans, &transform) < 0) { + weston_log("Invalid transform \"%s\" for output %s\n", + trans, output->name); + } + weston_output_set_transform(output, transform); + + weston_config_section_get_string(section, "gbm-format", + &gbm_format, NULL); + api->set_gbm_format(output, gbm_format); + free(gbm_format); + + weston_config_section_get_string(section, "seat", &seat, ""); + + api->set_seat(output, seat); + free(seat); + + weston_config_section_get_string(section, "gst-pipeline", &pipeline, + NULL); + if (pipeline) { + api->set_gst_pipeline(output, pipeline); + free(pipeline); + return 0; + } + + weston_config_section_get_string(section, "host", &host, NULL); + weston_config_section_get_int(section, "port", &port, 0); + if (!host || port <= 0 || 65533 < port) { + weston_log("Cannot configure an output \"%s\". " + "Need to specify gst-pipeline or " + "host and port (1-65533).\n", output->name); + } + api->set_host(output, host); + free(host); + api->set_port(output, port); + + return 0; +} + + +static int +remote_output_init(struct ivi_output *ivi_output, + struct weston_compositor *compositor, + struct weston_config_section *section, + const struct weston_remoting_api *api) +{ + char *output_name, *modeline = NULL; + int ret = -1; + + weston_config_section_get_string(section, "name", &output_name, NULL); + if (!output_name) + return ret; + + weston_config_section_get_string(section, "mode", &modeline, "off"); + if (strcmp(modeline, "off") == 0) + goto err; + + ivi_output->output = api->create_output(compositor, output_name); + if (!ivi_output->output) { + weston_log("Cannot create remoted output \"%s\".\n", + output_name); + goto err; + } + + ret = drm_backend_remoted_output_configure(ivi_output->output, section, + modeline, api); + if (ret < 0) { + weston_log("Cannot configure remoted output \"%s\".\n", + output_name); + goto err; + } + + if (weston_output_enable(ivi_output->output) < 0) { + weston_log("Enabling remoted output \"%s\" failed.\n", + output_name); + goto err; + } + + free(modeline); + free(output_name); + weston_log("remoted output '%s' enabled\n", ivi_output->output->name); + + return 0; + +err: + free(modeline); + free(output_name); + if (ivi_output->output) + weston_output_destroy(ivi_output->output); + + return ret; +} + +static int +load_remoting(struct ivi_compositor *ivi, struct weston_config *config) +{ + struct weston_compositor *compositor = ivi->compositor; + int (*module_init)(struct weston_compositor *wc); + struct weston_config_section *remote_section = NULL; + const char *section_name; + + module_init = weston_load_module("remoting-plugin.so", + "weston_module_init"); + if (!module_init) + return -1; + + if (module_init(compositor) < 0) + return -1; + + ivi->remoting_api = weston_remoting_get_api(compositor); + if (!ivi->remoting_api) + return -1; + + while (weston_config_next_section(config, &remote_section, §ion_name)) { + if (strcmp(section_name, "remote-output")) + continue; + + struct ivi_output *ivi_output = NULL; + bool output_found = false; + char *_name = NULL; + + weston_config_section_get_string(remote_section, "name", &_name, NULL); + wl_list_for_each(ivi_output, &ivi->outputs, link) { + if (!strcmp(ivi_output->name, _name)) { + output_found = true; + break; + } + } + + if (output_found) { + free(_name); + continue; + } + + ivi_output = zalloc(sizeof(*ivi_output)); + + ivi_output->ivi = ivi; + ivi_output->name = _name; + ivi_output->config = remote_section; + + if (remote_output_init(ivi_output, compositor, + remote_section, ivi->remoting_api)) { + free(ivi_output->name); + free(ivi_output); + continue; + } + + ivi_output->output_destroy.notify = handle_output_destroy; + weston_output_add_destroy_listener(ivi_output->output, + &ivi_output->output_destroy); + + wl_list_insert(&ivi->outputs, &ivi_output->link); + ivi_output_configure_app_id(ivi_output); + } + + return 0; +} +#else +static int +load_remoting(struct weston_compositor *compositor, struct weston_config *config) +{ + return -1; +} +#endif + static int load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) { @@ -579,6 +791,8 @@ load_drm_backend(struct ivi_compositor *ivi, int *argc, char *argv[]) goto error; } + load_remoting(ivi, ivi->config); + error: free(config.gbm_format); free(config.seat_id); @@ -1126,20 +1340,6 @@ usage(int error_code) exit(error_code); } -static void -ivi_compositor_get_quirks(struct ivi_compositor *ivi) -{ - struct weston_config_section *section; - - if (!ivi->config) - return; - - section = weston_config_get_section(ivi->config, "shell", NULL, NULL); - weston_config_section_get_bool(section, "activate-by-default", - &ivi->quirks.activate_apps_by_default, 0); - -} - int main(int argc, char *argv[]) { struct ivi_compositor ivi = { 0 }; @@ -1217,8 +1417,6 @@ int main(int argc, char *argv[]) backend = choose_default_backend(); } - ivi_compositor_get_quirks(&ivi); - display = wl_display_create(); loop = wl_display_get_event_loop(display);