Tyler Trafford wrote:
Yeah, the code could just be put into start/end_fw_load().
That's where I threw it in on my tests. Diff attached for anyone
who wants to experiment on their load times.
If it's possible that anything else -using that instance of ivtv as
its i2c adapter- will do something during that interval where the
faster send will mess it up, there would need to be some locking done
From what I see, the only time the firmware load takes place is
during card init (or re-init). I'm not sure we'd need to worry about
things getting wonky (since most values are in an unknown state at that
point), but I can see what you mean. Ideally, this function of mine
should be moved to ivtv-i2c.c, and then use the i2c_lock mutex, don't
you think?
Index: cx25840-driver.c
===================================================================
--- cx25840-driver.c (revision 239)
+++ cx25840-driver.c (working copy)
@@ -28,6 +28,8 @@
#include <asm/uaccess.h>
#include <linux/video_decoder.h>
#include <linux/crypto.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
#include "ivtv.h"
#include "decoder.h"
@@ -197,6 +199,12 @@
return (value >> s) & (0xffffffff >> (32 - l));
}
+static void cx25840_i2c_set_delay(struct i2c_client *client, int delay)
+{
+ struct i2c_algo_bit_data *algod = client->adapter->algo_data;
+ algod->udelay = delay;
+}
+
static inline void start_fw_load(struct i2c_client *client)
{
CX25840_SET_DL_ADDR_LB(0x0000); // '*' (Default 0x0000) Reg: 0x0800
Start bit: 0 Bit length: 8
@@ -205,10 +213,12 @@
CX25840_SET_DL_AUTO_INC(0x0000); // 'Auto increment address on
write' (Default 0x0000) Reg: 0x0803 Start bit: 2 Bit length: 1
CX25840_SET_DL_ENABLE(0x0001); // 'Enable' (Default 0x0000) Reg:
0x0803 Start bit: 3 Bit length: 1
CX25840_SET_AUTO_INC_DIS(0x0001); // 'Do not increment the
address' (Default 0x0000) Reg: 0x0000 Start bit: 5 Bit length: 1
+ cx25840_i2c_set_delay(client, 3);
}
static inline void end_fw_load(struct i2c_client *client)
{
+ cx25840_i2c_set_delay(client, 10);
CX25840_SET_AUTO_INC_DIS(0x0000); // 'Do the auto-address
increment' (Default 0x0000) Reg: 0x0000 Start bit: 5 Bit length: 1
CX25840_SET_DL_ENABLE(0x0000); // 'Disable' (Default 0x0000) Reg:
0x0803 Start bit: 3 Bit length: 1
}