ref: 90a08cf1fda8eaf4afe98f74a7572fb36b7ef369
parent: 1a4e03cf93872eb78f498af8afd5d8c7d6143178
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Apr 3 00:23:25 EDT 2022
vncv: some fixes to work with intel amt kvm
--- a/sys/src/cmd/vnc/auth.c
+++ b/sys/src/cmd/vnc/auth.c
@@ -35,6 +35,8 @@
v->vers = 38;
else if(strncmp(msg, "RFB 003.889\n", VerLen) == 0)
v->vers = 38; /* Darwin */
+ else if(strncmp(msg, "RFB 004.000\n", VerLen) == 0)
+ v->vers = 38;
else /* RFC6143: Any other should be treated as 3.3. */
v->vers = 33;
--- a/sys/src/cmd/vnc/color.c
+++ b/sys/src/cmd/vnc/color.c
@@ -108,6 +108,26 @@
*dst++ = bgr8[*src++];
}
+static void
+cvt16to32(uchar *dst, uchar *src, int npixel)
+{
+ uchar *ed;
+ int w, r, g, b;
+
+ ed = dst+npixel*4;
+ while(dst < ed){
+ w = src[1]<<8 | src[0];
+ b = (w >> 11) & 0x1F;
+ g = (w >> 5) & 0x3F;
+ r = (w >> 0) & 0x1F;
+ dst[0] = b<<(8-5);
+ dst[1] = g<<(8-6);
+ dst[2] = r<<(8-5);
+ dst += 4;
+ src += 2;
+ }
+}
+
void
choosecolor(Vnc *v)
{
@@ -114,12 +134,16 @@
int bpp, depth;
ulong chan;
- bpp = screen->depth;
+ chan = screen->chan;
+ depth = screen->depth;
+ bpp = depth;
if((bpp / 8) * 8 != bpp)
sysfatal("screen not supported");
- depth = screen->depth;
- chan = screen->chan;
+ if(bpp == 32 && v->Pixfmt.bpp == 16){
+ cvtpixels = cvt16to32;
+ goto Done;
+ }
if(bpp == 24){
if(verbose)
@@ -156,6 +180,7 @@
if(v->red.max == 0 || v->green.max == 0 || v->blue.max == 0)
sysfatal("screen not supported");
+Done:
if(verbose)
fprint(2, "%d bpp, %d depth, 0x%lx chan, %d truecolor, %d bigendian\n",
v->bpp, v->depth, screen->chan, v->truecolor, v->bigendian);
--- a/sys/src/cmd/vnc/draw.c
+++ b/sys/src/cmd/vnc/draw.c
@@ -171,17 +171,17 @@
if(cvtpixels){
y = r.min.y;
- off = y * stride;
+ off = y * stride + r.min.x * pixb;
for(; y < r.max.y; y++){
vncrdbytes(v, linebuf, Dx(r) * vpixb);
- (*cvtpixels)(&pixbuf[off + r.min.x * pixb], linebuf, Dx(r));
+ (*cvtpixels)(&pixbuf[off], linebuf, Dx(r));
off += stride;
}
}else{
y = r.min.y;
- off = y * stride;
+ off = y * stride + r.min.x * pixb;
for(; y < r.max.y; y++){
- vncrdbytes(v, &pixbuf[off + r.min.x * pixb], Dx(r) * pixb);
+ vncrdbytes(v, &pixbuf[off], Dx(r) * pixb);
off += stride;
}
}
@@ -396,7 +396,7 @@
type = vncrdchar(v);
switch(type){
default:
- sysfatal("bad message from server");
+ sysfatal("bad message from server: %x", type);
break;
case MFrameUpdate:
vncrdchar(v);
--- a/sys/src/cmd/vnc/vncv.c
+++ b/sys/src/cmd/vnc/vncv.c
@@ -48,6 +48,10 @@
char *p, portstr[NETPATHLEN];
int port;
+ /* leave execnet dial strings alone */
+ if(strncmp(server, "exec!", 5) == 0)
+ return server;
+
port = 5900;
if(tls)
port = 35729;
@@ -96,7 +100,7 @@
tls = 1;
break;
case 'v':
- verbose = 1;
+ verbose++;
break;
case 'k':
keypattern = EARGF(usage());