Skip to content

Commit 2f1d310

Browse files
authored
Merge pull request #20 from intel-retail/release-3.0.0
Release 3.0.0
2 parents d50a7a6 + 2349d7b commit 2f1d310

32 files changed

Lines changed: 3139 additions & 590 deletions

README.md

Lines changed: 454 additions & 243 deletions
Large diffs are not rendered by default.

cmn/debug.h

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,40 @@
2525
#ifndef _DEBUG_H
2626
#define _DEBUG_H
2727

28-
#include <stdio.h>
29-
30-
enum {
31-
ERR,
32-
INFO,
33-
DBG,
34-
TRACE,
28+
enum log_level {
29+
LOG_LEVEL_NONE,
30+
LOG_LEVEL_ERROR,
31+
LOG_LEVEL_WARNING,
32+
LOG_LEVEL_INFO,
33+
LOG_LEVEL_DEBUG,
34+
LOG_LEVEL_TRACE,
3535
};
3636

37-
/**
38-
* Set it to 0 or higher with 0 being lowest number of messages
39-
* 0 = Only errors show up
40-
* 1 = Errors + Info messages
41-
* 2 = Errors + Info messages + Debug messages
42-
* 3 = Errors + Info messages + Debug messages + Trace calls
43-
*/
44-
#ifdef DEBUGON
45-
static int dbg_lvl = DBG;
46-
#else
47-
static int dbg_lvl = INFO;
48-
#endif
37+
extern log_level dbg_lvl;
4938

50-
#define _PRINT(prefix, fmt, ...) \
51-
if(1) {\
52-
printf("%s", prefix); \
53-
printf(fmt, ##__VA_ARGS__); \
54-
fflush(stdout); \
55-
}
39+
void set_log_mode(const char* mode);
40+
void set_log_level(log_level level);
41+
void set_log_level(const char* log_level);
42+
void log_message(log_level level, const char* format, ...);
5643

57-
#define PRINT(fmt, ...) _PRINT("", fmt, ##__VA_ARGS__)
58-
#define ERR(fmt, ...) _PRINT("[Error] ", fmt, ##__VA_ARGS__)
59-
#define WARNING(fmt, ...) _PRINT("[Warning] ", fmt, ##__VA_ARGS__)
60-
#define DBG(fmt, ...) if(dbg_lvl >= DBG) _PRINT("[DBG] ", fmt, ##__VA_ARGS__)
61-
#define INFO(fmt, ...) if(dbg_lvl >= INFO) _PRINT("[Info] ", fmt, ##__VA_ARGS__)
62-
#define TRACE(fmt, ...) if(dbg_lvl >= TRACE) PRINT(fmt, ##__VA_ARGS__)
44+
#define PRINT(format, ...) \
45+
log_message(LOG_LEVEL_NONE, format, ##__VA_ARGS__)
46+
47+
#define ERR(format, ...) \
48+
log_message(LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
49+
50+
#define WARNING(format, ...) \
51+
log_message(LOG_LEVEL_WARNING, format, ##__VA_ARGS__)
52+
53+
#define INFO(format, ...) \
54+
log_message(LOG_LEVEL_INFO, format, ##__VA_ARGS__)
55+
56+
#define DBG(format, ...) \
57+
log_message(LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
58+
59+
#define TRACE(format, ...) \
60+
log_message(LOG_LEVEL_TRACE, format, ##__VA_ARGS__)
6361

64-
#ifdef __cplusplus
65-
#define TRACING() tracer trace(__FUNCTION__);
66-
#else
67-
#define TRACING()
68-
#endif
6962

7063
#ifdef __cplusplus
7164
class tracer {
@@ -81,14 +74,10 @@ class tracer {
8174
};
8275
#endif
8376

84-
inline int set_dbg_lvl(int lvl)
85-
{
86-
int ret = 1;
87-
if(lvl >= ERR && lvl <= TRACE) {
88-
dbg_lvl = lvl;
89-
ret = 0;
90-
}
91-
return ret;
92-
}
93-
77+
#ifdef __cplusplus
78+
#define TRACING() tracer trace(__FUNCTION__);
79+
#else
80+
#define TRACING()
9481
#endif
82+
83+
#endif // _DEBUG_H

cmn/vsyncalter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131

3232
int vsync_lib_init();
3333
void vsync_lib_uninit();
34-
void synchronize_vsync(double time_diff, int pipe = ALL_PIPES);
34+
void synchronize_vsync(double time_diff, int pipe = ALL_PIPES, double shift = 0.01);
3535
int get_vsync(long *vsync_array, int size, int pipe = 0);
36+
double get_vblank_interval(int pipe);
37+
void shutdown_lib(void);
3638

3739
#endif

lib/Makefile

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,63 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: MIT
33

4-
export PWD=$(shell pwd)
5-
BINNAME=libvsyncalter.so
6-
MAKE += --no-print-directory
7-
export CC=g++
8-
export DBG_FLAGS?=-Ofast
9-
export LIBS=-lrt -ldrm -lpciaccess
10-
export INCLUDES=-I../cmn -I/usr/include/drm -Iplatforms
11-
export CFLAGS=-c -fPIC
12-
export LFLAGS=-Wall
13-
export HEADERS=$(wildcard *.h)
14-
export SOURCES=$(wildcard *.cpp)
15-
OBJECTS=$(SOURCES:.cpp=.o)
16-
17-
all::
18-
@echo "Compiling..."
19-
20-
all::$(SOURCES) $(BINNAME)
21-
22-
all::
23-
@echo "Done"
24-
25-
$(BINNAME): $(OBJECTS)
26-
@$(CC) $(DBG_FLAGS) $(LFLAGS) -shared -o $@ $(OBJECTS) $(LIBS)
27-
@if [ "$(DBG_FLAGS)" = "" ]; then \
28-
echo "Stripping $@"; \
29-
strip -x $@; \
30-
fi
31-
32-
.cpp.o:
33-
@echo $<
34-
@$(CC) $(DBG_FLAGS) $(CFLAGS) $(LFLAGS) $(INCLUDES) $<
4+
# Compiler and Flags
5+
CXX := g++
6+
CXXFLAGS := -Wall -fPIC -I../cmn -Iplatforms -Iinclude -I. -I/usr/include/drm
7+
LIBS :=-lrt -ldrm -lpciaccess
8+
# Directories
9+
SRCDIR := .
10+
OBJDIR := obj
11+
INCLUDEDIR := include
12+
13+
# Target libraries
14+
TARGET_SHARED := libvsyncalter.so
15+
TARGET_STATIC := libvsyncalter.a
16+
17+
# Find source files, create a list of object files
18+
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
19+
HEADERS := $(wildcard $(SRCDIR)/*.h ../cmn/*.h)
20+
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
21+
DEPS := $(OBJECTS:.o=.d) # Dependency files corresponding to object files
22+
23+
# Check if VERBOSE is set to 1, if not, silence the commands
24+
ifeq ($(VERBOSE),1)
25+
CMD_PREFIX=
26+
else
27+
CMD_PREFIX=@
28+
endif
29+
30+
# Default target
31+
all: $(TARGET_SHARED) $(TARGET_STATIC)
32+
33+
# Shared library
34+
$(TARGET_SHARED): $(OBJECTS)
35+
$(CMD_PREFIX)echo "Creating shared library..."
36+
$(CMD_PREFIX)$(CXX) -Wall -shared $(DBG_FLAGS) -o $@ $^ $(LIBS)
37+
# Static library
38+
$(TARGET_STATIC): $(OBJECTS)
39+
$(CMD_PREFIX)echo "Creating static library..."
40+
$(CMD_PREFIX)ar rcs $@ $^
41+
42+
# Compile source files into object files
43+
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(HEADERS)
44+
$(CMD_PREFIX)echo "Compiling $<"
45+
$(CMD_PREFIX)mkdir -p $(OBJDIR)
46+
$(CMD_PREFIX)$(CXX) $(CXXFLAGS) $(DBG_FLAGS) -c $< -o $@
47+
48+
# Include the .d files
49+
-include $(DEPS)
3550

3651
debug:
3752
@export DBG_FLAGS='-g -D DEBUGON'; \
3853
$(MAKE)
3954

55+
# Clean up build artifacts
4056
clean:
41-
@echo "Cleaning..."
42-
@rm -f $(BINNAME) *.o
57+
$(CMD_PREFIX)echo "Cleaning..."
58+
$(CMD_PREFIX)rm -f $(TARGET_SHARED) $(TARGET_STATIC) $(OBJECTS) $(DEPS)
59+
$(CMD_PREFIX)rm -rf $(OBJDIR)
4360

61+
62+
# Phony targets
63+
.PHONY: all clean

0 commit comments

Comments
 (0)