OSDN Git Service

01b1423996f55271a252284b0fbda726202ab936
[android-x86/external-libdrm.git] / linux-core / drm_crtc_helper.h
1 /*
2  * Copyright © 2006 Keith Packard
3  * Copyright © 2007 Intel Corporation
4  *   Jesse Barnes <jesse.barnes@intel.com>
5  */
6
7 /*
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
11  */
12
13 #ifndef __DRM_CRTC_HELPER_H__
14 #define __DRM_CRTC_HELPER_H__
15
16 #include <linux/i2c.h>
17 #include <linux/spinlock.h>
18 #include <linux/types.h>
19 #include <linux/idr.h>
20
21 #include <linux/fb.h>
22
23 struct drm_crtc_helper_funcs {
24         /*
25          * Control power levels on the CRTC.  If the mode passed in is
26          * unsupported, the provider must use the next lowest power level.
27          */
28         void (*dpms)(struct drm_crtc *crtc, int mode);
29         void (*prepare)(struct drm_crtc *crtc);
30         void (*commit)(struct drm_crtc *crtc);
31
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);
39
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);
42 };
43
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);
48
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);
59 };
60
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);
66 };
67         
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,
74                                      int x, int y);
75 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
76
77 extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
78                                           struct drm_mode_fb_cmd *mode_cmd,
79                                           void *mm_private);
80
81 static inline void drm_crtc_helper_add(struct drm_crtc *crtc, const struct drm_crtc_helper_funcs *funcs)
82 {
83         crtc->helper_private = (void *)funcs;
84 }
85
86 static inline void drm_encoder_helper_add(struct drm_encoder *encoder, const struct drm_encoder_helper_funcs *funcs)
87 {
88         encoder->helper_private = (void *)funcs;
89 }
90
91 static inline void drm_connector_helper_add(struct drm_connector *connector, const struct drm_connector_helper_funcs *funcs)
92 {
93         connector->helper_private = (void *)funcs;
94 }
95
96 extern int drm_helper_resume_force_mode(struct drm_device *dev);
97 #endif