hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/include/drm/drm_panel.h
....@@ -27,43 +27,18 @@
2727 #include <linux/err.h>
2828 #include <linux/errno.h>
2929 #include <linux/list.h>
30
-#include <linux/notifier.h>
3130
32
-/* A hardware display blank change occurred */
33
-#define DRM_PANEL_EVENT_BLANK 0x01
34
-/* A hardware display blank early change occurred */
35
-#define DRM_PANEL_EARLY_EVENT_BLANK 0x02
36
-
37
-enum {
38
- /* panel: power on */
39
- DRM_PANEL_BLANK_UNBLANK,
40
- /* panel: power off */
41
- DRM_PANEL_BLANK_POWERDOWN,
42
-};
43
-
44
-struct drm_panel_notifier {
45
- int refresh_rate;
46
- void *data;
47
- uint32_t id;
48
-};
49
-
31
+struct backlight_device;
5032 struct device_node;
5133 struct drm_connector;
5234 struct drm_device;
5335 struct drm_panel;
5436 struct display_timing;
5537
38
+enum drm_panel_orientation;
39
+
5640 /**
57
- * @loader_protect: protect loader logo panel's power
5841 * struct drm_panel_funcs - perform operations on a given panel
59
- * @disable: disable panel (turn off back light, etc.)
60
- * @unprepare: turn off panel
61
- * @prepare: turn on panel and perform set up
62
- * @enable: enable panel (turn on back light, etc.)
63
- * @get_modes: add modes to the connector that the panel is attached to and
64
- * return the number of modes added
65
- * @get_timings: copy display timings into the provided array and return
66
- * the number of display timings available
6742 *
6843 * The .prepare() function is typically called before the display controller
6944 * starts to transmit video data. Panel drivers can use this to turn the panel
....@@ -87,164 +62,157 @@
8762 *
8863 * To save power when no video data is transmitted, a driver can power down
8964 * the panel. This is the job of the .unprepare() function.
65
+ *
66
+ * Backlight can be handled automatically if configured using
67
+ * drm_panel_of_backlight(). Then the driver does not need to implement the
68
+ * functionality to enable/disable backlight.
9069 */
9170 struct drm_panel_funcs {
92
- int (*loader_protect)(struct drm_panel *panel, bool on);
93
- int (*disable)(struct drm_panel *panel);
94
- int (*unprepare)(struct drm_panel *panel);
71
+ /**
72
+ * @prepare:
73
+ *
74
+ * Turn on panel and perform set up.
75
+ *
76
+ * This function is optional.
77
+ */
9578 int (*prepare)(struct drm_panel *panel);
79
+
80
+ /**
81
+ * @enable:
82
+ *
83
+ * Enable panel (turn on back light, etc.).
84
+ *
85
+ * This function is optional.
86
+ */
9687 int (*enable)(struct drm_panel *panel);
97
- int (*get_modes)(struct drm_panel *panel);
88
+
89
+ /**
90
+ * @disable:
91
+ *
92
+ * Disable panel (turn off back light, etc.).
93
+ *
94
+ * This function is optional.
95
+ */
96
+ int (*disable)(struct drm_panel *panel);
97
+
98
+ /**
99
+ * @unprepare:
100
+ *
101
+ * Turn off panel.
102
+ *
103
+ * This function is optional.
104
+ */
105
+ int (*unprepare)(struct drm_panel *panel);
106
+
107
+ /**
108
+ * @get_modes:
109
+ *
110
+ * Add modes to the connector that the panel is attached to
111
+ * and returns the number of modes added.
112
+ *
113
+ * This function is mandatory.
114
+ */
115
+ int (*get_modes)(struct drm_panel *panel,
116
+ struct drm_connector *connector);
117
+
118
+ /**
119
+ * @get_timings:
120
+ *
121
+ * Copy display timings into the provided array and return
122
+ * the number of display timings available.
123
+ *
124
+ * This function is optional.
125
+ */
98126 int (*get_timings)(struct drm_panel *panel, unsigned int num_timings,
99127 struct display_timing *timings);
100128 };
101129
102130 /**
103131 * struct drm_panel - DRM panel object
104
- * @drm: DRM device owning the panel
105
- * @connector: DRM connector that the panel is attached to
106
- * @dev: parent device of the panel
107
- * @funcs: operations that can be performed on the panel
108
- * @list: panel entry in registry
109132 */
110133 struct drm_panel {
111
- struct drm_device *drm;
112
- struct drm_connector *connector;
134
+ /**
135
+ * @dev:
136
+ *
137
+ * Parent device of the panel.
138
+ */
113139 struct device *dev;
114140
115
- const struct drm_panel_funcs *funcs;
116
-
117
- struct list_head list;
141
+ /**
142
+ * @backlight:
143
+ *
144
+ * Backlight device, used to turn on backlight after the call
145
+ * to enable(), and to turn off backlight before the call to
146
+ * disable().
147
+ * backlight is set by drm_panel_of_backlight() and drivers
148
+ * shall not assign it.
149
+ */
150
+ struct backlight_device *backlight;
118151
119152 /**
120
- * @nh:
153
+ * @funcs:
121154 *
122
- * panel notifier list head
155
+ * Operations that can be performed on the panel.
123156 */
124
- struct blocking_notifier_head nh;
157
+ const struct drm_panel_funcs *funcs;
158
+
159
+ /**
160
+ * @connector_type:
161
+ *
162
+ * Type of the panel as a DRM_MODE_CONNECTOR_* value. This is used to
163
+ * initialise the drm_connector corresponding to the panel with the
164
+ * correct connector type.
165
+ */
166
+ int connector_type;
167
+
168
+ /**
169
+ * @list:
170
+ *
171
+ * Panel entry in registry.
172
+ */
173
+ struct list_head list;
125174 };
126175
127
-static inline int drm_panel_loader_protect(struct drm_panel *panel, bool on)
128
-{
129
- if (panel && panel->funcs && panel->funcs->loader_protect)
130
- return panel->funcs->loader_protect(panel, on);
176
+void drm_panel_init(struct drm_panel *panel, struct device *dev,
177
+ const struct drm_panel_funcs *funcs,
178
+ int connector_type);
131179
132
- return -EINVAL;
133
-}
134
-
135
-/**
136
- * drm_disable_unprepare - power off a panel
137
- * @panel: DRM panel
138
- *
139
- * Calling this function will completely power off a panel (assert the panel's
140
- * reset, turn off power supplies, ...). After this function has completed, it
141
- * is usually no longer possible to communicate with the panel until another
142
- * call to drm_panel_prepare().
143
- *
144
- * Return: 0 on success or a negative error code on failure.
145
- */
146
-static inline int drm_panel_unprepare(struct drm_panel *panel)
147
-{
148
- if (panel && panel->funcs && panel->funcs->unprepare)
149
- return panel->funcs->unprepare(panel);
150
-
151
- return panel ? -ENOSYS : -EINVAL;
152
-}
153
-
154
-/**
155
- * drm_panel_disable - disable a panel
156
- * @panel: DRM panel
157
- *
158
- * This will typically turn off the panel's backlight or disable the display
159
- * drivers. For smart panels it should still be possible to communicate with
160
- * the integrated circuitry via any command bus after this call.
161
- *
162
- * Return: 0 on success or a negative error code on failure.
163
- */
164
-static inline int drm_panel_disable(struct drm_panel *panel)
165
-{
166
- if (panel && panel->funcs && panel->funcs->disable)
167
- return panel->funcs->disable(panel);
168
-
169
- return panel ? -ENOSYS : -EINVAL;
170
-}
171
-
172
-/**
173
- * drm_panel_prepare - power on a panel
174
- * @panel: DRM panel
175
- *
176
- * Calling this function will enable power and deassert any reset signals to
177
- * the panel. After this has completed it is possible to communicate with any
178
- * integrated circuitry via a command bus.
179
- *
180
- * Return: 0 on success or a negative error code on failure.
181
- */
182
-static inline int drm_panel_prepare(struct drm_panel *panel)
183
-{
184
- if (panel && panel->funcs && panel->funcs->prepare)
185
- return panel->funcs->prepare(panel);
186
-
187
- return panel ? -ENOSYS : -EINVAL;
188
-}
189
-
190
-/**
191
- * drm_panel_enable - enable a panel
192
- * @panel: DRM panel
193
- *
194
- * Calling this function will cause the panel display drivers to be turned on
195
- * and the backlight to be enabled. Content will be visible on screen after
196
- * this call completes.
197
- *
198
- * Return: 0 on success or a negative error code on failure.
199
- */
200
-static inline int drm_panel_enable(struct drm_panel *panel)
201
-{
202
- if (panel && panel->funcs && panel->funcs->enable)
203
- return panel->funcs->enable(panel);
204
-
205
- return panel ? -ENOSYS : -EINVAL;
206
-}
207
-
208
-/**
209
- * drm_panel_get_modes - probe the available display modes of a panel
210
- * @panel: DRM panel
211
- *
212
- * The modes probed from the panel are automatically added to the connector
213
- * that the panel is attached to.
214
- *
215
- * Return: The number of modes available from the panel on success or a
216
- * negative error code on failure.
217
- */
218
-static inline int drm_panel_get_modes(struct drm_panel *panel)
219
-{
220
- if (panel && panel->funcs && panel->funcs->get_modes)
221
- return panel->funcs->get_modes(panel);
222
-
223
- return panel ? -ENOSYS : -EINVAL;
224
-}
225
-
226
-void drm_panel_init(struct drm_panel *panel);
227
-
228
-int drm_panel_add(struct drm_panel *panel);
180
+void drm_panel_add(struct drm_panel *panel);
229181 void drm_panel_remove(struct drm_panel *panel);
230182
231
-int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector);
232
-int drm_panel_detach(struct drm_panel *panel);
183
+int drm_panel_prepare(struct drm_panel *panel);
184
+int drm_panel_unprepare(struct drm_panel *panel);
233185
234
-int drm_panel_notifier_register(struct drm_panel *panel,
235
- struct notifier_block *nb);
236
-int drm_panel_notifier_unregister(struct drm_panel *panel,
237
- struct notifier_block *nb);
238
-int drm_panel_notifier_call_chain(struct drm_panel *panel,
239
- unsigned long val, void *v);
186
+int drm_panel_enable(struct drm_panel *panel);
187
+int drm_panel_disable(struct drm_panel *panel);
188
+
189
+int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector);
240190
241191 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL)
242192 struct drm_panel *of_drm_find_panel(const struct device_node *np);
193
+int of_drm_get_panel_orientation(const struct device_node *np,
194
+ enum drm_panel_orientation *orientation);
243195 #else
244196 static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
245197 {
246198 return ERR_PTR(-ENODEV);
247199 }
200
+
201
+static inline int of_drm_get_panel_orientation(const struct device_node *np,
202
+ enum drm_panel_orientation *orientation)
203
+{
204
+ return -ENODEV;
205
+}
206
+#endif
207
+
208
+#if IS_ENABLED(CONFIG_DRM_PANEL) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
209
+ (IS_MODULE(CONFIG_DRM) && IS_MODULE(CONFIG_BACKLIGHT_CLASS_DEVICE)))
210
+int drm_panel_of_backlight(struct drm_panel *panel);
211
+#else
212
+static inline int drm_panel_of_backlight(struct drm_panel *panel)
213
+{
214
+ return 0;
215
+}
248216 #endif
249217
250218 #endif