diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-08-05 00:07:16 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-08-05 00:17:33 -0700 |
commit | 3cc953518d1c2b84f08f5693d3566db4462623a8 (patch) | |
tree | 48f04a0f90bd465d822ec31900a631d88959e5f2 /src/drm_fb.c | |
parent | d7b92d1b6dd1b152c7263763de7e8f6b174583d4 (diff) |
til_setup,*: add til_setup_t.creator pointer
Particularly with nested modules it's annoying to have to stow
the module separate from the setup during the setup process.
If the baked setup included the module pointer in the
non-module-specific-setup part of the setup, then nested settings
could finalize using the generic module setup wrapper and just
rely on this til_setup_t.creator pointer to contain the
appropriate module. Which should enable tossing out a bunch of
copy-n-pasta surrounding nested modules setup.
Note this has to be a void* since til_setup_t is a generic thing
used equally by both the fb code and the module code. Hence why
this is called "creator" and not "module", as well as the void*
as opposed to til_module_t*.
Also if rototiller ever grows a sound backend, the setup
machinery will be reused there as well, and it'll be yet another
creator handle that isn't an til_fb_ops_t or a til_module_t.
It's assumed that the callers producing these setups won't be
trying to pass them to the wrong places i.e. a module setup
getting passed to an fb backend and vice versa.
I'm mildly annoyed about having to move the various til_module_t
blocks to above the module's foo_setup(), but it seemed like the
least annoying option. This may be revisited.
Diffstat (limited to 'src/drm_fb.c')
-rw-r--r-- | src/drm_fb.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c index d10891b..0b6e053 100644 --- a/src/drm_fb.c +++ b/src/drm_fb.c @@ -296,38 +296,6 @@ static void drm_fb_setup_free(til_setup_t *setup) } -/* setup is called repeatedly as settings is constructed, until 0 is returned. */ -/* a negative value is returned on error */ -/* positive value indicates another setting is needed, described in next_setting */ -static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) -{ - drm_fb_setup_t *setup = til_setup_new(settings, sizeof(*setup), drm_fb_setup_free); - til_setting_desc_generator_t generators[] = { - { - .key = "dev", - .value_ptr = &setup->dev, - .func = dev_desc_generator - }, { - .key = "connector", - .value_ptr = &setup->connector, - .func = connector_desc_generator - }, { - .key = "mode", - .value_ptr = &setup->mode, - .func = mode_desc_generator - }, - }; - - if (!drmAvailable()) - return -ENOSYS; - - if (!setup) - return -ENOMEM; - - return til_settings_apply_desc_generators(settings, generators, nelems(generators), &setup->til_setup, res_setting, res_desc, res_setup); -} - - /* lookup a mode string in the given connector returning its respective modeinfo */ static drmModeModeInfo * lookup_mode(drmModeConnector *connector, const char *mode) { @@ -563,6 +531,9 @@ static int drm_fb_page_flip(til_fb_t *fb, void *context, void *page) } +static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); + + til_fb_ops_t drm_fb_ops = { .setup = drm_fb_setup, .init = drm_fb_init, @@ -573,3 +544,37 @@ til_fb_ops_t drm_fb_ops = { .page_free = drm_fb_page_free, .page_flip = drm_fb_page_flip }; + + +/* setup is called repeatedly as settings is constructed, until 0 is returned. */ +/* a negative value is returned on error */ +/* positive value indicates another setting is needed, described in next_setting */ +static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) +{ + drm_fb_setup_t *setup = til_setup_new(settings, sizeof(*setup), drm_fb_setup_free, &drm_fb_ops); + til_setting_desc_generator_t generators[] = { + { + .key = "dev", + .value_ptr = &setup->dev, + .func = dev_desc_generator + }, { + .key = "connector", + .value_ptr = &setup->connector, + .func = connector_desc_generator + }, { + .key = "mode", + .value_ptr = &setup->mode, + .func = mode_desc_generator + }, + }; + + if (!drmAvailable()) + return -ENOSYS; + + if (!setup) + return -ENOMEM; + + return til_settings_apply_desc_generators(settings, generators, nelems(generators), &setup->til_setup, res_setting, res_desc, res_setup); +} + + |