17#include "../include/ps2cam_rpc.h"
21#define PS2_CAM_RPC_ID 0x00FD000 +2
25static int CamInited = 0;
44 if(CamInited)
return 0;
48 while (((ret = SifBindRpc(&cdata, PS2_CAM_RPC_ID, 0)) >= 0) && (cdata.server == NULL))
55 if (ret < 0)
return ret;
59 buf = (
int *)&data[0];
62 printf(
"bind done\n");
72 compSema.init_count = 1;
73 compSema.max_count = 1;
75 sem = CreateSema(&compSema);
90 ret = (
int *)&data[0];
106 ret = (
int *)&data[0];
122 ret = (
int *)&data[0];
124 ret[0] = device_index;
126 SifCallRpc(&cdata, PS2CAM_RPC_OPENDEVICE, 0, (
void*)(&data[0]),4,(
void*)(&data[0]),4,0,0);
138 ret = (
int *)&data[0];
142 SifCallRpc(&cdata, PS2CAM_RPC_CLOSEDEVICE, 0, (
void*)(&data[0]),4,(
void*)(&data[0]),4,0,0);
156 ret = (
int *)&data[0];
175 ret = (
int *)&data[0];
180 memcpy(iop_info,
info,
info->ssize);
198 ret = (
int *)&data[0];
223 ret = (
int *)&data[0];
230 if(ret[0] < 0)
return ret[0];
236 iop_addr = (
int *)(0xbc000000+ret[1]);
238 memcpy(&campacket[0],iop_addr, ret[0]);
255 ret = (
int *)&data[0];
271 ret = (
int *)&data[0];
275 memcpy(&ret[1], cfg, cfg->
ssize);
277 SifCallRpc(&cdata, PS2CAM_RPC_SETDEVCONFIG, 0, (
void*)(&data[0]), 4+cfg->
ssize,(
void*)(&data[0]),4+cfg->
ssize,0,0);
284int PS2CamExtractFrame(
int handle,
char *buffer,
int bufsize)
286 static int capturing;
306 if(ret < 0)
return ret;
312 if(head->
type==0x50 && head->
frame==0x00)
321 memcpy(&buffer[pos], &campacket[16], ret-16 );
326 else if(head->
type==0x50 && head->
frame==0x01)
332 else if(head->
type==0x51 && capturing==1)
336 pic_size = (int)(((head->
Lo) + ((int)(head->
Hi)<<8))<<3);
353 memcpy(&buffer[pos], &campacket[0], ret );
361 if(capturing==1 && ret !=0)
363 memcpy(&buffer[pos], &campacket[0], ret );
#define PS2CAM_RPC_GETDEVSTATUS
int PS2CamReadPacket(int handle)
#define PS2CAM_RPC_SETDEVBANDWIDTH
int PS2CamGetDeviceCount(void)
int PS2CamSetLEDMode(int handle, int mode)
#define PS2CAM_RPC_GETIRXVERSION
int PS2CamCloseDevice(int handle)
int PS2CamSetDeviceBandwidth(int handle, char bandwidth)
#define PS2CAM_RPC_GETDEVCOUNT
#define PS2CAM_RPC_SETLEDMODE
#define PS2CAM_RPC_GETDEVINFO
#define PS2CAM_RPC_INITIALIZE
int PS2CamGetIRXVersion(void)
int PS2CamOpenDevice(int device_index)
int PS2CamGetDeviceStatus(int handle)
#define PS2CAM_RPC_READPACKET