diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2007-04-04 13:11:04 -0700 |
---|---|---|
committer | Trent Piepho <xyzzy@speakeasy.org> | 2007-04-04 13:11:04 -0700 |
commit | 83912a99f13aa9f9f4e13ce2a393734658da9cd2 (patch) | |
tree | f39b0ebdaffaad73b72bdedf7be51c3f61b93849 /linux/drivers/media/video/sn9c102/sn9c102_sensor.h | |
parent | cec4aeb12813bbc223b4d1b4faa8e6334f6e364a (diff) | |
download | mediapointer-dvb-s2-83912a99f13aa9f9f4e13ce2a393734658da9cd2.tar.gz mediapointer-dvb-s2-83912a99f13aa9f9f4e13ce2a393734658da9cd2.tar.bz2 |
sn9c102: more efficient register writing code
From: Trent Piepho <xyzzy@speakeasy.org>
There were many places in the driver which had long sequences of constant
register initializations. These were done with one function call per
register. The register address and value were immediate values in the
function calls.
This is very inefficient, as each register and value take twice the space
when they are code, as each includes a push instruction to put it on
the stack. There there is the overhead, both size and time, for a
function call for each register. It's also quite a few lines of C code
to do this.
The patch creates a function that writes multiple registers from a list,
and a macro that makes it easy to construct a such a list as a const
static local to send to the function.
This gets rid of quite a bit of C code, and shrinks the driver by around
8k, while at the same time being more efficient.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Luca Risolia <luca.risolia@studio.unibo.it>
Diffstat (limited to 'linux/drivers/media/video/sn9c102/sn9c102_sensor.h')
-rw-r--r-- | linux/drivers/media/video/sn9c102/sn9c102_sensor.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/linux/drivers/media/video/sn9c102/sn9c102_sensor.h b/linux/drivers/media/video/sn9c102/sn9c102_sensor.h index d90f2c74f..7cbb993ad 100644 --- a/linux/drivers/media/video/sn9c102/sn9c102_sensor.h +++ b/linux/drivers/media/video/sn9c102/sn9c102_sensor.h @@ -115,9 +115,17 @@ extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); /* I/O on registers in the bridge. Could be used by the sensor methods too */ -extern int sn9c102_write_regs(struct sn9c102_device*, u8* buff, u16 index); -extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); +extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); +extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], + int count); +/* + * Write multiple registers with constant values. For example: + * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); + */ +#define sn9c102_write_const_regs(device, data...) \ + ({ const static u8 _data[][2] = {data}; \ + sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) /*****************************************************************************/ |