mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
capssc: Updated for new-ipc.
This commit is contained in:
parent
21e35ede7c
commit
39288a832e
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../services/sm.h"
|
#include "../sf/service.h"
|
||||||
#include "../services/caps.h"
|
#include "../services/caps.h"
|
||||||
|
|
||||||
/// Initialize caps:sc. Only available on [2.0.0+].
|
/// Initialize caps:sc. Only available on [2.0.0+].
|
||||||
|
@ -1,36 +1,26 @@
|
|||||||
#include "types.h"
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
#include "result.h"
|
#include "service_guard.h"
|
||||||
#include "arm/atomics.h"
|
|
||||||
#include "kernel/ipc.h"
|
|
||||||
#include "runtime/hosversion.h"
|
#include "runtime/hosversion.h"
|
||||||
#include "services/caps.h"
|
#include "services/caps.h"
|
||||||
#include "services/capssc.h"
|
#include "services/capssc.h"
|
||||||
#include "services/sm.h"
|
|
||||||
|
|
||||||
static Service g_capsscSrv;
|
static Service g_capsscSrv;
|
||||||
static u64 g_capsscRefCnt;
|
|
||||||
|
|
||||||
Result capsscInitialize(void) {
|
NX_GENERATE_SERVICE_GUARD(capssc);
|
||||||
|
|
||||||
|
Result _capsscInitialize(void) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
atomicIncrement64(&g_capsscRefCnt);
|
|
||||||
|
|
||||||
if (serviceIsActive(&g_capsscSrv))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (hosversionBefore(2,0,0))
|
if (hosversionBefore(2,0,0))
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
rc = MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = smGetService(&g_capsscSrv, "caps:sc");
|
if (R_SUCCEEDED(rc)) rc = smGetService(&g_capsscSrv, "caps:sc");
|
||||||
|
|
||||||
if (R_FAILED(rc)) capsscExit();
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void capsscExit(void) {
|
void _capsscCleanup(void) {
|
||||||
if (atomicDecrement64(&g_capsscRefCnt) == 0)
|
serviceClose(&g_capsscSrv);
|
||||||
serviceClose(&g_capsscSrv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* capsscGetServiceSession(void) {
|
Service* capsscGetServiceSession(void) {
|
||||||
@ -38,48 +28,18 @@ Service* capsscGetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result capsscCaptureRawImageWithTimeout(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout) {
|
Result capsscCaptureRawImageWithTimeout(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout) {
|
||||||
IpcCommand c;
|
const struct {
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
u32 inval;
|
u32 inval;
|
||||||
u64 width;
|
u64 width;
|
||||||
u64 height;
|
u64 height;
|
||||||
s64 buffer_count;
|
s64 buffer_count;
|
||||||
s64 buffer_index;
|
s64 buffer_index;
|
||||||
u64 timeout;
|
u64 timeout;
|
||||||
} *raw;
|
} in = { inval, width, height, buffer_count, buffer_index, timeout };
|
||||||
|
|
||||||
ipcAddRecvBuffer(&c, buf, size, 1);
|
return serviceDispatchIn(&g_capsscSrv, 2, in,
|
||||||
|
.buffer_attrs = { SfBufferAttr_HipcMapTransferAllowsNonSecure | SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||||
raw = serviceIpcPrepareHeader(&g_capsscSrv, &c, sizeof(*raw));
|
.buffers = { { buf, size } },
|
||||||
|
);
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 2;
|
|
||||||
raw->inval = inval;
|
|
||||||
raw->width = width;
|
|
||||||
raw->height = height;
|
|
||||||
raw->buffer_count = buffer_count;
|
|
||||||
raw->buffer_index = buffer_index;
|
|
||||||
raw->timeout = timeout;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_capsscSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_capsscSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user