| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2013 Red Hat |
|---|
| 3 | 4 | * Author: Rob Clark <robdclark@gmail.com> |
|---|
| 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 <drm/drm_crtc.h> |
|---|
| 19 | 8 | #include <drm/drm_fb_helper.h> |
|---|
| 9 | +#include <drm/drm_fourcc.h> |
|---|
| 20 | 10 | |
|---|
| 21 | 11 | #include "msm_drv.h" |
|---|
| 22 | 12 | #include "msm_kms.h" |
|---|
| .. | .. |
|---|
| 36 | 26 | struct drm_framebuffer *fb; |
|---|
| 37 | 27 | }; |
|---|
| 38 | 28 | |
|---|
| 39 | | -static struct fb_ops msm_fb_ops = { |
|---|
| 29 | +static const struct fb_ops msm_fb_ops = { |
|---|
| 40 | 30 | .owner = THIS_MODULE, |
|---|
| 41 | 31 | DRM_FB_HELPER_DEFAULT_OPS, |
|---|
| 42 | 32 | |
|---|
| .. | .. |
|---|
| 91 | 81 | sizes->surface_height, pitch, format); |
|---|
| 92 | 82 | |
|---|
| 93 | 83 | if (IS_ERR(fb)) { |
|---|
| 94 | | - dev_err(dev->dev, "failed to allocate fb\n"); |
|---|
| 84 | + DRM_DEV_ERROR(dev->dev, "failed to allocate fb\n"); |
|---|
| 95 | 85 | return PTR_ERR(fb); |
|---|
| 96 | 86 | } |
|---|
| 97 | 87 | |
|---|
| .. | .. |
|---|
| 104 | 94 | * in panic (ie. lock-safe, etc) we could avoid pinning the |
|---|
| 105 | 95 | * buffer now: |
|---|
| 106 | 96 | */ |
|---|
| 107 | | - ret = msm_gem_get_iova(bo, priv->kms->aspace, &paddr); |
|---|
| 97 | + ret = msm_gem_get_and_pin_iova(bo, priv->kms->aspace, &paddr); |
|---|
| 108 | 98 | if (ret) { |
|---|
| 109 | | - dev_err(dev->dev, "failed to get buffer obj iova: %d\n", ret); |
|---|
| 99 | + DRM_DEV_ERROR(dev->dev, "failed to get buffer obj iova: %d\n", ret); |
|---|
| 110 | 100 | goto fail_unlock; |
|---|
| 111 | 101 | } |
|---|
| 112 | 102 | |
|---|
| 113 | 103 | fbi = drm_fb_helper_alloc_fbi(helper); |
|---|
| 114 | 104 | if (IS_ERR(fbi)) { |
|---|
| 115 | | - dev_err(dev->dev, "failed to allocate fb info\n"); |
|---|
| 105 | + DRM_DEV_ERROR(dev->dev, "failed to allocate fb info\n"); |
|---|
| 116 | 106 | ret = PTR_ERR(fbi); |
|---|
| 117 | 107 | goto fail_unlock; |
|---|
| 118 | 108 | } |
|---|
| .. | .. |
|---|
| 122 | 112 | fbdev->fb = fb; |
|---|
| 123 | 113 | helper->fb = fb; |
|---|
| 124 | 114 | |
|---|
| 125 | | - fbi->par = helper; |
|---|
| 126 | 115 | fbi->fbops = &msm_fb_ops; |
|---|
| 127 | 116 | |
|---|
| 128 | | - strcpy(fbi->fix.id, "msm"); |
|---|
| 129 | | - |
|---|
| 130 | | - drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth); |
|---|
| 131 | | - drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); |
|---|
| 117 | + drm_fb_helper_fill_info(fbi, helper, sizes); |
|---|
| 132 | 118 | |
|---|
| 133 | 119 | dev->mode_config.fb_base = paddr; |
|---|
| 134 | 120 | |
|---|
| .. | .. |
|---|
| 174 | 160 | |
|---|
| 175 | 161 | drm_fb_helper_prepare(dev, helper, &msm_fb_helper_funcs); |
|---|
| 176 | 162 | |
|---|
| 177 | | - ret = drm_fb_helper_init(dev, helper, priv->num_connectors); |
|---|
| 163 | + ret = drm_fb_helper_init(dev, helper); |
|---|
| 178 | 164 | if (ret) { |
|---|
| 179 | | - dev_err(dev->dev, "could not init fbdev: ret=%d\n", ret); |
|---|
| 165 | + DRM_DEV_ERROR(dev->dev, "could not init fbdev: ret=%d\n", ret); |
|---|
| 180 | 166 | goto fail; |
|---|
| 181 | 167 | } |
|---|
| 182 | 168 | |
|---|
| 183 | | - ret = drm_fb_helper_single_add_all_connectors(helper); |
|---|
| 184 | | - if (ret) |
|---|
| 185 | | - goto fini; |
|---|
| 169 | + /* the fw fb could be anywhere in memory */ |
|---|
| 170 | + drm_fb_helper_remove_conflicting_framebuffers(NULL, "msm", false); |
|---|
| 186 | 171 | |
|---|
| 187 | 172 | ret = drm_fb_helper_initial_config(helper, 32); |
|---|
| 188 | 173 | if (ret) |
|---|