Re: [PATCH 1/2] Add new drmOpenWithType function (v4)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11 February 2015 at 04:40, Jammy Zhou <Jammy.Zhou@xxxxxxx> wrote:
> v2: Add drmGetMinorBase, and call drmOpenWithType in drmOpen
> v3: Pass 'type' to drmOpenByBusid and drmOpenDevice in drmOpenByName
> v4: Renumber node type definitions, and return -1 for unsupported type
>
> Signed-off-by: Jammy Zhou <Jammy.Zhou@xxxxxxx>
> Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx> (v3)
> ---
>  xf86drm.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++--------------
>  xf86drm.h |  9 +++++++-
>  2 files changed, 63 insertions(+), 16 deletions(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 345325a..998f010 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
[snip]
> @@ -507,16 +517,20 @@ int drmAvailable(void)
>   *
>   * \sa drmOpenMinor() and drmGetBusid().
>   */
> -static int drmOpenByBusid(const char *busid)
> +static int drmOpenByBusid(const char *busid, int type)
>  {
>      int        i, pci_domain_ok = 1;
>      int        fd;
>      const char *buf;
>      drmSetVersion sv;
> +    int        base = drmGetMinorBase(type);
Nitpick: If we make this const int, the compiler should not
fetch/compute the loop upper limit on each iteration.
Same thing goes for the other use cases.

> +
> +    if (base < 0)
> +        return -1;
>
>      drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
> -    for (i = 0; i < DRM_MAX_MINOR; i++) {
> -       fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY);
> +    for (i = base; i < base + DRM_MAX_MINOR; i++) {
> +       fd = drmOpenMinor(i, 1, type);
>         drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
>         if (fd >= 0) {
>             /* We need to try for 1.4 first for proper PCI domain support
[snip]
> diff --git a/xf86drm.h b/xf86drm.h
> index bfd0670..7e82521 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -552,7 +552,14 @@ do {       register unsigned int __old __asm("o0");                \
>  /* General user-level programmer's API: unprivileged */
>  extern int           drmAvailable(void);
>  extern int           drmOpen(const char *name, const char *busid);
> -extern int drmOpenControl(int minor);
> +
> +#define DRM_NODE_PRIMARY 0
> +#define DRM_NODE_CONTROL 1
> +#define DRM_NODE_RENDER  2
How do others feel about define vs enum nowadays ? I both are fine
imho yet I've went with the latter in another patch :-)

-Emil
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux