Permalink
Browse files

patches supplied by marcan

  • Loading branch information...
1 parent 434e715 commit 336de2c5ee1a382f19d76a46de95aa30d7be785d shagkur committed Oct 15, 2008
Showing with 136 additions and 60 deletions.
  1. +1 −1 Makefile
  2. +1 −0 gc/gccore.h
  3. +3 −2 gc/ogc/conf.h
  4. +1 −0 gc/ogc/es.h
  5. +0 −3 gc/ogc/usbstorage.h
  6. +9 −1 gcsdk.dsp
  7. +1 −0 libogc/conf.c
  8. +18 −1 libogc/es.c
  9. +3 −41 libogc/system.c
  10. +99 −10 libogc/video.c
  11. +0 −1 wiiuse/ir.c
View
@@ -144,7 +144,7 @@ OGCOBJ := \
console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o \
sbrk.o malloc_lock.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
sdgecko_io.o sdgecko_buf.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \
- texconv.o
+ texconv.o wiilaunch.o
#---------------------------------------------------------------------------------
MODOBJ := freqtab.o mixer.o modplay.o semitonetab.o gcmodplay.o
View
@@ -73,6 +73,7 @@ distribution.
#include "ogc/isfs.h"
#include "ogc/conf.h"
#include "ogc/usbstorage.h"
+#include "ogc/wiilaunch.h"
#endif
/*
View
@@ -64,8 +64,9 @@ enum {
enum {
CONF_REGION_JP = 0,
- CONF_REGION_US,
- CONF_REGION_EU
+ CONF_REGION_US = 1,
+ CONF_REGION_EU = 2,
+ CONF_REGION_KR = 6
};
enum {
View
@@ -235,6 +235,7 @@ s32 ES_AddContentData(s32 cid, u8 *data, u32 data_size);
s32 ES_AddContentFinish(u32 cid);
s32 ES_AddTitleFinish(void);
s32 ES_AddTitleCancel(void);
+s32 ES_ImportBoot(const signed_blob *tik, u32 tik_size,const signed_blob *tik_certs, u32 tik_certs_size,const signed_blob *tmd, u32 tmd_size,const signed_blob *tmd_certs, u32 tmd_certs_size,const u8 *content, u32 content_size);
s32 ES_OpenContent(u16 index);
s32 ES_ReadContent(s32 cfd, u8 *data, u32 data_size);
s32 ES_SeekContent(s32 cfd, s32 where, s32 whence);
View
@@ -31,9 +31,6 @@ typedef struct
u8 ep_in;
u8 ep_out;
- u32 ep_in_size;
- u32 ep_out_size;
-
u8 max_lun;
u32 *sector_size;
View
@@ -64,7 +64,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
@@ -436,6 +436,10 @@ SOURCE=.\libogc\video_asm.S
# End Source File
# Begin Source File
+SOURCE=.\libogc\wiilaunch.c
+# End Source File
+# Begin Source File
+
SOURCE=.\libogc\wiisd.c
# End Source File
# End Group
@@ -1286,6 +1290,10 @@ SOURCE=.\gc\ogc\video.h
SOURCE=.\gc\ogc\video_types.h
# End Source File
+# Begin Source File
+
+SOURCE=.\gc\ogc\wiilaunch.h
+# End Source File
# End Group
# Begin Group "ip4.h"
View
@@ -446,6 +446,7 @@ s32 CONF_GetRegion(void)
if(!strcmp(buf, "JP")) return CONF_REGION_JP;
if(!strcmp(buf, "US")) return CONF_REGION_US;
if(!strcmp(buf, "EU")) return CONF_REGION_EU;
+ if(!strcmp(buf, "KR")) return CONF_REGION_KR;
return CONF_EBADVALUE;
}
View
@@ -75,7 +75,7 @@ distribution.
#define IOCTL_ES_DIVERIFY 0x1C
#define IOCTL_ES_GETTITLEDIR 0x1D
#define IOCTL_ES_GETDEVICECERT 0x1E
-//#define IOCTL_ES_IMPORTBOOT 0x1F
+#define IOCTL_ES_IMPORTBOOT 0x1F
#define IOCTL_ES_GETTITLEID 0x20
#define IOCTL_ES_SETUID 0x21
#define IOCTL_ES_DELETETITLECONTENT 0x22
@@ -640,6 +640,23 @@ s32 ES_AddTitleCancel(void)
return IOS_IoctlvFormat(__es_hid, __es_fd, IOCTL_ES_ADDTITLECANCEL, "");
}
+s32 ES_ImportBoot(const signed_blob *tik, u32 tik_size,const signed_blob *tik_certs,u32 tik_certs_size,const signed_blob *tmd,u32 tmd_size,const signed_blob *tmd_certs,u32 tmd_certs_size,const u8 *content,u32 content_size)
+{
+ if(__es_fd<0) return ES_ENOTINIT;
+ if(!tik || !tik_size) return ES_EINVAL;
+ if(!tik_certs || !tik_certs_size) return ES_EINVAL;
+ if(!tmd || !tmd_size) return ES_EINVAL;
+ if(!tmd_certs || !tmd_certs_size) return ES_EINVAL;
+ if(!content || !content_size) return ES_EINVAL;
+ if(!ISALIGNED(tik)) return ES_EALIGN;
+ if(!ISALIGNED(tmd)) return ES_EALIGN;
+ if(!ISALIGNED(tik_certs)) return ES_EALIGN;
+ if(!ISALIGNED(tmd_certs)) return ES_EALIGN;
+ if(!ISALIGNED(content)) return ES_EALIGN;
+
+ return IOS_IoctlvFormat(__es_hid, __es_fd, IOCTL_ES_IMPORTBOOT, "dddddd:", tik, tik_size, tik_certs, tik_certs_size, tmd, tmd_size, tmd_certs, tmd_certs_size, NULL, 0, content, content_size);
+}
+
s32 ES_OpenContent(u16 index)
{
if(__es_fd<0) return ES_ENOTINIT;
View
@@ -44,6 +44,7 @@ distribution.
#include "stm.h"
#include "es.h"
#include "conf.h"
+#include "wiilaunch.h"
#endif
#include "cache.h"
#include "video.h"
@@ -1093,6 +1094,7 @@ void SYS_PreMain()
__IOS_InitializeSubsystems();
STM_RegisterEventHandler(__STMEventHandler);
CONF_Init();
+ WII_Initialize();
#endif
}
@@ -1146,46 +1148,6 @@ void SYS_ResetSystem(s32 reset,u32 reset_code,s32 force_menu)
#if defined(HW_RVL)
-s32 __SYS_LoadMenu()
-{
- s32 res;
- u32 numviews;
- u64 titleID = 0x100000002LL;
- STACK_ALIGN(tikview,views,4,32);
-#ifdef DEBUG_SYSTEM
- printf("Launching menu TitleID: %016llx\n",titleID);
-#endif
-
- res = ES_GetNumTicketViews(titleID, &numviews);
- if(res < 0) {
-#ifdef DEBUG_SYSTEM
- printf(" GetNumTicketViews failed: %d\n",res);
-#endif
- return res;
- }
- if(numviews > 4) {
- printf(" GetNumTicketViews too many views: %u\n",numviews);
- return IOS_ETOOMANYVIEWS;
- }
- res = ES_GetTicketViews(titleID, views, numviews);
- if(res < 0) {
-#ifdef DEBUG_SYSTEM
- printf(" GetTicketViews failed: %d\n",res);
-#endif
- return res;
- }
- res = ES_LaunchTitle(titleID, &views[0]);
- if(res < 0) {
-#ifdef DEBUG_SYSTEM
- printf(" LaunchTitle failed: %d\n",res);
-#endif
- return res;
- }
- __ES_Reset();
- return 0;
-
-}
-
void SYS_ResetSystem(s32 reset,u32 reset_code,s32 force_menu)
{
u32 level,ret = 0;
@@ -1220,7 +1182,7 @@ void SYS_ResetSystem(s32 reset,u32 reset_code,s32 force_menu)
STM_ShutdownToIdle();
break;
case SYS_RETURNTOMENU:
- __SYS_LoadMenu();
+ WII_ReturnToMenu();
break;
}
View
@@ -1796,28 +1796,61 @@ static u32 __VISendI2CData(u8 addr,void *val,u32 len)
return 1;
}
-static void __VISetYUVSEL(u8 dtvstatus)
+static void __VIWriteI2CRegister8(u8 reg, u8 data)
{
- u16 val;
+ u8 buf[2];
+ buf[0] = reg;
+ buf[1] = data;
+ __VISendI2CData(0xe0,buf,2);
+ udelay(2);
+}
+
+static void __VIWriteI2CRegister16(u8 reg, u16 data)
+{
+ u8 buf[3];
+ buf[0] = reg;
+ buf[1] = data >> 8;
+ buf[2] = data & 0xFF;
+ __VISendI2CData(0xe0,buf,3);
+ udelay(2);
+}
+
+static void __VIWriteI2CRegister32(u8 reg, u32 data)
+{
+ u8 buf[5];
+ buf[0] = reg;
+ buf[1] = data >> 24;
+ buf[2] = (data >> 16) & 0xFF;
+ buf[3] = (data >> 8) & 0xFF;
+ buf[4] = data & 0xFF;
+ __VISendI2CData(0xe0,buf,5);
+ udelay(2);
+}
+static void __VIWriteI2CRegisterBuf(u8 reg, int size, u8 *data)
+{
+ u8 buf[0x100];
+ buf[0] = reg;
+ memcpy(&buf[1], data, size);
+ __VISendI2CData(0xe0,buf,size+1);
+ udelay(2);
+}
+
+
+static void __VISetYUVSEL(u8 dtvstatus)
+{
if(currTvMode==VI_NTSC) vdacFlagRegion = 0x0000;
else if(currTvMode==VI_PAL || currTvMode==VI_EURGB60) vdacFlagRegion = 0x0002;
/* FIXME: setting this to 1 causes monochrome output on PAL systems*/
else if(currTvMode==VI_MPAL) vdacFlagRegion = 0x0002;
else vdacFlagRegion = 0x0000;
- val = (_SHIFTL(0x01,8,8)|_SHIFTL(dtvstatus,5,3)|(vdacFlagRegion&0x1f));
- __VISendI2CData(0xe0,&val,sizeof(u16));
- udelay(2);
+ __VIWriteI2CRegister8(0x01, _SHIFTL(dtvstatus,5,3)|(vdacFlagRegion&0x1f));
}
static void __VISetFilterEURGB60(u8 enable)
{
- u16 val;
-
- val = (_SHIFTL(0x6e,8,8)|enable);
- __VISendI2CData(0xe0,&val,sizeof(u16));
- udelay(2);
+ __VIWriteI2CRegister8(0x6e, enable);
}
#if 0
@@ -1839,6 +1872,59 @@ static void __VISet3in1Output(u8 enable)
udelay(2);
}
#endif
+
+static void __VISetupEncoder(void)
+{
+ u8 macrobuf[0x1a];
+
+ u8 gamma[0x21] = {
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00,
+ 0x10, 0x00, 0x10, 0x00, 0x10, 0x20, 0x40, 0x60,
+ 0x80, 0xa0, 0xeb, 0x10, 0x00, 0x20, 0x00, 0x40,
+ 0x00, 0x60, 0x00, 0x80, 0x00, 0xa0, 0x00, 0xeb,
+ 0x00
+ };
+
+ u8 dtv, tv;
+
+ tv = VIDEO_GetCurrentTvMode();
+ dtv = (_viReg[55]&0x01);
+ oldDtvStatus = dtv;
+
+ // SetRevolutionModeSimple
+
+ memset(macrobuf, 0, 0x1a);
+
+ __VIWriteI2CRegister8(0x6a, 1);
+ __VIWriteI2CRegister8(0x65, 1);
+ __VISetYUVSEL(dtv);
+ __VIWriteI2CRegister8(0x00, 0);
+ __VIWriteI2CRegister16(0x71, 0x8e8e);
+ __VIWriteI2CRegister8(0x02, 7);
+ __VIWriteI2CRegister16(0x05, 0x0000);
+ __VIWriteI2CRegister16(0x08, 0x0000);
+ __VIWriteI2CRegister32(0x7A, 0x00000000);
+
+ // Macrovision crap
+ __VIWriteI2CRegisterBuf(0x40, sizeof(macrobuf), macrobuf);
+
+ // Sometimes 1 in RGB mode? (reg 1 == 3)
+ __VIWriteI2CRegister8(0x0A, 0);
+
+ __VIWriteI2CRegister8(0x03, 1);
+
+ __VIWriteI2CRegisterBuf(0x10, sizeof(gamma), gamma);
+
+ __VIWriteI2CRegister8(0x04, 1);
+ __VIWriteI2CRegister32(0x7A, 0x00000000);
+ __VIWriteI2CRegister16(0x08, 0x0000);
+ __VIWriteI2CRegister8(0x03, 1);
+
+ if(tv==VI_EURGB60) __VISetFilterEURGB60(1);
+ else __VISetFilterEURGB60(0);
+ oldTvStatus = tv;
+
+}
#endif
static inline void __getCurrentDisplayPosition(u32 *px,u32 *py)
@@ -2142,6 +2228,9 @@ void VIDEO_Init()
IRQ_Request(IRQ_PI_VI,__VIRetraceHandler,NULL);
__UnmaskIrq(IRQMASK(IRQ_PI_VI));
+#if defined(HW_RVL)
+ __VISetupEncoder();
+#endif
_CPU_ISR_Restore(level);
}
View
@@ -696,7 +696,6 @@ void find_sensorbar(struct ir_t* ir, struct orient_t *orient) {
} else {
int bestidx = 0;
float best = 0.0f;
- float d;
WIIUSE_DEBUG("IR: finding best candidate\n");
// look for the best candidate
// for now, the formula is simple: pick the one with the smallest distance

0 comments on commit 336de2c

Please sign in to comment.