forge
Explore
Log in

Don't you dare go Hollow

Add per output max-bpc config and ipc action

Browse files at this commit

c5253968b4b2d9fc599c1636b0e295ff32aab52bMichael YangParent: 9a6f310
  • feat
    • add per output max-bpc config and ipc action
Show full message
feat: add per output max-bpc config and ipc action

List current max-bpc values in outputs.

fix: remove 16 bpc and change default behaviour

feat(ipc): add max_bpc and format to output

fix: bpc on output config change

docs: add bpc to Outputs

feat: use atomic commits for connector properties

fix: drm `value_type` breaking change

fix: minor changes based on PR review

Rename bpc to max-bpc.

Add max-bpc output action.

refactor: add set_connector_properties

Fix niri-config parse test.

fix: bail when outside valid max bpc range
docs/wiki/Configuration:-Outputs.mdmodified+18 -0
@@ -15,6 +15,7 @@ output "eDP-1" {
15 variable-refresh-rate // on-demand=true15 variable-refresh-rate // on-demand=true
16 focus-at-startup16 focus-at-startup
17 backdrop-color "#001100"17 backdrop-color "#001100"
18+ max-bpc 8
18 19
19 hot-corners {20 hot-corners {
20 // off21 // off
@@ -279,6 +280,23 @@ output "HDMI-A-1" {
279 }280 }
280 ```281 ```
281 282
283+### `max-bpc`
284+
285+<sup>Since: next release</sup>
286+
287+Set the maximum bits per channel (BPC) for this output.
288+You *do not* need to set this option unless you hit bandwidth issues (can't set a monitor configuration that works on other compositor) or lower-than-expected color depth.
289+Particularly, 10-bit color output may work even if max-bpc is 8.
290+
291+Valid values are `6`, `8`, `10`, `12`, `14`, `16`.
292+
293+```kdl
294+// Set 8 max-bpc on HDMI-A-1 to lower the bandwidth.
295+output "HDMI-A-1" {
296+ max-bpc 8
297+}
298+```
299+
282 ### `hot-corners`300 ### `hot-corners`
283 301
284 <sup>Since: 25.11</sup>302 <sup>Since: 25.11</sup>
niri-config/src/lib.rsmodified+9 -1
@@ -745,6 +745,7 @@ mod tests {
745 transform "flipped-90"745 transform "flipped-90"
746 position x=10 y=20746 position x=10 y=20
747 mode "1920x1080@144"747 mode "1920x1080@144"
748+ max-bpc 10
748 variable-refresh-rate on-demand=true749 variable-refresh-rate on-demand=true
749 background-color "rgba(25, 25, 102, 1.0)"750 background-color "rgba(25, 25, 102, 1.0)"
750 hot-corners {751 hot-corners {
@@ -857,7 +858,7 @@ mod tests {
857 window-open { off; }858 window-open { off; }
858 859
859 window-close {860 window-close {
860- curve "cubic-bezier" 0.05 0.7 0.1 1 861+ curve "cubic-bezier" 0.05 0.7 0.1 1
861 }862 }
862 863
863 recent-windows-close {864 recent-windows-close {
@@ -1160,6 +1161,11 @@ mod tests {
1160 y: 20,1161 y: 20,
1161 },1162 },
1162 ),1163 ),
1164+ max_bpc: Some(
1165+ MaxBpc(
1166+ _10,
1167+ ),
1168+ ),
1163 mode: Some(1169 mode: Some(
1164 Mode {1170 Mode {
1165 custom: false,1171 custom: false,
@@ -1205,6 +1211,7 @@ mod tests {
1205 scale: None,1211 scale: None,
1206 transform: Normal,1212 transform: Normal,
1207 position: None,1213 position: None,
1214+ max_bpc: None,
1208 mode: Some(1215 mode: Some(
1209 Mode {1216 Mode {
1210 custom: true,1217 custom: true,
@@ -1231,6 +1238,7 @@ mod tests {
1231 scale: None,1238 scale: None,
1232 transform: Normal,1239 transform: Normal,
1233 position: None,1240 position: None,
1241+ max_bpc: None,
1234 mode: None,1242 mode: None,
1235 modeline: Some(1243 modeline: Some(
1236 Modeline {1244 Modeline {
niri-config/src/output.rsmodified+42 -0
@@ -59,6 +59,8 @@ pub struct Output {
59 pub transform: Transform,59 pub transform: Transform,
60 #[knuffel(child)]60 #[knuffel(child)]
61 pub position: Option<Position>,61 pub position: Option<Position>,
62+ #[knuffel(child, unwrap(argument))]
63+ pub max_bpc: Option<MaxBpc>,
62 #[knuffel(child)]64 #[knuffel(child)]
63 pub mode: Option<Mode>,65 pub mode: Option<Mode>,
64 #[knuffel(child)]66 #[knuffel(child)]
@@ -101,6 +103,7 @@ impl Default for Output {
101 scale: None,103 scale: None,
102 transform: Transform::Normal,104 transform: Transform::Normal,
103 position: None,105 position: None,
106+ max_bpc: None,
104 mode: None,107 mode: None,
105 modeline: None,108 modeline: None,
106 variable_refresh_rate: None,109 variable_refresh_rate: None,
@@ -128,6 +131,9 @@ pub struct Position {
128 pub y: i32,131 pub y: i32,
129 }132 }
130 133
134+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
135+pub struct MaxBpc(pub niri_ipc::MaxBpc);
136+
131 #[derive(knuffel::Decode, Debug, Clone, PartialEq, Default)]137 #[derive(knuffel::Decode, Debug, Clone, PartialEq, Default)]
132 pub struct Vrr {138 pub struct Vrr {
133 #[knuffel(property, default = false)]139 #[knuffel(property, default = false)]
@@ -257,6 +263,42 @@ impl OutputName {
257 }263 }
258 }264 }
259 265
266+impl<S: ErrorSpan> knuffel::DecodeScalar<S> for MaxBpc {
267+ fn type_check(
268+ type_name: &Option<knuffel::span::Spanned<knuffel::ast::TypeName, S>>,
269+ ctx: &mut Context<S>,
270+ ) {
271+ if let Some(type_name) = &type_name {
272+ ctx.emit_error(DecodeError::unexpected(
273+ type_name,
274+ "type name",
275+ "no type name expected for this node",
276+ ));
277+ }
278+ }
279+
280+ fn raw_decode(
281+ value: &knuffel::span::Spanned<knuffel::ast::Literal, S>,
282+ ctx: &mut Context<S>,
283+ ) -> Result<Self, DecodeError<S>> {
284+ match &**value {
285+ knuffel::ast::Literal::Int(ref val) => match u8::try_from(val) {
286+ Ok(v) => niri_ipc::MaxBpc::try_from(v)
287+ .map(MaxBpc)
288+ .map_err(|e| DecodeError::conversion(value, e)),
289+ Err(e) => {
290+ ctx.emit_error(DecodeError::conversion(value, e));
291+ Ok(Self::default())
292+ }
293+ },
294+ _ => {
295+ ctx.emit_error(DecodeError::scalar_kind(knuffel::decode::Kind::Int, value));
296+ Ok(Self::default())
297+ }
298+ }
299+ }
300+}
301+
260 impl<S: ErrorSpan> knuffel::Decode<S> for Mode {302 impl<S: ErrorSpan> knuffel::Decode<S> for Mode {
261 fn decode_node(node: &SpannedNode<S>, ctx: &mut Context<S>) -> Result<Self, DecodeError<S>> {303 fn decode_node(node: &SpannedNode<S>, ctx: &mut Context<S>) -> Result<Self, DecodeError<S>> {
262 if let Some(type_name) = &node.type_name {304 if let Some(type_name) = &node.type_name {
niri-ipc/src/lib.rsmodified+58 -0
@@ -1097,6 +1097,12 @@ pub enum OutputAction {
1097 #[cfg_attr(feature = "clap", command(flatten))]1097 #[cfg_attr(feature = "clap", command(flatten))]
1098 vrr: VrrToSet,1098 vrr: VrrToSet,
1099 },1099 },
1100+ /// Set the maximum bits per channel (bit depth).
1101+ MaxBpc {
1102+ /// Maximum bits per channel to set.
1103+ #[cfg_attr(feature = "clap", arg())]
1104+ max_bpc: MaxBpc,
1105+ },
1100 }1106 }
1101 1107
1102 /// Output mode to set.1108 /// Output mode to set.
@@ -1228,6 +1234,8 @@ pub struct Output {
1228 ///1234 ///
1229 /// `None` if the output is not mapped to any logical output (for example, if it is disabled).1235 /// `None` if the output is not mapped to any logical output (for example, if it is disabled).
1230 pub logical: Option<LogicalOutput>,1236 pub logical: Option<LogicalOutput>,
1237+ /// Maximum bits per channel (bit depth), if known.
1238+ pub max_bpc: Option<u8>,
1231 }1239 }
1232 1240
1233 /// Output mode.1241 /// Output mode.
@@ -1291,6 +1299,32 @@ pub enum Transform {
1291 Flipped270,1299 Flipped270,
1292 }1300 }
1293 1301
1302+/// Output maximum bits per channel.
1303+#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)]
1304+#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
1305+#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
1306+pub enum MaxBpc {
1307+ /// 6-bit.
1308+ #[serde(rename = "6")]
1309+ _6 = 6,
1310+ /// 8-bit.
1311+ #[default]
1312+ #[serde(rename = "8")]
1313+ _8 = 8,
1314+ /// 10-bit.
1315+ #[serde(rename = "10")]
1316+ _10 = 10,
1317+ /// 12-bit.
1318+ #[serde(rename = "12")]
1319+ _12 = 12,
1320+ /// 14-bit.
1321+ #[serde(rename = "14")]
1322+ _14 = 14,
1323+ /// 16-bit.
1324+ #[serde(rename = "16")]
1325+ _16 = 16,
1326+}
1327+
1294 /// Toplevel window.1328 /// Toplevel window.
1295 #[derive(Serialize, Deserialize, Debug, Clone)]1329 #[derive(Serialize, Deserialize, Debug, Clone)]
1296 #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]1330 #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
@@ -1868,6 +1902,30 @@ impl FromStr for Transform {
1868 }1902 }
1869 }1903 }
1870 1904
1905+impl TryFrom<u8> for MaxBpc {
1906+ type Error = &'static str;
1907+
1908+ fn try_from(value: u8) -> Result<Self, Self::Error> {
1909+ match value {
1910+ 6 => Ok(MaxBpc::_6),
1911+ 8 => Ok(MaxBpc::_8),
1912+ 10 => Ok(MaxBpc::_10),
1913+ 12 => Ok(MaxBpc::_12),
1914+ 14 => Ok(MaxBpc::_14),
1915+ 16 => Ok(MaxBpc::_16),
1916+ _ => Err("invalid max-bpc, can be 6, 8, 10, 12, 14, 16"),
1917+ }
1918+ }
1919+}
1920+
1921+impl FromStr for MaxBpc {
1922+ type Err = &'static str;
1923+
1924+ fn from_str(s: &str) -> Result<Self, Self::Err> {
1925+ Self::try_from(s.parse::<u8>().unwrap_or_default())
1926+ }
1927+}
1928+
1871 impl FromStr for Layer {1929 impl FromStr for Layer {
1872 type Err = &'static str;1930 type Err = &'static str;
1873 1931
src/backend/headless.rsmodified+1 -0
@@ -109,6 +109,7 @@ impl Headless {
109 vrr_supported: false,109 vrr_supported: false,
110 vrr_enabled: false,110 vrr_enabled: false,
111 logical: Some(logical_output(&output)),111 logical: Some(logical_output(&output)),
112+ max_bpc: None,
112 },113 },
113 );114 );
114 115
src/backend/tty.rsmodified+137 -54
@@ -14,7 +14,7 @@ use anyhow::{anyhow, bail, ensure, Context};
14 use bytemuck::cast_slice_mut;14 use bytemuck::cast_slice_mut;
15 use drm_ffi::drm_mode_modeinfo;15 use drm_ffi::drm_mode_modeinfo;
16 use libc::dev_t;16 use libc::dev_t;
17-use niri_config::output::Modeline;17+use niri_config::output::{MaxBpc, Modeline};
18 use niri_config::{Config, OutputName};18 use niri_config::{Config, OutputName};
19 use niri_ipc::{HSyncPolarity, VSyncPolarity};19 use niri_ipc::{HSyncPolarity, VSyncPolarity};
20 use smithay::backend::allocator::dmabuf::Dmabuf;20 use smithay::backend::allocator::dmabuf::Dmabuf;
@@ -405,6 +405,8 @@ struct ConnectorProperties<'a> {
405 device: &'a DrmDevice,405 device: &'a DrmDevice,
406 connector: connector::Handle,406 connector: connector::Handle,
407 properties: Vec<(property::Info, property::RawValue)>,407 properties: Vec<(property::Info, property::RawValue)>,
408+ has_change: bool,
409+ requests: AtomicModeReq,
408 }410 }
409 411
410 impl Tty {412 impl Tty {
@@ -676,16 +678,19 @@ impl Tty {
676 // Apply pending gamma changes and restore our existing gamma.678 // Apply pending gamma changes and restore our existing gamma.
677 let device = self.devices.get_mut(&node).unwrap();679 let device = self.devices.get_mut(&node).unwrap();
678 for (crtc, surface) in device.surfaces.iter_mut() {680 for (crtc, surface) in device.surfaces.iter_mut() {
679- if let Ok(props) =681+ if let Ok(mut props) =
680 ConnectorProperties::try_new(&device.drm, surface.connector)682 ConnectorProperties::try_new(&device.drm, surface.connector)
681 {683 {
682- match reset_hdr(&props) {684+ let max_bpc = self
683- Ok(()) => (),685+ .config
684- Err(err) => debug!("couldn't reset HDR properties: {err:?}"),686+ .borrow()
685- }687+ .outputs
688+ .find(&surface.name)
689+ .and_then(|o| o.max_bpc);
690+ set_connector_properties(&mut props, max_bpc, true);
686 } else {691 } else {
687 warn!("failed to get connector properties");692 warn!("failed to get connector properties");
688- };693+ }
689 694
690 if let Some(ramp) = surface.pending_gamma_change.take() {695 if let Some(ramp) = surface.pending_gamma_change.take() {
691 let ramp = ramp.as_deref();696 let ramp = ramp.as_deref();
@@ -1302,13 +1307,10 @@ impl Tty {
1302 debug!("picking mode: {mode:?}");1307 debug!("picking mode: {mode:?}");
1303 1308
1304 let mut orientation = None;1309 let mut orientation = None;
1305- if let Ok(props) = ConnectorProperties::try_new(&device.drm, connector.handle()) {1310+ if let Ok(mut props) = ConnectorProperties::try_new(&device.drm, connector.handle()) {
1306- match reset_hdr(&props) {1311+ set_connector_properties(&mut props, config.max_bpc, true);
1307- Ok(()) => (),
1308- Err(err) => debug!("couldn't reset HDR properties: {err:?}"),
1309- }
1310 1312
1311- match get_panel_orientation(&props) {1313+ match props.get_panel_orientation() {
1312 Ok(x) => orientation = Some(x),1314 Ok(x) => orientation = Some(x),
1313 Err(err) => {1315 Err(err) => {
1314 trace!("couldn't get panel orientation: {err:?}");1316 trace!("couldn't get panel orientation: {err:?}");
@@ -1316,7 +1318,7 @@ impl Tty {
1316 }1318 }
1317 } else {1319 } else {
1318 warn!("failed to get connector properties");1320 warn!("failed to get connector properties");
1319- };1321+ }
1320 1322
1321 let mut gamma_props = GammaProps::new(&device.drm, crtc)1323 let mut gamma_props = GammaProps::new(&device.drm, crtc)
1322 .map_err(|err| debug!("couldn't get gamma properties: {err:?}"))1324 .map_err(|err| debug!("couldn't get gamma properties: {err:?}"))
@@ -2194,6 +2196,15 @@ impl Tty {
2194 OutputId::next()2196 OutputId::next()
2195 });2197 });
2196 2198
2199+ let props = ConnectorProperties::try_new(&device.drm, connector.handle()).ok();
2200+ let max_bpc = props.as_ref().and_then(|p| p.find(c"max bpc").ok());
2201+ let max_bpc = max_bpc.and_then(|(info, value)| {
2202+ info.value_type()
2203+ .convert_value(*value)
2204+ .as_unsigned_range()
2205+ .map(|v| v as u8)
2206+ });
2207+
2197 let ipc_output = niri_ipc::Output {2208 let ipc_output = niri_ipc::Output {
2198 name: connector_name,2209 name: connector_name,
2199 make: output_name.make.unwrap_or_else(|| "Unknown".into()),2210 make: output_name.make.unwrap_or_else(|| "Unknown".into()),
@@ -2206,6 +2217,7 @@ impl Tty {
2206 vrr_supported,2217 vrr_supported,
2207 vrr_enabled,2218 vrr_enabled,
2208 logical,2219 logical,
2220+ max_bpc,
2209 };2221 };
2210 2222
2211 ipc_outputs.insert(id, ipc_output);2223 ipc_outputs.insert(id, ipc_output);
@@ -2422,6 +2434,13 @@ impl Tty {
2422 },2434 },
2423 };2435 };
2424 2436
2437+ if let Ok(mut props) = ConnectorProperties::try_new(&device.drm, surface.connector)
2438+ {
2439+ set_connector_properties(&mut props, config.max_bpc, false);
2440+ } else {
2441+ warn!("failed to get connector properties");
2442+ }
2443+
2425 let change_mode = surface.compositor.pending_mode() != mode;2444 let change_mode = surface.compositor.pending_mode() != mode;
2426 2445
2427 let vrr_enabled = surface.compositor.vrr_enabled();2446 let vrr_enabled = surface.compositor.vrr_enabled();
@@ -3250,6 +3269,8 @@ impl<'a> ConnectorProperties<'a> {
3250 device,3269 device,
3251 connector,3270 connector,
3252 properties,3271 properties,
3272+ has_change: false,
3273+ requests: AtomicModeReq::new(),
3253 })3274 })
3254 }3275 }
3255 3276
@@ -3262,35 +3283,115 @@ impl<'a> ConnectorProperties<'a> {
3262 3283
3263 Err(anyhow!("couldn't find property: {name:?}"))3284 Err(anyhow!("couldn't find property: {name:?}"))
3264 }3285 }
3265-}
3266 3286
3267-const DRM_MODE_COLORIMETRY_DEFAULT: u64 = 0;3287+ fn get_panel_orientation(&self) -> anyhow::Result<Transform> {
3288+ let (info, value) = self.find(c"panel orientation")?;
3289+ match info.value_type().convert_value(*value) {
3290+ property::Value::Enum(Some(val)) => match val.value() {
3291+ // "Normal"
3292+ 0 => Ok(Transform::Normal),
3293+ // "Upside Down"
3294+ 1 => Ok(Transform::_180),
3295+ // "Left Side Up"
3296+ 2 => Ok(Transform::_90),
3297+ // "Right Side Up"
3298+ 3 => Ok(Transform::_270),
3299+ _ => bail!("panel orientation has invalid value: {:?}", val),
3300+ },
3301+ _ => bail!("panel orientation has wrong value type"),
3302+ }
3303+ }
3268 3304
3269-fn reset_hdr(props: &ConnectorProperties) -> anyhow::Result<()> {3305+ fn reset_hdr(&mut self) -> anyhow::Result<()> {
3270- let (info, value) = props.find(c"HDR_OUTPUT_METADATA")?;3306+ const DRM_MODE_COLORIMETRY_DEFAULT: u64 = 0;
3271- let property::ValueType::Blob = info.value_type() else {
3272- bail!("wrong property type")
3273- };
3274 3307
3275- if *value != 0 {3308+ let (info, value) = self.find(c"HDR_OUTPUT_METADATA")?;
3276- props3309+
3277- .device3310+ let property::ValueType::Blob = info.value_type() else {
3278- .set_property(props.connector, info.handle(), 0)3311+ bail!("wrong property type")
3279- .context("error setting property")?;3312+ };
3313+ if *value != 0 {
3314+ self.requests
3315+ .add_raw_property(self.connector.into(), info.handle(), 0);
3316+ self.has_change = true;
3317+ }
3318+
3319+ let (info, value) = self.find(c"Colorspace")?;
3320+ let property::ValueType::Enum(_) = info.value_type() else {
3321+ bail!("wrong property type")
3322+ };
3323+ if *value != DRM_MODE_COLORIMETRY_DEFAULT {
3324+ self.requests.add_raw_property(
3325+ self.connector.into(),
3326+ info.handle(),
3327+ DRM_MODE_COLORIMETRY_DEFAULT,
3328+ );
3329+ self.has_change = true;
3330+ }
3331+
3332+ Ok(())
3280 }3333 }
3281 3334
3282- let (info, value) = props.find(c"Colorspace")?;3335+ fn set_max_bpc(&mut self, max_bpc: MaxBpc) -> anyhow::Result<u64> {
3283- let property::ValueType::Enum(_) = info.value_type() else {3336+ let (info, value) = self.find(c"max bpc")?;
3284- bail!("wrong property type")3337+
3285- };3338+ let property::ValueType::UnsignedRange(min, max) = info.value_type() else {
3286- if *value != DRM_MODE_COLORIMETRY_DEFAULT {3339+ bail!("wrong property type")
3287- props3340+ };
3288- .device3341+
3289- .set_property(props.connector, info.handle(), DRM_MODE_COLORIMETRY_DEFAULT)3342+ let max_bpc = max_bpc.0 as u64;
3290- .context("error setting property")?;3343+ if !(min..=max).contains(&max_bpc) {
3344+ bail!("max-bpc {max_bpc} outside valid range of [{min}, {max}]");
3345+ }
3346+
3347+ let property::Value::UnsignedRange(value) = info.value_type().convert_value(*value) else {
3348+ bail!("wrong property type")
3349+ };
3350+
3351+ if value != max_bpc {
3352+ self.requests.add_raw_property(
3353+ self.connector.into(),
3354+ info.handle(),
3355+ property::Value::UnsignedRange(max_bpc).into(),
3356+ );
3357+ self.has_change = true;
3358+ }
3359+
3360+ Ok(max_bpc)
3291 }3361 }
3292 3362
3293- Ok(())3363+ fn commit(&mut self) -> anyhow::Result<()> {
3364+ if self.has_change {
3365+ self.device.atomic_commit(
3366+ AtomicCommitFlags::ALLOW_MODESET,
3367+ std::mem::take(&mut self.requests),
3368+ )?;
3369+ }
3370+
3371+ Ok(())
3372+ }
3373+}
3374+
3375+fn set_connector_properties(
3376+ props: &mut ConnectorProperties,
3377+ max_bpc: Option<MaxBpc>,
3378+ reset_hdr: bool,
3379+) {
3380+ if let Some(max_bpc) = max_bpc {
3381+ if let Err(err) = props.set_max_bpc(max_bpc) {
3382+ debug!("failed to set `max bpc` property: {err}");
3383+ }
3384+ }
3385+
3386+ if reset_hdr {
3387+ if let Err(err) = props.reset_hdr() {
3388+ debug!("failed to set HDR properties: {err}");
3389+ }
3390+ }
3391+
3392+ if let Err(err) = props.commit() {
3393+ warn!("failed to atomically commit properties: {err}");
3394+ }
3294 }3395 }
3295 3396
3296 fn is_vrr_capable(device: &DrmDevice, connector: connector::Handle) -> Option<bool> {3397 fn is_vrr_capable(device: &DrmDevice, connector: connector::Handle) -> Option<bool> {
@@ -3298,24 +3399,6 @@ fn is_vrr_capable(device: &DrmDevice, connector: connector::Handle) -> Option<bo
3298 info.value_type().convert_value(value).as_boolean()3399 info.value_type().convert_value(value).as_boolean()
3299 }3400 }
3300 3401
3301-fn get_panel_orientation(props: &ConnectorProperties) -> anyhow::Result<Transform> {
3302- let (info, value) = props.find(c"panel orientation")?;
3303- match info.value_type().convert_value(*value) {
3304- property::Value::Enum(Some(val)) => match val.value() {
3305- // "Normal"
3306- 0 => Ok(Transform::Normal),
3307- // "Upside Down"
3308- 1 => Ok(Transform::_180),
3309- // "Left Side Up"
3310- 2 => Ok(Transform::_90),
3311- // "Right Side Up"
3312- 3 => Ok(Transform::_270),
3313- _ => bail!("panel orientation has invalid value: {:?}", val),
3314- },
3315- _ => bail!("panel orientation has wrong value type"),
3316- }
3317-}
3318-
3319 pub fn set_gamma_for_crtc(3402 pub fn set_gamma_for_crtc(
3320 device: &DrmDevice,3403 device: &DrmDevice,
3321 crtc: crtc::Handle,3404 crtc: crtc::Handle,
src/backend/winit.rsmodified+1 -0
@@ -95,6 +95,7 @@ impl Winit {
95 vrr_supported: false,95 vrr_supported: false,
96 vrr_enabled: false,96 vrr_enabled: false,
97 logical: Some(logical_output(&output)),97 logical: Some(logical_output(&output)),
98+ max_bpc: None,
98 },99 },
99 )])));100 )])));
100 101
src/ipc/client.rsmodified+5 -0
@@ -568,6 +568,7 @@ fn print_output(output: Output) -> anyhow::Result<()> {
568 vrr_supported,568 vrr_supported,
569 vrr_enabled,569 vrr_enabled,
570 logical,570 logical,
571+ max_bpc,
571 } = output;572 } = output;
572 573
573 let serial = serial.as_deref().unwrap_or("Unknown");574 let serial = serial.as_deref().unwrap_or("Unknown");
@@ -651,6 +652,10 @@ fn print_output(output: Output) -> anyhow::Result<()> {
651 println!(" Transform: {transform}");652 println!(" Transform: {transform}");
652 }653 }
653 654
655+ if let Some(max_bpc) = max_bpc {
656+ println!(" Max bits per channel: {max_bpc}");
657+ }
658+
654 println!(" Available modes:");659 println!(" Available modes:");
655 for (idx, mode) in modes.into_iter().enumerate() {660 for (idx, mode) in modes.into_iter().enumerate() {
656 let Mode {661 let Mode {
src/niri.rsmodified+2 -0
@@ -14,6 +14,7 @@ use _server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as
14 use anyhow::{bail, ensure, Context};14 use anyhow::{bail, ensure, Context};
15 use calloop::futures::Scheduler;15 use calloop::futures::Scheduler;
16 use niri_config::debug::PreviewRender;16 use niri_config::debug::PreviewRender;
17+use niri_config::output::MaxBpc;
17 use niri_config::{18 use niri_config::{
18 Config, FloatOrInt, Key, Modifiers, OutputName, TrackLayout, WarpMouseToFocusMode,19 Config, FloatOrInt, Key, Modifiers, OutputName, TrackLayout, WarpMouseToFocusMode,
19 WorkspaceReference, Xkb,20 WorkspaceReference, Xkb,
@@ -1925,6 +1926,7 @@ impl State {
1925 None1926 None
1926 }1927 }
1927 }1928 }
1929+ niri_ipc::OutputAction::MaxBpc { max_bpc } => config.max_bpc = Some(MaxBpc(max_bpc)),
1928 });1930 });
1929 1931
1930 self.reload_output_config();1932 self.reload_output_config();