[sane-devel] Re: GL841  genesys.h
   
    stef
     
    svoltz@wanadoo.fr
       
    Fri, 6 May 2005 14:10:18 +0200
    
    
  
On Fri, May 06, 2005 at 01:06:59PM +0200, Philipp Schmid wrote:
> Hi Stef,
> 
> as the regs of the gl841 are different I propose to define two macros in 
> genesys.h to the bits if it is necessary. One for the gl841 and one for 
> the gl646 context of this bits. e.g.
> 
> #define REG01_COMPENB    0x08    //gl646
> #define REG01_M16DRAM    0x08    //gl841
> 
> Bye,
>    Philipp
> 
> 
	Hello,
	what I recommend is to move *ALL* registers defines out of genesys_low.h to
their corresponding low level files since they are different. Only use them in 
genesys_gl841.c or genesys_gl646.c . If a functions in genesys.c need some
of them, we should use a helper function that calls one specialized function.
	For instance I'll turn code like:
	if (genesys_read_reg_from_set (reg, 0x04) & REG04_FILTER)
	into:
	reg04 = genesys_read_reg_from_set (reg, 0x04);
	if (genesys_filter_bit(dev, reg04))
	with
	int genesys_filter_bit(Genesys_Device *dev, SANE_Byte)
	{
		switch(dev->model->asic_type)
		{
			case GENESYS_GL646:
				return gl646_filter_bit(dev,reg);
			case GENESYS_GL841:
				return gl841_filter_bit(dev,reg);
		}
	}
	right define would be used in gl646_filter_bit/gl841_filter_bit .
	Or be even better (register address could be different):
	into:
	if (genesys_filter_bit (dev, reg, 0x04))
	with:
	SANE_Byte genesys_filter_bit(Genesys_Device *dev,
				     Genesys_Register_Set *reg,
				     SANE_Byte addr)
	{
		switch(dev->model->asic_type)
		{
			case GENESYS_GL646:
				return gl646_filter_bit(dev,reg);
			case GENESYS_GL841:
				return gl841_filter_bit(dev,reg);
		}
	}
	glXXX_filter_bit will do the register search and test bit in a specific way.
	There are quite a few functions like that to add. 
Regards,
	Stef