Full analysis of libdrm 20 - Full analysis of source code (17)

Continued from the previous article: Full analysis of libdrm 19 - Full analysis of source code (16)

This article refers to the following blog posts:

DRM driver development (VKMS)

Thank you very much!

This article continues to explain the actual function macro definition in include/drm/drm.h.

29. DRM_IOCTL_SET_MASTER

The 29th macro is DRM_IOCTL_SET_MASTER, the corresponding code is as follows:

#define DRM_IOCTL_SET_MASTER            DRM_IO(0x1e)

Combined with the final definition of _IO(type,nr) in the previous article, the following code is obtained:

#define DRM_IOCTL_SET_MASTER        ( ((0)  << 30) | (('d') << 8) | ((0x1e)   << 0) | ((0) << 16) )

The Userspace API corresponding to DRM_IOCTL_SET_MASTER is: drmSetMaster(). This function is also in xf86drm.c, the code is as follows:

drm_public int drmSetMaster(int fd)
{
        return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL);
}

The role of the function is to obtain DRM-Master access rights. This function will be analyzed in detail later when the function is explained in detail. Let's get to know each other first and have an impression.

30. DRM_IOCTL_DROP_MASTER

The 30th macro is DRM_IOCTL_DROP_MASTER, the corresponding code is as follows:

#define DRM_IOCTL_DROP_MASTER           DRM_IO(0x1f)

Combined with the final definition of _IOWR(type,nr,size) in the previous article, the following code is obtained:

#define DRM_IOCTL_DROPMASTER        ( ((0)  << 30) | (('d') << 8) | ((0x1f)   << 0) | ((0) << 16) )

The Userspace API corresponding to DRM_IOCTL_DROP_MASTER is: drmDropMaster(). This function is also in xf86drm.c, the code is as follows:

drm_public int drmDropMaster(int fd)
{
        return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL);
}

The role of the function is to give up the DRM-Master access right. This function will be analyzed in detail later when the function is explained in detail. Let's get to know each other first and have an impression.

The remaining macro definitions will continue to be analyzed in subsequent articles.

Guess you like

Origin blog.csdn.net/phmatthaus/article/details/132491488