[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: kld screensavers
From:       Doug Rabson <dfr () nlsystems ! com>
Date:       1998-10-30 9:44:35
[Download RAW message or body]

On Thu, 29 Oct 1998, Kazutaka YOKOTA wrote:

> 
> >It looks about right and SI_SUB_PSEUDO is sufficiently late that it
> >shouldn't disturb anything.  Any time after SI_SUB_CONFIGURE should work I
> >think.
> >
> >It would be nice if the add_scrn_saver/remove_scrn_saver goop was factored
> >into a generic module event handler which can be used by all screen
> >savers.  Have a look at the CDEV_MODULE #define in sys/conf.h for a
> >possible way of doing this.
> >
> >If the generic module handler chains onto an optional user-supplied
> >handler, then extra initialisation (allocating message in this case) can
> >be done by each saver without repeating the registration code.
> 
> You mean something like this?
> 
> 1. Define generic_screen_saver_module_handler() in syscons.c or somewhere.
> 2. Each screen saver module define its own event handler.  It will call
>    the generic handler first and then do its own extra house keeping.

Thats more or less what I was suggesting.  Simple screen savers wouldn't
even need an event handler.  Maybe something like:

struct saver_module_data {
	modeventhand_t 	chainevh;
	void*		chainarg;
	void 	      	(*saver)(int);
};

#defined SAVER_MODULE(name, fn, evh, arg)		\
static struct saver_module_data name##_saver_mod = {	\
	evh, arg, fn					\
};							\
							\
static moduledata_t name##_mod = {			\
	#name,						\
	saver_module_handler,				\
	&name##_saver_mod				\
};							\
DECLARE_MODULE(name, name##_mod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE)

static int
saver_module_handler(module_t mod, modeventtype_t type, void *arg)
{
	struct saver_module_data *data = arg;
        switch (type) {
        case MOD_LOAD:
                return add_scrn_saver(data->saver);
        case MOD_UNLOAD:
                return remove_scrn_saver(data->saver);
        default:
                printf("star_saver module unknown event: 0x%x\n", type);
        }

	if (data->chainevh)
		return data->chainevh(mod, what, data->chainarg);
	else
	        return 0;
}

--
Doug Rabson				Mail:  dfr@nlsystems.com
Nonlinear Systems Ltd.			Phone: +44 181 951 1891
					Fax:   +44 181 381 1039



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic