PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ps2cam.h
Go to the documentation of this file.
1/*
2 PSX2 OpenSource Project
3 (C)2004 lion[PS2Dev]
4 (C)2004 PS2Dev.org
5*/
6
12#ifndef __PS2CAM_H__
13#define __PS2CAM_H__
14
15#include <types.h>
16
17//rpc call id
19#define PS2CAM_RPC_GETIRXVERSION 40
21#define PS2CAM_RPC_INITIALIZE 41
23#define PS2CAM_RPC_GETDEVCOUNT 42
24#define PS2CAM_RPC_OPENDEVICE 43
25#define PS2CAM_RPC_CLOSEDEVICE 44
27#define PS2CAM_RPC_GETDEVSTATUS 45
29#define PS2CAM_RPC_GETDEVINFO 46
31#define PS2CAM_RPC_SETDEVBANDWIDTH 47
33#define PS2CAM_RPC_READPACKET 48
35#define PS2CAM_RPC_SETLEDMODE 49
36
37#define PS2CAM_RPC_SETDEVCONFIG 50
38
39/* camera vendor(s) */
41#define PS2CAM_VEND_SONY 0x054C
43#define PS2CAM_VEND_DLINK 0x05A9
45#define PS2CAM_VEND_LOGITECH 0x0000
46
47/* product id(s) */
49#define PS2CAM_PROD_EYETOY 0x0154
51#define PS2CAM_PROD_EYETOY2 0x0155
53#define PS2CAM_PROD_EYETOY3 0x0156
55#define PS2CAM_PROD_EYETOY4 0x0157
56
58#define PS2CAM_PROD_VISUALSTREAM 0x8519
59
60// eyetoy regs
61#define EYETOY_IREG_H_SIZE 0x10
62#define EYETOY_IREG_V_SIZE 0x11
63#define EYETOY_IREG_X_OFFSETL 0x12
64#define EYETOY_IREG_X_OFFSETH 0x13
65#define EYETOY_IREG_Y_OFFSETL 0x14
66#define EYETOY_IREG_Y_OFFSETH 0x15
67#define EYETOY_IREG_DIVIDER 0x16
68#define EYETOY_IREG_DFR 0x20
69#define EYETOY_IREG_SR 0x21
70#define EYETOY_IREG_FRAR 0x22
71#define EYETOY_IREG_FORMAT 0x25
72
73#define EYETOY_CREG_RESET0 0x50
74#define EYETOY_CREG_RESET1 0x51
75#define EYETOY_CREG_EN_CLK0 0x53
76#define EYETOY_CREG_EN_CLK1 0x54
77#define EYETOY_CREG_AUDIO_CLK 0x55
78#define EYETOY_CREG_SNAPSHOT 0x57
79#define EYETOY_CREG_PONOFF 0x58
80#define EYETOY_CREG_CAMERA_CLK 0x59
81#define EYETOY_CREG_CTRL1 0x5A
82#define EYETOY_CREG_DEB_CLK 0x5B
83#define EYETOY_CREG_CLK 0x5C
84#define EYETOY_CREG_PWDN 0x5D
85#define EYETOY_CREG_USR_DFN 0x5E
86#define EYETOY_CREG_CTRL2 0x5F
87#define EYETOY_CREG_INTERRUPT0 0x60
88#define EYETOY_CREG_INTERRUPT1 0x61
89#define EYETOY_CREG_MASK0 0x62
90#define EYETOY_CREG_MASK1 0x63
91#define EYETOY_CREG_VCI_R0 0x64
92#define EYETOY_CREG_VCI_R1 0x65
93#define EYETOY_CREG_ADC_CTRL 0x68
94#define EYETOY_CREG_UC_CTRL 0x6D
95
96/* these reg control extra pins on chip(eg:red led) */
97#define EYETOY_GPIO_DATA_OUT0 0x71
98#define EYETOY_GPIO_IO_CTRL0 0x72
99
100//alternate settins(select butter size)
102#define EYETOY_ALTERNATE_SIZE_0 0x00
103#define EYETOY_ALTERNATE_SIZE_384 0x01
104#define EYETOY_ALTERNATE_SIZE_512 0x02
105#define EYETOY_ALTERNATE_SIZE_768 0x03
106#define EYETOY_ALTERNATE_SIZE_896 0x04
107
108// device status
110#define CAM_STATUS_NOTCONNECTED 0
112#define CAM_STATUS_CONNECTED 1
114#define CAM_STATUS_CONNECTEDREADY 2
115
116// used with PS2CAM_DEVICE_CONFIG->mask
117#define CAM_CONFIG_MASK_DIMENSION 0x00000001
118#define CAM_CONFIG_MASK_OFFSET 0x00000002
119#define CAM_CONFIG_MASK_DIVIDER 0x00000004
120#define CAM_CONFIG_MASK_FRAMERATE 0x00000008
121
122// error codes
124#define CAM_ERROR_NONE (00)
125#define CAM_ERROR_NOTINIT -(20)
126#define CAM_ERROR_INVALIDDEVICE -(21)
128#define CAM_ERROR_COMMUNKNOWN -(22)
130#define CAM_ERROR_DEVNOTREADY -(23)
132#define CAM_ERROR_NODEVICE -(24)
134#define CAM_ERROR_BADRANGE -(25)
136#define CAM_ERROR_UNKNOWN -(26)
138#define CAM_ERROR_MAXHANDLE -(27)
140#define CAM_ERROR_BADHANDLE -(28)
142#define CAM_ERROR_DISCONNECTED -(29)
143
144typedef struct
145{
147 unsigned int ssize;
148 unsigned short vendor_id;
149 unsigned short product_id;
150 unsigned char vendor_name[32];
151 unsigned char product_name[32];
152 unsigned char model[16];
154
155typedef struct
156{
157 int device_id;
158 int config_id;
159 int status;
160 int bandwidth;
161 int stream_pocket_size;
162
167
170 int bytes;
171 void *arg;
173
174typedef struct
175{
176 int fd;
177 int status;
178 CAMERA_DEVICE *cam;
180
181typedef struct
182{
184 unsigned int ssize;
185 unsigned int mask;
187 unsigned short width;
189 unsigned short height;
191 unsigned short x_offset;
193 unsigned short y_offset;
195 unsigned char h_divider;
197 unsigned char v_divider;
199 unsigned short framerate;
200
202
203typedef struct
204{
206 unsigned char magic1;
208 unsigned char magic2;
210 unsigned char magic3;
212 unsigned char type;
213 unsigned char uk1;
214 unsigned char uk2;
215 unsigned char uk3;
216 unsigned char uk4;
217 unsigned char uk5;
219 unsigned char frame;
220 unsigned char uk6;
221 unsigned char uk7;
222 unsigned char uk8;
223 unsigned char uk9;
225 unsigned char Lo;
227 unsigned char Hi;
229
230#define camSetDIVIDER(p, hdiv, en_lpf, vdiv, en_sa) setReg8((p), EYETOY_IREG_DIVIDER, \
231 ((unsigned char)(hdiv) <<0)|\
232 ((unsigned char)(en_lpf) <<3)|\
233 ((unsigned char)(vdiv) <<4)|\
234 ((unsigned char)(en_sa) <<7));
235
236void rpcMainThread(void* param);
237void *rpcCommandHandler(u32 command, void *buffer, int size);
238
239// usbd.irx calls
240int PS2CamInitDriver();
241int PS2CamProbe(int devId);
242int PS2CamConnect(int devId);
243int PS2CamDisconnect(int devId);
244void PS2CamGetDeviceSring(CAMERA_DEVICE* dev, int index, char *str, int strmax);
245
246//private funtions
247void PS2CamCallback(int resultCode, int bytes, void *arg);
251int PS2CamGetIRXVersion(void);
252int PS2CamInit(int mode);
253int PS2CamGetDeviceCount(void);
254int PS2CamOpenDevice(int device_index);
255int PS2CamCloseDevice(int handle);
256int PS2CamGetDeviceInfo(int handle,int *info);
257
258// low level camera funtions
259int setReg8(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value);
260int getReg8(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char *value);
261int setReg8Mask(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value,unsigned char mask);
262int setReg16(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned short value);
263int PS2CamSelectInterface(CAMERA_DEVICE* dev, int interface, int altSetting);
264
266void camEnableAutoLaunch(CAMERA_DEVICE *dev);
267void camDisableAutoLaunch(CAMERA_DEVICE *dev);
268void camClearSnapButton(CAMERA_DEVICE *dev);
269int camCheckAutoLaunch(CAMERA_DEVICE *dev);
272void camResetUsb(CAMERA_DEVICE *dev);
277void camBlockStream(CAMERA_DEVICE *dev);
279void camStopStream(CAMERA_DEVICE *dev);
280
281// PS2Cam rpc/export funtions
282int PS2CamReadPacket(int device_id);
283int PS2CamGetDeviceStatus(int device_id);
284int PS2CamSetDeviceBandwidth(int device_id, char bandwidth);
285int PS2CamSetLEDMode(int device_id, int mode);
286int PS2CamSetDeviceConfig(int handle, void *config);
287
288#endif /* __PS2CAM_H__ */
void PS2CamSetDeviceConfiguration(CAMERA_DEVICE *dev, int id)
Definition ps2cam.c:429
void camResetDevice(CAMERA_DEVICE *dev)
Definition ps2cam.c:743
void PS2CamCallback(int resultCode, int bytes, void *arg)
Definition ps2cam.c:570
int PS2CamDisconnect(int devId)
Definition ps2cam.c:297
void PS2CamInitializeNewDevice(CAMERA_DEVICE *argv)
Definition ps2cam.c:382
int getReg8(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char *value)
Definition ps2cam.c:606
void camStartStream(CAMERA_DEVICE *dev)
Definition ps2cam.c:837
int PS2CamGetDeviceStatus(int device_id)
Definition ps2cam_rpc.c:151
int PS2CamGetDeviceCount(void)
Definition ps2cam_rpc.c:102
int PS2CamSetLEDMode(int device_id, int mode)
Definition ps2cam_rpc.c:251
int PS2CamInitDriver()
Definition ps2cam.c:109
int PS2CamConnect(int devId)
Definition ps2cam.c:213
int PS2CamGetDeviceInfo(int handle, int *info)
Definition ps2cam.c:1113
int setReg8Mask(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value, unsigned char mask)
Definition ps2cam.c:633
int PS2CamInit(int mode)
Definition ps2cam_rpc.c:37
int PS2CamCloseDevice(int handle)
Definition ps2cam_rpc.c:134
int PS2CamProbe(int devId)
Definition ps2cam.c:143
void PS2CamSetDeviceDefaults(CAMERA_DEVICE *dev)
Definition ps2cam.c:453
void camTurnOffRedLed(CAMERA_DEVICE *dev)
Definition ps2cam.c:830
int PS2CamSelectInterface(CAMERA_DEVICE *dev, int interface, int altSetting)
Definition ps2cam.c:712
int PS2CamSetDeviceBandwidth(int device_id, char bandwidth)
Definition ps2cam_rpc.c:194
void camResetUsb(CAMERA_DEVICE *dev)
Definition ps2cam.c:797
int PS2CamGetIRXVersion(void)
Definition ps2cam_rpc.c:86
void camDisableSystem(CAMERA_DEVICE *dev)
Definition ps2cam.c:790
void camEnableSystem(CAMERA_DEVICE *dev)
Definition ps2cam.c:778
void camTurnOnRedLed(CAMERA_DEVICE *dev)
Definition ps2cam.c:823
void camSetUsbInit(CAMERA_DEVICE *dev)
Definition ps2cam.c:805
int PS2CamSetDeviceConfig(int handle, void *config)
Definition ps2cam.c:1353
int PS2CamOpenDevice(int device_index)
Definition ps2cam_rpc.c:118
void PS2CamGetDeviceSring(CAMERA_DEVICE *dev, int index, char *str, int strmax)
Definition ps2cam.c:674
int PS2CamReadPacket(int device_id)
Definition ps2cam_rpc.c:216
void camSetUsbWork(CAMERA_DEVICE *dev)
Definition ps2cam.c:814
int setReg8(CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value)
Definition ps2cam.c:580