9front - general discussion about 9front
 help / color / mirror / Atom feed
From: cinap_lenrek@felloff.net
To: 9front@9front.org
Subject: Re: [9front] recent kernel changes break built-in wacom serial tablet on
Date: Sun, 14 Jan 2024 22:28:01 +0100	[thread overview]
Message-ID: <0D913CCE4BB41F2B69426CB225F5D0CE@felloff.net> (raw)
In-Reply-To: <147EB4543ABBB0841A8F54F2B9AB766B@gaff.inri.net>

another possibility:

at startup, it aux/wacom asks the device for the
resolution that it will later use for scaling:

int
query(Tablet* t)
{
	uchar buf[11];

	if(write(t->ser, "&0*", 3) < 3) return -1;
	do {
		if(read(t->ser, buf, 1) < 1) return -1;
	} while(buf[0] != 0xC0);
	if(readn(t->ser, buf+1, 10) < 10) return -1;
	t->xmax = (buf[1] << 9) | (buf[2] << 2) | ((buf[6] >> 5) & 3);
	t->ymax = (buf[3] << 9) | (buf[4] << 2) | ((buf[6] >> 3) & 3);
	t->pmax = buf[5] | (buf[6] & 7);
	t->version = (buf[9] << 7) | buf[10];
	if(write(t->ser, "1", 1) < 1) return -1;
	return 0;
}

if this procress goes wrong for some reason
(because theres maybe garbage in the fifo?),
we might end up with a out-of-range t->ymax,
causing the y-corrdinate to become stuck at
eigther extreme?

adding a debug print here would be helpfull,
and maybe just calling query() multiple times
to see if the values stay consistent:

fprint(2, "query: xmax=%d ymax=%d pmax=%d version=%d\n",
	t->xmax, t->ymax, t->pmax, t->version);

...

	if(query(t) < 0) sysfatal("%r");
+	if(query(t) < 0) sysfatal("%r");
+	if(query(t) < 0) sysfatal("%r");

and finally, we should add a debug print in
readpacket() *BEFORE* the scaling:

	m->b = head & 7;
	m->x = (buf[0] << 9) | (buf[1] << 2) | ((buf[5] >> 5) & 3);
	m->y = (buf[2] << 9) | (buf[3] << 2) | ((buf[5] >> 3) & 3);
	m->p = ((buf[5] & 7) << 7) | buf[4];

fprint(2, "readpacket: b=%x x=%d y=%d p=%d\n", m->b, m->x, m->y, m->p);

...

in any case, lets make sure we understand
what is actually happening because i dont
know of any way how our recent changes could
have screwed up your tablet :(

--
cinap

  parent reply	other threads:[~2024-01-14 21:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 21:53 sl
2024-01-12 21:59 ` sl
2024-01-14 20:24 ` cinap_lenrek
2024-01-14 20:51 ` cinap_lenrek
2024-01-14 21:28 ` cinap_lenrek [this message]
2024-01-14 21:38   ` [9front] " Stanley Lieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0D913CCE4BB41F2B69426CB225F5D0CE@felloff.net \
    --to=cinap_lenrek@felloff.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).