| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd |
|---|
| 3 | 4 | * Author:Mark Yao <mark.yao@rock-chips.com> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 6 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 7 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 8 | | - * |
|---|
| 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. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #include <drm/drm.h> |
|---|
| 16 | | -#include <drm/drmP.h> |
|---|
| 17 | 8 | #include <drm/drm_fb_helper.h> |
|---|
| 18 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 9 | +#include <drm/drm_fourcc.h> |
|---|
| 10 | +#include <drm/drm_probe_helper.h> |
|---|
| 19 | 11 | |
|---|
| 20 | 12 | #include "rockchip_drm_drv.h" |
|---|
| 21 | 13 | #include "rockchip_drm_gem.h" |
|---|
| .. | .. |
|---|
| 33 | 25 | return rockchip_gem_mmap_buf(private->fbdev_bo, vma); |
|---|
| 34 | 26 | } |
|---|
| 35 | 27 | |
|---|
| 36 | | -static struct dma_buf *rockchip_fbdev_get_dma_buf(struct fb_info *info) |
|---|
| 37 | | -{ |
|---|
| 38 | | - struct dma_buf *buf = NULL; |
|---|
| 39 | | - struct drm_fb_helper *helper = info->par; |
|---|
| 40 | | - struct rockchip_drm_private *private = helper->dev->dev_private; |
|---|
| 41 | | - struct drm_device *dev = helper->dev; |
|---|
| 42 | | - |
|---|
| 43 | | - if (dev->driver->gem_prime_export) { |
|---|
| 44 | | - buf = dev->driver->gem_prime_export(dev, private->fbdev_bo, |
|---|
| 45 | | - O_RDWR); |
|---|
| 46 | | - if (buf) |
|---|
| 47 | | - drm_gem_object_get(private->fbdev_bo); |
|---|
| 48 | | - } |
|---|
| 49 | | - |
|---|
| 50 | | - return buf; |
|---|
| 51 | | -} |
|---|
| 52 | | - |
|---|
| 53 | | -static struct fb_ops rockchip_drm_fbdev_ops = { |
|---|
| 28 | +static const struct fb_ops rockchip_drm_fbdev_ops = { |
|---|
| 54 | 29 | .owner = THIS_MODULE, |
|---|
| 55 | 30 | DRM_FB_HELPER_DEFAULT_OPS, |
|---|
| 31 | + .fb_mmap = rockchip_fbdev_mmap, |
|---|
| 56 | 32 | .fb_fillrect = drm_fb_helper_cfb_fillrect, |
|---|
| 57 | 33 | .fb_copyarea = drm_fb_helper_cfb_copyarea, |
|---|
| 58 | 34 | .fb_imageblit = drm_fb_helper_cfb_imageblit, |
|---|
| 59 | | - .fb_mmap = rockchip_fbdev_mmap, |
|---|
| 60 | | - .fb_dmabuf_export = rockchip_fbdev_get_dma_buf, |
|---|
| 61 | 35 | }; |
|---|
| 62 | 36 | |
|---|
| 63 | 37 | static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, |
|---|
| .. | .. |
|---|
| 106 | 80 | goto out; |
|---|
| 107 | 81 | } |
|---|
| 108 | 82 | |
|---|
| 109 | | - fbi->par = helper; |
|---|
| 110 | | - fbi->flags = FBINFO_FLAG_DEFAULT; |
|---|
| 111 | 83 | fbi->fbops = &rockchip_drm_fbdev_ops; |
|---|
| 112 | 84 | |
|---|
| 113 | 85 | fb = helper->fb; |
|---|
| 114 | | - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); |
|---|
| 115 | | - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); |
|---|
| 86 | + drm_fb_helper_fill_info(fbi, helper, sizes); |
|---|
| 116 | 87 | |
|---|
| 117 | 88 | offset = fbi->var.xoffset * bytes_per_pixel; |
|---|
| 118 | 89 | offset += fbi->var.yoffset * fb->pitches[0]; |
|---|
| .. | .. |
|---|
| 127 | 98 | rk_obj->kvaddr, |
|---|
| 128 | 99 | offset, size); |
|---|
| 129 | 100 | |
|---|
| 130 | | - fbi->skip_vt_switch = true; |
|---|
| 131 | | - |
|---|
| 132 | 101 | return 0; |
|---|
| 133 | 102 | |
|---|
| 134 | 103 | out: |
|---|
| 135 | | - rockchip_gem_free_object(&rk_obj->base); |
|---|
| 104 | + drm_gem_object_put(&rk_obj->base); |
|---|
| 136 | 105 | return ret; |
|---|
| 137 | 106 | } |
|---|
| 138 | 107 | |
|---|
| .. | .. |
|---|
| 156 | 125 | |
|---|
| 157 | 126 | drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs); |
|---|
| 158 | 127 | |
|---|
| 159 | | - ret = drm_fb_helper_init(dev, helper, ROCKCHIP_MAX_CONNECTOR); |
|---|
| 128 | + ret = drm_fb_helper_init(dev, helper); |
|---|
| 160 | 129 | if (ret < 0) { |
|---|
| 161 | 130 | DRM_DEV_ERROR(dev->dev, |
|---|
| 162 | 131 | "Failed to initialize drm fb helper - %d.\n", |
|---|
| 163 | 132 | ret); |
|---|
| 164 | 133 | return ret; |
|---|
| 165 | | - } |
|---|
| 166 | | - |
|---|
| 167 | | - ret = drm_fb_helper_single_add_all_connectors(helper); |
|---|
| 168 | | - if (ret < 0) { |
|---|
| 169 | | - DRM_DEV_ERROR(dev->dev, |
|---|
| 170 | | - "Failed to add connectors - %d.\n", ret); |
|---|
| 171 | | - goto err_drm_fb_helper_fini; |
|---|
| 172 | 134 | } |
|---|
| 173 | 135 | |
|---|
| 174 | 136 | ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP); |
|---|