head-management: add brightness-setter-v1 extension
This commit is contained in:
parent
e0f1dd549d
commit
2d27dd3d64
7 changed files with 73 additions and 0 deletions
|
|
@ -134,6 +134,7 @@ enum HeadOp {
|
||||||
SetFormat(&'static Format),
|
SetFormat(&'static Format),
|
||||||
SetTransferFunction(BackendTransferFunction),
|
SetTransferFunction(BackendTransferFunction),
|
||||||
SetColorSpace(BackendColorSpace),
|
SetColorSpace(BackendColorSpace),
|
||||||
|
SetBrightness(Option<f64>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||||
|
|
|
||||||
|
|
@ -411,4 +411,5 @@ declare_extensions! {
|
||||||
format_setter_v1: FormatSetterV1,
|
format_setter_v1: FormatSetterV1,
|
||||||
drm_color_space_setter_v1: DrmColorSpaceSetterV1,
|
drm_color_space_setter_v1: DrmColorSpaceSetterV1,
|
||||||
brightness_info_v1: BrightnessInfoV1,
|
brightness_info_v1: BrightnessInfoV1,
|
||||||
|
brightness_setter_v1: BrightnessSetterV1,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
pub(super) mod jay_head_ext_brightness_info_v1;
|
pub(super) mod jay_head_ext_brightness_info_v1;
|
||||||
|
pub(super) mod jay_head_ext_brightness_setter_v1;
|
||||||
pub(super) mod jay_head_ext_compositor_space_enabler_v1;
|
pub(super) mod jay_head_ext_compositor_space_enabler_v1;
|
||||||
pub(super) mod jay_head_ext_compositor_space_info_v1;
|
pub(super) mod jay_head_ext_compositor_space_info_v1;
|
||||||
pub(super) mod jay_head_ext_compositor_space_positioner_v1;
|
pub(super) mod jay_head_ext_compositor_space_positioner_v1;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
ifs::head_management::HeadOp,
|
||||||
|
wire::{
|
||||||
|
jay_head_ext_brightness_setter_v1::{
|
||||||
|
JayHeadExtBrightnessSetterV1RequestHandler, SetBrightness, UnsetBrightness,
|
||||||
|
},
|
||||||
|
jay_head_manager_ext_brightness_setter_v1::JayHeadManagerExtBrightnessSetterV1RequestHandler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
impl_brightness_setter_v1! {
|
||||||
|
version = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JayHeadManagerExtBrightnessSetterV1RequestHandler for MgrName {
|
||||||
|
type Error = ErrorName;
|
||||||
|
|
||||||
|
mgr_common_req!();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JayHeadExtBrightnessSetterV1RequestHandler for HeadName {
|
||||||
|
type Error = ErrorName;
|
||||||
|
|
||||||
|
head_common_req!();
|
||||||
|
|
||||||
|
fn unset_brightness(&self, _req: UnsetBrightness, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.common.push_op(HeadOp::SetBrightness(None))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_brightness(&self, req: SetBrightness, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.common
|
||||||
|
.push_op(HeadOp::SetBrightness(Some(f32::from_bits(req.lux) as f64)))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error!();
|
||||||
|
|
@ -459,6 +459,10 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
||||||
state.color_space = c;
|
state.color_space = c;
|
||||||
to_send |= DRM_COLOR_SPACE_INFO;
|
to_send |= DRM_COLOR_SPACE_INFO;
|
||||||
}
|
}
|
||||||
|
HeadOp::SetBrightness(b) => {
|
||||||
|
state.brightness = b;
|
||||||
|
to_send |= BRIGHTNESS_INFO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if to_send.contains(CORE_INFO)
|
if to_send.contains(CORE_INFO)
|
||||||
|
|
@ -517,6 +521,11 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
||||||
{
|
{
|
||||||
i.send_state(state);
|
i.send_state(state);
|
||||||
}
|
}
|
||||||
|
if to_send.contains(BRIGHTNESS_INFO)
|
||||||
|
&& let Some(i) = &head.ext.brightness_info_v1
|
||||||
|
{
|
||||||
|
i.send_brightness(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
slf.schedule_transaction_result(req.result, None)?;
|
slf.schedule_transaction_result(req.result, None)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -554,6 +563,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
||||||
node.update_transform(desired.transform);
|
node.update_transform(desired.transform);
|
||||||
node.set_vrr_mode(VrrMode::from_config(desired.vrr_mode).unwrap());
|
node.set_vrr_mode(VrrMode::from_config(desired.vrr_mode).unwrap());
|
||||||
node.set_tearing_mode(TearingMode::from_config(desired.tearing_mode).unwrap());
|
node.set_tearing_mode(TearingMode::from_config(desired.tearing_mode).unwrap());
|
||||||
|
node.set_brightness(desired.brightness);
|
||||||
} else if let Some(mi) = &desired.monitor_info {
|
} else if let Some(mi) = &desired.monitor_info {
|
||||||
let pos = &self.client.state.persistent_output_states;
|
let pos = &self.client.state.persistent_output_states;
|
||||||
let pos = match pos.get(&mi.output_id) {
|
let pos = match pos.get(&mi.output_id) {
|
||||||
|
|
@ -579,6 +589,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
||||||
.set(VrrMode::from_config(desired.vrr_mode).unwrap());
|
.set(VrrMode::from_config(desired.vrr_mode).unwrap());
|
||||||
pos.tearing_mode
|
pos.tearing_mode
|
||||||
.set(TearingMode::from_config(desired.tearing_mode).unwrap());
|
.set(TearingMode::from_config(desired.tearing_mode).unwrap());
|
||||||
|
pos.brightness.set(desired.brightness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slf.schedule_transaction_result(req.result, None)?;
|
slf.schedule_transaction_result(req.result, None)?;
|
||||||
|
|
|
||||||
11
wire/jay_head_ext_brightness_setter_v1.txt
Normal file
11
wire/jay_head_ext_brightness_setter_v1.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
request destroy (destructor) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
request unset_brightness {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
request set_brightness {
|
||||||
|
lux: u32,
|
||||||
|
}
|
||||||
7
wire/jay_head_manager_ext_brightness_setter_v1.txt
Normal file
7
wire/jay_head_manager_ext_brightness_setter_v1.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
request destroy (destructor) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event head {
|
||||||
|
head: id(jay_head_ext_brightness_setter_v1) (new),
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue