2015-12-03 01:12:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Janne Grunau <janne-libav@jannau.net>
|
|
|
|
*
|
2016-01-02 11:25:55 +02:00
|
|
|
* This file is part of FFmpeg.
|
2015-12-03 01:12:39 +02:00
|
|
|
*
|
2016-01-02 11:25:55 +02:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2015-12-03 01:12:39 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2016-01-02 11:25:55 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2015-12-03 01:12:39 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2016-01-02 11:25:55 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2015-12-03 01:12:39 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVUTIL_AARCH64_TIMER_H
|
|
|
|
#define AVUTIL_AARCH64_TIMER_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
2024-06-07 10:39:08 +02:00
|
|
|
#if HAVE_INLINE_ASM
|
2015-12-03 01:12:39 +02:00
|
|
|
|
|
|
|
#define AV_READ_TIME read_time
|
|
|
|
|
|
|
|
static inline uint64_t read_time(void)
|
|
|
|
{
|
|
|
|
uint64_t cycle_counter;
|
|
|
|
__asm__ volatile(
|
|
|
|
"isb \t\n"
|
2024-06-07 10:39:08 +02:00
|
|
|
#if defined(__ANDROID__) || defined(__APPLE__)
|
|
|
|
// cntvct_el0 has lower resolution than pmccntr_el0, but is usually
|
|
|
|
// accessible from user space by default.
|
|
|
|
"mrs %0, cntvct_el0 "
|
|
|
|
#else
|
|
|
|
// pmccntr_el0 has higher resolution, but is usually not accessible
|
|
|
|
// from user space by default (but access can be enabled with a custom
|
|
|
|
// kernel module).
|
2015-12-03 01:12:39 +02:00
|
|
|
"mrs %0, pmccntr_el0 "
|
2024-06-07 10:39:08 +02:00
|
|
|
#endif
|
2015-12-03 01:12:39 +02:00
|
|
|
: "=r"(cycle_counter) :: "memory" );
|
|
|
|
|
|
|
|
return cycle_counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_INLINE_ASM */
|
|
|
|
|
|
|
|
#endif /* AVUTIL_AARCH64_TIMER_H */
|