On Thu, Jan 24, 2019 at 7:21 PM Eric Anholt <e...@anholt.net> wrote:
>
> Rob Herring <r...@kernel.org> writes:
>
> > Enable using etnaviv for KMS renderonly. This still needs KMS driver
> > name mapping to kmsro to be used automatically.
> >
> > Signed-off-by: Rob Herring <r...@kernel.org>
>
> > diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c 
> > b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> > index 4448150cc0c6..e086c0858f05 100644
> > --- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> > +++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c
> > @@ -27,6 +27,7 @@
> >
> >  #include "kmsro_drm_public.h"
> >  #include "vc4/drm/vc4_drm_public.h"
> > +#include "etnaviv/drm/etnaviv_drm_public.h"
> >  #include "xf86drm.h"
> >
> >  #include "pipe/p_screen.h"
> > @@ -34,22 +35,39 @@
> >
> >  struct pipe_screen *kmsro_drm_screen_create(int fd)
> >  {
> > +   struct pipe_screen *screen = NULL;
> >     struct renderonly ro = {
> > +      .kms_fd = fd,
> > +      .gpu_fd = -1,
> > +   };
> > +
> > +#if defined(GALLIUM_VC4)
> > +   ro.gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER);
> > +   if (ro.gpu_fd >= 0) {
> >        /* Passes the vc4-allocated BO through to the KMS-only DRM device 
> > using
> >         * PRIME buffer sharing.  The VC4 BO must be linear, which the 
> > SCANOUT
> >         * flag on allocation will have ensured.
> >         */
> > -      .create_for_resource = renderonly_create_gpu_import_for_resource,
> > -      .kms_fd = fd,
> > -      .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER),
> > -   };
> > +      ro.create_for_resource = renderonly_create_gpu_import_for_resource,
> > +      screen = vc4_drm_screen_create_renderonly(&ro);
> > +      if (!screen)
> > +         close(ro.gpu_fd);
> > +
> > +      return screen;
> > +   }
> > +#endif
> >
> > -   if (ro.gpu_fd < 0)
> > -      return NULL;
> > +#if defined(GALLIUM_ETNAVIV)
> > +   ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER);
> > +   if (ro.gpu_fd >= 0) {
> > +      ro.create_for_resource = 
> > renderonly_create_kms_dumb_buffer_for_resource,
> > +      screen = etna_drm_screen_create_renderonly(&ro);
> > +      if (!screen)
> > +         close(ro.gpu_fd);
> >
> > -   struct pipe_screen *screen = vc4_drm_screen_create_renderonly(&ro);
> > -   if (!screen)
> > -      close(ro.gpu_fd);
> > +      return screen;
> > +   }
> > +#endif
>
> Would it make more sense to open the first render node once, then check
> if its name matches any of the drivers we support and calling their
> setup function?

That would be more efficient. The downside is if you did have more
than one render node, then which device you get is less predictable as
it would be depending on probe order. As-is, we can handle at least
simple prioritization of drivers to use.

Rob
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to