mirror of https://gitee.com/openkylin/linux.git
drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs
With the vblank hooks in struct drm_crtc_funcs, we do not need to maintain the CRTC specific vblank callbacks with struct imx_drm_crtc_helper_funcs any more. By moving the stuff that we currently do in imx_drm_add_crtc(), like of_node setting and drm_crtc_helper_add()/drm_crtc_init_with_planes() invoking, we can kill things like struct imx_drm_crtc, imx_drm_crtc_helper_funcs and related functions completely. Functions ipu_enable_vblank() and ipu_disable_vblank() are moved around without changes, only for saving the forward declarations. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Link: http://patchwork.freedesktop.org/patch/msgid/1486458995-31018-13-git-send-email-shawnguo@kernel.org
This commit is contained in:
parent
14de02cdb0
commit
44b460cfe5
|
@ -40,17 +40,11 @@ struct imx_drm_component {
|
||||||
|
|
||||||
struct imx_drm_device {
|
struct imx_drm_device {
|
||||||
struct drm_device *drm;
|
struct drm_device *drm;
|
||||||
struct imx_drm_crtc *crtc[MAX_CRTC];
|
|
||||||
unsigned int pipes;
|
unsigned int pipes;
|
||||||
struct drm_fbdev_cma *fbhelper;
|
struct drm_fbdev_cma *fbhelper;
|
||||||
struct drm_atomic_state *state;
|
struct drm_atomic_state *state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct imx_drm_crtc {
|
|
||||||
struct drm_crtc *crtc;
|
|
||||||
struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
|
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
|
||||||
static int legacyfb_depth = 16;
|
static int legacyfb_depth = 16;
|
||||||
module_param(legacyfb_depth, int, 0444);
|
module_param(legacyfb_depth, int, 0444);
|
||||||
|
@ -63,38 +57,6 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
|
||||||
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
|
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
|
|
||||||
{
|
|
||||||
struct imx_drm_device *imxdrm = drm->dev_private;
|
|
||||||
struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!imx_drm_crtc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!imx_drm_crtc->imx_drm_helper_funcs.enable_vblank)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
ret = imx_drm_crtc->imx_drm_helper_funcs.enable_vblank(
|
|
||||||
imx_drm_crtc->crtc);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
|
|
||||||
{
|
|
||||||
struct imx_drm_device *imxdrm = drm->dev_private;
|
|
||||||
struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
|
|
||||||
|
|
||||||
if (!imx_drm_crtc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!imx_drm_crtc->imx_drm_helper_funcs.disable_vblank)
|
|
||||||
return;
|
|
||||||
|
|
||||||
imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations imx_drm_driver_fops = {
|
static const struct file_operations imx_drm_driver_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = drm_open,
|
.open = drm_open,
|
||||||
|
@ -180,67 +142,6 @@ static struct drm_mode_config_helper_funcs imx_drm_mode_config_helpers = {
|
||||||
.atomic_commit_tail = imx_drm_atomic_commit_tail,
|
.atomic_commit_tail = imx_drm_atomic_commit_tail,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* imx_drm_add_crtc - add a new crtc
|
|
||||||
*/
|
|
||||||
int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
|
|
||||||
struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
|
|
||||||
const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
|
|
||||||
struct device_node *port)
|
|
||||||
{
|
|
||||||
struct imx_drm_device *imxdrm = drm->dev_private;
|
|
||||||
struct imx_drm_crtc *imx_drm_crtc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The vblank arrays are dimensioned by MAX_CRTC - we can't
|
|
||||||
* pass IDs greater than this to those functions.
|
|
||||||
*/
|
|
||||||
if (imxdrm->pipes >= MAX_CRTC)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (imxdrm->drm->open_count)
|
|
||||||
return -EBUSY;
|
|
||||||
|
|
||||||
imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
|
|
||||||
if (!imx_drm_crtc)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
|
|
||||||
imx_drm_crtc->crtc = crtc;
|
|
||||||
|
|
||||||
crtc->port = port;
|
|
||||||
|
|
||||||
imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;
|
|
||||||
|
|
||||||
*new_crtc = imx_drm_crtc;
|
|
||||||
|
|
||||||
drm_crtc_helper_add(crtc,
|
|
||||||
imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
|
|
||||||
|
|
||||||
drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
|
|
||||||
imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs, NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* imx_drm_remove_crtc - remove a crtc
|
|
||||||
*/
|
|
||||||
int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
|
|
||||||
{
|
|
||||||
struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
|
|
||||||
unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc);
|
|
||||||
|
|
||||||
drm_crtc_cleanup(imx_drm_crtc->crtc);
|
|
||||||
|
|
||||||
imxdrm->crtc[pipe] = NULL;
|
|
||||||
|
|
||||||
kfree(imx_drm_crtc);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
|
|
||||||
|
|
||||||
int imx_drm_encoder_parse_of(struct drm_device *drm,
|
int imx_drm_encoder_parse_of(struct drm_device *drm,
|
||||||
struct drm_encoder *encoder, struct device_node *np)
|
struct drm_encoder *encoder, struct device_node *np)
|
||||||
|
@ -288,8 +189,6 @@ static struct drm_driver imx_drm_driver = {
|
||||||
.gem_prime_vmap = drm_gem_cma_prime_vmap,
|
.gem_prime_vmap = drm_gem_cma_prime_vmap,
|
||||||
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
|
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
|
||||||
.gem_prime_mmap = drm_gem_cma_prime_mmap,
|
.gem_prime_mmap = drm_gem_cma_prime_mmap,
|
||||||
.enable_vblank = imx_drm_enable_vblank,
|
|
||||||
.disable_vblank = imx_drm_disable_vblank,
|
|
||||||
.ioctls = imx_drm_ioctls,
|
.ioctls = imx_drm_ioctls,
|
||||||
.num_ioctls = ARRAY_SIZE(imx_drm_ioctls),
|
.num_ioctls = ARRAY_SIZE(imx_drm_ioctls),
|
||||||
.fops = &imx_drm_driver_fops,
|
.fops = &imx_drm_driver_fops,
|
||||||
|
|
|
@ -25,19 +25,6 @@ static inline struct imx_crtc_state *to_imx_crtc_state(struct drm_crtc_state *s)
|
||||||
{
|
{
|
||||||
return container_of(s, struct imx_crtc_state, base);
|
return container_of(s, struct imx_crtc_state, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct imx_drm_crtc_helper_funcs {
|
|
||||||
int (*enable_vblank)(struct drm_crtc *crtc);
|
|
||||||
void (*disable_vblank)(struct drm_crtc *crtc);
|
|
||||||
const struct drm_crtc_helper_funcs *crtc_helper_funcs;
|
|
||||||
const struct drm_crtc_funcs *crtc_funcs;
|
|
||||||
};
|
|
||||||
|
|
||||||
int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
|
|
||||||
struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
|
|
||||||
const struct imx_drm_crtc_helper_funcs *imx_helper_funcs,
|
|
||||||
struct device_node *port);
|
|
||||||
int imx_drm_remove_crtc(struct imx_drm_crtc *);
|
|
||||||
int imx_drm_init_drm(struct platform_device *pdev,
|
int imx_drm_init_drm(struct platform_device *pdev,
|
||||||
int preferred_bpp);
|
int preferred_bpp);
|
||||||
int imx_drm_exit_drm(void);
|
int imx_drm_exit_drm(void);
|
||||||
|
|
|
@ -129,18 +129,31 @@ static void imx_drm_crtc_destroy_state(struct drm_crtc *crtc,
|
||||||
kfree(to_imx_crtc_state(state));
|
kfree(to_imx_crtc_state(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void imx_drm_crtc_destroy(struct drm_crtc *crtc)
|
static int ipu_enable_vblank(struct drm_crtc *crtc)
|
||||||
{
|
{
|
||||||
imx_drm_remove_crtc(to_ipu_crtc(crtc)->imx_crtc);
|
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
|
||||||
|
|
||||||
|
enable_irq(ipu_crtc->irq);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ipu_disable_vblank(struct drm_crtc *crtc)
|
||||||
|
{
|
||||||
|
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
|
||||||
|
|
||||||
|
disable_irq_nosync(ipu_crtc->irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct drm_crtc_funcs ipu_crtc_funcs = {
|
static const struct drm_crtc_funcs ipu_crtc_funcs = {
|
||||||
.set_config = drm_atomic_helper_set_config,
|
.set_config = drm_atomic_helper_set_config,
|
||||||
.destroy = imx_drm_crtc_destroy,
|
.destroy = drm_crtc_cleanup,
|
||||||
.page_flip = drm_atomic_helper_page_flip,
|
.page_flip = drm_atomic_helper_page_flip,
|
||||||
.reset = imx_drm_crtc_reset,
|
.reset = imx_drm_crtc_reset,
|
||||||
.atomic_duplicate_state = imx_drm_crtc_duplicate_state,
|
.atomic_duplicate_state = imx_drm_crtc_duplicate_state,
|
||||||
.atomic_destroy_state = imx_drm_crtc_destroy_state,
|
.atomic_destroy_state = imx_drm_crtc_destroy_state,
|
||||||
|
.enable_vblank = ipu_enable_vblank,
|
||||||
|
.disable_vblank = ipu_disable_vblank,
|
||||||
};
|
};
|
||||||
|
|
||||||
static irqreturn_t ipu_irq_handler(int irq, void *dev_id)
|
static irqreturn_t ipu_irq_handler(int irq, void *dev_id)
|
||||||
|
@ -261,29 +274,6 @@ static const struct drm_crtc_helper_funcs ipu_helper_funcs = {
|
||||||
.enable = ipu_crtc_enable,
|
.enable = ipu_crtc_enable,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ipu_enable_vblank(struct drm_crtc *crtc)
|
|
||||||
{
|
|
||||||
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
|
|
||||||
|
|
||||||
enable_irq(ipu_crtc->irq);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ipu_disable_vblank(struct drm_crtc *crtc)
|
|
||||||
{
|
|
||||||
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
|
|
||||||
|
|
||||||
disable_irq_nosync(ipu_crtc->irq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct imx_drm_crtc_helper_funcs ipu_crtc_helper_funcs = {
|
|
||||||
.enable_vblank = ipu_enable_vblank,
|
|
||||||
.disable_vblank = ipu_disable_vblank,
|
|
||||||
.crtc_funcs = &ipu_crtc_funcs,
|
|
||||||
.crtc_helper_funcs = &ipu_helper_funcs,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void ipu_put_resources(struct ipu_crtc *ipu_crtc)
|
static void ipu_put_resources(struct ipu_crtc *ipu_crtc)
|
||||||
{
|
{
|
||||||
if (!IS_ERR_OR_NULL(ipu_crtc->dc))
|
if (!IS_ERR_OR_NULL(ipu_crtc->dc))
|
||||||
|
@ -321,6 +311,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
|
||||||
struct ipu_client_platformdata *pdata, struct drm_device *drm)
|
struct ipu_client_platformdata *pdata, struct drm_device *drm)
|
||||||
{
|
{
|
||||||
struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
|
struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
|
||||||
|
struct drm_crtc *crtc = &ipu_crtc->base;
|
||||||
int dp = -EINVAL;
|
int dp = -EINVAL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -340,19 +331,16 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
|
||||||
goto err_put_resources;
|
goto err_put_resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc,
|
crtc->port = pdata->of_node;
|
||||||
&ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs,
|
drm_crtc_helper_add(crtc, &ipu_helper_funcs);
|
||||||
pdata->of_node);
|
drm_crtc_init_with_planes(drm, crtc, &ipu_crtc->plane[0]->base, NULL,
|
||||||
if (ret) {
|
&ipu_crtc_funcs, NULL);
|
||||||
dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
|
|
||||||
goto err_put_resources;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
|
ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(ipu_crtc->dev, "getting plane 0 resources failed with %d.\n",
|
dev_err(ipu_crtc->dev, "getting plane 0 resources failed with %d.\n",
|
||||||
ret);
|
ret);
|
||||||
goto err_remove_crtc;
|
goto err_put_resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this crtc is using the DP, add an overlay plane */
|
/* If this crtc is using the DP, add an overlay plane */
|
||||||
|
@ -390,8 +378,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
|
||||||
ipu_plane_put_resources(ipu_crtc->plane[1]);
|
ipu_plane_put_resources(ipu_crtc->plane[1]);
|
||||||
err_put_plane0_res:
|
err_put_plane0_res:
|
||||||
ipu_plane_put_resources(ipu_crtc->plane[0]);
|
ipu_plane_put_resources(ipu_crtc->plane[0]);
|
||||||
err_remove_crtc:
|
|
||||||
imx_drm_remove_crtc(ipu_crtc->imx_crtc);
|
|
||||||
err_put_resources:
|
err_put_resources:
|
||||||
ipu_put_resources(ipu_crtc);
|
ipu_put_resources(ipu_crtc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue