Re: RFC: Drm-connector properties managed by another driver / privacy screen support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

On 4/24/20 11:08 AM, Pekka Paalanen wrote:
On Fri, 24 Apr 2020 10:24:31 +0200
Hans de Goede <hdegoede@xxxxxxxxxx> wrote:

<snip>

Agree on the hw-state prop reflecting the actual hardware state at
all times, that one is easy.

However, when userspace sets "privacy-screen-sw-state", the driver
should attempt to change hardware state regardless of whether the
"privacy-screen-sw-state" value changes compared to its old value or
not. Otherwise userspace cannot intentionally override a hardware
hotkey setting if possible (or would need two atomic commits to do it).

Ack / agreed.

Mind, the above paragraph is only what I interpreted from this email
thread here. Previously I did not think that with atomic KMS, setting a
property to a value it already has could trigger anything. But I guess
it can?

In a way. My idea for the "privacy-screen-sw-state" is for it to reflect
the last requested value, where the request could come from either a
firmware controlled hotkey; or from userspace (this seems to be where
our ideas of how to handle this diverts).

So what can happen is (with both props being always in sync)
-userspace reads privacy screen being off
-user toggles privacy screen on through firmware controlled hotkey
-kernel gets notified about state toggle, updates both property
   states to on
-userspace commits its old knowledge of the property (off), thereby
   triggering the kernel to turn the privacy screen back off

So in this case from the kernel pov the property is actually set
to a new value, not to "a value it already has".

Hi,

that is an interesting point of view.

You are keeping the separation between "wanted" and "actual" state, but
counting firmware/hardware hotkeys as "want" instead of letting them
silently change hardware state.

Right, that seems more natural to me, as mentioned
already, this way the wanted and hw state only get out
of sync if the hw is locked to a certain state.

That seems ok.

Note there can be races here of course, but lets ignore those (for now).
Both the hotkey event as well as userspace changing the setting will be
end-user triggered events and will not happen at high frequency.
Also I see no way to completely eliminate racing here. Luckily the side
effects of the race or pretty harmless (annoying maybe, but not causing
crashes, etc).

This design is based on that it can.
What is not clear to me is if any change to"privacy-screen-hw-state"
shall be propagated to "privacy-screen-sw-state"?
   - If yes, then I think we are not solving any problems of single property.
   - If no, then why do we require userspace to write to sw state only
if something has changed?

No. As already written, the kernel must not change the value of
"privacy-screen-sw-state", only userspace can.

So this is where out view of how to handle this differs, I do
not see the hotkey changing the state as different from userspace
changing it. The reason for me to have both a sw- and a hw-state
is in case there is a physical switch (typically a slider style
switch) which forces the state to on / off. In this case userspace
could still set the "privacy-screen-sw-state" prop and then
the 2 could differ.

Yes, the locked switch case definitely makes sense to me.

If userspace has to avoid setting the sw property unless it actually
intends to change it, then the sw property being controlled from
multiple sources (firmware, hotkey, the /proc file below) could work.
It would even tell the KMS client when someone else changed the
"wanted" state.

Right, that is the idea and telling the KMS client definitely
is a feature we want, so that we can show an OSD notifcation
on the firmware handled hotkey presses, like we already do for volume
control/mute, (kbd) backlight changes, etc.

Lets add one more complication to this, which I think helps.
Currently the thinkpad_acpi driver exports the privacy screen as:

/proc/acpi/ibm/lcdshadow

Userspace can write this and then change the privacy-screen
setting, this is in shipped kernels and cannot be dropped
because it is part if the kernel's uABI now.
This means that another userspace process can change the
property underneath a kms client. I do not see how this is
different from the firmware changing the setting based on
a hotkey press. Yet if we stick with your "only userspace can"
change the sw-state setting, then does this count as userspace,
or do you mean only a kms client can ?  And then how is
another kms-client changing the setting different ?

To me that would be similar to firmware changing hardware state: it's
not the KMS client (the display server) doing it, but something else
behind its back while it thinks it's in full control.

Doing things behind the display server's back is what creates all the
mess here.

Right, unfortunately this is not something which we can change.
I have asked Lenovo if it will be possible to just have the hotkey
send keypresses and let userspace deal with it. This might happen
on future hardware generations. But then again it might not and
for the current hardware gen. we are stuck with the firmware
handling it.

Another KMS client cannot set the property behind the display server's
back, because the display server is holding DRM master, and the
property cannot be written without DRM master status. If the display
server drops DRM master, it knows it probably lost all state.

True.

So to me to avoid confusion the only valid case where the
hw- and sw-state can differ is if userspace requests
say "off" as state while the privacy screen is forced on
by say a physical switch (or e.g. a BIOS option to lock it?).

Then we would remember the off in sw-state but hw-state would
still be on.

I guess that maybe for the enum of the hw-state we need 4 values
instead of 2:

Enabled
Disabled
Enabled, locked
Disabled, locked

To indicate to userspace that atm the state cannot be changed.

If userspace needs that information, sure.

Yes I believe that userspace will want to know when the state is locked.
Currently when wifi is disable through a hardware switch, like
the sliders on the side of (usually somewhat older) laptops, then e.g.
GNOME will show "Disabled in hardware" (the wording could do with
some work) at the place where you would normally run wifi on/off and
select the network to use.

This makes me think that a driver needs to handle different types of
switches/hotkeys through different properties:

- For a hardware latching switch that forces the shield state to be one
   and not the other, it should change the hw-state but it does not seem
   to have a reason to change the sw-state property: it's not a "want",
   it's a hard setting. Changing sw-state would also lose the userspace
   preference of the setting.

Yes, I completely agree.

- For momentary button or a hotkey that is supposed to just toggle the
   shield state, it would toggle sw-state property since it's a "want"
   that can be overridden. Setting the property leads to changing the
   hw-state as well (if not locked).

Also agreed, although in practice the firmware may actually change
the hw state itself (if not locked), but we would then update both the sw
and hw props to reflect this.

Does that make sense?

Yes this makes sense to me. Now we just need to write it all down in
such a way so that other people will also understand it :)

Maybe this is the best compromise given the display server cannot be in
full control.

I agree that this seems to be the best compromise.

If userspace then still changes sw-state we cache it and apply
this if the privacy screen control gets unlocked.

Sounds good.

On hardware where there is no "lock" the 2 properties will simply
always be the same.

Ok.

Regards,

Hans

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux