drm: xlnx: zynqmp_dpsub: Move all DRM init and cleanup to zynqmp_kms.c
Continue the isolation of DRM/KMS code by moving all DRM init and cleanup from zynqmp_dpsub.c to zynqmp_kms.c. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
6ca91bb43a
commit
074ef0ce9f
@ -18,126 +18,16 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include <drm/drm_atomic_helper.h>
|
#include <drm/drm_atomic_helper.h>
|
||||||
#include <drm/drm_bridge_connector.h>
|
|
||||||
#include <drm/drm_device.h>
|
|
||||||
#include <drm/drm_drv.h>
|
#include <drm/drm_drv.h>
|
||||||
#include <drm/drm_fb_helper.h>
|
|
||||||
#include <drm/drm_fourcc.h>
|
|
||||||
#include <drm/drm_gem_dma_helper.h>
|
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
|
||||||
#include <drm/drm_managed.h>
|
#include <drm/drm_managed.h>
|
||||||
#include <drm/drm_mode_config.h>
|
#include <drm/drm_modeset_helper.h>
|
||||||
#include <drm/drm_module.h>
|
#include <drm/drm_module.h>
|
||||||
#include <drm/drm_probe_helper.h>
|
|
||||||
#include <drm/drm_vblank.h>
|
|
||||||
|
|
||||||
#include "zynqmp_disp.h"
|
#include "zynqmp_disp.h"
|
||||||
#include "zynqmp_dp.h"
|
#include "zynqmp_dp.h"
|
||||||
#include "zynqmp_dpsub.h"
|
#include "zynqmp_dpsub.h"
|
||||||
#include "zynqmp_kms.h"
|
#include "zynqmp_kms.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Dumb Buffer & Framebuffer Allocation
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int zynqmp_dpsub_dumb_create(struct drm_file *file_priv,
|
|
||||||
struct drm_device *drm,
|
|
||||||
struct drm_mode_create_dumb *args)
|
|
||||||
{
|
|
||||||
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(drm);
|
|
||||||
unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
|
|
||||||
|
|
||||||
/* Enforce the alignment constraints of the DMA engine. */
|
|
||||||
args->pitch = ALIGN(pitch, dpsub->dma_align);
|
|
||||||
|
|
||||||
return drm_gem_dma_dumb_create_internal(file_priv, drm, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct drm_framebuffer *
|
|
||||||
zynqmp_dpsub_fb_create(struct drm_device *drm, struct drm_file *file_priv,
|
|
||||||
const struct drm_mode_fb_cmd2 *mode_cmd)
|
|
||||||
{
|
|
||||||
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(drm);
|
|
||||||
struct drm_mode_fb_cmd2 cmd = *mode_cmd;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
/* Enforce the alignment constraints of the DMA engine. */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(cmd.pitches); ++i)
|
|
||||||
cmd.pitches[i] = ALIGN(cmd.pitches[i], dpsub->dma_align);
|
|
||||||
|
|
||||||
return drm_gem_fb_create(drm, file_priv, &cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct drm_mode_config_funcs zynqmp_dpsub_mode_config_funcs = {
|
|
||||||
.fb_create = zynqmp_dpsub_fb_create,
|
|
||||||
.atomic_check = drm_atomic_helper_check,
|
|
||||||
.atomic_commit = drm_atomic_helper_commit,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DRM/KMS Driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
DEFINE_DRM_GEM_DMA_FOPS(zynqmp_dpsub_drm_fops);
|
|
||||||
|
|
||||||
static const struct drm_driver zynqmp_dpsub_drm_driver = {
|
|
||||||
.driver_features = DRIVER_MODESET | DRIVER_GEM |
|
|
||||||
DRIVER_ATOMIC,
|
|
||||||
|
|
||||||
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(zynqmp_dpsub_dumb_create),
|
|
||||||
|
|
||||||
.fops = &zynqmp_dpsub_drm_fops,
|
|
||||||
|
|
||||||
.name = "zynqmp-dpsub",
|
|
||||||
.desc = "Xilinx DisplayPort Subsystem Driver",
|
|
||||||
.date = "20130509",
|
|
||||||
.major = 1,
|
|
||||||
.minor = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
|
|
||||||
{
|
|
||||||
struct drm_device *drm = &dpsub->drm;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Initialize mode config, vblank and the KMS poll helper. */
|
|
||||||
ret = drmm_mode_config_init(drm);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
drm->mode_config.funcs = &zynqmp_dpsub_mode_config_funcs;
|
|
||||||
drm->mode_config.min_width = 0;
|
|
||||||
drm->mode_config.min_height = 0;
|
|
||||||
drm->mode_config.max_width = ZYNQMP_DISP_MAX_WIDTH;
|
|
||||||
drm->mode_config.max_height = ZYNQMP_DISP_MAX_HEIGHT;
|
|
||||||
|
|
||||||
ret = drm_vblank_init(drm, 1);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
drm_kms_helper_poll_init(drm);
|
|
||||||
|
|
||||||
ret = zynqmp_dpsub_kms_init(dpsub);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err_poll_fini;
|
|
||||||
|
|
||||||
/* Reset all components and register the DRM device. */
|
|
||||||
drm_mode_config_reset(drm);
|
|
||||||
|
|
||||||
ret = drm_dev_register(drm, 0);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err_poll_fini;
|
|
||||||
|
|
||||||
/* Initialize fbdev generic emulation. */
|
|
||||||
drm_fbdev_generic_setup(drm, 24);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_poll_fini:
|
|
||||||
drm_kms_helper_poll_fini(drm);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Power Management
|
* Power Management
|
||||||
*/
|
*/
|
||||||
@ -320,11 +210,8 @@ err_mem:
|
|||||||
static int zynqmp_dpsub_remove(struct platform_device *pdev)
|
static int zynqmp_dpsub_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct zynqmp_dpsub *dpsub = platform_get_drvdata(pdev);
|
struct zynqmp_dpsub *dpsub = platform_get_drvdata(pdev);
|
||||||
struct drm_device *drm = &dpsub->drm;
|
|
||||||
|
|
||||||
drm_dev_unregister(drm);
|
zynqmp_dpsub_drm_cleanup(dpsub);
|
||||||
drm_atomic_helper_shutdown(drm);
|
|
||||||
drm_kms_helper_poll_fini(drm);
|
|
||||||
|
|
||||||
zynqmp_disp_remove(dpsub);
|
zynqmp_disp_remove(dpsub);
|
||||||
zynqmp_dp_remove(dpsub);
|
zynqmp_dp_remove(dpsub);
|
||||||
|
@ -72,11 +72,6 @@ struct zynqmp_dpsub {
|
|||||||
unsigned int dma_align;
|
unsigned int dma_align;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct zynqmp_dpsub *to_zynqmp_dpsub(struct drm_device *drm)
|
|
||||||
{
|
|
||||||
return container_of(drm, struct zynqmp_dpsub, drm);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool zynqmp_dpsub_audio_enabled(struct zynqmp_dpsub *dpsub);
|
bool zynqmp_dpsub_audio_enabled(struct zynqmp_dpsub *dpsub);
|
||||||
unsigned int zynqmp_dpsub_get_audio_clk_rate(struct zynqmp_dpsub *dpsub);
|
unsigned int zynqmp_dpsub_get_audio_clk_rate(struct zynqmp_dpsub *dpsub);
|
||||||
|
|
||||||
|
@ -16,12 +16,19 @@
|
|||||||
#include <drm/drm_bridge_connector.h>
|
#include <drm/drm_bridge_connector.h>
|
||||||
#include <drm/drm_connector.h>
|
#include <drm/drm_connector.h>
|
||||||
#include <drm/drm_crtc.h>
|
#include <drm/drm_crtc.h>
|
||||||
|
#include <drm/drm_device.h>
|
||||||
|
#include <drm/drm_drv.h>
|
||||||
#include <drm/drm_encoder.h>
|
#include <drm/drm_encoder.h>
|
||||||
|
#include <drm/drm_fb_helper.h>
|
||||||
#include <drm/drm_fourcc.h>
|
#include <drm/drm_fourcc.h>
|
||||||
#include <drm/drm_framebuffer.h>
|
#include <drm/drm_framebuffer.h>
|
||||||
|
#include <drm/drm_gem_dma_helper.h>
|
||||||
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/drm_managed.h>
|
#include <drm/drm_managed.h>
|
||||||
|
#include <drm/drm_mode_config.h>
|
||||||
#include <drm/drm_plane.h>
|
#include <drm/drm_plane.h>
|
||||||
#include <drm/drm_plane_helper.h>
|
#include <drm/drm_plane_helper.h>
|
||||||
|
#include <drm/drm_probe_helper.h>
|
||||||
#include <drm/drm_simple_kms_helper.h>
|
#include <drm/drm_simple_kms_helper.h>
|
||||||
#include <drm/drm_vblank.h>
|
#include <drm/drm_vblank.h>
|
||||||
|
|
||||||
@ -35,6 +42,11 @@
|
|||||||
#include "zynqmp_dpsub.h"
|
#include "zynqmp_dpsub.h"
|
||||||
#include "zynqmp_kms.h"
|
#include "zynqmp_kms.h"
|
||||||
|
|
||||||
|
static inline struct zynqmp_dpsub *to_zynqmp_dpsub(struct drm_device *drm)
|
||||||
|
{
|
||||||
|
return container_of(drm, struct zynqmp_dpsub, drm);
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DRM Planes
|
* DRM Planes
|
||||||
*/
|
*/
|
||||||
@ -339,10 +351,65 @@ void zynqmp_dpsub_handle_vblank(struct zynqmp_dpsub *dpsub)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Initialization
|
* Dumb Buffer & Framebuffer Allocation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub)
|
static int zynqmp_dpsub_dumb_create(struct drm_file *file_priv,
|
||||||
|
struct drm_device *drm,
|
||||||
|
struct drm_mode_create_dumb *args)
|
||||||
|
{
|
||||||
|
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(drm);
|
||||||
|
unsigned int pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
|
||||||
|
|
||||||
|
/* Enforce the alignment constraints of the DMA engine. */
|
||||||
|
args->pitch = ALIGN(pitch, dpsub->dma_align);
|
||||||
|
|
||||||
|
return drm_gem_dma_dumb_create_internal(file_priv, drm, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct drm_framebuffer *
|
||||||
|
zynqmp_dpsub_fb_create(struct drm_device *drm, struct drm_file *file_priv,
|
||||||
|
const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||||
|
{
|
||||||
|
struct zynqmp_dpsub *dpsub = to_zynqmp_dpsub(drm);
|
||||||
|
struct drm_mode_fb_cmd2 cmd = *mode_cmd;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/* Enforce the alignment constraints of the DMA engine. */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(cmd.pitches); ++i)
|
||||||
|
cmd.pitches[i] = ALIGN(cmd.pitches[i], dpsub->dma_align);
|
||||||
|
|
||||||
|
return drm_gem_fb_create(drm, file_priv, &cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct drm_mode_config_funcs zynqmp_dpsub_mode_config_funcs = {
|
||||||
|
.fb_create = zynqmp_dpsub_fb_create,
|
||||||
|
.atomic_check = drm_atomic_helper_check,
|
||||||
|
.atomic_commit = drm_atomic_helper_commit,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* DRM/KMS Driver
|
||||||
|
*/
|
||||||
|
|
||||||
|
DEFINE_DRM_GEM_DMA_FOPS(zynqmp_dpsub_drm_fops);
|
||||||
|
|
||||||
|
const struct drm_driver zynqmp_dpsub_drm_driver = {
|
||||||
|
.driver_features = DRIVER_MODESET | DRIVER_GEM |
|
||||||
|
DRIVER_ATOMIC,
|
||||||
|
|
||||||
|
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(zynqmp_dpsub_dumb_create),
|
||||||
|
|
||||||
|
.fops = &zynqmp_dpsub_drm_fops,
|
||||||
|
|
||||||
|
.name = "zynqmp-dpsub",
|
||||||
|
.desc = "Xilinx DisplayPort Subsystem Driver",
|
||||||
|
.date = "20130509",
|
||||||
|
.major = 1,
|
||||||
|
.minor = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub)
|
||||||
{
|
{
|
||||||
struct drm_encoder *encoder = &dpsub->encoder;
|
struct drm_encoder *encoder = &dpsub->encoder;
|
||||||
struct drm_connector *connector;
|
struct drm_connector *connector;
|
||||||
@ -385,3 +452,55 @@ int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
|
||||||
|
{
|
||||||
|
struct drm_device *drm = &dpsub->drm;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Initialize mode config, vblank and the KMS poll helper. */
|
||||||
|
ret = drmm_mode_config_init(drm);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
drm->mode_config.funcs = &zynqmp_dpsub_mode_config_funcs;
|
||||||
|
drm->mode_config.min_width = 0;
|
||||||
|
drm->mode_config.min_height = 0;
|
||||||
|
drm->mode_config.max_width = ZYNQMP_DISP_MAX_WIDTH;
|
||||||
|
drm->mode_config.max_height = ZYNQMP_DISP_MAX_HEIGHT;
|
||||||
|
|
||||||
|
ret = drm_vblank_init(drm, 1);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
drm_kms_helper_poll_init(drm);
|
||||||
|
|
||||||
|
ret = zynqmp_dpsub_kms_init(dpsub);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_poll_fini;
|
||||||
|
|
||||||
|
/* Reset all components and register the DRM device. */
|
||||||
|
drm_mode_config_reset(drm);
|
||||||
|
|
||||||
|
ret = drm_dev_register(drm, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_poll_fini;
|
||||||
|
|
||||||
|
/* Initialize fbdev generic emulation. */
|
||||||
|
drm_fbdev_generic_setup(drm, 24);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_poll_fini:
|
||||||
|
drm_kms_helper_poll_fini(drm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void zynqmp_dpsub_drm_cleanup(struct zynqmp_dpsub *dpsub)
|
||||||
|
{
|
||||||
|
struct drm_device *drm = &dpsub->drm;
|
||||||
|
|
||||||
|
drm_dev_unregister(drm);
|
||||||
|
drm_atomic_helper_shutdown(drm);
|
||||||
|
drm_kms_helper_poll_fini(drm);
|
||||||
|
}
|
||||||
|
@ -14,8 +14,11 @@
|
|||||||
|
|
||||||
struct zynqmp_dpsub;
|
struct zynqmp_dpsub;
|
||||||
|
|
||||||
|
extern const struct drm_driver zynqmp_dpsub_drm_driver;
|
||||||
|
|
||||||
void zynqmp_dpsub_handle_vblank(struct zynqmp_dpsub *dpsub);
|
void zynqmp_dpsub_handle_vblank(struct zynqmp_dpsub *dpsub);
|
||||||
|
|
||||||
int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub);
|
int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub);
|
||||||
|
void zynqmp_dpsub_drm_cleanup(struct zynqmp_dpsub *dpsub);
|
||||||
|
|
||||||
#endif /* _ZYNQMP_KMS_H_ */
|
#endif /* _ZYNQMP_KMS_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user