aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/sn9c102/sn9c102_mi0360.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-04-04 17:11:04 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 15:45:27 -0300
commitc680dd603857d7218b84751e9f6f0654bbfbefa2 (patch)
tree58ce390afc6bc720a57550a2171aa1af9a4b7df9 /drivers/media/video/sn9c102/sn9c102_mi0360.c
parent0ee32871c18a3662d8958a8e9998eb4d2ae94159 (diff)
V4L/DVB (5502): Sn9c102: more efficient register writing code
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. Acked-by: Luca Risolia <luca.risolia@studio.unibo.it> Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/sn9c102/sn9c102_mi0360.c')
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0360.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0360.c b/drivers/media/video/sn9c102/sn9c102_mi0360.c
index 7154dd0534f..64698acb0b1 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0360.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0360.c
@@ -27,34 +27,20 @@ static int mi0360_init(struct sn9c102_device* cam)
struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
int err = 0;
- err += sn9c102_write_reg(cam, 0x00, 0x10);
- err += sn9c102_write_reg(cam, 0x00, 0x11);
- err += sn9c102_write_reg(cam, 0x0a, 0x14);
- err += sn9c102_write_reg(cam, 0x40, 0x01);
- err += sn9c102_write_reg(cam, 0x20, 0x17);
- err += sn9c102_write_reg(cam, 0x07, 0x18);
- err += sn9c102_write_reg(cam, 0xa0, 0x19);
- err += sn9c102_write_reg(cam, 0x02, 0x1c);
- err += sn9c102_write_reg(cam, 0x03, 0x1d);
- err += sn9c102_write_reg(cam, 0x0f, 0x1e);
- err += sn9c102_write_reg(cam, 0x0c, 0x1f);
- err += sn9c102_write_reg(cam, 0x00, 0x20);
- err += sn9c102_write_reg(cam, 0x10, 0x21);
- err += sn9c102_write_reg(cam, 0x20, 0x22);
- err += sn9c102_write_reg(cam, 0x30, 0x23);
- err += sn9c102_write_reg(cam, 0x40, 0x24);
- err += sn9c102_write_reg(cam, 0x50, 0x25);
- err += sn9c102_write_reg(cam, 0x60, 0x26);
- err += sn9c102_write_reg(cam, 0x70, 0x27);
- err += sn9c102_write_reg(cam, 0x80, 0x28);
- err += sn9c102_write_reg(cam, 0x90, 0x29);
- err += sn9c102_write_reg(cam, 0xa0, 0x2a);
- err += sn9c102_write_reg(cam, 0xb0, 0x2b);
- err += sn9c102_write_reg(cam, 0xc0, 0x2c);
- err += sn9c102_write_reg(cam, 0xd0, 0x2d);
- err += sn9c102_write_reg(cam, 0xe0, 0x2e);
- err += sn9c102_write_reg(cam, 0xf0, 0x2f);
- err += sn9c102_write_reg(cam, 0xff, 0x30);
+ err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11},
+ {0x0a, 0x14}, {0x40, 0x01},
+ {0x20, 0x17}, {0x07, 0x18},
+ {0xa0, 0x19}, {0x02, 0x1c},
+ {0x03, 0x1d}, {0x0f, 0x1e},
+ {0x0c, 0x1f}, {0x00, 0x20},
+ {0x10, 0x21}, {0x20, 0x22},
+ {0x30, 0x23}, {0x40, 0x24},
+ {0x50, 0x25}, {0x60, 0x26},
+ {0x70, 0x27}, {0x80, 0x28},
+ {0x90, 0x29}, {0xa0, 0x2a},
+ {0xb0, 0x2b}, {0xc0, 0x2c},
+ {0xd0, 0x2d}, {0xe0, 0x2e},
+ {0xf0, 0x2f}, {0xff, 0x30});
err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d,
0x00, 0x01, 0, 0);
@@ -332,11 +318,10 @@ static struct sn9c102_sensor mi0360 = {
int sn9c102_probe_mi0360(struct sn9c102_device* cam)
{
u8 data[5+1];
- int err = 0;
+ int err;
- err += sn9c102_write_reg(cam, 0x01, 0x01);
- err += sn9c102_write_reg(cam, 0x00, 0x01);
- err += sn9c102_write_reg(cam, 0x28, 0x17);
+ err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
+ {0x28, 0x17});
if (err)
return -EIO;