Skip to content

Commit

Permalink
Add custom display scripts to steamfork-device-support
Browse files Browse the repository at this point in the history
Thanks to:
@matte-schwartz: ASUS Ally/Ally X scripting
@aarron-lee: GPD Win 4 scripting
@fewtarius: AYN Loki Max EDID and testing
  • Loading branch information
uejji committed Dec 6, 2024
1 parent ea9048d commit 63c6845
Show file tree
Hide file tree
Showing 6 changed files with 503 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
-- Ayaneo Air Plus
-- Ayaneo Slide
-- Antec Core HS

local panel_id = "ayaneo_hd_lcd"
local panel_name = "Ayaneo HD LCD Panel"

local panel_models = {
{ vendor = "AYA", model = "AYANEOHD" },
}

local panel_colorimetry = {
r = { x = 0.6484, y = 0.3388 },
g = { x = 0.2822, y = 0.6025 },
b = { x = 0.1425, y = 0.0703 },
w = { x = 0.3134, y = 0.3291 }
}

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 },
}

local panel_refresh_rates = {}
for hz = 45, 60 do
table.insert(panel_refresh_rates, hz)
end

local panel_hdr = {
supported = false,
force_enabled = false,
eotf = gamescope.eotf.gamma22,
max_content_light_level = 500,
max_frame_average_luminance = 500,
min_content_light_level = 0.5
}


gamescope.config.known_displays[panel_id] = {
pretty_name = panel_name,
dynamic_refresh_rates = panel_refresh_rates,
hdr = panel_hdr,
colorimetry = panel_colorimetry,

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")

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)
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)

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
debug("["..panel_id.."] Matched vendor: "..display.vendor.." model: "..display.model)
return 4000
end
end

return -1
end
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
-- Ayaneo 2
-- Ayaneo 2S

local panel_id = "ayaneo_wuxga_lcd"
local panel_name = "Ayaneo WUXGA LCD Panel"

local panel_models = {
{ vendor = "AYA", model = "AYANEOWUXGA" },
}

local panel_colorimetry = {
r = { x = 0.6503, y = 0.3388 },
g = { x = 0.3242, y = 0.6132 },
b = { x = 0.1572, y = 0.0488 },
w = { x = 0.3134, y = 0.3291 }
}

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 },
}

local panel_refresh_rates = {}
for hz = 46, 60 do
table.insert(panel_refresh_rates, hz)
end

local panel_hdr = {
supported = false,
force_enabled = false,
eotf = gamescope.eotf.gamma22,
max_content_light_level = 500,
max_frame_average_luminance = 500,
min_content_light_level = 0.5
}


gamescope.config.known_displays[panel_id] = {
pretty_name = panel_name,
dynamic_refresh_rates = panel_refresh_rates,
hdr = panel_hdr,
colorimetry = panel_colorimetry,

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")

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)
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)

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
debug("["..panel_id.."] Matched vendor: "..display.vendor.." model: "..display.model)
return 4000
end
end

return -1
end
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
-- AYN Loki
-- AYN Loki Max
-- AYN Loki Zero

local panel_id = "ayn_loki_lcd"
local panel_name = "AYN Loki LCD Panel"

local panel_models = {
{ vendor = "AYN", model = "LK-GOLDSPV58" },
}

local panel_colorimetry = {
r = { x = 0.0000, y = 0.0000 },
g = { x = 0.0000, y = 0.0000 },
b = { x = 0.0000, y = 0.0000 },
w = { x = 0.0000, y = 0.0000 }
}

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 },
}


local panel_refresh_rates = {}
for hz = 31, 60 do
table.insert(panel_refresh_rates, hz)
end

local panel_hdr = {
supported = false,
force_enabled = false,
eotf = gamescope.eotf.gamma22,
max_content_light_level = 500,
max_frame_average_luminance = 500,
min_content_light_level = 0.5
}


gamescope.config.known_displays[panel_id] = {
pretty_name = panel_name,
dynamic_refresh_rates = panel_refresh_rates,
hdr = panel_hdr,
--colorimetry = panel_colorimetry,

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")

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)
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)

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
debug("["..panel_id.."] Matched vendor: "..display.vendor.." model: "..display.model)
return 4000
end
end

return -1
end
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- colorimetry from edid
local gpd_win4_lcd_colorimetry = {
r = { x = 0.6250, y = 0.3398 },
g = { x = 0.2802, y = 0.5947 },
b = { x = 0.1552, y = 0.0703 },
w = { x = 0.2832, y = 0.2978 }
}

gamescope.config.known_displays.gpd_win4_lcd = {
pretty_name = "GPD Win 4",
dynamic_refresh_rates = {
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60
},
hdr = {
supported = false,
force_enabled = false,
eotf = gamescope.eotf.gamma22,
max_content_light_level = 400,
max_frame_average_luminance = 400,
min_content_light_level = 0.5
},
colorimetry = gpd_win4_lcd_colorimetry,
dynamic_modegen = function(base_mode, refresh)
debug("Generating mode "..refresh.."Hz for GPD Win 4")
local mode = base_mode

gamescope.modegen.set_resolution(mode, 1920, 1080)

-- Horizontal timings: Hfront, Hsync, Hback
gamescope.modegen.set_h_timings(mode, 72, 8, 16)
-- Vertical timings: Vfront, Vsync, Vback
gamescope.modegen.set_v_timings(mode, 14, 3, 13)

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

return mode
end,
matches = function(display)
-- There are multiple revisions of the GPD Win 4
-- They all should have the same panel
-- lcd_types is just in case there are different panels
local lcd_types = {
{ vendor = "GPD", model = "G1618-04" },
}

for index, value in ipairs(lcd_types) do
if value.vendor == display.vendor and value.model == display.model then
debug("[gpd_win4_lcd] Matched vendor: "..value.vendor.." model: "..value.model)
return 4000
end
end

return -1
end
}
debug("Registered GPD Win 4 as a known display")
--debug(inspect(gamescope.config.known_displays.gpd_win4_lcd))
Loading

0 comments on commit 63c6845

Please sign in to comment.