[linux-dvb] idea on how to break the static dependencies on demodulator modules

Oliver Endriss o.endriss at gmx.de
Tue Apr 18 06:41:52 CEST 2006


Andrew de Quincey wrote:
> Hi, Manu and I were just discussing this, and we think we have come up with an 
> idea. See the attached patch.
> 
> Note: this is just an idea - it needs completed. The patch is just 
> illustrative - it won't tune or anything.
> 
> Anyway: if you look at the frontend_init() code. Instead of calling the attach 
> methods (eg. stv0299_attach()) directly, we instead define something like the 
> macros I have added (e.g. STV0299_ATTACH).
> 
> These use symbol_get() to dynamically get the address of the XXX_attach() 
> method and, if found, call it. Otherwise they fake a NULL return, and the 
> normal frontend failure code comes into effect.
> 
> This method (suprisingly!) seems to work really well - dmesg for my test card 
> in this machine when I modprobed the modified budget-ci module:
> 
> saa7146: register extension 'budget_ci dvb'.
> ACPI: PCI Interrupt 0000:05:06.0[A] -> Link [APC1] -> GSI 16 (level, low) -> 
> IRQ 66
> saa7146: found saa7146 @ mem ffffc20010d04000 (revision 1, irq 66) 
> (0x13c2,0x100f).
> saa7146 (0): dma buffer size 192512
> DVB: registering new adapter (TT-Budget/WinTV-NOVA-CI PCI).
> adapter has MAC addr = 00:d0:5c:21:10:f5
> input: Budget-CI dvb ir receiver saa7146 (0) as /class/input/input6
> DVB: registering frontend 0 (ST STV0299 DVB-S)...
> 
> The only DVB modules loaded are however:
> budget_ci
> budget_core
> saa7146
> ttpci_eeprom
> stv0299
> dvb_core
> 
> Can anyone see anything fundamentally wrong with doing it this way? Due to the 
> frontend refactoring a while back, we already have these nice tables of 
> function pointers everywhere anyway.
> 
> We do have a few static function calls to deal with - I just hacked 'em out in 
> the patch. With the PLL refactoring (see my other post) more of these are 
> going away anyway, so the few remaining ones can be dealt with in some neater 
> manner.

Hey, this is a great idea! And surprisingly simple.
No more loading of frontend drivers which are not required!

Does request_module() log a message if the module cannot be loaded?
If yes, fine. If no, a message should be logged by the DVB_ATTACH macro:

#define DVB_ATTACH(RESULT, MODULE, FUNCTION,ARGS...) \
do { \
	typeof(&FUNCTION) __a;				\
	request_module(MODULE);				\
	__a = symbol_get(FUNCTION);			\
	if (__a)					\
		RESULT = __a(ARGS);			\
	else {						\
		printk("unable to load %s\n", MODULE);	\
		RESULT = NULL;				\
	}						\
} while(0);

Looks perfect otherise. Great idea!

CU
Oliver

-- 
--------------------------------------------------------
VDR Remote Plugin available at
http://www.escape-edv.de/endriss/vdr/
--------------------------------------------------------



More information about the linux-dvb mailing list