2 * Copyright (C) 2012 Google, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _EXYNOS_DRM_PANEL_H_
15 #define _EXYNOS_DRM_PANEL_H_
18 * Callbacks used to manipulate the panel (DP/HDMI/MIPI)
20 * @subdrv_probe: Used to associate drm_dev with panel context
21 * @is_connected: Returns true if the panel is connected
22 * @get_edid: Fills in edid with mode data from the panel
23 * @check_timing: Returns 0 if the given timing is valid for the panel
24 * @power: Sets the panel's power to mode
25 * @dpms: Same as power, but called in different places. Best to avoid it
26 * @mode_fixup: Copies and optionally alters mode to adjusted_mode
27 * @mode_set: Sets the panel to output mode
28 * @commit: Commits changes to the panel from mode_set
29 * @apply: Same as commit in most cases
30 * @get_max_res: Returns the maximum resolution in width/height
32 struct exynos_panel_ops {
33 int (*subdrv_probe)(void *ctx, struct drm_device *drm_dev);
34 bool (*is_connected)(void *ctx);
35 int (*get_edid)(void *ctx, struct drm_connector *connector,
37 int (*check_timing)(void *ctx, void *timing);
38 int (*power)(void *ctx, int mode);
39 int (*dpms)(void *ctx, int mode);
40 void (*mode_fixup)(void *ctx, struct drm_connector *connector,
41 struct drm_display_mode *mode,
42 struct drm_display_mode *adjusted_mode);
43 void (*mode_set)(void *ctx, void *mode);
44 void (*commit)(void *ctx);
45 void (*apply)(void *ctx);
46 void (*get_max_res)(void *ctx, unsigned int *width,
47 unsigned int *height);
51 * Callbacks used to manipulate the controller (FIMD/Mixer)
53 * @subdrv_probe: Used to associate drm_dev with the controller context
54 * @get_panel: If we're not using edid, return the panel info
55 * @enable_vblank: Enable the controller's vblank interrupt and set pipe
56 * @disable_vblank: Disable the controller's vblank interrupt
57 * @power: Sets the controller's power to mode
58 * @dpms: Same as power, but called in different places. Best to avoid it
59 * @mode_set: Sets the controller to output mode
60 * @page_flip: Updates the controller's dma pointer
61 * @commit: Applies controller level settings (as opposed to window level)
62 * @apply: Commits the changes on all of the controller's windows
63 * @win_commit: Commits the changes on only one window
64 * @win_disable: Disables one of the controller's windows
66 struct exynos_controller_ops {
67 int (*subdrv_probe)(void *ctx, struct drm_device *drm_dev);
68 struct exynos_drm_panel_info *(*get_panel)(void *ctx);
69 int (*enable_vblank)(void *ctx, int pipe);
70 void (*disable_vblank)(void *ctx);
71 int (*power)(void *ctx, int mode);
72 int (*dpms)(void *ctx, int mode);
73 void (*mode_set)(void *ctx, struct exynos_drm_overlay *overlay);
74 void (*page_flip)(void *ctx, struct exynos_drm_overlay *overlay);
75 void (*commit)(void *ctx);
76 void (*apply)(void *ctx);
77 void (*win_commit)(void *ctx, int zpos);
78 void (*win_disable)(void *ctx, int zpos);
81 enum exynos_drm_display_type {
82 EXYNOS_DRM_DISPLAY_TYPE_FIMD,
83 EXYNOS_DRM_DISPLAY_TYPE_MIXER,
84 EXYNOS_DRM_DISPLAY_TYPE_VIDI,
85 EXYNOS_DRM_DISPLAY_NUM_DISPLAYS,
89 * The various bits we need to keep track of to manipulate the hardware from
90 * the connector/encoder/crtc drm callbacks.
92 * @display_type: The type of display, depends on which CONFIGs are enabled
93 * @subdrv: The exynos drm sub driver pointer
94 * @panel_ops: The panel callbacks to use
95 * @controller_ops: The controller callbacks to use
96 * @panel_ctx: The context pointer to pass to panel callbacks
97 * @controller_ctx: The context pointer to pass to controller callbacks
98 * @pipe: The current pipe number for this display
100 struct exynos_drm_display {
101 enum exynos_drm_display_type display_type;
102 struct exynos_drm_subdrv *subdrv;
103 struct exynos_panel_ops *panel_ops;
104 struct exynos_controller_ops *controller_ops;
106 void *controller_ctx;
111 * Used by the hardware drivers to attach panel and controller callbacks and
112 * contexts to a display.
114 void exynos_display_attach_panel(enum exynos_drm_display_type type,
115 struct exynos_panel_ops *ops, void *ctx);
116 void exynos_display_attach_controller(enum exynos_drm_display_type type,
117 struct exynos_controller_ops *ops, void *ctx);
119 /* Initializes the given display to type */
120 int exynos_display_init(struct exynos_drm_display *display,
121 enum exynos_drm_display_type type);
123 /* Cleans up the given display */
124 void exynos_display_remove(struct exynos_drm_display *display);