mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: of_display_timings: Add simple-panel support
@ 2018-04-20 11:01 Stefan Riedmueller
  2018-05-02 10:49 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Riedmueller @ 2018-04-20 11:01 UTC (permalink / raw)
  To: barebox

Display timings can now be set with simple-panel method which selects
the required timings by the compatible of the simple panel devicetree
node.

This patch adds an option to set simple panel timings with the
of_display_timings command by setting the compatible of the display node.
The options -P and -c were implemented. The -P option requires the display
node path as argument and the -c option requires the compatible to set.

This has one downside. The available simple panel timings cannot be
listed since the timings are defined in the kernel. Account for this in the
help text.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
---
 commands/of_display_timings.c | 65 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 61 insertions(+), 4 deletions(-)

diff --git a/commands/of_display_timings.c b/commands/of_display_timings.c
index ccf2db0..ca8275f 100644
--- a/commands/of_display_timings.c
+++ b/commands/of_display_timings.c
@@ -28,6 +28,39 @@
 #include <linux/err.h>
 #include <string.h>
 
+struct panel_info {
+	char *displaypath;
+	char *compatible;
+};
+
+static int of_panel_timing(struct device_node *root, void *context)
+{
+	int ret = 0;
+	struct panel_info *panel = (struct panel_info*)context;
+	struct device_node *display;
+
+	display = of_find_node_by_path_from(root, panel->displaypath);
+	if (!display) {
+		pr_err("Path to display node is not vaild.\n");
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = of_set_property(display, "compatible",
+			      panel->compatible,
+			      strlen(panel->compatible) + 1, 1);
+
+	if (ret < 0) {
+		pr_err("Could not update compatible property\n");
+		goto out;
+	}
+
+	ret = of_device_enable(display);
+
+out:
+	return ret;
+}
+
 static int of_display_timing(struct device_node *root, void *timingpath)
 {
 	int ret = 0;
@@ -55,10 +88,12 @@ static int do_of_display_timings(int argc, char *argv[])
 	struct device_node *root = NULL;
 	struct device_node *display = NULL;
 	struct device_node *timings = NULL;
+	struct panel_info *panel = NULL;
 	char *timingpath = NULL;
 	char *dtbfile = NULL;
+	char *compatible = NULL;
 
-	while ((opt = getopt(argc, argv, "sS:lf:")) > 0) {
+	while ((opt = getopt(argc, argv, "sS:lf:c:P:")) > 0) {
 		switch (opt) {
 		case 'l':
 			list = 1;
@@ -69,10 +104,18 @@ static int do_of_display_timings(int argc, char *argv[])
 		case 's':
 			selected = 1;
 			break;
+		case 'c':
+			compatible = optarg;
+			break;
 		case 'S':
 			timingpath = xzalloc(strlen(optarg) + 1);
 			strcpy(timingpath, optarg);
 			break;
+		case 'P':
+			panel = xzalloc(sizeof(struct panel_info));
+			panel->displaypath = xzalloc(strlen(optarg) + 1);
+			strcpy(panel->displaypath, optarg);
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
@@ -140,6 +183,18 @@ static int do_of_display_timings(int argc, char *argv[])
 			printf("No selected display-timings found.\n");
 	}
 
+	if (panel) {
+		if (!compatible) {
+			pr_err("No compatible argument. -P option requires compatible with -c option\n");
+			return -EINVAL;
+		} else {
+			panel->compatible = xzalloc(strlen(compatible) + 1);
+			strcpy(panel->compatible, compatible);
+		}
+
+		of_register_fixup(of_panel_timing, panel);
+	}
+
 	if (timingpath)
 		of_register_fixup(of_display_timing, timingpath);
 
@@ -148,16 +203,18 @@ static int do_of_display_timings(int argc, char *argv[])
 
 BAREBOX_CMD_HELP_START(of_display_timings)
 BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT("-l",  "list path of all available display-timings\n")
-BAREBOX_CMD_HELP_OPT("-s",  "list path of all selected display-timings\n")
+BAREBOX_CMD_HELP_OPT("-l",  "list path of all available display-timings\n\t\tNOTE: simple-panel timings cannot be listed\n")
+BAREBOX_CMD_HELP_OPT("-s",  "list path of all selected display-timings\n\t\tNOTE: simple-panel timings cannot be listed\n")
+BAREBOX_CMD_HELP_OPT("-c",  "display compatible to enable with -P option. Has no effect on -S option\n")
 BAREBOX_CMD_HELP_OPT("-S path",  "select display-timings and register oftree fixup\n")
+BAREBOX_CMD_HELP_OPT("-P path",  "select simple-panel node and register oftree fixup with -c compatible\n")
 BAREBOX_CMD_HELP_OPT("-f dtb",  "work on dtb. Has no effect on -s option\n")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(of_display_timings)
 	.cmd	= do_of_display_timings,
 	BAREBOX_CMD_DESC("print and select display-timings")
-	BAREBOX_CMD_OPTS("[-ls] [-S path] [-f dtb]")
+	BAREBOX_CMD_OPTS("[-ls] [-S path] [-P path -c compatible] [-f dtb]")
 	BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 	BAREBOX_CMD_COMPLETE(devicetree_file_complete)
 	BAREBOX_CMD_HELP(cmd_of_display_timings_help)
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] commands: of_display_timings: Add simple-panel support
  2018-04-20 11:01 [PATCH] commands: of_display_timings: Add simple-panel support Stefan Riedmueller
@ 2018-05-02 10:49 ` Sascha Hauer
  2018-05-04 14:19   ` Stefan Riedmüller
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2018-05-02 10:49 UTC (permalink / raw)
  To: Stefan Riedmueller; +Cc: barebox

Hi Stefan,

On Fri, Apr 20, 2018 at 01:01:01PM +0200, Stefan Riedmueller wrote:
> Display timings can now be set with simple-panel method which selects
> the required timings by the compatible of the simple panel devicetree
> node.
> 
> This patch adds an option to set simple panel timings with the
> of_display_timings command by setting the compatible of the display node.
> The options -P and -c were implemented. The -P option requires the display
> node path as argument and the -c option requires the compatible to set.
> 
> This has one downside. The available simple panel timings cannot be
> listed since the timings are defined in the kernel. Account for this in the
> help text.
> 
> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
> ---
>  commands/of_display_timings.c | 65 ++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 61 insertions(+), 4 deletions(-)

This patch seems to be a way to manipulate a device tree property in the
Linux device tree. How about adding a new option to the of_property
command which would register a of_fixup instead of doing the operation
now?

Like this:

of_property -f -s /path/to/node compatible vendor,foo-display

> +		case 'c':
> +			compatible = optarg;
> +			break;
>  		case 'S':
>  			timingpath = xzalloc(strlen(optarg) + 1);
>  			strcpy(timingpath, optarg);

xstrdup() is what you want here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] commands: of_display_timings: Add simple-panel support
  2018-05-02 10:49 ` Sascha Hauer
@ 2018-05-04 14:19   ` Stefan Riedmüller
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Riedmüller @ 2018-05-04 14:19 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On 02.05.2018 12:49, Sascha Hauer wrote:
> Hi Stefan,
>
> On Fri, Apr 20, 2018 at 01:01:01PM +0200, Stefan Riedmueller wrote:
>> Display timings can now be set with simple-panel method which selects
>> the required timings by the compatible of the simple panel devicetree
>> node.
>>
>> This patch adds an option to set simple panel timings with the
>> of_display_timings command by setting the compatible of the display node.
>> The options -P and -c were implemented. The -P option requires the display
>> node path as argument and the -c option requires the compatible to set.
>>
>> This has one downside. The available simple panel timings cannot be
>> listed since the timings are defined in the kernel. Account for this in the
>> help text.
>>
>> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
>> ---
>>   commands/of_display_timings.c | 65 ++++++++++++++++++++++++++++++++++++++++---
>>   1 file changed, 61 insertions(+), 4 deletions(-)
> This patch seems to be a way to manipulate a device tree property in the
> Linux device tree. How about adding a new option to the of_property
> command which would register a of_fixup instead of doing the operation
> now?
>
> Like this:
>
> of_property -f -s /path/to/node compatible vendor,foo-display

Thats a good idea. My intention was to put it in of_display_timings 
because it is display timing related but I see the advantage of having a 
more generic solution for this. So I put it on my todo and try to send a 
patch soon.

Thanks
Stefan

>
>> +		case 'c':
>> +			compatible = optarg;
>> +			break;
>>   		case 'S':
>>   			timingpath = xzalloc(strlen(optarg) + 1);
>>   			strcpy(timingpath, optarg);
> xstrdup() is what you want here.
>
> Sascha
>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-04 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 11:01 [PATCH] commands: of_display_timings: Add simple-panel support Stefan Riedmueller
2018-05-02 10:49 ` Sascha Hauer
2018-05-04 14:19   ` Stefan Riedmüller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox