gma500: Fix dependencies
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / gma500 / mdfld_tpo_vid.c
blob954901751760a8e76ee192eb1da4dbd03afeb8e8
1 /*
2 * Copyright © 2010 Intel Corporation
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:
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.
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.
23 * Authors:
24 * jim liu <jim.liu@intel.com>
25 * Jackie Li<yaodong.li@intel.com>
28 #include "mdfld_dsi_dbi.h"
29 #include "mdfld_dsi_dpi.h"
30 #include "mdfld_dsi_output.h"
31 #include "mdfld_output.h"
33 #include "mdfld_dsi_pkg_sender.h"
35 #include "displays/tpo_vid.h"
37 static struct drm_display_mode *tpo_vid_get_config_mode(struct drm_device *dev)
39 struct drm_display_mode *mode;
40 struct drm_psb_private *dev_priv = dev->dev_private;
41 struct mrst_timing_info *ti = &dev_priv->gct_data.DTD;
42 bool use_gct = false;
44 mode = kzalloc(sizeof(*mode), GFP_KERNEL);
45 if (!mode) {
46 dev_err(dev->dev, "out of memory\n");
47 return NULL;
50 if (use_gct) {
51 mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo;
52 mode->vdisplay = (ti->vactive_hi << 8) | ti->vactive_lo;
53 mode->hsync_start = mode->hdisplay + \
54 ((ti->hsync_offset_hi << 8) | \
55 ti->hsync_offset_lo);
56 mode->hsync_end = mode->hsync_start + \
57 ((ti->hsync_pulse_width_hi << 8) | \
58 ti->hsync_pulse_width_lo);
59 mode->htotal = mode->hdisplay + ((ti->hblank_hi << 8) | \
60 ti->hblank_lo);
61 mode->vsync_start = \
62 mode->vdisplay + ((ti->vsync_offset_hi << 8) | \
63 ti->vsync_offset_lo);
64 mode->vsync_end = \
65 mode->vsync_start + ((ti->vsync_pulse_width_hi << 8) | \
66 ti->vsync_pulse_width_lo);
67 mode->vtotal = mode->vdisplay + \
68 ((ti->vblank_hi << 8) | ti->vblank_lo);
69 mode->clock = ti->pixel_clock * 10;
71 dev_dbg(dev->dev, "hdisplay is %d\n", mode->hdisplay);
72 dev_dbg(dev->dev, "vdisplay is %d\n", mode->vdisplay);
73 dev_dbg(dev->dev, "HSS is %d\n", mode->hsync_start);
74 dev_dbg(dev->dev, "HSE is %d\n", mode->hsync_end);
75 dev_dbg(dev->dev, "htotal is %d\n", mode->htotal);
76 dev_dbg(dev->dev, "VSS is %d\n", mode->vsync_start);
77 dev_dbg(dev->dev, "VSE is %d\n", mode->vsync_end);
78 dev_dbg(dev->dev, "vtotal is %d\n", mode->vtotal);
79 dev_dbg(dev->dev, "clock is %d\n", mode->clock);
80 } else {
81 mode->hdisplay = 864;
82 mode->vdisplay = 480;
83 mode->hsync_start = 873;
84 mode->hsync_end = 876;
85 mode->htotal = 887;
86 mode->vsync_start = 487;
87 mode->vsync_end = 490;
88 mode->vtotal = 499;
89 mode->clock = 33264;
92 drm_mode_set_name(mode);
93 drm_mode_set_crtcinfo(mode, 0);
95 mode->type |= DRM_MODE_TYPE_PREFERRED;
97 return mode;
100 static int tpo_vid_get_panel_info(struct drm_device *dev,
101 int pipe,
102 struct panel_info *pi)
104 if (!dev || !pi)
105 return -EINVAL;
107 pi->width_mm = TPO_PANEL_WIDTH;
108 pi->height_mm = TPO_PANEL_HEIGHT;
110 return 0;
113 /*TPO DPI encoder helper funcs*/
114 static const struct drm_encoder_helper_funcs
115 mdfld_tpo_dpi_encoder_helper_funcs = {
116 .dpms = mdfld_dsi_dpi_dpms,
117 .mode_fixup = mdfld_dsi_dpi_mode_fixup,
118 .prepare = mdfld_dsi_dpi_prepare,
119 .mode_set = mdfld_dsi_dpi_mode_set,
120 .commit = mdfld_dsi_dpi_commit,
123 /*TPO DPI encoder funcs*/
124 static const struct drm_encoder_funcs mdfld_tpo_dpi_encoder_funcs = {
125 .destroy = drm_encoder_cleanup,
128 void tpo_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs)
130 if (!dev || !p_funcs) {
131 dev_err(dev->dev, "tpo_vid_init: Invalid parameters\n");
132 return;
135 p_funcs->encoder_funcs = &mdfld_tpo_dpi_encoder_funcs;
136 p_funcs->encoder_helper_funcs = &mdfld_tpo_dpi_encoder_helper_funcs;
137 p_funcs->get_config_mode = &tpo_vid_get_config_mode;
138 p_funcs->update_fb = NULL;
139 p_funcs->get_panel_info = tpo_vid_get_panel_info;