| 1 | /* |
| 2 | * drivers/staging/omapdrm/omap_drv.h |
| 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments |
| 5 | * Author: Rob Clark <rob@ti.com> |
| 6 | * |
| 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. |
| 10 | * |
| 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 |
| 14 | * more details. |
| 15 | * |
| 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/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __OMAP_DRV_H__ |
| 21 | #define __OMAP_DRV_H__ |
| 22 | |
| 23 | #include <video/omapdss.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/types.h> |
| 26 | #include <drm/drmP.h> |
| 27 | #include "omap_drm.h" |
| 28 | #include "omap_priv.h" |
| 29 | |
| 30 | #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) |
| 31 | #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */ |
| 32 | |
| 33 | #define MODULE_NAME "omapdrm" |
| 34 | |
| 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 |
| 37 | * data.. |
| 38 | */ |
| 39 | #define MAX_MAPPERS 2 |
| 40 | |
| 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]; |
| 48 | |
| 49 | struct drm_fb_helper *fbdev; |
| 50 | }; |
| 51 | |
| 52 | struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev); |
| 53 | void omap_fbdev_free(struct drm_device *dev); |
| 54 | |
| 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); |
| 58 | |
| 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); |
| 67 | |
| 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); |
| 74 | |
| 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); |
| 86 | |
| 87 | void omap_gem_init(struct drm_device *dev); |
| 88 | void omap_gem_deinit(struct drm_device *dev); |
| 89 | |
| 90 | struct drm_gem_object *omap_gem_new(struct drm_device *dev, |
| 91 | union omap_gem_size gsize, uint32_t flags); |
| 92 | int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file, |
| 93 | union omap_gem_size gsize, uint32_t flags, uint32_t *handle); |
| 94 | void omap_gem_free_object(struct drm_gem_object *obj); |
| 95 | int omap_gem_init_object(struct drm_gem_object *obj); |
| 96 | void *omap_gem_vaddr(struct drm_gem_object *obj); |
| 97 | int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, |
| 98 | uint32_t handle, uint64_t *offset); |
| 99 | int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, |
| 100 | uint32_t handle); |
| 101 | int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev, |
| 102 | struct drm_mode_create_dumb *args); |
| 103 | int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
| 104 | int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); |
| 105 | int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op); |
| 106 | int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op); |
| 107 | int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op); |
| 108 | int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op, |
| 109 | void (*fxn)(void *arg), void *arg); |
| 110 | int omap_gem_get_paddr(struct drm_gem_object *obj, |
| 111 | dma_addr_t *paddr, bool remap); |
| 112 | int omap_gem_put_paddr(struct drm_gem_object *obj); |
| 113 | uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj); |
| 114 | size_t omap_gem_mmap_size(struct drm_gem_object *obj); |
| 115 | |
| 116 | static inline int align_pitch(int pitch, int width, int bpp) |
| 117 | { |
| 118 | int bytespp = (bpp + 7) / 8; |
| 119 | /* in case someone tries to feed us a completely bogus stride: */ |
| 120 | pitch = max(pitch, width * bytespp); |
| 121 | /* PVR needs alignment to 8 pixels.. right now that is the most |
| 122 | * restrictive stride requirement.. |
| 123 | */ |
| 124 | return ALIGN(pitch, 8 * bytespp); |
| 125 | } |
| 126 | |
| 127 | #endif /* __OMAP_DRV_H__ */ |