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

Split into application and library #3

Merged
merged 21 commits into from
Aug 8, 2024
Merged

Split into application and library #3

merged 21 commits into from
Aug 8, 2024

Conversation

bith3ad
Copy link
Contributor

@bith3ad bith3ad commented Aug 1, 2024

Hi,

this splits the single application into an application and library. It is based on the leica patch but is more traceable and don't expose internals to the library users instead a cookie solution is implemented.

Qingwu-Li and others added 7 commits August 1, 2024 17:40
Remove the autotools configure.ac and cleanup the .gitignore file.

While on it update the README.rst to include the required compile steps
and provide a version bump.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
The warning was detected with GCC 14.1.1

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Limit the scope to the current file.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Move struct modeset_dev declaration to the file top to make it easier to
find it. This aligns the code more to the kernel coding style.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Introduce struct platsch_ctx to bundle the required state. At the moment
it is just an container for the modeset_dev list but it will be extended in
the upcoming commits.

This commit also drops the usage of the gloabl modeset_list variable
usage.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Save the drmfd file descriptor within the platsch_ctx and make use of
it.

This prepares the code base for the upcoming application/library split.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Store the dir path and base name within the platsch_ctx. The strdup() is
not needed at the moment but prepares the code for the
application/library split too.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
@bith3ad bith3ad requested a review from pH5 August 1, 2024 16:06
platsch.c Outdated Show resolved Hide resolved
platsch.c Outdated Show resolved Hide resolved
platsch.c Outdated Show resolved Hide resolved
platsch.c Outdated Show resolved Hide resolved
libplatsch.c Outdated Show resolved Hide resolved
platsch.c Outdated Show resolved Hide resolved
Marco Felsch added 5 commits August 5, 2024 10:56
Add platsch_create_ctx() to bundle the initialization.

This prepares the code base for the upcoming application/library split.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Add platsch_draw() to bundle the draw step.

This prepares the code base for the upcoming application/library split.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Add platsch_destroy_ctx() to bundle the final step. While on it add the
missing modeset_dev free which is important once we split this part into
a library.

This prepares the code base for the upcoming application/library split.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Move the default value handling out of the application main() function
into platsch_init_ctx().

This prepares the code base for the upcoming application/library split.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Use calloc which set the memory automatically to zero to remove the
memset() call.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
@bith3ad bith3ad force-pushed the topic/libsplit branch 2 times, most recently from 21a583f to df275ae Compare August 6, 2024 05:45
sources : ['libplatsch.c'],
dependencies : [libdrm_dep],
install : true
)
Copy link
Member

Choose a reason for hiding this comment

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

You're creating a shared library here, right? In that case, we should probably export symbols properly.

Copy link
Contributor Author

@bith3ad bith3ad Aug 7, 2024

Choose a reason for hiding this comment

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

Yes, I addressed this with the latest version. Can you please check if my implementation is what you had in mind?

Copy link
Member

Choose a reason for hiding this comment

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

$ nm -D libplatsch.so.0.1
[...]
00000000000029a1 T platsch_alloc_ctx
000000000000293e T platsch_create_ctx
0000000000002bb0 T platsch_destroy_ctx
000000000000276a T platsch_draw
0000000000002b96 T platsch_init_ctx
000000000000290a T platsch_register_custom_draw_cb
[...]

Looks good.

Marco Felsch added 9 commits August 7, 2024 09:31
Split the single platsch.c into platsch.c and libplatsch.c. The later
can be used by other projects to build custom bootsplash applications
once we support building the library.

During the split no changes are made except for making:

 struct platsch_ctx *platsch_create_ctx(const char *dir, const char *base);
 void platsch_destroy_ctx(struct platsch_ctx *ctx);
 void platsch_draw(struct platsch_ctx *ctx);

public.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
This adds the support for building platsch and libplatsch. Platsch uses
the static library to not cause any performance regression.

By this commit the conversion from a standalone application into an
application and library is complete.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Add drmIsMaster() before dropping the master to not cause confusion due
to the error message print.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
The platsch_create_ctx() allocates and init the ctx in one call but
sometimes applications need to add custom data in between both steps.
Therefore add platsch_alloc_ctx and platsch_init_ctx.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
This adds the support to register a custom draw operation callback which
will be called during platsch_draw(). The callback has all the necessary
information about the framebuffer and a reference to the framebuffer
itself to update content. The information will be freed after the
callback has finished, therfore the content needs to be copied by the
application.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Disable the setmode flag once it was set succefully since all further
platsch_draw() calls only need an page flip operation.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Rename the function to platsch_draw_buffer and align the function params
to make it identical to the platsch_custom_draw_buffer function.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Pass the whole contect to the helper function to align it with the code
base. No functional change.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
At the moment we rely on the 'default' visibility which was okay since
all global functions are API functions. This is error prone as one could
expose symbols by accident.

Therefore change the behavior by setting the default visibility to
'hidden' and introducing a new macro to export selected API functions.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
@bith3ad
Copy link
Contributor Author

bith3ad commented Aug 7, 2024

  • aligned header function order with implementation order
  • dropped drm_put and context_free in favor of drmIsMaster()
  • added LIBPLATSCH_API define and set symbol visibility to hidden per default

@bith3ad
Copy link
Contributor Author

bith3ad commented Aug 8, 2024

Successfully tested the pid1 and !pid1 use-case, ready to merge.

@bith3ad bith3ad merged commit 917ab44 into master Aug 8, 2024
2 checks passed
@bith3ad bith3ad deleted the topic/libsplit branch August 8, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants