Re: [U-Boot] [PATCH 3/5] arm: tegra30: video: integrate display driver for t30

On 20 Aug 2015 22:09, Stephen Warren swarren@wwwdotorg.org wrote:
Hopefully the process was to copy the Linux Tegra30 DT verbatim?
No, the T20 one is far from verbatim neither. So I just did the adjustments analogous by comparing the T20 and T30 Linux DTs.
That's far more likely to yield a correct DT than copying the Tegra20 DT to Tegra30 and then patching it until it works.
I guess U-Boot has anyway about zero functionality dependency on that part of the device trees.
If this DT doesn't exactly match the Linux kernel, this needs to be fixed.
Well, then any Tegra device tree currently in U-Boot needs serious fixing. I usually tend to at least not make the mess any worse.
diff --git a/arch/arm/mach-tegra/tegra30/Makefile b/arch/arm/mach-tegra/tegra30/Makefile
-obj-$(CONFIG_SPL_BUILD) += cpu.o +ifdef CONFIG_SPL_BUILD +obj-y += cpu.o
I don't think there's any need to edit the cpu.o line. While you can move it into the ifdef like that, I don't see a need.
I can sure revert this then.
diff --git a/arch/arm/mach-tegra/tegra30/display.c b/arch/arm/mach-tegra/tegra30/display.c
I didn't review this file in detail; I'll leave that to Thierry since he knows the display HW.
However, one question: Is this file a complete cut/paste of tegra20/display.c, or does it just replace some parts of it? Hopefully this patch doesn't simply duplicate the whole driver?
Yes, for now this is an exact one-to-one copy but I lack the detailed knowledge about Tegra graphics to know whether this is much sane.
On first sight to me the current split between hardware agnostic (e.g. driver/video/tegra.c) and hardware specific (e.g. mach-tegra/<SoC>/display.c) seems rather arbitrary. Downstream [1] I actually took a more radical approach and if that is rather accepted I'm happy to rework this patch set in that direction as well. But then actually completely merging tegra.c and display.c might even make more sense. I'm open to suggestions really.
[1] http://git.toradex.com/cgit/u-boot-toradex.git/commit/?h=2015.04-toradex-nex...

On Thu, Aug 20, 2015 at 11:46:41PM +0000, Marcel Ziswiler wrote:
On 20 Aug 2015 22:09, Stephen Warren swarren@wwwdotorg.org wrote:
Hopefully the process was to copy the Linux Tegra30 DT verbatim?
No, the T20 one is far from verbatim neither. So I just did the adjustments analogous by comparing the T20 and T30 Linux DTs.
I agree with Stephen that U-Boot should use an exact copy of the DTS files in the kernel. The bits in the kernel get much more review and have been known to work well for a number of years.
That's far more likely to yield a correct DT than copying the Tegra20 DT to Tegra30 and then patching it until it works.
I guess U-Boot has anyway about zero functionality dependency on that part of the device trees.
U-Boot depending on the device tree or not is really an orthogonal issue. If we keep a delta between U-Boot and Linux DTS files, we'll risk breaking things badly if we ever do end up putting device tree sources into a common source tree, because we'd be exposing U-Boot to something that it wasn't tested against.
If this DT doesn't exactly match the Linux kernel, this needs to be fixed.
Well, then any Tegra device tree currently in U-Boot needs serious fixing. I usually tend to at least not make the mess any worse.
That's certainly a true statement. There really should never have been such a disconnect as we currently have. If we can't agree on using the very same DTS files for both U-Boot and Linux we might as well not use device tree at all (in U-Boot).
Perhaps a good idea would be to simply copy what we have in the kernel and see where (if at all) U-Boot breaks down and fix it to work properly with "upstream" DTBs.
I can't obviously force you to do all that work to fix past mistakes, but I'd like to see at least new DTS content in U-Boot deviate from what we have upstream in the kernel.
diff --git a/arch/arm/mach-tegra/tegra30/Makefile b/arch/arm/mach-tegra/tegra30/Makefile
-obj-$(CONFIG_SPL_BUILD) += cpu.o +ifdef CONFIG_SPL_BUILD +obj-y += cpu.o
I don't think there's any need to edit the cpu.o line. While you can move it into the ifdef like that, I don't see a need.
I can sure revert this then.
diff --git a/arch/arm/mach-tegra/tegra30/display.c b/arch/arm/mach-tegra/tegra30/display.c
I didn't review this file in detail; I'll leave that to Thierry since he knows the display HW.
However, one question: Is this file a complete cut/paste of tegra20/display.c, or does it just replace some parts of it? Hopefully this patch doesn't simply duplicate the whole driver?
Yes, for now this is an exact one-to-one copy but I lack the detailed knowledge about Tegra graphics to know whether this is much sane.
It looks to me like this adds even a third copy. There's already a duplicate of the display controller bits in drivers/video/tegra124 along with some new code to support eDP. There really isn't much reason for duplicating the drivers since the display controllers haven't changed very much over the various SoC generations. And especially in U-Boot I don't think you'll need fancy features like color conversion or gamma correction, or smart dimming, which are really the only areas where there have been changes.
If you look at the Linux kernel driver we get away with very minimal parameterization, and I think the same should be possible for U-Boot.
In a similar vein I think it should be possible to write unified drivers for each type of output (RGB, HDMI, DSI, SOR). Those require even less parameterization since there have been almost no changes to those since their introduction, the rare exception being fancy features that I don't think would be needed for U-Boot.
Granted, U-Boot doesn't give you much of a framework to work with, so there's a lot of code that would need to be written to abstract things, but I think that's effort well spent, much better than simply duplicating for each new generation.
On first sight to me the current split between hardware agnostic (e.g. driver/video/tegra.c) and hardware specific (e.g. mach-tegra/<SoC>/display.c) seems rather arbitrary. Downstream [1] I actually took a more radical approach and if that is rather accepted I'm happy to rework this patch set in that direction as well. But then actually completely merging tegra.c and display.c might even make more sense. I'm open to suggestions really.
[1] http://git.toradex.com/cgit/u-boot-toradex.git/commit/?h=2015.04-toradex-nex...
Frankly I think it should all move into a separate "tegra" subdirectory in drivers/video/. There's likely going to be quite a few files if we want to support several types of outputs, and a subdirectory will help keep things organized.
I think a framework for U-Boot could be fairly simple and doesn't have to have the complexity of DRM/KMS in the kernel. I'd expect the U-Boot configuration to be statically defined, and if the "framework" is Tegra specific it doesn't need to be as generic either.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... };
struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
Thierry

Hi,
On 21 August 2015 at 03:27, Thierry Reding treding@nvidia.com wrote:
On Thu, Aug 20, 2015 at 11:46:41PM +0000, Marcel Ziswiler wrote:
On 20 Aug 2015 22:09, Stephen Warren swarren@wwwdotorg.org wrote:
Hopefully the process was to copy the Linux Tegra30 DT verbatim?
No, the T20 one is far from verbatim neither. So I just did the adjustments analogous by comparing the T20 and T30 Linux DTs.
I agree with Stephen that U-Boot should use an exact copy of the DTS files in the kernel. The bits in the kernel get much more review and have been known to work well for a number of years.
That's far more likely to yield a correct DT than copying the Tegra20 DT to Tegra30 and then patching it until it works.
I guess U-Boot has anyway about zero functionality dependency on that part of the device trees.
U-Boot depending on the device tree or not is really an orthogonal issue. If we keep a delta between U-Boot and Linux DTS files, we'll risk breaking things badly if we ever do end up putting device tree sources into a common source tree, because we'd be exposing U-Boot to something that it wasn't tested against.
If this DT doesn't exactly match the Linux kernel, this needs to be fixed.
Well, then any Tegra device tree currently in U-Boot needs serious fixing. I usually tend to at least not make the mess any worse.
That's certainly a true statement. There really should never have been such a disconnect as we currently have. If we can't agree on using the very same DTS files for both U-Boot and Linux we might as well not use device tree at all (in U-Boot).
Perhaps a good idea would be to simply copy what we have in the kernel and see where (if at all) U-Boot breaks down and fix it to work properly with "upstream" DTBs.
I can't obviously force you to do all that work to fix past mistakes, but I'd like to see at least new DTS content in U-Boot deviate from what we have upstream in the kernel.
diff --git a/arch/arm/mach-tegra/tegra30/Makefile b/arch/arm/mach-tegra/tegra30/Makefile
-obj-$(CONFIG_SPL_BUILD) += cpu.o +ifdef CONFIG_SPL_BUILD +obj-y += cpu.o
I don't think there's any need to edit the cpu.o line. While you can move it into the ifdef like that, I don't see a need.
I can sure revert this then.
diff --git a/arch/arm/mach-tegra/tegra30/display.c b/arch/arm/mach-tegra/tegra30/display.c
I didn't review this file in detail; I'll leave that to Thierry since he knows the display HW.
However, one question: Is this file a complete cut/paste of tegra20/display.c, or does it just replace some parts of it? Hopefully this patch doesn't simply duplicate the whole driver?
Yes, for now this is an exact one-to-one copy but I lack the detailed knowledge about Tegra graphics to know whether this is much sane.
I have serious doubts about the wisdom of requiring a contributor to completely re-architect the existing display system in U-Boot. It's a big job. Perhaps we can settle for following along the same lines and not making things worse?
That said, if Marcel has the time, I may as well pile on with a few more comments :-)
It looks to me like this adds even a third copy. There's already a duplicate of the display controller bits in drivers/video/tegra124 along with some new code to support eDP. There really isn't much reason for duplicating the drivers since the display controllers haven't changed very much over the various SoC generations. And especially in U-Boot I don't think you'll need fancy features like color conversion or gamma correction, or smart dimming, which are really the only areas where there have been changes.
If you look at the Linux kernel driver we get away with very minimal parameterization, and I think the same should be possible for U-Boot.
In a similar vein I think it should be possible to write unified drivers for each type of output (RGB, HDMI, DSI, SOR). Those require even less parameterization since there have been almost no changes to those since their introduction, the rare exception being fancy features that I don't think would be needed for U-Boot.
Granted, U-Boot doesn't give you much of a framework to work with, so there's a lot of code that would need to be written to abstract things, but I think that's effort well spent, much better than simply duplicating for each new generation.
On first sight to me the current split between hardware agnostic (e.g. driver/video/tegra.c) and hardware specific (e.g. mach-tegra/<SoC>/display.c) seems rather arbitrary. Downstream [1] I actually took a more radical approach and if that is rather accepted I'm happy to rework this patch set in that direction as well. But then actually completely merging tegra.c and display.c might even make more sense. I'm open to suggestions really.
[1] http://git.toradex.com/cgit/u-boot-toradex.git/commit/?h=2015.04-toradex-nex...
Frankly I think it should all move into a separate "tegra" subdirectory in drivers/video/. There's likely going to be quite a few files if we want to support several types of outputs, and a subdirectory will help keep things organized.
I think a framework for U-Boot could be fairly simple and doesn't have to have the complexity of DRM/KMS in the kernel. I'd expect the U-Boot configuration to be statically defined, and if the "framework" is Tegra specific it doesn't need to be as generic either.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... }; struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Please don't add function points to structures on an ad-hoc basis. These should use driver model. There is a uclass for display port but not for LCD panels or SOR. You could add a very simple one for a panel if you like. Please take a look at tegra124's display driver for an example.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
Regards, Simon

On Fri, Aug 21, 2015 at 06:37:37PM -0600, Simon Glass wrote: [...]
I have serious doubts about the wisdom of requiring a contributor to completely re-architect the existing display system in U-Boot. It's a big job. Perhaps we can settle for following along the same lines and not making things worse?
I didn't suggest re-architecting the display system in U-Boot. What I was suggesting was a way to architect Tegra-specific display driver code to make it reusable rather than duplicate display controller programming for each new generation, while the hardware has remained mostly the same.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... }; struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Please don't add function points to structures on an ad-hoc basis. These should use driver model. There is a uclass for display port but not for LCD panels or SOR. You could add a very simple one for a panel if you like. Please take a look at tegra124's display driver for an example.
I don't think the driver model is a good fit here. Abstracting a display port isn't very useful in itself because users don't really care about the type of display, they only care about it being a display. So if you want to usefully abstract you'd do it at a higher level, such as display or screen. Then you have a generic object which users can use to put up a framebuffer onto a physical screen.
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
Thierry

+Nikita
Hi Thierry,
On 24 August 2015 at 04:12, Thierry Reding treding@nvidia.com wrote:
On Fri, Aug 21, 2015 at 06:37:37PM -0600, Simon Glass wrote: [...]
I have serious doubts about the wisdom of requiring a contributor to completely re-architect the existing display system in U-Boot. It's a big job. Perhaps we can settle for following along the same lines and not making things worse?
I didn't suggest re-architecting the display system in U-Boot. What I was suggesting was a way to architect Tegra-specific display driver code to make it reusable rather than duplicate display controller programming for each new generation, while the hardware has remained mostly the same.
OK, I misunderstood.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... }; struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Please don't add function points to structures on an ad-hoc basis. These should use driver model. There is a uclass for display port but not for LCD panels or SOR. You could add a very simple one for a panel if you like. Please take a look at tegra124's display driver for an example.
I don't think the driver model is a good fit here. Abstracting a display port isn't very useful in itself because users don't really care about the type of display, they only care about it being a display. So if you want to usefully abstract you'd do it at a higher level, such as display or screen. Then you have a generic object which users can use to put up a framebuffer onto a physical screen.
I think you are referring to the lcd/video interface. If so, this is already fairly well defined, but lcd and video should be merged, and a uclass could be added. Nikita Kiryanov has done quite a bit of work on the merging side.
But I still think there is value in a low-level abstraction too. Function pointers indicate that there is an interface that can be used by multiple drivers, and that is what driver model is for. See displayport.h for an attempt at this. We can of course consider expanding the display port uclass to encompass panels in general. I was reluctant to do that with a sample size of one. Here is the current interface:
/** * display_port_read_edid() - Read information from EDID * * @dev: Device to read from * @buf: Buffer to read into (should be EDID_SIZE bytes) * @buf_size: Buffer size (should be EDID_SIZE) * @return number of bytes read, <=0 for error */ int display_port_read_edid(struct udevice *dev, u8 *buf, int buf_size);
/** * display_port_enable() - Enable a display port device * * @dev: Device to enable * @panel_bpp: Number of bits per pixel for panel * @timing: Display timings * @return 0 if OK, -ve on error */ int display_port_enable(struct udevice *dev, int panel_bpp, const struct display_timing *timing);
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
But if it is a single implementation why do you need to add function pointers? It would just be a normal call in that case. I'm not suggesting we add uclasses with no generic use.
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
I am wondering if the problem here is just that I misunderstood your intent. How about:
- the display controller code (display.c) should be common across all Tegra SoCs - the code (which was merged 3 years ago) should move to use the new device tree bindings (as does tegra124 display support)
What am I missing?
Let's see what Marcel is able to do here.
Regards, Simon

On Mon, Aug 24, 2015 at 10:58:48AM -0600, Simon Glass wrote:
+Nikita
Hi Thierry,
On 24 August 2015 at 04:12, Thierry Reding treding@nvidia.com wrote:
On Fri, Aug 21, 2015 at 06:37:37PM -0600, Simon Glass wrote: [...]
I have serious doubts about the wisdom of requiring a contributor to completely re-architect the existing display system in U-Boot. It's a big job. Perhaps we can settle for following along the same lines and not making things worse?
I didn't suggest re-architecting the display system in U-Boot. What I was suggesting was a way to architect Tegra-specific display driver code to make it reusable rather than duplicate display controller programming for each new generation, while the hardware has remained mostly the same.
OK, I misunderstood.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... }; struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Please don't add function points to structures on an ad-hoc basis. These should use driver model. There is a uclass for display port but not for LCD panels or SOR. You could add a very simple one for a panel if you like. Please take a look at tegra124's display driver for an example.
I don't think the driver model is a good fit here. Abstracting a display port isn't very useful in itself because users don't really care about the type of display, they only care about it being a display. So if you want to usefully abstract you'd do it at a higher level, such as display or screen. Then you have a generic object which users can use to put up a framebuffer onto a physical screen.
I think you are referring to the lcd/video interface. If so, this is already fairly well defined, but lcd and video should be merged, and a uclass could be added. Nikita Kiryanov has done quite a bit of work on the merging side.
But I still think there is value in a low-level abstraction too. Function pointers indicate that there is an interface that can be used by multiple drivers, and that is what driver model is for. See displayport.h for an attempt at this. We can of course consider expanding the display port uclass to encompass panels in general. I was reluctant to do that with a sample size of one. Here is the current interface:
/**
- display_port_read_edid() - Read information from EDID
- @dev: Device to read from
- @buf: Buffer to read into (should be EDID_SIZE bytes)
- @buf_size: Buffer size (should be EDID_SIZE)
- @return number of bytes read, <=0 for error
*/ int display_port_read_edid(struct udevice *dev, u8 *buf, int buf_size);
/**
- display_port_enable() - Enable a display port device
- @dev: Device to enable
- @panel_bpp: Number of bits per pixel for panel
- @timing: Display timings
- @return 0 if OK, -ve on error
*/ int display_port_enable(struct udevice *dev, int panel_bpp, const struct display_timing *timing);
Both of these really aren't specific to DisplayPort. A DSI or HDMI input also wants to be enabled or have its EDID queried. Well, EDID may not be available on most DSI panels, so I think this particular abstraction should be slightly higher-level. What users are interested in isn't the EDID information, but the content therein. So I think a better way to return this type of information is by generating a list of modes (or a single one) given a display output device.
And once you have that abstraction it becomes useless to abstract the various types of outputs, because DisplayPort, LVDS, HDMI, DSI, etc. will all behave the same.
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
But if it is a single implementation why do you need to add function pointers? It would just be a normal call in that case. I'm not suggesting we add uclasses with no generic use.
The function pointers are there to allow the display driver to call into the different output drivers. Generally on Tegra what you do to scan out a framebuffer is roughly this:
1) setup display controller to drive a specified display mode 2) enable a window to scan out a given framebuffer 3) setup an output driver to take input from the display controller and push it over the wire
1) and 2) will be the same no matter what output you use. 3) is specific to the type of output, but can be done with the same software interface.
The function pointers help in implementing 3) using the same abstraction which I called tegra_output. A driver for HDMI would implement this in one way, while the driver for DSI would implement it in another. For SOR you would have yet another implementation. But the display driver itself would be able to treat them the same way.
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
I am wondering if the problem here is just that I misunderstood your intent. How about:
- the display controller code (display.c) should be common across all Tegra SoCs
- the code (which was merged 3 years ago) should move to use the new
device tree bindings (as does tegra124 display support)
What am I missing?
Sounds good to me. My suggestions were targetted at how to decouple some of the code to allow both the RGB (for the existing Tegra20 support) and SOR (for the existing Tegra124 support) outputs to be used, depending on the particular use-case.
And yes, this can all be driven from DT. The driver should be able to parse the "primary" output from DT using information that's available (such as which outputs are enabled) and some heuristics in case multiple outputs are enabled (DSI or RGB and HDMI for example). In all cases that I know of the internal panel (RGB, DSI, eDP) will be the primary one, so giving those priority over HDMI should always give you a sane default configuration.
Once you have the primary output you can query what mode it should drive (using static display mode information from an internal panel, or preferably EDID), allocate an appropriately sized framebuffer, set the mode and scan out that buffer.
Thierry

Hi Thierry,
On 25 August 2015 at 05:02, Thierry Reding treding@nvidia.com wrote:
On Mon, Aug 24, 2015 at 10:58:48AM -0600, Simon Glass wrote:
+Nikita
Hi Thierry,
On 24 August 2015 at 04:12, Thierry Reding treding@nvidia.com wrote:
On Fri, Aug 21, 2015 at 06:37:37PM -0600, Simon Glass wrote: [...]
I have serious doubts about the wisdom of requiring a contributor to completely re-architect the existing display system in U-Boot. It's a big job. Perhaps we can settle for following along the same lines and not making things worse?
I didn't suggest re-architecting the display system in U-Boot. What I was suggesting was a way to architect Tegra-specific display driver code to make it reusable rather than duplicate display controller programming for each new generation, while the hardware has remained mostly the same.
OK, I misunderstood.
Perhaps something as simple as:
struct tegra_dc { ... int (*enable)(struct tegra_dc *dc, const struct display_mode *mode); void (*disable)(struct tegra_dc *dc); ... }; struct tegra_output { ... struct tegra_dc *dc; ... int (*enable)(struct tegra_output *output, const struct display_mode *mode); void (*disable)(struct tegra_output *output); ... };
would work fine. That's roughly how drivers are implemented in the kernel. Setting up display on an output would be done by determining the mode (typically by parsing EDID if available, or using a hard-coded mode otherwise) and then calling:
output->dc = dc; dc->enable(dc, mode); output->enable(output, mode);
You might want to add in an abstraction for panels as well to make sure you have enough flexibility to enable and disable those, too. In that case you'd probably want to complement the above sequence with:
panel->enable(panel);
Please don't add function points to structures on an ad-hoc basis. These should use driver model. There is a uclass for display port but not for LCD panels or SOR. You could add a very simple one for a panel if you like. Please take a look at tegra124's display driver for an example.
I don't think the driver model is a good fit here. Abstracting a display port isn't very useful in itself because users don't really care about the type of display, they only care about it being a display. So if you want to usefully abstract you'd do it at a higher level, such as display or screen. Then you have a generic object which users can use to put up a framebuffer onto a physical screen.
I think you are referring to the lcd/video interface. If so, this is already fairly well defined, but lcd and video should be merged, and a uclass could be added. Nikita Kiryanov has done quite a bit of work on the merging side.
But I still think there is value in a low-level abstraction too. Function pointers indicate that there is an interface that can be used by multiple drivers, and that is what driver model is for. See displayport.h for an attempt at this. We can of course consider expanding the display port uclass to encompass panels in general. I was reluctant to do that with a sample size of one. Here is the current interface:
/**
- display_port_read_edid() - Read information from EDID
- @dev: Device to read from
- @buf: Buffer to read into (should be EDID_SIZE bytes)
- @buf_size: Buffer size (should be EDID_SIZE)
- @return number of bytes read, <=0 for error
*/ int display_port_read_edid(struct udevice *dev, u8 *buf, int buf_size);
/**
- display_port_enable() - Enable a display port device
- @dev: Device to enable
- @panel_bpp: Number of bits per pixel for panel
- @timing: Display timings
- @return 0 if OK, -ve on error
*/ int display_port_enable(struct udevice *dev, int panel_bpp, const struct display_timing *timing);
Both of these really aren't specific to DisplayPort. A DSI or HDMI input also wants to be enabled or have its EDID queried. Well, EDID may not be available on most DSI panels, so I think this particular abstraction should be slightly higher-level. What users are interested in isn't the EDID information, but the content therein. So I think a better way to return this type of information is by generating a list of modes (or a single one) given a display output device.
That sounds reasonable.
And once you have that abstraction it becomes useless to abstract the various types of outputs, because DisplayPort, LVDS, HDMI, DSI, etc. will all behave the same.
OK so once we have another user we should rename this to something like VIDEOPORT...
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
But if it is a single implementation why do you need to add function pointers? It would just be a normal call in that case. I'm not suggesting we add uclasses with no generic use.
The function pointers are there to allow the display driver to call into the different output drivers. Generally on Tegra what you do to scan out a framebuffer is roughly this:
1) setup display controller to drive a specified display mode 2) enable a window to scan out a given framebuffer 3) setup an output driver to take input from the display controller and push it over the wire
- and 2) will be the same no matter what output you use. 3) is specific
to the type of output, but can be done with the same software interface.
The function pointers help in implementing 3) using the same abstraction which I called tegra_output. A driver for HDMI would implement this in one way, while the driver for DSI would implement it in another. For SOR you would have yet another implementation. But the display driver itself would be able to treat them the same way.
OK then I think we should create a new video output uclass for this purpose. We then end up with a high-level 'interface' uclass (hdmi, displayport, etc.) and a low-level 'video transport' uclass.
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
I am wondering if the problem here is just that I misunderstood your intent. How about:
- the display controller code (display.c) should be common across all Tegra SoCs
- the code (which was merged 3 years ago) should move to use the new
device tree bindings (as does tegra124 display support)
What am I missing?
Sounds good to me. My suggestions were targetted at how to decouple some of the code to allow both the RGB (for the existing Tegra20 support) and SOR (for the existing Tegra124 support) outputs to be used, depending on the particular use-case.
And yes, this can all be driven from DT. The driver should be able to parse the "primary" output from DT using information that's available (such as which outputs are enabled) and some heuristics in case multiple outputs are enabled (DSI or RGB and HDMI for example). In all cases that I know of the internal panel (RGB, DSI, eDP) will be the primary one, so giving those priority over HDMI should always give you a sane default configuration.
Once you have the primary output you can query what mode it should drive (using static display mode information from an internal panel, or preferably EDID), allocate an appropriately sized framebuffer, set the mode and scan out that buffer.
OK, sounds good. I'm not yet sure who is planning to work on this and I would much prefer to do it with another SoC uses the same framework. It's normally a bad idea to design a general purpose framework with a sample size of 1!
Regards, Simon

On Tue, Aug 25, 2015 at 10:03:13AM -0600, Simon Glass wrote:
On 25 August 2015 at 05:02, Thierry Reding treding@nvidia.com wrote:
On Mon, Aug 24, 2015 at 10:58:48AM -0600, Simon Glass wrote:
On 24 August 2015 at 04:12, Thierry Reding treding@nvidia.com wrote:
[...]
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
But if it is a single implementation why do you need to add function pointers? It would just be a normal call in that case. I'm not suggesting we add uclasses with no generic use.
The function pointers are there to allow the display driver to call into the different output drivers. Generally on Tegra what you do to scan out a framebuffer is roughly this:
1) setup display controller to drive a specified display mode 2) enable a window to scan out a given framebuffer 3) setup an output driver to take input from the display controller and push it over the wire
- and 2) will be the same no matter what output you use. 3) is specific
to the type of output, but can be done with the same software interface.
The function pointers help in implementing 3) using the same abstraction which I called tegra_output. A driver for HDMI would implement this in one way, while the driver for DSI would implement it in another. For SOR you would have yet another implementation. But the display driver itself would be able to treat them the same way.
OK then I think we should create a new video output uclass for this purpose. We then end up with a high-level 'interface' uclass (hdmi, displayport, etc.) and a low-level 'video transport' uclass.
I don't understand. This is all internal to the display driver, why should it need to bother with uclasses?
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
Which should work for everything, except maybe DSI, where you may need some sort of inbetween step for panels that need additional setup using DCS commands or the like. But I suspect that's a bridge that can be crossed when we get to it.
That said, I don't forsee myself having any time to devote to this, but if anyone ends up spending work on this, feel free to Cc me on patches or ask if you have questions about the display hardware or the framework design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
I am wondering if the problem here is just that I misunderstood your intent. How about:
- the display controller code (display.c) should be common across all Tegra SoCs
- the code (which was merged 3 years ago) should move to use the new
device tree bindings (as does tegra124 display support)
What am I missing?
Sounds good to me. My suggestions were targetted at how to decouple some of the code to allow both the RGB (for the existing Tegra20 support) and SOR (for the existing Tegra124 support) outputs to be used, depending on the particular use-case.
And yes, this can all be driven from DT. The driver should be able to parse the "primary" output from DT using information that's available (such as which outputs are enabled) and some heuristics in case multiple outputs are enabled (DSI or RGB and HDMI for example). In all cases that I know of the internal panel (RGB, DSI, eDP) will be the primary one, so giving those priority over HDMI should always give you a sane default configuration.
Once you have the primary output you can query what mode it should drive (using static display mode information from an internal panel, or preferably EDID), allocate an appropriately sized framebuffer, set the mode and scan out that buffer.
OK, sounds good. I'm not yet sure who is planning to work on this and I would much prefer to do it with another SoC uses the same framework. It's normally a bad idea to design a general purpose framework with a sample size of 1!
Again, this is about adding infrastructure to the Tegra display driver to allow code reuse. Why would this need to be done in conjunction with other SoCs?
Thierry

Hi Thierry,
On 26 August 2015 at 00:29, Thierry Reding treding@nvidia.com wrote:
On Tue, Aug 25, 2015 at 10:03:13AM -0600, Simon Glass wrote:
On 25 August 2015 at 05:02, Thierry Reding treding@nvidia.com wrote:
On Mon, Aug 24, 2015 at 10:58:48AM -0600, Simon Glass wrote:
On 24 August 2015 at 04:12, Thierry Reding treding@nvidia.com wrote:
[...]
SOR is an even worse abstraction because it's completely Tegra-specific and other SoCs will have completely different ways of providing the same types of output. You'll end up with a uclass containing a single implementation.
But if it is a single implementation why do you need to add function pointers? It would just be a normal call in that case. I'm not suggesting we add uclasses with no generic use.
The function pointers are there to allow the display driver to call into the different output drivers. Generally on Tegra what you do to scan out a framebuffer is roughly this:
1) setup display controller to drive a specified display mode 2) enable a window to scan out a given framebuffer 3) setup an output driver to take input from the display controller and push it over the wire
- and 2) will be the same no matter what output you use. 3) is specific
to the type of output, but can be done with the same software interface.
The function pointers help in implementing 3) using the same abstraction which I called tegra_output. A driver for HDMI would implement this in one way, while the driver for DSI would implement it in another. For SOR you would have yet another implementation. But the display driver itself would be able to treat them the same way.
OK then I think we should create a new video output uclass for this purpose. We then end up with a high-level 'interface' uclass (hdmi, displayport, etc.) and a low-level 'video transport' uclass.
I don't understand. This is all internal to the display driver, why should it need to bother with uclasses?
One of the design goals of driver model is to expose these interfaces so that the structure of devices can be seen. It hopefully promotes code reuse and better software architecture since more thought goes into exactly where these interfaces should be drawn, and whether they can be shared across different drivers for the same subsystem.
Driver model was created to expose and standardise the various interfaces in U-Boot between generic code (or even arch-specific code) and the drivers it uses. This doesn't just apply at the top level - e.g. pinctrl is arguably something that could be dealt with internally by each driver, but we choose to make it its own first-class subsystem. For Ethernet we have a PHY library to promote code reuse.
I'm sure there are merits on each side but I think the default position should be that whenever an interface with function methods is added we should consider it a new uclass. This is particularly true when we have a device tree child since we want to main that tree structure in driver model so that nodes correspond to devices.
I'm sure there are exceptions where this does not make sense.
So, to reiterate, the above wasn't meant to be a generic abstraction for a U-Boot-wide display framework, but rather a suggestion on how the Tegra driver could internally be structured in order to avoid code duplication.
> Which should work for everything, except maybe DSI, where you may need > some sort of inbetween step for panels that need additional setup using > DCS commands or the like. But I suspect that's a bridge that can be > crossed when we get to it. > > That said, I don't forsee myself having any time to devote to this, but > if anyone ends up spending work on this, feel free to Cc me on patches > or ask if you have questions about the display hardware or the framework > design. I'm sure I can find the time to provide feedback.
In which case I suggest we limit the amount of rewrite we ask for in this case...
People asked for my opinion, so I shared. If you prefer code duplication over a properly architected driver that's of course your prerogative.
I am wondering if the problem here is just that I misunderstood your intent. How about:
- the display controller code (display.c) should be common across all Tegra SoCs
- the code (which was merged 3 years ago) should move to use the new
device tree bindings (as does tegra124 display support)
What am I missing?
Sounds good to me. My suggestions were targetted at how to decouple some of the code to allow both the RGB (for the existing Tegra20 support) and SOR (for the existing Tegra124 support) outputs to be used, depending on the particular use-case.
And yes, this can all be driven from DT. The driver should be able to parse the "primary" output from DT using information that's available (such as which outputs are enabled) and some heuristics in case multiple outputs are enabled (DSI or RGB and HDMI for example). In all cases that I know of the internal panel (RGB, DSI, eDP) will be the primary one, so giving those priority over HDMI should always give you a sane default configuration.
Once you have the primary output you can query what mode it should drive (using static display mode information from an internal panel, or preferably EDID), allocate an appropriately sized framebuffer, set the mode and scan out that buffer.
OK, sounds good. I'm not yet sure who is planning to work on this and I would much prefer to do it with another SoC uses the same framework. It's normally a bad idea to design a general purpose framework with a sample size of 1!
Again, this is about adding infrastructure to the Tegra display driver to allow code reuse. Why would this need to be done in conjunction with other SoCs?
It seems like the operations you are proposing would be the same on any SoC with this hardware.
Regards, Simon
participants (3)
-
Marcel Ziswiler
-
Simon Glass
-
Thierry Reding