devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ong, Hean Loong" <hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org"
	<eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
	"dinguyen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<dinguyen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Vetter,
	Daniel" <daniel.vetter-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: "dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	"Loh,
	Tien Hock"
	<tien.hock.loh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"Ong-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org"
	<Ong-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCHv2 2/3] ARM: drm: Intel FPGA VIP Frame Buffer II drm driver
Date: Thu, 4 May 2017 01:53:18 +0000	[thread overview]
Message-ID: <1493862797.2182.22.camel@intel.com> (raw)
In-Reply-To: <87o9v9znl1.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>

On Wed, 2017-05-03 at 13:34 -0700, Eric Anholt wrote:
> hean.loong.ong@intel.com writes:
> 
> > 
> > From: "Ong, Hean Loong" <hean.loong.ong@intel.com>
> > 
> > Driver for Intel FPGA Video and Image Processing
> > Suite Frame Buffer II. The driver only supports the Intel
> > Arria10 devkit and its variants. This driver can be either
> > loaded staticlly or in modules. The OF device tree binding
> > is located at:
> > Documentation/devicetree/bindings/display/altr,vip-fb2.txt
> > 
> > Signed-off-by: Ong, Hean Loong <hean.loong.ong@intel.com>
> I'm not sure if this driver is going to make sense as-is, if it
> doesn't
> actually do display of planes from system memory.  But in case I was
> wrong, here's my review:
> 
> 
> > 
> > diff --git a/drivers/gpu/drm/ivip/intel_vip_conn.c
> > b/drivers/gpu/drm/ivip/intel_vip_conn.c
> > new file mode 100644
> > index 0000000..499d3b4
> > --- /dev/null
> > +++ b/drivers/gpu/drm/ivip/intel_vip_conn.c
> > @@ -0,0 +1,96 @@
> > +/*
> > + * intel_vip_conn.c -- Intel Video and Image Processing(VIP)
> > + * Frame Buffer II driver
> > + *
> > + * This driver supports the Intel VIP Frame Reader component.
> > + * More info on the hardware can be found in the Intel Video
> > + * and Image Processing Suite User Guide at this address
> > + * http://www.altera.com/literature/ug/ug_vip.pdf.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > modify it
> > + * under the terms and conditions of the GNU General Public
> > License,
> > + * version 2, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope 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.
> > + *
> > + * Authors:
> > + * Ong, Hean-Loong <hean.loong.ong@intel.com>
> > + *
> > + */
> > +
> > +#include <linux/init.h>
> > +#include <linux/kernel.h>
> > +#include <drm/drm_atomic_helper.h>
> > +#include <drm/drm_crtc_helper.h>
> > +#include <drm/drm_encoder_slave.h>
> > +#include <drm/drm_plane_helper.h>
> > +
> > +static enum drm_connector_status
> > +intelvipfb_drm_connector_detect(struct drm_connector *connector,
> > bool force)
> > +{
> > +	return connector_status_connected;
> > +}
> > +
> > +static void intelvipfb_drm_connector_destroy(struct drm_connector
> > *connector)
> > +{
> > +	drm_connector_unregister(connector);
> > +	drm_connector_cleanup(connector);
> > +}
> > +
> > +static const struct drm_connector_funcs
> > intelvipfb_drm_connector_funcs = {
> > +	.dpms = drm_helper_connector_dpms,
> > +	.reset = drm_atomic_helper_connector_reset,
> > +	.detect = intelvipfb_drm_connector_detect,
> > +	.fill_modes = drm_helper_probe_single_connector_modes,
> > +	.destroy = intelvipfb_drm_connector_destroy,
> > +	.atomic_duplicate_state =
> > drm_atomic_helper_connector_duplicate_state,
> > +	.atomic_destroy_state =
> > drm_atomic_helper_connector_destroy_state,
> > +};
> > +
> > +static int intelvipfb_drm_connector_get_modes(struct drm_connector
> > *connector)
> > +{
> > +	struct drm_device *drm = connector->dev;
> > +	int count;
> > +
> > +	count = drm_add_modes_noedid(connector, drm-
> > >mode_config.max_width,
> > +				     drm->mode_config.max_height);
> > +	drm_set_preferred_mode(connector, drm-
> > >mode_config.max_width,
> > +			       drm->mode_config.max_height);
> > +	return count;
> > +}
> You're adding a bunch of modes here, but I don't see anywhere in the
> driver that you change the resolution being scanned out.
> 
> If you can't change resolution, then I'd probably use drm_gtf_mode()
> or
> something to generate just the one mode (do you have a vrefresh for
> it?).  Also, in the simple display pipe's atomic_check, make sure
> that
> the mode chosen is the width/height you can support.
> 
From the drivers perpective the resolution is dependant on how the FPGA
Display Port Framebuffer hardwware IP is designed. I would take a look
into how drm_gtf_mode() works compared to this.
> > 
> > +
> > +static const struct drm_connector_helper_funcs
> > +intelvipfb_drm_connector_helper_funcs = {
> > +	.get_modes = intelvipfb_drm_connector_get_modes,
> > +};
> > +
> > +struct drm_connector *
> > +intelvipfb_conn_setup(struct drm_device *drm)
> > +{
> > +	struct drm_connector *conn;
> > +	int ret;
> > +
> > +	conn = devm_kzalloc(drm->dev, sizeof(*conn), GFP_KERNEL);
> > +	if (IS_ERR(conn))
> > +		return NULL;
> > +
> > +	ret = drm_connector_init(drm, conn,
> > &intelvipfb_drm_connector_funcs,
> > +				 DRM_MODE_CONNECTOR_DisplayPort);
> Are you actually outputting DisplayPort
> (https://en.wikipedia.org/wiki/DisplayPort)?
> 
> You probably want something else from the DRM_MODE_CONNECTOR list, or
> maybe just DRM_MODE_CONNECTOR_Unknown.
> 
The Physical Connector is a Display Port connector. A simple
introduction of the product is found here.
https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literat
ure/an/an793.pdf
> 
> > 
> > +	if (ret < 0) {
> > +		dev_err(drm->dev, "failed to initialize drm
> > connector\n");
> > +		ret = -ENOMEM;
> > +		goto error_connector_cleanup;
> > +	}
> > +
> > +	drm_connector_helper_add(conn,
> > &intelvipfb_drm_connector_helper_funcs);
> > +
> > +	return conn;
> > +
> > +error_connector_cleanup:
> > +	drm_connector_cleanup(conn);
> > +
> > +	return NULL;
> > +}
> > diff --git a/drivers/gpu/drm/ivip/intel_vip_core.c
> > b/drivers/gpu/drm/ivip/intel_vip_core.c
> > new file mode 100644
> > index 0000000..4e83343
> > --- /dev/null
> > +++ b/drivers/gpu/drm/ivip/intel_vip_core.c
> > @@ -0,0 +1,171 @@
> > +/*
> > + * intel_vip_core.c -- Intel Video and Image Processing(VIP)
> > + * Frame Buffer II driver
> > + *
> > + * This driver supports the Intel VIP Frame Reader component.
> > + * More info on the hardware can be found in the Intel Video
> > + * and Image Processing Suite User Guide at this address
> > + * http://www.altera.com/literature/ug/ug_vip.pdf.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > modify it
> > + * under the terms and conditions of the GNU General Public
> > License,
> > + * version 2, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope 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.
> > + *
> > + * Authors:
> > + * Ong, Hean-Loong <hean.loong.ong@intel.com>
> > + *
> > + */
> > +
> > +#include <linux/init.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +
> > +#include <drm/drmP.h>
> > +#include <drm/drm_atomic.h>
> > +#include <drm/drm_atomic_helper.h>
> > +#include <drm/drm_crtc_helper.h>
> > +#include <drm/drm_fb_helper.h>
> > +#include <drm/drm_fb_cma_helper.h>
> > +#include <drm/drm_gem_cma_helper.h>
> > +#include <drm/drm_plane_helper.h>
> > +#include <drm/drm_simple_kms_helper.h>
> > +
> > +#include "intel_vip_drv.h"
> > +
> > +static const u32 fbpriv_formats[] = {
> > +	DRM_FORMAT_XRGB8888,
> > +	DRM_FORMAT_RGB565
> > +};
> You're registering that you support this set of formats, but I don't
> see
> anything programming the hardware differently based on the format of
> the
> plane.
> 
> > 
> > +static void intelvipfb_start_hw(void __iomem *base,
> > resource_size_t addr)
> > +{
> > +	/*
> > +	 * The frameinfo variable has to correspond to the size of
> > the VIP Suite
> > +	 * Frame Reader register 7 which will determine the
> > maximum size used
> > +	 * in this frameinfo
> > +	 */
> > +
> > +	u32 frameinfo;
> > +
> > +	frameinfo =
> > +		readl(base + INTELVIPFB_FRAME_READER) &
> > 0x00ffffff;
> > +	writel(frameinfo, base + INTELVIPFB_FRAME_INFO);
> > +	writel(addr, base + INTELVIPFB_FRAME_START);
> > +	/* Finally set the control register to 1 to start
> > streaming */
> > +	writel(1, base + INTELVIPFB_CONTROL);
> > +}
> The addr you're passing in here is from dev->mode_config.fb_base,
> which
> is this weird sideband value from drm_fbdev_cma.  It's the wrong
> value
> to use if anything else uses the KMS interfaces to change the plane
> --
> you should be using
> drm_fb_cma_get_gem_addr(drm_simple_display_pipe->plane->state, 0)
> instead.
> 
Thank you for highlighting this. Will look into using
drm_fb_cma_get_gem_addr(drm_simple_display_pipe->plane->state, 0)
> > 
> > +
> > +static void intelvipfb_disable_hw(void __iomem *base)
> > +{
> > +	/* set the control register to 0 to stop streaming */
> > +	writel(0, base + INTELVIPFB_CONTROL);
> > +}
> These two functions should be be called from fbpriv_funcs.enable()
> and
> .disable(), not device load/unload.
> 
Since I am not supporting hotplugging here would it make a difference?
>  
> > 
> > +static const struct drm_mode_config_funcs
> > intelvipfb_mode_config_funcs = {
> > +	.fb_create = drm_fb_cma_create,
> > +	.atomic_check = drm_atomic_helper_check,
> > +	.atomic_commit = drm_atomic_helper_commit,
> > +};
> > +
> > +static struct drm_mode_config_helper_funcs
> > intelvipfb_mode_config_helpers = {
> > +	.atomic_commit_tail = drm_atomic_helper_commit_tail,
> > +};
> > +
> > +static void intelvipfb_setup_mode_config(struct drm_device *drm)
> > +{
> > +	drm_mode_config_init(drm);
> > +	drm->mode_config.funcs = &intelvipfb_mode_config_funcs;
> > +	drm->mode_config.helper_private =
> > &intelvipfb_mode_config_helpers;
> > +}
> > +
> > +static int intelvipfb_pipe_prepare_fb(struct
> > drm_simple_display_pipe *pipe,
> > +				      struct drm_plane_state
> > *plane_state)
> > +{
> > +	return drm_fb_cma_prepare_fb(&pipe->plane, plane_state);
> > +}
> > +
> > +static struct drm_simple_display_pipe_funcs fbpriv_funcs = {
> > +	.prepare_fb = intelvipfb_pipe_prepare_fb,
> > +};
> > +
> > +int intelvipfb_probe(struct device *dev, void __iomem *base)
> > +{
> > +	int retval;
> > +	struct drm_device *drm;
> > +	struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev);
> > +	struct drm_connector *connector;
> > +
> > +	dev_set_drvdata(dev, fbpriv);
> > +
> > +	drm = fbpriv->drm;
> > +
> > +	intelvipfb_setup_mode_config(drm);
> > +
> > +	connector = intelvipfb_conn_setup(drm);
> > +	if (!connector) {
> > +		dev_err(drm->dev, "Connector setup failed\n");
> > +		goto err_mode_config;
> > +	}
> > +
> > +	retval = drm_simple_display_pipe_init(drm, &fbpriv->pipe,
> > +					      &fbpriv_funcs,
> > +					      fbpriv_formats,
> > +					      ARRAY_SIZE(fbpriv_fo
> > rmats),
> > +					      connector);
> > +	if (retval < 0) {
> > +		dev_err(drm->dev, "Cannot setup simple display
> > pipe\n");
> > +		goto err_mode_config;
> > +	}
> > +
> > +	fbpriv->fbcma = drm_fbdev_cma_init(drm, PREF_BPP,
> > +					   drm-
> > >mode_config.num_connector);
> > +	if (!fbpriv->fbcma) {
> > +		fbpriv->fbcma = NULL;
> > +		dev_err(drm->dev, "Failed to init FB CMA area\n");
> > +		goto err_mode_config;
> > +	}
> On failure, drm_fbdev_cma_init() returns an ERR_PTR, not NULL.
> 
> Also, you're passing this PREF_BPP value here, ignoring
> the altr,bits-per-symbol property.  That seems wrong.

Noted thanks for highlighting.

  parent reply	other threads:[~2017-05-04  1:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25  2:06 [PATCHv2 0/3] Intel FPGA VIP Frame Buffer II DRM Driver hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1493086006-4392-1-git-send-email-hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-25  2:06   ` [PATCHv2 1/3] dt-bindings: display: Intel FPGA VIP drm driver Devicetree bindings hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w
2017-04-28 18:32     ` Rob Herring
2017-05-02  2:10       ` Ong, Hean Loong
     [not found]     ` <1493086006-4392-2-git-send-email-hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-04  7:55       ` Neil Armstrong
     [not found]         ` <803710eb-bcce-3d89-e306-5b7433f9962d-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-05-04  8:38           ` Ong, Hean Loong
2017-04-25  2:06   ` [PATCHv2 2/3] ARM: drm: Intel FPGA VIP Frame Buffer II drm driver hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1493086006-4392-3-git-send-email-hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-25  7:17       ` Jani Nikula
2017-05-03 20:34     ` Eric Anholt
     [not found]       ` <87o9v9znl1.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-05-04  1:53         ` Ong, Hean Loong [this message]
2017-06-01  2:47         ` Ong, Hean Loong
2017-04-25  2:06   ` [PATCHv2 3/3] ARM: socfpga: drm driver updates in socfpga_defconfig hean.loong.ong-ral2JQCrhuEAvxtiuMwx3w
2017-05-03 20:28   ` [PATCHv2 0/3] Intel FPGA VIP Frame Buffer II DRM Driver Eric Anholt
     [not found]     ` <87shklznuo.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-05-04  1:39       ` Ong, Hean Loong
     [not found]         ` <1493861983.2182.11.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-04 17:11           ` Eric Anholt
     [not found]             ` <87lgqcsg18.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-05-08  2:03               ` Ong, Hean Loong
     [not found]                 ` <1494209010.2533.4.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-08 16:03                   ` Eric Anholt
     [not found]                     ` <87efvz2v4m.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-05-09  3:24                       ` Ong, Hean Loong
     [not found]                         ` <1494300270.5383.29.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-09 16:40                           ` Eric Anholt
     [not found]                             ` <8760hanfua.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-05-11  2:50                               ` Ong, Hean Loong
     [not found]                                 ` <1494471040.2062.16.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-12  6:51                                   ` Daniel Vetter
2017-05-04  9:22     ` 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=1493862797.2182.22.camel@intel.com \
    --to=hean.loong.ong-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=Ong-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org \
    --cc=daniel.vetter-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dinguyen-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=tien.hock.loh-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /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).