1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright (C) 2020 Red Hat, Inc. 4 * 5 * Authors: 6 * Hans de Goede <hdegoede@redhat.com> 7 */ 8 9 #ifndef __DRM_PRIVACY_SCREEN_DRIVER_H__ 10 #define __DRM_PRIVACY_SCREEN_DRIVER_H__ 11 12 #include <linux/device.h> 13 #include <linux/list.h> 14 #include <linux/mutex.h> 15 #include <drm/drm_connector.h> 16 17 struct drm_privacy_screen; 18 19 /** 20 * struct drm_privacy_screen_ops - drm_privacy_screen operations 21 * 22 * Defines the operations which the privacy-screen class code may call. 23 * These functions should be implemented by the privacy-screen driver. 24 */ 25 struct drm_privacy_screen_ops { 26 /** 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. 32 */ 33 int (*set_sw_state)(struct drm_privacy_screen *priv, 34 enum drm_privacy_screen_status sw_state); 35 /** 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. 40 */ 41 void (*get_hw_state)(struct drm_privacy_screen *priv); 42 }; 43 44 /** 45 * struct drm_privacy_screen - central privacy-screen structure 46 * 47 * Central privacy-screen structure, this contains the struct device used 48 * to register the screen in sysfs, the screen's state, ops, etc. 49 */ 50 struct drm_privacy_screen { 51 /** @dev: device used to register the privacy-screen in sysfs. */ 52 struct device dev; 53 /** @lock: mutex protection all fields in this struct. */ 54 struct mutex lock; 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; 59 /** 60 * @ops: &struct drm_privacy_screen_ops for this privacy-screen. 61 * This is NULL if the driver has unregistered the privacy-screen. 62 */ 63 const struct drm_privacy_screen_ops *ops; 64 /** 65 * @sw_state: The privacy-screen's software state, see 66 * :ref:`Standard Connector Properties<standard_connector_properties>` 67 * for more info. 68 */ 69 enum drm_privacy_screen_status sw_state; 70 /** 71 * @hw_state: The privacy-screen's hardware state, see 72 * :ref:`Standard Connector Properties<standard_connector_properties>` 73 * for more info. 74 */ 75 enum drm_privacy_screen_status hw_state; 76 /** 77 * @drvdata: Private data owned by the privacy screen provider 78 */ 79 void *drvdata; 80 }; 81 82 static inline 83 void *drm_privacy_screen_get_drvdata(struct drm_privacy_screen *priv) 84 { 85 return priv->drvdata; 86 } 87 88 struct drm_privacy_screen *drm_privacy_screen_register( 89 struct device *parent, const struct drm_privacy_screen_ops *ops, 90 void *data); 91 void drm_privacy_screen_unregister(struct drm_privacy_screen *priv); 92 93 void drm_privacy_screen_call_notifier_chain(struct drm_privacy_screen *priv); 94 95 #endif 96