Repository navigation
wide-gamut: no EDID mapping without primaries; dp3 for Mac built-in panels #18843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
joshuaswarren
wants to merge
4
commits into
omacom:quattro
Choose a base branch
from
joshuaswarren:skip-edid-cm-without-primaries
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+143
−1
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
be78958
Skip the EDID color mapping for panels that report no primaries
joshuaswarren 5c3bd3c
wide-gamut: match desc: selectors against the monitor description
joshuaswarren da1d352
wide-gamut: map a built-in panel without primaries to dp3
joshuaswarren 8b78f93
Merge branch 'quattro' into skip-edid-cm-without-primaries
joshuaswarren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,46 @@ local paths = require("default.hypr.paths") | |
|
|
||
| local chosen = {} | ||
|
|
||
| -- The area of the primaries triangle in an EDID's chromaticity block (sRGB is | ||
| -- about 0.11). A panel that reports no primaries has no gamut to map into: | ||
| -- "edid" then collapses the output to black. Unreadable EDIDs count as usable. | ||
| local function edid_has_gamut(name) | ||
| if not name:match("^[%w%-]+$") then | ||
| return true | ||
| end | ||
|
|
||
| local pipe = io.popen("cat /sys/class/drm/card*-" .. name .. "/edid 2>/dev/null", "r") | ||
| if not pipe then | ||
| return true | ||
| end | ||
| local edid = pipe:read("a") | ||
| pipe:close() | ||
| if #edid < 35 then | ||
| return true | ||
| end | ||
|
|
||
| local function coord(msb_offset, lsb_offset, shift) | ||
| local msb = edid:byte(msb_offset + 1) | ||
| local lsb = (edid:byte(lsb_offset + 1) // 2 ^ shift) % 4 | ||
| return (msb * 4 + lsb) / 1024 | ||
| end | ||
|
|
||
| local rx, ry = coord(27, 25, 6), coord(28, 25, 4) | ||
| local gx, gy = coord(29, 25, 2), coord(30, 25, 0) | ||
| local bx, by = coord(31, 26, 6), coord(32, 26, 4) | ||
| return math.abs(rx * (gy - by) + gx * (by - ry) + bx * (ry - gy)) / 2 > 0.01 | ||
| end | ||
|
|
||
| -- Whether every monitor a rule covers has a gamut ("" covers all of them). | ||
| local function gamut_for_rule(output) | ||
| for _, monitor in ipairs(hl.get_monitors()) do | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If — Marcelo's agent |
||
| if (output == "" or monitor.name == output) and not edid_has_gamut(monitor.name) then | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| return false | ||
| end | ||
| end | ||
| return true | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| end | ||
|
|
||
| local function chosen_for(output) | ||
| if chosen[output] then | ||
| return chosen[output] | ||
|
|
@@ -47,7 +87,7 @@ if o.shell_succeeds(o.shell_quote(paths.omarchy_path .. "/bin/omarchy-hw-aarch64 | |
| if rule.cm ~= nil then | ||
| chosen[output] = rule.cm | ||
| else | ||
| rule.cm = chosen_for(output) or "edid" | ||
| rule.cm = chosen_for(output) or (gamut_for_rule(output) and "edid" or nil) | ||
| end | ||
| end | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: requiring 128 bytes and the EDID header would keep a truncated blob from being read as primaries.
— Marcelo's agent