diff --git a/src/drm.cpp b/src/drm.cpp index 575a798..119e622 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -82,17 +82,21 @@ static uint32_t steam_deck_display_rates[] = { 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70 }; static uint32_t galileo_display_rates[] = { - 45,47,48,49, - 50,51,53,55,56,59, - 60,62,64,65,66,68, - 72,73,76,77,78, - 80,81,82,84,85,86,87,88, - 90, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100,101,102,103,104,105,106,107,108,109, + 110,111,112,113,114,115,116,117,118,119, + 120, }; static uint32_t get_conn_display_info_flags(struct drm_t *drm, struct connector *connector) diff --git a/src/modegen.cpp b/src/modegen.cpp index 197641c..3ece1b6 100644 --- a/src/modegen.cpp +++ b/src/modegen.cpp @@ -276,24 +276,65 @@ void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay, // fps 45 48 51 55 60 65 72 80 90 // VFP 1320 1156 992 828 664 500 336 172 8 -// SDC VFP values for 45 Hz to 90 Hz +// SDC VFP values for 40 Hz to 120 Hz, Untested unsigned int galileo_sdc_vfp[] = { - 1321,1264,1209,1157,1106,1058,993,967,925,883,829,805,768,732,698, - 665,632,601,571,542,501,486,459,433,408,383,360,337,314,292,271,250,230,210,191, - 173,154,137,119,102,86,70,54,38,23,9 + 1321,1321,1321,1321,1321,1321,1264,1209,1157,1106, + 1058,1012, 967, 925, 883, 844, 805, 768, 732, 698, + 665, 632, 601, 571, 542, 513, 486, 459, 433, 408, + 383, 360, 337, 314, 292, 271, 250, 230, 210, 191, + 173, 154, 137, 119, 102, 86, 70, 54, 38, 23, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9 }; -// BOE VFP values for 45 Hz to 90 Hz +// SDC pixel clock values for 40 to 120 Hz, Untested +// Unlikely to function over ~100Hz due to bandwidth limitations +unsigned int galileo_sdc_clock[] = +{ + 118400,121360,124320,127280,130240,133200,133200,133200,133200,133200, + 133200,133200,133200,133200,133200,133200,133200,133200,133200,133200, + 133200,133200,133200,133200,133200,133200,133200,133200,133200,133200, + 133200,133200,133200,133200,133200,133200,133200,133200,133200,133200, + 133200,133200,133200,133200,133200,133200,133200,133200,133200,133200, + 133200,134680,136160,137640,139120,140600,142080,143560,145040,146520, + 148000,149480,150960,152440,153920,155400,156880,158360,159840,161320, + 162800,164280,165760,167240,168720,170200,171680,173160,174640,176120, + 177160 +}; + +// BOE VFP values for 40 Hz to 120 Hz // BOE Vtotal must be a multiple of 4 unsigned int galileo_boe_vfp[] = { - 1320,1272,1216,1156,1112,1064,992,972,928,888,828,808,772,736,700, - 664,636,604,572,544,500,488,460,436,408,384,360,336,316,292,272,252,228,212,192, - 172,152,136,120,100,84,68,52,36,20,8 + 1320,1320,1216,1216,1216,1216,1320,1320,1216,1112, + 1112, 992, 928, 992, 992, 828, 808, 700, 808, 664, + 700, 664, 664, 604, 544, 544, 500, 436, 488, 436, + 336, 316, 336, 316, 228, 336, 316, 252, 252, 212, + 100, 84, 172, 136, 68, 36, 84, 52, 36, 68, + 84, 36, 136, 52, 36, 52, 52, 8, 152, 68, + 100, 8, 136, 36, 84, 8, 36, 8, 84, 8, + 172, 68, 8, 8, 52, 36, 68, 8, 36, 100, + 100 }; -#define GALILEO_MIN_REFRESH 45 +// BOE pixel clock values for 40 to 120 Hz +unsigned int galileo_boe_clock[] = +{ + 90340, 92590, 91100, 93270, 95440, 97610,103880,106140,104120,101910, + 103990,100820, 99940,104780,106750,100990,101870, 98400,105500,100030, + 103580,103420,105120,103570,101920,103510,102610,100490,105020,103490, + 98980, 99180,101810,101970, 97780,106050,106160,103330,104670,103300, + 96920, 97020,104410,103120, 99460, 98310,103010,101820,101780,105380, + 107800,105250,114300,108840,108720,111180,112350,109860,123100,117220, + 121150,114390,126730,119130,124570,118920,122600,121190,129360,123450, + 140060,131430,126850,127980,133420,133010,137350,132510,136480,144170, + 145380 +}; + +#define GALILEO_MIN_REFRESH 40 #define GALILEO_SDC_PID 0x3003 #define GALILEO_SDC_VSYNC 1 #define GALILEO_SDC_VBP 22 @@ -312,33 +353,52 @@ unsigned int get_galileo_vfp( int vrefresh, unsigned int * vfp_array, unsigned i return 0; } +unsigned int get_galileo_clock( int vrefresh, unsigned int * clock_array, unsigned int num_rates ) +{ + for ( unsigned int i = 0; i < num_rates; i++ ) { + if ( i+GALILEO_MIN_REFRESH == (unsigned int)vrefresh ) { + return clock_array[i]; + } + } + return 0; +} + void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base, int vrefresh, - bool use_tuned_clocks, unsigned int use_vfp ) + bool use_tuned_clocks, unsigned int use_vfp ) { *mode = *base; if (!vrefresh) vrefresh = 60; if ( use_vfp ) { - unsigned int vfp, vsync, vbp = 0; + unsigned int clock, vfp, vsync, vbp = 0; if (GALILEO_SDC_PID == use_vfp) { vfp = get_galileo_vfp( vrefresh, galileo_sdc_vfp, ARRAY_SIZE(galileo_sdc_vfp) ); + clock = get_galileo_clock( vrefresh, galileo_sdc_clock, ARRAY_SIZE(galileo_sdc_clock) ); + // if we did not find a matching rate then we default to 60 Hz if ( !vfp ) { vrefresh = 60; vfp = 665; + clock = 133200; } + vsync = GALILEO_SDC_VSYNC; vbp = GALILEO_SDC_VBP; } else { // BOE Panel vfp = get_galileo_vfp( vrefresh, galileo_boe_vfp, ARRAY_SIZE(galileo_boe_vfp) ); + clock = get_galileo_clock( vrefresh, galileo_boe_clock, ARRAY_SIZE(galileo_boe_clock) ); + // if we did not find a matching rate then we default to 60 Hz if ( !vfp ) { vrefresh = 60; - vfp = 664; + vfp = 700; + clock = 103580; } + vsync = GALILEO_BOE_VSYNC; vbp = GALILEO_BOE_VBP; - } + } + mode->clock = clock; mode->vsync_start = mode->vdisplay + vfp; mode->vsync_end = mode->vsync_start + vsync; mode->vtotal = mode->vsync_end + vbp;