bpf: Prevent memory disambiguation attack
[linux/fpc-iii.git] / drivers / gpu / drm / sun4i / sunxi_engine.h
blob4cb70ae65c79c1577d3e7dd2be3a6d2b6582df07
1 /*
2 * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 */
10 #ifndef _SUNXI_ENGINE_H_
11 #define _SUNXI_ENGINE_H_
13 struct drm_plane;
14 struct drm_device;
16 struct sunxi_engine;
18 struct sunxi_engine_ops {
19 void (*commit)(struct sunxi_engine *engine);
20 struct drm_plane **(*layers_init)(struct drm_device *drm,
21 struct sunxi_engine *engine);
23 void (*apply_color_correction)(struct sunxi_engine *engine);
24 void (*disable_color_correction)(struct sunxi_engine *engine);
27 /**
28 * struct sunxi_engine - the common parts of an engine for sun4i-drm driver
29 * @ops: the operations of the engine
30 * @node: the of device node of the engine
31 * @regs: the regmap of the engine
32 * @id: the id of the engine (-1 if not used)
34 struct sunxi_engine {
35 const struct sunxi_engine_ops *ops;
37 struct device_node *node;
38 struct regmap *regs;
40 int id;
42 /* Engine list management */
43 struct list_head list;
46 /**
47 * sunxi_engine_commit() - commit all changes of the engine
48 * @engine: pointer to the engine
50 static inline void
51 sunxi_engine_commit(struct sunxi_engine *engine)
53 if (engine->ops && engine->ops->commit)
54 engine->ops->commit(engine);
57 /**
58 * sunxi_engine_layers_init() - Create planes (layers) for the engine
59 * @drm: pointer to the drm_device for which planes will be created
60 * @engine: pointer to the engine
62 static inline struct drm_plane **
63 sunxi_engine_layers_init(struct drm_device *drm, struct sunxi_engine *engine)
65 if (engine->ops && engine->ops->layers_init)
66 return engine->ops->layers_init(drm, engine);
67 return ERR_PTR(-ENOSYS);
70 /**
71 * sunxi_engine_apply_color_correction - Apply the RGB2YUV color correction
72 * @engine: pointer to the engine
74 * This functionality is optional for an engine, however, if the engine is
75 * intended to be used with TV Encoder, the output will be incorrect
76 * without the color correction, due to TV Encoder expects the engine to
77 * output directly YUV signal.
79 static inline void
80 sunxi_engine_apply_color_correction(struct sunxi_engine *engine)
82 if (engine->ops && engine->ops->apply_color_correction)
83 engine->ops->apply_color_correction(engine);
86 /**
87 * sunxi_engine_disable_color_correction - Disable the color space correction
88 * @engine: pointer to the engine
90 * This function is paired with apply_color_correction().
92 static inline void
93 sunxi_engine_disable_color_correction(struct sunxi_engine *engine)
95 if (engine->ops && engine->ops->disable_color_correction)
96 engine->ops->disable_color_correction(engine);
98 #endif /* _SUNXI_ENGINE_H_ */