NetBSD Problem Report #40105

From www@NetBSD.org  Thu Dec  4 20:55:39 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 5743B63BB35
	for <gnats-bugs@gnats.netbsd.org>; Thu,  4 Dec 2008 20:55:39 +0000 (UTC)
Message-Id: <20081204205538.D710A63BAE7@narn.NetBSD.org>
Date: Thu,  4 Dec 2008 20:55:38 +0000 (UTC)
From: nicolas.jouanne@free.fr
Reply-To: nicolas.jouanne@free.fr
To: gnats-bugs@NetBSD.org
Subject: no calibration in uep(4)
X-Send-Pr-Version: www-1.0

>Number:         40105
>Category:       kern
>Synopsis:       no calibration in uep(4)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 04 21:00:01 +0000 2008
>Closed-Date:    Mon Dec 05 14:09:08 +0000 2016
>Last-Modified:  Mon Dec 05 14:09:08 +0000 2016
>Originator:     Jouanne
>Release:        5.99.01
>Organization:
individual
>Environment:
NetBSD plop.localdomain 5.99.01 NetBSD 5.99.01 (5424) #69: Thu Dec  4 21:21:08 CET 2008  root@plop.localdomain:/usr/src/sys/arch/i386/compile/5424 i386

>Description:
uep(4) lacks calibration.
>How-To-Repeat:
n/a
>Fix:
Hard-coded calibration (EeePC 7" touchscreen)

--- /usr/src/sys/dev/usb/uep.c.orig     2008-11-09 12:09:41.000000000 +0000
+++ /usr/src/sys/dev/usb/uep.c  2008-12-04 20:20:47.000000000 +0000
@@ -59,6 +59,16 @@
 #include <dev/wscons/tpcalibvar.h>

 #define UIDSTR "eGalax USB SN000000"
+/* calibration - integer values */
+#define X_RATIO   293 
+#define X_OFFSET  -28
+#define Y_RATIO   -348
+#define Y_OFFSET  537
+/* a X_RATIO of ``312''  means : reduce by a factor 3.12 x axis amplitude */
+/* a Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
+   and revert y motion */
+#undef  UEP_DEBUG
+/* #define UEP_DEBUG 0 */

 struct uep_softc {
        USBBASEDEVICE sc_dev;
@@ -368,6 +378,9 @@

        usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);

+       /* calibration */
+       int num,denom,quot,rem ;
+
        if (status == USBD_CANCELLED)
                return;

@@ -416,6 +429,36 @@

                x = (p[3] << 7) | p[4];
                y = (p[1] << 7) | p[2];
+                
+               /* calibration */
+               
+               /* x axis */
+               num   = 100 * x ;
+               denom = X_RATIO ;
+               
+               quot  = num / denom ;
+               rem   = num % denom ;
+               
+               if (num >= 0 && rem < 0)
+                       quot++;
+               
+               x = (int) (quot) + X_OFFSET ;
+               
+               /* y axis */
+               num   = 100 * y ;
+               denom = Y_RATIO ;
+               
+               quot  = num / denom ;
+               rem   = num % denom ;
+               
+               if (num >= 0 && rem < 0)
+                       quot++;
+               
+               y = (int) (quot) + Y_OFFSET ;
+
+#ifdef UEP_DEBUG
+               printf("uep.c : (x,y) : [%d,%d].\n",x,y);
+#endif

                tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);

>Release-Note:

>Audit-Trail:
From: Nicolas Jouanne <nicolas.jouanne@free.fr>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/40105
Date: Mon, 22 Dec 2008 13:28:41 +0100

 same patch with a linguistic correction in comments  : s/revert/reverse/

 --- /usr/src/sys/dev/usb/uep.c.orig	2008-11-09 12:09:41.000000000 +0000
 +++ /usr/src/sys/dev/usb/uep.c	2008-12-04 20:20:47.000000000 +0000
 @@ -59,6 +59,16 @@
  #include <dev/wscons/tpcalibvar.h>

  #define UIDSTR	"eGalax USB SN000000"
 +/* calibration - integer values */
 +#define X_RATIO   293 
 +#define X_OFFSET  -28
 +#define Y_RATIO   -348
 +#define Y_OFFSET  537
 +/* a X_RATIO of ``312''  means : reduce by a factor 3.12 x axis amplitude */
 +/* a Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
 +   and reverse y motion */
 +#undef  UEP_DEBUG
 +/* #define UEP_DEBUG 0 */

  struct uep_softc {
  	USBBASEDEVICE sc_dev;
 @@ -368,6 +378,9 @@

  	usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);

 +	/* calibration */
 +	int num,denom,quot,rem ;
 +
  	if (status == USBD_CANCELLED)
  		return;

 @@ -416,6 +429,36 @@

  		x = (p[3] << 7) | p[4];
  		y = (p[1] << 7) | p[2];
 +                
 +		/* calibration */
 +		
 +		/* x axis */
 +		num   = 100 * x ;
 +		denom = X_RATIO ;
 +		
 +		quot  = num / denom ;
 +		rem   = num % denom ;
 +		
 +		if (num >= 0 && rem < 0)
 +			quot++;
 +		
 +		x = (int) (quot) + X_OFFSET ;
 +		
 +		/* y axis */
 +		num   = 100 * y ;
 +		denom = Y_RATIO ;
 +		
 +		quot  = num / denom ;
 +		rem   = num % denom ;
 +		
 +		if (num >= 0 && rem < 0)
 +			quot++;
 +		
 +		y = (int) (quot) + Y_OFFSET ;
 +
 +#ifdef UEP_DEBUG
 +		printf("uep.c : (x,y) : [%d,%d].\n",x,y);
 +#endif

  		tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);


From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, nicolas.jouanne@free.fr
Cc: 
Subject: Re: kern/40105
Date: Mon, 22 Dec 2008 10:20:00 -0500

 On Dec 22, 12:25pm, nicolas.jouanne@free.fr (Nicolas Jouanne) wrote:
 -- Subject: Re: kern/40105

 |  same patch with a linguistic correction in comments  : s/revert/reverse/

 How about?

 christos

 Index: uep.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/uep.c,v
 retrieving revision 1.6
 diff -u -u -r1.6 uep.c
 --- uep.c	3 Sep 2006 07:13:46 -0000	1.6
 +++ uep.c	22 Dec 2008 15:18:58 -0000
 @@ -66,6 +66,14 @@
  #include <dev/wscons/tpcalibvar.h>

  #define UIDSTR	"eGalax USB SN000000"
 +/* calibration - integer values, perhaps sysctls?  */
 +#define X_RATIO   293 
 +#define X_OFFSET  -28
 +#define Y_RATIO   -348
 +#define Y_OFFSET  537
 +/* an X_RATIO of ``312''  means : reduce by a factor 3.12 x axis amplitude */
 +/* an Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
 + * and reverse y motion */

  struct uep_softc {
  	USBBASEDEVICE sc_dev;
 @@ -354,6 +362,17 @@
  	return EPASSTHROUGH;
  }

 +static int
 +uep_adjust(int v, int off, int rat)
 +{
 +	int num = 100 * v;
 +	int quot = num / rat;
 +	int rem = num % rat;
 +	if (num >= 0 && rem < 0)
 +		quot++;
 +	return quot + off;
 +}
 +
  void
  uep_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
  {
 @@ -409,8 +428,8 @@
                   *
                   */

 -		x = (p[3] << 7) | p[4];
 -		y = (p[1] << 7) | p[2];
 +		x = uep_adjust((p[3] << 7) | p[4], X_OFFSET, X_RATIO);
 +		y = uep_adjust((p[1] << 7) | p[2], Y_OFFSET, Y_RATIO);

  		tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);


From: Nicolas Jouanne <nicolas.jouanne@free.fr>
To: christos@zoulas.com, gnats-bugs@NetBSD.org,
	kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/40105
Date: Tue, 23 Dec 2008 13:32:23 +0100

 patch application  : ok                                                         
 kernel compilation : ok                                                         
 touchscreen tests  : ok     

 -- 
 n

From: coypu@SDF.ORG
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/40105: no calibration in uep(4)
Date: Sun, 4 Dec 2016 16:40:45 +0000

 --ReaqsoxgOBHFXBhH
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi!

 This bug's patch was tested, but unfortunately. not applied.

 I've tried to apply the same to HEAD, but encoutnered one change
 since: revision 1.16 by mbalmer

 Add support for newer eGalax controllers that send 5 ot 6 byte long packets.
 The protocol is backwards compatible. While here, unfold a few lines and
 remove the link to the documentation, which was invalid.
 This enables the touchscreen on the PROTECH PS-3100 MINI POS system. 

 Attached is a version taking into account the new & msk introduced
 by mbalmer in that revision.

 What do you think?

 --ReaqsoxgOBHFXBhH
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="uep-new.diff"

 Index: uep.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/uep.c,v
 retrieving revision 1.20
 diff -u -p -u -r1.20 uep.c
 --- uep.c	23 Apr 2016 10:15:32 -0000	1.20
 +++ uep.c	4 Dec 2016 15:15:53 -0000
 @@ -54,6 +54,14 @@ __KERNEL_RCSID(0, "$NetBSD: uep.c,v 1.20
  #include <dev/wscons/tpcalibvar.h>

  #define UIDSTR	"eGalax USB SN000000"
 +/* calibration - integer values, perhaps sysctls?  */
 +#define X_RATIO   293 
 +#define X_OFFSET  -28
 +#define Y_RATIO   -348
 +#define Y_OFFSET  537
 +/* an X_RATIO of ``312''  means : reduce by a factor 3.12 x axis amplitude */
 +/* an Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
 + * and reverse y motion */

  struct uep_softc {
  	device_t sc_dev;
 @@ -358,6 +366,17 @@ uep_ioctl(void *v, u_long cmd, void *dat
  	return EPASSTHROUGH;
  }

 +static int
 +uep_adjust(int v, int off, int rat)
 +{
 +	int num = 100 * v;
 +	int quot = num / rat;
 +	int rem = num % rat;
 +	if (num >= 0 && rem < 0)
 +		quot++;
 +	return quot + off;
 +}
 +
  void
  uep_intr(struct usbd_xfer *xfer, void *addr, usbd_status status)
  {
 @@ -429,8 +448,8 @@ uep_intr(struct usbd_xfer *xfer, void *a
  		default:
  			msk = 0x0f;	/* H=0, L=0 */
  		}
 -		x = ((p[3] & msk) << 7) | p[4];
 -		y = ((p[1] & msk) << 7) | p[2];
 +		x = uep_adjust(((p[3] & msk) << 7) | p[4], X_OFFSET, X_RATIO);
 +		y = uep_adjust(((p[1] & msk) << 7) | p[2], Y_OFFSET, Y_RATIO);

  		tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);


 --ReaqsoxgOBHFXBhH--

From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40105 CVS commit: src/sys/dev/usb
Date: Mon, 5 Dec 2016 13:14:22 +0000

 Module Name:	src
 Committed By:	maya
 Date:		Mon Dec  5 13:14:22 UTC 2016

 Modified Files:
 	src/sys/dev/usb: uep.c

 Log Message:
 uep: allow (hard-coded) calibration.

 From Nicolas Jouanne in PR kern/40105
 ok skrll


 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/sys/dev/usb/uep.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Mon, 05 Dec 2016 14:09:08 +0000
State-Changed-Why:
Applied, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.