mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
gfx/hid/irs/nv/vi: changes related to sysmodule users, see details:
- Removed hard dependency on applet - Allow appletGetAppletResourceUserId to fail (using default zero in that case) - nvInitialize uses nvdrv:s for AppletType_None - gfx now uses weak global __nx_gfx_vi_service_type for the ViServiceType passed to viInitialize
This commit is contained in:
parent
3a31df429e
commit
ae77cbea97
@ -12,6 +12,8 @@
|
||||
#include "display/gfx.h"
|
||||
#include "nvidia/map.h"
|
||||
|
||||
__attribute__((weak)) ViServiceType __nx_gfx_vi_service_type = ViServiceType_Default;
|
||||
|
||||
static bool g_gfxInitialized = 0;
|
||||
static ViDisplay g_gfxDisplay;
|
||||
static Event g_gfxDisplayVsyncEvent;
|
||||
@ -231,7 +233,7 @@ Result gfxInitDefault(void) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = viInitialize(ViServiceType_Default);
|
||||
rc = viInitialize(__nx_gfx_vi_service_type);
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = viOpenDefaultDisplay(&g_gfxDisplay);
|
||||
|
||||
|
@ -61,17 +61,12 @@ Result hidInitialize(void)
|
||||
if (serviceIsActive(&g_hidSrv))
|
||||
return 0;
|
||||
|
||||
if (R_FAILED(appletInitialize()))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AppletFailedToInitialize);
|
||||
|
||||
Result rc;
|
||||
Handle sharedmem_handle;
|
||||
u64 AppletResourceUserId;
|
||||
|
||||
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
// If this failed (for example because we're a sysmodule) AppletResourceUserId stays zero
|
||||
if (R_FAILED(rc))
|
||||
AppletResourceUserId = 0;
|
||||
u64 AppletResourceUserId = 0;
|
||||
appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
|
||||
rc = smGetService(&g_hidSrv, "hid");
|
||||
if (R_FAILED(rc))
|
||||
@ -124,8 +119,6 @@ void hidExit(void)
|
||||
serviceClose(&g_hidIAppletResource);
|
||||
serviceClose(&g_hidSrv);
|
||||
shmemClose(&g_hidSharedmem);
|
||||
|
||||
appletExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,19 +32,15 @@ Result irsInitialize(void)
|
||||
if (serviceIsActive(&g_irsSrv))
|
||||
return 0;
|
||||
|
||||
if (R_FAILED(appletInitialize()))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AppletFailedToInitialize);
|
||||
|
||||
Result rc;
|
||||
Handle sharedmem_handle;
|
||||
u64 AppletResourceUserId=0;
|
||||
|
||||
g_irsSensorActivated = 0;
|
||||
memset(g_irsCameras, 0, sizeof(g_irsCameras));
|
||||
|
||||
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
if (R_FAILED(rc))
|
||||
return rc;
|
||||
// If this failed (for example because we're a sysmodule) AppletResourceUserId stays zero
|
||||
u64 AppletResourceUserId=0;
|
||||
appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
|
||||
rc = smGetService(&g_irsSrv, "irs");
|
||||
if (R_FAILED(rc))
|
||||
@ -83,7 +79,6 @@ void irsExit(void)
|
||||
|
||||
serviceClose(&g_irsSrv);
|
||||
shmemClose(&g_irsSharedmem);
|
||||
appletExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,15 +28,14 @@ Result nvInitialize(void)
|
||||
if (serviceIsActive(&g_nvSrv))
|
||||
return 0;
|
||||
|
||||
if (R_FAILED(appletInitialize())) {
|
||||
atomicDecrement64(&g_refCnt);
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AppletFailedToInitialize);
|
||||
}
|
||||
|
||||
Result rc = 0;
|
||||
u64 AppletResourceUserId = 0;
|
||||
|
||||
switch (appletGetAppletType()) {
|
||||
case AppletType_None:
|
||||
rc = smGetService(&g_nvSrv, "nvdrv:s");
|
||||
break;
|
||||
|
||||
case AppletType_Default:
|
||||
case AppletType_Application:
|
||||
case AppletType_SystemApplication:
|
||||
@ -91,7 +90,6 @@ void nvExit(void)
|
||||
serviceClose(&g_nvSrvClone);
|
||||
serviceClose(&g_nvSrv);
|
||||
tmemClose(&g_nvTransfermem);
|
||||
appletExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,6 @@ Result viInitialize(ViServiceType service_type)
|
||||
if (serviceIsActive(&g_viIApplicationDisplayService))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
||||
|
||||
if (R_FAILED(appletInitialize()))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AppletFailedToInitialize);
|
||||
|
||||
Service root_srv;
|
||||
Result rc = 0;
|
||||
|
||||
@ -88,8 +85,6 @@ void viExit(void)
|
||||
serviceClose(&g_viIHOSBinderDriverRelay);
|
||||
serviceClose(&g_viIApplicationDisplayService);
|
||||
g_viServiceType = ViServiceType_Default;
|
||||
|
||||
appletExit();
|
||||
}
|
||||
|
||||
Service* viGetSession_IApplicationDisplayService(void)
|
||||
|
Loading…
Reference in New Issue
Block a user