[PATCH 1/2] compositor-drm: Cache the DPMS property on drm_output

Kristian Høgsberg hoegsberg at gmail.com
Tue Jun 4 21:01:00 PDT 2013


On Tue, Jun 04, 2013 at 06:31:26PM +0200, David Herrmann wrote:
> Hi Ander
> 
> On Tue, Jun 4, 2013 at 3:24 PM, Ander Conselvan de Oliveira
> <conselvan2 at gmail.com> wrote:
> > From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
> >
> > This avoids one drmModeGetConnector() call every time the DPMS mode is
> > set. That call can take hundreds of milliseconds due to DDC.
> > ---
> >  src/compositor-drm.c |   21 +++++++--------------
> >  1 file changed, 7 insertions(+), 14 deletions(-)
> >
> > diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> > index 4222e57..27d4d02 100644
> > --- a/src/compositor-drm.c
> > +++ b/src/compositor-drm.c
> > @@ -145,6 +145,7 @@ struct drm_output {
> >         uint32_t connector_id;
> >         drmModeCrtcPtr original_crtc;
> >         struct drm_edid edid;
> > +       drmModePropertyPtr dpms_prop;
> >
> >         int vblank_pending;
> >         int page_flip_pending;
> > @@ -1054,6 +1055,8 @@ drm_output_destroy(struct weston_output *output_base)
> >         if (output->backlight)
> >                 backlight_destroy(output->backlight);
> >
> > +       drmModeFreeProperty(output->dpms_prop);
> > +
> >         /* Turn off hardware cursor */
> >         drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
> >
> > @@ -1365,23 +1368,12 @@ drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
> >         struct drm_output *output = (struct drm_output *) output_base;
> >         struct weston_compositor *ec = output_base->compositor;
> >         struct drm_compositor *c = (struct drm_compositor *) ec;
> > -       drmModeConnectorPtr connector;
> > -       drmModePropertyPtr prop;
> >
> > -       connector = drmModeGetConnector(c->drm.fd, output->connector_id);
> > -       if (!connector)
> > +       if (!output->dpms_prop)
> >                 return;
> >
> > -       prop = drm_get_prop(c->drm.fd, connector, "DPMS");
> > -       if (!prop) {
> > -               drmModeFreeConnector(connector);
> > -               return;
> > -       }
> > -
> > -       drmModeConnectorSetProperty(c->drm.fd, connector->connector_id,
> > -                                   prop->prop_id, level);
> > -       drmModeFreeProperty(prop);
> > -       drmModeFreeConnector(connector);
> > +       drmModeConnectorSetProperty(c->drm.fd, output->connector_id,
> > +                                   output->dpms_prop->prop_id, level);
> >  }
> >
> >  static const char *connector_type_names[] = {
> > @@ -1813,6 +1805,7 @@ create_output_for_connector(struct drm_compositor *ec,
> >         ec->connector_allocator |= (1 << output->connector_id);
> >
> >         output->original_crtc = drmModeGetCrtc(ec->drm.fd, output->crtc_id);
> > +       output->dpms_prop = drm_get_prop(ec->drm.fd, connector, "DPMS");
> 
> Please also call this on VT_Enter(). Other sessions might disable
> connectors and we need to detect that and refresh our state.
> Otherwise, we end up with an outdated cache and disabled connector and
> we will get errors on drmModeSetCrtc().

I don't think this is making things worse than they already are.  We
do full modeset on vt enter which restores the cached
crtc/connector/encoder configuration that the cached values expect.

Kristian

> Regards
> David
> 
> >
> >         /* Get the current mode on the crtc that's currently driving
> >          * this connector. */
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list