From ef5129c68d1cef4f81571d59c33c2c4c46b87acd Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Wed, 11 Aug 2021 11:45:53 +0200 Subject: [PATCH 1/5] build: remove obsolete module directory --- module/Makefile | 73 ------------------------------------------ module/aravis-module.c | 18 ----------- module/aravis-module.h | 0 3 files changed, 91 deletions(-) delete mode 100644 module/Makefile delete mode 100644 module/aravis-module.c delete mode 100644 module/aravis-module.h diff --git a/module/Makefile b/module/Makefile deleted file mode 100644 index 8553a66d3..000000000 --- a/module/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -ifneq ($(KERNELRELEASE),) - -obj-m := aravis-module.o - -else - -ifeq ($(PREFIX),) -PREFIX := /usr/local -endif - -MODULE := aravis-module -KDIR := /lib/modules/$(shell uname -r)/build -INCLUDE := -isystem $(KDIR)/include -MODCFLAGS := -DMODULE -D__KERNEL__ -Wall $(INCLUDE) - -KMAKE := $(MAKE) -C $(KDIR) SUBDIRS=$$PWD - -modules: $(MODULE).o - -insert_module: install - modprobe -r aravis-module - modprobe aravis-module - -ifneq ($(shell (uname -r | grep 2.6) > /dev/null ; echo -n $$?),0) - echo A 2.6 kernel is required; exit 1 -endif - -# build module - -$(MODULE).o: $(MODULE).c $(MODULE).h - $(KMAKE) modules - - -# Automake rules, as per "Third-Party Makefiles" in the automake manual - -all: $(MODULE).o - -distdir: - cp aravis-module.c $(distdir) - cp aravis-module.h $(distdir) - cp Makefile $(distdir) - -install: - $(KMAKE) modules_install - [ -e /sbin/depmod ] && /sbin/depmod - -install-data: -install-exec: -uninstall: - -install-info: -installdirs: -check: -installcheck: -mostlyclean: -clean: - rm -f aravis-module.ko - rm -f aravis-module.o - rm -f aravis-module.mod.o - rm -f aravis-module.mod.c - rm -f modules.order - rm -f Module.symvers -distclean: clean -maintainer-clean: -dvi: -pdf: -info: -html: -tags: -ctags: - -endif - diff --git a/module/aravis-module.c b/module/aravis-module.c deleted file mode 100644 index e7fbd717f..000000000 --- a/module/aravis-module.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Emmanuel Pacaud "); - -int -init_module(void) -{ - printk (KERN_ALERT "aravis: loaded\n"); - - return 0; -} - -void -cleanup_module(void) -{ - printk (KERN_ALERT "aravis: unloaded\n"); -} diff --git a/module/aravis-module.h b/module/aravis-module.h deleted file mode 100644 index e69de29bb..000000000 From 98d9db47185e571b01a29f24ca2692d42cb25398 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Wed, 13 Jul 2022 17:05:57 +0200 Subject: [PATCH 2/5] linux: gigevision kernel driver build setup It is just an empty driver for now :) --- drivers/linux-gv/Kbuild | 3 +++ drivers/linux-gv/arvgvkmod.c | 18 ++++++++++++++++++ drivers/linux-gv/meson.build | 13 +++++++++++++ drivers/meson.build | 12 ++++++++++++ drivers/mesonbuildkmod.sh | 7 +++++++ meson.build | 4 ++++ meson_options.txt | 2 ++ 7 files changed, 59 insertions(+) create mode 100644 drivers/linux-gv/Kbuild create mode 100644 drivers/linux-gv/arvgvkmod.c create mode 100644 drivers/linux-gv/meson.build create mode 100644 drivers/meson.build create mode 100755 drivers/mesonbuildkmod.sh diff --git a/drivers/linux-gv/Kbuild b/drivers/linux-gv/Kbuild new file mode 100644 index 000000000..9f4bb5e38 --- /dev/null +++ b/drivers/linux-gv/Kbuild @@ -0,0 +1,3 @@ +ccflags-y := $(MODULE_CFLAGS) +obj-m := aravis_gv.o +aravis_gv-y := $(patsubst $(src)/%.c,%.o,$(wildcard $(src)/*.c)) diff --git a/drivers/linux-gv/arvgvkmod.c b/drivers/linux-gv/arvgvkmod.c new file mode 100644 index 000000000..db1ae3245 --- /dev/null +++ b/drivers/linux-gv/arvgvkmod.c @@ -0,0 +1,18 @@ +#include + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Emmanuel Pacaud "); + +int +init_module(void) +{ + printk (KERN_ALERT "aravis: loaded\n"); + + return 0; +} + +void +cleanup_module(void) +{ + printk (KERN_ALERT "aravis: unloaded\n"); +} diff --git a/drivers/linux-gv/meson.build b/drivers/linux-gv/meson.build new file mode 100644 index 000000000..c6eec3bc6 --- /dev/null +++ b/drivers/linux-gv/meson.build @@ -0,0 +1,13 @@ +gv_mkfile = custom_target('gv_makefile', output:'Makefile', command:['touch', '@OUTPUT@']) + +gv_sources = files([ + 'arvgvkmod.c' +]) + +custom_target ('gv_kmod',input: gv_sources, output: 'aravis_gv.ko', command:[ + 'make', '-j4', '-C', kernel_build_dir, + 'M='+join_paths(meson.current_build_dir()), + 'src='+join_paths(meson.current_source_dir()), + 'MODULE_CFLAGS=-I'+meson.current_source_dir(), + 'modules'], depends:gv_mkfile, build_by_default:true) + diff --git a/drivers/meson.build b/drivers/meson.build new file mode 100644 index 000000000..6256386c1 --- /dev/null +++ b/drivers/meson.build @@ -0,0 +1,12 @@ +if host_machine.system()=='linux' + kernel_version = run_command('uname', '-r').stdout().strip() + kernel_build_dir = join_paths('/', 'lib', 'modules', kernel_version, 'build') + + # test running make in kernel directory, using "make kernelversion" + make_returncode = run_command('make', '-sC', kernel_build_dir, 'kernelversion').returncode() + if make_returncode != 0 + error('Cannot compile kernel modules as requested - are kernel headers installed?') + endif + + subdir('linux-gv') +endif diff --git a/drivers/mesonbuildkmod.sh b/drivers/mesonbuildkmod.sh new file mode 100755 index 000000000..e85cf7afb --- /dev/null +++ b/drivers/mesonbuildkmod.sh @@ -0,0 +1,7 @@ +mkdir -p "$2/drivers/kmod.dir" +cp -Rf "$1/drivers/"* "$2/drivers/kmod.dir" +rm -f "$2/drivers/kmod.dir/meson.build" "$2/drivers/kmod.dir/mesonbuild.sh" +cd "$2/drivers/kmod.dir" +sed -i -e "s|\$(src)|$1/drivers|" "$2/drivers/kmod.dir/Kbuild" +make +mv "aravis_gv.ko" "$2/drivers" diff --git a/meson.build b/meson.build index 1672167e9..433993026 100644 --- a/meson.build +++ b/meson.build @@ -110,6 +110,10 @@ viewer_deps = aravis_dependencies + [dependency ('gtk+-3.0', version: '>=3.12', subdir ('po', if_found: viewer_deps) subdir ('viewer', if_found: viewer_deps) +if get_option('drivers') + subdir('drivers') +endif + gst_enabled = false gst_option = get_option ('gst-plugin') gst_deps = aravis_dependencies + [dependency ('gstreamer-base-1.0', required: gst_option), diff --git a/meson_options.txt b/meson_options.txt index eba1b30ae..61b94ee8e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,6 +8,8 @@ option('packet-socket', type: 'feature', value: 'auto', description : 'Enable pa option('tests', type: 'boolean', value: true, description: 'Build tests') option('fast-heartbeat', type: 'boolean', value: false, description: 'Enable faster heartbeat rate') +option('drivers', type: 'boolean', value: false, description: 'Build linux driver') + # Parameters option('gv-n-buffers', type: 'integer', min: 1, value: 16, description: 'Number of buffers used to receive GVSP packets') From f8a427660d50f8178b556e11c3bd1c7c12de35b2 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Mon, 16 Aug 2021 13:39:26 +0200 Subject: [PATCH 3/5] meson: add shebang line to kernel module build script --- drivers/mesonbuildkmod.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mesonbuildkmod.sh b/drivers/mesonbuildkmod.sh index e85cf7afb..470e02f82 100755 --- a/drivers/mesonbuildkmod.sh +++ b/drivers/mesonbuildkmod.sh @@ -1,3 +1,5 @@ +#!/bin/sh + mkdir -p "$2/drivers/kmod.dir" cp -Rf "$1/drivers/"* "$2/drivers/kmod.dir" rm -f "$2/drivers/kmod.dir/meson.build" "$2/drivers/kmod.dir/mesonbuild.sh" From 5aa5a2dd8f344a0bc7f88bddc478471cd5c5ba70 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Tue, 19 Jul 2022 13:50:47 +0200 Subject: [PATCH 4/5] driver: remove build script --- drivers/mesonbuildkmod.sh | 9 --------- 1 file changed, 9 deletions(-) delete mode 100755 drivers/mesonbuildkmod.sh diff --git a/drivers/mesonbuildkmod.sh b/drivers/mesonbuildkmod.sh deleted file mode 100755 index 470e02f82..000000000 --- a/drivers/mesonbuildkmod.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -mkdir -p "$2/drivers/kmod.dir" -cp -Rf "$1/drivers/"* "$2/drivers/kmod.dir" -rm -f "$2/drivers/kmod.dir/meson.build" "$2/drivers/kmod.dir/mesonbuild.sh" -cd "$2/drivers/kmod.dir" -sed -i -e "s|\$(src)|$1/drivers|" "$2/drivers/kmod.dir/Kbuild" -make -mv "aravis_gv.ko" "$2/drivers" From 07880f3553834374cd5b7f41f775964a187377b2 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Fri, 22 Jul 2022 08:09:52 +0200 Subject: [PATCH 5/5] driver: update email address --- drivers/linux-gv/arvgvkmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/linux-gv/arvgvkmod.c b/drivers/linux-gv/arvgvkmod.c index db1ae3245..e7fbd717f 100644 --- a/drivers/linux-gv/arvgvkmod.c +++ b/drivers/linux-gv/arvgvkmod.c @@ -1,7 +1,7 @@ #include MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Emmanuel Pacaud "); +MODULE_AUTHOR("Emmanuel Pacaud "); int init_module(void)