Message ID | E1X2kC1-0000sH-C6@rmk-PC.arm.linux.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jul 3, 2014 at 12:49 PM, Russell King <rmk+kernel@arm.linux.org.uk> wrote: > Add a helper to allow encoders to find their possible CRTCs from the > OF graph without having to re-implement this functionality. We add a > device_node to drm_crtc which corresponds with the port node in the > DT description of the CRTC device. > > We can then scan the DRM device list for CRTCs to find their index, > matching the appropriate CRTC using the port device_node, thus building > up the possible CRTC mask. > > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> > --- > This helper will be shared between imx-drm and Armada DRM, and should > be useful for other OF-based drivers. At the moment, this is being > sent for comments and acks; I need to build upon this patch in order > to convert Armada DRM to DT. ok, possibly a dumb question, but in my defense I don't claim to be a DT expert ;-) Do you have somewhere handy a example dts which this would be parsing? I think that would help me understand this patch a bit better. BR, -R > drivers/gpu/drm/Makefile | 1 + > drivers/gpu/drm/drm_of.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ > include/drm/drm_crtc.h | 2 ++ > include/drm/drm_of.h | 18 ++++++++++++++ > 4 files changed, 86 insertions(+) > create mode 100644 drivers/gpu/drm/drm_of.c > create mode 100644 include/drm/drm_of.h > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index dd2ba4269740..533d011eab3e 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -20,6 +20,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o > drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o > drm-$(CONFIG_PCI) += ati_pcigart.o > drm-$(CONFIG_DRM_PANEL) += drm_panel.o > +drm-$(CONFIG_OF) += drm_of.o > > drm-usb-y := drm_usb.o > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > new file mode 100644 > index 000000000000..46d967881689 > --- /dev/null > +++ b/drivers/gpu/drm/drm_of.c > @@ -0,0 +1,65 @@ > +#include <linux/export.h> > +#include <linux/list.h> > +#include <linux/of_graph.h> > +#include <drm/drmP.h> > +#include <drm/drm_crtc.h> > +#include <drm/drm_of.h> > + > +/** > + * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node > + * @dev: DRM device > + * @port: port OF node > + * > + * Given a port OF node, return the possible mask of the corresponding > + * CRTC within a device's list of CRTCs. Returns zero if not found. > + */ > +static uint32_t drm_crtc_port_mask(struct drm_device *dev, > + struct device_node *port) > +{ > + unsigned int index = 0; > + struct drm_crtc *tmp; > + > + list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) { > + if (tmp->port == port) > + return 1 << index; > + > + index++; > + } > + > + return 0; > +} > + > +/** > + * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port > + * @dev: DRM device > + * @port: encoder port to scan for endpoints > + * > + * Scan all endpoints attached to a port, locate their attached CRTCs, > + * and generate the DRM mask of CRTCs which may be attached to this > + * encoder. > + */ > +uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port) > +{ > + struct device_node *remote_port, *ep = NULL; > + uint32_t possible_crtcs = 0; > + > + do { > + ep = of_graph_get_next_endpoint(port, ep); > + if (!ep) > + break; > + > + remote_port = of_graph_get_remote_port(ep); > + if (!remote_port) { > + of_node_put(ep); > + return 0; > + } > + > + possible_crtcs |= drm_crtc_port_mask(dev, remote_port); > + > + of_node_put(remote_port); > + } while (1); > + > + return possible_crtcs; > +} > +EXPORT_SYMBOL(drm_of_find_possible_crtcs); > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h > index 251b75e6bf7a..6a94909f1ca9 100644 > --- a/include/drm/drm_crtc.h > +++ b/include/drm/drm_crtc.h > @@ -41,6 +41,7 @@ struct drm_framebuffer; > struct drm_object_properties; > struct drm_file; > struct drm_clip_rect; > +struct device_node; > > #define DRM_MODE_OBJECT_CRTC 0xcccccccc > #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 > @@ -314,6 +315,7 @@ struct drm_crtc_funcs { > */ > struct drm_crtc { > struct drm_device *dev; > + struct device_node *port; > struct list_head head; > > /** > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h > new file mode 100644 > index 000000000000..2441f7112074 > --- /dev/null > +++ b/include/drm/drm_of.h > @@ -0,0 +1,18 @@ > +#ifndef __DRM_OF_H__ > +#define __DRM_OF_H__ > + > +struct drm_device; > +struct device_node; > + > +#ifdef CONFIG_OF > +extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port); > +#else > +static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port) > +{ > + return 0; > +} > +#endif > + > +#endif /* __DRM_OF_H__ */ > -- > 1.8.3.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Jul 3, 2014 at 12:49 PM, Russell King <rmk+kernel@arm.linux.org.uk> wrote: > Add a helper to allow encoders to find their possible CRTCs from the > OF graph without having to re-implement this functionality. We add a > device_node to drm_crtc which corresponds with the port node in the > DT description of the CRTC device. > > We can then scan the DRM device list for CRTCs to find their index, > matching the appropriate CRTC using the port device_node, thus building > up the possible CRTC mask. > > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> > --- > This helper will be shared between imx-drm and Armada DRM, and should > be useful for other OF-based drivers. At the moment, this is being > sent for comments and acks; I need to build upon this patch in order > to convert Armada DRM to DT. > > drivers/gpu/drm/Makefile | 1 + > drivers/gpu/drm/drm_of.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ > include/drm/drm_crtc.h | 2 ++ > include/drm/drm_of.h | 18 ++++++++++++++ oh, probably also should get links in Documentation/DocBook/drm.tmpl BR, -R > 4 files changed, 86 insertions(+) > create mode 100644 drivers/gpu/drm/drm_of.c > create mode 100644 include/drm/drm_of.h > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index dd2ba4269740..533d011eab3e 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -20,6 +20,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o > drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o > drm-$(CONFIG_PCI) += ati_pcigart.o > drm-$(CONFIG_DRM_PANEL) += drm_panel.o > +drm-$(CONFIG_OF) += drm_of.o > > drm-usb-y := drm_usb.o > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > new file mode 100644 > index 000000000000..46d967881689 > --- /dev/null > +++ b/drivers/gpu/drm/drm_of.c > @@ -0,0 +1,65 @@ > +#include <linux/export.h> > +#include <linux/list.h> > +#include <linux/of_graph.h> > +#include <drm/drmP.h> > +#include <drm/drm_crtc.h> > +#include <drm/drm_of.h> > + > +/** > + * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node > + * @dev: DRM device > + * @port: port OF node > + * > + * Given a port OF node, return the possible mask of the corresponding > + * CRTC within a device's list of CRTCs. Returns zero if not found. > + */ > +static uint32_t drm_crtc_port_mask(struct drm_device *dev, > + struct device_node *port) > +{ > + unsigned int index = 0; > + struct drm_crtc *tmp; > + > + list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) { > + if (tmp->port == port) > + return 1 << index; > + > + index++; > + } > + > + return 0; > +} > + > +/** > + * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port > + * @dev: DRM device > + * @port: encoder port to scan for endpoints > + * > + * Scan all endpoints attached to a port, locate their attached CRTCs, > + * and generate the DRM mask of CRTCs which may be attached to this > + * encoder. > + */ > +uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port) > +{ > + struct device_node *remote_port, *ep = NULL; > + uint32_t possible_crtcs = 0; > + > + do { > + ep = of_graph_get_next_endpoint(port, ep); > + if (!ep) > + break; > + > + remote_port = of_graph_get_remote_port(ep); > + if (!remote_port) { > + of_node_put(ep); > + return 0; > + } > + > + possible_crtcs |= drm_crtc_port_mask(dev, remote_port); > + > + of_node_put(remote_port); > + } while (1); > + > + return possible_crtcs; > +} > +EXPORT_SYMBOL(drm_of_find_possible_crtcs); > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h > index 251b75e6bf7a..6a94909f1ca9 100644 > --- a/include/drm/drm_crtc.h > +++ b/include/drm/drm_crtc.h > @@ -41,6 +41,7 @@ struct drm_framebuffer; > struct drm_object_properties; > struct drm_file; > struct drm_clip_rect; > +struct device_node; > > #define DRM_MODE_OBJECT_CRTC 0xcccccccc > #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 > @@ -314,6 +315,7 @@ struct drm_crtc_funcs { > */ > struct drm_crtc { > struct drm_device *dev; > + struct device_node *port; > struct list_head head; > > /** > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h > new file mode 100644 > index 000000000000..2441f7112074 > --- /dev/null > +++ b/include/drm/drm_of.h > @@ -0,0 +1,18 @@ > +#ifndef __DRM_OF_H__ > +#define __DRM_OF_H__ > + > +struct drm_device; > +struct device_node; > + > +#ifdef CONFIG_OF > +extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port); > +#else > +static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > + struct device_node *port) > +{ > + return 0; > +} > +#endif > + > +#endif /* __DRM_OF_H__ */ > -- > 1.8.3.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Jul 03, 2014 at 06:17:24PM -0400, Rob Clark wrote: > On Thu, Jul 3, 2014 at 12:49 PM, Russell King > <rmk+kernel@arm.linux.org.uk> wrote: > > Add a helper to allow encoders to find their possible CRTCs from the > > OF graph without having to re-implement this functionality. We add a > > device_node to drm_crtc which corresponds with the port node in the > > DT description of the CRTC device. > > > > We can then scan the DRM device list for CRTCs to find their index, > > matching the appropriate CRTC using the port device_node, thus building > > up the possible CRTC mask. > > > > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> > > --- > > This helper will be shared between imx-drm and Armada DRM, and should > > be useful for other OF-based drivers. At the moment, this is being > > sent for comments and acks; I need to build upon this patch in order > > to convert Armada DRM to DT. > > ok, possibly a dumb question, but in my defense I don't claim to be a > DT expert ;-) > > Do you have somewhere handy a example dts which this would be parsing? > I think that would help me understand this patch a bit better. The patch is merely moving something that's already being used by imx-drm into a more convenient location. The documentation for the "binding" (it isn't really parsing a binding, merely traversing the graph itself) is: Documentation/devicetree/bindings/graph.txt which is shared from the v4l2 code. To give an example, this is an extract from the imx6qdl dtsi file. I've cut out a load of stuff which isn't that relevant to the overall structure. The full stuff is arch/arm/boots/dts/imx6qdl.dtsi. IPU contains two display interfaces (DIs, aka CRTCs). Each display interface is connected to a set of muxes, one mux per display bridge (encoder/connector) which can select between DI0 or DI1. Some chips have two IPUs, hence four DIs, making it possible to drive the four display bridges entirely independently. ipu1: ipu@02400000 { ipu1_di0: port@2 { ipu1_di0_hdmi: endpoint@1 { remote-endpoint = <&hdmi_mux_0>; }; ... ipu1_di0_lvds1: endpoint@4 { remote-endpoint = <&lvds1_mux_0>; }; }; ipu1_di1: port@3 { ipu1_di0_disp1: endpoint@0 { }; ipu1_di1_hdmi: endpoint@1 { remote-endpoint = <&hdmi_mux_1>; }; ... ipu1_di1_lvds1: endpoint@4 { remote-endpoint = <&lvds1_mux_1>; }; }; }; HDMI transmitter component: hdmi: hdmi@0120000 { port@0 { reg = <0>; hdmi_mux_0: endpoint { remote-endpoint = <&ipu1_di0_hdmi>; }; }; port@1 { reg = <1>; hdmi_mux_1: endpoint { remote-endpoint = <&ipu1_di1_hdmi>; }; }; };
On Thu, Jul 3, 2014 at 6:41 PM, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > On Thu, Jul 03, 2014 at 06:17:24PM -0400, Rob Clark wrote: >> On Thu, Jul 3, 2014 at 12:49 PM, Russell King >> <rmk+kernel@arm.linux.org.uk> wrote: >> > Add a helper to allow encoders to find their possible CRTCs from the >> > OF graph without having to re-implement this functionality. We add a >> > device_node to drm_crtc which corresponds with the port node in the >> > DT description of the CRTC device. >> > >> > We can then scan the DRM device list for CRTCs to find their index, >> > matching the appropriate CRTC using the port device_node, thus building >> > up the possible CRTC mask. >> > >> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> >> > --- >> > This helper will be shared between imx-drm and Armada DRM, and should >> > be useful for other OF-based drivers. At the moment, this is being >> > sent for comments and acks; I need to build upon this patch in order >> > to convert Armada DRM to DT. >> >> ok, possibly a dumb question, but in my defense I don't claim to be a >> DT expert ;-) >> >> Do you have somewhere handy a example dts which this would be parsing? >> I think that would help me understand this patch a bit better. > > The patch is merely moving something that's already being used by > imx-drm into a more convenient location. > > The documentation for the "binding" (it isn't really parsing a binding, > merely traversing the graph itself) is: > > Documentation/devicetree/bindings/graph.txt ahh, thanks.. this makes more sense. Might be worth putting something along the lines of "see Documentation/devicetree/bindings/graph.txt" for the drm_of_find_possible_crtcs() comment block. BR, -R > which is shared from the v4l2 code. > > To give an example, this is an extract from the imx6qdl dtsi file. I've > cut out a load of stuff which isn't that relevant to the overall > structure. The full stuff is arch/arm/boots/dts/imx6qdl.dtsi. > > IPU contains two display interfaces (DIs, aka CRTCs). Each display > interface is connected to a set of muxes, one mux per display bridge > (encoder/connector) which can select between DI0 or DI1. Some chips > have two IPUs, hence four DIs, making it possible to drive the four > display bridges entirely independently. > > ipu1: ipu@02400000 { > ipu1_di0: port@2 { > ipu1_di0_hdmi: endpoint@1 { > remote-endpoint = <&hdmi_mux_0>; > }; > ... > ipu1_di0_lvds1: endpoint@4 { > remote-endpoint = <&lvds1_mux_0>; > }; > }; > > ipu1_di1: port@3 { > ipu1_di0_disp1: endpoint@0 { > }; > > ipu1_di1_hdmi: endpoint@1 { > remote-endpoint = <&hdmi_mux_1>; > }; > ... > ipu1_di1_lvds1: endpoint@4 { > remote-endpoint = <&lvds1_mux_1>; > }; > }; > }; > > HDMI transmitter component: > > hdmi: hdmi@0120000 { > port@0 { > reg = <0>; > > hdmi_mux_0: endpoint { > remote-endpoint = <&ipu1_di0_hdmi>; > }; > }; > > port@1 { > reg = <1>; > > hdmi_mux_1: endpoint { > remote-endpoint = <&ipu1_di1_hdmi>; > }; > }; > }; > > -- > FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly > improving, and getting towards what was expected from it.
On Thu, Jul 03, 2014 at 06:36:47PM -0400, Rob Clark wrote: > On Thu, Jul 3, 2014 at 12:49 PM, Russell King > <rmk+kernel@arm.linux.org.uk> wrote: > > Add a helper to allow encoders to find their possible CRTCs from the > > OF graph without having to re-implement this functionality. We add a > > device_node to drm_crtc which corresponds with the port node in the > > DT description of the CRTC device. > > > > We can then scan the DRM device list for CRTCs to find their index, > > matching the appropriate CRTC using the port device_node, thus building > > up the possible CRTC mask. > > > > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> > > --- > > This helper will be shared between imx-drm and Armada DRM, and should > > be useful for other OF-based drivers. At the moment, this is being > > sent for comments and acks; I need to build upon this patch in order > > to convert Armada DRM to DT. > > > > drivers/gpu/drm/Makefile | 1 + > > drivers/gpu/drm/drm_of.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ > > include/drm/drm_crtc.h | 2 ++ > > include/drm/drm_of.h | 18 ++++++++++++++ > > oh, probably also should get links in Documentation/DocBook/drm.tmpl Hmm... can you advise a suitable location... I've never touched that stuff before, and it seems I can't even get it to build on my machine: Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' DOCPROC Documentation/DocBook/w1.xml DOCPROC Documentation/DocBook/writing_musb_glue_layer.xml PDF Documentation/DocBook/z8530book.pdf Making portrait pages on A4 paper (210mmx297mm) sh: /usr/share/xmlto/format/docbook/../fo/pdf: No such file or directory make[2]: *** [Documentation/DocBook/z8530book.pdf] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [pdfdocs] Error 2 make: *** [sub-make] Error 2 I guess my install is too old for it. Thanks.
On Wed, Jul 9, 2014 at 11:16 AM, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > On Thu, Jul 03, 2014 at 06:36:47PM -0400, Rob Clark wrote: >> On Thu, Jul 3, 2014 at 12:49 PM, Russell King >> <rmk+kernel@arm.linux.org.uk> wrote: >> > Add a helper to allow encoders to find their possible CRTCs from the >> > OF graph without having to re-implement this functionality. We add a >> > device_node to drm_crtc which corresponds with the port node in the >> > DT description of the CRTC device. >> > >> > We can then scan the DRM device list for CRTCs to find their index, >> > matching the appropriate CRTC using the port device_node, thus building >> > up the possible CRTC mask. >> > >> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> >> > --- >> > This helper will be shared between imx-drm and Armada DRM, and should >> > be useful for other OF-based drivers. At the moment, this is being >> > sent for comments and acks; I need to build upon this patch in order >> > to convert Armada DRM to DT. >> > >> > drivers/gpu/drm/Makefile | 1 + >> > drivers/gpu/drm/drm_of.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ >> > include/drm/drm_crtc.h | 2 ++ >> > include/drm/drm_of.h | 18 ++++++++++++++ >> >> oh, probably also should get links in Documentation/DocBook/drm.tmpl > > Hmm... can you advise a suitable location... I've never touched that > stuff before, and it seems I can't even get it to build on my machine: > > Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' > Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' > Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' > Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' > DOCPROC Documentation/DocBook/w1.xml > DOCPROC Documentation/DocBook/writing_musb_glue_layer.xml > PDF Documentation/DocBook/z8530book.pdf > Making portrait pages on A4 paper (210mmx297mm) > sh: /usr/share/xmlto/format/docbook/../fo/pdf: No such file or directory > make[2]: *** [Documentation/DocBook/z8530book.pdf] Error 1 > make[2]: *** Waiting for unfinished jobs.... > make[1]: *** [pdfdocs] Error 2 > make: *** [sub-make] Error 2 hmm, I usually use 'make htmldocs'.. hadn't really bothered to try to build pdf docs. It was a while ago, but I think 'xmlto-tex' would be what you need for fedora to get docs to build. Hopefully the package has a similar name on other distros. There are unfortunately a lot of warnings.. the headerdoc stuff is not always as clever as you would like. BR, -R > I guess my install is too old for it. > > Thanks. > > -- > FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up > according to speedtest.net.
On Wed, Jul 09, 2014 at 02:11:18PM -0400, Rob Clark wrote: > On Wed, Jul 9, 2014 at 11:16 AM, Russell King - ARM Linux > <linux@arm.linux.org.uk> wrote: > > Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' > > Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' > > Warning(.../include/drm/drm_flip_work.h:68): No description found for parameter ')' > > Warning(.../include/drm/drm_flip_work.h:68): Excess struct/union/enum/typedef member 'fifo' description in 'drm_flip_work' > > DOCPROC Documentation/DocBook/w1.xml > > DOCPROC Documentation/DocBook/writing_musb_glue_layer.xml > > PDF Documentation/DocBook/z8530book.pdf > > Making portrait pages on A4 paper (210mmx297mm) > > sh: /usr/share/xmlto/format/docbook/../fo/pdf: No such file or directory > > make[2]: *** [Documentation/DocBook/z8530book.pdf] Error 1 > > make[2]: *** Waiting for unfinished jobs.... > > make[1]: *** [pdfdocs] Error 2 > > make: *** [sub-make] Error 2 > > hmm, I usually use 'make htmldocs'.. hadn't really bothered to try to > build pdf docs. It was a while ago, but I think 'xmlto-tex' would be > what you need for fedora to get docs to build. Hopefully the package > has a similar name on other distros. > > There are unfortunately a lot of warnings.. the headerdoc stuff is > not always as clever as you would like. Thanks, that helps it get a bit further, but it spits out a whole truck load of errors before it gets anywhere near DRM stuff. Either this stuff isn't maintained, or it's for a newer flavour of TEX. From what I read on the web, this kind of problem is fairly typical where TEX stuff goes (no two tex versions are compatible.) I think I'll leave the kerneldoc stuff to someone who knows (a) how to deal with it.
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index dd2ba4269740..533d011eab3e 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -20,6 +20,7 @@ drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o drm-$(CONFIG_PCI) += ati_pcigart.o drm-$(CONFIG_DRM_PANEL) += drm_panel.o +drm-$(CONFIG_OF) += drm_of.o drm-usb-y := drm_usb.o diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c new file mode 100644 index 000000000000..46d967881689 --- /dev/null +++ b/drivers/gpu/drm/drm_of.c @@ -0,0 +1,65 @@ +#include <linux/export.h> +#include <linux/list.h> +#include <linux/of_graph.h> +#include <drm/drmP.h> +#include <drm/drm_crtc.h> +#include <drm/drm_of.h> + +/** + * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node + * @dev: DRM device + * @port: port OF node + * + * Given a port OF node, return the possible mask of the corresponding + * CRTC within a device's list of CRTCs. Returns zero if not found. + */ +static uint32_t drm_crtc_port_mask(struct drm_device *dev, + struct device_node *port) +{ + unsigned int index = 0; + struct drm_crtc *tmp; + + list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) { + if (tmp->port == port) + return 1 << index; + + index++; + } + + return 0; +} + +/** + * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port + * @dev: DRM device + * @port: encoder port to scan for endpoints + * + * Scan all endpoints attached to a port, locate their attached CRTCs, + * and generate the DRM mask of CRTCs which may be attached to this + * encoder. + */ +uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, + struct device_node *port) +{ + struct device_node *remote_port, *ep = NULL; + uint32_t possible_crtcs = 0; + + do { + ep = of_graph_get_next_endpoint(port, ep); + if (!ep) + break; + + remote_port = of_graph_get_remote_port(ep); + if (!remote_port) { + of_node_put(ep); + return 0; + } + + possible_crtcs |= drm_crtc_port_mask(dev, remote_port); + + of_node_put(remote_port); + } while (1); + + return possible_crtcs; +} +EXPORT_SYMBOL(drm_of_find_possible_crtcs); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 251b75e6bf7a..6a94909f1ca9 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -41,6 +41,7 @@ struct drm_framebuffer; struct drm_object_properties; struct drm_file; struct drm_clip_rect; +struct device_node; #define DRM_MODE_OBJECT_CRTC 0xcccccccc #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 @@ -314,6 +315,7 @@ struct drm_crtc_funcs { */ struct drm_crtc { struct drm_device *dev; + struct device_node *port; struct list_head head; /** diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h new file mode 100644 index 000000000000..2441f7112074 --- /dev/null +++ b/include/drm/drm_of.h @@ -0,0 +1,18 @@ +#ifndef __DRM_OF_H__ +#define __DRM_OF_H__ + +struct drm_device; +struct device_node; + +#ifdef CONFIG_OF +extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, + struct device_node *port); +#else +static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, + struct device_node *port) +{ + return 0; +} +#endif + +#endif /* __DRM_OF_H__ */
Add a helper to allow encoders to find their possible CRTCs from the OF graph without having to re-implement this functionality. We add a device_node to drm_crtc which corresponds with the port node in the DT description of the CRTC device. We can then scan the DRM device list for CRTCs to find their index, matching the appropriate CRTC using the port device_node, thus building up the possible CRTC mask. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> --- This helper will be shared between imx-drm and Armada DRM, and should be useful for other OF-based drivers. At the moment, this is being sent for comments and acks; I need to build upon this patch in order to convert Armada DRM to DT. drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_of.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 2 ++ include/drm/drm_of.h | 18 ++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 drivers/gpu/drm/drm_of.c create mode 100644 include/drm/drm_of.h