blob: eabf53d58f923baa07a574f6787a92993c55658c [file] [log] [blame]
Alan Coxa8978542011-07-05 15:36:47 +01001/*
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>
Paul Gortmaker3f934e02011-09-15 18:21:58 -040029#include <linux/moduleparam.h>
Alan Coxa8978542011-07-05 15:36:47 +010030#include "mdfld_dsi_dbi.h"
31#include "mdfld_dsi_dpi.h"
32#include "mdfld_dsi_output.h"
33#include "mdfld_output.h"
Alan Cox3a970ac2011-07-15 17:35:49 +010034#include "mdfld_dsi_dbi_dpu.h"
Alan Coxa8978542011-07-05 15:36:47 +010035
36#include "displays/tpo_cmd.h"
37#include "displays/tpo_vid.h"
38#include "displays/tmd_cmd.h"
39#include "displays/tmd_vid.h"
40#include "displays/pyr_cmd.h"
41#include "displays/pyr_vid.h"
42/* #include "displays/hdmi.h" */
43
Alan Cox3a970ac2011-07-15 17:35:49 +010044static int mdfld_dual_mipi;
45static int mdfld_hdmi;
46static int mdfld_dpu;
47
48module_param(mdfld_dual_mipi, int, 0600);
49MODULE_PARM_DESC(mdfld_dual_mipi, "Enable dual MIPI configuration");
50module_param(mdfld_hdmi, int, 0600);
51MODULE_PARM_DESC(mdfld_hdmi, "Enable Medfield HDMI");
52module_param(mdfld_dpu, int, 0600);
53MODULE_PARM_DESC(mdfld_dpu, "Enable Medfield DPU");
54
Alan Coxa8978542011-07-05 15:36:47 +010055/* For now a single type per device is all we cope with */
56int mdfld_get_panel_type(struct drm_device *dev, int pipe)
57{
58 struct drm_psb_private *dev_priv = dev->dev_private;
59 return dev_priv->panel_id;
60}
61
62int mdfld_panel_dpi(struct drm_device *dev)
63{
64 struct drm_psb_private *dev_priv = dev->dev_private;
65
66 switch (dev_priv->panel_id) {
67 case TMD_VID:
68 case TPO_VID:
69 case PYR_VID:
70 return true;
71 case TMD_CMD:
72 case TPO_CMD:
73 case PYR_CMD:
74 default:
75 return false;
76 }
77}
78
Alan Cox92367fe12011-07-05 15:38:26 +010079static int init_panel(struct drm_device *dev, int mipi_pipe, int p_type)
Alan Coxa8978542011-07-05 15:36:47 +010080{
81 struct panel_funcs *p_cmd_funcs;
82 struct panel_funcs *p_vid_funcs;
83
84 /* Oh boy ... FIXME */
85 p_cmd_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
Alan Cox92367fe12011-07-05 15:38:26 +010086 if (p_cmd_funcs == NULL)
87 return -ENODEV;
Alan Coxa8978542011-07-05 15:36:47 +010088 p_vid_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
Alan Cox92367fe12011-07-05 15:38:26 +010089 if (p_vid_funcs == NULL) {
90 kfree(p_cmd_funcs);
91 return -ENODEV;
92 }
Alan Coxa8978542011-07-05 15:36:47 +010093
94 switch (p_type) {
95 case TPO_CMD:
96 tpo_cmd_init(dev, p_cmd_funcs);
97 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
98 break;
99 case TPO_VID:
100 tpo_vid_init(dev, p_vid_funcs);
101 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
102 break;
103 case TMD_CMD:
104 /*tmd_cmd_init(dev, p_cmd_funcs); */
105 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
106 break;
107 case TMD_VID:
108 tmd_vid_init(dev, p_vid_funcs);
109 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
110 break;
111 case PYR_CMD:
112 pyr_cmd_init(dev, p_cmd_funcs);
113 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs, NULL);
114 break;
115 case PYR_VID:
Alan Coxa8978542011-07-05 15:36:47 +0100116 mdfld_dsi_output_init(dev, mipi_pipe, NULL, NULL, p_vid_funcs);
117 break;
118 case TPO: /* TPO panel supports both cmd & vid interfaces */
119 tpo_cmd_init(dev, p_cmd_funcs);
120 tpo_vid_init(dev, p_vid_funcs);
121 mdfld_dsi_output_init(dev, mipi_pipe, NULL, p_cmd_funcs,
122 p_vid_funcs);
123 break;
124 case TMD:
125 break;
126 case PYR:
127 break;
128#if 0
129 case HDMI:
130 dev_dbg(dev->dev, "Initializing HDMI");
131 mdfld_hdmi_init(dev, &dev_priv->mode_dev);
132 break;
133#endif
134 default:
135 dev_err(dev->dev, "Unsupported interface %d", p_type);
Alan Cox92367fe12011-07-05 15:38:26 +0100136 return -ENODEV;
Alan Coxa8978542011-07-05 15:36:47 +0100137 }
Alan Cox92367fe12011-07-05 15:38:26 +0100138 return 0;
Alan Coxa8978542011-07-05 15:36:47 +0100139}
140
Alan Cox92367fe12011-07-05 15:38:26 +0100141int mdfld_output_init(struct drm_device *dev)
Alan Coxa8978542011-07-05 15:36:47 +0100142{
143 int type;
144
145 /* MIPI panel 1 */
146 type = mdfld_get_panel_type(dev, 0);
147 dev_info(dev->dev, "panel 1: type is %d\n", type);
148 init_panel(dev, 0, type);
149
Alan Cox3a970ac2011-07-15 17:35:49 +0100150 if (mdfld_dual_mipi) {
151 /* MIPI panel 2 */
152 type = mdfld_get_panel_type(dev, 2);
153 dev_info(dev->dev, "panel 2: type is %d\n", type);
154 init_panel(dev, 2, type);
155 }
156 if (mdfld_hdmi)
157 /* HDMI panel */
158 init_panel(dev, 0, HDMI);
Alan Cox92367fe12011-07-05 15:38:26 +0100159 return 0;
Alan Coxa8978542011-07-05 15:36:47 +0100160}
Alan Cox3a970ac2011-07-15 17:35:49 +0100161
162void mdfld_output_setup(struct drm_device *dev)
163{
164 /* FIXME: this is not the right place for this stuff ! */
165 if (IS_MFLD(dev)) {
166 if (mdfld_dpu)
167 mdfld_dbi_dpu_init(dev);
168 else
169 mdfld_dbi_dsr_init(dev);
170 }
Paul Gortmaker3f934e02011-09-15 18:21:58 -0400171}