PS2SDK
PS2 Homebrew Libraries
|
#include <stdio.h>
#include <sysclib.h>
#include <tamtypes.h>
#include <thbase.h>
#include <sifcmd.h>
#include <sifrpc.h>
#include <loadcore.h>
#include <ioman.h>
#include <usbd.h>
#include <usbd_macro.h>
#include <thsemap.h>
#include <sysmem.h>
#include "ps2cam.h"
Go to the source code of this file.
Macros | |
#define | MODNAME "PS2 USB camera driver" |
#define | BIND_RPC_ID 0x00FD000 +2 |
#define | DRIVER_VERSON_MAJOR 1 |
#define | DRIVER_VERSON_MINOR 0 |
#define | MAX_CAM_DEVICE 2 |
#define | MAX_CAM_DEVICE_HANDLE 2 |
Functions | |
IRX_ID (MODNAME, 1, 1) | |
static SifRpcDataQueue_t rpc_queue | __attribute__ ((__aligned__(16))) |
static int _rpc_buffer[1024] | __attribute__ ((__aligned__(4))) |
int | _start (int argc, char *argv[]) |
int | PS2CamInitDriver (void) |
int | PS2CamProbe (int devId) |
int | PS2CamConnect (int devId) |
int | PS2CamDisconnect (int devId) |
void | rpcMainThread (void *param) |
void | PS2CamInitializeNewDevice (CAMERA_DEVICE *cam) |
void | PS2CamSetDeviceConfiguration (CAMERA_DEVICE *dev, int id) |
void | PS2CamSetDeviceDefaults (CAMERA_DEVICE *dev) |
void | PS2CamCallback (int resultCode, int bytes, void *arg) |
int | setReg8 (CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value) |
int | getReg8 (CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char *value) |
int | setReg8Mask (CAMERA_DEVICE *dev, unsigned char reg_id, unsigned char value, unsigned char mask) |
int | setReg16 (CAMERA_DEVICE *dev, unsigned char reg_id, unsigned short value) |
void | PS2CamGetDeviceSring (CAMERA_DEVICE *dev, int index, char *str, int strmax) |
int | PS2CamSelectInterface (CAMERA_DEVICE *dev, int interface, int altSetting) |
void | camResetDevice (CAMERA_DEVICE *dev) |
void | camEnableAutoLaunch (CAMERA_DEVICE *dev) |
void | camDisableAutoLaunch (CAMERA_DEVICE *dev) |
void | camClearSnapButton (CAMERA_DEVICE *dev) |
int | camCheckAutoLaunch (CAMERA_DEVICE *dev) |
void | camEnableSystem (CAMERA_DEVICE *dev) |
void | camDisableSystem (CAMERA_DEVICE *dev) |
void | camResetUsb (CAMERA_DEVICE *dev) |
void | camSetUsbInit (CAMERA_DEVICE *dev) |
void | camSetUsbWork (CAMERA_DEVICE *dev) |
void | camTurnOnRedLed (CAMERA_DEVICE *dev) |
void | camTurnOffRedLed (CAMERA_DEVICE *dev) |
void | camStartStream (CAMERA_DEVICE *dev) |
void | camStopStream (CAMERA_DEVICE *dev) |
void | PS2CamReadDataCallback (int resultCode, int bytes, void *arg) |
int | PS2CamReadData (CAMERA_DEVICE *dev, void *addr, int size) |
int | PS2CamGetIRXVersion (void) |
int | PS2CamInit (int mode) |
int | PS2CamGetDeviceCount (void) |
int | PS2CamOpenDevice (int device_index) |
int | PS2CamCloseDevice (int handle) |
int | PS2CamGetDeviceStatus (int handle) |
int | PS2CamGetDeviceInfo (int handle, int *info) |
int | PS2CamSetDeviceBandwidth (int handle, char bandwidth) |
int | PS2CamReadPacket (int handle) |
int | PS2CamSetLEDMode (int handle, int mode) |
int | PS2CamSetDeviceConfig (int handle, void *config) |
void * | rpcCommandHandler (u32 command, void *buffer, int size) |
Variables | |
static int | maintain_thread |
sceUsbdLddOps | cam_driver |
char | irx_initialized = 0 |
int | ps2cam_sema =0 |
CAMERA_DEVICE | Camera [MAX_CAM_DEVICE] |
PS2CAM_DEVICE_HANDLE | CamHandle [MAX_CAM_DEVICE_HANDLE] |
int | read_rslt |
int | read_byts |
PS2Camera driver irx
Definition in file ps2cam.c.
int PS2CamInitDriver | ( | void | ) |
int PS2CamProbe | ( | int | devId | ) |
check if the device is pluged in
Definition at line 143 of file ps2cam.c.
References count, PS2CAM_PROD_EYETOY, PS2CAM_PROD_EYETOY2, PS2CAM_PROD_EYETOY3, PS2CAM_PROD_EYETOY4, PS2CAM_PROD_VISUALSTREAM, PS2CAM_VEND_DLINK, and PS2CAM_VEND_SONY.
int PS2CamConnect | ( | int | devId | ) |
this is executed when a compatible camera is detected
Definition at line 213 of file ps2cam.c.
References CAM_STATUS_CONNECTED, CAMERA_DEVICE::controll, PS2CamInitializeNewDevice(), and CAMERA_DEVICE::stream.
int PS2CamDisconnect | ( | int | devId | ) |
this is executed when a compatible camera is unplugged
Definition at line 297 of file ps2cam.c.
References CAM_STATUS_NOTCONNECTED, CAMERA_DEVICE::controll, and CAMERA_DEVICE::stream.
void PS2CamInitializeNewDevice | ( | CAMERA_DEVICE * | cam | ) |
called after a camera is accepted
Definition at line 382 of file ps2cam.c.
References CAM_STATUS_CONNECTEDREADY, camStartStream(), PS2CamGetDeviceSring(), PS2CamSelectInterface(), PS2CamSetDeviceConfiguration(), and PS2CamSetDeviceDefaults().
Referenced by PS2CamConnect().
void PS2CamSetDeviceConfiguration | ( | CAMERA_DEVICE * | dev, |
int | id | ||
) |
select the configuration for the device
Definition at line 429 of file ps2cam.c.
References CAMERA_DEVICE::controll, PS2CamCallback(), and USB_RC_OK.
Referenced by PS2CamInitializeNewDevice().
void PS2CamSetDeviceDefaults | ( | CAMERA_DEVICE * | dev | ) |
set the defaults for the camera
Definition at line 453 of file ps2cam.c.
References camEnableSystem(), camResetDevice(), camSetUsbInit(), camStartStream(), camTurnOffRedLed(), setReg8(), and setReg8Mask().
Referenced by PS2CamInitializeNewDevice().
void PS2CamCallback | ( | int | resultCode, |
int | bytes, | ||
void * | arg | ||
) |
call back for most lowlevel usb funtions
Definition at line 570 of file ps2cam.c.
Referenced by getReg8(), PS2CamGetDeviceSring(), PS2CamSelectInterface(), PS2CamSetDeviceConfiguration(), and setReg8().
int setReg8 | ( | CAMERA_DEVICE * | dev, |
unsigned char | reg_id, | ||
unsigned char | value | ||
) |
Set the value in a 8bit register
Definition at line 580 of file ps2cam.c.
References CAMERA_DEVICE::controll, PS2CamCallback(), and USB_RC_OK.
Referenced by camEnableSystem(), camResetDevice(), camResetUsb(), camSetUsbInit(), camSetUsbWork(), camStartStream(), PS2CamSetDeviceBandwidth(), PS2CamSetDeviceConfig(), PS2CamSetDeviceDefaults(), and setReg8Mask().
int getReg8 | ( | CAMERA_DEVICE * | dev, |
unsigned char | reg_id, | ||
unsigned char * | value | ||
) |
Read the camera's 8bit register and return the value
Definition at line 606 of file ps2cam.c.
References CAMERA_DEVICE::controll, PS2CamCallback(), and USB_RC_OK.
Referenced by setReg8Mask().
int setReg8Mask | ( | CAMERA_DEVICE * | dev, |
unsigned char | reg_id, | ||
unsigned char | value, | ||
unsigned char | mask | ||
) |
Set the value in a 8bit register using a mask
Definition at line 633 of file ps2cam.c.
References getReg8(), and setReg8().
Referenced by camDisableSystem(), camTurnOffRedLed(), camTurnOnRedLed(), and PS2CamSetDeviceDefaults().
int setReg16 | ( | CAMERA_DEVICE * | dev, |
unsigned char | reg_id, | ||
unsigned short | value | ||
) |
void PS2CamGetDeviceSring | ( | CAMERA_DEVICE * | dev, |
int | index, | ||
char * | str, | ||
int | strmax | ||
) |
Get a string descriptor from device
Definition at line 674 of file ps2cam.c.
References CAMERA_DEVICE::controll, PS2CamCallback(), and USB_RC_OK.
Referenced by PS2CamGetDeviceInfo(), and PS2CamInitializeNewDevice().
int PS2CamSelectInterface | ( | CAMERA_DEVICE * | dev, |
int | interface, | ||
int | altSetting | ||
) |
Select the interface and alternet settting to use
Definition at line 712 of file ps2cam.c.
References CAMERA_DEVICE::controll, PS2CamCallback(), and USB_RC_OK.
Referenced by PS2CamInitializeNewDevice(), and PS2CamSetDeviceBandwidth().
void camResetDevice | ( | CAMERA_DEVICE * | dev | ) |
Reset the eyetoy
Definition at line 743 of file ps2cam.c.
References setReg8().
Referenced by PS2CamSetDeviceDefaults().
void camEnableAutoLaunch | ( | CAMERA_DEVICE * | dev | ) |
void camDisableAutoLaunch | ( | CAMERA_DEVICE * | dev | ) |
void camClearSnapButton | ( | CAMERA_DEVICE * | dev | ) |
int camCheckAutoLaunch | ( | CAMERA_DEVICE * | dev | ) |
void camEnableSystem | ( | CAMERA_DEVICE * | dev | ) |
Enable some setting that make the cam capture
Definition at line 778 of file ps2cam.c.
References setReg8().
Referenced by PS2CamSetDeviceDefaults().
void camDisableSystem | ( | CAMERA_DEVICE * | dev | ) |
void camResetUsb | ( | CAMERA_DEVICE * | dev | ) |
void camSetUsbInit | ( | CAMERA_DEVICE * | dev | ) |
reset jpeg and clear the frame reg
Definition at line 805 of file ps2cam.c.
References setReg8().
Referenced by PS2CamSetDeviceDefaults().
void camSetUsbWork | ( | CAMERA_DEVICE * | dev | ) |
void camTurnOnRedLed | ( | CAMERA_DEVICE * | dev | ) |
turn on the red leg on the GPIO pin
Definition at line 823 of file ps2cam.c.
References setReg8Mask().
Referenced by PS2CamSetLEDMode().
void camTurnOffRedLed | ( | CAMERA_DEVICE * | dev | ) |
turn off the red leg on the GPIO pin
Definition at line 830 of file ps2cam.c.
References setReg8Mask().
Referenced by PS2CamSetDeviceDefaults(), and PS2CamSetLEDMode().
void camStartStream | ( | CAMERA_DEVICE * | dev | ) |
restart stream
Definition at line 837 of file ps2cam.c.
References setReg8().
Referenced by PS2CamInitializeNewDevice(), PS2CamSetDeviceConfig(), and PS2CamSetDeviceDefaults().
void camStopStream | ( | CAMERA_DEVICE * | dev | ) |
void PS2CamReadDataCallback | ( | int | resultCode, |
int | bytes, | ||
void * | arg | ||
) |
int PS2CamReadData | ( | CAMERA_DEVICE * | dev, |
void * | addr, | ||
int | size | ||
) |
int PS2CamGetIRXVersion | ( | void | ) |
Return the current version of the 'ps2cam.irx'
Definition at line 939 of file ps2cam.c.
References PS2CAM_RPC_GETIRXVERSION, and PS2CamGetIRXVersion().
Referenced by PS2CamGetIRXVersion().
int PS2CamInit | ( | int | mode | ) |
initalize the camera driver. must be called 1st
Definition at line 954 of file ps2cam.c.
References PS2CAM_RPC_INITIALIZE, and PS2CamInit().
Referenced by PS2CamInit().
int PS2CamGetDeviceCount | ( | void | ) |
get the number of compatible camera connected
Definition at line 966 of file ps2cam.c.
References count, PS2CAM_RPC_GETDEVCOUNT, and PS2CamGetDeviceCount().
Referenced by PS2CamGetDeviceCount().
int PS2CamOpenDevice | ( | int | device_index | ) |
open one of the compatible camera for reading
Definition at line 990 of file ps2cam.c.
References CAM_ERROR_BADRANGE, CAM_ERROR_MAXHANDLE, CAM_ERROR_NODEVICE, CAM_ERROR_UNKNOWN, and PS2CamOpenDevice().
Referenced by PS2CamOpenDevice().
int PS2CamCloseDevice | ( | int | handle | ) |
close the device if it is no longer needed or disconnected
Definition at line 1059 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, and PS2CamCloseDevice().
Referenced by PS2CamCloseDevice().
int PS2CamGetDeviceStatus | ( | int | handle | ) |
get the status of the compatible camera
Definition at line 1089 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DISCONNECTED, PS2CAM_RPC_GETDEVSTATUS, and PS2CamGetDeviceStatus().
Referenced by PS2CamGetDeviceStatus().
int PS2CamGetDeviceInfo | ( | int | handle, |
int * | info | ||
) |
get information about the compatible device
Definition at line 1113 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DISCONNECTED, PS2CAM_DEVICE_INFO::model, PS2CAM_DEVICE_INFO::product_id, PS2CAM_DEVICE_INFO::product_name, PS2CAM_PROD_EYETOY, PS2CAM_PROD_EYETOY2, PS2CamGetDeviceSring(), PS2CAM_DEVICE_INFO::ssize, PS2CAM_DEVICE_INFO::vendor_id, and PS2CAM_DEVICE_INFO::vendor_name.
int PS2CamSetDeviceBandwidth | ( | int | handle, |
char | bandwidth | ||
) |
before reading you must set the camera's bandwidth
Definition at line 1178 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DISCONNECTED, EYETOY_ALTERNATE_SIZE_0, PS2CAM_RPC_SETDEVBANDWIDTH, PS2CamSelectInterface(), PS2CamSetDeviceBandwidth(), setReg8(), and CAMERA_DEVICE::stream.
Referenced by PS2CamSetDeviceBandwidth().
int PS2CamReadPacket | ( | int | handle | ) |
read some data from the camera based on bandwidth
Definition at line 1254 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DEVNOTREADY, CAM_ERROR_DISCONNECTED, EYETOY_ALTERNATE_SIZE_0, PS2CAM_RPC_READPACKET, and PS2CamReadPacket().
Referenced by PS2CamReadPacket().
int PS2CamSetLEDMode | ( | int | handle, |
int | mode | ||
) |
set the mode for the red led
Definition at line 1308 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DEVNOTREADY, CAM_ERROR_DISCONNECTED, camTurnOffRedLed(), camTurnOnRedLed(), PS2CAM_RPC_SETLEDMODE, and PS2CamSetLEDMode().
Referenced by PS2CamSetLEDMode().
int PS2CamSetDeviceConfig | ( | int | handle, |
void * | config | ||
) |
activate setting that is in config struct
Definition at line 1353 of file ps2cam.c.
References CAM_ERROR_BADHANDLE, CAM_ERROR_DEVNOTREADY, CAM_ERROR_DISCONNECTED, camStartStream(), PS2CAM_DEVICE_CONFIG::framerate, PS2CAM_DEVICE_CONFIG::h_divider, PS2CAM_DEVICE_CONFIG::height, PS2CAM_DEVICE_CONFIG::mask, setReg8(), PS2CAM_DEVICE_CONFIG::v_divider, PS2CAM_DEVICE_CONFIG::width, PS2CAM_DEVICE_CONFIG::x_offset, and PS2CAM_DEVICE_CONFIG::y_offset.
void * rpcCommandHandler | ( | u32 | command, |
void * | buffer, | ||
int | size | ||
) |
sceUsbdLddOps cam_driver |
CAMERA_DEVICE Camera[MAX_CAM_DEVICE] |
PS2CAM_DEVICE_HANDLE CamHandle[MAX_CAM_DEVICE_HANDLE] |