diff mbox series

[1/1] package/panel-mipi-dbi-firmware: new package

Message ID 20250123144032.1429434-1-fiona.klute@gmx.de
State Accepted
Delegated to: Julien Olivain
Headers show
Series [1/1] package/panel-mipi-dbi-firmware: new package | expand

Commit Message

Fiona Klute Jan. 23, 2025, 2:40 p.m. UTC
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>

This package supports building and installing initialization command
firmware files for use with the panel-mipi-dbi DRM driver. To use the
package, initialization commands for the specific display(s) must be
provided in text form.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/tiny/Kconfig?id=7004a2e46d1693848370809aa3d9c340a209edbb#n70
https://github.com/notro/panel-mipi-dbi/wiki

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 package/panel-mipi-dbi-firmware/Config.in     | 29 +++++++++++++++
 .../panel-mipi-dbi-firmware.hash              |  3 ++
 .../panel-mipi-dbi-firmware.mk                | 35 +++++++++++++++++++
 5 files changed, 69 insertions(+)
 create mode 100644 package/panel-mipi-dbi-firmware/Config.in
 create mode 100644 package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.hash
 create mode 100644 package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk

Comments

Julien Olivain Jan. 24, 2025, 8:05 p.m. UTC | #1
Hi Fiona,

Thanks for the patch!

On 23/01/2025 15:40, Fiona Klute via buildroot wrote:
[...]
> diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk 
> b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
> new file mode 100644
> index 0000000000..c3a9fa7afc
> --- /dev/null
> +++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
> @@ -0,0 +1,35 @@
> +################################################################################
> +#
> +# panel-mipi-dbi-firmware
> +#
> +################################################################################
> +
> +PANEL_MIPI_DBI_FIRMWARE_VERSION = 
> 1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e
> +PANEL_MIPI_DBI_FIRMWARE_SITE = 
> https://github.com/notro/panel-mipi-dbi.git
> +PANEL_MIPI_DBI_FIRMWARE_SITE_METHOD = git
> +PANEL_MIPI_DBI_FIRMWARE_LICENSE = CC0-1.0
> +# license info is directly in the only source file
> +PANEL_MIPI_DBI_FIRMWARE_LICENSE_FILES = mipi-dbi-cmd
> +
> +PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = host-python3

The script mipi-dbi-cmd does not seem to depend on extra host python
modules. See:
https://github.com/notro/panel-mipi-dbi/blob/main/mipi-dbi-cmd#L15

Do you think we could use BR2_PYTHON3_HOST_DEPENDENCY instead? See:
https://gitlab.com/buildroot.org/buildroot/-/commit/b98062f7301bc72d2a59cca733f36525405d3bb9

This could save the time of the host-python compilation, in some 
situation.

What do you think?

Best regards,

Julien.
Fiona Klute Jan. 24, 2025, 9:03 p.m. UTC | #2
Hi Julien!

Am 24.01.25 um 21:05 schrieb Julien Olivain:
> Hi Fiona,
>
> Thanks for the patch!
>
> On 23/01/2025 15:40, Fiona Klute via buildroot wrote:
> [...]
>> diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-
>> firmware.mk b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
>> new file mode 100644
>> index 0000000000..c3a9fa7afc
>> --- /dev/null
>> +++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
>> @@ -0,0 +1,35 @@
>> +################################################################################
>> +#
>> +# panel-mipi-dbi-firmware
>> +#
>> +################################################################################
>> +
>> +PANEL_MIPI_DBI_FIRMWARE_VERSION =
>> 1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e
>> +PANEL_MIPI_DBI_FIRMWARE_SITE = https://github.com/notro/panel-mipi-
>> dbi.git
>> +PANEL_MIPI_DBI_FIRMWARE_SITE_METHOD = git
>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE = CC0-1.0
>> +# license info is directly in the only source file
>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE_FILES = mipi-dbi-cmd
>> +
>> +PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = host-python3
>
> The script mipi-dbi-cmd does not seem to depend on extra host python
> modules. See:
> https://github.com/notro/panel-mipi-dbi/blob/main/mipi-dbi-cmd#L15
>
> Do you think we could use BR2_PYTHON3_HOST_DEPENDENCY instead? See:
> https://gitlab.com/buildroot.org/buildroot/-/commit/
> b98062f7301bc72d2a59cca733f36525405d3bb9
>
> This could save the time of the host-python compilation, in some situation.
>
> What do you think?
In principle that should work, but as far as I can see I'd have to add
some logic to search the Python interpreter in that case:
$(HOST_DIR)/bin/python, python3, or python?

I suppose the elegant solution would be to store the detected
interpreter in a make variable from
support/dependencies/check-host-python3.mk, and the host-python3 one
otherwise. I can add a patch to do that, but the naming scheme varies
between the other check-host-* files. Would PYTHON3 be acceptable, or
should I use BR2_PYTHON3? Something else?

Or would it be acceptable to just use "python3" and break in the (likely
rare) case someone only has "python"? I don't really like that option.

Best regards,
Fiona
Julien Olivain Jan. 25, 2025, 11:49 a.m. UTC | #3
Hi Fiona,

On 24/01/2025 22:03, Fiona Klute wrote:
> Hi Julien!
> 
> Am 24.01.25 um 21:05 schrieb Julien Olivain:
>> Hi Fiona,
>> 
>> Thanks for the patch!
>> 
>> On 23/01/2025 15:40, Fiona Klute via buildroot wrote:
>> [...]
>>> diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-
>>> firmware.mk 
>>> b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
>>> new file mode 100644
>>> index 0000000000..c3a9fa7afc
>>> --- /dev/null
>>> +++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
>>> @@ -0,0 +1,35 @@
>>> +################################################################################
>>> +#
>>> +# panel-mipi-dbi-firmware
>>> +#
>>> +################################################################################
>>> +
>>> +PANEL_MIPI_DBI_FIRMWARE_VERSION =
>>> 1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e
>>> +PANEL_MIPI_DBI_FIRMWARE_SITE = https://github.com/notro/panel-mipi-
>>> dbi.git
>>> +PANEL_MIPI_DBI_FIRMWARE_SITE_METHOD = git
>>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE = CC0-1.0
>>> +# license info is directly in the only source file
>>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE_FILES = mipi-dbi-cmd
>>> +
>>> +PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = host-python3
>> 
>> The script mipi-dbi-cmd does not seem to depend on extra host python
>> modules. See:
>> https://github.com/notro/panel-mipi-dbi/blob/main/mipi-dbi-cmd#L15
>> 
>> Do you think we could use BR2_PYTHON3_HOST_DEPENDENCY instead? See:
>> https://gitlab.com/buildroot.org/buildroot/-/commit/
>> b98062f7301bc72d2a59cca733f36525405d3bb9
>> 
>> This could save the time of the host-python compilation, in some 
>> situation.
>> 
>> What do you think?
> In principle that should work, but as far as I can see I'd have to add
> some logic to search the Python interpreter in that case:
> $(HOST_DIR)/bin/python, python3, or python?
> 
> I suppose the elegant solution would be to store the detected
> interpreter in a make variable from
> support/dependencies/check-host-python3.mk, and the host-python3 one
> otherwise. I can add a patch to do that, but the naming scheme varies
> between the other check-host-* files. Would PYTHON3 be acceptable, or
> should I use BR2_PYTHON3? Something else?
> 
> Or would it be acceptable to just use "python3" and break in the 
> (likely
> rare) case someone only has "python"? I don't really like that option.

My understanding of PEP 394:
https://peps.python.org/pep-0394/
is that a system with the "python" binary alone could only be a old
Python 2 interpreter (which would not be sufficient and would build
a host-python3).

Then, the "mipi-dbi-cmd" script is executable and correctly starts
with "#!/usr/bin/env python3", which needs a "python3" binary in
the PATH.

So I believe it would work to have:

PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = $(BR2_PYTHON3_HOST_DEPENDENCY)

Then calling the script with:

PATH=$(BR_PATH) $(@D)/mipi-dbi-cmd ...

Anyways, this point is an optimization detail, so I'll apply the
patch as is and let decide if it is worth improving that in a
follow up patch.

> Best regards,
> Fiona

Best regards,

Julien.
Fiona Klute Jan. 25, 2025, 10:45 p.m. UTC | #4
Am 25.01.25 um 12:49 schrieb Julien Olivain:
> Hi Fiona,
>
> On 24/01/2025 22:03, Fiona Klute wrote:
>> Hi Julien!
>>
>> Am 24.01.25 um 21:05 schrieb Julien Olivain:
>>> Hi Fiona,
>>>
>>> Thanks for the patch!
>>>
>>> On 23/01/2025 15:40, Fiona Klute via buildroot wrote:
>>> [...]
>>>> diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-
>>>> firmware.mk b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-
>>>> firmware.mk
>>>> new file mode 100644
>>>> index 0000000000..c3a9fa7afc
>>>> --- /dev/null
>>>> +++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
>>>> @@ -0,0 +1,35 @@
>>>> +################################################################################
>>>> +#
>>>> +# panel-mipi-dbi-firmware
>>>> +#
>>>> +################################################################################
>>>> +
>>>> +PANEL_MIPI_DBI_FIRMWARE_VERSION =
>>>> 1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e
>>>> +PANEL_MIPI_DBI_FIRMWARE_SITE = https://github.com/notro/panel-mipi-
>>>> dbi.git
>>>> +PANEL_MIPI_DBI_FIRMWARE_SITE_METHOD = git
>>>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE = CC0-1.0
>>>> +# license info is directly in the only source file
>>>> +PANEL_MIPI_DBI_FIRMWARE_LICENSE_FILES = mipi-dbi-cmd
>>>> +
>>>> +PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = host-python3
>>>
>>> The script mipi-dbi-cmd does not seem to depend on extra host python
>>> modules. See:
>>> https://github.com/notro/panel-mipi-dbi/blob/main/mipi-dbi-cmd#L15
>>>
>>> Do you think we could use BR2_PYTHON3_HOST_DEPENDENCY instead? See:
>>> https://gitlab.com/buildroot.org/buildroot/-/commit/
>>> b98062f7301bc72d2a59cca733f36525405d3bb9
>>>
>>> This could save the time of the host-python compilation, in some
>>> situation.
>>>
>>> What do you think?
>> In principle that should work, but as far as I can see I'd have to add
>> some logic to search the Python interpreter in that case:
>> $(HOST_DIR)/bin/python, python3, or python?
>>
>> I suppose the elegant solution would be to store the detected
>> interpreter in a make variable from
>> support/dependencies/check-host-python3.mk, and the host-python3 one
>> otherwise. I can add a patch to do that, but the naming scheme varies
>> between the other check-host-* files. Would PYTHON3 be acceptable, or
>> should I use BR2_PYTHON3? Something else?
>>
>> Or would it be acceptable to just use "python3" and break in the (likely
>> rare) case someone only has "python"? I don't really like that option.
>
> My understanding of PEP 394:
> https://peps.python.org/pep-0394/
> is that a system with the "python" binary alone could only be a old
> Python 2 interpreter (which would not be sufficient and would build
> a host-python3).
Thanks, I wasn't aware that's an actual standard, not just common
practice. In that case it's indeed simple, I've just sent the patch. :-)

Best regards,
Fiona
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index dbb028998a..c0ab17c5ba 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1091,6 +1091,7 @@  F:	package/python-pymodbus/
 
 N:	Fiona Klute <fiona.klute@gmx.de>
 F:	package/*/S*
+F:	package/panel-mipi-dbi-firmware/
 F:	package/python-aiomqtt/
 F:	package/python-dunamai/
 F:	package/python-poetry-dynamic-versioning/
diff --git a/package/Config.in b/package/Config.in
index 400183516e..3f4dd42cbe 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -449,6 +449,7 @@  menu "Firmware"
 	source "package/linux-firmware/Config.in"
 	source "package/murata-cyw-fw/Config.in"
 	source "package/odroidc2-firmware/Config.in"
+	source "package/panel-mipi-dbi-firmware/Config.in"
 	source "package/qcom-db410c-firmware/Config.in"
 	source "package/qoriq-fm-ucode/Config.in"
 	source "package/rcw-smarc-sal28/Config.in"
diff --git a/package/panel-mipi-dbi-firmware/Config.in b/package/panel-mipi-dbi-firmware/Config.in
new file mode 100644
index 0000000000..08ed51f594
--- /dev/null
+++ b/package/panel-mipi-dbi-firmware/Config.in
@@ -0,0 +1,29 @@ 
+config BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE
+	bool "panel-mipi-dbi firmware"
+	help
+	  Build and install firmware files for the panel-mipi-dbi DRM
+	  driver. The driver requires firmware file(s) to provide
+	  initialization commands for the specific display(s) in
+	  use. The initialization commands are written in text form
+	  and converted to the binary format during the build.
+
+	  If you select this package you will be prompted for the
+	  initialization command file(s) to build firmware from.
+
+	  https://github.com/notro/panel-mipi-dbi
+
+if BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE
+
+config BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_SOURCE
+	string "Source files for panel-mipi-dbi firmware"
+	default ""
+	help
+	  Space separated list of initialization command files for
+	  displays used with the panel-mipi-dbi driver. The files will
+	  be converted to binary format and installed to /lib/firmware
+	  in the rootfs. The binary files will use the basenames of
+	  the input files, plus a .bin ending. The basename of each
+	  file must match the first element of the "compatible" device
+	  tree property of the display the file is for.
+
+endif # BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE
diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.hash b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.hash
new file mode 100644
index 0000000000..cb06ae66ee
--- /dev/null
+++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.hash
@@ -0,0 +1,3 @@ 
+# Locally computed
+sha256  6d57b140dca0241079b186027e72a9168843bd1b6427536dcd422b7a9b6dc53f  panel-mipi-dbi-firmware-1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e-git4.tar.gz
+sha256  e3f98ddc0b15dae65c5661d6c8403a007f30e2f04bcb6170526da609e3fcfd05  mipi-dbi-cmd
diff --git a/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
new file mode 100644
index 0000000000..c3a9fa7afc
--- /dev/null
+++ b/package/panel-mipi-dbi-firmware/panel-mipi-dbi-firmware.mk
@@ -0,0 +1,35 @@ 
+################################################################################
+#
+# panel-mipi-dbi-firmware
+#
+################################################################################
+
+PANEL_MIPI_DBI_FIRMWARE_VERSION = 1cbd40135a8c7f25d7b444a7fac77fd3c3ad471e
+PANEL_MIPI_DBI_FIRMWARE_SITE = https://github.com/notro/panel-mipi-dbi.git
+PANEL_MIPI_DBI_FIRMWARE_SITE_METHOD = git
+PANEL_MIPI_DBI_FIRMWARE_LICENSE = CC0-1.0
+# license info is directly in the only source file
+PANEL_MIPI_DBI_FIRMWARE_LICENSE_FILES = mipi-dbi-cmd
+
+PANEL_MIPI_DBI_FIRMWARE_DEPENDENCIES = host-python3
+
+BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_BIN = $(addsuffix .bin,$(basename $(notdir $(shell echo $(BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_SOURCE)))))
+
+define PANEL_MIPI_DBI_FIRMWARE_BUILD_CMDS
+	for source in $(shell echo $(BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_SOURCE)) ; do \
+		$(HOST_DIR)/bin/python $(@D)/mipi-dbi-cmd "$(@D)/$$(basename $${source%.*}).bin" "$${source}" ; \
+	done
+endef
+
+define PANEL_MIPI_DBI_FIRMWARE_INSTALL_TARGET_CMDS
+	for bin in $(shell echo $(BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_BIN)); do \
+		$(INSTALL) -m 0644 -D "$(@D)/$${bin}" "$(TARGET_DIR)/lib/firmware/$${bin}" ; \
+	done
+endef
+
+# installing firmware requires source, give a clear error message if missing
+ifeq ($(BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE)$(call qstrip,$(BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_SOURCE)),y)
+$(error No panel-mipi-dbi firmware source selected, check your BR2_PACKAGE_PANEL_MIPI_DBI_FIRMWARE_SOURCE setting)
+endif
+
+$(eval $(generic-package))