gma500: Medfield support
[pandora-kernel.git] / drivers / staging / gma500 / mdfld_output.c
1 /*
2  * Copyright (c)  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, sublicensen
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  * Thomas Eaton <thomas.g.eaton@intel.com>
25  * Scott Rowe <scott.m.rowe@intel.com>
26 */
27
28 #include <linux/init.h>
29 #include "mdfld_dsi_dbi.h"
30 #include "mdfld_dsi_dpi.h"
31 #include "mdfld_dsi_output.h"
32 #include "mdfld_output.h"
33
34 #include "displays/tpo_cmd.h"
35 #include "displays/tpo_vid.h"
36 #include "displays/tmd_cmd.h"
37 #include "displays/tmd_vid.h"
38 #include "displays/pyr_cmd.h"
39 #include "displays/pyr_vid.h"
40 /* #include "displays/hdmi.h" */
41
42 /* For now a single type per device is all we cope with */
43 int mdfld_get_panel_type(struct drm_device *dev, int pipe)
44 {
45         struct drm_psb_private *dev_priv = dev->dev_private;
46         return dev_priv->panel_id;
47 }
48
49 int mdfld_panel_dpi(struct drm_device *dev)
50 {
51         struct drm_psb_private *dev_priv = dev->dev_private;
52
53         switch (dev_priv->panel_id) {
54         case TMD_VID:
55         case TPO_VID:
56         case PYR_VID:
57                 return true;
58         case TMD_CMD:
59         case TPO_CMD:
60         case PYR_CMD:
61         default:
62                 return false;
63         }
64 }
65
66 static void init_panel(struct drm_device *dev, int mipi_pipe, int p_type)
67 {
68         struct panel_funcs *p_cmd_funcs;
69         struct panel_funcs *p_vid_funcs;
70
71         /* Oh boy ... FIXME */
72         p_cmd_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
73         p_vid_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
74
75         switch (p_type) {
76         case TPO_CMD:
77                 tpo_cmd_init(dev, p_cmd_funcs);
78                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
79                 break;
80         case TPO_VID:
81                 tpo_vid_init(dev, p_vid_funcs);
82                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
83                 break;
84         case TMD_CMD:
85                 /*tmd_cmd_init(dev, p_cmd_funcs); */
86                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
87                 break;
88         case TMD_VID:
89                 tmd_vid_init(dev, p_vid_funcs);
90                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
91                 break;
92         case PYR_CMD:
93                 pyr_cmd_init(dev, p_cmd_funcs);
94                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
95                 break;
96         case PYR_VID:
97                 /*pyr_vid_init(dev, p_vid_funcs); */
98                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
99                 break;
100         case TPO:       /* TPO panel supports both cmd & vid interfaces */
101                 tpo_cmd_init(dev, p_cmd_funcs);
102                 tpo_vid_init(dev, p_vid_funcs);
103                 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs,
104                                       p_vid_funcs);
105                 break;
106         case TMD:
107                 break;
108         case PYR:
109                 break;
110 #if 0
111         case HDMI:
112                 dev_dbg(dev->dev, "Initializing HDMI");
113                 mdfld_hdmi_init(dev, &dev_priv->mode_dev);
114                 break;
115 #endif
116         default:
117                 dev_err(dev->dev, "Unsupported interface %d", p_type);
118                 break;
119         }
120 }
121
122 void mdfld_output_init(struct drm_device *dev)
123 {
124         int type;
125
126         /* MIPI panel 1 */
127         type = mdfld_get_panel_type(dev, 0);
128         dev_info(dev->dev, "panel 1: type is %d\n", type);
129         init_panel(dev, 0, type);
130
131         /* MIPI panel 2 */
132         type = mdfld_get_panel_type(dev, 2);
133         dev_info(dev->dev, "panel 2: type is %d\n", type);
134         init_panel(dev, 2, type);
135 }