Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[pandora-kernel.git] / drivers / staging / gma500 / mdfld_dsi_output.h
1 /*
2  * Copyright © 2010 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  * jim liu <jim.liu@intel.com>
25  * Jackie Li<yaodong.li@intel.com>
26  */
27
28 #ifndef __MDFLD_DSI_OUTPUT_H__
29 #define __MDFLD_DSI_OUTPUT_H__
30
31 #include <linux/backlight.h>
32 #include <drm/drmP.h>
33 #include <drm/drm.h>
34 #include <drm/drm_crtc.h>
35 #include <drm/drm_edid.h>
36
37 #include "psb_drv.h"
38 #include "psb_intel_drv.h"
39 #include "psb_intel_reg.h"
40 #include "power.h"
41 #include "mdfld_output.h"
42
43 #include <asm/mrst.h>
44
45
46 static inline struct mdfld_dsi_config *
47         mdfld_dsi_get_config(struct mdfld_dsi_connector *connector)
48 {
49         if (!connector)
50                 return NULL;
51         return (struct mdfld_dsi_config *)connector->private;
52 }
53
54 static inline void *mdfld_dsi_get_pkg_sender(struct mdfld_dsi_config *config)
55 {
56         struct mdfld_dsi_connector *dsi_connector;
57
58         if (!config)
59                 return NULL;
60
61         dsi_connector = config->connector;
62
63         if (!dsi_connector)
64                 return NULL;
65
66         return dsi_connector->pkg_sender;
67 }
68
69 static inline struct mdfld_dsi_config *
70         mdfld_dsi_encoder_get_config(struct mdfld_dsi_encoder *encoder)
71 {
72         if (!encoder)
73                 return NULL;
74         return (struct mdfld_dsi_config *)encoder->private;
75 }
76
77 static inline struct mdfld_dsi_connector *
78         mdfld_dsi_encoder_get_connector(struct mdfld_dsi_encoder *encoder)
79 {
80         struct mdfld_dsi_config *config;
81
82         if (!encoder)
83                 return NULL;
84
85         config = mdfld_dsi_encoder_get_config(encoder);
86         if (!config)
87                 return NULL;
88
89         return config->connector;
90 }
91
92 static inline void *mdfld_dsi_encoder_get_pkg_sender(
93         struct mdfld_dsi_encoder *encoder)
94 {
95         struct mdfld_dsi_config *dsi_config;
96
97         dsi_config = mdfld_dsi_encoder_get_config(encoder);
98         if (!dsi_config)
99                 return NULL;
100
101         return mdfld_dsi_get_pkg_sender(dsi_config);
102 }
103
104 static inline int mdfld_dsi_encoder_get_pipe(struct mdfld_dsi_encoder *encoder)
105 {
106         struct mdfld_dsi_connector *connector;
107
108         if (!encoder)
109                 return -1;
110
111         connector = mdfld_dsi_encoder_get_connector(encoder);
112         if (!connector)
113                 return -1;
114
115         return connector->pipe;
116 }
117
118 extern void mdfld_dsi_gen_fifo_ready(struct drm_device *dev,
119                                 u32 gen_fifo_stat_reg, u32 fifo_stat);
120 extern void mdfld_dsi_brightness_init(struct mdfld_dsi_config *dsi_config,
121                                 int pipe);
122 extern void mdfld_dsi_brightness_control(struct drm_device *dev, int pipe,
123                                 int level);
124 extern void mdfld_dsi_output_init(struct drm_device *dev, int pipe,
125                                 struct mdfld_dsi_config *config,
126                                 struct panel_funcs *p_cmd_funcs,
127                                 struct panel_funcs *p_vid_funcs);
128 extern void mdfld_dsi_controller_init(struct mdfld_dsi_config *dsi_config,
129                                 int pipe);
130 extern int mdfld_dsi_get_power_mode(struct mdfld_dsi_config *dsi_config,
131                                 u32 *mode,
132                                 u8 transmission);
133 extern int mdfld_dsi_get_diagnostic_result(struct mdfld_dsi_config *dsi_config,
134                                 u32 *result,
135                                 u8 transmission);
136 extern int mdfld_dsi_panel_reset(int pipe);
137
138 #endif /*__MDFLD_DSI_OUTPUT_H__*/