2 * Copyright (C) 2005-2006 Micronas USA Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/i2c.h>
21 #include <linux/videodev2.h>
32 static u8 initial_registers[] =
40 0xFF, 0xFF, /* Terminator (reg 0xFF is unused) */
43 static int write_regs(struct i2c_client *client, u8 *regs)
47 for (i = 0; regs[i] != 0xFF; i += 2)
48 if (i2c_smbus_write_byte_data(client, regs[i], regs[i + 1]) < 0)
53 static int wis_ov7640_probe(struct i2c_client *client,
54 const struct i2c_device_id *id)
56 struct i2c_adapter *adapter = client->adapter;
58 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
61 client->flags = I2C_CLIENT_SCCB;
64 "wis-ov7640: initializing OV7640 at address %d on %s\n",
65 client->addr, adapter->name);
67 if (write_regs(client, initial_registers) < 0) {
68 printk(KERN_ERR "wis-ov7640: error initializing OV7640\n");
75 static int wis_ov7640_remove(struct i2c_client *client)
80 static struct i2c_device_id wis_ov7640_id[] = {
85 static struct i2c_driver wis_ov7640_driver = {
87 .name = "WIS OV7640 I2C driver",
89 .probe = wis_ov7640_probe,
90 .remove = wis_ov7640_remove,
91 .id_table = wis_ov7640_id,
94 static int __init wis_ov7640_init(void)
96 return i2c_add_driver(&wis_ov7640_driver);
99 static void __exit wis_ov7640_cleanup(void)
101 i2c_del_driver(&wis_ov7640_driver);
104 module_init(wis_ov7640_init);
105 module_exit(wis_ov7640_cleanup);
107 MODULE_LICENSE("GPL v2");