drm/sprd: save pid/tgid in private file data
[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                           pid;
49         pid_t                           tgid;
50 };
51
52 /*
53  * Spreadtrum drm private structure.
54  */
55 struct sprd_drm_private {
56         struct drm_device       *drm_dev;
57         unsigned int            irq;
58         unsigned long   vbl_itv_us;
59         bool    vbl_swap;
60         unsigned int    fake_vbl_hz;
61         struct work_struct fake_vbl_work;
62         struct drm_fb_helper    *fb_helper;
63         struct ion_client       *sprd_drm_ion_client;
64         /* list head for new event to be added. */
65         struct list_head        pageflip_event_list;
66         void __iomem *regs;
67         size_t reg_size;
68
69         /*
70          * created crtc object would be contained at this array and
71          * this array is used to be aware of which crtc did it request vblank.
72          */
73         struct drm_crtc         *crtc[MAX_CRTC];
74         u32 dpms[MAX_CRTC];
75         struct notifier_block   nb_ctrl;
76 #ifdef CONFIG_DRM_DPMS_IOCTL
77         struct sprd_drm_dpms_work       *dpms_work;
78         struct completion       dpms_comp;
79         struct mutex    dpms_lock;
80 #endif
81         atomic_t vbl_trg_cnt[MAX_CRTC];
82         int     dbg_cnt;
83 };
84
85 /*
86  * Spreadtrum drm sub driver structure.
87  *
88  * @list: sub driver has its own list object to register to sprd drm driver.
89  * @dev: pointer to device object for subdrv device driver.
90  * @drm_dev: pointer to drm_device and this pointer would be set
91  *      when sub driver calls sprd_drm_subdrv_register().
92  * @manager: subdrv has its own manager to control a hardware appropriately
93  *      and we can access a hardware drawing on this manager.
94  * @probe: this callback would be called by sprd drm driver after
95  *      subdrv is registered to it.
96  * @remove: this callback is used to release resources created
97  *      by probe callback.
98  * @open: this would be called with drm device file open.
99  * @close: this would be called with drm device file close.
100  * @encoder: encoder object owned by this sub driver.
101  * @connector: connector object owned by this sub driver.
102  */
103 struct sprd_drm_subdrv {
104         struct list_head list;
105         struct device *dev;
106         struct drm_device *drm_dev;
107
108         int (*probe)(struct drm_device *drm_dev, struct device *dev);
109         void (*remove)(struct drm_device *drm_dev, struct device *dev);
110         int (*open)(struct drm_device *drm_dev, struct device *dev,
111                         struct drm_file *file);
112         void (*close)(struct drm_device *drm_dev, struct device *dev,
113                         struct drm_file *file);
114 };
115
116 /*
117  * this function calls a probe callback registered to sub driver list and
118  * create its own encoder and connector and then set drm_device object
119  * to global one.
120  */
121 int sprd_drm_device_register(struct drm_device *dev);
122 /*
123  * this function calls a remove callback registered to sub driver list and
124  * destroy its own encoder and connetor.
125  */
126 int sprd_drm_device_unregister(struct drm_device *dev);
127
128 /*
129  * this function would be called by sub drivers such as display controller
130  * or hdmi driver to register this sub driver object to sprd drm driver
131  * and when a sub driver is registered to sprd drm driver a probe callback
132  * of the sub driver is called and creates its own encoder and connector.
133  */
134 int sprd_drm_subdrv_register(struct sprd_drm_subdrv *drm_subdrv);
135
136 /* this function removes subdrv list from sprd drm driver */
137 int sprd_drm_subdrv_unregister(struct sprd_drm_subdrv *drm_subdrv);
138
139 int sprd_drm_subdrv_open(struct drm_device *dev, struct drm_file *file);
140 void sprd_drm_subdrv_close(struct drm_device *dev, struct drm_file *file);
141
142 #ifdef CONFIG_DRM_DPMS_IOCTL
143 void sprd_drm_dpms_work_ops(struct work_struct *work);
144 #endif
145
146 /*
147  * this function registers sprd drm ipp platform device.
148  */
149 int sprd_platform_device_ipp_register(void);
150
151 /*
152  * this function unregisters sprd drm ipp platform device if it exists.
153  */
154 void sprd_platform_device_ipp_unregister(void);
155
156 extern struct platform_driver gsp_driver;
157 extern struct platform_driver ipp_driver;
158 #endif