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>
28 #include "omap_priv.h"
30 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
31 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
33 #define MODULE_NAME "omapdrm"
35 /* max # of mapper-id's that can be assigned.. todo, come up with a better
36 * (but still inexpensive) way to store/access per-buffer mapper private
41 struct omap_drm_private {
42 unsigned int num_crtcs;
43 struct drm_crtc *crtcs[8];
44 unsigned int num_encoders;
45 struct drm_encoder *encoders[8];
46 unsigned int num_connectors;
47 struct drm_connector *connectors[8];
49 struct drm_fb_helper *fbdev;
52 struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
53 void omap_fbdev_free(struct drm_device *dev);
55 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
56 struct omap_overlay *ovl, int id);
57 struct omap_overlay *omap_crtc_get_overlay(struct drm_crtc *crtc);
59 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
60 struct omap_overlay_manager *mgr);
61 struct omap_overlay_manager *omap_encoder_get_manager(
62 struct drm_encoder *encoder);
63 struct drm_encoder *omap_connector_attached_encoder(
64 struct drm_connector *connector);
65 enum drm_connector_status omap_connector_detect(
66 struct drm_connector *connector, bool force);
68 struct drm_connector *omap_connector_init(struct drm_device *dev,
69 int connector_type, struct omap_dss_device *dssdev);
70 void omap_connector_mode_set(struct drm_connector *connector,
71 struct drm_display_mode *mode);
72 void omap_connector_flush(struct drm_connector *connector,
73 int x, int y, int w, int h);
75 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
76 struct drm_file *file, struct drm_mode_fb_cmd *mode_cmd);
77 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
78 struct drm_mode_fb_cmd *mode_cmd, struct drm_gem_object *bo);
79 struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb);
80 int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
81 void **vaddr, dma_addr_t *paddr, unsigned int *screen_width);
82 struct drm_connector *omap_framebuffer_get_next_connector(
83 struct drm_framebuffer *fb, struct drm_connector *from);
84 void omap_framebuffer_flush(struct drm_framebuffer *fb,
85 int x, int y, int w, int h);
88 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
89 union omap_gem_size gsize, uint32_t flags);
90 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
91 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
92 void omap_gem_free_object(struct drm_gem_object *obj);
93 int omap_gem_init_object(struct drm_gem_object *obj);
94 void *omap_gem_vaddr(struct drm_gem_object *obj);
95 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
96 uint32_t handle, uint64_t *offset);
97 int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
99 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
100 struct drm_mode_create_dumb *args);
101 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
102 int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
103 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
104 int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
105 int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
106 int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
107 void (*fxn)(void *arg), void *arg);
108 int omap_gem_get_paddr(struct drm_gem_object *obj,
109 dma_addr_t *paddr, bool remap);
110 int omap_gem_put_paddr(struct drm_gem_object *obj);
111 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
113 static inline int align_pitch(int pitch, int width, int bpp)
115 int bytespp = (bpp + 7) / 8;
116 /* in case someone tries to feed us a completely bogus stride: */
117 pitch = max(pitch, width * bytespp);
118 /* PVR needs alignment to 8 pixels.. right now that is the most
119 * restrictive stride requirement..
121 return ALIGN(pitch, 8 * bytespp);
124 #endif /* __OMAP_DRV_H__ */