LCOV - code coverage report
Current view: top level - nnstreamer-2.4.2/gst/nnstreamer - hw_accel.c (source / functions) Coverage Total Hit
Test: nnstreamer 2.4.2-0 nnstreamer/nnstreamer#eca68b8d050408568af95d831a8eef62aaee7784 Lines: 100.0 % 3 3
Test Date: 2025-03-13 05:38:21 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /* SPDX-License-Identifier: LGPL-2.1-only */
       2              : /**
       3              :  * NNStreamer hardware accelerator availability checking
       4              :  * Copyright (C) 2020 Parichay Kapoor <pk.kapoor@samsung.com>
       5              :  */
       6              : /**
       7              :  * @file        hw_accel.c
       8              :  * @date        8 September 2020
       9              :  * @brief       Common hardware acceleration availability checks
      10              :  * @see         https://github.com/nnstreamer/nnstreamer
      11              :  * @author      Parichay Kapoor <pk.kapoor@samsung.com>
      12              :  * @bug         No known bugs except for NYI items
      13              :  *
      14              :  */
      15              : 
      16              : #include <hw_accel.h>
      17              : #include <errno.h>
      18              : 
      19              : #if defined(__aarch64__) || defined(__arm__)
      20              : #if defined(__TIZEN__) || defined(__ANDROID__) || defined(__linux__)
      21              : #include <asm/hwcap.h>
      22              : #endif /* __TIZEN__ || __ANDROID__ || __linux__ */
      23              : #endif /* __arch64__ || __arm__ */
      24              : 
      25              : #if !defined(__APPLE__)
      26              : #include <sys/auxv.h>
      27              : #else
      28              : #define HWCAP_ASIMD 0x1
      29              : #if defined(__aarch64__)
      30              : #define getauxval(x) (HWCAP_ASIMD)
      31              : #else
      32              : #define getauxval(x) (0x0)
      33              : #endif /* __aarch64__ */
      34              : #endif /* __APPLE__ */
      35              : 
      36              : /**
      37              :  * @brief Check if neon is supported
      38              :  * @retval 0 if supported, else -errno
      39              :  */
      40              : gint
      41          750 : cpu_neon_accel_available (void)
      42              : {
      43          750 :   gint neon_available = 0;
      44              : 
      45              : #if defined(__aarch64__) || defined(__arm__)
      46              :   gulong hwcap_flag;
      47              : 
      48              : #if defined(__aarch64__)
      49              :   hwcap_flag = HWCAP_ASIMD;
      50              : #elif defined(__arm__)
      51              :   hwcap_flag = HWCAP_NEON;
      52              : #endif /* __arch64 __ */
      53              : 
      54              :   if (getauxval (AT_HWCAP) & hwcap_flag) {
      55              :     neon_available = 0;
      56              :   } else {
      57              :     neon_available = -EINVAL;
      58              :   }
      59              : #endif /* __arch64__ || __arm__ */
      60              : 
      61          750 :   return neon_available;
      62              : }
        

Generated by: LCOV version 2.0-1