All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Jyri Sarha <jsarha@ti.com>
Cc: dri-devel@lists.freedesktop.org, airlied@linux.ie,
	linux-omap@vger.kernel.org, devicetree@vger.kernel.org,
	bcousson@baylibre.com, tony@atomide.com, detheridge@ti.com,
	moinejf@free.fr, linux@arm.linux.org.uk,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [PATCH RFC 3/6] drm/tilcdc: Add support for external compontised DRM encoder
Date: Mon, 2 Mar 2015 14:44:29 +0200	[thread overview]
Message-ID: <54F45B2D.8060907@ti.com> (raw)
In-Reply-To: <92792bb4f64fb1b7f26e687ec159d870d0e7a81a.1424961754.git.jsarha@ti.com>

[-- Attachment #1: Type: text/plain, Size: 5111 bytes --]

On 26/02/15 16:55, Jyri Sarha wrote:
> Add support for an external compontised DRM encoder. The external
> encoder can be connected to tilcdc trough device tree graph binding.
> The binding document for tilcdc has been updated. The support has only
> been tested with tda998x encoder, but other encoders should work too
> with a little tweaking.
> 
> I got the idea and some lines of code from Jean-Francois Moine's
> "drm/tilcdc: Change the interface with the tda998x driver"-patch.
> 
> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> ---

<snip>

> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> new file mode 100644
> index 0000000..7254151
> --- /dev/null
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (C) 2015 Texas Instruments
> + * Author: Jyri Sarha <jsarha@ti.com>
> + *
> + * 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.
> + *
> + */
> +#define DEBUG 1

You probably didn't mean to include this.

> +
> +#include <linux/component.h>
> +#include <linux/of_graph.h>
> +
> +#include "tilcdc_drv.h"
> +#include "tilcdc_external.h"
> +
> +static const struct tilcdc_panel_info panel_info_defaults = {
> +		.ac_bias                = 255,
> +		.ac_bias_intrpt         = 0,
> +		.dma_burst_sz           = 16,
> +		.bpp                    = 16,
> +		.fdd                    = 0x80,
> +		.tft_alt_mode           = 0,
> +		.invert_pxl_clk		= 1,
> +		.sync_edge              = 1,
> +		.sync_ctrl              = 1,
> +		.raster_order           = 0,
> +};
> +
> +static int tilcdc_add_external_encoder(struct drm_device *dev, int *bpp,
> +				       struct drm_connector *connector)
> +{
> +	struct tilcdc_drm_private *priv = dev->dev_private;
> +
> +	priv->connectors[priv->num_connectors++] = connector;
> +	priv->encoders[priv->num_encoders++] = connector->encoder;
> +
> +	tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
> +	tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_defaults);

Setting of the simulate vesa sync and the panel info here look a bit
like a hack to me. Both of them are for tda998x, not "defaults".

So... I don't know. You could state that at the moment tilcdc only
supports tda998x as an external encoder. Then the above would be ok, but
still it would be good to clearly state this in the desc, comments and
variable names.

Doing this properly may be more difficult. Some parameters should be
defined in the .dts, some should probably come from tda998x driver, and
some should be deduced by tilcdc driver internally.

> +	*bpp = panel_info_defaults.bpp;
> +
> +	dev_info(dev->dev, "External encoder '%s' connected\n",
> +		 connector->encoder->name);

This and the other dev_info in this patch look more like dev_dbg to me.

> +
> +	return 0;
> +}
> +
> +
> +int tilcdc_add_external_encoders(struct drm_device *dev, int *bpp)
> +{
> +	struct tilcdc_drm_private *priv = dev->dev_private;
> +	struct drm_connector *connector;
> +	int num_internal_connectors = priv->num_connectors;
> +
> +	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
> +		bool found = false;
> +		int i, ret;
> +
> +		for (i = 0; i < num_internal_connectors; i++)
> +			if (connector == priv->connectors[i])
> +				found = true;
> +		if (!found) {
> +			ret = tilcdc_add_external_encoder(dev, bpp, connector);
> +			if (ret)
> +				return ret;
> +		}
> +	}
> +	if (priv->num_connectors - num_internal_connectors > 1) {
> +		dev_err(dev->dev, "Only one external encoder is supported.");
> +		return -EINVAL;
> +	}
> +	return 0;
> +}
> +
> +static int of_dev_node_match(struct device *dev, void *data)
> +{
> +	return dev->of_node == data;
> +}
> +
> +int tilcdc_add_external_components(struct device *master,
> +				   struct master *m)
> +{
> +	struct device_node *ep = NULL;
> +
> +	while ((ep = of_graph_get_next_endpoint(master->of_node, ep))) {
> +		struct device_node *node;
> +		int ret;
> +
> +		node = of_graph_get_remote_port_parent(ep);
> +		of_node_put(ep);

Note that there's an unmerged series "Add of-graph helpers to loop over
endpoints and find ports by id" from Philipp which changes the behavior
of of_graph_get_next_endpoint.

> +		if (!node || !of_device_is_available(node))
> +			continue;

Should you of_node_put(node) if node != NULL above?

> +
> +		dev_info(master, "Subdevice node '%s' found\n", node->name);
> +		ret = component_master_add_child(m, of_dev_node_match, node);
> +		of_node_put(node);
> +		if (ret) {
> +			dev_err(master, "Adding component failed: %d\n", ret);
> +			of_node_put(ep);
> +			return ret;
> +		}
> +	}
> +	return 0;
> +}

I don't know if it matters, but as tilcdc only supports a single
endpoint, and I think this is the earliest place where it can be
detected, you could fail above if there are more than one endpoint.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-03-02 12:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 14:55 [PATCH RFC 0/6] Use DRM component API in tilcdc to connect to tda998x Jyri Sarha
2015-02-26 14:55 ` [PATCH RFC 1/6] drm/tilcdc: Fix module unloading Jyri Sarha
2015-03-02 13:10   ` Tomi Valkeinen
2015-02-26 14:55 ` [PATCH RFC 2/6] drm/tilcdc: Remove tilcdc slave support for tda998x driver Jyri Sarha
2015-02-26 14:55 ` [PATCH RFC 3/6] drm/tilcdc: Add support for external compontised DRM encoder Jyri Sarha
2015-03-02 12:44   ` Tomi Valkeinen [this message]
2015-03-02 16:01   ` Russell King - ARM Linux
2015-03-06  8:33     ` Jyri Sarha
2015-03-06  9:58       ` Russell King - ARM Linux
2015-03-06 10:21         ` Jyri Sarha
2015-03-06 10:35           ` Russell King - ARM Linux
2015-02-26 14:55 ` [PATCH RFC 4/6] drm/tilcdc: Add DRM_TILCDC_INIT for "ti,tilcdc,slave" binding support Jyri Sarha
     [not found]   ` <6cf3243f87975ef349dead7af136870fa406ad6b.1424961754.git.jsarha-l0cyMroinI0@public.gmane.org>
2015-03-02 13:04     ` Tomi Valkeinen
     [not found] ` <cover.1424961754.git.jsarha-l0cyMroinI0@public.gmane.org>
2015-02-26 14:55   ` [PATCH RFC 5/6] drm/tilcdc: Force building of DRM_TILCDC_INIT Jyri Sarha
2015-03-02 12:59     ` Tomi Valkeinen
2015-02-26 14:55 ` [PATCH RFC 6/6] ARM: dts: am335x-boneblack: Use new binding for HDMI Jyri Sarha
2015-03-02 12:28   ` Tomi Valkeinen
2015-03-02 16:06     ` Russell King - ARM Linux
2015-03-02 17:08       ` Tomi Valkeinen
2015-03-02 17:42         ` Russell King - ARM Linux
2015-03-03  8:35           ` Tomi Valkeinen
2015-03-02 11:34 ` [PATCH RFC 0/6] Use DRM component API in tilcdc to connect to tda998x Tomi Valkeinen

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=54F45B2D.8060907@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=airlied@linux.ie \
    --cc=bcousson@baylibre.com \
    --cc=detheridge@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=moinejf@free.fr \
    --cc=p.zabel@pengutronix.de \
    --cc=tony@atomide.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.