13 #include <linux/errno.h>
16 #include <linux/kernel.h>
18 #include <linux/module.h>
20 #include <linux/slab.h>
23 #include <linux/videodev2.h>
24 #include <linux/i2c.h>
30 #define INDYCAM_MODULE_VERSION "0.0.5"
41 #define dprintk(x...) printk("IndyCam: " x);
42 #define indycam_regdump(client) indycam_regdump_debug(client)
45 #define indycam_regdump(client)
58 static const u8 initseq[] = {
78 "skipping write-only register %d\n", reg);
87 "register = 0x%02x\n", reg);
98 struct i2c_client *client = v4l2_get_subdevdata(sd);
102 dprintk(
"indycam_write_reg(): "
103 "skipping read-only register %d\n", reg);
107 dprintk(
"Writing Reg %d = 0x%02x\n", reg, value);
112 "register = 0x%02x, value = 0x%02x\n", reg, value);
117 static int indycam_write_block(
struct v4l2_subdev *sd,
u8 reg,
122 for (i = 0; i <
length; i++) {
123 err = indycam_write_reg(sd, reg + i, data[i]);
134 static void indycam_regdump_debug(
struct v4l2_subdev *sd)
139 for (i = 0; i < 9; i++) {
140 indycam_read_reg(sd, i, &val);
141 dprintk(
"Reg %d = 0x%02x\n", i, val);
148 struct indycam *camera = to_indycam(sd);
169 ctrl->
value = ((
s32)reg == 0x00) ? 0xff : ((
s32)reg - 1);
190 ret = indycam_read_reg(sd,
197 ret = indycam_read_reg(sd,
205 ret = indycam_read_reg(sd,
223 struct indycam *camera = to_indycam(sd);
249 reg = (ctrl->
value == 0xff) ? 0x00 : (ctrl->
value + 1);
286 static int indycam_g_chip_ident(
struct v4l2_subdev *sd,
289 struct i2c_client *client = v4l2_get_subdevdata(sd);
290 struct indycam *camera = to_indycam(sd);
299 .g_chip_ident = indycam_g_chip_ident,
300 .g_ctrl = indycam_g_ctrl,
301 .s_ctrl = indycam_s_ctrl,
305 .core = &indycam_core_ops,
308 static int indycam_probe(
struct i2c_client *client,
315 v4l_info(client,
"chip found @ 0x%x (%s)\n",
340 err = indycam_write_block(sd, 0,
sizeof(initseq), (
u8 *)&initseq);
365 static int indycam_remove(
struct i2c_client *client)
367 struct v4l2_subdev *sd = i2c_get_clientdata(client);
370 kfree(to_indycam(sd));
385 .probe = indycam_probe,
386 .remove = indycam_remove,
387 .id_table = indycam_id,