diff --git a/user_io.cpp b/user_io.cpp index f195691..2b25ff8 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -2586,8 +2586,64 @@ static void setPLL(double Fout) vitems[20] = k; } +short scaler_coef[32][4] = +{ + { -24, 176, -24, 0 }, + { -20, 174, -26, 0 }, + { -16, 169, -26, 1 }, + { -11, 160, -23, 2 }, + { -6, 147, -16, 3 }, + { -1, 129, -4, 4 }, + { 2, 109, 11, 6 }, + { 5, 84, 32, 7 }, + { 6, 58, 58, 6 }, + { 7, 32, 84, 5 }, + { 6, 11, 109, 2 }, + { 4, -4, 129, -1 }, + { 3, -16, 147, -6 }, + { 2, -23, 160, -11 }, + { 1, -26, 169, -16 }, + { 0, -26, 174, -20 }, + + { 0, 128, 0, 0 }, + { -4, 126, 6, 0 }, + { -8, 124, 13, -1 }, + { -10, 119, 20, -1 }, + { -11, 111, 30, -2 }, + { -11, 103, 40, -4 }, + { -10, 93, 50, -5 }, + { -9, 82, 61, -6 }, + { -8, 72, 72, -8 }, + { -6, 61, 82, -9 }, + { -5, 50, 93, -10 }, + { -4, 40, 103, -11 }, + { -2, 30, 111, -11 }, + { -1, 20, 119, -10 }, + { -1, 13, 124, -8 }, + { 0, 6, 126, -4 } +}; + +static void setScaler() +{ + printf("*** Send Scaler parameters:\n"); + + spi_uio_cmd_cont(UIO_SET_VIPCOEF); + for (int i = 0; i < 32; i++) + { + for (int t = 0; t < 4; t++) + { + uint16_t data = (scaler_coef[i][t] & 0x1FF) | (((i * 4) + t) << 9); + printf("%d.%d.%d: %d\n", data >> 15, (data >> 11) & 0xF, (data >> 9) & 0x3, data & 0x1FF); + spi_w(data); + } + } + DisableIO(); +} + static void setVideo() { + setScaler(); + printf("Send HDMI parameters:\n"); spi_uio_cmd_cont(UIO_SET_VIDEO); printf("video: "); diff --git a/user_io.h b/user_io.h index 12ed9d6..e8d13fb 100644 --- a/user_io.h +++ b/user_io.h @@ -62,6 +62,7 @@ #define UIO_SETHEIGHT 0x27 // Set scaled vertical resolution (to reduce scaling artefacts) #define UIO_GETUARTFLG 0x28 // Get UART_FLG_* #define UIO_GET_STATUS 0x29 // Update status from the core +#define UIO_SET_VIPCOEF 0x2A // Set Scaler coefficients // codes as used by 8bit for file loading from OSD #define UIO_FILE_TX 0x53