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

fb: cfb: Support color display #58817

Closed

Conversation

soburi
Copy link
Member

@soburi soburi commented Jun 4, 2023

Add color display support for CFB.

The concept of "Invert" depended on monochrome displays.
I reimplemented it with foreground color and background color concepts that are newly introduced with color support.

The CFB is no longer a "(Monochrome) Character Frame Buffer" but
the concept and usage of the API remain the same.
Since I would like to maintain the CFB abbreviation, I am considering renaming it "Compact Frame Buffer."


This PR is part of a series of CFB enhancements (third of four #72177).
I would appreciate it if you could check the #67881 part first.

@soburi soburi force-pushed the cfb_transfer_to_color_display branch 2 times, most recently from 05cdc53 to e30ac83 Compare June 5, 2023 05:04
@soburi soburi changed the title Cfb transfer to color display cfb: Adding limited color LCD support using transfer buffers Jun 5, 2023
@soburi soburi marked this pull request as ready for review June 5, 2023 08:24
@cfriedt
Copy link
Member

cfriedt commented Aug 3, 2023

dev-review: ping @jfischer-no

@MaureenHelm
Copy link
Member

@jfischer-no @danieldegrasse will you please take a look?

Copy link
Collaborator

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

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

Just some initial comments- but I am still confused about the goal of this rework. First off, the subsystem itself is called Monochrome Character Framebuffer. The subsystem is explicitly:

  • monochrome
  • intended for font rendering

If we are going to extend CFB to be what I would consider a small graphics framework, I would like to see the following:

  • Documentation updates- the current CFB naming is confusing
  • Additional tests or samples demonstrating usage of this framework, so we can verify rendering functions work as expected

Additionally, I am slightly confused about where a graphics framework would fit versus LVGL. Is the intention of this framework to fit where LVGL can't?

@jfischer-no ping- I'll defer to you on any of these comments, I just want to make sure that if we are extending CFB we keep documentation and samples up to date.

subsys/fb/cfb.c Outdated
desc.pitch = fb->x_res;
if ((fb->pixel_format == PIXEL_FORMAT_MONO01 || fb->pixel_format == PIXEL_FORMAT_MONO10) &&
(fb->screen_info & SCREEN_INFO_MONO_VTILED)) {
/* A VTILED format display usually does not support partial region transfers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the code enforcing this restriction? Wouldn't a user know their display, and if it did not support partial region transfers simply call cfb_framebuffer_finalize instead?

* @param a The alpha channel of the foreground color
*
*/
void cfb_framebuffer_set_foreground_color(const struct device *dev, uint8_t r, uint8_t g, uint8_t b,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think we can go with this never ending identifiers, so please use common abbreviation and find shorter names, e.g. cfb_set_fg_color(). And there is no reason to have additional framebuffer to cfb.

@@ -31,6 +31,26 @@ config CHARACTER_FRAMEBUFFER_SHELL_DRIVER_NAME
help
Character Framebuffer Display Driver Name

config CHARACTER_FRAMEBUFFER_TRANSFER_WITH_PIXEL_FORMAT_CONVERSION
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please just CFB_TRANSFER_..., for that you will need to change the three option above to CFB_USE_DEFAULT_FONTS, CFB_SHELL, CFB_SHELL_DRIVER_NAME (this one looks outdated, not sure it is still used).

subsys/fb/cfb.c Outdated
return api->write(dev, 0, 0, &desc, fb->buf);
}

#ifdef CONFIG_CHARACTER_FRAMEBUFFER_TRANSFER_WITH_PIXEL_FORMAT_CONVERSION
Copy link
Collaborator

Choose a reason for hiding this comment

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

if(ENABLED(CFB_TRANSFER_WITH_PIXEL_FORMAT_CONVERSION)) {
	cfb_transfer_with_pixel_conversion(..);
}

I do not understand why this code should not always be built, and why it cannot be broken into smaller chunks. As it is now, it is difficult to understand and review.

@MaureenHelm
Copy link
Member

@soburi do you plan to return to this PR?

@soburi
Copy link
Member Author

soburi commented Sep 28, 2023

@soburi do you plan to return to this PR?

I'm in bit busy state. I'll late to update it.

@soburi soburi marked this pull request as draft October 30, 2023 04:18
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Dec 30, 2023
@soburi soburi force-pushed the cfb_transfer_to_color_display branch from e30ac83 to 9b78a29 Compare January 10, 2024 15:23
@github-actions github-actions bot removed the Stale label Jan 11, 2024
@soburi soburi force-pushed the cfb_transfer_to_color_display branch from 9b78a29 to 7b8e69b Compare January 13, 2024 11:20
@soburi soburi force-pushed the cfb_transfer_to_color_display branch from 7b8e69b to 453afc5 Compare January 28, 2024 15:02
@soburi soburi added the DNM This PR should not be merged (Do Not Merge) label Jan 28, 2024
@soburi soburi force-pushed the cfb_transfer_to_color_display branch 3 times, most recently from d0e1ec7 to de85a26 Compare January 28, 2024 22:31
@soburi soburi removed the DNM This PR should not be merged (Do Not Merge) label May 2, 2024
@soburi soburi force-pushed the cfb_transfer_to_color_display branch from 0d08faf to 10b6d1c Compare May 5, 2024 15:32
cfriedt
cfriedt previously approved these changes Jun 1, 2024
@danieldegrasse
Copy link
Collaborator

@jfischer-no can you revisit comments on this PR?

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

some comments re: docs / migration guide

Comment on lines +286 to +878
Therefore, use :c:func:`cfb_display_init` instead of deprecated cfb_framebuffer_init.
cfb_framebuffer_init has been deprecated.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Therefore, use :c:func:`cfb_display_init` instead of deprecated cfb_framebuffer_init.
cfb_framebuffer_init has been deprecated.
Therefore, use :c:func:`cfb_display_init` instead of deprecated ``cfb_framebuffer_init``.
``cfb_framebuffer_init`` has been deprecated.


config CHARACTER_FRAMEBUFFER_USE_DEFAULT_FONTS
config CFB_USE_DEFAULT_FONTS
Copy link
Collaborator

Choose a reason for hiding this comment

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

renamed kconfigs need to be detailed in the migration guide

cfb_print(fb, "Hello!", 0, 0);


Also, please see the sample in ``samples/display/cfb``.
Copy link
Collaborator

Choose a reason for hiding this comment

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

path is wrong, and you may use :zephyr:code-sample: anyway

Suggested change
Also, please see the sample in ``samples/display/cfb``.
Also, please see the :zephyr:code-sample:`cfb-sample`.

* :c:func:`cfb_finalize` (renamed from `cfb_framebuffer_finalize`)
* :c:func:`cfb_set_font` (renamed from `cfb_framebuffer_finalize`)

:c:func:`cfb_display_alloc` can use to migrate from `cfb_framebuffer_init`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

not clear what this means?

Copy link
Collaborator

Choose a reason for hiding this comment

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

would be nice to have release note entry as well, but this can come later too.

soburi added 16 commits July 2, 2024 19:42
The logic introduced in zephyrproject-rtos#67881 can also handle fonts with heights
other than integer multiple of 8. I remove the restriction.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add test cases for 1x1 and 11x13 fonts.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Change the arguments of `cfb_invert_area`, `cfb_print`, and
`cfb_draw_(point|line|rect)`, which used unsigned integers to specify
coordinates to signed integers.

This is because coordinate calculations are usually based on real
numbers, so it is difficult to use unless negative numbers are
accepted.
We clip drawings outside the drawable area on the implementation side.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
`cfb_get_font_size` and `cfb_get_numof_fonts` take a
`const struct driver *` as a first argument, but not use it.

Remove the argument and clean up related sources.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
There are three major changes.

- Introducing `struct cfb_display`
- Changed the argument `struct device *` to `struct cfb_framebuffer *`
- Rename APIs starting with `cfb_framebuffer_*`

Introduces struct cfb_display as a data structure to represent the display.
As a result, it is now possible to create multiple pieces of data managed
using a single static variable in previous implementations,
making it possible to handle multiple displays.
The old `struct cfb_framebuffer` remains but is now part of the
`struct cfb_display` data structure.
You can get cfb_framebuffer from cfb_display using the added API
`cfb_display_get_framebuffer`.

All places where a `struct device *` argument was passed to specify the
target will be replaced with a `struct cfb_framebuffer *`.
In line with this, API names starting with `cfb_framebuffer_*`,
which were redundant and inconsistent names, will remove
`_framebuffer` and change to `cfb_*` .

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add `display select` command to select display.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add a note about the changes of CFB(Character framebuffer) APIs.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
The pixel per tile value can be calculated from pixel_format,
so delete the ppt field.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
If a character that does not exist in the font was specified,
it was replaced with a space character, but it will now draw with 0 data.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Added support for color displays.

Along with color support, we are introducing the concept of foreground
and background colors. Drawing fonts and lines is done with the
foreground color, and clear operation fills with the background color.
With the introduction of drawing colors, we have removed the process of
inverting data before transfer if the inverted flag was enabled
during finalizing.
Replacing the "Invert" operation by swapping the foreground and
background colors.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
I have removed the process to set the display format to monochrome.
Also, I added board settings conf files for native_sim and native_sim_64
to change the initial value of the SDL display driver's pixel format.
CFB operates according to the pixel format set here.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Added a test to check the display on a color display.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add the `fgcolor` `bgcolor` and `display pixel_format`  to
support color display

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
CHARACTER_FRAMEBUFFER_SHELL_DRIVER_NAME is not used.
Remove it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
CFB was an abbreviation for Character Framebuffer.
However, it currently supports characters and graphic drawing,
so it has become far from actual.

However, since there are only a few API changes, I don't want to
change symbol names, etc.
Therefore, we will keep the abbreviation CFB and change the name
to `Compact Framebuffer`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Update README to update to current specs.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the cfb_transfer_to_color_display branch from 10b6d1c to ca6abc6 Compare July 2, 2024 10:46
@soburi soburi marked this pull request as draft July 2, 2024 10:46
Copy link

github-actions bot commented Sep 1, 2024

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Sep 1, 2024
@github-actions github-actions bot closed this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants