Re: [RFC 09/11] drm/mediatek: add fbdev support
Hi, Ulrich: On Fri, 2017-09-29 at 15:09 +0200, Ulrich Hecht wrote: > Forward-ported from chromeos-3.18 vendor kernel. > > Signed-off-by: Ulrich HechtI think this patch originate from [1]. And you should keep the signed-off-by info so that we could know who contribute to this patch. [1] https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/330532 Regards, CK > --- > drivers/gpu/drm/mediatek/Makefile| 2 + > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 9 ++ > drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 +- > drivers/gpu/drm/mediatek/mtk_drm_fb.c| 13 +++ > drivers/gpu/drm/mediatek/mtk_drm_fb.h| 3 + > drivers/gpu/drm/mediatek/mtk_drm_fbdev.c | 184 > +++ > drivers/gpu/drm/mediatek/mtk_drm_fbdev.h | 32 ++ > 7 files changed, 246 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.c > create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.h > > diff --git a/drivers/gpu/drm/mediatek/Makefile > b/drivers/gpu/drm/mediatek/Makefile > index e37b55a..8306fb5 100644 > --- a/drivers/gpu/drm/mediatek/Makefile > +++ b/drivers/gpu/drm/mediatek/Makefile > @@ -12,6 +12,8 @@ mediatek-drm-y := mtk_disp_color.o \ > mtk_mipi_tx.o \ > mtk_dpi.o > > +mediatek-drm-$(CONFIG_DRM_FBDEV_EMULATION) += mtk_drm_fbdev.o > + > obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o > > mediatek-drm-hdmi-objs := mtk_cec.o \ > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c > b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > index 8c92630..a69aa2f 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > @@ -30,6 +30,7 @@ > #include "mtk_drm_ddp_comp.h" > #include "mtk_drm_drv.h" > #include "mtk_drm_fb.h" > +#include "mtk_drm_fbdev.h" > #include "mtk_drm_gem.h" > > #define DRIVER_NAME "mediatek" > @@ -257,8 +258,15 @@ static int mtk_drm_kms_init(struct drm_device *drm) > drm_kms_helper_poll_init(drm); > drm_mode_config_reset(drm); > > + ret = mtk_fbdev_init(drm); > + if (ret) > + goto err_kms_helper_poll_fini; > + > return 0; > > +err_kms_helper_poll_fini: > + drm_kms_helper_poll_fini(drm); > +// drm_vblank_cleanup(drm); > err_component_unbind: > component_unbind_all(drm->dev, drm); > err_config_cleanup: > @@ -269,6 +277,7 @@ static int mtk_drm_kms_init(struct drm_device *drm) > > static void mtk_drm_kms_deinit(struct drm_device *drm) > { > + mtk_fbdev_fini(drm); > drm_kms_helper_poll_fini(drm); > > component_unbind_all(drm->dev, drm); > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h > b/drivers/gpu/drm/mediatek/mtk_drm_drv.h > index c3378c4..4edc002 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h > @@ -14,6 +14,7 @@ > #ifndef MTK_DRM_DRV_H > #define MTK_DRM_DRV_H > > +#include > #include > #include "mtk_drm_ddp_comp.h" > > @@ -24,7 +25,6 @@ struct device; > struct device_node; > struct drm_crtc; > struct drm_device; > -struct drm_fb_helper; > struct drm_property; > struct regmap; > > @@ -56,6 +56,8 @@ struct mtk_drm_private { > } commit; > > struct drm_atomic_state *suspend_state; > + struct drm_fb_helper fb_helper; > + struct drm_gem_object *fbdev_bo; > }; > > extern struct platform_driver mtk_ddp_driver; > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c > b/drivers/gpu/drm/mediatek/mtk_drm_fb.c > index 0d8d506..ac8561d 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c > @@ -96,6 +96,19 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct > drm_device *dev, > return mtk_fb; > } > > +struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev, > + const struct drm_mode_fb_cmd2 *mode, > + struct drm_gem_object *obj) > +{ > + struct mtk_drm_fb *mtk_fb; > + > + mtk_fb = mtk_drm_framebuffer_init(dev, mode, obj); > + if (IS_ERR(mtk_fb)) > + return ERR_CAST(mtk_fb); > + > + return _fb->base; > +} > + > /* > * Wait for any exclusive fence in fb's gem object's reservation object. > * > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h > b/drivers/gpu/drm/mediatek/mtk_drm_fb.h > index 9b2ae34..9ee1ac2 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h > @@ -19,5 +19,8 @@ int mtk_fb_wait(struct drm_framebuffer *fb); > struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, > struct drm_file *file, > const struct drm_mode_fb_cmd2 > *cmd); > +struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev, > + const struct drm_mode_fb_cmd2 *mode, > + struct drm_gem_object *obj); > > #endif /* MTK_DRM_FB_H
[RFC 09/11] drm/mediatek: add fbdev support
Forward-ported from chromeos-3.18 vendor kernel. Signed-off-by: Ulrich Hecht--- drivers/gpu/drm/mediatek/Makefile| 2 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 9 ++ drivers/gpu/drm/mediatek/mtk_drm_drv.h | 4 +- drivers/gpu/drm/mediatek/mtk_drm_fb.c| 13 +++ drivers/gpu/drm/mediatek/mtk_drm_fb.h| 3 + drivers/gpu/drm/mediatek/mtk_drm_fbdev.c | 184 +++ drivers/gpu/drm/mediatek/mtk_drm_fbdev.h | 32 ++ 7 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.c create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fbdev.h diff --git a/drivers/gpu/drm/mediatek/Makefile b/drivers/gpu/drm/mediatek/Makefile index e37b55a..8306fb5 100644 --- a/drivers/gpu/drm/mediatek/Makefile +++ b/drivers/gpu/drm/mediatek/Makefile @@ -12,6 +12,8 @@ mediatek-drm-y := mtk_disp_color.o \ mtk_mipi_tx.o \ mtk_dpi.o +mediatek-drm-$(CONFIG_DRM_FBDEV_EMULATION) += mtk_drm_fbdev.o + obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o mediatek-drm-hdmi-objs := mtk_cec.o \ diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 8c92630..a69aa2f 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -30,6 +30,7 @@ #include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" +#include "mtk_drm_fbdev.h" #include "mtk_drm_gem.h" #define DRIVER_NAME "mediatek" @@ -257,8 +258,15 @@ static int mtk_drm_kms_init(struct drm_device *drm) drm_kms_helper_poll_init(drm); drm_mode_config_reset(drm); + ret = mtk_fbdev_init(drm); + if (ret) + goto err_kms_helper_poll_fini; + return 0; +err_kms_helper_poll_fini: + drm_kms_helper_poll_fini(drm); +// drm_vblank_cleanup(drm); err_component_unbind: component_unbind_all(drm->dev, drm); err_config_cleanup: @@ -269,6 +277,7 @@ static int mtk_drm_kms_init(struct drm_device *drm) static void mtk_drm_kms_deinit(struct drm_device *drm) { + mtk_fbdev_fini(drm); drm_kms_helper_poll_fini(drm); component_unbind_all(drm->dev, drm); diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h index c3378c4..4edc002 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h @@ -14,6 +14,7 @@ #ifndef MTK_DRM_DRV_H #define MTK_DRM_DRV_H +#include #include #include "mtk_drm_ddp_comp.h" @@ -24,7 +25,6 @@ struct device; struct device_node; struct drm_crtc; struct drm_device; -struct drm_fb_helper; struct drm_property; struct regmap; @@ -56,6 +56,8 @@ struct mtk_drm_private { } commit; struct drm_atomic_state *suspend_state; + struct drm_fb_helper fb_helper; + struct drm_gem_object *fbdev_bo; }; extern struct platform_driver mtk_ddp_driver; diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c index 0d8d506..ac8561d 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c @@ -96,6 +96,19 @@ static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev, return mtk_fb; } +struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev, + const struct drm_mode_fb_cmd2 *mode, + struct drm_gem_object *obj) +{ + struct mtk_drm_fb *mtk_fb; + + mtk_fb = mtk_drm_framebuffer_init(dev, mode, obj); + if (IS_ERR(mtk_fb)) + return ERR_CAST(mtk_fb); + + return _fb->base; +} + /* * Wait for any exclusive fence in fb's gem object's reservation object. * diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h index 9b2ae34..9ee1ac2 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.h @@ -19,5 +19,8 @@ int mtk_fb_wait(struct drm_framebuffer *fb); struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *cmd); +struct drm_framebuffer *mtk_drm_framebuffer_create(struct drm_device *dev, + const struct drm_mode_fb_cmd2 *mode, + struct drm_gem_object *obj); #endif /* MTK_DRM_FB_H */ diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c b/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c new file mode 100644 index 000..1e46216 --- /dev/null +++ b/drivers/gpu/drm/mediatek/mtk_drm_fbdev.c @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2016 MediaTek Inc. + * + * 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. + * + * This program is distributed in the hope that it will be