drm/sprd: include correct ion.h header file in sprd_drm
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / gpu / drm / sprd / sprd_drm_drv.h
1 /* sprd_drm_drv.h
2  * Copyright (c) 2014 Spreadtrum Communications, Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #ifndef _SPRD_DRM_DRV_H_
16 #define _SPRD_DRM_DRV_H_
17
18 #include <linux/module.h>
19 #include "ion.h"
20 #include "drm.h"
21 #include <drm/sprd_drm.h>
22
23 #define MAX_CRTC        2
24
25 struct drm_device;
26 extern unsigned int drm_vblank_offdelay;
27
28 #ifdef CONFIG_DRM_DPMS_IOCTL
29 struct drm_sprd_send_dpms_event {
30         struct drm_pending_event        base;
31         struct drm_control_dpms_event   event;
32 };
33
34 struct sprd_drm_dpms_work {
35         struct work_struct      work;
36         struct drm_sprd_send_dpms_event *event;
37         struct sprd_drm_private *private;
38 };
39 #endif
40
41 struct sprd_drm_ipp_private {
42         struct device   *dev;
43         struct list_head        event_list;
44 };
45
46 struct drm_sprd_file_private {
47         struct sprd_drm_ipp_private     *ipp_priv;
48         pid_t tgid;
49 };
50
51 /*
52  * Spreadtrum drm private structure.
53  */
54 struct sprd_drm_private {
55         struct drm_device       *drm_dev;
56         unsigned int            irq;
57         unsigned long   vbl_itv_us;
58         bool    vbl_swap;
59         unsigned int    fake_vbl_hz;
60         struct work_struct fake_vbl_work;
61         struct drm_fb_helper    *fb_helper;
62         struct ion_client       *sprd_drm_ion_client;
63         /* list head for new event to be added. */
64         struct list_head        pageflip_event_list;
65         void __iomem *regs;
66         size_t reg_size;
67
68         /*
69          * created crtc object would be contained at this array and
70          * this array is used to be aware of which crtc did it request vblank.
71          */
72         struct drm_crtc         *crtc[MAX_CRTC];
73         u32 dpms[MAX_CRTC];
74         struct notifier_block   nb_ctrl;
75 #ifdef CONFIG_DRM_DPMS_IOCTL
76         struct sprd_drm_dpms_work       *dpms_work;
77         struct completion       dpms_comp;
78         struct mutex    dpms_lock;
79 #endif
80         atomic_t vbl_trg_cnt[MAX_CRTC];
81         int     dbg_cnt;
82 };
83
84 /*
85  * Spreadtrum drm sub driver structure.
86  *
87  * @list: sub driver has its own list object to register to sprd drm driver.
88  * @dev: pointer to device object for subdrv device driver.
89  * @drm_dev: pointer to drm_device and this pointer would be set
90  *      when sub driver calls sprd_drm_subdrv_register().
91  * @manager: subdrv has its own manager to control a hardware appropriately
92  *      and we can access a hardware drawing on this manager.
93  * @probe: this callback would be called by sprd drm driver after
94  *      subdrv is registered to it.
95  * @remove: this callback is used to release resources created
96  *      by probe callback.
97  * @open: this would be called with drm device file open.
98  * @close: this would be called with drm device file close.
99  * @encoder: encoder object owned by this sub driver.
100  * @connector: connector object owned by this sub driver.
101  */
102 struct sprd_drm_subdrv {
103         struct list_head list;
104         struct device *dev;
105         struct drm_device *drm_dev;
106
107         int (*probe)(struct drm_device *drm_dev, struct device *dev);
108         void (*remove)(struct drm_device *drm_dev, struct device *dev);
109         int (*open)(struct drm_device *drm_dev, struct device *dev,
110                         struct drm_file *file);
111         void (*close)(struct drm_device *drm_dev, struct device *dev,
112                         struct drm_file *file);
113 };
114
115 /*
116  * this function calls a probe callback registered to sub driver list and
117  * create its own encoder and connector and then set drm_device object
118  * to global one.
119  */
120 int sprd_drm_device_register(struct drm_device *dev);
121 /*
122  * this function calls a remove callback registered to sub driver list and
123  * destroy its own encoder and connetor.
124  */
125 int sprd_drm_device_unregister(struct drm_device *dev);
126
127 /*
128  * this function would be called by sub drivers such as display controller
129  * or hdmi driver to register this sub driver object to sprd drm driver
130  * and when a sub driver is registered to sprd drm driver a probe callback
131  * of the sub driver is called and creates its own encoder and connector.
132  */
133 int sprd_drm_subdrv_register(struct sprd_drm_subdrv *drm_subdrv);
134
135 /* this function removes subdrv list from sprd drm driver */
136 int sprd_drm_subdrv_unregister(struct sprd_drm_subdrv *drm_subdrv);
137
138 int sprd_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
139 void sprd_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
140
141 #ifdef CONFIG_DRM_DPMS_IOCTL
142 void sprd_drm_dpms_work_ops(struct work_struct *work);
143 #endif
144
145 /*
146  * this function registers sprd drm ipp platform device.
147  */
148 int sprd_platform_device_ipp_register(void);
149
150 /*
151  * this function unregisters sprd drm ipp platform device if it exists.
152  */
153 void sprd_platform_device_ipp_unregister(void);
154
155 extern struct platform_driver gsp_driver;
156 extern struct platform_driver ipp_driver;
157 #endif