summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-09-19 17:11:07 +0800
committerChia-I Wu <[email protected]>2010-09-19 17:19:40 +0800
commite4513e7fb96c6336d8c7fcdadfaddb6b335a736e (patch)
treee8a793caa5d0c3ff236636c6921cd61f07283948 /src/gallium/state_trackers
parente7424d72405a1cb1fb5ac625b340043aaa9f88be (diff)
st/egl: s/kms/drm/ on the drm backend.
s/kms/drm/, s/kdpy/drmdpy/, and so forth.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/egl/drm/modeset.c432
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.c94
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.h80
3 files changed, 303 insertions, 303 deletions
diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c
index 5d6a07e2fdd..06a60770537 100644
--- a/src/gallium/state_trackers/egl/drm/modeset.c
+++ b/src/gallium/state_trackers/egl/drm/modeset.c
@@ -33,23 +33,23 @@
#include "native_drm.h"
static boolean
-kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+drm_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
- if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
+ if (!resource_surface_add_resources(drmsurf->rsurf, attachment_mask))
return FALSE;
if (textures)
- resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
+ resource_surface_get_resources(drmsurf->rsurf, textures, attachment_mask);
if (seq_num)
- *seq_num = ksurf->sequence_number;
+ *seq_num = drmsurf->sequence_number;
if (width)
- *width = ksurf->width;
+ *width = drmsurf->width;
if (height)
- *height = ksurf->height;
+ *height = drmsurf->height;
return TRUE;
}
@@ -58,33 +58,33 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
* Add textures as DRM framebuffers.
*/
static boolean
-kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
+drm_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_display *drmdpy = drmsurf->drmdpy;
int num_framebuffers = (need_back) ? 2 : 1;
int i, err;
for (i = 0; i < num_framebuffers; i++) {
- struct kms_framebuffer *fb;
+ struct drm_framebuffer *fb;
enum native_attachment natt;
struct winsys_handle whandle;
uint block_bits;
if (i == 0) {
- fb = &ksurf->front_fb;
+ fb = &drmsurf->front_fb;
natt = NATIVE_ATTACHMENT_FRONT_LEFT;
}
else {
- fb = &ksurf->back_fb;
+ fb = &drmsurf->back_fb;
natt = NATIVE_ATTACHMENT_BACK_LEFT;
}
if (!fb->texture) {
/* make sure the texture has been allocated */
- resource_surface_add_resources(ksurf->rsurf, 1 << natt);
+ resource_surface_add_resources(drmsurf->rsurf, 1 << natt);
fb->texture =
- resource_surface_get_single_resource(ksurf->rsurf, natt);
+ resource_surface_get_single_resource(drmsurf->rsurf, natt);
if (!fb->texture)
return FALSE;
}
@@ -99,12 +99,12 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
+ if (!drmdpy->base.screen->resource_get_handle(drmdpy->base.screen,
fb->texture, &whandle))
return FALSE;
- block_bits = util_format_get_blocksizebits(ksurf->color_format);
- err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
+ block_bits = util_format_get_blocksizebits(drmsurf->color_format);
+ err = drmModeAddFB(drmdpy->fd, drmsurf->width, drmsurf->height,
block_bits, block_bits, whandle.stride, whandle.handle,
&fb->buffer_id);
if (err) {
@@ -117,133 +117,133 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
}
static boolean
-kms_surface_flush_frontbuffer(struct native_surface *nsurf)
+drm_surface_flush_frontbuffer(struct native_surface *nsurf)
{
#ifdef DRM_MODE_FEATURE_DIRTYFB
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_display *drmdpy = drmsurf->drmdpy;
- if (ksurf->front_fb.is_passive)
- drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
+ if (drmsurf->front_fb.is_passive)
+ drmModeDirtyFB(drmdpy->fd, drmsurf->front_fb.buffer_id, NULL, 0);
#endif
return TRUE;
}
static boolean
-kms_surface_swap_buffers(struct native_surface *nsurf)
+drm_surface_swap_buffers(struct native_surface *nsurf)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
- struct kms_display *kdpy = ksurf->kdpy;
- struct kms_framebuffer tmp_fb;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_crtc *drmcrtc = &drmsurf->current_crtc;
+ struct drm_display *drmdpy = drmsurf->drmdpy;
+ struct drm_framebuffer tmp_fb;
int err;
- if (!ksurf->back_fb.buffer_id) {
- if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
+ if (!drmsurf->back_fb.buffer_id) {
+ if (!drm_surface_init_framebuffers(&drmsurf->base, TRUE))
return FALSE;
}
- if (ksurf->is_shown && kcrtc->crtc) {
- err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
+ if (drmsurf->is_shown && drmcrtc->crtc) {
+ err = drmModeSetCrtc(drmdpy->fd, drmcrtc->crtc->crtc_id,
+ drmsurf->back_fb.buffer_id, drmcrtc->crtc->x, drmcrtc->crtc->y,
+ drmcrtc->connectors, drmcrtc->num_connectors, &drmcrtc->crtc->mode);
if (err)
return FALSE;
}
/* swap the buffers */
- tmp_fb = ksurf->front_fb;
- ksurf->front_fb = ksurf->back_fb;
- ksurf->back_fb = tmp_fb;
+ tmp_fb = drmsurf->front_fb;
+ drmsurf->front_fb = drmsurf->back_fb;
+ drmsurf->back_fb = tmp_fb;
- resource_surface_swap_buffers(ksurf->rsurf,
+ resource_surface_swap_buffers(drmsurf->rsurf,
NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
/* the front/back textures are swapped */
- ksurf->sequence_number++;
- kdpy->event_handler->invalid_surface(&kdpy->base,
- &ksurf->base, ksurf->sequence_number);
+ drmsurf->sequence_number++;
+ drmdpy->event_handler->invalid_surface(&drmdpy->base,
+ &drmsurf->base, drmsurf->sequence_number);
return TRUE;
}
static void
-kms_surface_wait(struct native_surface *nsurf)
+drm_surface_wait(struct native_surface *nsurf)
{
/* no-op */
}
static void
-kms_surface_destroy(struct native_surface *nsurf)
+drm_surface_destroy(struct native_surface *nsurf)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
- if (ksurf->current_crtc.crtc)
- drmModeFreeCrtc(ksurf->current_crtc.crtc);
+ if (drmsurf->current_crtc.crtc)
+ drmModeFreeCrtc(drmsurf->current_crtc.crtc);
- if (ksurf->front_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
- pipe_resource_reference(&ksurf->front_fb.texture, NULL);
+ if (drmsurf->front_fb.buffer_id)
+ drmModeRmFB(drmsurf->drmdpy->fd, drmsurf->front_fb.buffer_id);
+ pipe_resource_reference(&drmsurf->front_fb.texture, NULL);
- if (ksurf->back_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
- pipe_resource_reference(&ksurf->back_fb.texture, NULL);
+ if (drmsurf->back_fb.buffer_id)
+ drmModeRmFB(drmsurf->drmdpy->fd, drmsurf->back_fb.buffer_id);
+ pipe_resource_reference(&drmsurf->back_fb.texture, NULL);
- resource_surface_destroy(ksurf->rsurf);
- FREE(ksurf);
+ resource_surface_destroy(drmsurf->rsurf);
+ FREE(drmsurf);
}
-static struct kms_surface *
-kms_display_create_surface(struct native_display *ndpy,
+static struct drm_surface *
+drm_display_create_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_config *kconf = kms_config(nconf);
- struct kms_surface *ksurf;
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_config *drmconf = drm_config(nconf);
+ struct drm_surface *drmsurf;
- ksurf = CALLOC_STRUCT(kms_surface);
- if (!ksurf)
+ drmsurf = CALLOC_STRUCT(drm_surface);
+ if (!drmsurf)
return NULL;
- ksurf->kdpy = kdpy;
- ksurf->color_format = kconf->base.color_format;
- ksurf->width = width;
- ksurf->height = height;
+ drmsurf->drmdpy = drmdpy;
+ drmsurf->color_format = drmconf->base.color_format;
+ drmsurf->width = width;
+ drmsurf->height = height;
- ksurf->rsurf = resource_surface_create(kdpy->base.screen,
- ksurf->color_format,
+ drmsurf->rsurf = resource_surface_create(drmdpy->base.screen,
+ drmsurf->color_format,
PIPE_BIND_RENDER_TARGET |
PIPE_BIND_SAMPLER_VIEW |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SCANOUT);
- if (!ksurf->rsurf) {
- FREE(ksurf);
+ if (!drmsurf->rsurf) {
+ FREE(drmsurf);
return NULL;
}
- resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
+ resource_surface_set_size(drmsurf->rsurf, drmsurf->width, drmsurf->height);
- ksurf->base.destroy = kms_surface_destroy;
- ksurf->base.swap_buffers = kms_surface_swap_buffers;
- ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
- ksurf->base.validate = kms_surface_validate;
- ksurf->base.wait = kms_surface_wait;
+ drmsurf->base.destroy = drm_surface_destroy;
+ drmsurf->base.swap_buffers = drm_surface_swap_buffers;
+ drmsurf->base.flush_frontbuffer = drm_surface_flush_frontbuffer;
+ drmsurf->base.validate = drm_surface_validate;
+ drmsurf->base.wait = drm_surface_wait;
- return ksurf;
+ return drmsurf;
}
/**
* Choose a CRTC that supports all given connectors.
*/
static uint32_t
-kms_display_choose_crtc(struct native_display *ndpy,
+drm_display_choose_crtc(struct native_display *ndpy,
uint32_t *connectors, int num_connectors)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
int idx;
- for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
+ for (idx = 0; idx < drmdpy->resources->count_crtcs; idx++) {
boolean found_crtc = TRUE;
int i, j;
@@ -251,7 +251,7 @@ kms_display_choose_crtc(struct native_display *ndpy,
drmModeConnectorPtr connector;
int encoder_idx = -1;
- connector = drmModeGetConnector(kdpy->fd, connectors[i]);
+ connector = drmModeGetConnector(drmdpy->fd, connectors[i]);
if (!connector) {
found_crtc = FALSE;
break;
@@ -260,7 +260,7 @@ kms_display_choose_crtc(struct native_display *ndpy,
/* find an encoder the CRTC supports */
for (j = 0; j < connector->count_encoders; j++) {
drmModeEncoderPtr encoder =
- drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
+ drmModeGetEncoder(drmdpy->fd, connector->encoders[j]);
if (encoder->possible_crtcs & (1 << idx)) {
encoder_idx = j;
break;
@@ -279,32 +279,32 @@ kms_display_choose_crtc(struct native_display *ndpy,
break;
}
- if (idx >= kdpy->resources->count_crtcs) {
+ if (idx >= drmdpy->resources->count_crtcs) {
_eglLog(_EGL_WARNING,
"failed to find a CRTC that supports the given %d connectors",
num_connectors);
return 0;
}
- return kdpy->resources->crtcs[idx];
+ return drmdpy->resources->crtcs[idx];
}
/**
* Remember the original CRTC status and set the CRTC
*/
static boolean
-kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
+drm_display_set_crtc(struct native_display *ndpy, int crtc_idx,
uint32_t buffer_id, uint32_t x, uint32_t y,
uint32_t *connectors, int num_connectors,
drmModeModeInfoPtr mode)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_crtc *drmcrtc = &drmdpy->saved_crtcs[crtc_idx];
uint32_t crtc_id;
int err;
- if (kcrtc->crtc) {
- crtc_id = kcrtc->crtc->crtc_id;
+ if (drmcrtc->crtc) {
+ crtc_id = drmcrtc->crtc->crtc_id;
}
else {
int count = 0, i;
@@ -313,39 +313,39 @@ kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
* Choose the CRTC once. It could be more dynamic, but let's keep it
* simple for now.
*/
- crtc_id = kms_display_choose_crtc(&kdpy->base,
+ crtc_id = drm_display_choose_crtc(&drmdpy->base,
connectors, num_connectors);
/* save the original CRTC status */
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
- if (!kcrtc->crtc)
+ drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
+ if (!drmcrtc->crtc)
return FALSE;
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- drmModeConnectorPtr connector = kconn->connector;
+ for (i = 0; i < drmdpy->num_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
+ drmModeConnectorPtr connector = drmconn->connector;
drmModeEncoderPtr encoder;
- encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
+ encoder = drmModeGetEncoder(drmdpy->fd, connector->encoder_id);
if (encoder) {
if (encoder->crtc_id == crtc_id) {
- kcrtc->connectors[count++] = connector->connector_id;
- if (count >= Elements(kcrtc->connectors))
+ drmcrtc->connectors[count++] = connector->connector_id;
+ if (count >= Elements(drmcrtc->connectors))
break;
}
drmModeFreeEncoder(encoder);
}
}
- kcrtc->num_connectors = count;
+ drmcrtc->num_connectors = count;
}
- err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
+ err = drmModeSetCrtc(drmdpy->fd, crtc_id, buffer_id, x, y,
connectors, num_connectors, mode);
if (err) {
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = NULL;
- kcrtc->num_connectors = 0;
+ drmModeFreeCrtc(drmcrtc->crtc);
+ drmcrtc->crtc = NULL;
+ drmcrtc->num_connectors = 0;
return FALSE;
}
@@ -354,14 +354,14 @@ kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
}
static boolean
-kms_display_program(struct native_display *ndpy, int crtc_idx,
+drm_display_program(struct native_display *ndpy, int crtc_idx,
struct native_surface *nsurf, uint x, uint y,
const struct native_connector **nconns, int num_nconns,
const struct native_mode *nmode)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_surface *ksurf = kms_surface(nsurf);
- const struct kms_mode *kmode = kms_mode(nmode);
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ const struct drm_mode *drmmode = drm_mode(nmode);
uint32_t connector_ids[32];
uint32_t buffer_id;
drmModeModeInfo mode_tmp, *mode;
@@ -372,13 +372,13 @@ kms_display_program(struct native_display *ndpy, int crtc_idx,
num_nconns = Elements(connector_ids);
}
- if (ksurf) {
- if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
+ if (drmsurf) {
+ if (!drm_surface_init_framebuffers(&drmsurf->base, FALSE))
return FALSE;
- buffer_id = ksurf->front_fb.buffer_id;
+ buffer_id = drmsurf->front_fb.buffer_id;
/* the mode argument of drmModeSetCrtc is not constified */
- mode_tmp = kmode->mode;
+ mode_tmp = drmmode->mode;
mode = &mode_tmp;
}
else {
@@ -389,94 +389,94 @@ kms_display_program(struct native_display *ndpy, int crtc_idx,
}
for (i = 0; i < num_nconns; i++) {
- struct kms_connector *kconn = kms_connector(nconns[i]);
- connector_ids[i] = kconn->connector->connector_id;
+ struct drm_connector *drmconn = drm_connector(nconns[i]);
+ connector_ids[i] = drmconn->connector->connector_id;
}
- if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
+ if (!drm_display_set_crtc(&drmdpy->base, crtc_idx, buffer_id, x, y,
connector_ids, num_nconns, mode)) {
_eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
return FALSE;
}
- if (kdpy->shown_surfaces[crtc_idx])
- kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
- kdpy->shown_surfaces[crtc_idx] = ksurf;
+ if (drmdpy->shown_surfaces[crtc_idx])
+ drmdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
+ drmdpy->shown_surfaces[crtc_idx] = drmsurf;
/* remember the settings for buffer swapping */
- if (ksurf) {
- uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
+ if (drmsurf) {
+ uint32_t crtc_id = drmdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
+ struct drm_crtc *drmcrtc = &drmsurf->current_crtc;
- if (kcrtc->crtc)
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+ if (drmcrtc->crtc)
+ drmModeFreeCrtc(drmcrtc->crtc);
+ drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
- assert(num_nconns < Elements(kcrtc->connectors));
- memcpy(kcrtc->connectors, connector_ids,
+ assert(num_nconns < Elements(drmcrtc->connectors));
+ memcpy(drmcrtc->connectors, connector_ids,
sizeof(*connector_ids) * num_nconns);
- kcrtc->num_connectors = num_nconns;
+ drmcrtc->num_connectors = num_nconns;
- ksurf->is_shown = TRUE;
+ drmsurf->is_shown = TRUE;
}
return TRUE;
}
static const struct native_mode **
-kms_display_get_modes(struct native_display *ndpy,
+drm_display_get_modes(struct native_display *ndpy,
const struct native_connector *nconn,
int *num_modes)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_connector *kconn = kms_connector(nconn);
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_connector *drmconn = drm_connector(nconn);
const struct native_mode **nmodes_return;
int count, i;
/* delete old data */
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
+ if (drmconn->connector) {
+ drmModeFreeConnector(drmconn->connector);
+ FREE(drmconn->drm_modes);
- kconn->connector = NULL;
- kconn->kms_modes = NULL;
- kconn->num_modes = 0;
+ drmconn->connector = NULL;
+ drmconn->drm_modes = NULL;
+ drmconn->num_modes = 0;
}
/* detect again */
- kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
- if (!kconn->connector)
+ drmconn->connector = drmModeGetConnector(drmdpy->fd, drmconn->connector_id);
+ if (!drmconn->connector)
return NULL;
- count = kconn->connector->count_modes;
- kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
- if (!kconn->kms_modes) {
- drmModeFreeConnector(kconn->connector);
- kconn->connector = NULL;
+ count = drmconn->connector->count_modes;
+ drmconn->drm_modes = CALLOC(count, sizeof(*drmconn->drm_modes));
+ if (!drmconn->drm_modes) {
+ drmModeFreeConnector(drmconn->connector);
+ drmconn->connector = NULL;
return NULL;
}
for (i = 0; i < count; i++) {
- struct kms_mode *kmode = &kconn->kms_modes[i];
- drmModeModeInfoPtr mode = &kconn->connector->modes[i];
+ struct drm_mode *drmmode = &drmconn->drm_modes[i];
+ drmModeModeInfoPtr mode = &drmconn->connector->modes[i];
- kmode->mode = *mode;
+ drmmode->mode = *mode;
- kmode->base.desc = kmode->mode.name;
- kmode->base.width = kmode->mode.hdisplay;
- kmode->base.height = kmode->mode.vdisplay;
- kmode->base.refresh_rate = kmode->mode.vrefresh;
+ drmmode->base.desc = drmmode->mode.name;
+ drmmode->base.width = drmmode->mode.hdisplay;
+ drmmode->base.height = drmmode->mode.vdisplay;
+ drmmode->base.refresh_rate = drmmode->mode.vrefresh;
/* not all kernels have vrefresh = refresh_rate * 1000 */
- if (kmode->base.refresh_rate > 1000)
- kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
+ if (drmmode->base.refresh_rate > 1000)
+ drmmode->base.refresh_rate = (drmmode->base.refresh_rate + 500) / 1000;
}
nmodes_return = MALLOC(count * sizeof(*nmodes_return));
if (nmodes_return) {
for (i = 0; i < count; i++)
- nmodes_return[i] = &kconn->kms_modes[i].base;
+ nmodes_return[i] = &drmconn->drm_modes[i].base;
if (num_modes)
*num_modes = count;
}
@@ -485,135 +485,135 @@ kms_display_get_modes(struct native_display *ndpy,
}
static const struct native_connector **
-kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
+drm_display_get_connectors(struct native_display *ndpy, int *num_connectors,
int *num_crtc)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
const struct native_connector **connectors;
int i;
- if (!kdpy->connectors) {
- kdpy->connectors =
- CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
- if (!kdpy->connectors)
+ if (!drmdpy->connectors) {
+ drmdpy->connectors =
+ CALLOC(drmdpy->resources->count_connectors, sizeof(*drmdpy->connectors));
+ if (!drmdpy->connectors)
return NULL;
- for (i = 0; i < kdpy->resources->count_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
+ for (i = 0; i < drmdpy->resources->count_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
- kconn->connector_id = kdpy->resources->connectors[i];
- /* kconn->connector is allocated when the modes are asked */
+ drmconn->connector_id = drmdpy->resources->connectors[i];
+ /* drmconn->connector is allocated when the modes are asked */
}
- kdpy->num_connectors = kdpy->resources->count_connectors;
+ drmdpy->num_connectors = drmdpy->resources->count_connectors;
}
- connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
+ connectors = MALLOC(drmdpy->num_connectors * sizeof(*connectors));
if (connectors) {
- for (i = 0; i < kdpy->num_connectors; i++)
- connectors[i] = &kdpy->connectors[i].base;
+ for (i = 0; i < drmdpy->num_connectors; i++)
+ connectors[i] = &drmdpy->connectors[i].base;
if (num_connectors)
- *num_connectors = kdpy->num_connectors;
+ *num_connectors = drmdpy->num_connectors;
}
if (num_crtc)
- *num_crtc = kdpy->resources->count_crtcs;
+ *num_crtc = drmdpy->resources->count_crtcs;
return connectors;
}
static struct native_surface *
-kms_display_create_scanout_surface(struct native_display *ndpy,
+drm_display_create_scanout_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
- struct kms_surface *ksurf;
+ struct drm_surface *drmsurf;
- ksurf = kms_display_create_surface(ndpy, nconf, width, height);
- return &ksurf->base;
+ drmsurf = drm_display_create_surface(ndpy, nconf, width, height);
+ return &drmsurf->base;
}
-static struct native_display_modeset kms_display_modeset = {
- .get_connectors = kms_display_get_connectors,
- .get_modes = kms_display_get_modes,
- .create_scanout_surface = kms_display_create_scanout_surface,
- .program = kms_display_program
+static struct native_display_modeset drm_display_modeset = {
+ .get_connectors = drm_display_get_connectors,
+ .get_modes = drm_display_get_modes,
+ .create_scanout_surface = drm_display_create_scanout_surface,
+ .program = drm_display_program
};
void
-kms_display_fini_modeset(struct native_display *ndpy)
+drm_display_fini_modeset(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
int i;
- if (kdpy->connectors) {
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
+ if (drmdpy->connectors) {
+ for (i = 0; i < drmdpy->num_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
+ if (drmconn->connector) {
+ drmModeFreeConnector(drmconn->connector);
+ FREE(drmconn->drm_modes);
}
}
- FREE(kdpy->connectors);
+ FREE(drmdpy->connectors);
}
- if (kdpy->shown_surfaces) {
- FREE(kdpy->shown_surfaces);
- kdpy->shown_surfaces = NULL;
+ if (drmdpy->shown_surfaces) {
+ FREE(drmdpy->shown_surfaces);
+ drmdpy->shown_surfaces = NULL;
}
- if (kdpy->saved_crtcs) {
- for (i = 0; i < kdpy->resources->count_crtcs; i++) {
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
+ if (drmdpy->saved_crtcs) {
+ for (i = 0; i < drmdpy->resources->count_crtcs; i++) {
+ struct drm_crtc *drmcrtc = &drmdpy->saved_crtcs[i];
- if (kcrtc->crtc) {
+ if (drmcrtc->crtc) {
/* restore crtc */
- drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors,
- &kcrtc->crtc->mode);
+ drmModeSetCrtc(drmdpy->fd, drmcrtc->crtc->crtc_id,
+ drmcrtc->crtc->buffer_id, drmcrtc->crtc->x, drmcrtc->crtc->y,
+ drmcrtc->connectors, drmcrtc->num_connectors,
+ &drmcrtc->crtc->mode);
- drmModeFreeCrtc(kcrtc->crtc);
+ drmModeFreeCrtc(drmcrtc->crtc);
}
}
- FREE(kdpy->saved_crtcs);
+ FREE(drmdpy->saved_crtcs);
}
- if (kdpy->resources) {
- drmModeFreeResources(kdpy->resources);
- kdpy->resources = NULL;
+ if (drmdpy->resources) {
+ drmModeFreeResources(drmdpy->resources);
+ drmdpy->resources = NULL;
}
- kdpy->base.modeset = NULL;
+ drmdpy->base.modeset = NULL;
}
boolean
-kms_display_init_modeset(struct native_display *ndpy)
+drm_display_init_modeset(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
/* resources are fixed, unlike crtc, connector, or encoder */
- kdpy->resources = drmModeGetResources(kdpy->fd);
- if (!kdpy->resources) {
+ drmdpy->resources = drmModeGetResources(drmdpy->fd);
+ if (!drmdpy->resources) {
_eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
return FALSE;
}
- kdpy->saved_crtcs =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
- if (!kdpy->saved_crtcs) {
- kms_display_fini_modeset(&kdpy->base);
+ drmdpy->saved_crtcs =
+ CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->saved_crtcs));
+ if (!drmdpy->saved_crtcs) {
+ drm_display_fini_modeset(&drmdpy->base);
return FALSE;
}
- kdpy->shown_surfaces =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
- if (!kdpy->shown_surfaces) {
- kms_display_fini_modeset(&kdpy->base);
+ drmdpy->shown_surfaces =
+ CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->shown_surfaces));
+ if (!drmdpy->shown_surfaces) {
+ drm_display_fini_modeset(&drmdpy->base);
return FALSE;
}
- kdpy->base.modeset = &kms_display_modeset;
+ drmdpy->base.modeset = &drm_display_modeset;
return TRUE;
}
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index 8ffdde66ba8..f6dc5584370 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -37,7 +37,7 @@
#include "radeon/drm/radeon_drm.h"
static boolean
-kms_display_is_format_supported(struct native_display *ndpy,
+drm_display_is_format_supported(struct native_display *ndpy,
enum pipe_format fmt, boolean is_color)
{
return ndpy->screen->is_format_supported(ndpy->screen,
@@ -47,48 +47,48 @@ kms_display_is_format_supported(struct native_display *ndpy,
}
static const struct native_config **
-kms_display_get_configs(struct native_display *ndpy, int *num_configs)
+drm_display_get_configs(struct native_display *ndpy, int *num_configs)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
const struct native_config **configs;
/* first time */
- if (!kdpy->config) {
+ if (!drmdpy->config) {
struct native_config *nconf;
enum pipe_format format;
- kdpy->config = CALLOC(1, sizeof(*kdpy->config));
- if (!kdpy->config)
+ drmdpy->config = CALLOC(1, sizeof(*drmdpy->config));
+ if (!drmdpy->config)
return NULL;
- nconf = &kdpy->config->base;
+ nconf = &drmdpy->config->base;
nconf->buffer_mask =
(1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
(1 << NATIVE_ATTACHMENT_BACK_LEFT);
format = PIPE_FORMAT_B8G8R8A8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) {
+ if (!drm_display_is_format_supported(&drmdpy->base, format, TRUE)) {
format = PIPE_FORMAT_A8R8G8B8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))
+ if (!drm_display_is_format_supported(&drmdpy->base, format, TRUE))
format = PIPE_FORMAT_NONE;
}
if (format == PIPE_FORMAT_NONE) {
- FREE(kdpy->config);
- kdpy->config = NULL;
+ FREE(drmdpy->config);
+ drmdpy->config = NULL;
return NULL;
}
nconf->color_format = format;
/* support KMS */
- if (kdpy->resources)
+ if (drmdpy->resources)
nconf->scanout_bit = TRUE;
}
configs = MALLOC(sizeof(*configs));
if (configs) {
- configs[0] = &kdpy->config->base;
+ configs[0] = &drmdpy->config->base;
if (num_configs)
*num_configs = 1;
}
@@ -97,7 +97,7 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)
}
static int
-kms_display_get_param(struct native_display *ndpy,
+drm_display_get_param(struct native_display *ndpy,
enum native_param_type param)
{
int val;
@@ -112,22 +112,22 @@ kms_display_get_param(struct native_display *ndpy,
}
static void
-kms_display_destroy(struct native_display *ndpy)
+drm_display_destroy(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
- if (kdpy->config)
- FREE(kdpy->config);
+ if (drmdpy->config)
+ FREE(drmdpy->config);
- kms_display_fini_modeset(&kdpy->base);
+ drm_display_fini_modeset(&drmdpy->base);
- if (kdpy->base.screen)
- kdpy->base.screen->destroy(kdpy->base.screen);
+ if (drmdpy->base.screen)
+ drmdpy->base.screen->destroy(drmdpy->base.screen);
- if (kdpy->fd >= 0)
- close(kdpy->fd);
+ if (drmdpy->fd >= 0)
+ close(drmdpy->fd);
- FREE(kdpy);
+ FREE(drmdpy);
}
static const char *
@@ -155,26 +155,26 @@ get_drm_screen_name(int fd, drmVersionPtr version)
* Initialize KMS and pipe screen.
*/
static boolean
-kms_display_init_screen(struct native_display *ndpy)
+drm_display_init_screen(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
drmVersionPtr version;
const char *name;
- version = drmGetVersion(kdpy->fd);
+ version = drmGetVersion(drmdpy->fd);
if (!version) {
- _eglLog(_EGL_WARNING, "invalid fd %d", kdpy->fd);
+ _eglLog(_EGL_WARNING, "invalid fd %d", drmdpy->fd);
return FALSE;
}
- name = get_drm_screen_name(kdpy->fd, version);
+ name = get_drm_screen_name(drmdpy->fd, version);
if (name) {
- kdpy->base.screen =
- kdpy->event_handler->new_drm_screen(&kdpy->base, name, kdpy->fd);
+ drmdpy->base.screen =
+ drmdpy->event_handler->new_drm_screen(&drmdpy->base, name, drmdpy->fd);
}
drmFreeVersion(version);
- if (!kdpy->base.screen) {
+ if (!drmdpy->base.screen) {
_eglLog(_EGL_WARNING, "failed to create DRM screen");
return FALSE;
}
@@ -183,31 +183,31 @@ kms_display_init_screen(struct native_display *ndpy)
}
static struct native_display *
-kms_create_display(int fd, struct native_event_handler *event_handler,
+drm_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
{
- struct kms_display *kdpy;
+ struct drm_display *drmdpy;
- kdpy = CALLOC_STRUCT(kms_display);
- if (!kdpy)
+ drmdpy = CALLOC_STRUCT(drm_display);
+ if (!drmdpy)
return NULL;
- kdpy->fd = fd;
- kdpy->event_handler = event_handler;
- kdpy->base.user_data = user_data;
+ drmdpy->fd = fd;
+ drmdpy->event_handler = event_handler;
+ drmdpy->base.user_data = user_data;
- if (!kms_display_init_screen(&kdpy->base)) {
- kms_display_destroy(&kdpy->base);
+ if (!drm_display_init_screen(&drmdpy->base)) {
+ drm_display_destroy(&drmdpy->base);
return NULL;
}
- kdpy->base.destroy = kms_display_destroy;
- kdpy->base.get_param = kms_display_get_param;
- kdpy->base.get_configs = kms_display_get_configs;
+ drmdpy->base.destroy = drm_display_destroy;
+ drmdpy->base.get_param = drm_display_get_param;
+ drmdpy->base.get_configs = drm_display_get_configs;
- kms_display_init_modeset(&kdpy->base);
+ drm_display_init_modeset(&drmdpy->base);
- return &kdpy->base;
+ return &drmdpy->base;
}
static struct native_display *
@@ -225,7 +225,7 @@ native_create_display(void *dpy, struct native_event_handler *event_handler,
if (fd < 0)
return NULL;
- return kms_create_display(fd, event_handler, user_data);
+ return drm_create_display(fd, event_handler, user_data);
}
static const struct native_platform drm_platform = {
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
index 3a9b1a67887..03c4fe01dc1 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.h
+++ b/src/gallium/state_trackers/egl/drm/native_drm.h
@@ -23,8 +23,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef _NATIVE_KMS_H_
-#define _NATIVE_KMS_H_
+#ifndef _NATIVE_DRM_H_
+#define _NATIVE_DRM_H_
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -37,110 +37,110 @@
#include "common/native.h"
#include "common/native_helper.h"
-struct kms_config;
-struct kms_crtc;
-struct kms_connector;
-struct kms_mode;
-struct kms_surface;
+struct drm_config;
+struct drm_crtc;
+struct drm_connector;
+struct drm_mode;
+struct drm_surface;
-struct kms_display {
+struct drm_display {
struct native_display base;
struct native_event_handler *event_handler;
int fd;
- struct kms_config *config;
+ struct drm_config *config;
/* for modesetting */
drmModeResPtr resources;
- struct kms_connector *connectors;
+ struct drm_connector *connectors;
int num_connectors;
- struct kms_surface **shown_surfaces;
+ struct drm_surface **shown_surfaces;
/* save the original settings of the CRTCs */
- struct kms_crtc *saved_crtcs;
+ struct drm_crtc *saved_crtcs;
};
-struct kms_config {
+struct drm_config {
struct native_config base;
};
-struct kms_crtc {
+struct drm_crtc {
drmModeCrtcPtr crtc;
uint32_t connectors[32];
int num_connectors;
};
-struct kms_framebuffer {
+struct drm_framebuffer {
struct pipe_resource *texture;
boolean is_passive;
uint32_t buffer_id;
};
-struct kms_surface {
+struct drm_surface {
struct native_surface base;
- struct kms_display *kdpy;
+ struct drm_display *drmdpy;
struct resource_surface *rsurf;
enum pipe_format color_format;
int width, height;
unsigned int sequence_number;
- struct kms_framebuffer front_fb, back_fb;
+ struct drm_framebuffer front_fb, back_fb;
boolean is_shown;
- struct kms_crtc current_crtc;
+ struct drm_crtc current_crtc;
};
-struct kms_connector {
+struct drm_connector {
struct native_connector base;
uint32_t connector_id;
drmModeConnectorPtr connector;
- struct kms_mode *kms_modes;
+ struct drm_mode *drm_modes;
int num_modes;
};
-struct kms_mode {
+struct drm_mode {
struct native_mode base;
drmModeModeInfo mode;
};
-static INLINE struct kms_display *
-kms_display(const struct native_display *ndpy)
+static INLINE struct drm_display *
+drm_display(const struct native_display *ndpy)
{
- return (struct kms_display *) ndpy;
+ return (struct drm_display *) ndpy;
}
-static INLINE struct kms_config *
-kms_config(const struct native_config *nconf)
+static INLINE struct drm_config *
+drm_config(const struct native_config *nconf)
{
- return (struct kms_config *) nconf;
+ return (struct drm_config *) nconf;
}
-static INLINE struct kms_surface *
-kms_surface(const struct native_surface *nsurf)
+static INLINE struct drm_surface *
+drm_surface(const struct native_surface *nsurf)
{
- return (struct kms_surface *) nsurf;
+ return (struct drm_surface *) nsurf;
}
-static INLINE struct kms_connector *
-kms_connector(const struct native_connector *nconn)
+static INLINE struct drm_connector *
+drm_connector(const struct native_connector *nconn)
{
- return (struct kms_connector *) nconn;
+ return (struct drm_connector *) nconn;
}
-static INLINE struct kms_mode *
-kms_mode(const struct native_mode *nmode)
+static INLINE struct drm_mode *
+drm_mode(const struct native_mode *nmode)
{
- return (struct kms_mode *) nmode;
+ return (struct drm_mode *) nmode;
}
boolean
-kms_display_init_modeset(struct native_display *ndpy);
+drm_display_init_modeset(struct native_display *ndpy);
void
-kms_display_fini_modeset(struct native_display *ndpy);
+drm_display_fini_modeset(struct native_display *ndpy);
-#endif /* _NATIVE_KMS_H_ */
+#endif /* _NATIVE_DRM_H_ */