| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
|---|
| 3 | 4 | * Author: Rob Clark <rob.clark@linaro.org> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 7 | | - * the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 15 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 16 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | 7 | #include <linux/dma-buf.h> |
|---|
| 8 | +#include <linux/highmem.h> |
|---|
| 9 | + |
|---|
| 10 | +#include <drm/drm_prime.h> |
|---|
| 19 | 11 | |
|---|
| 20 | 12 | #include "omap_drv.h" |
|---|
| 21 | 13 | |
|---|
| .. | .. |
|---|
| 75 | 67 | { |
|---|
| 76 | 68 | struct drm_gem_object *obj = buffer->priv; |
|---|
| 77 | 69 | struct page **pages; |
|---|
| 78 | | - if (omap_gem_flags(obj) & OMAP_BO_TILED) { |
|---|
| 70 | + if (omap_gem_flags(obj) & OMAP_BO_TILED_MASK) { |
|---|
| 79 | 71 | /* TODO we would need to pin at least part of the buffer to |
|---|
| 80 | 72 | * get de-tiled view. For now just reject it. |
|---|
| 81 | 73 | */ |
|---|
| .. | .. |
|---|
| 91 | 83 | struct drm_gem_object *obj = buffer->priv; |
|---|
| 92 | 84 | omap_gem_put_pages(obj); |
|---|
| 93 | 85 | return 0; |
|---|
| 94 | | -} |
|---|
| 95 | | - |
|---|
| 96 | | -static void *omap_gem_dmabuf_kmap(struct dma_buf *buffer, |
|---|
| 97 | | - unsigned long page_num) |
|---|
| 98 | | -{ |
|---|
| 99 | | - struct drm_gem_object *obj = buffer->priv; |
|---|
| 100 | | - struct page **pages; |
|---|
| 101 | | - omap_gem_get_pages(obj, &pages, false); |
|---|
| 102 | | - omap_gem_cpu_sync_page(obj, page_num); |
|---|
| 103 | | - return kmap(pages[page_num]); |
|---|
| 104 | | -} |
|---|
| 105 | | - |
|---|
| 106 | | -static void omap_gem_dmabuf_kunmap(struct dma_buf *buffer, |
|---|
| 107 | | - unsigned long page_num, void *addr) |
|---|
| 108 | | -{ |
|---|
| 109 | | - struct drm_gem_object *obj = buffer->priv; |
|---|
| 110 | | - struct page **pages; |
|---|
| 111 | | - omap_gem_get_pages(obj, &pages, false); |
|---|
| 112 | | - kunmap(pages[page_num]); |
|---|
| 113 | 86 | } |
|---|
| 114 | 87 | |
|---|
| 115 | 88 | static int omap_gem_dmabuf_mmap(struct dma_buf *buffer, |
|---|
| .. | .. |
|---|
| 131 | 104 | .release = drm_gem_dmabuf_release, |
|---|
| 132 | 105 | .begin_cpu_access = omap_gem_dmabuf_begin_cpu_access, |
|---|
| 133 | 106 | .end_cpu_access = omap_gem_dmabuf_end_cpu_access, |
|---|
| 134 | | - .map = omap_gem_dmabuf_kmap, |
|---|
| 135 | | - .unmap = omap_gem_dmabuf_kunmap, |
|---|
| 136 | 107 | .mmap = omap_gem_dmabuf_mmap, |
|---|
| 137 | 108 | }; |
|---|
| 138 | 109 | |
|---|
| 139 | | -struct dma_buf *omap_gem_prime_export(struct drm_device *dev, |
|---|
| 140 | | - struct drm_gem_object *obj, int flags) |
|---|
| 110 | +struct dma_buf *omap_gem_prime_export(struct drm_gem_object *obj, int flags) |
|---|
| 141 | 111 | { |
|---|
| 142 | 112 | DEFINE_DMA_BUF_EXPORT_INFO(exp_info); |
|---|
| 143 | 113 | |
|---|
| .. | .. |
|---|
| 146 | 116 | exp_info.flags = flags; |
|---|
| 147 | 117 | exp_info.priv = obj; |
|---|
| 148 | 118 | |
|---|
| 149 | | - return drm_gem_dmabuf_export(dev, &exp_info); |
|---|
| 119 | + return drm_gem_dmabuf_export(obj->dev, &exp_info); |
|---|
| 150 | 120 | } |
|---|
| 151 | 121 | |
|---|
| 152 | 122 | /* ----------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 168 | 138 | * Importing dmabuf exported from out own gem increases |
|---|
| 169 | 139 | * refcount on gem itself instead of f_count of dmabuf. |
|---|
| 170 | 140 | */ |
|---|
| 171 | | - drm_gem_object_reference(obj); |
|---|
| 141 | + drm_gem_object_get(obj); |
|---|
| 172 | 142 | return obj; |
|---|
| 173 | 143 | } |
|---|
| 174 | 144 | } |
|---|