Skip to content

Commit

Permalink
Merge pull request #20 from intel-retail/release-3.0.0
Browse files Browse the repository at this point in the history
Release 3.0.0
  • Loading branch information
eshenayo authored Oct 31, 2024
2 parents d50a7a6 + 2349d7b commit 2f1d310
Show file tree
Hide file tree
Showing 32 changed files with 3,139 additions and 590 deletions.
697 changes: 454 additions & 243 deletions README.md

Large diffs are not rendered by default.

81 changes: 35 additions & 46 deletions cmn/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,40 @@
#ifndef _DEBUG_H
#define _DEBUG_H

#include <stdio.h>

enum {
ERR,
INFO,
DBG,
TRACE,
enum log_level {
LOG_LEVEL_NONE,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_TRACE,
};

/**
* Set it to 0 or higher with 0 being lowest number of messages
* 0 = Only errors show up
* 1 = Errors + Info messages
* 2 = Errors + Info messages + Debug messages
* 3 = Errors + Info messages + Debug messages + Trace calls
*/
#ifdef DEBUGON
static int dbg_lvl = DBG;
#else
static int dbg_lvl = INFO;
#endif
extern log_level dbg_lvl;

#define _PRINT(prefix, fmt, ...) \
if(1) {\
printf("%s", prefix); \
printf(fmt, ##__VA_ARGS__); \
fflush(stdout); \
}
void set_log_mode(const char* mode);
void set_log_level(log_level level);
void set_log_level(const char* log_level);
void log_message(log_level level, const char* format, ...);

#define PRINT(fmt, ...) _PRINT("", fmt, ##__VA_ARGS__)
#define ERR(fmt, ...) _PRINT("[Error] ", fmt, ##__VA_ARGS__)
#define WARNING(fmt, ...) _PRINT("[Warning] ", fmt, ##__VA_ARGS__)
#define DBG(fmt, ...) if(dbg_lvl >= DBG) _PRINT("[DBG] ", fmt, ##__VA_ARGS__)
#define INFO(fmt, ...) if(dbg_lvl >= INFO) _PRINT("[Info] ", fmt, ##__VA_ARGS__)
#define TRACE(fmt, ...) if(dbg_lvl >= TRACE) PRINT(fmt, ##__VA_ARGS__)
#define PRINT(format, ...) \
log_message(LOG_LEVEL_NONE, format, ##__VA_ARGS__)

#define ERR(format, ...) \
log_message(LOG_LEVEL_ERROR, format, ##__VA_ARGS__)

#define WARNING(format, ...) \
log_message(LOG_LEVEL_WARNING, format, ##__VA_ARGS__)

#define INFO(format, ...) \
log_message(LOG_LEVEL_INFO, format, ##__VA_ARGS__)

#define DBG(format, ...) \
log_message(LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)

#define TRACE(format, ...) \
log_message(LOG_LEVEL_TRACE, format, ##__VA_ARGS__)

#ifdef __cplusplus
#define TRACING() tracer trace(__FUNCTION__);
#else
#define TRACING()
#endif

#ifdef __cplusplus
class tracer {
Expand All @@ -81,14 +74,10 @@ class tracer {
};
#endif

inline int set_dbg_lvl(int lvl)
{
int ret = 1;
if(lvl >= ERR && lvl <= TRACE) {
dbg_lvl = lvl;
ret = 0;
}
return ret;
}

#ifdef __cplusplus
#define TRACING() tracer trace(__FUNCTION__);
#else
#define TRACING()
#endif

#endif // _DEBUG_H
4 changes: 3 additions & 1 deletion cmn/vsyncalter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

int vsync_lib_init();
void vsync_lib_uninit();
void synchronize_vsync(double time_diff, int pipe = ALL_PIPES);
void synchronize_vsync(double time_diff, int pipe = ALL_PIPES, double shift = 0.01);
int get_vsync(long *vsync_array, int size, int pipe = 0);
double get_vblank_interval(int pipe);
void shutdown_lib(void);

#endif
86 changes: 53 additions & 33 deletions lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: MIT

export PWD=$(shell pwd)
BINNAME=libvsyncalter.so
MAKE += --no-print-directory
export CC=g++
export DBG_FLAGS?=-Ofast
export LIBS=-lrt -ldrm -lpciaccess
export INCLUDES=-I../cmn -I/usr/include/drm -Iplatforms
export CFLAGS=-c -fPIC
export LFLAGS=-Wall
export HEADERS=$(wildcard *.h)
export SOURCES=$(wildcard *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)

all::
@echo "Compiling..."

all::$(SOURCES) $(BINNAME)

all::
@echo "Done"

$(BINNAME): $(OBJECTS)
@$(CC) $(DBG_FLAGS) $(LFLAGS) -shared -o $@ $(OBJECTS) $(LIBS)
@if [ "$(DBG_FLAGS)" = "" ]; then \
echo "Stripping $@"; \
strip -x $@; \
fi

.cpp.o:
@echo $<
@$(CC) $(DBG_FLAGS) $(CFLAGS) $(LFLAGS) $(INCLUDES) $<
# Compiler and Flags
CXX := g++
CXXFLAGS := -Wall -fPIC -I../cmn -Iplatforms -Iinclude -I. -I/usr/include/drm
LIBS :=-lrt -ldrm -lpciaccess
# Directories
SRCDIR := .
OBJDIR := obj
INCLUDEDIR := include

# Target libraries
TARGET_SHARED := libvsyncalter.so
TARGET_STATIC := libvsyncalter.a

# Find source files, create a list of object files
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
HEADERS := $(wildcard $(SRCDIR)/*.h ../cmn/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
DEPS := $(OBJECTS:.o=.d) # Dependency files corresponding to object files

# Check if VERBOSE is set to 1, if not, silence the commands
ifeq ($(VERBOSE),1)
CMD_PREFIX=
else
CMD_PREFIX=@
endif

# Default target
all: $(TARGET_SHARED) $(TARGET_STATIC)

# Shared library
$(TARGET_SHARED): $(OBJECTS)
$(CMD_PREFIX)echo "Creating shared library..."
$(CMD_PREFIX)$(CXX) -Wall -shared $(DBG_FLAGS) -o $@ $^ $(LIBS)
# Static library
$(TARGET_STATIC): $(OBJECTS)
$(CMD_PREFIX)echo "Creating static library..."
$(CMD_PREFIX)ar rcs $@ $^

# Compile source files into object files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(HEADERS)
$(CMD_PREFIX)echo "Compiling $<"
$(CMD_PREFIX)mkdir -p $(OBJDIR)
$(CMD_PREFIX)$(CXX) $(CXXFLAGS) $(DBG_FLAGS) -c $< -o $@

# Include the .d files
-include $(DEPS)

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

# Clean up build artifacts
clean:
@echo "Cleaning..."
@rm -f $(BINNAME) *.o
$(CMD_PREFIX)echo "Cleaning..."
$(CMD_PREFIX)rm -f $(TARGET_SHARED) $(TARGET_STATIC) $(OBJECTS) $(DEPS)
$(CMD_PREFIX)rm -rf $(OBJDIR)


# Phony targets
.PHONY: all clean
Loading

0 comments on commit 2f1d310

Please sign in to comment.