weston/libweston/compositor-headless.c

341 lines
8.5 KiB
C
Raw Normal View History

/*
* Copyright © 2010-2011 Benjamin Franzke
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <stdbool.h>
#include "compositor.h"
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
#include "compositor-headless.h"
#include "shared/helpers.h"
#include "pixman-renderer.h"
#include "presentation-time-server-protocol.h"
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
#include "windowed-output-api.h"
struct headless_backend {
struct weston_backend base;
struct weston_compositor *compositor;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
struct weston_seat fake_seat;
bool use_pixman;
};
struct headless_output {
struct weston_output base;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
struct weston_mode mode;
struct wl_event_source *finish_frame_timer;
uint32_t *image_buf;
pixman_image_t *image;
};
static inline struct headless_output *
to_headless_output(struct weston_output *base)
{
return container_of(base, struct headless_output, base);
}
static inline struct headless_backend *
to_headless_backend(struct weston_compositor *base)
{
return container_of(base->backend, struct headless_backend, base);
}
static void
headless_output_start_repaint_loop(struct weston_output *output)
{
struct timespec ts;
weston_compositor_read_presentation_clock(output->compositor, &ts);
weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID);
}
static int
finish_frame_handler(void *data)
{
compositor: set presentation.presented flags Change weston_output_finish_frame() signature so that backends are required to set the flags, that will be reported on the Presentation 'presented' event. This is meant for output-wide feedback flags. Flags that vary per wl_surface are subject for the following patch. All start_repaint_loop functions use the special private flag PRESENTATION_FEEDBACK_INVALID to mark, that this call of weston_output_finish_frame() cannot trigger the 'presented' event. If it does, we now hit an assert, and should then investigate why a fake update triggered Presentation feedback. DRM: Page flip is always vsync'd, and always gets the completion timestamp from the kernel which should correspond well to hardware. Completion is triggered by the kernel/hardware. Vblank handler is only used with the broken planes path, therefore do not report VSYNC, because we cannot guarantee all the planes updated at the same time. We cannot set the INVALID, because it would abort the compositor if the broken planes path was ever used. This is a hack that will get fixed with nuclear pageflip support in the future. fbdev: No vsync, update done by copy, no completion event from hardware, and completion time is totally fake. headless: No real output to update. RDP: Guessing that maybe no vsync, fake time, and copy make sense (pixels sent over network). Also no event that the pixels have been shown? RPI: Presumably Dispmanx updates are vsync'd. We get a completion event from the driver, but need to read the clock ourselves, so the completion time is somewhat unreliable. Zero-copy flag not implemented though it would be theoretically possible with EGL clients (zero-copy is a per-surface flag anyway, so in this patch). Wayland: No information how the host compositor is doing updates, so make a safe guess without assuming vsync or hardware completion event. While we do get some timestamp from the host compositor, it is not the completion time. Would need to hook to the Presentation extension of the host compositor to get more accurate flags. X11: No idea about vsync, completion event, or copying. Also the timestamp is a fake. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com> Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 14:20:40 +00:00
struct headless_output *output = data;
struct timespec ts;
weston_compositor_read_presentation_clock(output->base.compositor, &ts);
compositor: set presentation.presented flags Change weston_output_finish_frame() signature so that backends are required to set the flags, that will be reported on the Presentation 'presented' event. This is meant for output-wide feedback flags. Flags that vary per wl_surface are subject for the following patch. All start_repaint_loop functions use the special private flag PRESENTATION_FEEDBACK_INVALID to mark, that this call of weston_output_finish_frame() cannot trigger the 'presented' event. If it does, we now hit an assert, and should then investigate why a fake update triggered Presentation feedback. DRM: Page flip is always vsync'd, and always gets the completion timestamp from the kernel which should correspond well to hardware. Completion is triggered by the kernel/hardware. Vblank handler is only used with the broken planes path, therefore do not report VSYNC, because we cannot guarantee all the planes updated at the same time. We cannot set the INVALID, because it would abort the compositor if the broken planes path was ever used. This is a hack that will get fixed with nuclear pageflip support in the future. fbdev: No vsync, update done by copy, no completion event from hardware, and completion time is totally fake. headless: No real output to update. RDP: Guessing that maybe no vsync, fake time, and copy make sense (pixels sent over network). Also no event that the pixels have been shown? RPI: Presumably Dispmanx updates are vsync'd. We get a completion event from the driver, but need to read the clock ourselves, so the completion time is somewhat unreliable. Zero-copy flag not implemented though it would be theoretically possible with EGL clients (zero-copy is a per-surface flag anyway, so in this patch). Wayland: No information how the host compositor is doing updates, so make a safe guess without assuming vsync or hardware completion event. While we do get some timestamp from the host compositor, it is not the completion time. Would need to hook to the Presentation extension of the host compositor to get more accurate flags. X11: No idea about vsync, completion event, or copying. Also the timestamp is a fake. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com> Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 14:20:40 +00:00
weston_output_finish_frame(&output->base, &ts, 0);
return 1;
}
static int
headless_output_repaint(struct weston_output *output_base,
pixman_region32_t *damage)
{
struct headless_output *output = to_headless_output(output_base);
struct weston_compositor *ec = output->base.compositor;
ec->renderer->repaint_output(&output->base, damage);
pixman_region32_subtract(&ec->primary_plane.damage,
&ec->primary_plane.damage, damage);
wl_event_source_timer_update(output->finish_frame_timer, 16);
return 0;
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
static int
headless_output_disable(struct weston_output *base)
{
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
struct headless_output *output = to_headless_output(base);
struct headless_backend *b = to_headless_backend(base->compositor);
if (!output->base.enabled)
return 0;
wl_event_source_remove(output->finish_frame_timer);
if (b->use_pixman) {
pixman_renderer_output_destroy(&output->base);
pixman_image_unref(output->image);
free(output->image_buf);
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
return 0;
}
static void
headless_output_destroy(struct weston_output *base)
{
struct headless_output *output = to_headless_output(base);
headless_output_disable(&output->base);
weston_output_destroy(&output->base);
free(output);
}
static int
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
headless_output_enable(struct weston_output *base)
{
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
struct headless_output *output = to_headless_output(base);
struct headless_backend *b = to_headless_backend(base->compositor);
struct wl_event_loop *loop;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
if (b->use_pixman) {
output->image_buf = malloc(output->base.current_mode->width *
output->base.current_mode->height * 4);
if (!output->image_buf)
goto err_malloc;
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
output->base.current_mode->width,
output->base.current_mode->height,
output->image_buf,
output->base.current_mode->width * 4);
if (pixman_renderer_output_create(&output->base) < 0)
goto err_renderer;
pixman_renderer_output_set_buffer(&output->base,
output->image);
}
return 0;
err_renderer:
pixman_image_unref(output->image);
free(output->image_buf);
err_malloc:
wl_event_source_remove(output->finish_frame_timer);
return -1;
}
static int
headless_output_set_size(struct weston_output *base,
int width, int height)
{
struct headless_output *output = to_headless_output(base);
int output_width, output_height;
/* We can only be called once. */
assert(!output->base.current_mode);
/* Make sure we have scale set. */
assert(output->base.scale);
output_width = width * output->base.scale;
output_height = height * output->base.scale;
output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
output->mode.width = output_width;
output->mode.height = output_height;
output->mode.refresh = 60000;
wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
output->base.make = "weston";
output->base.model = "headless";
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
/* XXX: Calculate proper size. */
output->base.mm_width = width;
output->base.mm_height = height;
output->base.start_repaint_loop = headless_output_start_repaint_loop;
output->base.repaint = headless_output_repaint;
output->base.assign_planes = NULL;
output->base.set_backlight = NULL;
output->base.set_dpms = NULL;
output->base.switch_mode = NULL;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
return 0;
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
static int
headless_output_create(struct weston_compositor *compositor,
const char *name)
{
struct headless_output *output;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
/* name can't be NULL. */
assert(name);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
output = zalloc(sizeof *output);
if (output == NULL)
return -1;
output->base.name = strdup(name);
output->base.destroy = headless_output_destroy;
output->base.disable = headless_output_disable;
output->base.enable = headless_output_enable;
weston_output_init(&output->base, compositor);
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
weston_compositor_add_pending_output(&output->base, compositor);
return 0;
}
static void
headless_restore(struct weston_compositor *ec)
{
}
static void
headless_destroy(struct weston_compositor *ec)
{
struct headless_backend *b = to_headless_backend(ec);
weston_compositor_shutdown(ec);
free(b);
}
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
static const struct weston_windowed_output_api api = {
headless_output_set_size,
headless_output_create,
};
static struct headless_backend *
headless_backend_create(struct weston_compositor *compositor,
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
struct weston_headless_backend_config *config)
{
struct headless_backend *b;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
int ret;
b = zalloc(sizeof *b);
if (b == NULL)
return NULL;
b->compositor = compositor;
if (weston_compositor_set_presentation_clock_software(compositor) < 0)
goto err_free;
b->base.destroy = headless_destroy;
b->base.restore = headless_restore;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
b->use_pixman = config->use_pixman;
if (b->use_pixman) {
pixman_renderer_init(compositor);
}
if (!b->use_pixman && noop_renderer_init(compositor) < 0)
goto err_input;
compositor->backend = &b->base;
weston: Port headless backend to new output handling API This is a complete port of the headless backend that uses the recently added output handling API for output configuration. - Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually, obtained from the configuration file or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. - Output can be created at runtime using the output API. The output creation only creates a pending output, which needs to be configured the same way as mentioned above. After everything has been set, output needs to be enabled manually using weston_output_enable(). Same as before, a single output is created at runtime using the default configuration or a configuration parsed from the command line. The no-outputs functionality is also preserved, which means that no output will be created initially, but more outputs can be added at runtime using the output API. New feature: This patch also adds, as a bonus of using shared functionality, support for setting options for outputs created by this backend in the weston config file in addition to setting them from the command line. v2: - Fix wet_configure_windowed_output_from_config() usage. - Call headless_output_disable() explicitly from headless_output_destroy(). v3: - Add scale support to output width and height. - Use scaled values in calls to various functions which require width and height. - Disallow calling headless_output_configure more than once. - Remove unneeded checks for output->name == NULL as that has been disallowed. - Use weston_compositor_add_pending_output(). - Bump weston_headless_backend_config version to 2. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-09-30 12:11:07 +00:00
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
&api, sizeof(api));
if (ret < 0) {
weston_log("Failed to register output API.\n");
goto err_input;
}
return b;
err_input:
weston_compositor_shutdown(compositor);
err_free:
free(b);
return NULL;
}
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
static void
config_init_to_defaults(struct weston_headless_backend_config *config)
{
}
WL_EXPORT int
backend_init(struct weston_compositor *compositor,
struct weston_backend_config *config_base)
{
struct headless_backend *b;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
struct weston_headless_backend_config config = {{ 0, }};
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
if (config_base == NULL ||
config_base->struct_version != WESTON_HEADLESS_BACKEND_CONFIG_VERSION ||
config_base->struct_size > sizeof(struct weston_headless_backend_config)) {
weston_log("headless backend config structure is invalid\n");
return -1;
}
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
config_init_to_defaults(&config);
memcpy(&config, config_base, config_base->struct_size);
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
b = headless_backend_create(compositor, &config);
if (b == NULL)
return -1;
headless: port the headless backend to the new init api refactor configuration API of headless-backend Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v6: - Define version number in the header - Don't use leading underscores in header guards - Add stub config_init_to_defaults() - Allocate config on stack - Drop unused display_name parameter - Add error message when config is invalid - Install compositor-headless.h and list it in headless-backend sources v5: - Update to current trunk - Fixed typo 'struct weston_wayland_backend_config' - Dropped unused variables - Dropped weston_headless_backend_config_create() in favor of directly zalloc'ing the object - Dropped weston_headless_backend_load() in favor of the more generalized load_backend_new(). - Dropped typedef from header - Restored use of 'backend_init' entry point - Backend_init() takes a base weston_backend_config object - Renamed 'param' to 'config' in a few places for consistency - Renamed 'headless_options' variable to 'options for consistency - Version the base struct - Free config on error - Don't free config during backend_init normal operations - Adjust header ordering - Make header guard naming consistent with other headers - Light reformatting for code style and consistency with other backend config patches Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> [Pekka: rebased to apply before drm and x11 backends] [Pekka: squashed in the headless part of "Enforce destruction of all backend config objects after initialization"] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-04-16 03:28:32 +00:00
return 0;
}