Table of Contents
LCD
The gamepad's LCD is connected to the I2C interface: bus 3, device 0x39.
Initialization
Before displaying anything, the LCD must be initialized with the following sequence.
First, configure the LCD GPIO (at 0xF0005100) as an output, by setting it to 0xC200. Then set it to zero, wait atleast 5 milliseconds, set it to one, wait atleast 15 milliseconds. This sequence seems to prepare the LCD for I2C communication.
Then, to identify the LCD, perform the following I2C transactions, one line being a single transaction:
- Send bytes 0xB0, 0x02.
- Send byte 0xBF; receive 5 bytes.
- Send bytes 0xB0, 0x03.
The first 4 bytes received in the second transaction are the LCD's ID. There are two possible values:
ID | LCD type |
---|---|
0x08922201 | JDI |
0x00000002 | Panasonic |
Any other value would indicate a communication failure.
Note: not sure if any retail gamepads are equipped with the Panasonic LCD. The diagnostics firmware only supports the JDI one.
The second part of the initialization procedure depends on the LCD type.
JDI
- Send bytes 0xB0, 0x02.
- Send bytes 0xBB, 0x08, 0x7A, 0x01, 0x00.
- Send bytes 0xB0, 0x03.
Panasonic
- Send bytes 0x05, 0x00, 0x00, 0x01, 0x7A.
The third and final step is to configure the screen brightness.
Setting the brightness
The gamepad firmware supports 6 brightness levels.
There is a table at address 0x1377 in UIC memory that maps the predefined brightness levels to the correct settings for the LCD. Each two bytes correspond to a brightness level, the first byte is setting A and the second byte is the index for setting B.
The byte right after that table (at address 0x1383) is the brightness level setting.
While setting A is written directly to the LCD, setting B is derived by using a table with 10 entries:
Second byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Setting B | 0x00 | 0x01 | 0x02 | 0x05 | 0x0B | 0x17 | 0x2F | 0x5F | 0xC5 | 0xFF |
The procedure to set the brightness, once again, depends on the LCD type.
First, toggle the LCD GPIO in the same way as during initialization: zero, 5ms wait, one, 15ms wait.
Then, perform the following I2C transactions:
JDI
- Send bytes 0xB0, 0x02.
- Send bytes 0xBB, 0x08, A, B, 0x00.
- Send bytes 0xB0, 0x03.
- Send bytes 0xB0, 0x02.
- Send bytes 0xB8, 0x01, 0x18, 0x01, 0x04, 0x40.
- Send bytes 0xB0, 0x03.
- Send byte C.
Where A is setting A, B is setting B, and C is 0x29 when turning on the backlight, 0x28 when turning it off.
Panasonic
- Send bytes 0x05, 0x00, 0x00, B, A.
- Send bytes 0x0B, 0xAA.
- Send byte C.
Where A is setting A, B is setting B, and C is 0x01 when turning on the backlight, 0x00 when turning it off.
As a last step, send command 0x12 to the UIC to actually toggle the backlight.
The LCD should now be ready to go.