Skip to content

Commit 64fc4a0

Browse files
committed
introducting VIDimming
1 parent 69cea24 commit 64fc4a0

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

gc/ogc/stm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ s32 STM_RebootSystem(void);
7474
s32 STM_SetLedMode(u32 mode);
7575
s32 STM_StartLEDFlashLoop(u8 id, u8 priority, u8 flags, const u16* patterns, u32 num_patterns);
7676

77+
s32 STM_VIDimming(bool enable, u32 luma, u32 chroma);
78+
7779
#ifdef __cplusplus
7880
}
7981
#endif /* __cplusplus */

libogc/stm.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,36 @@ s32 STM_StartLEDFlashLoop(u8 id, u8 priority, u8 flags, const u16* patterns, u32
318318
return ret;
319319
}
320320

321+
// https://wiibrew.org/wiki//dev/stm/immediate#VIDimming
322+
s32 STM_VIDimming(bool enable, u32 luma, u32 chroma) {
323+
s32 ret, fd;
324+
u32 inbuf[8], outbuf[8];
325+
326+
inbuf[0] = enable << 7 | (luma & 0x7) << 3 | (chroma & 0x7);
327+
inbuf[1] = 0;
328+
inbuf[2] = 0;
329+
330+
inbuf[4] = 0; // keep nothing
331+
inbuf[5] = ~0; // keep everything
332+
inbuf[6] = ~0; // <official software> uses 0xFFFF0000 here, but, what is the register even for....
333+
334+
ret = fd = IOS_Open("/dev/stm/immediate", 0);
335+
if (ret >= 0) {
336+
ret = IOS_Ioctl(fd, IOCTL_STM_VIDIMMING, inbuf, sizeof inbuf, outbuf, sizeof outbuf);
337+
if (ret < 0) {
338+
STM_printf("STM LEDMode failed (%i).\n", ret);
339+
} else {
340+
STM_printf("0x0d80001c: %08x\n", outbuf[0]);
341+
STM_printf("0x0d800020: %08x\n", outbuf[1]);
342+
STM_printf("0x0d800028: %08x\n", outbuf[2]);
343+
}
344+
345+
IOS_Close(fd);
346+
} else {
347+
STM_printf("Open /dev/stm/immediate failed {%i}\n", ret);
348+
}
349+
350+
return ret;
351+
}
352+
321353
#endif /* defined(HW_RVL) */

0 commit comments

Comments
 (0)