mirror of
https://gitlab.com/zephray/glider.git
synced 2024-12-22 13:43:16 +00:00
Initial fw support for lite version
This commit is contained in:
parent
cde330abc4
commit
0420623c76
8 changed files with 303 additions and 75 deletions
|
@ -7,11 +7,15 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# initalize pico_sdk from installed location
|
# initalize pico_sdk from installed location
|
||||||
# (note this can come from environment, CMake cache etc)
|
# (note this can come from environment, CMake cache etc)
|
||||||
set(PICO_SDK_PATH "/Users/wenting/pico/pico-sdk")
|
set(PICO_SDK_PATH "/home/wenting/pico/pico-sdk")
|
||||||
|
set(PICO_EXTRAS_PATH "/home/wenting/pico/pico-extras")
|
||||||
|
|
||||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
include(pico_sdk_import.cmake)
|
include(pico_sdk_import.cmake)
|
||||||
|
|
||||||
|
# We also need PICO EXTRAS
|
||||||
|
include(pico_extras_import.cmake)
|
||||||
|
|
||||||
project(fw C CXX ASM)
|
project(fw C CXX ASM)
|
||||||
|
|
||||||
# Initialise the Raspberry Pi Pico SDK
|
# Initialise the Raspberry Pi Pico SDK
|
||||||
|
@ -20,19 +24,20 @@ pico_sdk_init()
|
||||||
# Add executable. Default name is the project name, version 0.1
|
# Add executable. Default name is the project name, version 0.1
|
||||||
|
|
||||||
add_executable(fw
|
add_executable(fw
|
||||||
fw.c
|
bitstream.c
|
||||||
utils.c
|
edid.c
|
||||||
|
fpga.c
|
||||||
fusb302.c
|
fusb302.c
|
||||||
|
fw.c
|
||||||
|
max17135.c
|
||||||
power.c
|
power.c
|
||||||
ptn3460.c
|
ptn3460.c
|
||||||
tcpm_driver.c
|
tcpm_driver.c
|
||||||
tps65185.c
|
tps65185.c
|
||||||
max17135.c
|
|
||||||
bitstream.c
|
|
||||||
fpga.c
|
|
||||||
usb_pd_driver.c
|
usb_pd_driver.c
|
||||||
usb_pd_policy.c
|
usb_pd_policy.c
|
||||||
usb_pd_protocol.c
|
usb_pd_protocol.c
|
||||||
|
utils.c
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_set_program_name(fw "fw")
|
pico_set_program_name(fw "fw")
|
||||||
|
@ -42,7 +47,7 @@ pico_enable_stdio_uart(fw 0)
|
||||||
pico_enable_stdio_usb(fw 1)
|
pico_enable_stdio_usb(fw 1)
|
||||||
|
|
||||||
# Add the standard library to the build
|
# Add the standard library to the build
|
||||||
target_link_libraries(fw pico_stdlib)
|
target_link_libraries(fw pico_stdlib hardware_sleep)
|
||||||
|
|
||||||
# Add any user requested libraries
|
# Add any user requested libraries
|
||||||
target_link_libraries(fw
|
target_link_libraries(fw
|
||||||
|
@ -50,6 +55,8 @@ target_link_libraries(fw
|
||||||
hardware_dma
|
hardware_dma
|
||||||
hardware_i2c
|
hardware_i2c
|
||||||
hardware_pwm
|
hardware_pwm
|
||||||
|
pico_unique_id
|
||||||
|
pico_i2c_slave
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_add_extra_outputs(fw)
|
pico_add_extra_outputs(fw)
|
||||||
|
|
35
fw/config.h
35
fw/config.h
|
@ -24,7 +24,9 @@
|
||||||
/* BOARD REVISION CONFIGURATION */
|
/* BOARD REVISION CONFIGURATION */
|
||||||
// Eariler revisions are not supported
|
// Eariler revisions are not supported
|
||||||
//#define BOARD_REV_R0P5
|
//#define BOARD_REV_R0P5
|
||||||
#define BOARD_REV_R0P6
|
//#define BOARD_REV_R0P6
|
||||||
|
// Lite version uses DVI instead of Type-C DP Alt-mode
|
||||||
|
#define BOARD_REV_RL0P1
|
||||||
|
|
||||||
/* SCREEN CONFIGURATION */
|
/* SCREEN CONFIGURATION */
|
||||||
|
|
||||||
|
@ -49,8 +51,15 @@
|
||||||
/* SET BASED ON PREVIOUS DEFINES, DO NOT MODIFY */
|
/* SET BASED ON PREVIOUS DEFINES, DO NOT MODIFY */
|
||||||
#if defined(BOARD_REV_R0P5)
|
#if defined(BOARD_REV_R0P5)
|
||||||
#define POWER_TPS65185
|
#define POWER_TPS65185
|
||||||
|
#define INPUT_TYPEC
|
||||||
#elif defined(BOARD_REV_R0P6)
|
#elif defined(BOARD_REV_R0P6)
|
||||||
#define POWER_GPIO
|
#define POWER_GPIO
|
||||||
|
// VCOM measurement is not supported
|
||||||
|
#define INPUT_TYPEC
|
||||||
|
#elif defined(BOARD_REV_RL0P1)
|
||||||
|
#define POWER_GPIO
|
||||||
|
#define POWER_GPIO_VCOM_MEASURE
|
||||||
|
#define INPUT_DVI
|
||||||
#else
|
#else
|
||||||
#error "Unknown board revision"
|
#error "Unknown board revision"
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,15 +131,25 @@
|
||||||
#define SCREEN_VSYNC 10
|
#define SCREEN_VSYNC 10
|
||||||
#elif defined(SCREEN_1600_1200)
|
#elif defined(SCREEN_1600_1200)
|
||||||
// 1600x1200 @ 60, 162MHz DMT
|
// 1600x1200 @ 60, 162MHz DMT
|
||||||
#define SCREEN_CLK 162000
|
// #define SCREEN_CLK 162000
|
||||||
|
// #define SCREEN_HACT 1600
|
||||||
|
// #define SCREEN_VACT 1200
|
||||||
|
// #define SCREEN_HBLK 560
|
||||||
|
// #define SCREEN_HFP 64
|
||||||
|
// #define SCREEN_HSYNC 192
|
||||||
|
// #define SCREEN_VBLK 50
|
||||||
|
// #define SCREEN_VFP 1
|
||||||
|
// #define SCREEN_VSYNC 3
|
||||||
|
// 1600x1200 @ 60, 124.488MHz CVT-RB-v2
|
||||||
|
#define SCREEN_CLK 124488
|
||||||
#define SCREEN_HACT 1600
|
#define SCREEN_HACT 1600
|
||||||
#define SCREEN_VACT 1200
|
#define SCREEN_VACT 1200
|
||||||
#define SCREEN_HBLK 560
|
#define SCREEN_HBLK 80
|
||||||
#define SCREEN_HFP 64
|
#define SCREEN_HFP 8
|
||||||
#define SCREEN_HSYNC 192
|
#define SCREEN_HSYNC 32
|
||||||
#define SCREEN_VBLK 50
|
#define SCREEN_VBLK 35
|
||||||
#define SCREEN_VFP 1
|
#define SCREEN_VFP 21
|
||||||
#define SCREEN_VSYNC 3
|
#define SCREEN_VSYNC 8
|
||||||
#elif defined(SCREEN_1872_1404)
|
#elif defined(SCREEN_1872_1404)
|
||||||
// 1872x1404 @ 60, 162MHz Custom
|
// 1872x1404 @ 60, 162MHz Custom
|
||||||
#define SCREEN_CLK 162000
|
#define SCREEN_CLK 162000
|
||||||
|
|
151
fw/edid.c
Normal file
151
fw/edid.c
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
//
|
||||||
|
// Copyright 2022 Wenting Zhang <zephray@outlook.com>
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <pico/stdlib.h>
|
||||||
|
#include <hardware/i2c.h>
|
||||||
|
#include <pico/unique_id.h>
|
||||||
|
#include <pico/i2c_slave.h>
|
||||||
|
#include "edid.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef INPUT_DVI
|
||||||
|
#define EDID_I2C_ADDRESS (0x50)
|
||||||
|
#define EDID_I2C (i2c0)
|
||||||
|
#define EDID_I2C_SDA (0)
|
||||||
|
#define EDID_I2C_SCL (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static char edid[129] = {
|
||||||
|
0x00, // register number, not part of EDID
|
||||||
|
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, // fixed header (0-7)
|
||||||
|
0x6a, 0x12, // manufacturer ID (8-9)
|
||||||
|
0x01, 0x00, // product code (10-11)
|
||||||
|
0x42, 0x4b, 0x1d, 0x00, // serial number (12-15)
|
||||||
|
0x01, // week of manufacture (16)
|
||||||
|
0x20, // year of manufacture (17)
|
||||||
|
0x01, // EDID version (18)
|
||||||
|
0x03, // EDID revision (19)
|
||||||
|
0x85, // display parameter (20)
|
||||||
|
(SCREEN_SIZE_X / 10), // horizontal screen size in cm (21)
|
||||||
|
(SCREEN_SIZE_Y / 10), // vertical screen size in cm (22)
|
||||||
|
0x78, // display gamma (23)
|
||||||
|
0x06, // supported feature (24)
|
||||||
|
0xee, 0x95, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54, // chromatic (25-34)
|
||||||
|
0x00, 0x00, 0x00, // established timing (35-37)
|
||||||
|
(SCREEN_HACT / 8 - 31), // X resolution (38)
|
||||||
|
SCREEN_ASPECT, // aspect ratio and vertical frequency (39)
|
||||||
|
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // standard timing
|
||||||
|
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // standard timing continued
|
||||||
|
// descriptor 1 (54-71)
|
||||||
|
((SCREEN_CLK / 10) & 0xff), ((SCREEN_CLK / 10) >> 8), // pixel clock in 10kHz
|
||||||
|
(SCREEN_HACT & 0xff), // HACT LSB
|
||||||
|
(SCREEN_HBLK & 0xff), // VBLK LSB
|
||||||
|
(((SCREEN_HACT >> 8) << 4) | (SCREEN_HBLK >> 8)), // HACT MSB | HBLK MSB
|
||||||
|
(SCREEN_VACT & 0xff), // VACT LSB
|
||||||
|
(SCREEN_VBLK & 0xff), // VBLK LSB
|
||||||
|
(((SCREEN_VACT >> 8) << 4) | (SCREEN_VBLK >> 8)), // VACT MSB | VBLK MSB
|
||||||
|
(SCREEN_HFP & 0xff), // HFP LSB
|
||||||
|
(SCREEN_HSYNC & 0xff), // HSYNC LSB
|
||||||
|
(((SCREEN_VFP & 0xf) << 4) | (SCREEN_VSYNC & 0xf)), // VFP LSB | VSYNC LSB
|
||||||
|
(((SCREEN_HFP >> 8) << 6) | ((SCREEN_HSYNC >> 8) << 4) |
|
||||||
|
((SCREEN_VFP >> 4) << 2) | (SCREEN_VSYNC >> 4)), // HFP MSB | HSYNC MSB | VFP MSB | VSYNC MSB
|
||||||
|
(SCREEN_SIZE_X & 0xff), // Horizontal size in mm LSB
|
||||||
|
(SCREEN_SIZE_Y & 0xff), // Vertical size in mm LSB
|
||||||
|
(((SCREEN_SIZE_X >> 8) << 4) | (SCREEN_SIZE_Y >> 8)), // HSIZE MSB | VSIZE LSB
|
||||||
|
0x00, // Horizontal border pixels
|
||||||
|
0x00, // Vertical border lines 0x1e,
|
||||||
|
// descriptor 2 (72-89) display name
|
||||||
|
0x00, 0x00, 0x00, 0xfc, 0x00, 0x50, 0x61, 0x70, 0x65, 0x72, 0x20,
|
||||||
|
0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72,
|
||||||
|
// descriptor 3 (90-107) display name
|
||||||
|
0x00, 0x00, 0x00, 0xfc, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
// descriptor 4 (108-125) dummy
|
||||||
|
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, // number of extensions (126)
|
||||||
|
0x00 // checksum (127)
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef INPUT_DVI
|
||||||
|
static void edid_i2c_slave_handler(i2c_inst_t *i2c, i2c_slave_event_t event) {
|
||||||
|
static uint8_t addr = 0;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case I2C_SLAVE_RECEIVE:
|
||||||
|
// I2C master has written some data
|
||||||
|
// EDID is read only, all write are treated as address
|
||||||
|
addr = i2c_read_byte_raw(i2c);
|
||||||
|
break;
|
||||||
|
case I2C_SLAVE_REQUEST:
|
||||||
|
// I2C master is requesting data
|
||||||
|
i2c_write_byte_raw(i2c, edid[addr + 1]);
|
||||||
|
addr++;
|
||||||
|
if (addr == 128)
|
||||||
|
addr = 0; // wrap around
|
||||||
|
break;
|
||||||
|
case I2C_SLAVE_FINISH:
|
||||||
|
// I2C master sent stop
|
||||||
|
// Reset transaction if needed
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void edid_init() {
|
||||||
|
// Fill in runtime info
|
||||||
|
pico_unique_board_id_t board_id;
|
||||||
|
pico_get_unique_board_id(&board_id);
|
||||||
|
// Populate serial number with this ID (XORed down to 4 bytes)
|
||||||
|
edid[13] = board_id.id[0] ^ board_id.id[4];
|
||||||
|
edid[14] = board_id.id[1] ^ board_id.id[5];
|
||||||
|
edid[15] = board_id.id[2] ^ board_id.id[6];
|
||||||
|
edid[16] = board_id.id[3] ^ board_id.id[7];
|
||||||
|
|
||||||
|
// Fix checksum in EDID
|
||||||
|
uint8_t checksum = 0;
|
||||||
|
for (int i = 1; i < 128; i++) {
|
||||||
|
checksum += edid[i];
|
||||||
|
}
|
||||||
|
checksum = ~checksum + 1;
|
||||||
|
edid[128] = checksum;
|
||||||
|
|
||||||
|
#ifdef INPUT_DVI
|
||||||
|
// DVI models has DDC I2C connected directly to the RP2040
|
||||||
|
// EDID ROM emulation is needed
|
||||||
|
|
||||||
|
gpio_init(EDID_I2C_SDA);
|
||||||
|
gpio_init(EDID_I2C_SCL);
|
||||||
|
|
||||||
|
gpio_set_function(EDID_I2C_SDA, GPIO_FUNC_I2C);
|
||||||
|
gpio_set_function(EDID_I2C_SCL, GPIO_FUNC_I2C);
|
||||||
|
|
||||||
|
i2c_slave_init(EDID_I2C, EDID_I2C_ADDRESS, &edid_i2c_slave_handler);
|
||||||
|
|
||||||
|
// Pull HPD high so host can read the EDID
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *edid_get_raw() {
|
||||||
|
return edid;
|
||||||
|
}
|
76
fw/edid.h
76
fw/edid.h
|
@ -1,53 +1,25 @@
|
||||||
#include "config.h"
|
//
|
||||||
|
// Copyright 2022 Wenting Zhang <zephray@outlook.com>
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
char edid[129] = {
|
void edid_init();
|
||||||
0x00, // register number, not part of EDID
|
uint8_t *edid_get_raw();
|
||||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, // fixed header (0-7)
|
|
||||||
0x6a, 0x12, // manufacturer ID (8-9)
|
|
||||||
0x01, 0x00, // product code (10-11)
|
|
||||||
0x42, 0x4b, 0x1d, 0x00, // serial number (12-15)
|
|
||||||
0x01, // week of manufacture (16)
|
|
||||||
0x20, // year of manufacture (17)
|
|
||||||
0x01, // EDID version (18)
|
|
||||||
0x03, // EDID revision (19)
|
|
||||||
0x85, // display parameter (20)
|
|
||||||
(SCREEN_SIZE_X / 10), // horizontal screen size in cm (21)
|
|
||||||
(SCREEN_SIZE_Y / 10), // vertical screen size in cm (22)
|
|
||||||
0x78, // display gamma (23)
|
|
||||||
0x06, // supported feature (24)
|
|
||||||
0xee, 0x95, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54, // chromatic (25-34)
|
|
||||||
0x00, 0x00, 0x00, // established timing (35-37)
|
|
||||||
(SCREEN_HACT / 8 - 31), // X resolution (38)
|
|
||||||
SCREEN_ASPECT, // aspect ratio and vertical frequency (39)
|
|
||||||
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // standard timing
|
|
||||||
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // standard timing continued
|
|
||||||
// descriptor 1 (54-71)
|
|
||||||
((SCREEN_CLK / 10) & 0xff), ((SCREEN_CLK / 10) >> 8), // pixel clock in 10kHz
|
|
||||||
(SCREEN_HACT & 0xff), // HACT LSB
|
|
||||||
(SCREEN_HBLK & 0xff), // VBLK LSB
|
|
||||||
(((SCREEN_HACT >> 8) << 4) | (SCREEN_HBLK >> 8)), // HACT MSB | HBLK MSB
|
|
||||||
(SCREEN_VACT & 0xff), // VACT LSB
|
|
||||||
(SCREEN_VBLK & 0xff), // VBLK LSB
|
|
||||||
(((SCREEN_VACT >> 8) << 4) | (SCREEN_VBLK >> 8)), // VACT MSB | VBLK MSB
|
|
||||||
(SCREEN_HFP & 0xff), // HFP LSB
|
|
||||||
(SCREEN_HSYNC & 0xff), // HSYNC LSB
|
|
||||||
(((SCREEN_VFP & 0xf) << 4) | (SCREEN_VSYNC & 0xf)), // VFP LSB | VSYNC LSB
|
|
||||||
(((SCREEN_HFP >> 8) << 6) | ((SCREEN_HSYNC >> 8) << 4) |
|
|
||||||
((SCREEN_VFP >> 4) << 2) | (SCREEN_VSYNC >> 4)), // HFP MSB | HSYNC MSB | VFP MSB | VSYNC MSB
|
|
||||||
(SCREEN_SIZE_X & 0xff), // Horizontal size in mm LSB
|
|
||||||
(SCREEN_SIZE_Y & 0xff), // Vertical size in mm LSB
|
|
||||||
(((SCREEN_SIZE_X >> 8) << 4) | (SCREEN_SIZE_Y >> 8)), // HSIZE MSB | VSIZE LSB
|
|
||||||
0x00, // Horizontal border pixels
|
|
||||||
0x00, // Vertical border lines 0x1e,
|
|
||||||
// descriptor 2 (72-89) display name
|
|
||||||
0x00, 0x00, 0x00, 0xfc, 0x00, 0x50, 0x61, 0x70, 0x65, 0x72, 0x20,
|
|
||||||
0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72,
|
|
||||||
// descriptor 3 (90-107) display name
|
|
||||||
0x00, 0x00, 0x00, 0xfc, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
|
||||||
// descriptor 4 (108-125) dummy
|
|
||||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, // number of extensions (126)
|
|
||||||
0x00 // checksum (127)
|
|
||||||
};
|
|
||||||
|
|
17
fw/fw.c
17
fw/fw.c
|
@ -22,6 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "pico/binary_info.h"
|
#include "pico/binary_info.h"
|
||||||
|
#include "pico/sleep.h"
|
||||||
#include "hardware/i2c.h"
|
#include "hardware/i2c.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
#include "ptn3460.h"
|
#include "ptn3460.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "fpga.h"
|
#include "fpga.h"
|
||||||
|
#include "edid.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -40,6 +42,20 @@ int main()
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Glider\n");
|
printf("Glider\n");
|
||||||
|
|
||||||
|
// TODO: Unify both input options
|
||||||
|
#if defined(INPUT_DVI)
|
||||||
|
power_init();
|
||||||
|
edid_init();
|
||||||
|
power_enable(true);
|
||||||
|
|
||||||
|
//sleep_run_from_xosc();
|
||||||
|
//sleep_goto_dormant_until_edge_high(8);
|
||||||
|
// https://ghubcoder.github.io/posts/awaking-the-pico/
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
#elif defined(INPUT_TYPEC)
|
||||||
int result = tcpm_init(0);
|
int result = tcpm_init(0);
|
||||||
if (result)
|
if (result)
|
||||||
fatal("Failed to initialize TCPC\n");
|
fatal("Failed to initialize TCPC\n");
|
||||||
|
@ -78,6 +94,7 @@ int main()
|
||||||
printf(dp_valid ? "Input is valid\n" : "Input is invalid\n");
|
printf(dp_valid ? "Input is valid\n" : "Input is invalid\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
62
fw/pico_extras_import.cmake
Normal file
62
fw/pico_extras_import.cmake
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
# This is a copy of <PICO_EXTRAS_PATH>/external/pico_extras_import.cmake
|
||||||
|
|
||||||
|
# This can be dropped into an external project to help locate pico-extras
|
||||||
|
# It should be include()ed prior to project()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_EXTRAS_PATH} AND (NOT PICO_EXTRAS_PATH))
|
||||||
|
set(PICO_EXTRAS_PATH $ENV{PICO_EXTRAS_PATH})
|
||||||
|
message("Using PICO_EXTRAS_PATH from environment ('${PICO_EXTRAS_PATH}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT))
|
||||||
|
set(PICO_EXTRAS_FETCH_FROM_GIT $ENV{PICO_EXTRAS_FETCH_FROM_GIT})
|
||||||
|
message("Using PICO_EXTRAS_FETCH_FROM_GIT from environment ('${PICO_EXTRAS_FETCH_FROM_GIT}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT_PATH))
|
||||||
|
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH $ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH})
|
||||||
|
message("Using PICO_EXTRAS_FETCH_FROM_GIT_PATH from environment ('${PICO_EXTRAS_FETCH_FROM_GIT_PATH}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT PICO_EXTRAS_PATH)
|
||||||
|
if (PICO_EXTRAS_FETCH_FROM_GIT)
|
||||||
|
include(FetchContent)
|
||||||
|
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
|
||||||
|
if (PICO_EXTRAS_FETCH_FROM_GIT_PATH)
|
||||||
|
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
|
endif ()
|
||||||
|
FetchContent_Declare(
|
||||||
|
PICO_EXTRAS
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-extras
|
||||||
|
GIT_TAG master
|
||||||
|
)
|
||||||
|
if (NOT PICO_EXTRAS)
|
||||||
|
message("Downloading PICO EXTRAS")
|
||||||
|
FetchContent_Populate(PICO_EXTRAS)
|
||||||
|
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR})
|
||||||
|
endif ()
|
||||||
|
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||||
|
else ()
|
||||||
|
if (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../pico-extras")
|
||||||
|
set(PICO_EXTRAS_PATH ${PICO_SDK_PATH}/../pico-extras)
|
||||||
|
message("Defaulting PICO_EXTRAS_PATH as sibling of PICO_SDK_PATH: ${PICO_EXTRAS_PATH}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"PICO EXTRAS location was not specified. Please set PICO_EXTRAS_PATH or set PICO_EXTRAS_FETCH_FROM_GIT to on to fetch from git."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to the PICO EXTRAS")
|
||||||
|
set(PICO_EXTRAS_FETCH_FROM_GIT "${PICO_EXTRAS_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO EXTRAS from git if not otherwise locatable")
|
||||||
|
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download EXTRAS")
|
||||||
|
|
||||||
|
get_filename_component(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||||
|
if (NOT EXISTS ${PICO_EXTRAS_PATH})
|
||||||
|
message(FATAL_ERROR "Directory '${PICO_EXTRAS_PATH}' not found")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE)
|
||||||
|
|
||||||
|
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)
|
14
fw/ptn3460.c
14
fw/ptn3460.c
|
@ -20,12 +20,15 @@
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
//
|
//
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "hardware/i2c.h"
|
#include "hardware/i2c.h"
|
||||||
#include "ptn3460.h"
|
#include "ptn3460.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "edid.h"
|
#include "edid.h"
|
||||||
|
|
||||||
|
#ifdef INPUT_TYPEC
|
||||||
|
|
||||||
#define PTN3460_I2C_ADDRESS (0x60)
|
#define PTN3460_I2C_ADDRESS (0x60)
|
||||||
#define PTN3460_I2C (i2c0)
|
#define PTN3460_I2C (i2c0)
|
||||||
#define PTN3460_HPD_PIN (8)
|
#define PTN3460_HPD_PIN (8)
|
||||||
|
@ -46,13 +49,6 @@ void ptn3460_select_edid_emulation(uint8_t id) {
|
||||||
|
|
||||||
void ptn3460_load_edid(uint8_t *edid) {
|
void ptn3460_load_edid(uint8_t *edid) {
|
||||||
int result;
|
int result;
|
||||||
// Fix checksum in EDID
|
|
||||||
uint8_t checksum = 0;
|
|
||||||
for (int i = 1; i < 128; i++) {
|
|
||||||
checksum += edid[i];
|
|
||||||
}
|
|
||||||
checksum = ~checksum + 1;
|
|
||||||
edid[128] = checksum;
|
|
||||||
|
|
||||||
result = i2c_write_blocking(PTN3460_I2C, PTN3460_I2C_ADDRESS,
|
result = i2c_write_blocking(PTN3460_I2C, PTN3460_I2C_ADDRESS,
|
||||||
edid, 129, false);
|
edid, 129, false);
|
||||||
|
@ -96,7 +92,7 @@ void ptn3460_init(void) {
|
||||||
printf("PTN3460 up after %d ms\n", ticks);
|
printf("PTN3460 up after %d ms\n", ticks);
|
||||||
// Enable EDID emulation
|
// Enable EDID emulation
|
||||||
ptn3460_select_edid_emulation(0);
|
ptn3460_select_edid_emulation(0);
|
||||||
ptn3460_load_edid(edid);
|
ptn3460_load_edid(edid_get_raw());
|
||||||
|
|
||||||
//ptn3460_write(0x80, 0x02); // Set AUX reverse
|
//ptn3460_write(0x80, 0x02); // Set AUX reverse
|
||||||
ptn3460_write(0x81, 0x29); // 18bpp, clock on odd bus, dual channel
|
ptn3460_write(0x81, 0x29); // 18bpp, clock on odd bus, dual channel
|
||||||
|
@ -115,3 +111,5 @@ void ptn3460_init(void) {
|
||||||
bool ptn3460_is_valid(void) {
|
bool ptn3460_is_valid(void) {
|
||||||
return gpio_get(PTN3460_VALID_PIN);
|
return gpio_get(PTN3460_VALID_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -21,5 +21,7 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef INPUT_TYPEC
|
||||||
void ptn3460_init(void);
|
void ptn3460_init(void);
|
||||||
bool ptn3460_is_valid(void);
|
bool ptn3460_is_valid(void);
|
||||||
|
#endif
|
Loading…
Reference in a new issue