2 * Copyright (c) 2014 Spreadtrum Communications, Inc.
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.
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.
15 #ifndef _SPRD_DRM_DRV_H_
16 #define _SPRD_DRM_DRV_H_
18 #include <linux/module.h>
21 #include <drm/sprd_drm.h>
26 extern unsigned int drm_vblank_offdelay;
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;
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;
41 struct sprd_drm_ipp_private {
43 struct list_head event_list;
46 struct drm_sprd_file_private {
47 struct sprd_drm_ipp_private *ipp_priv;
53 * Spreadtrum drm private structure.
55 struct sprd_drm_private {
56 struct drm_device *drm_dev;
58 unsigned long vbl_itv_us;
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;
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.
73 struct drm_crtc *crtc[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;
81 atomic_t vbl_trg_cnt[MAX_CRTC];
86 * Spreadtrum drm sub driver structure.
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
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.
103 struct sprd_drm_subdrv {
104 struct list_head list;
106 struct drm_device *drm_dev;
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);
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
121 int sprd_drm_device_register(struct drm_device *dev);
123 * this function calls a remove callback registered to sub driver list and
124 * destroy its own encoder and connetor.
126 int sprd_drm_device_unregister(struct drm_device *dev);
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.
134 int sprd_drm_subdrv_register(struct sprd_drm_subdrv *drm_subdrv);
136 /* this function removes subdrv list from sprd drm driver */
137 int sprd_drm_subdrv_unregister(struct sprd_drm_subdrv *drm_subdrv);
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);
142 #ifdef CONFIG_DRM_DPMS_IOCTL
143 void sprd_drm_dpms_work_ops(struct work_struct *work);
147 * this function registers sprd drm ipp platform device.
149 int sprd_platform_device_ipp_register(void);
152 * this function unregisters sprd drm ipp platform device if it exists.
154 void sprd_platform_device_ipp_unregister(void);
156 extern struct platform_driver gsp_driver;
157 extern struct platform_driver ipp_driver;