Merge tag 'drm-misc-next-2017-05-16' of git://anongit.freedesktop.org/git/drm-misc...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / gma500 / mdfld_tpo_vid.c
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 #include "mdfld_dsi_dpi.h"
29
30 static struct drm_display_mode *tpo_vid_get_config_mode(struct drm_device *dev)
31 {
32         struct drm_display_mode *mode;
33         struct drm_psb_private *dev_priv = dev->dev_private;
34         struct oaktrail_timing_info *ti = &dev_priv->gct_data.DTD;
35
36         mode = kzalloc(sizeof(*mode), GFP_KERNEL);
37         if (!mode)
38                 return NULL;
39
40         mode->hdisplay = 864;
41         mode->vdisplay = 480;
42         mode->hsync_start = 873;
43         mode->hsync_end = 876;
44         mode->htotal = 887;
45         mode->vsync_start = 487;
46         mode->vsync_end = 490;
47         mode->vtotal = 499;
48         mode->clock = 33264;
49
50         drm_mode_set_name(mode);
51         drm_mode_set_crtcinfo(mode, 0);
52
53         mode->type |= DRM_MODE_TYPE_PREFERRED;
54
55         return mode;
56 }
57
58 static int tpo_vid_get_panel_info(struct drm_device *dev,
59                                 int pipe,
60                                 struct panel_info *pi)
61 {
62         if (!dev || !pi)
63                 return -EINVAL;
64
65         pi->width_mm = TPO_PANEL_WIDTH;
66         pi->height_mm = TPO_PANEL_HEIGHT;
67
68         return 0;
69 }
70
71 /*TPO DPI encoder helper funcs*/
72 static const struct drm_encoder_helper_funcs
73                                 mdfld_tpo_dpi_encoder_helper_funcs = {
74         .dpms = mdfld_dsi_dpi_dpms,
75         .mode_fixup = mdfld_dsi_dpi_mode_fixup,
76         .prepare = mdfld_dsi_dpi_prepare,
77         .mode_set = mdfld_dsi_dpi_mode_set,
78         .commit = mdfld_dsi_dpi_commit,
79 };
80
81 /*TPO DPI encoder funcs*/
82 static const struct drm_encoder_funcs mdfld_tpo_dpi_encoder_funcs = {
83         .destroy = drm_encoder_cleanup,
84 };
85
86 const struct panel_funcs mdfld_tpo_vid_funcs = {
87         .encoder_funcs = &mdfld_tpo_dpi_encoder_funcs,
88         .encoder_helper_funcs = &mdfld_tpo_dpi_encoder_helper_funcs,
89         .get_config_mode = &tpo_vid_get_config_mode,
90         .get_panel_info = tpo_vid_get_panel_info,
91 };