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.
10 #ifndef _SUNXI_ENGINE_H_
11 #define _SUNXI_ENGINE_H_
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);
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)
35 const struct sunxi_engine_ops *ops;
37 struct device_node *node;
42 /* Engine list management */
43 struct list_head list;
47 * sunxi_engine_commit() - commit all changes of the engine
48 * @engine: pointer to the engine
51 sunxi_engine_commit(struct sunxi_engine *engine)
53 if (engine->ops && engine->ops->commit)
54 engine->ops->commit(engine);
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);
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.
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);
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().
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_ */