Skip to content

Commit

Permalink
Merge pull request #4 from raleighlittles/feature/add-ps4-camera-support
Browse files Browse the repository at this point in the history
[Feature] add PS4 compatibility
  • Loading branch information
raleighlittles authored Jun 29, 2023
2 parents 001f370 + ba82085 commit 63a8698
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 149 deletions.
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug"]
assignees:
- raleighlittles
body:
- type: textarea
id: what-happened
attributes:
label: Provide a brief description of the issue
description: Also tell us, what did you expect to happen?
placeholder:
value: "Bug description"
validations:
required: true
- type: dropdown
id: os_version
attributes:
label: Operating System version
description: What operating system did you encounter this issue on?
options:
- Linux (Default)
- Mac
validations:
required: true
- type: dropdown
id: camera_version
attributes:
label: Which camera model was this for?
multiple: true
options:
- PlayStation 4
- PlayStation 5
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted, so no need for backticks ('`')
render: shell
145 changes: 86 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

# About

This tool is used to load firmware onto a Playstation 5 camera: https://www.playstation.com/en-us/accessories/hd-camera/
This tool is used to install firmware onto a Playstation 5 camera: <https://www.playstation.com/en-us/accessories/hd-camera/>

![ps5-camera](https://gmedia.playstation.com/is/image/SIEPDC/hd-camera-ps5-image-block-03-en-02jul20?$facebook$)
**Despite the name, it also works on Playstataion <u>4</u> cameras.**

The main reason why you'd want to load custom firmware onto the camera is to be able to use it as a [UVC device](https://en.wikipedia.org/wiki/USB_video_device_class).
The main reason why you'd want to load custom firmware onto the camera is to be able to use it as a [UVC device](https://en.wikipedia.org/wiki/USB_video_device_class), i.e. a webcam.

This is a Linux port of [OrbisEyeCam](https://github.com/psxdev/OrbisEyeCam) for Windows. Kudos to @psxdev for the initial effort of reverse-engineering it.

# Webcam setup

To use this as a webcam, we need to install custom firmware onto the device (the default firmware doesn't use UVC). Download `firmware.bin` from here: https://github.com/Hackinside/PS5_camera_files/blob/main/firmware.bin
To use this as a webcam, we need to install custom firmware onto the device (the default firmware doesn't support UVC).

(Kudos to @Hackinside for the custom firmware)
You can find custom firmware for the Playstation camera on Github, here's a few that I've used:

* <https://github.com/prosperodev/hdcamera/blob/main/firmware/21.01-03.20.00.04-00.00.00.bin>
* <https://github.com/Hackinside/PS5_camera_files/blob/main/firmware.bin>

(Many more firmware versions are available [here](https://github.com/psxdev/luke_firmwares))

## Connect device

Connect your PS5 camera to a USB 3.0 port on your computer.
Connect your PS camera to a USB 3.0 port on your computer. (If you have a PS4 camera, you need to purchase an [AUX to USB adapter](https://www.amazon.com/dp/B09NTM46ND))

Make sure you see the following in the dmesg log:

Expand All @@ -29,40 +34,45 @@ Make sure you see the following in the dmesg log:
usb 2-4.4.4.4: Product: USB Boot
usb 2-4.4.4.4: Manufacturer: OmniVision Technologies, Inc.
```

Keep the dmesg window open, we'll need it for later.

## Setup permissions

[libusb](https://libusb.info/) needs permissions to be able to write to USB devices.

0. Make sure your user is part of the `plugdev` group. Easiest way to do this is to check your `/etc/group` file.
0. Make sure your user is part of the `plugdev` group. Easiest way to do this is to check your `/etc/group` file. If you're not in the plugdev group, run:

```bash
sudo usermod -a -G plugdev $USER
```

1. Copy the udev rules (`100-playstation-camera.rules`) to `/etc/udev/rules.d`

2. Reload the udev rules by running:
2. Reload the udev rules by running:

`$ sudo udevadm control --reload ; sudo udevadm trigger `
`$ sudo udevadm control --reload ; sudo udevadm trigger`

## Run the script

This product has two "back-ends", one written in C++ and one written in Rust. You can use either, but the C++ backend has been tested more thoroughly.
This product has two "back-ends", one written in C++ and one written in Rust. The C++ version is deprecated, but it still works, and going forward, I will only be supporting the Rust version.

To build & run the C++ version:

```bash
$ cmake CMakeLists.txt
$ make
$ ./ps5_camera_firmware_loader <firmware-file-path>
cmake CMakeLists.txt
make
./ps5_camera_firmware_loader <firmware-file-path>
```

To build & run the Rust version:

```bash
$ cargo build --manifest-path=Cargo.toml
$ ./target/debug/ps5_camera_firmware_loader <firmware-file-path>
cargo build --manifest-path=Cargo.toml
./target/debug/ps5_camera_firmware_loader <firmware-file-path>
```

## Success :heavy_check_mark:
## Success :heavy_check_mark

Go back to the dmesg window from earlier. You should see the following line:

Expand All @@ -72,55 +82,72 @@ uvcvideo: Found UVC 1.00 device USB Camera-OV580 (05a9:058c)

Open your favorite webcam program and now you're all set. Note that you must **reinstall the firmware every time the device power cycles**.

Here's a test image:
Here's a test image from the PS5 camera:

![test-image](./ps5-camera-test-image.jpg)

If you're using the firmware that I linked to above, then these are the formats it supports:
If you're using the firmware that I linked to above, then these are the formats and parameters it supports:

```
User Controls
brightness 0x00980900 (int) : min=0 max=8 step=1 default=4 value=4
contrast 0x00980901 (int) : min=0 max=8 step=1 default=4 value=4
saturation 0x00980902 (int) : min=0 max=8 step=1 default=4 value=4
hue 0x00980903 (int) : min=0 max=11 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gain 0x00980913 (int) : min=0 max=8 step=1 default=4 value=4
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1 (50 Hz)
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=100 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=8 step=1 default=4 value=4
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=2 value=2 (Shutter Priority Mode)
exposure_time_absolute 0x009a0902 (int) : min=1 max=5000 step=1 default=1000 value=1000 flags=inactive
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 896x256
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 960x520
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 448x256
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 1280x800
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 640x376
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 320x184
Interval: Discrete 0.004s (240.004 fps)
Size: Discrete 5148x1088
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 3840x1080
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 1920x520
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 2560x800
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 1280x376
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 640x184
Interval: Discrete 0.004s (240.004 fps)
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 896x256
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 960x520
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 448x256
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 1280x800
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 640x376
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 320x184
Interval: Discrete 0.004s (240.004 fps)
Size: Discrete 5148x1088
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 3840x1080
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 1920x520
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 2560x800
Interval: Discrete 0.017s (60.000 fps)
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.125s (8.000 fps)
Size: Discrete 1280x376
Interval: Discrete 0.008s (120.000 fps)
Size: Discrete 640x184
Interval: Discrete 0.004s (240.004 fps)
```

# Troubleshooting
Expand Down
135 changes: 135 additions & 0 deletions cpp/log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
Transferred 512 bytes [0,512], value=0, index=20, size=512
Transferred 512 bytes [512,1024], value=512, index=20, size=512
Transferred 512 bytes [1024,1536], value=1024, index=20, size=512
Transferred 512 bytes [1536,2048], value=1536, index=20, size=512
Transferred 512 bytes [2048,2560], value=2048, index=20, size=512
Transferred 512 bytes [2560,3072], value=2560, index=20, size=512
Transferred 512 bytes [3072,3584], value=3072, index=20, size=512
Transferred 512 bytes [3584,4096], value=3584, index=20, size=512
Transferred 512 bytes [4096,4608], value=4096, index=20, size=512
Transferred 512 bytes [4608,5120], value=4608, index=20, size=512
Transferred 512 bytes [5120,5632], value=5120, index=20, size=512
Transferred 512 bytes [5632,6144], value=5632, index=20, size=512
Transferred 512 bytes [6144,6656], value=6144, index=20, size=512
Transferred 512 bytes [6656,7168], value=6656, index=20, size=512
Transferred 512 bytes [7168,7680], value=7168, index=20, size=512
Transferred 512 bytes [7680,8192], value=7680, index=20, size=512
Transferred 512 bytes [8192,8704], value=8192, index=20, size=512
Transferred 512 bytes [8704,9216], value=8704, index=20, size=512
Transferred 512 bytes [9216,9728], value=9216, index=20, size=512
Transferred 512 bytes [9728,10240], value=9728, index=20, size=512
Transferred 512 bytes [10240,10752], value=10240, index=20, size=512
Transferred 512 bytes [10752,11264], value=10752, index=20, size=512
Transferred 512 bytes [11264,11776], value=11264, index=20, size=512
Transferred 512 bytes [11776,12288], value=11776, index=20, size=512
Transferred 512 bytes [12288,12800], value=12288, index=20, size=512
Transferred 512 bytes [12800,13312], value=12800, index=20, size=512
Transferred 512 bytes [13312,13824], value=13312, index=20, size=512
Transferred 512 bytes [13824,14336], value=13824, index=20, size=512
Transferred 512 bytes [14336,14848], value=14336, index=20, size=512
Transferred 512 bytes [14848,15360], value=14848, index=20, size=512
Transferred 512 bytes [15360,15872], value=15360, index=20, size=512
Transferred 512 bytes [15872,16384], value=15872, index=20, size=512
Transferred 512 bytes [16384,16896], value=16384, index=20, size=512
Transferred 512 bytes [16896,17408], value=16896, index=20, size=512
Transferred 512 bytes [17408,17920], value=17408, index=20, size=512
Transferred 512 bytes [17920,18432], value=17920, index=20, size=512
Transferred 512 bytes [18432,18944], value=18432, index=20, size=512
Transferred 512 bytes [18944,19456], value=18944, index=20, size=512
Transferred 512 bytes [19456,19968], value=19456, index=20, size=512
Transferred 512 bytes [19968,20480], value=19968, index=20, size=512
Transferred 512 bytes [20480,20992], value=20480, index=20, size=512
Transferred 512 bytes [20992,21504], value=20992, index=20, size=512
Transferred 512 bytes [21504,22016], value=21504, index=20, size=512
Transferred 512 bytes [22016,22528], value=22016, index=20, size=512
Transferred 512 bytes [22528,23040], value=22528, index=20, size=512
Transferred 512 bytes [23040,23552], value=23040, index=20, size=512
Transferred 512 bytes [23552,24064], value=23552, index=20, size=512
Transferred 512 bytes [24064,24576], value=24064, index=20, size=512
Transferred 512 bytes [24576,25088], value=24576, index=20, size=512
Transferred 512 bytes [25088,25600], value=25088, index=20, size=512
Transferred 512 bytes [25600,26112], value=25600, index=20, size=512
Transferred 512 bytes [26112,26624], value=26112, index=20, size=512
Transferred 512 bytes [26624,27136], value=26624, index=20, size=512
Transferred 512 bytes [27136,27648], value=27136, index=20, size=512
Transferred 512 bytes [27648,28160], value=27648, index=20, size=512
Transferred 512 bytes [28160,28672], value=28160, index=20, size=512
Transferred 512 bytes [28672,29184], value=28672, index=20, size=512
Transferred 512 bytes [29184,29696], value=29184, index=20, size=512
Transferred 512 bytes [29696,30208], value=29696, index=20, size=512
Transferred 512 bytes [30208,30720], value=30208, index=20, size=512
Transferred 512 bytes [30720,31232], value=30720, index=20, size=512
Transferred 512 bytes [31232,31744], value=31232, index=20, size=512
Transferred 512 bytes [31744,32256], value=31744, index=20, size=512
Transferred 512 bytes [32256,32768], value=32256, index=20, size=512
Transferred 512 bytes [32768,33280], value=32768, index=20, size=512
Transferred 512 bytes [33280,33792], value=33280, index=20, size=512
Transferred 512 bytes [33792,34304], value=33792, index=20, size=512
Transferred 512 bytes [34304,34816], value=34304, index=20, size=512
Transferred 512 bytes [34816,35328], value=34816, index=20, size=512
Transferred 512 bytes [35328,35840], value=35328, index=20, size=512
Transferred 512 bytes [35840,36352], value=35840, index=20, size=512
Transferred 512 bytes [36352,36864], value=36352, index=20, size=512
Transferred 512 bytes [36864,37376], value=36864, index=20, size=512
Transferred 512 bytes [37376,37888], value=37376, index=20, size=512
Transferred 512 bytes [37888,38400], value=37888, index=20, size=512
Transferred 512 bytes [38400,38912], value=38400, index=20, size=512
Transferred 512 bytes [38912,39424], value=38912, index=20, size=512
Transferred 512 bytes [39424,39936], value=39424, index=20, size=512
Transferred 512 bytes [39936,40448], value=39936, index=20, size=512
Transferred 512 bytes [40448,40960], value=40448, index=20, size=512
Transferred 512 bytes [40960,41472], value=40960, index=20, size=512
Transferred 512 bytes [41472,41984], value=41472, index=20, size=512
Transferred 512 bytes [41984,42496], value=41984, index=20, size=512
Transferred 512 bytes [42496,43008], value=42496, index=20, size=512
Transferred 512 bytes [43008,43520], value=43008, index=20, size=512
Transferred 512 bytes [43520,44032], value=43520, index=20, size=512
Transferred 512 bytes [44032,44544], value=44032, index=20, size=512
Transferred 512 bytes [44544,45056], value=44544, index=20, size=512
Transferred 512 bytes [45056,45568], value=45056, index=20, size=512
Transferred 512 bytes [45568,46080], value=45568, index=20, size=512
Transferred 512 bytes [46080,46592], value=46080, index=20, size=512
Transferred 512 bytes [46592,47104], value=46592, index=20, size=512
Transferred 512 bytes [47104,47616], value=47104, index=20, size=512
Transferred 512 bytes [47616,48128], value=47616, index=20, size=512
Transferred 512 bytes [48128,48640], value=48128, index=20, size=512
Transferred 512 bytes [48640,49152], value=48640, index=20, size=512
Transferred 512 bytes [49152,49664], value=49152, index=20, size=512
Transferred 512 bytes [49664,50176], value=49664, index=20, size=512
Transferred 512 bytes [50176,50688], value=50176, index=20, size=512
Transferred 512 bytes [50688,51200], value=50688, index=20, size=512
Transferred 512 bytes [51200,51712], value=51200, index=20, size=512
Transferred 512 bytes [51712,52224], value=51712, index=20, size=512
Transferred 512 bytes [52224,52736], value=52224, index=20, size=512
Transferred 512 bytes [52736,53248], value=52736, index=20, size=512
Transferred 512 bytes [53248,53760], value=53248, index=20, size=512
Transferred 512 bytes [53760,54272], value=53760, index=20, size=512
Transferred 512 bytes [54272,54784], value=54272, index=20, size=512
Transferred 512 bytes [54784,55296], value=54784, index=20, size=512
Transferred 512 bytes [55296,55808], value=55296, index=20, size=512
Transferred 512 bytes [55808,56320], value=55808, index=20, size=512
Transferred 512 bytes [56320,56832], value=56320, index=20, size=512
Transferred 512 bytes [56832,57344], value=56832, index=20, size=512
Transferred 512 bytes [57344,57856], value=57344, index=20, size=512
Transferred 512 bytes [57856,58368], value=57856, index=20, size=512
Transferred 512 bytes [58368,58880], value=58368, index=20, size=512
Transferred 512 bytes [58880,59392], value=58880, index=20, size=512
Transferred 512 bytes [59392,59904], value=59392, index=20, size=512
Transferred 512 bytes [59904,60416], value=59904, index=20, size=512
Transferred 512 bytes [60416,60928], value=60416, index=20, size=512
Transferred 512 bytes [60928,61440], value=60928, index=20, size=512
Transferred 512 bytes [61440,61952], value=61440, index=20, size=512
Transferred 512 bytes [61952,62464], value=61952, index=20, size=512
Transferred 512 bytes [62464,62976], value=62464, index=20, size=512
Transferred 512 bytes [62976,63488], value=62976, index=20, size=512
Transferred 512 bytes [63488,64000], value=63488, index=20, size=512
Transferred 512 bytes [64000,64512], value=64000, index=20, size=512
Transferred 512 bytes [64512,65024], value=64512, index=20, size=512
Transferred 512 bytes [65024,65536], value=65024, index=20, size=512
Transferred 512 bytes [65536,66048], value=0, index=21, size=512
Transferred 512 bytes [66048,66560], value=512, index=21, size=512
Transferred 512 bytes [66560,67072], value=1024, index=21, size=512
Transferred 512 bytes [67072,67584], value=1536, index=21, size=512
Transferred 512 bytes [67584,68096], value=2048, index=21, size=512
Transferred 512 bytes [68096,68608], value=2560, index=21, size=512
Transferred 340 bytes [68608,68948], value=3072, index=21, size=340
Loading

0 comments on commit 63a8698

Please sign in to comment.