Module Name: src Committed By: mlelstv Date: Sat Dec 25 13:54:13 UTC 2021
Modified Files: src/sbin/wsconsctl: Makefile display.c util.c wsconsctl.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/wsconsctl/Makefile \ src/sbin/wsconsctl/display.c cvs rdiff -u -r1.32 -r1.33 src/sbin/wsconsctl/util.c cvs rdiff -u -r1.13 -r1.14 src/sbin/wsconsctl/wsconsctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/wsconsctl/Makefile diff -u src/sbin/wsconsctl/Makefile:1.16 src/sbin/wsconsctl/Makefile:1.17 --- src/sbin/wsconsctl/Makefile:1.16 Tue Oct 26 17:33:18 2021 +++ src/sbin/wsconsctl/Makefile Sat Dec 25 13:54:13 2021 @@ -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 <bsd.prog.mk> +.PATH: ${NETBSDSRCDIR}/sys/dev/videomode + # Environment for scripts executed during build. SCRIPT_ENV= \ AWK=${TOOL_AWK:Q} \ Index: src/sbin/wsconsctl/display.c diff -u src/sbin/wsconsctl/display.c:1.16 src/sbin/wsconsctl/display.c:1.17 --- src/sbin/wsconsctl/display.c:1.16 Tue Mar 20 18:50:31 2012 +++ src/sbin/wsconsctl/display.c Sat Dec 25 13:54:13 2021 @@ -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 Index: src/sbin/wsconsctl/util.c diff -u src/sbin/wsconsctl/util.c:1.32 src/sbin/wsconsctl/util.c:1.33 --- src/sbin/wsconsctl/util.c:1.32 Fri Nov 23 06:31:57 2018 +++ src/sbin/wsconsctl/util.c Sat Dec 25 13:54:13 2021 @@ -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 <dev/wscons/wsconsio.h> #include <dev/wscons/wsksymdef.h> +#include <dev/videomode/videomode.h> +#include <dev/videomode/edidreg.h> +#include <dev/videomode/edidvar.h> #include <err.h> #include <errno.h> @@ -249,6 +252,8 @@ pr_field(struct field *f, const char *se 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 *se 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) } } } + Index: src/sbin/wsconsctl/wsconsctl.h diff -u src/sbin/wsconsctl/wsconsctl.h:1.13 src/sbin/wsconsctl/wsconsctl.h:1.14 --- src/sbin/wsconsctl/wsconsctl.h:1.13 Fri Nov 23 06:31:57 2018 +++ src/sbin/wsconsctl/wsconsctl.h Sat Dec 25 13:54:13 2021 @@ -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 */