Re: Reasons for keeping sc(4) and libvgl ?

From: Cejka Rudolf <cejkar_at_fit.vutbr.cz>
Date: Fri, 08 Jul 2022 15:37:10 UTC
Warner Losh wrote (2022/06/23):
> On Thu, Jun 23, 2022 at 1:44 AM Cejka Rudolf <cejkar@fit.vutbr.cz> wrote:
> > Hello,
> >   so is there any solution for problem below now?
> >
> > Cejka Rudolf wrote (2021/11/29):
> > > Hello,
> > >   I have one problem or two with VT in FreeBSD 12. I wrote a question in
> > > freebsd-stable what to do, but without response, so I still have to
> > > use SC. Please, could you look at it? There is not configured device
> > > /dev/console without monitor after upgrade from 11 to 12 and device
> > > /dev/kbdmux0 is busy using VT but not with SC.
> > >
> > > Subject: Unable to grab keyboard with VT on a headless node in stable/12
> > >
> > > Hello,
> > >   I have a headless node without monitor and without keyboard. There
> > > is just network and USB card reader in keyboard mode.
> > >
> > > In stable/11, there was no problem to disconnect USB card reader
> > > from kbdmux using kbdcontrol -A ukbd0 < /dev/console and open
> > > /dev/ukbd0 in a program.
> > >
> > > However, under stable/12 it works just with connected monitor.
> > >
> > > Without monitor, there is an error:
> > >
> > > # kbdcontrol < /dev/console
> > > -bash: /dev/console: Device not configured
> > >
> > > Furthermore with default VT, it is also impossible to use /dev/kbdmux0:
> > >
> > > # kbdcontrol < /dev/kbdmux0
> > > -bash: /dev/kbdmux0: Device busy
> > >
> > > I have found a workaround using SC, where it is possible to atleast
> > > open /dev/kbdmux0 and use kbdcontrol -A ukbd0 < /dev/kbdmux0, but why
> > > keyboard operation is now dependend on connected monitor? And why VT
> > > does not allow to open /dev/kbdmux0?
> > >
> > > Thank you.
> >
> 
> Have you filed a bug for this? This looks like a legit bug and one that
> should be easy(ish) to reproduce.

Not yet, I'm still not sure, if it is a bug or a feature.

> Or at least it looks that way on the surface, there might be a pilot error
> as well that just happened to
> work before and needs a slightly different workaround to what you are
> doing...

During getting answers to your questions I finally found a workaround - do not
use /dev/console nor /dev/kbdmux0, but use /dev/ttyv0. With /dev/ttyv0 I can
detach USB card reader:

# usbconfig show_ifdrv
ugen0.2: <GIGA-TMS USB300> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.2.0: ukbd0: <GIGA-TMS USB300, class 0/0, rev 1.10/7.03, addr 1>
ugen0.2.1: uhid0: <GIGA-TMS USB300, class 0/0, rev 1.10/7.03, addr 1>

from kbdmux0 using

kbdcontrol -A ukbd0 </dev/ttyv0

and then open /dev/ukbd0 in a program even after upgrade from FreeBSD 11 to 12
and even with

# sysctl kern.vty
kern.vty: vt

> And it's an actual monitor connected that's the only difference?

Yes.

> Or is this some KVM switch that's connected, so there's an atkbd
> in the mix somewhere?

No, just direct cable connection between computer and monitor.

> What's the difference in dmesg between
> these two boots? Is this with EFI or legacy BIOS boot?
> A dmesg with bootverbose would be most enligtening.

It is EFI boot and it seems that the only interesting difference
is that with connected monitor there is

kernel: VT(efifb): resolution 1280x1024

while with disconnected monitor there is

kernel: VT(vga): resolution 640x480

> 'Not conifgured' is ENXIO which is returned when /dev/console isn't there
> (eg, no /dev/console), which seems weird in the extreme. And it's 'bash'
> that's giving the message, which means kbdcontrol isn't even getting invoked.

Ok, however there is question, what is the suggested device for kbdcontrol.
I see just /dev/kbdmux0 or /dev/console in manual.

SC with or without monitor, both are the same (I temporarily
connected also one USB keyboard):

# kbdcontrol -i </dev/console
-bash: /dev/console: Device not configured

# kbdcontrol -i </dev/kbdmux0
kbd1:
    kbdmux0, type:AT 101/102 (2)

VT with monitor (over console, if it could be
important, I can also try this over network
connection):

# kbdcontrol -i </dev/console
kbd1:
    kbdmux0, type:AT 101/102 (2)

# kbdcontrol -i </dev/kbdmux0
bash: /dev/kbdmux0: Device busy

# kbdcontrol -i </dev/ttyv0
kbd1:
    kbdmux0, type:AT 101/102 (2)

VT without monitor (over network connection):

# kbdcontrol -i </dev/console
-bash: /dev/console: Device not configured

# kbdcontrol -i </dev/kbdmux0
-bash: /dev/kbdmux0: Device busy

# kbdcontrol -i </dev/ttyv0
kbd1:
    kbdmux0, type:AT 101/102 (2)

> And I'm also a little confused, detach ukbd0 from a usb card reader? That's
> an interesting setup. While
> it won't affect whether or not this is a bug, I'd be interested to know
> more details there...

Detach ukbd0 (= USB card reader) from kbdmux0, so USB card reader is usable
as an inpout in a program. Without detach, characters from USB card reader
are grabbed by kbdmux0.

PC connected to the network with USB card reader works as a controller
for Xerox printer for users authentication, when they want to make paid
paper copies.

-- 
Rudolf Cejka <cejkar at fit.vut.cz> https://www.fit.vut.cz/~cejkar
Brno University of Technology, Faculty of Information Technology
Bozetechova 1/2, 612 00  Brno, Czech Republic