Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: mipi-dbi: use string for mipi-mode property #81293

Merged

Conversation

danieldegrasse
Copy link
Collaborator

Use a string for the mipi-mode property over an integer value, as this
significantly improves the readability of the MIPI DBI device binding.

Open to feedback as to whether we feel this improvement is work breaking downstream user devicetrees. Personally I think it is ok given the transition note in the migration guide, but I'm not strongly committed to this change.

jfischer-no
jfischer-no previously approved these changes Nov 13, 2024
Copy link
Collaborator

@jfischer-no jfischer-no left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, API is considered experimental

@erwango
Copy link
Member

erwango commented Nov 13, 2024

Mostly a complain about usage of strings in bindings:
I won't block but I wonder if spreading use of strings is going in the right direction. I know this is used in other places and this is peanuts in the binary size of an application running display. However, if this starts to be generalized in all bindings, this will start to be visible in binaries of small applications around few 10Ks (eg sensors).
This is specially a shame as we're "bloating" binaries for bindings readability (so, not even a functional reason), while historically we've always tried to find footprint friendly solutions, even for complex functional issues.

@JarmouniA
Copy link
Collaborator

This is specially a shame as we're "bloating" binaries for bindings readability (so, not even a functional reason), while historically we've always tried to find footprint friendly solutions, even for complex functional issues.

@erwango unless I'm mistaken, this is not going to increase binary size as DT_INST_STRING_UPPER_TOKEN(inst, mipi_mode) is still going to be resolved to an integer value (as defined in https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/dt-bindings/mipi_dbi/mipi_dbi.h) during preprocessing.

@danieldegrasse
Copy link
Collaborator Author

This is specially a shame as we're "bloating" binaries for bindings readability (so, not even a functional reason), while historically we've always tried to find footprint friendly solutions, even for complex functional issues.

@erwango unless I'm mistaken, this is not going to increase binary size as DT_INST_STRING_UPPER_TOKEN(inst, mipi_mode) is still going to be resolved to an integer value (as defined in https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/dt-bindings/mipi_dbi/mipi_dbi.h) during preprocessing.

Yeah, this is my understanding as well. We are expanding these strings to a C token, which the preprocessor will then handle.

Copy link
Collaborator

@faxe1008 faxe1008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I kinda get the point regarding the readbility, but imo adding a comment after each enum value would make the binding also more terse.
Additionally it kinda adds some macrobatics where the end result in a dt overlay is using a " instead of <. If the stringified version was more compact I guess there would be more to gain from this change.

But yeah neither nacking or approving, just wanted to give my two cents as I had this suggestion on one of my PRs earlier as well :^)

@danieldegrasse
Copy link
Collaborator Author

Hmm I kinda get the point regarding the readbility, but imo adding a comment after each enum value would make the binding also more terse. Additionally it kinda adds some macrobatics where the end result in a dt overlay is using a " instead of <. If the stringified version was more compact I guess there would be more to gain from this change.

But yeah neither nacking or approving, just wanted to give my two cents as I had this suggestion on one of my PRs earlier as well :^)

Yeah, I guess the advantage is that the string enum is a bit more restrictive- IE it is not possible to ignore the recommendation of "please use the MIPI DBI header to get the integer value". The output devicetree generated by the build system will also be more readable.

@erwango
Copy link
Member

erwango commented Nov 14, 2024

@erwango unless I'm mistaken, this is not going to increase binary size as DT_INST_STRING_UPPER_TOKEN(inst, mipi_mode) is still going to be resolved to an integer value (as defined in https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/dt-bindings/mipi_dbi/mipi_dbi.h) during preprocessing.

:), perfect then!

kartben
kartben previously approved these changes Nov 18, 2024
wmrsouza
wmrsouza previously approved these changes Nov 18, 2024
Use a string for the mipi-mode property over an integer value, as this
significantly improves the readability of the MIPI DBI device binding.

Signed-off-by: Daniel DeGrasse <[email protected]>
Document change to mipi-dbi device binding, and provide users with
example of how to transition to the new mipi-mode property.

Signed-off-by: Daniel DeGrasse <[email protected]>
@danieldegrasse
Copy link
Collaborator Author

Rebased to pick up CI fixes

@kartben kartben merged commit 3d6dde4 into zephyrproject-rtos:main Nov 23, 2024
37 checks passed
@danieldegrasse danieldegrasse deleted the feature/mipi-dbi-mode-cleanup branch November 23, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree area: Display Controller area: Display area: Shields Shields (add-on boards) platform: ADI Analog Devices, Inc. platform: ESP32 Espressif ESP32 platform: STM32 ST Micro STM32 Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants