- bufmgr_sprd->fd = _tbm_sprd_open_drm();
- if (bufmgr_sprd->fd < 0) {
- TBM_ERR("fail to open drm!\n");
+ TBM_ERR("fail to open drm!\n");
+ if (error)
+ *error = TBM_ERROR_INVALID_OPERATION;
+ goto fail_open_drm;
+ }
+
+ if (drmIsMaster(bufmgr_sprd->fd)) {
+ tbm_drm_helper_set_tbm_master_fd(bufmgr_sprd->fd);
+
+ bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd);
+ if (!bufmgr_sprd->device_name) {
+ TBM_ERR("fail to get device name!\n");
+ tbm_drm_helper_unset_tbm_master_fd();
+ if (error)
+ *error = TBM_ERROR_INVALID_OPERATION;
+ goto fail_get_device_name;
+ }
+ TBM_ERR("This is Master FD(%d) from open_drm.", bufmgr_sprd->fd);
+ } else {
+ /* close the fd and get the authenticated fd from the master fd */
+ close(bufmgr_sprd->fd);
+ bufmgr_sprd->fd = -1;
+
+ /* get the authenticated drm fd from the master fd */
+ if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) {
+ TBM_ERR("fail to get auth drm info!\n");