[PATCH weston v6 09/12] drm: Move drm's output configuration into the drm backend

Bryce Harrington bryce at osg.samsung.com
Mon Apr 18 18:16:44 UTC 2016


On Sun, Apr 17, 2016 at 01:26:58PM +0300, Giulio Camuffo wrote:
> Hi,
> 
> I don't understand this one at all, you're moving configuration back
> into the backend, partially reverting patch 5.

This was done to implement the change Benoit requested in the v5 series
for tracking gbm_format as its enum type rather than as string.
 
> 2016-04-16 6:28 GMT+03:00 Bryce Harrington <bryce at osg.samsung.com>:
> > Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> > ---
> >  src/compositor-drm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++--------
> >  src/compositor-drm.h | 41 -----------------------
> >  src/main.c           | 43 ------------------------
> >  3 files changed, 80 insertions(+), 97 deletions(-)
> >
> > diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> > index 6ef706a..d129adc 100644
> > --- a/src/compositor-drm.c
> > +++ b/src/compositor-drm.c
> > @@ -75,6 +75,41 @@
> >  #define GBM_BO_USE_CURSOR GBM_BO_USE_CURSOR_64X64
> >  #endif
> >
> > +enum weston_drm_backend_output_mode {
> > +       /** The output is disabled */
> > +       WESTON_DRM_BACKEND_OUTPUT_OFF,
> > +
> > +       /** The output will use the current active mode */
> > +       WESTON_DRM_BACKEND_OUTPUT_CURRENT,
> > +
> > +       /** The output will use the preferred mode. A modeline can be provided
> > +        * by setting weston_backend_output_config::modeline in the form of
> > +        * "WIDTHxHEIGHT" or in the form of an explicit modeline calculated
> > +        * using e.g. the cvt tool. If a valid modeline is supplied it will be
> > +        * used, if invalid or NULL the preferred available mode will be used. */
> > +       WESTON_DRM_BACKEND_OUTPUT_PREFERRED,
> > +};
> > +
> > +struct weston_drm_backend_output_config {
> > +       struct weston_backend_output_config base;
> > +
> > +       /** The pixel format to be used by the output. Valid values are:
> > +        * - NULL - The format set at backend creation time will be used
> > +        * - "xrgb8888"
> > +        * - "rgb565"
> > +        * - "xrgb2101010"
> > +        */
> > +       char *gbm_format;
> > +
> > +       /** The seat to be used by the output. Set to NULL to use the
> > +        * default seat. */
> > +       char *seat;
> > +
> > +       /** The modeline to be used by the output. Refer to the documentation
> > +        * of WESTON_DRM_BACKEND_OUTPUT_PREFERRED for details. */
> > +       char *modeline;
> > +};
> > +
> >  struct drm_backend {
> >         struct weston_backend base;
> >         struct weston_compositor *compositor;
> > @@ -121,16 +156,6 @@ struct drm_backend {
> >         int32_t cursor_width;
> >         int32_t cursor_height;
> >
> > -        /** Callback used to configure the outputs.
> > -        *
> > -         * This function will be called by the backend when a new DRM
> > -         * output needs to be configured.
> > -         */
> > -        enum weston_drm_backend_output_mode
> > -       (*configure_output)(struct weston_compositor *compositor,
> > -                           bool use_current_mode,
> > -                           const char *name,
> > -                           struct weston_drm_backend_output_config *output_config);
> >         bool use_current_mode;
> >  };
> >
> > @@ -2275,6 +2300,49 @@ connector_get_current_mode(drmModeConnector *connector, int drm_fd,
> >         return 0;
> >  }
> >
> > +static enum weston_drm_backend_output_mode
> > +drm_configure_output(struct weston_compositor *c,
> > +                     bool use_current_mode,
> > +                     const char *name,
> > +                     struct weston_drm_backend_output_config *config)
> > +{
> > +       struct weston_config *wc = weston_compositor_get_user_data(c);
> 
> This is wrong, you're assuming the user data is a weston_config, which
> won't be true for non-weston compositors.
> 
> Sorry, but NAK from me.
> 
> 
> Giulio
> 
> > +       struct weston_config_section *section;
> > +       char *s;
> > +       int scale;
> > +       enum weston_drm_backend_output_mode mode =
> > +               WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
> > +
> > +       section = weston_config_get_section(wc, "output", "name", name);
> > +       weston_config_section_get_string(section, "mode", &s, "preferred");
> > +       if (strcmp(s, "off") == 0) {
> > +               free(s);
> > +               return WESTON_DRM_BACKEND_OUTPUT_OFF;
> > +       }
> > +
> > +       if (use_current_mode || strcmp(s, "current") == 0) {
> > +               mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
> > +       } else if (strcmp(s, "preferred") != 0) {
> > +               config->modeline = s;
> > +               s = NULL;
> > +       }
> > +       free(s);
> > +
> > +       weston_config_section_get_int(section, "scale", &scale, 1);
> > +       config->base.scale = scale >= 1 ? scale : 1;
> > +       weston_config_section_get_string(section, "transform", &s, "normal");
> > +       if (weston_parse_transform(s, &config->base.transform) < 0)
> > +               weston_log("Invalid transform \"%s\" for output %s\n",
> > +                          s, name);
> > +       free(s);
> > +
> > +       weston_config_section_get_string(section,
> > +                                        "gbm-format", &config->gbm_format, NULL);
> > +       weston_config_section_get_string(section, "seat", &config->seat, "");
> > +       return mode;
> > +}
> > +
> > +
> >  /**
> >   * Create and configure a Weston output structure
> >   *
> > @@ -2321,8 +2389,8 @@ create_output_for_connector(struct drm_backend *b,
> >         output->base.serial_number = "unknown";
> >         wl_list_init(&output->base.mode_list);
> >
> > -       mode = b->configure_output(b->compositor, b->use_current_mode,
> > -                                  output->base.name, &config);
> > +       mode = drm_configure_output(b->compositor, b->use_current_mode,
> > +                                   output->base.name, &config);
> >         if (parse_gbm_format(config.gbm_format, b->gbm_format, &output->gbm_format) == -1)
> >                 output->gbm_format = b->gbm_format;
> >
> > @@ -3059,7 +3127,6 @@ drm_backend_create(struct weston_compositor *compositor,
> >         b->sprites_are_broken = 1;
> >         b->compositor = compositor;
> >         b->use_pixman = config->use_pixman;
> > -       b->configure_output = config->configure_output;
> >         b->use_current_mode = config->use_current_mode;
> >
> >         if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB8888, &b->gbm_format) < 0)
> > diff --git a/src/compositor-drm.h b/src/compositor-drm.h
> > index 3b2dc17..e57b742 100644
> > --- a/src/compositor-drm.h
> > +++ b/src/compositor-drm.h
> > @@ -36,37 +36,6 @@ extern "C" {
> >
> >  #define WESTON_DRM_BACKEND_CONFIG_VERSION 1
> >
> > -enum weston_drm_backend_output_mode {
> > -       /** The output is disabled */
> > -       WESTON_DRM_BACKEND_OUTPUT_OFF,
> > -       /** The output will use the current active mode */
> > -       WESTON_DRM_BACKEND_OUTPUT_CURRENT,
> > -       /** The output will use the preferred mode. A modeline can be provided
> > -        * by setting weston_backend_output_config::modeline in the form of
> > -        * "WIDTHxHEIGHT" or in the form of an explicit modeline calculated
> > -        * using e.g. the cvt tool. If a valid modeline is supplied it will be
> > -        * used, if invalid or NULL the preferred available mode will be used. */
> > -       WESTON_DRM_BACKEND_OUTPUT_PREFERRED,
> > -};
> > -
> > -struct weston_drm_backend_output_config {
> > -       struct weston_backend_output_config base;
> > -
> > -       /** The pixel format to be used by the output. Valid values are:
> > -        * - NULL - The format set at backend creation time will be used;
> > -        * - "xrgb8888";
> > -        * - "rgb565"
> > -        * - "xrgb2101010"
> > -        */
> > -       char *gbm_format;
> > -       /** The seat to be used by the output. Set to NULL to use the
> > -        * default seat. */
> > -       char *seat;
> > -       /** The modeline to be used by the output. Refer to the documentation
> > -        * of WESTON_DRM_BACKEND_OUTPUT_PREFERRED for details. */
> > -       char *modeline;
> > -};
> > -
> >  /** The backend configuration struct.
> >   *
> >   * weston_drm_backend_config contains the configuration used by a DRM
> > @@ -107,16 +76,6 @@ struct weston_drm_backend_config {
> >          */
> >         char *gbm_format;
> >
> > -       /** Callback used to configure the outputs.
> > -        *
> > -        * This function will be called by the backend when a new DRM
> > -        * output needs to be configured.
> > -        */
> > -       enum weston_drm_backend_output_mode
> > -               (*configure_output)(struct weston_compositor *compositor,
> > -                                   bool use_current_mode,
> > -                                   const char *name,
> > -                                   struct weston_drm_backend_output_config *output_config);
> >         bool use_current_mode;
> >  };
> >
> > diff --git a/src/main.c b/src/main.c
> > index 21b7f5c..dcd5ee6 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -674,48 +674,6 @@ load_backend_new(struct weston_compositor *compositor, const char *backend,
> >         return backend_init(compositor, NULL, NULL, NULL, config_base);
> >  }
> >
> > -static enum weston_drm_backend_output_mode
> > -drm_configure_output(struct weston_compositor *c,
> > -                    bool use_current_mode,
> > -                    const char *name,
> > -                    struct weston_drm_backend_output_config *config)
> > -{
> > -       struct weston_config *wc = weston_compositor_get_user_data(c);
> > -       struct weston_config_section *section;
> > -       char *s;
> > -       int scale;
> > -       enum weston_drm_backend_output_mode mode =
> > -               WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
> > -
> > -       section = weston_config_get_section(wc, "output", "name", name);
> > -       weston_config_section_get_string(section, "mode", &s, "preferred");
> > -       if (strcmp(s, "off") == 0) {
> > -               free(s);
> > -               return WESTON_DRM_BACKEND_OUTPUT_OFF;
> > -       }
> > -
> > -       if (use_current_mode || strcmp(s, "current") == 0) {
> > -               mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
> > -       } else if (strcmp(s, "preferred") != 0) {
> > -               config->modeline = s;
> > -               s = NULL;
> > -       }
> > -       free(s);
> > -
> > -       weston_config_section_get_int(section, "scale", &scale, 1);
> > -       config->base.scale = scale >= 1 ? scale : 1;
> > -       weston_config_section_get_string(section, "transform", &s, "normal");
> > -       if (weston_parse_transform(s, &config->base.transform) < 0)
> > -               weston_log("Invalid transform \"%s\" for output %s\n",
> > -                          s, name);
> > -       free(s);
> > -
> > -       weston_config_section_get_string(section,
> > -                                        "gbm-format", &config->gbm_format, NULL);
> > -       weston_config_section_get_string(section, "seat", &config->seat, "");
> > -       return mode;
> > -}
> > -
> >  static int
> >  load_drm_backend(struct weston_compositor *c, const char *backend,
> >                  int *argc, char **argv, struct weston_config *wc)
> > @@ -745,7 +703,6 @@ load_drm_backend(struct weston_compositor *c, const char *backend,
> >
> >         config->base.struct_version = WESTON_DRM_BACKEND_CONFIG_VERSION;
> >         config->base.struct_size = sizeof(struct weston_drm_backend_config);
> > -       config->configure_output = drm_configure_output;
> >
> >         ret = load_backend_new(c, backend,
> >                                (struct weston_backend_config *)config);
> > --
> > 1.9.1
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list