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
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.
24 * Jim Liu <jim.liu@intel.com>
25 * Jackie Li<yaodong.li@intel.com>
26 * Gideon Eaton <eaton.
27 * Scott Rowe <scott.m.rowe@intel.com>
30 #include "mdfld_dsi_dbi.h"
31 #include "mdfld_dsi_dpi.h"
32 #include "mdfld_dsi_output.h"
33 #include "mdfld_output.h"
35 #include "mdfld_dsi_pkg_sender.h"
37 #include "displays/tmd_vid.h"
40 struct drm_display_mode
*tmd_vid_get_config_mode(struct drm_device
*dev
)
42 struct drm_display_mode
*mode
;
43 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
44 struct mrst_timing_info
*ti
= &dev_priv
->gct_data
.DTD
;
45 bool use_gct
= false; /*Disable GCT for now*/
47 mode
= kzalloc(sizeof(*mode
), GFP_KERNEL
);
49 dev_err(dev
->dev
, "Out of memory\n");
54 dev_dbg(dev
->dev
, "gct find MIPI panel.\n");
56 mode
->hdisplay
= (ti
->hactive_hi
<< 8) | ti
->hactive_lo
;
57 mode
->vdisplay
= (ti
->vactive_hi
<< 8) | ti
->vactive_lo
;
58 mode
->hsync_start
= mode
->hdisplay
+
59 ((ti
->hsync_offset_hi
<< 8) |
61 mode
->hsync_end
= mode
->hsync_start
+
62 ((ti
->hsync_pulse_width_hi
<< 8) |
63 ti
->hsync_pulse_width_lo
);
64 mode
->htotal
= mode
->hdisplay
+ ((ti
->hblank_hi
<< 8) |
67 mode
->vdisplay
+ ((ti
->vsync_offset_hi
<< 8) |
70 mode
->vsync_start
+ ((ti
->vsync_pulse_width_hi
<< 8) | \
71 ti
->vsync_pulse_width_lo
);
72 mode
->vtotal
= mode
->vdisplay
+
73 ((ti
->vblank_hi
<< 8) | ti
->vblank_lo
);
74 mode
->clock
= ti
->pixel_clock
* 10;
76 dev_dbg(dev
->dev
, "hdisplay is %d\n", mode
->hdisplay
);
77 dev_dbg(dev
->dev
, "vdisplay is %d\n", mode
->vdisplay
);
78 dev_dbg(dev
->dev
, "HSS is %d\n", mode
->hsync_start
);
79 dev_dbg(dev
->dev
, "HSE is %d\n", mode
->hsync_end
);
80 dev_dbg(dev
->dev
, "htotal is %d\n", mode
->htotal
);
81 dev_dbg(dev
->dev
, "VSS is %d\n", mode
->vsync_start
);
82 dev_dbg(dev
->dev
, "VSE is %d\n", mode
->vsync_end
);
83 dev_dbg(dev
->dev
, "vtotal is %d\n", mode
->vtotal
);
84 dev_dbg(dev
->dev
, "clock is %d\n", mode
->clock
);
88 mode
->hsync_start
= 487;
89 mode
->hsync_end
= 490;
91 mode
->vsync_start
= 861;
92 mode
->vsync_end
= 865;
96 drm_mode_set_name(mode
);
97 drm_mode_set_crtcinfo(mode
, 0);
99 mode
->type
|= DRM_MODE_TYPE_PREFERRED
;
104 static int tmd_vid_get_panel_info(struct drm_device
*dev
,
106 struct panel_info
*pi
)
111 pi
->width_mm
= TMD_PANEL_WIDTH
;
112 pi
->height_mm
= TMD_PANEL_HEIGHT
;
117 /* TMD DPI encoder helper funcs */
118 static const struct drm_encoder_helper_funcs
119 mdfld_tpo_dpi_encoder_helper_funcs
= {
120 .dpms
= mdfld_dsi_dpi_dpms
,
121 .mode_fixup
= mdfld_dsi_dpi_mode_fixup
,
122 .prepare
= mdfld_dsi_dpi_prepare
,
123 .mode_set
= mdfld_dsi_dpi_mode_set
,
124 .commit
= mdfld_dsi_dpi_commit
,
127 /* TMD DPI encoder funcs */
128 static const struct drm_encoder_funcs mdfld_tpo_dpi_encoder_funcs
= {
129 .destroy
= drm_encoder_cleanup
,
132 void tmd_vid_init(struct drm_device
*dev
, struct panel_funcs
*p_funcs
)
134 if (!dev
|| !p_funcs
) {
135 dev_err(dev
->dev
, "Invalid parameters\n");
139 p_funcs
->encoder_funcs
= &mdfld_tpo_dpi_encoder_funcs
;
140 p_funcs
->encoder_helper_funcs
= &mdfld_tpo_dpi_encoder_helper_funcs
;
141 p_funcs
->get_config_mode
= &tmd_vid_get_config_mode
;
142 p_funcs
->update_fb
= NULL
;
143 p_funcs
->get_panel_info
= tmd_vid_get_panel_info
;