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;
52 * Spreadtrum drm private structure.
54 struct sprd_drm_private {
55 struct drm_device *drm_dev;
57 unsigned long vbl_itv_us;
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;
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.
72 struct drm_crtc *crtc[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;
80 atomic_t vbl_trg_cnt[MAX_CRTC];
85 * Spreadtrum drm sub driver structure.
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
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.
102 struct sprd_drm_subdrv {
103 struct list_head list;
105 struct drm_device *drm_dev;
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);
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
120 int sprd_drm_device_register(struct drm_device *dev);
122 * this function calls a remove callback registered to sub driver list and
123 * destroy its own encoder and connetor.
125 int sprd_drm_device_unregister(struct drm_device *dev);
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.
133 int sprd_drm_subdrv_register(struct sprd_drm_subdrv *drm_subdrv);
135 /* this function removes subdrv list from sprd drm driver */
136 int sprd_drm_subdrv_unregister(struct sprd_drm_subdrv *drm_subdrv);
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);
141 #ifdef CONFIG_DRM_DPMS_IOCTL
142 void sprd_drm_dpms_work_ops(struct work_struct *work);
146 * this function registers sprd drm ipp platform device.
148 int sprd_platform_device_ipp_register(void);
151 * this function unregisters sprd drm ipp platform device if it exists.
153 void sprd_platform_device_ipp_unregister(void);
155 extern struct platform_driver gsp_driver;
156 extern struct platform_driver ipp_driver;