From: CK Hu <ck.hu@mediatek.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
DRI Development <dri-devel@lists.freedesktop.org>,
linux-mediatek@lists.infradead.org,
Philipp Zabel <p.zabel@pengutronix.de>,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/8] drm/mediatek: don't open-code drm_gem_fb_create
Date: Fri, 22 Nov 2019 15:42:39 +0800 [thread overview]
Message-ID: <1574408559.21408.2.camel@mtksdaap41> (raw)
In-Reply-To: <20191115092120.4445-4-daniel.vetter@ffwll.ch>
Hi, Daniel:
On Fri, 2019-11-15 at 10:21 +0100, Daniel Vetter wrote:
> Aside: There's a few other fb_create implementations which
> simply check for valid buffer format (or an approximation thereof),
> and then call drm_gem_fb_create. For atomic drivers at least we could
> walk all planes and make sure the format/modifier combo is valid,
> and remove even more code.
>
> For non-atomic drivers that's not possible, since the format list for
> the primary buffer might be garbage (and most likely it is).
>
> Also delete mtk_drm_fb.[hc] since it would now only contain one
> function.
Acked-by: CK Hu <ck.hu@mediatek.com>
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> ---
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 ++++-
> drivers/gpu/drm/mediatek/mtk_drm_fb.c | 92 ------------------------
> drivers/gpu/drm/mediatek/mtk_drm_fb.h | 13 ----
> drivers/gpu/drm/mediatek/mtk_drm_plane.c | 1 -
> 4 files changed, 15 insertions(+), 107 deletions(-)
> delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.c
> delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.h
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 84d14213d992..2b1c122066ea 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -16,8 +16,10 @@
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_drv.h>
> #include <drm/drm_fb_helper.h>
> +#include <drm/drm_fourcc.h>
> #include <drm/drm_gem.h>
> #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
> #include <drm/drm_of.h>
> #include <drm/drm_probe_helper.h>
> #include <drm/drm_vblank.h>
> @@ -27,7 +29,6 @@
> #include "mtk_drm_ddp.h"
> #include "mtk_drm_ddp_comp.h"
> #include "mtk_drm_drv.h"
> -#include "mtk_drm_fb.h"
> #include "mtk_drm_gem.h"
>
> #define DRIVER_NAME "mediatek"
> @@ -115,6 +116,19 @@ static int mtk_atomic_commit(struct drm_device *drm,
> return 0;
> }
>
> +static struct drm_framebuffer *
> +mtk_drm_mode_fb_create(struct drm_device *dev,
> + struct drm_file *file,
> + const struct drm_mode_fb_cmd2 *cmd)
> +{
> + const struct drm_format_info *info = drm_get_format_info(dev, cmd);
> +
> + if (info->num_planes != 1)
> + return ERR_PTR(-EINVAL);
> +
> + return drm_gem_fb_create(dev, file, cmd);
> +}
> +
> static const struct drm_mode_config_funcs mtk_drm_mode_config_funcs = {
> .fb_create = mtk_drm_mode_fb_create,
> .atomic_check = drm_atomic_helper_check,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> deleted file mode 100644
> index 3f230a28a2dc..000000000000
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
> +++ /dev/null
> @@ -1,92 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (c) 2015 MediaTek Inc.
> - */
> -
> -#include <linux/dma-buf.h>
> -#include <linux/dma-resv.h>
> -
> -#include <drm/drm_modeset_helper.h>
> -#include <drm/drm_fb_helper.h>
> -#include <drm/drm_fourcc.h>
> -#include <drm/drm_gem.h>
> -#include <drm/drm_gem_framebuffer_helper.h>
> -
> -#include "mtk_drm_drv.h"
> -#include "mtk_drm_fb.h"
> -#include "mtk_drm_gem.h"
> -
> -static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = {
> - .create_handle = drm_gem_fb_create_handle,
> - .destroy = drm_gem_fb_destroy,
> -};
> -
> -static struct drm_framebuffer *mtk_drm_framebuffer_init(struct drm_device *dev,
> - const struct drm_mode_fb_cmd2 *mode,
> - struct drm_gem_object *obj)
> -{
> - const struct drm_format_info *info = drm_get_format_info(dev, mode);
> - struct drm_framebuffer *fb;
> - int ret;
> -
> - if (info->num_planes != 1)
> - return ERR_PTR(-EINVAL);
> -
> - fb = kzalloc(sizeof(*fb), GFP_KERNEL);
> - if (!fb)
> - return ERR_PTR(-ENOMEM);
> -
> - drm_helper_mode_fill_fb_struct(dev, fb, mode);
> -
> - fb->obj[0] = obj;
> -
> - ret = drm_framebuffer_init(dev, fb, &mtk_drm_fb_funcs);
> - if (ret) {
> - DRM_ERROR("failed to initialize framebuffer\n");
> - kfree(fb);
> - return ERR_PTR(ret);
> - }
> -
> - return fb;
> -}
> -
> -struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
> - struct drm_file *file,
> - const struct drm_mode_fb_cmd2 *cmd)
> -{
> - const struct drm_format_info *info = drm_get_format_info(dev, cmd);
> - struct drm_framebuffer *fb;
> - struct drm_gem_object *gem;
> - unsigned int width = cmd->width;
> - unsigned int height = cmd->height;
> - unsigned int size, bpp;
> - int ret;
> -
> - if (info->num_planes != 1)
> - return ERR_PTR(-EINVAL);
> -
> - gem = drm_gem_object_lookup(file, cmd->handles[0]);
> - if (!gem)
> - return ERR_PTR(-ENOENT);
> -
> - bpp = info->cpp[0];
> - size = (height - 1) * cmd->pitches[0] + width * bpp;
> - size += cmd->offsets[0];
> -
> - if (gem->size < size) {
> - ret = -EINVAL;
> - goto unreference;
> - }
> -
> - fb = mtk_drm_framebuffer_init(dev, cmd, gem);
> - if (IS_ERR(fb)) {
> - ret = PTR_ERR(fb);
> - goto unreference;
> - }
> -
> - return fb;
> -
> -unreference:
> - drm_gem_object_put_unlocked(gem);
> - return ERR_PTR(ret);
> -}
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.h b/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> deleted file mode 100644
> index eb64d26001c6..000000000000
> --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.h
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * Copyright (c) 2015 MediaTek Inc.
> - */
> -
> -#ifndef MTK_DRM_FB_H
> -#define MTK_DRM_FB_H
> -
> -struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
> - struct drm_file *file,
> - const struct drm_mode_fb_cmd2 *cmd);
> -
> -#endif /* MTK_DRM_FB_H */
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 3b0cc91c7023..540ef2faa40a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -13,7 +13,6 @@
> #include "mtk_drm_crtc.h"
> #include "mtk_drm_ddp_comp.h"
> #include "mtk_drm_drv.h"
> -#include "mtk_drm_fb.h"
> #include "mtk_drm_gem.h"
> #include "mtk_drm_plane.h"
>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2019-11-22 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191115092120.4445-1-daniel.vetter@ffwll.ch>
2019-11-15 9:21 ` [PATCH 3/8] drm/mediatek: don't open-code drm_gem_fb_create Daniel Vetter
2019-11-22 7:42 ` CK Hu [this message]
2019-11-22 17:09 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1574408559.21408.2.camel@mtksdaap41 \
--to=ck.hu@mediatek.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).