diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-12-09 19:28:28 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-12-29 12:07:46 +0300 |
commit | f76ee892a99e68b55402b8d4b8aeffcae2aff34d (patch) | |
tree | 3760b7eb7a6db6bad5be5449e680ec5613c67848 /drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | |
parent | 1c6aac92ee6cbb007ec0765956095357e7d4090c (diff) | |
download | linux-f76ee892a99e68b55402b8d4b8aeffcae2aff34d.tar.xz |
omapfb: copy omapdss & displays for omapfb
This patch makes a copy of the omapdss driver and the omap panel &
encoder drivers for omapfb. The purpose is to separate omapdrm and
omapfb drivers from each other.
Note that this patch only does a direct copy of the files without any
other modifications. The files are not yet used.
The original files are in:
drivers/video/fbdev/omap2/dss/
drivers/video/fbdev/omap2/displays-new/
Here's a more detailed explanation about this and the following patches,
from the introduction mail of the patch series:
A short background on the current status. We have the following
entities:
* omapdss, located in drivers/video/fbdev/omap2/dss/. This is a driver for the
display subsystem IPs used on OMAP (and related) SoCs. It offers only a
kernel internal API, and does not implement anything for fbdev or drm.
* omapdss panels and encoders, located in
drivers/video/fbdev/omap2/displays-new/. These are panel and external encoder
drivers, which use APIs offered by omapdss driver. These also don't implement
anything for fbdev or drm.
* omapdrm, located in drivers/gpu/drm/omapdrm/. This is a drm driver, which
uses omapdss and the panel/encoder drivers to operate the hardware.
* omapfb, located in drivers/video/fbdev/omap2/omapfb/. This is an fbdev
driver, which uses omapdss and the panel/encoder drivers to operate the
hardware.
* omap_vout, located in drivers/media/platform/omap/. This is a v4l2 driver,
which uses omapdss and omapfb to implement a v4l2 API for the video overlays.
So, on the top level, we have either omapdrm, or omapfb+omap_vout. Both of
those use the same low level drivers. Without going to the historical details
why the architecture is like that, I think it's finally time to change that.
The situation with omapfb+omap_vout is that it still works, but no new features
have been added for a long time, and I want to keep it working as it's still
being used. At some point in the future I'd like to remove omapfb and
omap_vout altogether.
Omapdrm, on the other hand, is being actively developed. Sharing the low level
parts with omapfb makes that development more difficult than it should be. It
also "hides" half of the development, as everything happening in the low level
parts resides under fbdev directory, not in the drm directory.
I've been wanting to clean this up for a long time, but I haven't figured out a
very good way to do it. I still haven't, but here's the best way I have come up
with.
This series makes a full copy of the low level parts, omapdss and panel/encoder
drivers. Both omapfb+omap_vout and omapdrm will have their own versions. The
copy omapfb+omap_vout get is a new copy, and the copy that omapdrm gets is just
the current files moved. This way git will associate the omapdrm version with
the old files.
The omapfb+omap_vout versions won't be touched unless there are some big issues
there.
The omapdrm versions can be refactored and cleaned up, as the omapfb support
code is no longer needed. We can perhaps also merge omapdss and omapdrm into
the same kernel module.
This series only does the copy, and the absolutely necessary parts. No further
cleanups are done yet.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Dave Airlie <airlied@gmail.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/video/fbdev/omap2/omapfb/dss/dss-of.c')
-rw-r--r-- | drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c new file mode 100644 index 000000000000..bf407b6ba15c --- /dev/null +++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2013 Texas Instruments + * Author: Tomi Valkeinen <tomi.valkeinen@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. + * + * This program is distributed in the hope that 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. + */ + +#include <linux/device.h> +#include <linux/err.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/seq_file.h> + +#include <video/omapdss.h> + +#include "dss.h" + +struct device_node * +omapdss_of_get_next_port(const struct device_node *parent, + struct device_node *prev) +{ + struct device_node *port = NULL; + + if (!parent) + return NULL; + + if (!prev) { + struct device_node *ports; + /* + * It's the first call, we have to find a port subnode + * within this node or within an optional 'ports' node. + */ + ports = of_get_child_by_name(parent, "ports"); + if (ports) + parent = ports; + + port = of_get_child_by_name(parent, "port"); + + /* release the 'ports' node */ + of_node_put(ports); + } else { + struct device_node *ports; + + ports = of_get_parent(prev); + if (!ports) + return NULL; + + do { + port = of_get_next_child(ports, prev); + if (!port) { + of_node_put(ports); + return NULL; + } + prev = port; + } while (of_node_cmp(port->name, "port") != 0); + + of_node_put(ports); + } + + return port; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_next_port); + +struct device_node * +omapdss_of_get_next_endpoint(const struct device_node *parent, + struct device_node *prev) +{ + struct device_node *ep = NULL; + + if (!parent) + return NULL; + + do { + ep = of_get_next_child(parent, prev); + if (!ep) + return NULL; + prev = ep; + } while (of_node_cmp(ep->name, "endpoint") != 0); + + return ep; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_next_endpoint); + +struct device_node *dss_of_port_get_parent_device(struct device_node *port) +{ + struct device_node *np; + int i; + + if (!port) + return NULL; + + np = of_get_parent(port); + + for (i = 0; i < 2 && np; ++i) { + struct property *prop; + + prop = of_find_property(np, "compatible", NULL); + + if (prop) + return np; + + np = of_get_next_parent(np); + } + + return NULL; +} + +u32 dss_of_port_get_port_number(struct device_node *port) +{ + int r; + u32 reg; + + r = of_property_read_u32(port, "reg", ®); + if (r) + reg = 0; + + return reg; +} + +static struct device_node *omapdss_of_get_remote_port(const struct device_node *node) +{ + struct device_node *np; + + np = of_parse_phandle(node, "remote-endpoint", 0); + if (!np) + return NULL; + + np = of_get_next_parent(np); + + return np; +} + +struct device_node * +omapdss_of_get_first_endpoint(const struct device_node *parent) +{ + struct device_node *port, *ep; + + port = omapdss_of_get_next_port(parent, NULL); + + if (!port) + return NULL; + + ep = omapdss_of_get_next_endpoint(port, NULL); + + of_node_put(port); + + return ep; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint); + +struct omap_dss_device * +omapdss_of_find_source_for_first_ep(struct device_node *node) +{ + struct device_node *ep; + struct device_node *src_port; + struct omap_dss_device *src; + + ep = omapdss_of_get_first_endpoint(node); + if (!ep) + return ERR_PTR(-EINVAL); + + src_port = omapdss_of_get_remote_port(ep); + if (!src_port) { + of_node_put(ep); + return ERR_PTR(-EINVAL); + } + + of_node_put(ep); + + src = omap_dss_find_output_by_port_node(src_port); + + of_node_put(src_port); + + return src ? src : ERR_PTR(-EPROBE_DEFER); +} +EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep); |