mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 12:05:10 +07:00
c942fddf87
Based on 3 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [graeme] [gregory] [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema] [hk] [hemahk]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1105 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
99 lines
2.6 KiB
C
99 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* drm kms/fb cma (contiguous memory allocator) helper functions
|
|
*
|
|
* Copyright (C) 2012 Analog Device Inc.
|
|
* Author: Lars-Peter Clausen <lars@metafoo.de>
|
|
*
|
|
* Based on udl_fbdev.c
|
|
* Copyright (C) 2012 Red Hat
|
|
*/
|
|
|
|
#include <drm/drm_fourcc.h>
|
|
#include <drm/drm_framebuffer.h>
|
|
#include <drm/drm_gem_cma_helper.h>
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
|
#include <drm/drm_plane.h>
|
|
#include <linux/module.h>
|
|
|
|
/**
|
|
* DOC: framebuffer cma helper functions
|
|
*
|
|
* Provides helper functions for creating a cma (contiguous memory allocator)
|
|
* backed framebuffer.
|
|
*
|
|
* drm_gem_fb_create() is used in the &drm_mode_config_funcs.fb_create
|
|
* callback function to create a cma backed framebuffer.
|
|
*/
|
|
|
|
/**
|
|
* drm_fb_cma_get_gem_obj() - Get CMA GEM object for framebuffer
|
|
* @fb: The framebuffer
|
|
* @plane: Which plane
|
|
*
|
|
* Return the CMA GEM object for given framebuffer.
|
|
*
|
|
* This function will usually be called from the CRTC callback functions.
|
|
*/
|
|
struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
|
|
unsigned int plane)
|
|
{
|
|
struct drm_gem_object *gem;
|
|
|
|
gem = drm_gem_fb_get_obj(fb, plane);
|
|
if (!gem)
|
|
return NULL;
|
|
|
|
return to_drm_gem_cma_obj(gem);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);
|
|
|
|
/**
|
|
* drm_fb_cma_get_gem_addr() - Get physical address for framebuffer, for pixel
|
|
* formats where values are grouped in blocks this will get you the beginning of
|
|
* the block
|
|
* @fb: The framebuffer
|
|
* @state: Which state of drm plane
|
|
* @plane: Which plane
|
|
* Return the CMA GEM address for given framebuffer.
|
|
*
|
|
* This function will usually be called from the PLANE callback functions.
|
|
*/
|
|
dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
|
|
struct drm_plane_state *state,
|
|
unsigned int plane)
|
|
{
|
|
struct drm_gem_cma_object *obj;
|
|
dma_addr_t paddr;
|
|
u8 h_div = 1, v_div = 1;
|
|
u32 block_w = drm_format_info_block_width(fb->format, plane);
|
|
u32 block_h = drm_format_info_block_height(fb->format, plane);
|
|
u32 block_size = fb->format->char_per_block[plane];
|
|
u32 sample_x;
|
|
u32 sample_y;
|
|
u32 block_start_y;
|
|
u32 num_hblocks;
|
|
|
|
obj = drm_fb_cma_get_gem_obj(fb, plane);
|
|
if (!obj)
|
|
return 0;
|
|
|
|
paddr = obj->paddr + fb->offsets[plane];
|
|
|
|
if (plane > 0) {
|
|
h_div = fb->format->hsub;
|
|
v_div = fb->format->vsub;
|
|
}
|
|
|
|
sample_x = (state->src_x >> 16) / h_div;
|
|
sample_y = (state->src_y >> 16) / v_div;
|
|
block_start_y = (sample_y / block_h) * block_h;
|
|
num_hblocks = sample_x / block_w;
|
|
|
|
paddr += fb->pitches[plane] * block_start_y;
|
|
paddr += block_size * num_hblocks;
|
|
|
|
return paddr;
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr);
|