18 #include <linux/module.h>
21 #include <linux/sched.h>
24 #include <linux/time.h>
27 #include <linux/device.h>
28 #include <linux/i2c.h>
32 #include <linux/slab.h>
33 #include <linux/videodev2.h>
49 go->
hpi_ops->read_interrupt(go);
91 static int go7007_load_encoder(
struct go7007 *
go)
94 char fw_name[] =
"go7007fw.bin";
97 u16 intr_val, intr_data;
100 v4l2_err(go,
"unable to load firmware from file "
101 "\"%s\"\n", fw_name);
104 if (fw_entry->
size < 16 ||
memcmp(fw_entry->
data,
"WISGO7007FW", 11)) {
105 v4l2_err(go,
"file \"%s\" does not appear to be "
106 "go7007 firmware\n", fw_name);
110 fw_len = fw_entry->
size - 16;
112 if (bounce ==
NULL) {
113 v4l2_err(go,
"unable to allocate %d bytes for "
114 "firmware transfer\n", fw_len);
123 (intr_val & ~0x1) != 0x5a5a) {
124 v4l2_err(go,
"error transferring firmware\n");
145 ret = go7007_load_encoder(go);
165 static int go7007_init_encoder(
struct go7007 *go)
187 if (go7007_load_encoder(go) < 0)
189 return go7007_init_encoder(go);
198 struct go7007 *go = i2c_get_adapdata(adapter);
223 ret = go7007_init_encoder(go);
265 int fw_len, rv = 0,
i;
266 u16 intr_val, intr_data;
270 for (
i = 0;
i < 4; ++
i) {
271 if (go->
modet[
i].enable) {
275 go->
modet[
i].pixel_threshold = 32767;
276 go->
modet[
i].motion_threshold = 32767;
277 go->
modet[
i].mb_threshold = 32767;
322 static void frame_boundary(
struct go7007 *go)
330 for (i = 0; i < 216; ++
i)
351 static void write_bitmap_word(
struct go7007 *go)
353 int x,
y,
i, stride = ((go->
width >> 4) + 7) >> 3;
355 for (i = 0; i < 16; ++
i) {
358 if (stride * y + (x >> 3) <
sizeof(go->
active_map))
372 int i, seq_start_code = -1, frame_start_code = -1;
378 seq_start_code = 0xB0;
379 frame_start_code = 0xB6;
383 seq_start_code = 0xB3;
384 frame_start_code = 0x00;
465 (buf[i] == seq_start_code ||
467 buf[i] == frame_start_code)) {
470 if (buf[i] == frame_start_code) {
546 write_bitmap_word(go);
625 for (i = 0; i < 4; ++
i)
626 go->
modet[i].enable = 0;
627 for (i = 0; i < 1624; ++
i)
631 INIT_LIST_HEAD(&go->
stream);
649 "error removing I2C adapter!\n");