Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to HUION KD200 and other recent HUION 0064 tablets #644

Closed
wants to merge 6 commits into from

Conversation

inochisa
Copy link
Contributor

@inochisa inochisa commented Dec 22, 2022

This patch add support for HUION KD200 tablets(256c:0064) and other recent HUION tablets

Summary

  1. Add new huion device id 0064.
  2. Increase the checked interface number of huion to 2 (The original is 1) to avoid invalid interface.

New support tablets

This pull request may add support to the following tablets (0064)

Allow DIGImend detects more interface

These issue with interface is invalid, ignoring should also be fixed:
#640
#486
#335

Edit

  1. This patch should have the same effects as Add support to HUION KD200 and other recent HUION 0064 tablets #644 at least.
  2. The conversation mentioned below only provides a draft version. Use this pull instead.

Footnotes

  1. I have already tested this tablet. 2

  2. unlike the descriptors data in Pls Add support HUION KD200 #545, it seems that KD200 now has three usbif.

Since Huion uses a new device id for recent tablets, add a new
device id 0x0064 to support recent Huion tablets.

At least these tablets are using device id 0x0064:

Gaomon 1060 Pro (0x256c:0x0064)
Gaomon M6       (0x256c:0x0064)
Huion KD200     (0x256c:0x0064)
Huion KD100     (0x256c:0x0064)

Signed-off-by: Inochi Amaoto <[email protected]>
@inochisa
Copy link
Contributor Author

@JoseExposito

@JoseExposito
Copy link
Collaborator

Hi @inochisa!

Thanks for the PR. For reference, this comes from this conversation in the kernel mailing list:
https://lore.kernel.org/linux-input/IA1PR20MB4953704646AA47DCD3F1DF52BBEA9@IA1PR20MB4953.namprd20.prod.outlook.com/T/

Let's see if you can get a few users to test it!

@inochisa
Copy link
Contributor Author

@JoseExposito, thanks for you improvement, I have updated my pull description.

@inochisa inochisa changed the title Add support to HUION KD200 and other recent HUION tablets Add support to HUION KD200 and other recent HUION 0064 tablets Dec 28, 2022
As now the huion tablets has more than two usbif, limited interface
number will lead to a broken tablet. Increase the allowed interface
number to 2 to avoid this problems.

Signed-off-by: Inochi Amaoto <[email protected]>
Add Digitizer, stylus and multi-axis support for the input configuration
of uclogic device, this will help libinput detecte tablets accurately.

Signed-off-by: Inochi Amaoto <[email protected]>
@inochisa
Copy link
Contributor Author

@JoseExposito Is there any advice for implement with bluetooth uclogic devices.

I have already found that the tablet uses bluetooth ATT packet to configure itself (the similar configure code of the usb). But I did not find a way to send the packet from kernel.

I tried to directly access the hci_conn from hid->dev.parent in the hid device. but all the operation on this conn got a NULL access error.

@JoseExposito
Copy link
Collaborator

I tried it a while ago and I gave up because it was too complicated. The driver relays in too many USB related functionality to easily add support for Bluetooth. It'd require migrating a bunch of function (many of them I can not test because I don't own the hardware), so I decided to focus on something else.

The code of uclogic_params_huion_init has too much condition check,
use goto to simplify it.

Signed-off-by: Inochi Amaoto <[email protected]>
uclogic_params_huion_init alway init tablet with a touch ring or
touch strip, but some tablets have none. Add a list to suppress this
init process.

Signed-off-by: Inochi Amaoto <[email protected]>
@freezai-Yang
Copy link

Hi,there are some problems when I was installing it. The make.conf is as follows:
cat /var/lib/dkms/digimend/11/build/make.log [17:23:59] DKMS make.log for digimend-11 for kernel 6.4.3-arch1-2 (x86_64) 2023年 07月 21日 星期五 17:23:56 CST make -C /lib/modules/6.4.3-arch1-2/build M=/var/lib/dkms/digimend/11/build modules CC [M] /var/lib/dkms/digimend/11/build/hid-kye.o CC [M] /var/lib/dkms/digimend/11/build/hid-uclogic-core.o CC [M] /var/lib/dkms/digimend/11/build/hid-uclogic-rdesc.o CC [M] /var/lib/dkms/digimend/11/build/hid-uclogic-params.o CC [M] /var/lib/dkms/digimend/11/build/hid-polostar.o /var/lib/dkms/digimend/11/build/hid-uclogic-params.c: 在函数‘uclogic_params_init’中: /var/lib/dkms/digimend/11/build/hid-uclogic-params.c:1232:17: 错误:隐式声明函数‘hid_is_using_ll_driver’ [-Werror=implicit-function-declaration] 1232 | || !hid_is_using_ll_driver(hdev, &usb_hid_driver) | ^~~~~~~~~~~~~~~~~~~~~~ /var/lib/dkms/digimend/11/build/hid-uclogic-params.c:1232:47: 错误:‘usb_hid_driver’ undeclared (first use in this function); did you mean ‘to_hid_driver’? 1232 | || !hid_is_using_ll_driver(hdev, &usb_hid_driver) | ^~~~~~~~~~~~~~ | to_hid_driver /var/lib/dkms/digimend/11/build/hid-uclogic-params.c:1232:47: 附注:每个未声明的标识符在其出现的函数内只报告一次/var/lib/dkms/digimend/11/build/hid-uclogic-params.c:1354:20: 警告:this statement may fall through [-Wimplicit-fallthrough=] 1354 | if (bNumInterfaces != 3) { | ^ /var/lib/dkms/digimend/11/build/hid-uclogic-params.c:1372:9: 附注:here 1372 | case VID_PID(USB_VENDOR_ID_HUION, | ^~~~ cc1:有些警告被当作是错误 CC [M] /var/lib/dkms/digimend/11/build/hid-viewsonic.o make[2]: *** [scripts/Makefile.build:252:/var/lib/dkms/digimend/11/build/hid-uclogic-params.o] 错误 1 make[2]: *** 正在等待未完成的任务.... make[1]: *** [Makefile:2026:/var/lib/dkms/digimend/11/build] 错误 2 make: *** [Makefile:25:modules] 错误 2

When I search for a solution, I found this: https://github.com/torvalds/linux/commit/1d9ca84ce034960707b62ce7d5ca75d04f8db91a

Please could anyone give me some advice what should I do?Thanks.

@inochisa
Copy link
Contributor Author

@freezai-Yang I am using 6.4.4-arch1, and there is no problem. Try to update your system and rebuild.

Also, this problem seems not to be related to this pr. Please check the state of a fresh repo.

@inochisa
Copy link
Contributor Author

@nvkomimi I now hold the development process since I didn't have enough time. The code of uclogic is completely a mess and needs a reconstruction to achieve handling device dynamically.

But anyway, if you only need usb support, use this patch is just enough.

@brianmego
Copy link

I can confirm this works with my Huion 1060P. My before state was STYLUS and ERASER, now I get PAD also

@spbnick
Copy link
Member

spbnick commented Jan 16, 2024

Ah, glad to hear my code earned the "completely a mess" badge 😂 It means my perfectionism is finally giving way 😅

Thanks to everyone posting your changes to the driver, and especially @JoseExposito for the stellar work in the input layer!

And sorry I'm not up to taking it any further. I'd be happy to give reigns to anyone interested and capable enough, and I just sent an invite to José. Let's see if he accepts 🤞

@inochisa
Copy link
Contributor Author

Hi, @spbnick . Thanks for your efforts for this repo.

@JoseExposito
Copy link
Collaborator

Hi @inochisa,

Sorry for the long delay on my side.

I plan to create a DIGImend release (v13) this weekend with the changes already in master and I'd like to include the new product ID for your tablet (0x0064) as well as #678 (0x006f).

This should allow us to get some actual testing (and bug reports) before we send the patches to the upstream kernel.

I created a PR cherry-picking your first commit: #685

About the HID: uclogic: fix invalid interface for HUION tablets patch: Is it required for the tablets to works or just avoids printing a warning?
I'd like to keep the changes as small as possible to make a bit easier identify regressions caused by the new version.

@inochisa
Copy link
Contributor Author

inochisa commented May 1, 2024

@JoseExposito Excellent work

About the HID: uclogic: fix invalid interface for HUION tablets patch: Is it required for the tablets to works or just avoids printing a warning?

This is necessary for my KD200 to work, but I suspend that it should check udev->config->desc.bNumInterfaces - 1 instead of 2 for a generic solution.

I have attached the usb descriptors of my board. And I hope it may be useful.
descriptors.txt

/* Keep everything intact, but mark pen usage invalid */
p.pen.usage_invalid = true;
goto output;
/* Else, if it's not a pen interface */
} else if (bInterfaceNumber != 0) {
} else if (bInterfaceNumber > 2) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inochisa thanks a lot for the quick reply.

I'm trying to understand this second patch a bit better.

What are the events sent by the interface with bInterfaceNumber == 2? The keyboard events? In that case, it make sense to add if (bInterfaceNumber == 1 || bInterfaceNumber == 2) so the interface is used but not as a pen.

About the second condition. Can this else if condition remain unmodified?

I made a minor modification of your patch in the PR I'm working on for v13 to illustrate what I mean. I think it should work: 0462d43

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inochisa thanks a lot for the quick reply.

I'm trying to understand this second patch a bit better.

What are the events sent by the interface with bInterfaceNumber == 2? The keyboard events? In that case, it make sense to add if (bInterfaceNumber == 1 || bInterfaceNumber == 2) so the interface is used but not as a pen.

Yes, it is keyboard events.

About the second condition. Can this else if condition remain unmodified?

I think this can be left unmodified. As we already check bInterfaceNumber "1" and "2", it is OK to use existed check.

I made a minor modification of your patch in the PR I'm working on for v13 to illustrate what I mean. I think it should work: 0462d43

Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged! Thanks a lot 🎉

You can rebase this PR on top of master if you want. But I'm trying to avoid refactors without KUnit tests to ensure the functionality is kept.

About the firmware list... I recently discovered that they are unique and that can be used to identify the tablets in user-space linuxwacom/libwacom#659

It might be a good idea to add a full list of firmwares in the future, but for the moment I'd like to keep it as it is to avoid bugs/regressions until I have a clear idea of how we can take advantage of it.

Copy link
Contributor Author

@inochisa inochisa May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged! Thanks a lot 🎉

You can rebase this PR on top of master if you want. But I'm trying to avoid refactors without KUnit tests to ensure the functionality is kept.

I prefer to close this PR as the left in this patch is hard to evolve. (I want to improve the touch strip detection, but it is ugly to use a firmware name list)

About the firmware list... I recently discovered that they are unique and that can be used to identify the tablets in user-space linuxwacom/libwacom#659

It might be a good idea to add a full list of firmwares in the future, but for the moment I'd like to keep it as it is to avoid bugs/regressions until I have a clear idea of how we can take advantage of it.

Excellent. I see your tool detect the feather of KD200. I will check result and see there is anything that can improve/

@inochisa inochisa closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants