From 283fdabbf64c2d3b6532cdbea6cb3f71d777f140 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sun, 19 Nov 2017 00:35:49 -0500 Subject: [PATCH] Renamed gfxproducerBufferInit to gfxproducerTegraBufferInit. Use an enum for the binder 'code' for this. Added comments for the BufferInitData structure. --- nx/include/switch/gfx/gfxproducer.h | 2 +- nx/source/gfx/gfxproducer.c | 6 +++--- nx/source/gfx/nvgfx.c | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nx/include/switch/gfx/gfxproducer.h b/nx/include/switch/gfx/gfxproducer.h index 72ef5466..16c89c1b 100644 --- a/nx/include/switch/gfx/gfxproducer.h +++ b/nx/include/switch/gfx/gfxproducer.h @@ -6,4 +6,4 @@ Result gfxproducerDequeueBuffer(bool async, u32 width, u32 height, s32 format, u Result gfxproducerQueueBuffer(s32 buf, u8 input[0x5c]); Result gfxproducerQuery(s32 what, s32* value); Result gfxproducerConnect(s32 api, bool producerControlledByApp); -Result gfxproducerBufferInit(s32 buf, u8 input[0x178]); +Result gfxproducerTegraBufferInit(s32 buf, u8 input[0x178]); diff --git a/nx/source/gfx/gfxproducer.c b/nx/source/gfx/gfxproducer.c index b3aba070..9546098c 100644 --- a/nx/source/gfx/gfxproducer.c +++ b/nx/source/gfx/gfxproducer.c @@ -19,6 +19,7 @@ enum { DISCONNECT, //0xB SET_SIDEBAND_STREAM, //0xC ALLOCATE_BUFFERS, //0xD + TEGRA_BUFFER_INIT, //0xE (Custom Switch-specific command - unofficial name) }; static char _gfxproducer_InterfaceDescriptor[] = "android.gui.IGraphicBufferProducer"; @@ -152,8 +153,7 @@ Result gfxproducerConnect(s32 api, bool producerControlledByApp) { return 0; } -//Unknown what this is. -Result gfxproducerBufferInit(s32 buf, u8 input[0x178]) { +Result gfxproducerTegraBufferInit(s32 buf, u8 input[0x178]) { Result rc; parcelContext parcel, parcel_reply; @@ -167,7 +167,7 @@ Result gfxproducerBufferInit(s32 buf, u8 input[0x178]) { parcelWriteInt32(&parcel, buf); parcelWriteData(&parcel, input, 0x178); - rc = parcelTransact(g_gfxproducerBinderSession, 0xE, &parcel, &parcel_reply); + rc = parcelTransact(g_gfxproducerBinderSession, TEGRA_BUFFER_INIT, &parcel, &parcel_reply); if (R_FAILED(rc)) return rc; //TODO: parse reply diff --git a/nx/source/gfx/nvgfx.c b/nx/source/gfx/nvgfx.c index f61ecb8b..eaf1ede3 100644 --- a/nx/source/gfx/nvgfx.c +++ b/nx/source/gfx/nvgfx.c @@ -37,6 +37,7 @@ static nvmapobj nvmap_objs[18]; static u64 nvmap_obj6_mapbuffer_xdb_offset; +//Some of this struct is based on tegra_dc_ext_flip_windowattr. static u32 g_gfxprod_BufferInitData[0x178>>2] = { 0x1, 0x16c, 0x0, 0x47424652, @@ -48,7 +49,7 @@ static u32 g_gfxprod_BufferInitData[0x178>>2] = { 0x0, 0xdaffcaff, 0x2a, 0x0, 0xb00, 0x1, 0x1, 1280, 0x3c0000, 0x1, 0x0, 1280, -720, 0x532120, 0x1, 0x3, +720, 0x532120, 0x1, 0x3, //0x52* field is flags 0x1400, 0x0, //nvmap handle 0x0, @@ -300,7 +301,7 @@ Result nvgfxInitialize(void) { g_gfxprod_BufferInitData[0x20] = tmpval; g_gfxprod_BufferInitData[0x21] = 0x3c0000*i; ptr64[0x170>>3] = svcGetSystemTick(); - rc = gfxproducerBufferInit(i, (u8*)g_gfxprod_BufferInitData); + rc = gfxproducerTegraBufferInit(i, (u8*)g_gfxprod_BufferInitData); if (R_FAILED(rc)) break; } if (R_FAILED(rc)) break;