Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/wsconsctl Add support for a read-only edid attribute th...



details:   https://anonhg.NetBSD.org/src/rev/dc19b7efdcc7
branches:  trunk
changeset: 1029186:dc19b7efdcc7
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Dec 25 13:54:13 2021 +0000

description:
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.

diffstat:

 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(-)

diffs (133 lines):

diff -r cd1e4de513e6 -r dc19b7efdcc7 sbin/wsconsctl/Makefile
--- a/sbin/wsconsctl/Makefile   Sat Dec 25 13:51:42 2021 +0000
+++ b/sbin/wsconsctl/Makefile   Sat Dec 25 13:54:13 2021 +0000
@@ -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} \
diff -r cd1e4de513e6 -r dc19b7efdcc7 sbin/wsconsctl/display.c
--- a/sbin/wsconsctl/display.c  Sat Dec 25 13:51:42 2021 +0000
+++ b/sbin/wsconsctl/display.c  Sat Dec 25 13:54:13 2021 +0000
@@ -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 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 @@
     { "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 @@
                        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 -r cd1e4de513e6 -r dc19b7efdcc7 sbin/wsconsctl/util.c
--- a/sbin/wsconsctl/util.c     Sat Dec 25 13:51:42 2021 +0000
+++ b/sbin/wsconsctl/util.c     Sat Dec 25 13:54:13 2021 +0000
@@ -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 @@
        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 @@
                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 @@
                }
        }
 }
+
diff -r cd1e4de513e6 -r dc19b7efdcc7 sbin/wsconsctl/wsconsctl.h
--- a/sbin/wsconsctl/wsconsctl.h        Sat Dec 25 13:51:42 2021 +0000
+++ b/sbin/wsconsctl/wsconsctl.h        Sat Dec 25 13:54:13 2021 +0000
@@ -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 @@
 #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 */



Home | Main Index | Thread Index | Old Index