1 /* SPDX-License-Identifier: MIT */
3 * Copyright (C) 2020 Red Hat, Inc.
6 * Hans de Goede <hdegoede@redhat.com>
9 #ifndef __DRM_PRIVACY_SCREEN_DRIVER_H__
10 #define __DRM_PRIVACY_SCREEN_DRIVER_H__
12 #include <linux/device.h>
13 #include <linux/list.h>
14 #include <linux/mutex.h>
15 #include <drm/drm_connector.h>
17 struct drm_privacy_screen;
20 * struct drm_privacy_screen_ops - drm_privacy_screen operations
22 * Defines the operations which the privacy-screen class code may call.
23 * These functions should be implemented by the privacy-screen driver.
25 struct drm_privacy_screen_ops {
27 * @set_sw_state: Called to request a change of the privacy-screen
28 * state. The privacy-screen class code contains a check to avoid this
29 * getting called when the hw_state reports the state is locked.
30 * It is the driver's responsibility to update sw_state and hw_state.
31 * This is always called with the drm_privacy_screen's lock held.
33 int (*set_sw_state)(struct drm_privacy_screen *priv,
34 enum drm_privacy_screen_status sw_state);
36 * @get_hw_state: Called to request that the driver gets the current
37 * privacy-screen state from the hardware and then updates sw_state and
38 * hw_state accordingly. This will be called by the core just before
39 * the privacy-screen is registered in sysfs.
41 void (*get_hw_state)(struct drm_privacy_screen *priv);
45 * struct drm_privacy_screen - central privacy-screen structure
47 * Central privacy-screen structure, this contains the struct device used
48 * to register the screen in sysfs, the screen's state, ops, etc.
50 struct drm_privacy_screen {
51 /** @dev: device used to register the privacy-screen in sysfs. */
53 /** @lock: mutex protection all fields in this struct. */
55 /** @list: privacy-screen devices list list-entry. */
56 struct list_head list;
57 /** @notifier_head: privacy-screen notifier head. */
58 struct blocking_notifier_head notifier_head;
60 * @ops: &struct drm_privacy_screen_ops for this privacy-screen.
61 * This is NULL if the driver has unregistered the privacy-screen.
63 const struct drm_privacy_screen_ops *ops;
65 * @sw_state: The privacy-screen's software state, see
66 * :ref:`Standard Connector Properties<standard_connector_properties>`
69 enum drm_privacy_screen_status sw_state;
71 * @hw_state: The privacy-screen's hardware state, see
72 * :ref:`Standard Connector Properties<standard_connector_properties>`
75 enum drm_privacy_screen_status hw_state;
77 * @drvdata: Private data owned by the privacy screen provider
83 void *drm_privacy_screen_get_drvdata(struct drm_privacy_screen *priv)
88 struct drm_privacy_screen *drm_privacy_screen_register(
89 struct device *parent, const struct drm_privacy_screen_ops *ops,
91 void drm_privacy_screen_unregister(struct drm_privacy_screen *priv);
93 void drm_privacy_screen_call_notifier_chain(struct drm_privacy_screen *priv);