From e084512afd3bab3a874bbfe8460c0c8912b4940b Mon Sep 17 00:00:00 2001 From: Joel16 Date: Mon, 19 Sep 2022 23:27:34 -0400 Subject: [PATCH] audio_driver: Drop audio_driver in favour of kuKernelCall --- .gitignore | 1 - Makefile | 2 +- app/include/kernel_functions.h | 2 +- app/source/kernel_functions.cpp | 20 +++++++++++++++++++- app/source/utils.cpp | 5 ++--- audio_driver/Makefile | 24 ------------------------ audio_driver/audio_driver.c | 20 -------------------- audio_driver/exports.exp | 16 ---------------- 8 files changed, 23 insertions(+), 67 deletions(-) delete mode 100644 audio_driver/Makefile delete mode 100644 audio_driver/audio_driver.c delete mode 100644 audio_driver/exports.exp diff --git a/.gitignore b/.gitignore index 9092ab4..de4d62c 100644 --- a/.gitignore +++ b/.gitignore @@ -54,7 +54,6 @@ Mkfile.old dkms.conf # CMFileManager PSP Specific objects -app/drivers/audio_driver.S app/drivers/display_driver.S app/drivers/fs_driver.S app/drivers/module_driver.S diff --git a/Makefile b/Makefile index 27ee0f8..3ac8ce3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SUBDIRS = audio_driver display_driver fs_driver module_driver app launcher +SUBDIRS = display_driver fs_driver module_driver app launcher all: @for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done diff --git a/app/include/kernel_functions.h b/app/include/kernel_functions.h index 69278b1..2f93a9e 100644 --- a/app/include/kernel_functions.h +++ b/app/include/kernel_functions.h @@ -12,7 +12,7 @@ extern "C" { // Kernel function prototypes // audio_driver functions -extern int pspAudioSetFrequency(int frequency); +int pspAudioSetFrequency(int frequency); // display_driver functions extern int pspDisplayEnable(void); diff --git a/app/source/kernel_functions.cpp b/app/source/kernel_functions.cpp index aa8e4c0..9e8adc2 100644 --- a/app/source/kernel_functions.cpp +++ b/app/source/kernel_functions.cpp @@ -1,7 +1,25 @@ +#include + #include "kernel_functions.h" +#include "kubridge.h" +#include "log.h" +#include "systemctrl.h" +#include "utils.h" // audio_driver functions -int pspAudioSetFrequency(int frequency); +int pspAudioSetFrequency(int frequency) { + struct KernelCallArg args = { 0 }; + void *func_addr = nullptr; + int ret = 0; + + func_addr = (void*)sctrlHENFindFunction("sceAudio_driver", "sceAudio_driver", 0xA2BEAA6C); + args.arg1 = static_cast(frequency); + + if (R_FAILED(ret = kuKernelCall(func_addr, &args))) + Log::Error("%s: pspAudioSetFrequency returns 0x%08X\n", __func__, args.ret1); + + return args.ret1; +} // display driver functions int pspDisplayEnable(void); diff --git a/app/source/utils.cpp b/app/source/utils.cpp index 22b52d3..24a161b 100644 --- a/app/source/utils.cpp +++ b/app/source/utils.cpp @@ -21,8 +21,8 @@ enum PspCtrlButtons PSP_CTRL_ENTER, PSP_CTRL_CANCEL; BROWSE_STATE device = BROWSE_STATE_EXTERNAL; int g_psp_language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH; -extern unsigned char audio_driver_prx_start[], display_driver_prx_start[], fs_driver_prx_start[], module_driver_prx_start[]; -extern unsigned int audio_driver_prx_size, display_driver_prx_size, fs_driver_prx_size, module_driver_prx_size; +extern unsigned char display_driver_prx_start[], fs_driver_prx_start[], module_driver_prx_start[]; +extern unsigned int display_driver_prx_size, fs_driver_prx_size, module_driver_prx_size; namespace Utils { constexpr unsigned int CTRL_DEADZONE_DELAY = 500000; @@ -43,7 +43,6 @@ namespace Utils { } Module; static std::vector kernel_modules { - { "audio_driver.prx", -1, audio_driver_prx_start, audio_driver_prx_size }, { "display_driver.prx", -1, display_driver_prx_start, display_driver_prx_size }, { "fs_driver.prx", -1, fs_driver_prx_start, fs_driver_prx_size } }; diff --git a/audio_driver/Makefile b/audio_driver/Makefile deleted file mode 100644 index d68f857..0000000 --- a/audio_driver/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TARGET = audio_driver -OBJS = audio_driver.o exports.o - -PRX_EXPORTS = exports.exp - -# Use the kernel's small inbuilt libc -USE_KERNEL_LIBC = 1 -# Use only kernel libraries -USE_KERNEL_LIBS = 1 - -CFLAGS = -Os -G0 -Wall -fno-builtin-printf -CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -ASFLAGS = $(CFLAGS) - -LDFLAGS = -nostartfiles -LIBS = -lpspaudio_driver - -PSPSDK=$(shell psp-config --pspsdk-path) -include $(PSPSDK)/lib/build_prx.mak - -all: - psp-build-exports -s $(PRX_EXPORTS) - mv audio_driver.S "../app/drivers/" - mv audio_driver.prx "../app/data/" diff --git a/audio_driver/audio_driver.c b/audio_driver/audio_driver.c deleted file mode 100644 index b1444d3..0000000 --- a/audio_driver/audio_driver.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -PSP_MODULE_INFO("audio_driver", PSP_MODULE_KERNEL, 1, 4); -PSP_NO_CREATE_MAIN_THREAD(); - -int pspAudioSetFrequency(int frequency) { - u32 k1 = pspSdkSetK1(0); - int ret = sceAudioSetFrequency(frequency); - pspSdkSetK1(k1); - return ret; -} - -int module_start(SceSize args, void *argp) { - return 0; -} - -int module_stop(void) { - return 0; -} diff --git a/audio_driver/exports.exp b/audio_driver/exports.exp deleted file mode 100644 index b171d25..0000000 --- a/audio_driver/exports.exp +++ /dev/null @@ -1,16 +0,0 @@ -# Define the exports for the prx -PSP_BEGIN_EXPORTS - -# These four lines are mandatory (although you can add other functions like module_stop) -# syslib is a psynonym for the single mandatory export. -PSP_EXPORT_START(syslib, 0, 0x8000) -PSP_EXPORT_FUNC(module_start) -PSP_EXPORT_FUNC(module_stop) -PSP_EXPORT_VAR(module_info) -PSP_EXPORT_END - -PSP_EXPORT_START(audio_driver, 0, 0x4001) -PSP_EXPORT_FUNC(pspAudioSetFrequency) -PSP_EXPORT_END - -PSP_END_EXPORTS