📺
Ubuntu 24.04.2 LTS にTVチューナー PX-W3PE4 のドライバをインストールする
この度重い腰を上げて自宅のUbuntuサーバーを 22.04.5 LTS から 24.04.2 LTS にアップデートしたところ、刺していたTVチューナーを認識しなくなった。
$ ls /dev/px*
(ドライバファイルが表示されない)
アップデートに伴ってチューナーのドライバが削除されていたっぽいので、以下の非公式ドライバをインストールしようとした。
READMEにある手順通りに進めると、ドライバのビルドでエラーを吐いた。
'revision.h' was updated.
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-59-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
You are using: gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
CC [M] /home/mana/tmp/px4_drv/driver/driver_module.o
CC [M] /home/mana/tmp/px4_drv/driver/ptx_chrdev.o
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c: In function ‘ptx_chrdev_context_create’:
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c:569:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’? [-Werror=implicit-function-declaration]
569 | strlcpy(ctx->devname, devname, sizeof(ctx->devname));
| ^~~~~~~
| strscpy
In file included from ./arch/x86/include/asm/mem_encrypt.h:15,
from ./include/linux/mem_encrypt.h:17,
from ./arch/x86/include/asm/processor-flags.h:6,
from ./arch/x86/include/asm/irqflags.h:5,
from ./include/linux/irqflags.h:18,
from ./include/linux/spinlock.h:59,
from ./include/linux/kref.h:16,
from /home/mana/tmp/px4_drv/driver/ptx_chrdev.h:13,
from /home/mana/tmp/px4_drv/driver/ptx_chrdev.c:9:
./include/linux/init.h:188:22: error: passing argument 1 of ‘class_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
188 | #define THIS_MODULE (&__this_module)
| ~^~~~~~~~~~~~~~~
| |
| struct module *
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c:573:35: note: in expansion of macro ‘THIS_MODULE’
573 | ctx->class = class_create(THIS_MODULE, name);
| ^~~~~~~~~~~
In file included from ./include/linux/device.h:31,
from ./include/linux/cdev.h:8,
from /home/mana/tmp/px4_drv/driver/ptx_chrdev.h:16:
./include/linux/device/class.h:228:54: note: expected ‘const char *’ but argument is of type ‘struct module *’
228 | struct class * __must_check class_create(const char *name);
| ~~~~~~~~~~~~^~~~
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c:573:22: error: too many arguments to function ‘class_create’
573 | ctx->class = class_create(THIS_MODULE, name);
| ^~~~~~~~~~~~
./include/linux/device/class.h:228:29: note: declared here
228 | struct class * __must_check class_create(const char *name);
| ^~~~~~~~~~~~
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c: At top level:
/home/mana/tmp/px4_drv/driver/ptx_chrdev.c:727:5: warning: no previous prototype for ‘ptx_chrdev_context_reserve’ [-Wmissing-prototypes]
727 | int ptx_chrdev_context_reserve(struct ptx_chrdev_context *chrdev_ctx,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:243: /home/mana/tmp/px4_drv/driver/ptx_chrdev.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.8.0-59-generic/Makefile:1925: /home/mana/tmp/px4_drv/driver] Error 2
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-59-generic'
make: *** [Makefile:19: px4_drv.ko] Error 2
どうやら新旧のカーネル間で関数が無くなっていたり、仕様の違いがあるよう。
もうリポジトリはメンテされていなさそうなので、forkして自分でパッチした。
From e76c6aa45717cc17725c8c1cecba6951a7bf5b6d Mon Sep 17 00:00:00 2001
From: s4kr4 <s4kr4m4@gmail.com>
Date: Tue, 13 May 2025 23:49:50 +0900
Subject: [PATCH] Update for Linux Kernel 6.8 or later
---
driver/ptx_chrdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/driver/ptx_chrdev.c b/driver/ptx_chrdev.c
index dec1cee..3d56dea 100644
--- a/driver/ptx_chrdev.c
+++ b/driver/ptx_chrdev.c
@@ -566,11 +566,11 @@ int ptx_chrdev_context_create(const char *name, const char *devname,
return -ENOMEM;
mutex_init(&ctx->lock);
- strlcpy(ctx->devname, devname, sizeof(ctx->devname));
+ strscpy(ctx->devname, devname, sizeof(ctx->devname));
INIT_LIST_HEAD(&ctx->group_list);
- ctx->class = class_create(THIS_MODULE, name);
+ ctx->class = class_create(name);
if (IS_ERR(ctx->class)) {
pr_err("ptx_chrdev_context_create: class_create(\"%s\") failed.\n",
name);
forkリポジトリは以下
無事ビルドが通ったのでそのまま make install
し、無事ドライバの動作を確認できた。
$ ls /dev/px*
/dev/px4video0 /dev/px4video1 /dev/px4video2 /dev/px4video3
Discussion