mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
intel: Move i915_drm.h specific code from common/intel_gem.h to common/i915/intel_gem.h
This allow us to remove one more i915_drm.h include from code shared by both backends. Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23905>
This commit is contained in:
parent
0579627f21
commit
4198a301b3
6 changed files with 93 additions and 91 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/mman.h>
|
||||
|
||||
#include "common/intel_gem.h"
|
||||
#include "common/i915/intel_gem.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
||||
#include "drm-uapi/i915_drm.h"
|
||||
|
|
|
|||
|
|
@ -49,3 +49,92 @@ i915_gem_create_context_ext(int fd,
|
|||
bool i915_gem_supports_protected_context(int fd);
|
||||
bool i915_gem_get_param(int fd, uint32_t param, int *value);
|
||||
bool i915_gem_can_render_on_fd(int fd);
|
||||
|
||||
/**
|
||||
* A wrapper around DRM_IOCTL_I915_QUERY
|
||||
*
|
||||
* Unfortunately, the error semantics of this ioctl are rather annoying so
|
||||
* it's better to have a common helper.
|
||||
*/
|
||||
static inline int
|
||||
intel_i915_query_flags(int fd, uint64_t query_id, uint32_t flags,
|
||||
void *buffer, int32_t *buffer_len)
|
||||
{
|
||||
struct drm_i915_query_item item = {
|
||||
.query_id = query_id,
|
||||
.length = *buffer_len,
|
||||
.flags = flags,
|
||||
.data_ptr = (uintptr_t)buffer,
|
||||
};
|
||||
|
||||
struct drm_i915_query args = {
|
||||
.num_items = 1,
|
||||
.flags = 0,
|
||||
.items_ptr = (uintptr_t)&item,
|
||||
};
|
||||
|
||||
int ret = intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &args);
|
||||
if (ret != 0)
|
||||
return -errno;
|
||||
else if (item.length < 0)
|
||||
return item.length;
|
||||
|
||||
*buffer_len = item.length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
intel_i915_query(int fd, uint64_t query_id, void *buffer,
|
||||
int32_t *buffer_len)
|
||||
{
|
||||
return intel_i915_query_flags(fd, query_id, 0, buffer, buffer_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query for the given data, allocating as needed
|
||||
*
|
||||
* The caller is responsible for freeing the returned pointer.
|
||||
*/
|
||||
static inline void *
|
||||
intel_i915_query_alloc(int fd, uint64_t query_id, int32_t *query_length)
|
||||
{
|
||||
if (query_length)
|
||||
*query_length = 0;
|
||||
|
||||
int32_t length = 0;
|
||||
int ret = intel_i915_query(fd, query_id, NULL, &length);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
|
||||
void *data = calloc(1, length);
|
||||
assert(data != NULL); /* This shouldn't happen in practice */
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = intel_i915_query(fd, query_id, data, &length);
|
||||
assert(ret == 0); /* We should have caught the error above */
|
||||
if (ret < 0) {
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (query_length)
|
||||
*query_length = length;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
intel_gem_add_ext(__u64 *ptr, uint32_t ext_name,
|
||||
struct i915_user_extension *ext)
|
||||
{
|
||||
__u64 *iter = ptr;
|
||||
|
||||
while (*iter != 0) {
|
||||
iter = (__u64 *) &((struct i915_user_extension *)(uintptr_t)*iter)->next_extension;
|
||||
}
|
||||
|
||||
ext->name = ext_name;
|
||||
|
||||
*iter = (uintptr_t) ext;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "drm-uapi/i915_drm.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -85,80 +83,6 @@ intel_ioctl(int fd, unsigned long request, void *arg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around DRM_IOCTL_I915_QUERY
|
||||
*
|
||||
* Unfortunately, the error semantics of this ioctl are rather annoying so
|
||||
* it's better to have a common helper.
|
||||
*/
|
||||
static inline int
|
||||
intel_i915_query_flags(int fd, uint64_t query_id, uint32_t flags,
|
||||
void *buffer, int32_t *buffer_len)
|
||||
{
|
||||
struct drm_i915_query_item item = {
|
||||
.query_id = query_id,
|
||||
.length = *buffer_len,
|
||||
.flags = flags,
|
||||
.data_ptr = (uintptr_t)buffer,
|
||||
};
|
||||
|
||||
struct drm_i915_query args = {
|
||||
.num_items = 1,
|
||||
.flags = 0,
|
||||
.items_ptr = (uintptr_t)&item,
|
||||
};
|
||||
|
||||
int ret = intel_ioctl(fd, DRM_IOCTL_I915_QUERY, &args);
|
||||
if (ret != 0)
|
||||
return -errno;
|
||||
else if (item.length < 0)
|
||||
return item.length;
|
||||
|
||||
*buffer_len = item.length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
intel_i915_query(int fd, uint64_t query_id, void *buffer,
|
||||
int32_t *buffer_len)
|
||||
{
|
||||
return intel_i915_query_flags(fd, query_id, 0, buffer, buffer_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query for the given data, allocating as needed
|
||||
*
|
||||
* The caller is responsible for freeing the returned pointer.
|
||||
*/
|
||||
static inline void *
|
||||
intel_i915_query_alloc(int fd, uint64_t query_id, int32_t *query_length)
|
||||
{
|
||||
if (query_length)
|
||||
*query_length = 0;
|
||||
|
||||
int32_t length = 0;
|
||||
int ret = intel_i915_query(fd, query_id, NULL, &length);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
|
||||
void *data = calloc(1, length);
|
||||
assert(data != NULL); /* This shouldn't happen in practice */
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = intel_i915_query(fd, query_id, data, &length);
|
||||
assert(ret == 0); /* We should have caught the error above */
|
||||
if (ret < 0) {
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (query_length)
|
||||
*query_length = length;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
bool intel_gem_supports_syncobj_wait(int fd);
|
||||
|
||||
bool
|
||||
|
|
@ -199,19 +123,4 @@ bool intel_gem_create_context_ext(int fd, enum intel_gem_create_context_flags fl
|
|||
bool intel_gem_supports_protected_context(int fd,
|
||||
enum intel_kmd_type kmd_type);
|
||||
|
||||
static inline void
|
||||
intel_gem_add_ext(__u64 *ptr, uint32_t ext_name,
|
||||
struct i915_user_extension *ext)
|
||||
{
|
||||
__u64 *iter = ptr;
|
||||
|
||||
while (*iter != 0) {
|
||||
iter = (__u64 *) &((struct i915_user_extension *)(uintptr_t)*iter)->next_extension;
|
||||
}
|
||||
|
||||
ext->name = ext_name;
|
||||
|
||||
*iter = (uintptr_t) ext;
|
||||
}
|
||||
|
||||
#endif /* INTEL_GEM_H */
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "intel/dev/intel_hwconfig.h"
|
||||
#include "intel/common/intel_gem.h"
|
||||
#include "intel/common/i915/intel_gem.h"
|
||||
|
||||
#include "util/bitscan.h"
|
||||
#include "util/log.h"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include <drm-uapi/i915_drm.h>
|
||||
|
||||
#include "common/intel_gem.h"
|
||||
#include "common/i915/intel_gem.h"
|
||||
|
||||
#include "dev/intel_debug.h"
|
||||
#include "dev/intel_device_info.h"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "i915/anv_batch_chain.h"
|
||||
|
||||
#include "drm-uapi/i915_drm.h"
|
||||
#include "intel/common/i915/intel_gem.h"
|
||||
|
||||
static uint32_t
|
||||
i915_gem_create(struct anv_device *device,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue