drm_privacy_screen_driver.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (C) 2020 Red Hat, Inc.
  4. *
  5. * Authors:
  6. * Hans de Goede <[email protected]>
  7. */
  8. #ifndef __DRM_PRIVACY_SCREEN_DRIVER_H__
  9. #define __DRM_PRIVACY_SCREEN_DRIVER_H__
  10. #include <linux/device.h>
  11. #include <linux/list.h>
  12. #include <linux/mutex.h>
  13. #include <drm/drm_connector.h>
  14. struct drm_privacy_screen;
  15. /**
  16. * struct drm_privacy_screen_ops - drm_privacy_screen operations
  17. *
  18. * Defines the operations which the privacy-screen class code may call.
  19. * These functions should be implemented by the privacy-screen driver.
  20. */
  21. struct drm_privacy_screen_ops {
  22. /**
  23. * @set_sw_state: Called to request a change of the privacy-screen
  24. * state. The privacy-screen class code contains a check to avoid this
  25. * getting called when the hw_state reports the state is locked.
  26. * It is the driver's responsibility to update sw_state and hw_state.
  27. * This is always called with the drm_privacy_screen's lock held.
  28. */
  29. int (*set_sw_state)(struct drm_privacy_screen *priv,
  30. enum drm_privacy_screen_status sw_state);
  31. /**
  32. * @get_hw_state: Called to request that the driver gets the current
  33. * privacy-screen state from the hardware and then updates sw_state and
  34. * hw_state accordingly. This will be called by the core just before
  35. * the privacy-screen is registered in sysfs.
  36. */
  37. void (*get_hw_state)(struct drm_privacy_screen *priv);
  38. };
  39. /**
  40. * struct drm_privacy_screen - central privacy-screen structure
  41. *
  42. * Central privacy-screen structure, this contains the struct device used
  43. * to register the screen in sysfs, the screen's state, ops, etc.
  44. */
  45. struct drm_privacy_screen {
  46. /** @dev: device used to register the privacy-screen in sysfs. */
  47. struct device dev;
  48. /** @lock: mutex protection all fields in this struct. */
  49. struct mutex lock;
  50. /** @list: privacy-screen devices list list-entry. */
  51. struct list_head list;
  52. /** @notifier_head: privacy-screen notifier head. */
  53. struct blocking_notifier_head notifier_head;
  54. /**
  55. * @ops: &struct drm_privacy_screen_ops for this privacy-screen.
  56. * This is NULL if the driver has unregistered the privacy-screen.
  57. */
  58. const struct drm_privacy_screen_ops *ops;
  59. /**
  60. * @sw_state: The privacy-screen's software state, see
  61. * :ref:`Standard Connector Properties<standard_connector_properties>`
  62. * for more info.
  63. */
  64. enum drm_privacy_screen_status sw_state;
  65. /**
  66. * @hw_state: The privacy-screen's hardware state, see
  67. * :ref:`Standard Connector Properties<standard_connector_properties>`
  68. * for more info.
  69. */
  70. enum drm_privacy_screen_status hw_state;
  71. /**
  72. * @drvdata: Private data owned by the privacy screen provider
  73. */
  74. void *drvdata;
  75. };
  76. static inline
  77. void *drm_privacy_screen_get_drvdata(struct drm_privacy_screen *priv)
  78. {
  79. return priv->drvdata;
  80. }
  81. struct drm_privacy_screen *drm_privacy_screen_register(
  82. struct device *parent, const struct drm_privacy_screen_ops *ops,
  83. void *data);
  84. void drm_privacy_screen_unregister(struct drm_privacy_screen *priv);
  85. void drm_privacy_screen_call_notifier_chain(struct drm_privacy_screen *priv);
  86. #endif