2012-11-16 05:28:22 +08:00
|
|
|
/*
|
2013-03-22 22:34:08 +08:00
|
|
|
* Copyright (C) 2012-2013 Avionic Design GmbH
|
2012-11-16 05:28:22 +08:00
|
|
|
* Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
|
|
|
|
*
|
2013-03-22 22:34:08 +08:00
|
|
|
* Based on the KMS/FB CMA helpers
|
|
|
|
* Copyright (C) 2012 Analog Device Inc.
|
|
|
|
*
|
2012-11-16 05:28:22 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2015-08-11 19:11:49 +08:00
|
|
|
#include <linux/console.h>
|
|
|
|
|
2012-11-16 05:28:22 +08:00
|
|
|
#include "drm.h"
|
2013-03-22 22:34:08 +08:00
|
|
|
#include "gem.h"
|
|
|
|
|
|
|
|
static inline struct tegra_fb *to_tegra_fb(struct drm_framebuffer *fb)
|
|
|
|
{
|
|
|
|
return container_of(fb, struct tegra_fb, base);
|
|
|
|
}
|
|
|
|
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 22:34:08 +08:00
|
|
|
static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper)
|
|
|
|
{
|
|
|
|
return container_of(helper, struct tegra_fbdev, base);
|
|
|
|
}
|
2013-10-31 20:28:50 +08:00
|
|
|
#endif
|
2013-03-22 22:34:08 +08:00
|
|
|
|
|
|
|
struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
|
|
|
|
unsigned int index)
|
|
|
|
{
|
|
|
|
struct tegra_fb *fb = to_tegra_fb(framebuffer);
|
|
|
|
|
|
|
|
if (index >= drm_format_num_planes(framebuffer->pixel_format))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return fb->planes[index];
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:47:58 +08:00
|
|
|
bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer)
|
|
|
|
{
|
|
|
|
struct tegra_fb *fb = to_tegra_fb(framebuffer);
|
|
|
|
|
|
|
|
if (fb->planes[0]->flags & TEGRA_BO_BOTTOM_UP)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-03 20:48:12 +08:00
|
|
|
int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
|
|
|
|
struct tegra_bo_tiling *tiling)
|
2013-10-05 04:34:01 +08:00
|
|
|
{
|
|
|
|
struct tegra_fb *fb = to_tegra_fb(framebuffer);
|
|
|
|
|
2014-06-03 20:48:12 +08:00
|
|
|
/* TODO: handle YUV formats? */
|
|
|
|
*tiling = fb->planes[0]->tiling;
|
2013-10-05 04:34:01 +08:00
|
|
|
|
2014-06-03 20:48:12 +08:00
|
|
|
return 0;
|
2013-10-05 04:34:01 +08:00
|
|
|
}
|
|
|
|
|
2013-03-22 22:34:08 +08:00
|
|
|
static void tegra_fb_destroy(struct drm_framebuffer *framebuffer)
|
|
|
|
{
|
|
|
|
struct tegra_fb *fb = to_tegra_fb(framebuffer);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fb->num_planes; i++) {
|
|
|
|
struct tegra_bo *bo = fb->planes[i];
|
|
|
|
|
2014-06-27 03:41:53 +08:00
|
|
|
if (bo) {
|
|
|
|
if (bo->pages && bo->vaddr)
|
|
|
|
vunmap(bo->vaddr);
|
|
|
|
|
2013-03-22 22:34:08 +08:00
|
|
|
drm_gem_object_unreference_unlocked(&bo->gem);
|
2014-06-27 03:41:53 +08:00
|
|
|
}
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
drm_framebuffer_cleanup(framebuffer);
|
|
|
|
kfree(fb->planes);
|
|
|
|
kfree(fb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tegra_fb_create_handle(struct drm_framebuffer *framebuffer,
|
|
|
|
struct drm_file *file, unsigned int *handle)
|
|
|
|
{
|
|
|
|
struct tegra_fb *fb = to_tegra_fb(framebuffer);
|
|
|
|
|
|
|
|
return drm_gem_handle_create(file, &fb->planes[0]->gem, handle);
|
|
|
|
}
|
|
|
|
|
2015-12-15 19:21:13 +08:00
|
|
|
static const struct drm_framebuffer_funcs tegra_fb_funcs = {
|
2013-03-22 22:34:08 +08:00
|
|
|
.destroy = tegra_fb_destroy,
|
|
|
|
.create_handle = tegra_fb_create_handle,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm,
|
2015-11-12 01:11:29 +08:00
|
|
|
const struct drm_mode_fb_cmd2 *mode_cmd,
|
2013-03-22 22:34:08 +08:00
|
|
|
struct tegra_bo **planes,
|
|
|
|
unsigned int num_planes)
|
|
|
|
{
|
|
|
|
struct tegra_fb *fb;
|
|
|
|
unsigned int i;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
fb = kzalloc(sizeof(*fb), GFP_KERNEL);
|
|
|
|
if (!fb)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
fb->planes = kzalloc(num_planes * sizeof(*planes), GFP_KERNEL);
|
2013-11-12 18:25:26 +08:00
|
|
|
if (!fb->planes) {
|
|
|
|
kfree(fb);
|
2013-03-22 22:34:08 +08:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2013-11-12 18:25:26 +08:00
|
|
|
}
|
2013-03-22 22:34:08 +08:00
|
|
|
|
|
|
|
fb->num_planes = num_planes;
|
|
|
|
|
|
|
|
drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
|
|
|
|
|
|
|
|
for (i = 0; i < fb->num_planes; i++)
|
|
|
|
fb->planes[i] = planes[i];
|
|
|
|
|
|
|
|
err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs);
|
|
|
|
if (err < 0) {
|
|
|
|
dev_err(drm->dev, "failed to initialize framebuffer: %d\n",
|
|
|
|
err);
|
|
|
|
kfree(fb->planes);
|
|
|
|
kfree(fb);
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
}
|
|
|
|
|
2014-11-26 20:03:57 +08:00
|
|
|
struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
|
|
|
|
struct drm_file *file,
|
2015-11-12 01:11:29 +08:00
|
|
|
const struct drm_mode_fb_cmd2 *cmd)
|
2013-03-22 22:34:08 +08:00
|
|
|
{
|
|
|
|
unsigned int hsub, vsub, i;
|
|
|
|
struct tegra_bo *planes[4];
|
|
|
|
struct drm_gem_object *gem;
|
|
|
|
struct tegra_fb *fb;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
hsub = drm_format_horz_chroma_subsampling(cmd->pixel_format);
|
|
|
|
vsub = drm_format_vert_chroma_subsampling(cmd->pixel_format);
|
|
|
|
|
|
|
|
for (i = 0; i < drm_format_num_planes(cmd->pixel_format); i++) {
|
|
|
|
unsigned int width = cmd->width / (i ? hsub : 1);
|
|
|
|
unsigned int height = cmd->height / (i ? vsub : 1);
|
|
|
|
unsigned int size, bpp;
|
|
|
|
|
|
|
|
gem = drm_gem_object_lookup(drm, file, cmd->handles[i]);
|
|
|
|
if (!gem) {
|
|
|
|
err = -ENXIO;
|
|
|
|
goto unreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
bpp = drm_format_plane_cpp(cmd->pixel_format, i);
|
|
|
|
|
|
|
|
size = (height - 1) * cmd->pitches[i] +
|
|
|
|
width * bpp + cmd->offsets[i];
|
|
|
|
|
|
|
|
if (gem->size < size) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto unreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
planes[i] = to_tegra_bo(gem);
|
|
|
|
}
|
|
|
|
|
|
|
|
fb = tegra_fb_alloc(drm, cmd, planes, i);
|
|
|
|
if (IS_ERR(fb)) {
|
|
|
|
err = PTR_ERR(fb);
|
|
|
|
goto unreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &fb->base;
|
|
|
|
|
|
|
|
unreference:
|
|
|
|
while (i--)
|
|
|
|
drm_gem_object_unreference_unlocked(&planes[i]->gem);
|
2012-11-16 05:28:22 +08:00
|
|
|
|
2013-03-22 22:34:08 +08:00
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 22:34:08 +08:00
|
|
|
static struct fb_ops tegra_fb_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
2015-07-22 17:28:07 +08:00
|
|
|
.fb_fillrect = drm_fb_helper_sys_fillrect,
|
|
|
|
.fb_copyarea = drm_fb_helper_sys_copyarea,
|
|
|
|
.fb_imageblit = drm_fb_helper_sys_imageblit,
|
2013-03-22 22:34:08 +08:00
|
|
|
.fb_check_var = drm_fb_helper_check_var,
|
|
|
|
.fb_set_par = drm_fb_helper_set_par,
|
|
|
|
.fb_blank = drm_fb_helper_blank,
|
|
|
|
.fb_pan_display = drm_fb_helper_pan_display,
|
|
|
|
.fb_setcmap = drm_fb_helper_setcmap,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int tegra_fbdev_probe(struct drm_fb_helper *helper,
|
|
|
|
struct drm_fb_helper_surface_size *sizes)
|
|
|
|
{
|
|
|
|
struct tegra_fbdev *fbdev = to_tegra_fbdev(helper);
|
2014-07-11 14:29:14 +08:00
|
|
|
struct tegra_drm *tegra = helper->dev->dev_private;
|
2013-03-22 22:34:08 +08:00
|
|
|
struct drm_device *drm = helper->dev;
|
|
|
|
struct drm_mode_fb_cmd2 cmd = { 0 };
|
|
|
|
unsigned int bytes_per_pixel;
|
|
|
|
struct drm_framebuffer *fb;
|
|
|
|
unsigned long offset;
|
|
|
|
struct fb_info *info;
|
|
|
|
struct tegra_bo *bo;
|
|
|
|
size_t size;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8);
|
|
|
|
|
|
|
|
cmd.width = sizes->surface_width;
|
|
|
|
cmd.height = sizes->surface_height;
|
2014-07-11 14:29:14 +08:00
|
|
|
cmd.pitches[0] = round_up(sizes->surface_width * bytes_per_pixel,
|
|
|
|
tegra->pitch_align);
|
2013-03-22 22:34:08 +08:00
|
|
|
cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
|
|
|
|
sizes->surface_depth);
|
|
|
|
|
|
|
|
size = cmd.pitches[0] * cmd.height;
|
|
|
|
|
2013-10-05 04:34:01 +08:00
|
|
|
bo = tegra_bo_create(drm, size, 0);
|
2013-03-22 22:34:08 +08:00
|
|
|
if (IS_ERR(bo))
|
|
|
|
return PTR_ERR(bo);
|
|
|
|
|
2015-07-22 17:28:07 +08:00
|
|
|
info = drm_fb_helper_alloc_fbi(helper);
|
|
|
|
if (IS_ERR(info)) {
|
2013-03-22 22:34:08 +08:00
|
|
|
dev_err(drm->dev, "failed to allocate framebuffer info\n");
|
2014-11-06 21:33:19 +08:00
|
|
|
drm_gem_object_unreference_unlocked(&bo->gem);
|
2015-07-22 17:28:07 +08:00
|
|
|
return PTR_ERR(info);
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fbdev->fb = tegra_fb_alloc(drm, &cmd, &bo, 1);
|
|
|
|
if (IS_ERR(fbdev->fb)) {
|
|
|
|
err = PTR_ERR(fbdev->fb);
|
2014-11-06 21:36:19 +08:00
|
|
|
dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n",
|
|
|
|
err);
|
2014-11-06 21:33:19 +08:00
|
|
|
drm_gem_object_unreference_unlocked(&bo->gem);
|
2013-03-22 22:34:08 +08:00
|
|
|
goto release;
|
|
|
|
}
|
|
|
|
|
|
|
|
fb = &fbdev->fb->base;
|
|
|
|
helper->fb = fb;
|
|
|
|
helper->fbdev = info;
|
|
|
|
|
|
|
|
info->par = helper;
|
|
|
|
info->flags = FBINFO_FLAG_DEFAULT;
|
|
|
|
info->fbops = &tegra_fb_ops;
|
|
|
|
|
|
|
|
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
|
|
|
|
drm_fb_helper_fill_var(info, helper, fb->width, fb->height);
|
|
|
|
|
|
|
|
offset = info->var.xoffset * bytes_per_pixel +
|
|
|
|
info->var.yoffset * fb->pitches[0];
|
|
|
|
|
2014-06-27 03:41:53 +08:00
|
|
|
if (bo->pages) {
|
|
|
|
bo->vaddr = vmap(bo->pages, bo->num_pages, VM_MAP,
|
|
|
|
pgprot_writecombine(PAGE_KERNEL));
|
|
|
|
if (!bo->vaddr) {
|
|
|
|
dev_err(drm->dev, "failed to vmap() framebuffer\n");
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto destroy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 22:34:08 +08:00
|
|
|
drm->mode_config.fb_base = (resource_size_t)bo->paddr;
|
2013-11-08 20:18:14 +08:00
|
|
|
info->screen_base = (void __iomem *)bo->vaddr + offset;
|
2013-03-22 22:34:08 +08:00
|
|
|
info->screen_size = size;
|
|
|
|
info->fix.smem_start = (unsigned long)(bo->paddr + offset);
|
|
|
|
info->fix.smem_len = size;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
destroy:
|
|
|
|
drm_framebuffer_unregister_private(fb);
|
|
|
|
tegra_fb_destroy(fb);
|
|
|
|
release:
|
2015-07-22 17:28:07 +08:00
|
|
|
drm_fb_helper_release_fbi(helper);
|
2013-03-22 22:34:08 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:19:23 +08:00
|
|
|
static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = {
|
2013-03-22 22:34:08 +08:00
|
|
|
.fb_probe = tegra_fbdev_probe,
|
|
|
|
};
|
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm)
|
2013-03-22 22:34:08 +08:00
|
|
|
{
|
|
|
|
struct tegra_fbdev *fbdev;
|
|
|
|
|
|
|
|
fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
|
|
|
|
if (!fbdev) {
|
|
|
|
dev_err(drm->dev, "failed to allocate DRM fbdev\n");
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:19:24 +08:00
|
|
|
drm_fb_helper_prepare(drm, &fbdev->base, &tegra_fb_helper_funcs);
|
2013-03-22 22:34:08 +08:00
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
return fbdev;
|
|
|
|
}
|
|
|
|
|
2014-11-06 21:12:08 +08:00
|
|
|
static void tegra_fbdev_free(struct tegra_fbdev *fbdev)
|
|
|
|
{
|
|
|
|
kfree(fbdev);
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
static int tegra_fbdev_init(struct tegra_fbdev *fbdev,
|
|
|
|
unsigned int preferred_bpp,
|
|
|
|
unsigned int num_crtc,
|
|
|
|
unsigned int max_connectors)
|
|
|
|
{
|
|
|
|
struct drm_device *drm = fbdev->base.dev;
|
|
|
|
int err;
|
|
|
|
|
2013-03-22 22:34:08 +08:00
|
|
|
err = drm_fb_helper_init(drm, &fbdev->base, num_crtc, max_connectors);
|
|
|
|
if (err < 0) {
|
2014-11-06 21:36:19 +08:00
|
|
|
dev_err(drm->dev, "failed to initialize DRM FB helper: %d\n",
|
|
|
|
err);
|
2014-06-27 23:19:25 +08:00
|
|
|
return err;
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err = drm_fb_helper_single_add_all_connectors(&fbdev->base);
|
|
|
|
if (err < 0) {
|
2014-11-06 21:36:19 +08:00
|
|
|
dev_err(drm->dev, "failed to add connectors: %d\n", err);
|
2013-03-22 22:34:08 +08:00
|
|
|
goto fini;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = drm_fb_helper_initial_config(&fbdev->base, preferred_bpp);
|
|
|
|
if (err < 0) {
|
2014-11-06 21:36:19 +08:00
|
|
|
dev_err(drm->dev, "failed to set initial configuration: %d\n",
|
|
|
|
err);
|
2013-03-22 22:34:08 +08:00
|
|
|
goto fini;
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
return 0;
|
2013-03-22 22:34:08 +08:00
|
|
|
|
|
|
|
fini:
|
|
|
|
drm_fb_helper_fini(&fbdev->base);
|
2014-06-27 23:19:25 +08:00
|
|
|
return err;
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
2014-11-06 21:12:08 +08:00
|
|
|
static void tegra_fbdev_exit(struct tegra_fbdev *fbdev)
|
2013-03-22 22:34:08 +08:00
|
|
|
{
|
2015-07-22 17:28:07 +08:00
|
|
|
drm_fb_helper_unregister_fbi(&fbdev->base);
|
|
|
|
drm_fb_helper_release_fbi(&fbdev->base);
|
2013-03-22 22:34:08 +08:00
|
|
|
|
|
|
|
if (fbdev->fb) {
|
|
|
|
drm_framebuffer_unregister_private(&fbdev->fb->base);
|
2014-10-21 19:56:59 +08:00
|
|
|
drm_framebuffer_remove(&fbdev->fb->base);
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
drm_fb_helper_fini(&fbdev->base);
|
2014-11-06 21:12:08 +08:00
|
|
|
tegra_fbdev_free(fbdev);
|
2013-03-22 22:34:08 +08:00
|
|
|
}
|
|
|
|
|
2013-10-31 20:28:50 +08:00
|
|
|
void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev)
|
|
|
|
{
|
2014-05-31 00:29:48 +08:00
|
|
|
if (fbdev)
|
|
|
|
drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev->base);
|
2013-10-31 20:28:50 +08:00
|
|
|
}
|
|
|
|
|
2014-11-26 20:03:57 +08:00
|
|
|
void tegra_fb_output_poll_changed(struct drm_device *drm)
|
2012-11-16 05:28:22 +08:00
|
|
|
{
|
2013-09-24 19:22:17 +08:00
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
2012-11-16 05:28:22 +08:00
|
|
|
|
2013-09-24 19:22:17 +08:00
|
|
|
if (tegra->fbdev)
|
|
|
|
drm_fb_helper_hotplug_event(&tegra->fbdev->base);
|
2012-11-16 05:28:22 +08:00
|
|
|
}
|
2013-10-31 20:28:50 +08:00
|
|
|
#endif
|
2012-11-16 05:28:22 +08:00
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
int tegra_drm_fb_prepare(struct drm_device *drm)
|
2012-11-16 05:28:22 +08:00
|
|
|
{
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-09-24 19:22:17 +08:00
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
2012-11-16 05:28:22 +08:00
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
tegra->fbdev = tegra_fbdev_create(drm);
|
2013-10-31 20:28:50 +08:00
|
|
|
if (IS_ERR(tegra->fbdev))
|
|
|
|
return PTR_ERR(tegra->fbdev);
|
|
|
|
#endif
|
2012-11-16 05:28:22 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-06 21:12:08 +08:00
|
|
|
void tegra_drm_fb_free(struct drm_device *drm)
|
|
|
|
{
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2014-11-06 21:12:08 +08:00
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
|
|
|
|
|
|
|
tegra_fbdev_free(tegra->fbdev);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:19:25 +08:00
|
|
|
int tegra_drm_fb_init(struct drm_device *drm)
|
|
|
|
{
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2014-06-27 23:19:25 +08:00
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = tegra_fbdev_init(tegra->fbdev, 32, drm->mode_config.num_crtc,
|
|
|
|
drm->mode_config.num_connector);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-16 05:28:22 +08:00
|
|
|
void tegra_drm_fb_exit(struct drm_device *drm)
|
|
|
|
{
|
2015-10-27 16:10:59 +08:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-09-24 19:22:17 +08:00
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
2012-11-16 05:28:22 +08:00
|
|
|
|
2014-11-06 21:12:08 +08:00
|
|
|
tegra_fbdev_exit(tegra->fbdev);
|
2013-10-31 20:28:50 +08:00
|
|
|
#endif
|
2012-11-16 05:28:22 +08:00
|
|
|
}
|
2015-08-11 19:11:49 +08:00
|
|
|
|
|
|
|
void tegra_drm_fb_suspend(struct drm_device *drm)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
|
|
|
|
|
|
|
console_lock();
|
|
|
|
drm_fb_helper_set_suspend(&tegra->fbdev->base, 1);
|
|
|
|
console_unlock();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void tegra_drm_fb_resume(struct drm_device *drm)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
|
|
|
struct tegra_drm *tegra = drm->dev_private;
|
|
|
|
|
|
|
|
console_lock();
|
|
|
|
drm_fb_helper_set_suspend(&tegra->fbdev->base, 0);
|
|
|
|
console_unlock();
|
|
|
|
#endif
|
|
|
|
}
|