uterm: video: return buffer information on display_use()
uterm_display_use() now returns the current back-buffer index when called. It returns <0 on error. Whether OpenGL is supported is returned via a new parameter "opengl". Set it to NULL if you're not interested. Note that a backend might support OpenGL _and_ memory-mapped buffer access. But you shouldn't rely on uterm_display_use() to return the correct buffer-index if uterm_display_get_buffers() is not supported. For instance the DRM-3D backend always returns 0 as buffer index as it has no way of detecting it, yet. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
0b25c9f68a
commit
3eb9cc6f50
@ -201,6 +201,7 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp)
|
||||
unsigned int cols, rows;
|
||||
struct kmscon_font_attr attr = { "", 0, 20, false, false, 0, 0 };
|
||||
const char *be;
|
||||
bool opengl;
|
||||
|
||||
attr.ppi = term->conf->font_ppi;
|
||||
attr.points = term->conf->font_size;
|
||||
@ -242,10 +243,10 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp)
|
||||
kmscon_font_ref(scr->bold_font);
|
||||
}
|
||||
|
||||
ret = uterm_display_use(scr->disp);
|
||||
ret = uterm_display_use(scr->disp, &opengl);
|
||||
if (term->conf->render_engine)
|
||||
be = term->conf->render_engine;
|
||||
else if (!ret)
|
||||
else if (ret >= 0 && opengl)
|
||||
be = "gltex";
|
||||
else
|
||||
be = "bbulk";
|
||||
|
@ -147,6 +147,7 @@ static int gltex_set(struct kmscon_text *txt)
|
||||
GLint s;
|
||||
const char *ext;
|
||||
struct uterm_mode *mode;
|
||||
bool opengl;
|
||||
|
||||
memset(gt, 0, sizeof(*gt));
|
||||
shl_dlist_init(>->atlases);
|
||||
@ -163,8 +164,8 @@ static int gltex_set(struct kmscon_text *txt)
|
||||
if (ret)
|
||||
goto err_htable;
|
||||
|
||||
ret = uterm_display_use(txt->disp);
|
||||
if (ret) {
|
||||
ret = uterm_display_use(txt->disp, &opengl);
|
||||
if (ret < 0 || !opengl) {
|
||||
if (ret == -EOPNOTSUPP)
|
||||
log_error("display doesn't support hardware-acceleration");
|
||||
goto err_bold_htable;
|
||||
@ -231,7 +232,7 @@ static void gltex_unset(struct kmscon_text *txt)
|
||||
struct atlas *atlas;
|
||||
bool gl = true;
|
||||
|
||||
ret = uterm_display_use(txt->disp);
|
||||
ret = uterm_display_use(txt->disp, NULL);
|
||||
if (ret) {
|
||||
gl = false;
|
||||
log_warning("cannot activate OpenGL-CTX during destruction");
|
||||
@ -526,7 +527,7 @@ static int gltex_prepare(struct kmscon_text *txt)
|
||||
struct shl_dlist *iter;
|
||||
int ret;
|
||||
|
||||
ret = uterm_display_use(txt->disp);
|
||||
ret = uterm_display_use(txt->disp, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -430,6 +430,19 @@ static int display_set_dpms(struct uterm_display *disp, int state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int display_use(struct uterm_display *disp, bool *opengl)
|
||||
{
|
||||
struct fbdev_display *dfb = disp->data;
|
||||
|
||||
if (opengl)
|
||||
*opengl = false;
|
||||
|
||||
if (!(disp->flags & DISPLAY_DBUF))
|
||||
return 0;
|
||||
|
||||
return dfb->bufid ^ 1;
|
||||
}
|
||||
|
||||
static int display_get_buffers(struct uterm_display *disp,
|
||||
struct uterm_video_buffer *buffer,
|
||||
unsigned int formats)
|
||||
@ -499,7 +512,7 @@ static const struct display_ops fbdev_display_ops = {
|
||||
.activate = display_activate,
|
||||
.deactivate = display_deactivate,
|
||||
.set_dpms = display_set_dpms,
|
||||
.use = NULL,
|
||||
.use = display_use,
|
||||
.get_buffers = display_get_buffers,
|
||||
.swap = display_swap,
|
||||
.blit = uterm_fbdev_display_blit,
|
||||
|
@ -415,12 +415,12 @@ int uterm_display_get_dpms(const struct uterm_display *disp)
|
||||
return disp->dpms;
|
||||
}
|
||||
|
||||
int uterm_display_use(struct uterm_display *disp)
|
||||
int uterm_display_use(struct uterm_display *disp, bool *opengl)
|
||||
{
|
||||
if (!disp || !display_is_online(disp))
|
||||
return -EINVAL;
|
||||
|
||||
return VIDEO_CALL(disp->ops->use, -EOPNOTSUPP, disp);
|
||||
return VIDEO_CALL(disp->ops->use, -EOPNOTSUPP, disp, opengl);
|
||||
}
|
||||
|
||||
int uterm_display_get_buffers(struct uterm_display *disp,
|
||||
|
@ -164,7 +164,7 @@ void uterm_display_deactivate(struct uterm_display *disp);
|
||||
int uterm_display_set_dpms(struct uterm_display *disp, int state);
|
||||
int uterm_display_get_dpms(const struct uterm_display *disp);
|
||||
|
||||
int uterm_display_use(struct uterm_display *disp);
|
||||
int uterm_display_use(struct uterm_display *disp, bool *opengl);
|
||||
int uterm_display_get_buffers(struct uterm_display *disp,
|
||||
struct uterm_video_buffer *buffer,
|
||||
unsigned int formats);
|
||||
|
@ -305,7 +305,7 @@ static void display_deactivate(struct uterm_display *disp)
|
||||
disp->current_mode = NULL;
|
||||
}
|
||||
|
||||
static int display_use(struct uterm_display *disp)
|
||||
static int display_use(struct uterm_display *disp, bool *opengl)
|
||||
{
|
||||
struct uterm_drm3d_display *d3d = uterm_drm_display_get_data(disp);
|
||||
struct uterm_drm3d_video *v3d;
|
||||
@ -317,6 +317,10 @@ static int display_use(struct uterm_display *disp)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (opengl)
|
||||
*opengl = true;
|
||||
|
||||
/* TODO: lets find a way how to retrieve the current front buffer */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -461,7 +465,7 @@ static int display_blit(struct uterm_display *disp,
|
||||
return -EINVAL;
|
||||
|
||||
v3d = uterm_drm_video_get_data(disp->video);
|
||||
ret = display_use(disp);
|
||||
ret = display_use(disp, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = init_shaders(disp->video);
|
||||
@ -590,7 +594,7 @@ static int display_blend(struct uterm_display *disp,
|
||||
return -EINVAL;
|
||||
|
||||
v3d = uterm_drm_video_get_data(disp->video);
|
||||
ret = display_use(disp);
|
||||
ret = display_use(disp, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = init_shaders(disp->video);
|
||||
@ -748,7 +752,7 @@ static int display_fill(struct uterm_display *disp,
|
||||
int ret;
|
||||
|
||||
v3d = uterm_drm_video_get_data(disp->video);
|
||||
ret = display_use(disp);
|
||||
ret = display_use(disp, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = init_shaders(disp->video);
|
||||
@ -843,7 +847,7 @@ static void show_displays(struct uterm_video *video)
|
||||
if (iter->dpms != UTERM_DPMS_ON)
|
||||
continue;
|
||||
|
||||
ret = display_use(iter);
|
||||
ret = display_use(iter, NULL);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
|
@ -240,6 +240,16 @@ static void display_deactivate(struct uterm_display *disp)
|
||||
disp->current_mode = NULL;
|
||||
}
|
||||
|
||||
static int display_use(struct uterm_display *disp, bool *opengl)
|
||||
{
|
||||
struct uterm_drm2d_display *d2d = uterm_drm_display_get_data(disp);
|
||||
|
||||
if (opengl)
|
||||
*opengl = false;
|
||||
|
||||
return d2d->current_rb ^ 1;
|
||||
}
|
||||
|
||||
static int display_get_buffers(struct uterm_display *disp,
|
||||
struct uterm_video_buffer *buffer,
|
||||
unsigned int formats)
|
||||
@ -449,7 +459,7 @@ static const struct display_ops dumb_display_ops = {
|
||||
.activate = display_activate,
|
||||
.deactivate = display_deactivate,
|
||||
.set_dpms = uterm_drm_display_set_dpms,
|
||||
.use = NULL,
|
||||
.use = display_use,
|
||||
.get_buffers = display_get_buffers,
|
||||
.swap = display_swap,
|
||||
.blit = display_blit,
|
||||
|
@ -53,7 +53,7 @@ struct display_ops {
|
||||
int (*activate) (struct uterm_display *disp, struct uterm_mode *mode);
|
||||
void (*deactivate) (struct uterm_display *disp);
|
||||
int (*set_dpms) (struct uterm_display *disp, int state);
|
||||
int (*use) (struct uterm_display *disp);
|
||||
int (*use) (struct uterm_display *disp, bool *opengl);
|
||||
int (*get_buffers) (struct uterm_display *disp,
|
||||
struct uterm_video_buffer *buffer,
|
||||
unsigned int formats);
|
||||
|
Loading…
x
Reference in New Issue
Block a user