XenevaOS
Loading...
Searching...
No Matches
drm_panel.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013, NVIDIA Corporation. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef __DRM_PANEL_H__
25#define __DRM_PANEL_H__
26
27#include <linux/err.h>
28#include <linux/errno.h>
29#include <linux/list.h>
30#include <linux/mutex.h>
31#include <linux/kref.h>
32
33struct backlight_device;
34struct dentry;
35struct device_node;
36struct drm_connector;
38struct drm_panel;
39struct display_timing;
40
42
81 int (*prepare)(struct drm_panel *panel);
82
90 int (*enable)(struct drm_panel *panel);
91
99 int (*disable)(struct drm_panel *panel);
100
108 int (*unprepare)(struct drm_panel *panel);
109
118 int (*get_modes)(struct drm_panel *panel,
119 struct drm_connector *connector);
120
128 enum drm_panel_orientation (*get_orientation)(struct drm_panel *panel);
129
138 int (*get_timings)(struct drm_panel *panel, unsigned int num_timings,
139 struct display_timing *timings);
140
146 void (*debugfs_init)(struct drm_panel *panel, struct dentry *root);
147};
148
155 int (*panel_prepared)(struct drm_panel_follower *follower);
156
162 int (*panel_unpreparing)(struct drm_panel_follower *follower);
163
169 int (*panel_enabled)(struct drm_panel_follower *follower);
170
176 int (*panel_disabling)(struct drm_panel_follower *follower);
177};
178
186
193
200};
201
205struct drm_panel {
211 struct device *dev;
212
222 struct backlight_device *backlight;
223
229 const struct drm_panel_funcs *funcs;
230
239
246
253
260
270
277
284
290
295};
296
297void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offset,
298 const struct drm_panel_funcs *funcs,
299 int connector_type);
300
318#define devm_drm_panel_alloc(dev, type, member, funcs, connector_type) \
319 ((type *)__devm_drm_panel_alloc(dev, sizeof(type), \
320 offsetof(type, member), funcs, \
321 connector_type))
322
323struct drm_panel *drm_panel_get(struct drm_panel *panel);
324void drm_panel_put(struct drm_panel *panel);
325
326void drm_panel_add(struct drm_panel *panel);
327void drm_panel_remove(struct drm_panel *panel);
328int devm_drm_panel_add(struct device *dev, struct drm_panel *panel);
329
330void drm_panel_prepare(struct drm_panel *panel);
331void drm_panel_unprepare(struct drm_panel *panel);
332
333void drm_panel_enable(struct drm_panel *panel);
334void drm_panel_disable(struct drm_panel *panel);
335
336int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector);
337
338#if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL)
339struct drm_panel *of_drm_find_panel(const struct device_node *np);
340int of_drm_get_panel_orientation(const struct device_node *np,
341 enum drm_panel_orientation *orientation);
342#else
343static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
344{
345 return ERR_PTR(-ENODEV);
346}
347
348static inline int of_drm_get_panel_orientation(const struct device_node *np,
349 enum drm_panel_orientation *orientation)
350{
351 return -ENODEV;
352}
353#endif
354
355#if defined(CONFIG_DRM_PANEL)
356bool drm_is_panel_follower(struct device *dev);
357int drm_panel_add_follower(struct device *follower_dev,
358 struct drm_panel_follower *follower);
359void drm_panel_remove_follower(struct drm_panel_follower *follower);
360int devm_drm_panel_add_follower(struct device *follower_dev,
361 struct drm_panel_follower *follower);
362#else
363static inline bool drm_is_panel_follower(struct device *dev)
364{
365 return false;
366}
367
368static inline int drm_panel_add_follower(struct device *follower_dev,
369 struct drm_panel_follower *follower)
370{
371 return -ENODEV;
372}
373
374static inline void drm_panel_remove_follower(struct drm_panel_follower *follower) { }
375static inline int devm_drm_panel_add_follower(struct device *follower_dev,
376 struct drm_panel_follower *follower)
377{
378 return -ENODEV;
379}
380#endif
381
382#if IS_ENABLED(CONFIG_DRM_PANEL) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
383 (IS_MODULE(CONFIG_DRM) && IS_MODULE(CONFIG_BACKLIGHT_CLASS_DEVICE)))
384int drm_panel_of_backlight(struct drm_panel *panel);
385#else
386static inline int drm_panel_of_backlight(struct drm_panel *panel)
387{
388 return 0;
389}
390#endif
391
392#endif
#define ENODEV
Definition acclib.h:197
size_t size
Definition drm_bridge.h:1299
size_t size_t const struct drm_bridge_funcs * funcs
Definition drm_bridge.h:1300
size_t size_t offset
Definition drm_bridge.h:1299
drm_panel_orientation
Definition drm_connector.h:374
struct drm_panel * drm_panel_get(struct drm_panel *panel)
void drm_panel_put(struct drm_panel *panel)
void drm_panel_remove(struct drm_panel *panel)
void * __devm_drm_panel_alloc(struct device *dev, size_t size, size_t offset, const struct drm_panel_funcs *funcs, int connector_type)
void drm_panel_add(struct drm_panel *panel)
void drm_panel_unprepare(struct drm_panel *panel)
int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector)
void drm_panel_enable(struct drm_panel *panel)
void drm_panel_prepare(struct drm_panel *panel)
void drm_panel_disable(struct drm_panel *panel)
int devm_drm_panel_add(struct device *dev, struct drm_panel *panel)
const struct device * dev
Definition drm_print.h:519
#define ERR_PTR(err)
Definition err.h:51
Definition fs.h:255
Definition display_timing.h:63
Definition drm_connector.h:1998
Definition drm_panel.h:149
int(* panel_unpreparing)(struct drm_panel_follower *follower)
Definition drm_panel.h:162
int(* panel_disabling)(struct drm_panel_follower *follower)
Definition drm_panel.h:176
int(* panel_prepared)(struct drm_panel_follower *follower)
Definition drm_panel.h:155
int(* panel_enabled)(struct drm_panel_follower *follower)
Definition drm_panel.h:169
Definition drm_panel.h:179
const struct drm_panel_follower_funcs * funcs
Definition drm_panel.h:185
struct list_head list
Definition drm_panel.h:192
struct drm_panel * panel
Definition drm_panel.h:199
Definition drm_panel.h:73
int(* prepare)(struct drm_panel *panel)
Definition drm_panel.h:81
int(* disable)(struct drm_panel *panel)
Definition drm_panel.h:99
enum drm_panel_orientation(* get_orientation)(struct drm_panel *panel)
Definition drm_panel.h:128
int(* get_timings)(struct drm_panel *panel, unsigned int num_timings, struct display_timing *timings)
Definition drm_panel.h:138
void(* debugfs_init)(struct drm_panel *panel, struct dentry *root)
Definition drm_panel.h:146
int(* enable)(struct drm_panel *panel)
Definition drm_panel.h:90
int(* get_modes)(struct drm_panel *panel, struct drm_connector *connector)
Definition drm_panel.h:118
int(* unprepare)(struct drm_panel *panel)
Definition drm_panel.h:108
Definition drm_panel.h:205
const struct drm_panel_funcs * funcs
Definition drm_panel.h:229
struct list_head list
Definition drm_panel.h:245
struct mutex follower_lock
Definition drm_panel.h:259
struct list_head followers
Definition drm_panel.h:252
bool prepare_prev_first
Definition drm_panel.h:269
bool prepared
Definition drm_panel.h:276
int connector_type
Definition drm_panel.h:238
void * container
Definition drm_panel.h:289
bool enabled
Definition drm_panel.h:283
struct kref refcount
Definition drm_panel.h:294
struct backlight_device * backlight
Definition drm_panel.h:222
struct device * dev
Definition drm_panel.h:211
Definition kref.h:44
Definition list.h:11
Definition mutex.h:59
TTY * root
Definition tty.cpp:47