Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright (C) 2020 Red Hat, Inc.
0004  *
0005  * Authors:
0006  * Hans de Goede <hdegoede@redhat.com>
0007  */
0008 
0009 #ifndef __DRM_PRIVACY_SCREEN_DRIVER_H__
0010 #define __DRM_PRIVACY_SCREEN_DRIVER_H__
0011 
0012 #include <linux/device.h>
0013 #include <linux/list.h>
0014 #include <linux/mutex.h>
0015 #include <drm/drm_connector.h>
0016 
0017 struct drm_privacy_screen;
0018 
0019 /**
0020  * struct drm_privacy_screen_ops - drm_privacy_screen operations
0021  *
0022  * Defines the operations which the privacy-screen class code may call.
0023  * These functions should be implemented by the privacy-screen driver.
0024  */
0025 struct drm_privacy_screen_ops {
0026     /**
0027      * @set_sw_state: Called to request a change of the privacy-screen
0028      * state. The privacy-screen class code contains a check to avoid this
0029      * getting called when the hw_state reports the state is locked.
0030      * It is the driver's responsibility to update sw_state and hw_state.
0031      * This is always called with the drm_privacy_screen's lock held.
0032      */
0033     int (*set_sw_state)(struct drm_privacy_screen *priv,
0034                 enum drm_privacy_screen_status sw_state);
0035     /**
0036      * @get_hw_state: Called to request that the driver gets the current
0037      * privacy-screen state from the hardware and then updates sw_state and
0038      * hw_state accordingly. This will be called by the core just before
0039      * the privacy-screen is registered in sysfs.
0040      */
0041     void (*get_hw_state)(struct drm_privacy_screen *priv);
0042 };
0043 
0044 /**
0045  * struct drm_privacy_screen - central privacy-screen structure
0046  *
0047  * Central privacy-screen structure, this contains the struct device used
0048  * to register the screen in sysfs, the screen's state, ops, etc.
0049  */
0050 struct drm_privacy_screen {
0051     /** @dev: device used to register the privacy-screen in sysfs. */
0052     struct device dev;
0053     /** @lock: mutex protection all fields in this struct. */
0054     struct mutex lock;
0055     /** @list: privacy-screen devices list list-entry. */
0056     struct list_head list;
0057     /** @notifier_head: privacy-screen notifier head. */
0058     struct blocking_notifier_head notifier_head;
0059     /**
0060      * @ops: &struct drm_privacy_screen_ops for this privacy-screen.
0061      * This is NULL if the driver has unregistered the privacy-screen.
0062      */
0063     const struct drm_privacy_screen_ops *ops;
0064     /**
0065      * @sw_state: The privacy-screen's software state, see
0066      * :ref:`Standard Connector Properties<standard_connector_properties>`
0067      * for more info.
0068      */
0069     enum drm_privacy_screen_status sw_state;
0070     /**
0071      * @hw_state: The privacy-screen's hardware state, see
0072      * :ref:`Standard Connector Properties<standard_connector_properties>`
0073      * for more info.
0074      */
0075     enum drm_privacy_screen_status hw_state;
0076     /**
0077      * @drvdata: Private data owned by the privacy screen provider
0078      */
0079     void *drvdata;
0080 };
0081 
0082 static inline
0083 void *drm_privacy_screen_get_drvdata(struct drm_privacy_screen *priv)
0084 {
0085     return priv->drvdata;
0086 }
0087 
0088 struct drm_privacy_screen *drm_privacy_screen_register(
0089     struct device *parent, const struct drm_privacy_screen_ops *ops,
0090     void *data);
0091 void drm_privacy_screen_unregister(struct drm_privacy_screen *priv);
0092 
0093 void drm_privacy_screen_call_notifier_chain(struct drm_privacy_screen *priv);
0094 
0095 #endif