gbm: Give gbm_device a reference to its backend
This will be used for looking up the backend again at destruction time to perform any backend- agnostic cleanup. To facilitate that, also dispatch device destruction to the backend manager code. Signed-off-by: James Jones <jajones@nvidia.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9902>
This commit is contained in:
parent
ceb6c44fe4
commit
45bd17610c
|
@ -37,12 +37,12 @@
|
||||||
|
|
||||||
extern const struct gbm_backend gbm_dri_backend;
|
extern const struct gbm_backend gbm_dri_backend;
|
||||||
|
|
||||||
struct backend_desc {
|
struct gbm_backend_desc {
|
||||||
const char *name;
|
const char *name;
|
||||||
const struct gbm_backend *backend;
|
const struct gbm_backend *backend;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct backend_desc backends[] = {
|
static const struct gbm_backend_desc backends[] = {
|
||||||
{ "gbm_dri.so", &gbm_dri_backend },
|
{ "gbm_dri.so", &gbm_dri_backend },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,11 +52,16 @@ find_backend(const char *name, int fd)
|
||||||
struct gbm_device *dev = NULL;
|
struct gbm_device *dev = NULL;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(backends) && dev == NULL; ++i) {
|
for (i = 0; i < ARRAY_SIZE(backends); ++i) {
|
||||||
if (name && strcmp(backends[i].name, name))
|
if (name && strcmp(backends[i].name, name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = backends[i].backend->create_device(fd);
|
dev = backends[i].backend->create_device(fd);
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
dev->backend_desc = &backends[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -87,3 +92,9 @@ _gbm_create_device(int fd)
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gbm_device_destroy(struct gbm_device *gbm)
|
||||||
|
{
|
||||||
|
gbm->destroy(gbm);
|
||||||
|
}
|
||||||
|
|
|
@ -33,4 +33,7 @@
|
||||||
struct gbm_device *
|
struct gbm_device *
|
||||||
_gbm_create_device(int fd);
|
_gbm_create_device(int fd);
|
||||||
|
|
||||||
|
void
|
||||||
|
_gbm_device_destroy(struct gbm_device *gbm);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -106,7 +106,7 @@ gbm_device_get_format_modifier_plane_count(struct gbm_device *gbm,
|
||||||
GBM_EXPORT void
|
GBM_EXPORT void
|
||||||
gbm_device_destroy(struct gbm_device *gbm)
|
gbm_device_destroy(struct gbm_device *gbm)
|
||||||
{
|
{
|
||||||
gbm->destroy(gbm);
|
_gbm_device_destroy(gbm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a gbm device for allocating buffers
|
/** Create a gbm device for allocating buffers
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
* \brief Internal implementation details of gbm
|
* \brief Internal implementation details of gbm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct gbm_backend_desc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The device used for the memory allocation.
|
* The device used for the memory allocation.
|
||||||
*
|
*
|
||||||
|
@ -51,6 +53,8 @@ struct gbm_device {
|
||||||
/* Hack to make a gbm_device detectable by its first element. */
|
/* Hack to make a gbm_device detectable by its first element. */
|
||||||
struct gbm_device *(*dummy)(int);
|
struct gbm_device *(*dummy)(int);
|
||||||
|
|
||||||
|
const struct gbm_backend_desc *backend_desc;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue