Support Wacom One M (CTL-672) [Was: Support Wacom One S (CTL-472)]

2022-12-08 Thread Sven M . Hallberg
Marcus Glocker on Sat, Sep 03 2022:
> I have an Wacom One CTL-672, never used it on OpenBSD.

This is the "Wacom One M", which I also own...

> Currently it attaches to ums(4). Works fine with that.

It seems to expose two HIDs, one which reports as a regular "mouse" and
makes it work like a touchpad (relative mode), and a second one (with a
nonsense report descriptor) that can be used for absolute positioning.

> It also works fine when attaching to uwacom(4), without and with your
> diff.  It doesn't seem to require specific 'tsscale' nor
> 'loc_tip_press' settings.

This does not match my experience; the second device (which uwacom
attaches to) did not produce any events. It appears it needs the call to
uhidev_set_report() of the "One S" code path to switch on.

Trivial patch below that made it produce events for me.

I did have to fiddle with xinput(1) to get the scale right. I ended up
putting the following in its InputDevice section in /etc/X11/xorg.conf:

Option  "TransformationMatrix" "0.09 0 0 0 0.08 0 0 0 1"

I wonder what the correct way is to avoid having to do this. Is it those
tsscale parameters? If so, what's the best way to determine the correct
values?

-pesco


Index: dev/usb/uwacom.c
===
RCS file: /cvs/src/sys/dev/usb/uwacom.c,v
retrieving revision 1.7
diff -u -p -r1.7 uwacom.c
--- dev/usb/uwacom.c8 Oct 2022 06:53:06 -   1.7
+++ dev/usb/uwacom.c8 Dec 2022 12:47:44 -
@@ -141,7 +141,8 @@ uwacom_attach(struct device *parent, str
ms->sc_loc_btn[2].pos = 2;
ms->sc_loc_btn[2].size = 1;
 
-   if (uha->uaa->product == USB_PRODUCT_WACOM_ONE_S) {
+   if (uha->uaa->product == USB_PRODUCT_WACOM_ONE_S ||
+   uha->uaa->product == USB_PRODUCT_WACOM_ONE_M) {
static uByte reportbuf[2] = { 0x02, 0x02 };
uhidev_set_report(uha->parent, UHID_FEATURE_REPORT, 2,
&reportbuf, 2);



Re: agtimer(4/armv7): switch to clockintr

2022-12-08 Thread Mark Kettenis
> From: Jeremie Courreges-Anglas 
> Date: Thu, 08 Dec 2022 11:35:34 +0100
> 
> On Wed, Dec 07 2022, Scott Cheloha  wrote:
> > ARMv7 has four interrupt clocks available.  I think it'll be easier to
> > review/test if we do the clockintr switch driver by driver instead of
> > all at once in a massive single email.  When all four driver patches
> > are confirmed to work, I'll commit them.
> >
> > Here's a patch to switch agtimer(4/armv7) to clockintr.
> >
> > - Remove agtimer-specific clock interrupt scheduling bits
> >   and randomized statclock bits.
> >
> > - Wire up agtimer_intrclock.
> >
> > I am looking for a tester to help me get it compiling,
> 
> Fails to build because of a signature mismatch for agtimer_trigger(),
> updated diff below.
> 
> > and then run it
> > through a kernel-release-upgrade cycle.
> 
> That's not what you're asking for, but no regression spotted on a cubox
> machine - which seems to use amptimer(4) according to dmesg.

But that is important to test too! ;)

> Index: sys/arch/arm/include/cpu.h
> ===
> RCS file: /home/cvs/src/sys/arch/arm/include/cpu.h,v
> retrieving revision 1.61
> diff -u -p -r1.61 cpu.h
> --- sys/arch/arm/include/cpu.h6 Jul 2021 09:34:06 -   1.61
> +++ sys/arch/arm/include/cpu.h7 Dec 2022 23:09:20 -
> @@ -149,6 +149,7 @@ void  arm32_vector_init(vaddr_t, int);
>   * Per-CPU information.  For now we assume one CPU.
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -198,7 +199,7 @@ struct cpu_info {
>  #ifdef GPROF
>   struct gmonparam *ci_gmon;
>  #endif
> -
> + struct clockintr_queue  ci_queue;
>   charci_panicbuf[512];
>  };
>  
> Index: sys/arch/arm/include/_types.h
> ===
> RCS file: /home/cvs/src/sys/arch/arm/include/_types.h,v
> retrieving revision 1.19
> diff -u -p -r1.19 _types.h
> --- sys/arch/arm/include/_types.h 5 Mar 2018 01:15:25 -   1.19
> +++ sys/arch/arm/include/_types.h 7 Dec 2022 23:09:20 -
> @@ -35,6 +35,8 @@
>  #ifndef _ARM__TYPES_H_
>  #define _ARM__TYPES_H_
>  
> +#define  __HAVE_CLOCKINTR
> +
>  #if defined(_KERNEL)
>  typedef struct label_t {
>   long val[11];
> Index: sys/arch/arm/cortex/agtimer.c
> ===
> RCS file: /home/cvs/src/sys/arch/arm/cortex/agtimer.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 agtimer.c
> --- sys/arch/arm/cortex/agtimer.c 12 Mar 2022 14:40:41 -  1.15
> +++ sys/arch/arm/cortex/agtimer.c 7 Dec 2022 23:37:14 -
> @@ -17,9 +17,11 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -51,28 +53,12 @@ static struct timecounter agtimer_timeco
>   .tc_priv = NULL,
>  };
>  
> -struct agtimer_pcpu_softc {
> - uint64_tpc_nexttickevent;
> - uint64_tpc_nextstatevent;
> - u_int32_t   pc_ticks_err_sum;
> -};
> -
>  struct agtimer_softc {
>   struct device   sc_dev;
>   int sc_node;
> -
> - struct agtimer_pcpu_softc sc_pstat[MAXCPUS];
> -
> - u_int32_t   sc_ticks_err_cnt;
>   u_int32_t   sc_ticks_per_second;
> - u_int32_t   sc_ticks_per_intr;
> - u_int32_t   sc_statvar;
> - u_int32_t   sc_statmin;
> -
> -#ifdef AMPTIMER_DEBUG
> - struct evcount  sc_clk_count;
> - struct evcount  sc_stat_count;
> -#endif
> + uint64_tsc_nsec_cycle_ratio;
> + uint64_tsc_nsec_max;
>  };
>  
>  int  agtimer_match(struct device *, void *, void *);
> @@ -81,9 +67,11 @@ uint64_t   agtimer_readcnt64(void);
>  int  agtimer_intr(void *);
>  void agtimer_cpu_initclocks(void);
>  void agtimer_delay(u_int);
> +void agtimer_rearm(void *, uint64_t);
>  void agtimer_setstatclockrate(int stathz);
>  void agtimer_set_clockrate(int32_t new_frequency);
>  void agtimer_startclock(void);
> +void agtimer_trigger(void *);
>  
>  const struct cfattach agtimer_ca = {
>   sizeof (struct agtimer_softc), agtimer_match, agtimer_attach
> @@ -93,6 +81,11 @@ struct cfdriver agtimer_cd = {
>   NULL, "agtimer", DV_DULL
>  };
>  
> +struct intrclock agtimer_intrclock = {
> + .ic_rearm = agtimer_rearm,
> + .ic_trigger = agtimer_trigger
> +};
> +
>  uint64_t
>  agtimer_readcnt64(void)
>  {
> @@ -155,16 +148,13 @@ agtimer_attach(struct device *parent, st
>   agtimer_frequency =
>   OF_getpropint(sc->sc_node, "clock-frequency", agtimer_frequency);
>   sc->sc_ticks_per_second = agtimer_frequency;
> -
> + sc->sc_nsec_cycle_ratio =
> + sc->sc_ticks_per_second * (1ULL << 32) / 10;
> + sc->sc_nsec_max = UINT64_MAX / sc->sc_nsec_cycle_r

Re: agtimer(4/armv7): switch to clockintr

2022-12-08 Thread Jeremie Courreges-Anglas
On Wed, Dec 07 2022, Scott Cheloha  wrote:
> ARMv7 has four interrupt clocks available.  I think it'll be easier to
> review/test if we do the clockintr switch driver by driver instead of
> all at once in a massive single email.  When all four driver patches
> are confirmed to work, I'll commit them.
>
> Here's a patch to switch agtimer(4/armv7) to clockintr.
>
> - Remove agtimer-specific clock interrupt scheduling bits
>   and randomized statclock bits.
>
> - Wire up agtimer_intrclock.
>
> I am looking for a tester to help me get it compiling,

Fails to build because of a signature mismatch for agtimer_trigger(),
updated diff below.

> and then run it
> through a kernel-release-upgrade cycle.

That's not what you're asking for, but no regression spotted on a cubox
machine - which seems to use amptimer(4) according to dmesg.



Index: sys/arch/arm/include/cpu.h
===
RCS file: /home/cvs/src/sys/arch/arm/include/cpu.h,v
retrieving revision 1.61
diff -u -p -r1.61 cpu.h
--- sys/arch/arm/include/cpu.h  6 Jul 2021 09:34:06 -   1.61
+++ sys/arch/arm/include/cpu.h  7 Dec 2022 23:09:20 -
@@ -149,6 +149,7 @@ voidarm32_vector_init(vaddr_t, int);
  * Per-CPU information.  For now we assume one CPU.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -198,7 +199,7 @@ struct cpu_info {
 #ifdef GPROF
struct gmonparam *ci_gmon;
 #endif
-
+   struct clockintr_queue  ci_queue;
charci_panicbuf[512];
 };
 
Index: sys/arch/arm/include/_types.h
===
RCS file: /home/cvs/src/sys/arch/arm/include/_types.h,v
retrieving revision 1.19
diff -u -p -r1.19 _types.h
--- sys/arch/arm/include/_types.h   5 Mar 2018 01:15:25 -   1.19
+++ sys/arch/arm/include/_types.h   7 Dec 2022 23:09:20 -
@@ -35,6 +35,8 @@
 #ifndef _ARM__TYPES_H_
 #define _ARM__TYPES_H_
 
+#define__HAVE_CLOCKINTR
+
 #if defined(_KERNEL)
 typedef struct label_t {
long val[11];
Index: sys/arch/arm/cortex/agtimer.c
===
RCS file: /home/cvs/src/sys/arch/arm/cortex/agtimer.c,v
retrieving revision 1.15
diff -u -p -r1.15 agtimer.c
--- sys/arch/arm/cortex/agtimer.c   12 Mar 2022 14:40:41 -  1.15
+++ sys/arch/arm/cortex/agtimer.c   7 Dec 2022 23:37:14 -
@@ -17,9 +17,11 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -51,28 +53,12 @@ static struct timecounter agtimer_timeco
.tc_priv = NULL,
 };
 
-struct agtimer_pcpu_softc {
-   uint64_tpc_nexttickevent;
-   uint64_tpc_nextstatevent;
-   u_int32_t   pc_ticks_err_sum;
-};
-
 struct agtimer_softc {
struct device   sc_dev;
int sc_node;
-
-   struct agtimer_pcpu_softc sc_pstat[MAXCPUS];
-
-   u_int32_t   sc_ticks_err_cnt;
u_int32_t   sc_ticks_per_second;
-   u_int32_t   sc_ticks_per_intr;
-   u_int32_t   sc_statvar;
-   u_int32_t   sc_statmin;
-
-#ifdef AMPTIMER_DEBUG
-   struct evcount  sc_clk_count;
-   struct evcount  sc_stat_count;
-#endif
+   uint64_tsc_nsec_cycle_ratio;
+   uint64_tsc_nsec_max;
 };
 
 intagtimer_match(struct device *, void *, void *);
@@ -81,9 +67,11 @@ uint64_t agtimer_readcnt64(void);
 intagtimer_intr(void *);
 void   agtimer_cpu_initclocks(void);
 void   agtimer_delay(u_int);
+void   agtimer_rearm(void *, uint64_t);
 void   agtimer_setstatclockrate(int stathz);
 void   agtimer_set_clockrate(int32_t new_frequency);
 void   agtimer_startclock(void);
+void   agtimer_trigger(void *);
 
 const struct cfattach agtimer_ca = {
sizeof (struct agtimer_softc), agtimer_match, agtimer_attach
@@ -93,6 +81,11 @@ struct cfdriver agtimer_cd = {
NULL, "agtimer", DV_DULL
 };
 
+struct intrclock agtimer_intrclock = {
+   .ic_rearm = agtimer_rearm,
+   .ic_trigger = agtimer_trigger
+};
+
 uint64_t
 agtimer_readcnt64(void)
 {
@@ -155,16 +148,13 @@ agtimer_attach(struct device *parent, st
agtimer_frequency =
OF_getpropint(sc->sc_node, "clock-frequency", agtimer_frequency);
sc->sc_ticks_per_second = agtimer_frequency;
-
+   sc->sc_nsec_cycle_ratio =
+   sc->sc_ticks_per_second * (1ULL << 32) / 10;
+   sc->sc_nsec_max = UINT64_MAX / sc->sc_nsec_cycle_ratio;
printf(": %d kHz\n", sc->sc_ticks_per_second / 1000);
 
/* XXX: disable user access */
 
-#ifdef AMPTIMER_DEBUG
-   evcount_attach(&sc->sc_clk_count, "clock", NULL);
-   evcount_attach(&sc->sc_stat_count, "stat", NULL);
-#endif
-
/*
 * private timer and interrupts not enabled u