2 * drivers/staging/omapdrm/omap_drv.h
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob@ti.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __OMAP_DRV_H__
21 #define __OMAP_DRV_H__
23 #include <video/omapdss.h>
24 #include <linux/module.h>
25 #include <linux/types.h>
27 #include <drm/drm_crtc_helper.h>
29 #include "omap_priv.h"
31 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
32 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
34 #define MODULE_NAME "omapdrm"
36 /* max # of mapper-id's that can be assigned.. todo, come up with a better
37 * (but still inexpensive) way to store/access per-buffer mapper private
42 struct omap_drm_private
{
43 unsigned int num_crtcs
;
44 struct drm_crtc
*crtcs
[8];
45 unsigned int num_planes
;
46 struct drm_plane
*planes
[8];
47 unsigned int num_encoders
;
48 struct drm_encoder
*encoders
[8];
49 unsigned int num_connectors
;
50 struct drm_connector
*connectors
[8];
52 struct drm_fb_helper
*fbdev
;
57 #ifdef CONFIG_DEBUG_FS
58 int omap_debugfs_init(struct drm_minor
*minor
);
59 void omap_debugfs_cleanup(struct drm_minor
*minor
);
62 struct drm_fb_helper
*omap_fbdev_init(struct drm_device
*dev
);
63 void omap_fbdev_free(struct drm_device
*dev
);
65 struct drm_crtc
*omap_crtc_init(struct drm_device
*dev
,
66 struct omap_overlay
*ovl
, int id
);
68 struct drm_plane
*omap_plane_init(struct drm_device
*dev
,
69 struct omap_overlay
*ovl
, unsigned int possible_crtcs
,
71 int omap_plane_dpms(struct drm_plane
*plane
, int mode
);
72 int omap_plane_mode_set(struct drm_plane
*plane
,
73 struct drm_crtc
*crtc
, struct drm_framebuffer
*fb
,
74 int crtc_x
, int crtc_y
,
75 unsigned int crtc_w
, unsigned int crtc_h
,
76 uint32_t src_x
, uint32_t src_y
,
77 uint32_t src_w
, uint32_t src_h
);
79 struct drm_encoder
*omap_encoder_init(struct drm_device
*dev
,
80 struct omap_overlay_manager
*mgr
);
81 struct omap_overlay_manager
*omap_encoder_get_manager(
82 struct drm_encoder
*encoder
);
83 struct drm_encoder
*omap_connector_attached_encoder(
84 struct drm_connector
*connector
);
85 enum drm_connector_status
omap_connector_detect(
86 struct drm_connector
*connector
, bool force
);
88 struct drm_connector
*omap_connector_init(struct drm_device
*dev
,
89 int connector_type
, struct omap_dss_device
*dssdev
);
90 void omap_connector_mode_set(struct drm_connector
*connector
,
91 struct drm_display_mode
*mode
);
92 void omap_connector_flush(struct drm_connector
*connector
,
93 int x
, int y
, int w
, int h
);
95 struct drm_framebuffer
*omap_framebuffer_create(struct drm_device
*dev
,
96 struct drm_file
*file
, struct drm_mode_fb_cmd2
*mode_cmd
);
97 struct drm_framebuffer
*omap_framebuffer_init(struct drm_device
*dev
,
98 struct drm_mode_fb_cmd2
*mode_cmd
, struct drm_gem_object
**bos
);
99 struct drm_gem_object
*omap_framebuffer_bo(struct drm_framebuffer
*fb
, int p
);
100 int omap_framebuffer_pin(struct drm_framebuffer
*fb
);
101 void omap_framebuffer_unpin(struct drm_framebuffer
*fb
);
102 void omap_framebuffer_update_scanout(struct drm_framebuffer
*fb
, int x
, int y
,
103 struct omap_overlay_info
*info
);
104 struct drm_connector
*omap_framebuffer_get_next_connector(
105 struct drm_framebuffer
*fb
, struct drm_connector
*from
);
106 void omap_framebuffer_flush(struct drm_framebuffer
*fb
,
107 int x
, int y
, int w
, int h
);
109 void omap_gem_init(struct drm_device
*dev
);
110 void omap_gem_deinit(struct drm_device
*dev
);
112 struct drm_gem_object
*omap_gem_new(struct drm_device
*dev
,
113 union omap_gem_size gsize
, uint32_t flags
);
114 int omap_gem_new_handle(struct drm_device
*dev
, struct drm_file
*file
,
115 union omap_gem_size gsize
, uint32_t flags
, uint32_t *handle
);
116 void omap_gem_free_object(struct drm_gem_object
*obj
);
117 int omap_gem_init_object(struct drm_gem_object
*obj
);
118 void *omap_gem_vaddr(struct drm_gem_object
*obj
);
119 int omap_gem_dumb_map_offset(struct drm_file
*file
, struct drm_device
*dev
,
120 uint32_t handle
, uint64_t *offset
);
121 int omap_gem_dumb_destroy(struct drm_file
*file
, struct drm_device
*dev
,
123 int omap_gem_dumb_create(struct drm_file
*file
, struct drm_device
*dev
,
124 struct drm_mode_create_dumb
*args
);
125 int omap_gem_mmap(struct file
*filp
, struct vm_area_struct
*vma
);
126 int omap_gem_fault(struct vm_area_struct
*vma
, struct vm_fault
*vmf
);
127 int omap_gem_op_start(struct drm_gem_object
*obj
, enum omap_gem_op op
);
128 int omap_gem_op_finish(struct drm_gem_object
*obj
, enum omap_gem_op op
);
129 int omap_gem_op_sync(struct drm_gem_object
*obj
, enum omap_gem_op op
);
130 int omap_gem_op_async(struct drm_gem_object
*obj
, enum omap_gem_op op
,
131 void (*fxn
)(void *arg
), void *arg
);
132 int omap_gem_roll(struct drm_gem_object
*obj
, uint32_t roll
);
133 int omap_gem_get_paddr(struct drm_gem_object
*obj
,
134 dma_addr_t
*paddr
, bool remap
);
135 int omap_gem_put_paddr(struct drm_gem_object
*obj
);
136 uint64_t omap_gem_mmap_offset(struct drm_gem_object
*obj
);
137 size_t omap_gem_mmap_size(struct drm_gem_object
*obj
);
139 static inline int align_pitch(int pitch
, int width
, int bpp
)
141 int bytespp
= (bpp
+ 7) / 8;
142 /* in case someone tries to feed us a completely bogus stride: */
143 pitch
= max(pitch
, width
* bytespp
);
144 /* PVR needs alignment to 8 pixels.. right now that is the most
145 * restrictive stride requirement..
147 return ALIGN(pitch
, 8 * bytespp
);
150 /* should these be made into common util helpers?
153 static inline int objects_lookup(struct drm_device
*dev
,
154 struct drm_file
*filp
, uint32_t pixel_format
,
155 struct drm_gem_object
**bos
, uint32_t *handles
)
157 int i
, n
= drm_format_num_planes(pixel_format
);
159 for (i
= 0; i
< n
; i
++) {
160 bos
[i
] = drm_gem_object_lookup(dev
, filp
, handles
[i
]);
170 drm_gem_object_unreference_unlocked(bos
[i
]);
175 #endif /* __OMAP_DRV_H__ */