2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
8 * The DRM mode setting helper functions are common code for drivers to use if they wish.
9 * Drivers are not forced to use this code in their implementations but it would be useful
10 * if they code they do use at least provides a consistent interface and operation to userspace
13 #ifndef __DRM_CRTC_HELPER_H__
14 #define __DRM_CRTC_HELPER_H__
16 #include <linux/i2c.h>
17 #include <linux/spinlock.h>
18 #include <linux/types.h>
19 #include <linux/idr.h>
23 struct drm_crtc_helper_funcs {
25 * Control power levels on the CRTC. If the mode passed in is
26 * unsupported, the provider must use the next lowest power level.
28 void (*dpms)(struct drm_crtc *crtc, int mode);
29 void (*prepare)(struct drm_crtc *crtc);
30 void (*commit)(struct drm_crtc *crtc);
32 /* Provider can fixup or change mode timings before modeset occurs */
33 bool (*mode_fixup)(struct drm_crtc *crtc,
34 struct drm_display_mode *mode,
35 struct drm_display_mode *adjusted_mode);
36 /* Actually set the mode */
37 void (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
38 struct drm_display_mode *adjusted_mode, int x, int y);
40 /* Move the crtc on the current fb to the given position *optional* */
41 void (*mode_set_base)(struct drm_crtc *crtc, int x, int y);
44 struct drm_encoder_helper_funcs {
45 void (*dpms)(struct drm_encoder *encoder, int mode);
46 void (*save)(struct drm_encoder *encoder);
47 void (*restore)(struct drm_encoder *encoder);
49 bool (*mode_fixup)(struct drm_encoder *encoder,
50 struct drm_display_mode *mode,
51 struct drm_display_mode *adjusted_mode);
52 void (*prepare)(struct drm_encoder *encoder);
53 void (*commit)(struct drm_encoder *encoder);
54 void (*mode_set)(struct drm_encoder *encoder,
55 struct drm_display_mode *mode,
56 struct drm_display_mode *adjusted_mode);
57 /* detect for DAC style encoders */
58 enum drm_connector_status (*detect)(struct drm_encoder *encoder, struct drm_connector *connector);
61 struct drm_connector_helper_funcs {
62 int (*get_modes)(struct drm_connector *connector);
63 int (*mode_valid)(struct drm_connector *connector,
64 struct drm_display_mode *mode);
65 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
68 extern void drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
69 extern void drm_helper_disable_unused_functions(struct drm_device *dev);
70 extern int drm_helper_hotplug_stage_two(struct drm_device *dev);
71 extern bool drm_helper_initial_config(struct drm_device *dev, bool can_grow);
72 extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
73 extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
75 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
77 extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
78 struct drm_mode_fb_cmd *mode_cmd);
80 static inline void drm_crtc_helper_add(struct drm_crtc *crtc, const struct drm_crtc_helper_funcs *funcs)
82 crtc->helper_private = (void *)funcs;
85 static inline void drm_encoder_helper_add(struct drm_encoder *encoder, const struct drm_encoder_helper_funcs *funcs)
87 encoder->helper_private = (void *)funcs;
90 static inline void drm_connector_helper_add(struct drm_connector *connector, const struct drm_connector_helper_funcs *funcs)
92 connector->helper_private = (void *)funcs;
95 extern int drm_get_buffer_object(struct drm_device *dev, struct drm_buffer_object **bo, unsigned long handle);