Skip to content

Commit

Permalink
Overhaul display scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
uejji committed Dec 8, 2024
1 parent fa83382 commit 9892ea6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ local panel_colorimetry = {
}

local panel_resolutions = {
{ width = 1080, height = 1920,
hfront = 90, hsync = 18, hback = 72,
vfront = 14, vsync = 2, vback = 8 },
{ width = 1080, height = 1920 },
}

local panel_refresh_rates = { 60, 120 }
Expand All @@ -40,32 +38,33 @@ gamescope.config.known_displays[panel_id] = {

dynamic_modegen = function(base_mode, refresh)
local mode = base_mode
local found_res = false
local set_res = panel_resolutions[1]
debug("["..panel_id.."] Generating mode "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")
local set_res = false
debug("["..panel_id.."] Switching mode to "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")

for i, res in ipairs(panel_resolutions) do
if res.width == mode.hdisplay and res.height == mode.vdisplay then
found_res = true
set_res = res
break
end
end

if not found_res then
debug("["..panel_id.."] Generating mode failed. Setting default resolution of "..set_res.width.."x"..set_res.height)
gamescope.modegen.set_resolution(mode, set_res.width, set_res.height)
if not set_res then
debug("["..panel_id.."] Mode not found. Aborting.")
return mode
end

gamescope.modegen.set_h_timings(mode, set_res.hfront, set_res.hsync, set_res.hback)
gamescope.modegen.set_v_timings(mode, set_res.vfront, set_res.vsync, set_res.vback)
if set_res.hfp ~= nil and set_res.hsync ~= nil and set_res.hbp ~= nil then
gamescope.modegen.set_h_timings(mode, set_res.hfp, set_res.hsync, set_res.hbp)
end
if set_res.vfp ~= nil and set_res.vsync ~= nil and set_res.vbp ~= nil then
gamescope.modegen.set_v_timings(mode, set_res.vfp, set_res.vsync, set_res.vbp)
end

mode.clock = gamescope.modegen.calc_max_clock(mode, refresh)
mode.vrefresh = gamescope.modegen.calc_vrefresh(mode)

return mode
end,

matches = function(display)
for i, panel in ipairs(panel_models) do
if panel.vendor == display.vendor and panel.model == display.model then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,11 @@ local panel_colorimetry = {
}

local panel_resolutions = {
{ width = 1080, height = 1920,
hfront = 116, hsync = 4, hback = 34,
vfront = 20, vsync = 2, vback = 6 },
{ width = 600, height = 1066,
hfront = 64, hsync = 8, hback = 88,
vfront = 20, vsync = 8, vback = 12 },
{ width = 768, height = 1024,
hfront = 64, hsync = 8, hback = 88,
vfront = 20, vsync = 8, vback = 12 },
{ width = 600, height = 800,
hfront = 64, hsync = 8, hback = 88,
vfront = 20, vsync = 8, vback = 12 },
{ width = 720, height = 1280,
hfront = 68, hsync = 8, hback = 88,
vfront = 12, vsync = 4, vback = 8 },
{ width = 1080, height = 1920 },
{ width = 768, height = 1024 },
{ width = 720, height = 1280 },
{ width = 600, height = 1066 },
{ width = 600, height = 800 },
}

local panel_refresh_rates = {}
Expand All @@ -57,25 +47,27 @@ gamescope.config.known_displays[panel_id] = {

dynamic_modegen = function(base_mode, refresh)
local mode = base_mode
local found_res = false
local set_res = panel_resolutions[1]
debug("["..panel_id.."] Generating mode "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")
local set_res = false
debug("["..panel_id.."] Switching mode to "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")

for i, res in ipairs(panel_resolutions) do
if res.width == mode.hdisplay and res.height == mode.vdisplay then
found_res = true
set_res = res
break
end
end

if not found_res then
debug("["..panel_id.."] Generating mode failed. Setting default resolution of "..set_res.width.."x"..set_res.height)
gamescope.modegen.set_resolution(mode, set_res.width, set_res.height)
if not set_res then
debug("["..panel_id.."] Mode not found. Aborting.")
return mode
end

gamescope.modegen.set_h_timings(mode, set_res.hfront, set_res.hsync, set_res.hback)
gamescope.modegen.set_v_timings(mode, set_res.vfront, set_res.vsync, set_res.vback)
if set_res.hfp ~= nil and set_res.hsync ~= nil and set_res.hbp ~= nil then
gamescope.modegen.set_h_timings(mode, set_res.hfp, set_res.hsync, set_res.hbp)
end
if set_res.vfp ~= nil and set_res.vsync ~= nil and set_res.vbp ~= nil then
gamescope.modegen.set_v_timings(mode, set_res.vfp, set_res.vsync, set_res.vbp)
end

mode.clock = gamescope.modegen.calc_max_clock(mode, refresh)
mode.vrefresh = gamescope.modegen.calc_vrefresh(mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,13 @@ local panel_colorimetry = {
}

local panel_resolutions = {
{ width = 1200, height = 1920,
hfront = 64, hsync = 24, hback = 32,
vfront = 60, vsync = 8, vback = 32 },
{ width = 1080, height = 1920,
hfront = 40, hsync = 8, hback = 120,
vfront = 8, vsync = 16, vback = 44 },
{ width = 720, height = 1152,
hfront = 64, hsync = 8, hback = 88,
vfront = 8, vsync = 20, vback = 12 },
{ width = 800, height = 1280,
hfront = 32, hsync = 10, hback = 118,
vfront = 10, vsync = 16, vback = 20 },
{ width = 720, height = 1280,
hfront = 64, hsync = 8, hback = 68,
vfront = 10, vsync = 16, vback = 14 },
{ width = 768, height = 1024,
hfront = 48, hsync = 10, hback = 82,
vfront = 10, vsync = 24, vback = 22 },
{ width = 600, height = 960,
hfront = 68, hsync = 8, hback = 88,
vfront = 12, vsync = 4, vback = 8 },
{ width = 1200, height = 1920 },
{ width = 1080, height = 1920 },
{ width = 800, height = 1280 },
{ width = 768, height = 1024 },
{ width = 720, height = 1280 },
{ width = 720, height = 1152 },
{ width = 600, height = 960 },
}

local panel_refresh_rates = {}
Expand All @@ -62,25 +48,27 @@ gamescope.config.known_displays[panel_id] = {

dynamic_modegen = function(base_mode, refresh)
local mode = base_mode
local found_res = false
local set_res = panel_resolutions[1]
debug("["..panel_id.."] Generating mode "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")
local set_res = false
debug("["..panel_id.."] Switching mode to "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")

for i, res in ipairs(panel_resolutions) do
if res.width == mode.hdisplay and res.height == mode.vdisplay then
found_res = true
set_res = res
break
end
end

if not found_res then
debug("["..panel_id.."] Generating mode failed. Setting default resolution of "..set_res.width.."x"..set_res.height)
gamescope.modegen.set_resolution(mode, set_res.width, set_res.height)
if not set_res then
debug("["..panel_id.."] Mode not found. Aborting.")
return mode
end

gamescope.modegen.set_h_timings(mode, set_res.hfront, set_res.hsync, set_res.hback)
gamescope.modegen.set_v_timings(mode, set_res.vfront, set_res.vsync, set_res.vback)
if set_res.hfp ~= nil and set_res.hsync ~= nil and set_res.hbp ~= nil then
gamescope.modegen.set_h_timings(mode, set_res.hfp, set_res.hsync, set_res.hbp)
end
if set_res.vfp ~= nil and set_res.vsync ~= nil and set_res.vbp ~= nil then
gamescope.modegen.set_v_timings(mode, set_res.vfp, set_res.vsync, set_res.vbp)
end

mode.clock = gamescope.modegen.calc_max_clock(mode, refresh)
mode.vrefresh = gamescope.modegen.calc_vrefresh(mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,13 @@ local panel_colorimetry = {
}

local panel_resolutions = {
{ width = 1080, height = 1920,
hfront = 25, hsync = 10, hback = 15,
vfront = 3, vsync = 16, vback = 20 },
{ width = 810, height = 1440,
hfront = 144, hsync = 80, hback = 64,
vfront = 40, vsync = 10, vback = 3 },
{ width = 768, height = 1024,
hfront = 48, hsync = 10, hback = 82,
vfront = 10, vsync = 24, vback = 22 },
{ width = 720, height = 1280,
hfront = 128, hsync = 72, hback = 56,
vfront = 34, vsync = 10, vback = 3 },
{ width = 648, height = 1152,
hfront = 112, hsync = 64, hback = 48,
vfront = 30, vsync = 10, vback = 3 },
{ width = 600, height = 800,
hfront = 88, hsync = 56, hback = 31,
vfront = 18, vsync = 10, vback = 3 },
{ width = 768, height = 1366,
hfront = 136, hsync = 80, hback = 56,
vfront = 37, vsync = 10, vback = 3 },
{ width = 1080, height = 1920 },
{ width = 810, height = 1440 },
{ width = 768, height = 1366 },
{ width = 768, height = 1024 },
{ width = 720, height = 1280 },
{ width = 648, height = 1152 },
{ width = 600, height = 800 },
}


Expand All @@ -64,25 +50,27 @@ gamescope.config.known_displays[panel_id] = {

dynamic_modegen = function(base_mode, refresh)
local mode = base_mode
local found_res = false
local set_res = panel_resolutions[1]
debug("["..panel_id.."] Generating mode "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")
local set_res = false
debug("["..panel_id.."] Switching mode to "..mode.hdisplay.."x"..mode.vdisplay.."@"..refresh.."Hz")

for i, res in ipairs(panel_resolutions) do
if res.width == mode.hdisplay and res.height == mode.vdisplay then
found_res = true
set_res = res
break
end
end

if not found_res then
debug("["..panel_id.."] Generating mode failed. Setting default resolution of "..set_res.width.."x"..set_res.height)
gamescope.modegen.set_resolution(mode, set_res.width, set_res.height)
if not set_res then
debug("["..panel_id.."] Mode not found. Aborting.")
return mode
end

gamescope.modegen.set_h_timings(mode, set_res.hfront, set_res.hsync, set_res.hback)
gamescope.modegen.set_v_timings(mode, set_res.vfront, set_res.vsync, set_res.vback)
if set_res.hfp ~= nil and set_res.hsync ~= nil and set_res.hbp ~= nil then
gamescope.modegen.set_h_timings(mode, set_res.hfp, set_res.hsync, set_res.hbp)
end
if set_res.vfp ~= nil and set_res.vsync ~= nil and set_res.vbp ~= nil then
gamescope.modegen.set_v_timings(mode, set_res.vfp, set_res.vsync, set_res.vbp)
end

mode.clock = gamescope.modegen.calc_max_clock(mode, refresh)
mode.vrefresh = gamescope.modegen.calc_vrefresh(mode)
Expand Down

0 comments on commit 9892ea6

Please sign in to comment.