18 #include "../include/ps2cam_rpc.h"
22 #define PS2_CAM_RPC_ID 0x00FD000 +2
45 memset(&cdata, 0,
sizeof(cdata));
51 while (((ret = sceSifBindRpc(&cdata, PS2_CAM_RPC_ID, 0)) >= 0) && (cdata.server == NULL))
58 if (ret < 0)
return ret;
62 buf = (
int *)&data[0];
65 printf(
"bind done\n");
70 printf(
"init done\n");
73 compSema.init_count = 1;
74 compSema.max_count = 1;
76 sem = CreateSema(&compSema);
78 printf(
"sema done\n");
91 ret = (
int *)&data[0];
107 ret = (
int *)&data[0];
123 ret = (
int *)&data[0];
125 ret[0] = device_index;
127 sceSifCallRpc(&cdata, PS2CAM_RPC_OPENDEVICE, 0, (
void*)(&data[0]),4,(
void*)(&data[0]),4,0,0);
139 ret = (
int *)&data[0];
143 sceSifCallRpc(&cdata, PS2CAM_RPC_CLOSEDEVICE, 0, (
void*)(&data[0]),4,(
void*)(&data[0]),4,0,0);
157 ret = (
int *)&data[0];
176 ret = (
int *)&data[0];
181 memcpy(iop_info,
info,
info->ssize);
199 ret = (
int *)&data[0];
224 ret = (
int *)&data[0];
231 if(ret[0] < 0)
return ret[0];
233 SyncDCache(campacket, (u8 *)(&campacket[0]) +
sizeof(campacket));
234 if (sceSifGetOtherData(&rdata, (
void *)ret[1], &campacket[0],
sizeof(campacket), 0) < 0)
249 ret = (
int *)&data[0];
265 ret = (
int *)&data[0];
269 memcpy(&ret[1], cfg, cfg->
ssize);
271 sceSifCallRpc(&cdata, PS2CAM_RPC_SETDEVCONFIG, 0, (
void*)(&data[0]), 4+cfg->
ssize,(
void*)(&data[0]),4+cfg->
ssize,0,0);
278 int PS2CamExtractFrame(
int handle,
char *buffer,
int bufsize)
280 static int capturing;
300 if(ret < 0)
return ret;
306 if(head->
type==0x50 && head->
frame==0x00)
315 memcpy(&buffer[pos], UNCACHED_SEG(&campacket[16]), ret-16 );
320 else if(head->
type==0x50 && head->
frame==0x01)
326 else if(head->
type==0x51 && capturing==1)
330 pic_size = (int)(((head->
Lo) + ((int)(head->
Hi)<<8))<<3);
347 memcpy(&buffer[pos], UNCACHED_SEG(&campacket[0]), ret );
355 if(capturing==1 && ret !=0)
357 memcpy(&buffer[pos], UNCACHED_SEG(&campacket[0]), ret );