mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 10:31:53 +07:00
d7563c55ef
UAPI Changes: - Add syncobj timeline support to drm. Cross-subsystem Changes: - Remove shared fence staging in dma-buf's fence object, and allow reserving more than 1 fence and add more paranoia when debugging. - Constify infoframe functions in video/hdmi. Core Changes: - Add vkms todo, and a lot of assorted doc fixes. - Drop transitional helpers and convert drivers to use drm_atomic_helper_shutdown(). - Move atomic state helper functions to drm_atomic_state_helper.[ch] - Refactor drm selftests, and add new tests. - DP MST atomic state cleanups. - Drop EXPORT_SYMBOL from drm leases. - Lease cleanups and fixes. - Create render node for vgem. Driver Changes: - Fix build failure in imx without fbdev emulation. - Add rotation quirk for GPD win2 panel. - Add support for various CDTech panels, Banana Pi Panel, DLC1010GIG, Olimex LCD-O-LinuXino, Samsung S6D16D0, Truly NT35597 WQXGA, Himax HX8357D, simulated RTSM AEMv8. - Add dw_hdmi support to rockchip driver. - Fix YUV support in vc4. - Fix resource id handling in virtio. - Make rockchip use dw-mipi-dsi bridge driver, and add dual dsi support. - Advertise that tinydrm only supports DRM_FORMAT_MOD_LINEAR. - Convert many drivers to use atomic helpers, and drm_fbdev_generic_setup(). - Add Mali linear tiled formats, and enable them in the Mali-DP driver. - Add support for H6 DE3 mixer 0, DW HDMI, HDMI PHY and TCON TOP. - Assorted driver cleanups and fixes. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEuXvWqAysSYEJGuVH/lWMcqZwE8MFAlvi0eAACgkQ/lWMcqZw E8PI3g//TIlMmbrUc6BrWCNnz4YpJ+mC2dq7HMYB4yf5QeXTYrRDqK6syakbGcbe FGYxt+21REfyQ9IQPdQslmVIUqJZuMBFSvLjXnZvybJSllE23CAXG0hEwHTuPYiF yzxmYwlYOxVlW0nnB3fEDM8BfbWyMYR03c4sobPgiAGoBd+CJif/BtKEwranYrRx 7rZh8PnrCPGAnewmYux6U4zkOpWyjUp5t3kqpNRJDxPfxpa991yvUJX3DxTFFr9b nqYNp3F3fkdowYuJj2eH/uBNd17TouzITGQxIZWEsJfFvB+2Awp7KgRCT8nUAt0I vELbADsy3QwZlQp1F2FaVwfGbmHr41F+Vsq9coUt4vPaiyT3vCW0KGCeal1dKyYf +S8UXIijkoGXm0RqxkbkJsG7AYSIzG+NQm6W+9tnQg6CwpQb2wqU3YCPQWqtFHqM Tz/EW+JqG5Wl1aHXVEbnSajtqT2ooskwHfy81iwNqaGwVy+ZSLIZpqC91Hk9SyZ9 HBDuKWSzqEqXWf7nwbOTm0umQ9mk8+I41k+dyqc2fq9z/gySqKd32eC3aLa0/p3y 6bngvu1TT6jNhRdduwxgl/Y5cnQp/Zg9wYRKmAjViZtooaWj8p2o45AufGz1rplR BdYVUOPofVVD9ShwxayWzuocFW/HbgYc7FHHgKUFgFBO5iC/A2s= =UV0m -----END PGP SIGNATURE----- Merge tag 'drm-misc-next-2018-11-07' of git://anongit.freedesktop.org/drm/drm-misc into drm-next drm-misc-next for v4.21, part 1: UAPI Changes: - Add syncobj timeline support to drm. Cross-subsystem Changes: - Remove shared fence staging in dma-buf's fence object, and allow reserving more than 1 fence and add more paranoia when debugging. - Constify infoframe functions in video/hdmi. Core Changes: - Add vkms todo, and a lot of assorted doc fixes. - Drop transitional helpers and convert drivers to use drm_atomic_helper_shutdown(). - Move atomic state helper functions to drm_atomic_state_helper.[ch] - Refactor drm selftests, and add new tests. - DP MST atomic state cleanups. - Drop EXPORT_SYMBOL from drm leases. - Lease cleanups and fixes. - Create render node for vgem. Driver Changes: - Fix build failure in imx without fbdev emulation. - Add rotation quirk for GPD win2 panel. - Add support for various CDTech panels, Banana Pi Panel, DLC1010GIG, Olimex LCD-O-LinuXino, Samsung S6D16D0, Truly NT35597 WQXGA, Himax HX8357D, simulated RTSM AEMv8. - Add dw_hdmi support to rockchip driver. - Fix YUV support in vc4. - Fix resource id handling in virtio. - Make rockchip use dw-mipi-dsi bridge driver, and add dual dsi support. - Advertise that tinydrm only supports DRM_FORMAT_MOD_LINEAR. - Convert many drivers to use atomic helpers, and drm_fbdev_generic_setup(). - Add Mali linear tiled formats, and enable them in the Mali-DP driver. - Add support for H6 DE3 mixer 0, DW HDMI, HDMI PHY and TCON TOP. - Assorted driver cleanups and fixes. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/be7ebd91-edd9-8fa4-4286-1c57e3165113@linux.intel.com
240 lines
6.7 KiB
C
240 lines
6.7 KiB
C
/*
|
|
* 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
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_client.h>
|
|
#include <drm/drm_fb_helper.h>
|
|
#include <drm/drm_framebuffer.h>
|
|
#include <drm/drm_gem_cma_helper.h>
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
|
#include <drm/drm_fb_cma_helper.h>
|
|
#include <drm/drm_print.h>
|
|
#include <linux/module.h>
|
|
|
|
struct drm_fbdev_cma {
|
|
struct drm_fb_helper fb_helper;
|
|
};
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* An fbdev framebuffer backed by cma is also available by calling
|
|
* drm_fb_cma_fbdev_init(). drm_fb_cma_fbdev_fini() tears it down.
|
|
*/
|
|
|
|
static inline struct drm_fbdev_cma *to_fbdev_cma(struct drm_fb_helper *helper)
|
|
{
|
|
return container_of(helper, struct drm_fbdev_cma, fb_helper);
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* drm_fb_cma_fbdev_init() - Allocate and initialize fbdev emulation
|
|
* @dev: DRM device
|
|
* @preferred_bpp: Preferred bits per pixel for the device.
|
|
* @dev->mode_config.preferred_depth is used if this is zero.
|
|
* @max_conn_count: Maximum number of connectors.
|
|
* @dev->mode_config.num_connector is used if this is zero.
|
|
*
|
|
* Returns:
|
|
* Zero on success or negative error code on failure.
|
|
*/
|
|
int drm_fb_cma_fbdev_init(struct drm_device *dev, unsigned int preferred_bpp,
|
|
unsigned int max_conn_count)
|
|
{
|
|
struct drm_fbdev_cma *fbdev_cma;
|
|
|
|
/* dev->fb_helper will indirectly point to fbdev_cma after this call */
|
|
fbdev_cma = drm_fbdev_cma_init(dev, preferred_bpp, max_conn_count);
|
|
return PTR_ERR_OR_ZERO(fbdev_cma);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fb_cma_fbdev_init);
|
|
|
|
/**
|
|
* drm_fb_cma_fbdev_fini() - Teardown fbdev emulation
|
|
* @dev: DRM device
|
|
*/
|
|
void drm_fb_cma_fbdev_fini(struct drm_device *dev)
|
|
{
|
|
if (dev->fb_helper)
|
|
drm_fbdev_cma_fini(to_fbdev_cma(dev->fb_helper));
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fb_cma_fbdev_fini);
|
|
|
|
static const struct drm_fb_helper_funcs drm_fb_cma_helper_funcs = {
|
|
.fb_probe = drm_fb_helper_generic_probe,
|
|
};
|
|
|
|
/**
|
|
* drm_fbdev_cma_init() - Allocate and initializes a drm_fbdev_cma struct
|
|
* @dev: DRM device
|
|
* @preferred_bpp: Preferred bits per pixel for the device
|
|
* @max_conn_count: Maximum number of connectors
|
|
*
|
|
* Returns a newly allocated drm_fbdev_cma struct or a ERR_PTR.
|
|
*/
|
|
struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev,
|
|
unsigned int preferred_bpp, unsigned int max_conn_count)
|
|
{
|
|
struct drm_fbdev_cma *fbdev_cma;
|
|
struct drm_fb_helper *fb_helper;
|
|
int ret;
|
|
|
|
fbdev_cma = kzalloc(sizeof(*fbdev_cma), GFP_KERNEL);
|
|
if (!fbdev_cma)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
fb_helper = &fbdev_cma->fb_helper;
|
|
|
|
ret = drm_client_init(dev, &fb_helper->client, "fbdev", NULL);
|
|
if (ret)
|
|
goto err_free;
|
|
|
|
ret = drm_fb_helper_fbdev_setup(dev, fb_helper, &drm_fb_cma_helper_funcs,
|
|
preferred_bpp, max_conn_count);
|
|
if (ret)
|
|
goto err_client_put;
|
|
|
|
drm_client_add(&fb_helper->client);
|
|
|
|
return fbdev_cma;
|
|
|
|
err_client_put:
|
|
drm_client_release(&fb_helper->client);
|
|
err_free:
|
|
kfree(fbdev_cma);
|
|
|
|
return ERR_PTR(ret);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
|
|
|
|
/**
|
|
* drm_fbdev_cma_fini() - Free drm_fbdev_cma struct
|
|
* @fbdev_cma: The drm_fbdev_cma struct
|
|
*/
|
|
void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
|
|
{
|
|
drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
|
|
/* All resources have now been freed by drm_fbdev_fb_destroy() */
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fbdev_cma_fini);
|
|
|
|
/**
|
|
* drm_fbdev_cma_restore_mode() - Restores initial framebuffer mode
|
|
* @fbdev_cma: The drm_fbdev_cma struct, may be NULL
|
|
*
|
|
* This function is usually called from the &drm_driver.lastclose callback.
|
|
*/
|
|
void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma)
|
|
{
|
|
if (fbdev_cma)
|
|
drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev_cma->fb_helper);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fbdev_cma_restore_mode);
|
|
|
|
/**
|
|
* drm_fbdev_cma_hotplug_event() - Poll for hotpulug events
|
|
* @fbdev_cma: The drm_fbdev_cma struct, may be NULL
|
|
*
|
|
* This function is usually called from the &drm_mode_config.output_poll_changed
|
|
* callback.
|
|
*/
|
|
void drm_fbdev_cma_hotplug_event(struct drm_fbdev_cma *fbdev_cma)
|
|
{
|
|
if (fbdev_cma)
|
|
drm_fb_helper_hotplug_event(&fbdev_cma->fb_helper);
|
|
}
|
|
EXPORT_SYMBOL_GPL(drm_fbdev_cma_hotplug_event);
|