diff mbox series

[v2,17/23] HID: uclogic: Support faking Wacom pad device ID

Message ID 20190210101409.3511-18-spbnick@gmail.com (mailing list archive)
State Mainlined
Commit fde44ac556359b0fd56e11b889686377392b7407
Delegated to: Jiri Kosina
Headers show
Series [v2,01/23] HID: kye: Add support for EasyPen M406XE | expand

Commit Message

Nikolai Kondrashov Feb. 10, 2019, 10:14 a.m. UTC
Add support for inserting a Wacom pad device ID into hid-uclogic
reports. This allows reporting dial inputs in a way compatible with the
Wacom driver. Needed for Ugee G5 support in particular.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
---
 drivers/hid/hid-uclogic-core.c   | 10 ++++++++++
 drivers/hid/hid-uclogic-params.h |  9 +++++++++
 2 files changed, 19 insertions(+)

Comments

Benjamin Tissoires Feb. 21, 2019, 10:42 a.m. UTC | #1
On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@gmail.com> wrote:
>
> Add support for inserting a Wacom pad device ID into hid-uclogic
> reports. This allows reporting dial inputs in a way compatible with the
> Wacom driver. Needed for Ugee G5 support in particular.

I guess the Xorg wacom driver.

I don't think we need that for libinput. Peter?

Cheers,
Benjamin

>
> Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
> ---
>  drivers/hid/hid-uclogic-core.c   | 10 ++++++++++
>  drivers/hid/hid-uclogic-params.h |  9 +++++++++
>  2 files changed, 19 insertions(+)
>
> diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
> index e4324ad86e58..f5fb612daa1e 100644
> --- a/drivers/hid/hid-uclogic-core.c
> +++ b/drivers/hid/hid-uclogic-core.c
> @@ -300,6 +300,16 @@ static int uclogic_raw_event(struct hid_device *hdev,
>                 }
>         }
>
> +       /* Tweak frame control reports, if necessary */
> +       if ((report->type == HID_INPUT_REPORT) &&
> +           (report->id == params->frame.id)) {
> +               /* If need to, and can, set pad device ID for Wacom drivers */
> +               if (params->frame.dev_id_byte > 0 &&
> +                   params->frame.dev_id_byte < size) {
> +                       data[params->frame.dev_id_byte] = 0xf;
> +               }
> +       }
> +
>         return 0;
>  }
>
> diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
> index 1060f70d647d..4ba6ecc2b8b8 100644
> --- a/drivers/hid/hid-uclogic-params.h
> +++ b/drivers/hid/hid-uclogic-params.h
> @@ -87,6 +87,13 @@ struct uclogic_params_frame {
>          * Report ID, if reports should be tweaked, zero if not.
>          */
>         unsigned int id;
> +       /*
> +        * Offset of the Wacom-style device ID byte in the report, to be set
> +        * to pad device ID (0xf), for compatibility with Wacom drivers. Zero
> +        * if no changes to the report should be made. Only valid if "id" is
> +        * not zero.
> +        */
> +       unsigned int dev_id_byte;
>  };
>
>  /*
> @@ -161,6 +168,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
>                 ".frame.desc_ptr = %p\n"            \
>                 ".frame.desc_size = %u\n"           \
>                 ".frame.id = %u\n"                  \
> +               ".frame.dev_id_byte = %u\n"         \
>                 ".pen_frame_flag = 0x%02x\n"
>
>  /* Tablet interface parameters *printf format arguments */
> @@ -177,6 +185,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
>                 (_params)->frame.desc_ptr,                                  \
>                 (_params)->frame.desc_size,                                 \
>                 (_params)->frame.id,                                        \
> +               (_params)->frame.dev_id_byte,                               \
>                 (_params)->pen_frame_flag
>
>  /* Get a replacement report descriptor for a tablet's interface. */
> --
> 2.20.1
>
Nikolai Kondrashov Feb. 21, 2019, 11 a.m. UTC | #2
On 2/21/19 12:42 PM, Benjamin Tissoires wrote:
> On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@gmail.com> wrote:
>>
>> Add support for inserting a Wacom pad device ID into hid-uclogic
>> reports. This allows reporting dial inputs in a way compatible with the
>> Wacom driver. Needed for Ugee G5 support in particular.
> 
> I guess the Xorg wacom driver.

Yes, the X.org Wacom driver.

> I don't think we need that for libinput.

IIRC, libinput worked without this.

Nick

On 2/21/19 12:42 PM, Benjamin Tissoires wrote:
> On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@gmail.com> wrote:
>>
>> Add support for inserting a Wacom pad device ID into hid-uclogic
>> reports. This allows reporting dial inputs in a way compatible with the
>> Wacom driver. Needed for Ugee G5 support in particular.
> 
> I guess the Xorg wacom driver.
> 
> I don't think we need that for libinput. Peter?
> 
> Cheers,
> Benjamin
> 
>>
>> Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
>> ---
>>   drivers/hid/hid-uclogic-core.c   | 10 ++++++++++
>>   drivers/hid/hid-uclogic-params.h |  9 +++++++++
>>   2 files changed, 19 insertions(+)
>>
>> diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
>> index e4324ad86e58..f5fb612daa1e 100644
>> --- a/drivers/hid/hid-uclogic-core.c
>> +++ b/drivers/hid/hid-uclogic-core.c
>> @@ -300,6 +300,16 @@ static int uclogic_raw_event(struct hid_device *hdev,
>>                  }
>>          }
>>
>> +       /* Tweak frame control reports, if necessary */
>> +       if ((report->type == HID_INPUT_REPORT) &&
>> +           (report->id == params->frame.id)) {
>> +               /* If need to, and can, set pad device ID for Wacom drivers */
>> +               if (params->frame.dev_id_byte > 0 &&
>> +                   params->frame.dev_id_byte < size) {
>> +                       data[params->frame.dev_id_byte] = 0xf;
>> +               }
>> +       }
>> +
>>          return 0;
>>   }
>>
>> diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
>> index 1060f70d647d..4ba6ecc2b8b8 100644
>> --- a/drivers/hid/hid-uclogic-params.h
>> +++ b/drivers/hid/hid-uclogic-params.h
>> @@ -87,6 +87,13 @@ struct uclogic_params_frame {
>>           * Report ID, if reports should be tweaked, zero if not.
>>           */
>>          unsigned int id;
>> +       /*
>> +        * Offset of the Wacom-style device ID byte in the report, to be set
>> +        * to pad device ID (0xf), for compatibility with Wacom drivers. Zero
>> +        * if no changes to the report should be made. Only valid if "id" is
>> +        * not zero.
>> +        */
>> +       unsigned int dev_id_byte;
>>   };
>>
>>   /*
>> @@ -161,6 +168,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
>>                  ".frame.desc_ptr = %p\n"            \
>>                  ".frame.desc_size = %u\n"           \
>>                  ".frame.id = %u\n"                  \
>> +               ".frame.dev_id_byte = %u\n"         \
>>                  ".pen_frame_flag = 0x%02x\n"
>>
>>   /* Tablet interface parameters *printf format arguments */
>> @@ -177,6 +185,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
>>                  (_params)->frame.desc_ptr,                                  \
>>                  (_params)->frame.desc_size,                                 \
>>                  (_params)->frame.id,                                        \
>> +               (_params)->frame.dev_id_byte,                               \
>>                  (_params)->pen_frame_flag
>>
>>   /* Get a replacement report descriptor for a tablet's interface. */
>> --
>> 2.20.1
>>
Peter Hutterer Feb. 26, 2019, 7:40 a.m. UTC | #3
On Thu, Feb 21, 2019 at 01:00:53PM +0200, Nikolai Kondrashov wrote:
> On 2/21/19 12:42 PM, Benjamin Tissoires wrote:
> > On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@gmail.com> wrote:
> > > 
> > > Add support for inserting a Wacom pad device ID into hid-uclogic
> > > reports. This allows reporting dial inputs in a way compatible with the
> > > Wacom driver. Needed for Ugee G5 support in particular.
> > 
> > I guess the Xorg wacom driver.
> 
> Yes, the X.org Wacom driver.
> 
> > I don't think we need that for libinput.
> 
> IIRC, libinput worked without this.

yep this is a leftover from when the devices were all multiplexed through
the same device node. libinput expects the pad to be on its own device node
and doesn't (need to) care about the pad ID.

Cheers,
   Peter

> On 2/21/19 12:42 PM, Benjamin Tissoires wrote:
> > On Sun, Feb 10, 2019 at 11:15 AM Nikolai Kondrashov <spbnick@gmail.com> wrote:
> > > 
> > > Add support for inserting a Wacom pad device ID into hid-uclogic
> > > reports. This allows reporting dial inputs in a way compatible with the
> > > Wacom driver. Needed for Ugee G5 support in particular.
> > 
> > I guess the Xorg wacom driver.
> > 
> > I don't think we need that for libinput. Peter?
> > 
> > Cheers,
> > Benjamin
> > 
> > > 
> > > Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
> > > ---
> > >   drivers/hid/hid-uclogic-core.c   | 10 ++++++++++
> > >   drivers/hid/hid-uclogic-params.h |  9 +++++++++
> > >   2 files changed, 19 insertions(+)
> > > 
> > > diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
> > > index e4324ad86e58..f5fb612daa1e 100644
> > > --- a/drivers/hid/hid-uclogic-core.c
> > > +++ b/drivers/hid/hid-uclogic-core.c
> > > @@ -300,6 +300,16 @@ static int uclogic_raw_event(struct hid_device *hdev,
> > >                  }
> > >          }
> > > 
> > > +       /* Tweak frame control reports, if necessary */
> > > +       if ((report->type == HID_INPUT_REPORT) &&
> > > +           (report->id == params->frame.id)) {
> > > +               /* If need to, and can, set pad device ID for Wacom drivers */
> > > +               if (params->frame.dev_id_byte > 0 &&
> > > +                   params->frame.dev_id_byte < size) {
> > > +                       data[params->frame.dev_id_byte] = 0xf;
> > > +               }
> > > +       }
> > > +
> > >          return 0;
> > >   }
> > > 
> > > diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
> > > index 1060f70d647d..4ba6ecc2b8b8 100644
> > > --- a/drivers/hid/hid-uclogic-params.h
> > > +++ b/drivers/hid/hid-uclogic-params.h
> > > @@ -87,6 +87,13 @@ struct uclogic_params_frame {
> > >           * Report ID, if reports should be tweaked, zero if not.
> > >           */
> > >          unsigned int id;
> > > +       /*
> > > +        * Offset of the Wacom-style device ID byte in the report, to be set
> > > +        * to pad device ID (0xf), for compatibility with Wacom drivers. Zero
> > > +        * if no changes to the report should be made. Only valid if "id" is
> > > +        * not zero.
> > > +        */
> > > +       unsigned int dev_id_byte;
> > >   };
> > > 
> > >   /*
> > > @@ -161,6 +168,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
> > >                  ".frame.desc_ptr = %p\n"            \
> > >                  ".frame.desc_size = %u\n"           \
> > >                  ".frame.id = %u\n"                  \
> > > +               ".frame.dev_id_byte = %u\n"         \
> > >                  ".pen_frame_flag = 0x%02x\n"
> > > 
> > >   /* Tablet interface parameters *printf format arguments */
> > > @@ -177,6 +185,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
> > >                  (_params)->frame.desc_ptr,                                  \
> > >                  (_params)->frame.desc_size,                                 \
> > >                  (_params)->frame.id,                                        \
> > > +               (_params)->frame.dev_id_byte,                               \
> > >                  (_params)->pen_frame_flag
> > > 
> > >   /* Get a replacement report descriptor for a tablet's interface. */
> > > --
> > > 2.20.1
> > > 
>
diff mbox series

Patch

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index e4324ad86e58..f5fb612daa1e 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -300,6 +300,16 @@  static int uclogic_raw_event(struct hid_device *hdev,
 		}
 	}
 
+	/* Tweak frame control reports, if necessary */
+	if ((report->type == HID_INPUT_REPORT) &&
+	    (report->id == params->frame.id)) {
+		/* If need to, and can, set pad device ID for Wacom drivers */
+		if (params->frame.dev_id_byte > 0 &&
+		    params->frame.dev_id_byte < size) {
+			data[params->frame.dev_id_byte] = 0xf;
+		}
+	}
+
 	return 0;
 }
 
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index 1060f70d647d..4ba6ecc2b8b8 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -87,6 +87,13 @@  struct uclogic_params_frame {
 	 * Report ID, if reports should be tweaked, zero if not.
 	 */
 	unsigned int id;
+	/*
+	 * Offset of the Wacom-style device ID byte in the report, to be set
+	 * to pad device ID (0xf), for compatibility with Wacom drivers. Zero
+	 * if no changes to the report should be made. Only valid if "id" is
+	 * not zero.
+	 */
+	unsigned int dev_id_byte;
 };
 
 /*
@@ -161,6 +168,7 @@  extern int uclogic_params_init(struct uclogic_params *params,
 		".frame.desc_ptr = %p\n"            \
 		".frame.desc_size = %u\n"           \
 		".frame.id = %u\n"                  \
+		".frame.dev_id_byte = %u\n"         \
 		".pen_frame_flag = 0x%02x\n"
 
 /* Tablet interface parameters *printf format arguments */
@@ -177,6 +185,7 @@  extern int uclogic_params_init(struct uclogic_params *params,
 		(_params)->frame.desc_ptr,                                  \
 		(_params)->frame.desc_size,                                 \
 		(_params)->frame.id,                                        \
+		(_params)->frame.dev_id_byte,                               \
 		(_params)->pen_frame_flag
 
 /* Get a replacement report descriptor for a tablet's interface. */