[libcamera-devel] meson: detect kernel version

Message ID 20200610153936.3469-1-scerveau@collabora.com
State Superseded
Headers show
Series
  • [libcamera-devel] meson: detect kernel version
Related show

Commit Message

Stéphane Cerveau June 10, 2020, 3:39 p.m. UTC
Add kernel version detection to warn user
that only >= 5.0.0 V4L API are supported in
libcamera.

Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
---
 meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Nicolas Dufresne June 10, 2020, 9:15 p.m. UTC | #1
Le mercredi 10 juin 2020 à 17:39 +0200, Stéphane Cerveau a écrit :
> Add kernel version detection to warn user
> that only >= 5.0.0 V4L API are supported in
> libcamera.
> 
> Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
> ---
>  meson.build | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index e898782..5063edb 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -105,6 +105,12 @@ if get_option('test')
>      subdir('test')
>  endif
>  
> +kernel_version_req = '>= 5.0.0'
> +kernel_version = run_command('uname', '-r').stdout()
> +if not kernel_version.version_compare(kernel_version_req)
> +  warning('V4L2 API version @0@ is too old, @1@ is required, consider to upgrade your kernel version to use libcamera'.format(kernel_version, kernel_version_req))
> +endif

This should not be checked for cross builds. Perhaps it could be made
conditional to meson.is_cross_build() not be set ? It remains error
prone as the host kernel may differ from the target kernel even without
cross compilation.

> +
>  # Create a symlink from the build root to the source root. This is used when
>  # running libcamera from the build directory to locate resources in the source
>  # directory (such as IPA configuration files).
Kieran Bingham June 11, 2020, 7:48 a.m. UTC | #2
On 10/06/2020 22:15, Nicolas Dufresne wrote:
> Le mercredi 10 juin 2020 à 17:39 +0200, Stéphane Cerveau a écrit :
>> Add kernel version detection to warn user
>> that only >= 5.0.0 V4L API are supported in
>> libcamera.
>>
>> Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
>> ---
>>  meson.build | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/meson.build b/meson.build
>> index e898782..5063edb 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -105,6 +105,12 @@ if get_option('test')
>>      subdir('test')
>>  endif
>>  
>> +kernel_version_req = '>= 5.0.0'
>> +kernel_version = run_command('uname', '-r').stdout()
>> +if not kernel_version.version_compare(kernel_version_req)
>> +  warning('V4L2 API version @0@ is too old, @1@ is required, consider to upgrade your kernel version to use libcamera'.format(kernel_version, kernel_version_req))
>> +endif
> 
> This should not be checked for cross builds. Perhaps it could be made
> conditional to meson.is_cross_build() not be set ? It remains error
> prone as the host kernel may differ from the target kernel even without
> cross compilation.


Indeed,

Perhaps we should add some LOG(Media, Fatal) when enumerating the
devices at runtime which will print a more meaningful message based on
the kernel version given by the devices?

--
Kieran


> 
>> +
>>  # Create a symlink from the build root to the source root. This is used when
>>  # running libcamera from the build directory to locate resources in the source
>>  # directory (such as IPA configuration files).
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>

Patch

diff --git a/meson.build b/meson.build
index e898782..5063edb 100644
--- a/meson.build
+++ b/meson.build
@@ -105,6 +105,12 @@  if get_option('test')
     subdir('test')
 endif
 
+kernel_version_req = '>= 5.0.0'
+kernel_version = run_command('uname', '-r').stdout()
+if not kernel_version.version_compare(kernel_version_req)
+  warning('V4L2 API version @0@ is too old, @1@ is required, consider to upgrade your kernel version to use libcamera'.format(kernel_version, kernel_version_req))
+endif
+
 # Create a symlink from the build root to the source root. This is used when
 # running libcamera from the build directory to locate resources in the source
 # directory (such as IPA configuration files).