summaryrefslogtreecommitdiff
path: root/sys/dev/rasops
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-10-20 21:24:02 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-10-20 21:24:02 +0000
commitfb33eeebaac60c24bf5ead035da2d63f675dc290 (patch)
treeb6964334238130bf91233521e15ebc711a8d8a83 /sys/dev/rasops
parent10e70977872a9790c42077be5db06d18048385c9 (diff)
No longer store fonts added with the WSDISPLAYIO_LDFONT ioctl into the
wsdisplay softc. Instead, since the knowledge about available fonts lies in the parent driver itself, introduce a list_font wsdisplay_accessop which queries a font index, suitable to use within the WSDISPLAYIO_LSFONT ioctl. With this in place: - there is no global wsdisplay limit on the number of fonts loaded. Such a limit will be enforced by the display drivers themselves. - built-in kernel fonts will now appear in the list of fonts. Grow a list_font accesop for rasops, which relies upon wsfont_enum(), which is turned into something useful (and abortable if you do not need to iterate further). Not used by any rasops driver yet.
Diffstat (limited to 'sys/dev/rasops')
-rw-r--r--sys/dev/rasops/rasops.c54
-rw-r--r--sys/dev/rasops/rasops.h3
2 files changed, 55 insertions, 2 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c
index f524eac9296..1d561e6a23b 100644
--- a/sys/dev/rasops/rasops.c
+++ b/sys/dev/rasops/rasops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.c,v 1.29 2013/10/20 16:44:47 miod Exp $ */
+/* $OpenBSD: rasops.c,v 1.30 2013/10/20 21:24:00 miod Exp $ */
/* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */
/*-
@@ -178,6 +178,7 @@ void rasops_vcons_unpack_attr(void *, long, int *, int *, int *);
int rasops_add_font(struct rasops_info *, struct wsdisplay_font *);
int rasops_use_font(struct rasops_info *, struct wsdisplay_font *);
+int rasops_list_font_cb(void *, struct wsdisplay_font *);
/*
* Initialize a 'rasops_info' descriptor.
@@ -1707,3 +1708,54 @@ rasops_load_font(void *v, void *cookie, struct wsdisplay_font *font)
else
return rasops_use_font(ri, font);
}
+
+struct rasops_list_font_ctx {
+ struct rasops_info *ri;
+ int cnt;
+ struct wsdisplay_font *font;
+};
+
+int
+rasops_list_font_cb(void *cbarg, struct wsdisplay_font *font)
+{
+ struct rasops_list_font_ctx *ctx = cbarg;
+
+ if (font->fontheight != ctx->ri->ri_font->fontheight ||
+ font->fontwidth != ctx->ri->ri_font->fontwidth)
+ return 0;
+
+ if (ctx->cnt-- == 0) {
+ ctx->font = font;
+ return 1;
+ }
+
+ return 0;
+}
+
+int
+rasops_list_font(void *v, struct wsdisplay_font *font)
+{
+ struct rasops_info *ri = v;
+ struct rasops_list_font_ctx ctx;
+ int idx;
+
+ if ((ri->ri_flg & RI_CFGDONE) == 0 || ri->ri_font == NULL)
+ return EINVAL;
+
+ if (font->index < 0)
+ return EINVAL;
+
+ ctx.ri = ri;
+ ctx.cnt = font->index;
+ ctx.font = NULL;
+ wsfont_enum(rasops_list_font_cb, &ctx);
+
+ if (ctx.font == NULL)
+ return EINVAL;
+
+ idx = font->index;
+ *font = *ctx.font; /* struct copy */
+ font->index = idx;
+ font->cookie = font->data = NULL; /* don't leak kernel pointers */
+ return 0;
+}
diff --git a/sys/dev/rasops/rasops.h b/sys/dev/rasops/rasops.h
index bb255ef4c4f..bda5e40e1a3 100644
--- a/sys/dev/rasops/rasops.h
+++ b/sys/dev/rasops/rasops.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.h,v 1.14 2013/10/20 16:44:48 miod Exp $ */
+/* $OpenBSD: rasops.h,v 1.15 2013/10/20 21:24:00 miod Exp $ */
/* $NetBSD: rasops.h,v 1.13 2000/06/13 13:36:54 ad Exp $ */
/*-
@@ -174,6 +174,7 @@ void rasops_free_screen(void *, void *);
int rasops_show_screen(void *, void *, int,
void (*)(void *, int, int), void *);
int rasops_load_font(void *, void *, struct wsdisplay_font *);
+int rasops_list_font(void *, struct wsdisplay_font *);
int rasops_getchar(void *, int, int, struct wsdisplay_charcell *);
extern const u_char rasops_isgray[16];