From 9e53e1415d370b3b434f4760bb20510463275631 Mon Sep 17 00:00:00 2001 From: mlelstv Date: Sat, 25 Dec 2021 13:54:13 +0000 Subject: [PATCH] Add support for a read-only edid attribute that shows the result of WSDISPLAYIO_GET_EDID. Uses code from sys/dev/videomode to parse and print the edid data. --- sbin/wsconsctl/Makefile | 8 +++++--- sbin/wsconsctl/display.c | 13 ++++++++++++- sbin/wsconsctl/util.c | 17 ++++++++++++++++- sbin/wsconsctl/wsconsctl.h | 3 ++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/sbin/wsconsctl/Makefile b/sbin/wsconsctl/Makefile index d40ba6e82985..d5228404eb7c 100644 --- a/sbin/wsconsctl/Makefile +++ b/sbin/wsconsctl/Makefile @@ -1,17 +1,19 @@ -# $NetBSD: Makefile,v 1.16 2021/10/26 17:33:18 rillig Exp $ +# $NetBSD: Makefile,v 1.17 2021/12/25 13:54:13 mlelstv Exp $ PROG= wsconsctl SRCS= display.c keyboard.c keysym.c map_parse.y map_scan.l \ - mouse.c util.c wsconsctl.c + mouse.c util.c wsconsctl.c edid.c vesagtf.o videomode.o MAN= wsconsctl.8 YHEADER= 1 -CPPFLAGS+= -I. -I${.CURDIR} +CPPFLAGS+= -I. -I${.CURDIR} -I${NETBSDSRCDIR}/sys DPSRCS+= keysym.h CLEANFILES+= keysym.h .include +.PATH: ${NETBSDSRCDIR}/sys/dev/videomode + # Environment for scripts executed during build. SCRIPT_ENV= \ AWK=${TOOL_AWK:Q} \ diff --git a/sbin/wsconsctl/display.c b/sbin/wsconsctl/display.c index 5715d09dcb9c..cfbde2448821 100644 --- a/sbin/wsconsctl/display.c +++ b/sbin/wsconsctl/display.c @@ -1,4 +1,4 @@ -/* $NetBSD: display.c,v 1.16 2012/03/20 18:50:31 matt Exp $ */ +/* $NetBSD: display.c,v 1.17 2021/12/25 13:54:13 mlelstv Exp $ */ /*- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -49,6 +49,8 @@ static struct wsdisplay_param backlight; static struct wsdisplay_param brightness; static struct wsdisplay_param contrast; static struct wsdisplay_scroll_data scroll_l; +static struct wsdisplayio_edid_info edid_info; +static uint8_t edid_buf[256]; static int msg_default_attrs, msg_default_bg, msg_default_fg; static int msg_kernel_attrs, msg_kernel_bg, msg_kernel_fg; static int splash_enable, splash_progress; @@ -62,6 +64,7 @@ struct field display_field_tab[] = { { "contrast", &contrast.curval, FMT_UINT, FLG_MODIFY }, { "scroll.fastlines", &scroll_l.fastlines, FMT_UINT, FLG_MODIFY }, { "scroll.slowlines", &scroll_l.slowlines, FMT_UINT, FLG_MODIFY }, + { "edid", &edid_info, FMT_EDID, FLG_RDONLY|FLG_NOAUTO }, { "msg.default.attrs", &msg_default_attrs, FMT_ATTRS, 0 }, { "msg.default.bg", &msg_default_bg, FMT_COLOR, 0 }, { "msg.default.fg", &msg_default_fg, FMT_COLOR, 0 }, @@ -144,6 +147,14 @@ display_get_values(int fd) field_disable_by_value(&scroll_l.slowlines); } } + + if (field_by_value(&edid_info)->flags & FLG_GET) { + edid_info.edid_data = edid_buf; + edid_info.buffer_size = sizeof(edid_buf); + if (ioctl(fd, WSDISPLAYIO_GET_EDID, &edid_info) < 0) { + field_disable_by_value(&edid_info); + } + } } void diff --git a/sbin/wsconsctl/util.c b/sbin/wsconsctl/util.c index c0813749a4ea..f21fb3d35a03 100644 --- a/sbin/wsconsctl/util.c +++ b/sbin/wsconsctl/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.32 2018/11/23 06:31:57 mlelstv Exp $ */ +/* $NetBSD: util.c,v 1.33 2021/12/25 13:54:13 mlelstv Exp $ */ /*- * Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc. @@ -33,6 +33,9 @@ #include #include +#include +#include +#include #include #include @@ -249,6 +252,8 @@ pr_field(struct field *f, const char *sep) const char *p; unsigned int flags; int first, i, mask; + struct wsdisplayio_edid_info *info; + struct edid_info edid; if (sep) (void)printf("%s%s", f->name, sep); @@ -318,6 +323,15 @@ pr_field(struct field *f, const char *sep) if (first) (void)printf("none"); break; + case FMT_EDID: + info = (struct wsdisplayio_edid_info *)f->valp; + if (edid_parse(info->edid_data, &edid)) + (void)printf("invalid"); + else { + (void)printf("\n"); + edid_print(&edid); + } + break; default: errx(EXIT_FAILURE, "internal error: pr_field: no format %d", f->format); @@ -512,3 +526,4 @@ print_kmap(struct wskbd_map_data *map) } } } + diff --git a/sbin/wsconsctl/wsconsctl.h b/sbin/wsconsctl/wsconsctl.h index 60937b7518f8..b0266097eafb 100644 --- a/sbin/wsconsctl/wsconsctl.h +++ b/sbin/wsconsctl/wsconsctl.h @@ -1,4 +1,4 @@ -/* $NetBSD: wsconsctl.h,v 1.13 2018/11/23 06:31:57 mlelstv Exp $ */ +/* $NetBSD: wsconsctl.h,v 1.14 2021/12/25 13:54:13 mlelstv Exp $ */ /*- * Copyright (c) 1998, 2004, 2012 The NetBSD Foundation, Inc. @@ -63,6 +63,7 @@ struct field { #define FMT_KBMAP 105 /* keyboard map */ #define FMT_COLOR 201 /* display color */ #define FMT_ATTRS 202 /* display attributes */ +#define FMT_EDID 203 /* edid data */ int format; #define FLG_RDONLY 0x0001 /* variable cannot be modified */ #define FLG_WRONLY 0x0002 /* variable cannot be displayed */