Custom kernel patch - how to do it?

I am using F40 kernel 6.9.7-200 with virtualbox akmod installed. I have a Getac Rugged PC which uses eGalax touch/pen input devices. Touch input works out of the box but the pen input does not. I downloaded the drivers from eGalax and they require a kernel patch to work so their driver can work. I understand the principle of what I need to do but not the detail. From their driver guide :-

10-1.2 kernel 2.6.34 upwards

eGTouch Linux Programming Guide v2.5Q


  1. / SourceCode/drivers/input/evdev . c

**static bool evdev_match(struct input_handler handler, struct input_dev dev)


/ Avoid EETI USB touchscreens /

#define VID_EETI 0x0EEF

if ((BUS_USB == dev->id.bustype) && (VID_EETI == dev->id.vendor))

return false;

return true;


static struct input_handler evdev_handler = {

.event = evdev_event,

.match = evdev_match, / Added by EETI /

.connect = evdev_connect,

.disconnect = evdev_disconnect,

.fops = &evdev_fops,


.name = “evdev”,

.id_table = evdev_ids,


  1. /SourceCode/drivers/input/mousedev . c

**static bool mousedev_match(struct input_handler handler, struct input_dev dev)


/ Avoid EETI USB touchscreens /

#define VID_EETI 0x0EEF

if ((BUS_USB == dev->id.bustype) && (VID_EETI == dev->id.vendor))

return false;

/ Avoid EETI virtual devices /

if ((BUS_VIRTUAL == dev->id.bustype) && (VID_EETI == dev->id.vendor))

return false;

return true;


static struct input_handler mousedev_handler = {

.event = mousedev_event,

.match = mousedev_match, / Added by EETI /

.connect = mousedev_connect,

.disconnect = ousedev_disconnect,

.fops = &mousedev_fops,


.name = “mousedev”,

.id_table = mousedev_ids,


  1. / S o u r c e C o d e / d r i v e r s / i n p u t / j o y d e v . c

static bool joydev_match(struct input_handler *handler, struct input_dev *dev)


/* Avoid touchpads and touchscreens */

if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))

return false;

/* Avoid tablets, digitisers and similar devices */

if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit))

return false;

/ Avoid EETI virtual devices /

#define VID_EETI 0x0EEF

if (( BUS_VIRTUAL == dev->id.bustype) && (VID_EETI == dev->id.vendor))

return false;

return true;


static struct input_handler joydev_handler = {

.event = joydev_event,

.match = joydev_match,

.connect = joydev_connect,

.disconnect = joydev_disconnect,

.fops = &joydev_fops,


.name = “joydev”,

.id_table = joydev_ids,


In 10+ years they have not up-streamed support into linux.

You will have to apply the patches to each and every kernel you build.
To make this reproducible what I would do is get the fedora source rpm for the kernel and then add your patches to that source rpm.

Do you know how to work with source rpms?

1 Like

No but I want to learn how. I was hoping for an easy guide I can follow but the ones I have seen for kernel compiling do not give me the source to make these changes and I how do I make sure I don’t loose the mods for virtualbox drivers?

Building software like the kernel is challenging. I’ll outline what you would need to do.
If you are up for the challenge here are the steps that I can think of to get you started.

To get the kernel source rpm do:

dnf download --source kernel

Then install the source RPM:

rpm -i kernel*.src.rpm

Now you have files in ~/rpmbuild.
In the SPECS folder you will find kernel.spec and in the SOURCES folder you will find the patches and other files that are needed to build the kernel.

Have a look at the .spec file and see if you can make sense of it.

If you want to try building the kernel then you have two ways to do it.
You can use mock but that requires you have a source RPM.
Or you can use rpmbuild which is easier to use when creating new patches.

First you will need to install the build dependencies for the kernel.

sudo dnf install /usr/bin/rpmbuild
sudo dnf builddep kernel

Now you can build the kernel, this will take a long, long time to run.
You may want to leave it running overnight.

cd ~/rpmbuild/SPECS
rpmbuild -bb kernel.spec

Once it completes you will have a kernel somewhere in the ~/rpmbuild/RPMS tree.

Once you install your new kernel then you would need to build the VirtualBox drivers against it.

1 Like

I will give it a go. I did already get to the point of having the kernel rpm extracted into rpmbuild. I found the file linux-6.9.7.tar.xz with the 3 files i needed to alter which I have already done. I will see if it builds not with the final steps you provided. I will let you know how it goes. Thanks for your help.

Oh you will want to edit the release naming. In kernel.spec I think you can just
edit this and change the 200 to 2000 so your build is considered newer.
(There may be a smarter way to this but I’m not sure that smarter way is)

# This allows pkg_release to have configurable %%{?dist} tag
%define specrelease 200%{?buildid}%{?dist}

The way I create patches is to expand the tar.xz twice into tmp1 and tmp2.

Then I edit the files in tmp2 and make a patch with diff -u tmp1/<path-to-file> tmp2/<path-to-file> and save the output as a new named patch in SOURCES.
I do this for each file changed.

Then I add the patches to the kernel.spec file.

Good luck.

1 Like

OK I managed to build the kernel and the VBox Drivers. But Still no Pen input. Been digging a bit more and it seems there is more to do. The driver guide says to cd into /usr/src/kernels/kernel and run make menuconfig

enable [Device Drivers]/[Input device support]/[Event interface]

enable [Device Drivers]/[Input device support]/[Miscellaneous devices]/[User level driver support]

enable [Device Drivers]/[HID Devices]/[/dev/hidraw raw HID device support] ( for USB Interface )

enable [Device Drivers]/[HID Devices]/Special HID drivers/HID Multitouch panels

remove [Device Drivers]/[Input device support]/[Touchscreens]/[USB Touchscreen Driver]

now I have to rebuild again or can I fully rebuild the kernel with this?

I have tried everything I can think of. If CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set to y then it will not compile.

‘please set to appropriate value’

Looks like i nailed it.
Supposed to look like