blob: e5ed4db32e7bfcfb00ed7ebc3cce2f9176563944 [file] [log] [blame]
Ralf Baechled203a7e2005-09-06 15:19:37 -07001/*
2 * indycam.c - Silicon Graphics IndyCam digital camera driver
3 *
4 * Copyright (C) 2003 Ladislav Michl <ladis@linux-mips.org>
5 * Copyright (C) 2004,2005 Mikael Nousiainen <tmnousia@cc.hut.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
Ralf Baechled203a7e2005-09-06 15:19:37 -070012#include <linux/delay.h>
13#include <linux/errno.h>
14#include <linux/fs.h>
Ladislav Michl495515b2005-09-23 10:52:27 +000015#include <linux/init.h>
Ralf Baechled203a7e2005-09-06 15:19:37 -070016#include <linux/kernel.h>
17#include <linux/major.h>
Ladislav Michl495515b2005-09-23 10:52:27 +000018#include <linux/module.h>
Ralf Baechled203a7e2005-09-06 15:19:37 -070019#include <linux/mm.h>
Ladislav Michl495515b2005-09-23 10:52:27 +000020#include <linux/slab.h>
Ralf Baechled203a7e2005-09-06 15:19:37 -070021
Ralf Baechled203a7e2005-09-06 15:19:37 -070022/* IndyCam decodes stream of photons into digital image representation ;-) */
Hans Verkuilcf4e9482009-02-27 09:05:10 -030023#include <linux/videodev2.h>
Ralf Baechled203a7e2005-09-06 15:19:37 -070024#include <linux/i2c.h>
Hans Verkuil2b80a192009-02-13 19:38:10 -030025#include <media/v4l2-device.h>
26#include <media/v4l2-chip-ident.h>
Ralf Baechled203a7e2005-09-06 15:19:37 -070027
28#include "indycam.h"
29
Ladislav Michla637a112005-09-01 15:07:34 +000030#define INDYCAM_MODULE_VERSION "0.0.5"
Ralf Baechled203a7e2005-09-06 15:19:37 -070031
32MODULE_DESCRIPTION("SGI IndyCam driver");
33MODULE_VERSION(INDYCAM_MODULE_VERSION);
34MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>");
35MODULE_LICENSE("GPL");
36
Hans Verkuilcf4e9482009-02-27 09:05:10 -030037
Ladislav Michla637a112005-09-01 15:07:34 +000038// #define INDYCAM_DEBUG
39
Ralf Baechled203a7e2005-09-06 15:19:37 -070040#ifdef INDYCAM_DEBUG
41#define dprintk(x...) printk("IndyCam: " x);
42#define indycam_regdump(client) indycam_regdump_debug(client)
43#else
44#define dprintk(x...)
45#define indycam_regdump(client)
46#endif
47
Ralf Baechled203a7e2005-09-06 15:19:37 -070048struct indycam {
Hans Verkuil2b80a192009-02-13 19:38:10 -030049 struct v4l2_subdev sd;
Ladislav Michla637a112005-09-01 15:07:34 +000050 u8 version;
Ralf Baechled203a7e2005-09-06 15:19:37 -070051};
52
Hans Verkuil2b80a192009-02-13 19:38:10 -030053static inline struct indycam *to_indycam(struct v4l2_subdev *sd)
54{
55 return container_of(sd, struct indycam, sd);
56}
57
Ladislav Michla637a112005-09-01 15:07:34 +000058static const u8 initseq[] = {
Ralf Baechled203a7e2005-09-06 15:19:37 -070059 INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */
Ladislav Michla637a112005-09-01 15:07:34 +000060 INDYCAM_SHUTTER_60, /* INDYCAM_SHUTTER */
Ralf Baechled203a7e2005-09-06 15:19:37 -070061 INDYCAM_GAIN_DEFAULT, /* INDYCAM_GAIN */
62 0x00, /* INDYCAM_BRIGHTNESS (read-only) */
63 INDYCAM_RED_BALANCE_DEFAULT, /* INDYCAM_RED_BALANCE */
64 INDYCAM_BLUE_BALANCE_DEFAULT, /* INDYCAM_BLUE_BALANCE */
65 INDYCAM_RED_SATURATION_DEFAULT, /* INDYCAM_RED_SATURATION */
66 INDYCAM_BLUE_SATURATION_DEFAULT,/* INDYCAM_BLUE_SATURATION */
67};
68
69/* IndyCam register handling */
70
Hans Verkuil2b80a192009-02-13 19:38:10 -030071static int indycam_read_reg(struct v4l2_subdev *sd, u8 reg, u8 *value)
Ralf Baechled203a7e2005-09-06 15:19:37 -070072{
Hans Verkuil2b80a192009-02-13 19:38:10 -030073 struct i2c_client *client = v4l2_get_subdevdata(sd);
Ralf Baechled203a7e2005-09-06 15:19:37 -070074 int ret;
75
Ladislav Michla637a112005-09-01 15:07:34 +000076 if (reg == INDYCAM_REG_RESET) {
Ralf Baechled203a7e2005-09-06 15:19:37 -070077 dprintk("indycam_read_reg(): "
78 "skipping write-only register %d\n", reg);
79 *value = 0;
80 return 0;
81 }
82
83 ret = i2c_smbus_read_byte_data(client, reg);
Ladislav Michla637a112005-09-01 15:07:34 +000084
Ralf Baechled203a7e2005-09-06 15:19:37 -070085 if (ret < 0) {
86 printk(KERN_ERR "IndyCam: indycam_read_reg(): read failed, "
87 "register = 0x%02x\n", reg);
88 return ret;
89 }
90
Ladislav Michla637a112005-09-01 15:07:34 +000091 *value = (u8)ret;
Ralf Baechled203a7e2005-09-06 15:19:37 -070092
93 return 0;
94}
95
Hans Verkuil2b80a192009-02-13 19:38:10 -030096static int indycam_write_reg(struct v4l2_subdev *sd, u8 reg, u8 value)
Ralf Baechled203a7e2005-09-06 15:19:37 -070097{
Hans Verkuil2b80a192009-02-13 19:38:10 -030098 struct i2c_client *client = v4l2_get_subdevdata(sd);
Ralf Baechled203a7e2005-09-06 15:19:37 -070099 int err;
100
Hans Verkuil2b80a192009-02-13 19:38:10 -0300101 if (reg == INDYCAM_REG_BRIGHTNESS || reg == INDYCAM_REG_VERSION) {
Ralf Baechled203a7e2005-09-06 15:19:37 -0700102 dprintk("indycam_write_reg(): "
103 "skipping read-only register %d\n", reg);
104 return 0;
105 }
106
107 dprintk("Writing Reg %d = 0x%02x\n", reg, value);
108 err = i2c_smbus_write_byte_data(client, reg, value);
Ladislav Michla637a112005-09-01 15:07:34 +0000109
Ralf Baechled203a7e2005-09-06 15:19:37 -0700110 if (err) {
111 printk(KERN_ERR "IndyCam: indycam_write_reg(): write failed, "
112 "register = 0x%02x, value = 0x%02x\n", reg, value);
113 }
114 return err;
115}
116
Hans Verkuil2b80a192009-02-13 19:38:10 -0300117static int indycam_write_block(struct v4l2_subdev *sd, u8 reg,
Ladislav Michla637a112005-09-01 15:07:34 +0000118 u8 length, u8 *data)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700119{
Ladislav Michla637a112005-09-01 15:07:34 +0000120 int i, err;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700121
Ladislav Michla637a112005-09-01 15:07:34 +0000122 for (i = 0; i < length; i++) {
Hans Verkuil2b80a192009-02-13 19:38:10 -0300123 err = indycam_write_reg(sd, reg + i, data[i]);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700124 if (err)
125 return err;
126 }
127
128 return 0;
129}
130
131/* Helper functions */
132
133#ifdef INDYCAM_DEBUG
Hans Verkuil2b80a192009-02-13 19:38:10 -0300134static void indycam_regdump_debug(struct v4l2_subdev *sd)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700135{
136 int i;
Ladislav Michla637a112005-09-01 15:07:34 +0000137 u8 val;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700138
139 for (i = 0; i < 9; i++) {
Hans Verkuil2b80a192009-02-13 19:38:10 -0300140 indycam_read_reg(sd, i, &val);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700141 dprintk("Reg %d = 0x%02x\n", i, val);
142 }
143}
144#endif
145
Hans Verkuil2b80a192009-02-13 19:38:10 -0300146static int indycam_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700147{
Hans Verkuil2b80a192009-02-13 19:38:10 -0300148 struct indycam *camera = to_indycam(sd);
Ladislav Michla637a112005-09-01 15:07:34 +0000149 u8 reg;
150 int ret = 0;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700151
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300152 switch (ctrl->id) {
153 case V4L2_CID_AUTOGAIN:
154 case V4L2_CID_AUTO_WHITE_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300155 ret = indycam_read_reg(sd, INDYCAM_REG_CONTROL, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000156 if (ret)
157 return -EIO;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300158 if (ctrl->id == V4L2_CID_AUTOGAIN)
Ladislav Michla637a112005-09-01 15:07:34 +0000159 ctrl->value = (reg & INDYCAM_CONTROL_AGCENA)
160 ? 1 : 0;
161 else
162 ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL)
163 ? 1 : 0;
164 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300165 case V4L2_CID_EXPOSURE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300166 ret = indycam_read_reg(sd, INDYCAM_REG_SHUTTER, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000167 if (ret)
168 return -EIO;
169 ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1);
170 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300171 case V4L2_CID_GAIN:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300172 ret = indycam_read_reg(sd, INDYCAM_REG_GAIN, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000173 if (ret)
174 return -EIO;
175 ctrl->value = (s32)reg;
176 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300177 case V4L2_CID_RED_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300178 ret = indycam_read_reg(sd, INDYCAM_REG_RED_BALANCE, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000179 if (ret)
180 return -EIO;
181 ctrl->value = (s32)reg;
182 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300183 case V4L2_CID_BLUE_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300184 ret = indycam_read_reg(sd, INDYCAM_REG_BLUE_BALANCE, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000185 if (ret)
186 return -EIO;
187 ctrl->value = (s32)reg;
188 break;
189 case INDYCAM_CONTROL_RED_SATURATION:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300190 ret = indycam_read_reg(sd,
Ladislav Michla637a112005-09-01 15:07:34 +0000191 INDYCAM_REG_RED_SATURATION, &reg);
192 if (ret)
193 return -EIO;
194 ctrl->value = (s32)reg;
195 break;
196 case INDYCAM_CONTROL_BLUE_SATURATION:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300197 ret = indycam_read_reg(sd,
Ladislav Michla637a112005-09-01 15:07:34 +0000198 INDYCAM_REG_BLUE_SATURATION, &reg);
199 if (ret)
200 return -EIO;
201 ctrl->value = (s32)reg;
202 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300203 case V4L2_CID_GAMMA:
Ladislav Michla637a112005-09-01 15:07:34 +0000204 if (camera->version == CAMERA_VERSION_MOOSE) {
Hans Verkuil2b80a192009-02-13 19:38:10 -0300205 ret = indycam_read_reg(sd,
Ladislav Michla637a112005-09-01 15:07:34 +0000206 INDYCAM_REG_GAMMA, &reg);
207 if (ret)
208 return -EIO;
209 ctrl->value = (s32)reg;
210 } else {
211 ctrl->value = INDYCAM_GAMMA_DEFAULT;
212 }
213 break;
214 default:
215 ret = -EINVAL;
216 }
Ralf Baechled203a7e2005-09-06 15:19:37 -0700217
Ladislav Michla637a112005-09-01 15:07:34 +0000218 return ret;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700219}
220
Hans Verkuil2b80a192009-02-13 19:38:10 -0300221static int indycam_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700222{
Hans Verkuil2b80a192009-02-13 19:38:10 -0300223 struct indycam *camera = to_indycam(sd);
Ladislav Michla637a112005-09-01 15:07:34 +0000224 u8 reg;
225 int ret = 0;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700226
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300227 switch (ctrl->id) {
228 case V4L2_CID_AUTOGAIN:
229 case V4L2_CID_AUTO_WHITE_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300230 ret = indycam_read_reg(sd, INDYCAM_REG_CONTROL, &reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000231 if (ret)
232 break;
233
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300234 if (ctrl->id == V4L2_CID_AUTOGAIN) {
Ladislav Michla637a112005-09-01 15:07:34 +0000235 if (ctrl->value)
236 reg |= INDYCAM_CONTROL_AGCENA;
237 else
238 reg &= ~INDYCAM_CONTROL_AGCENA;
239 } else {
240 if (ctrl->value)
241 reg |= INDYCAM_CONTROL_AWBCTL;
242 else
243 reg &= ~INDYCAM_CONTROL_AWBCTL;
244 }
245
Hans Verkuil2b80a192009-02-13 19:38:10 -0300246 ret = indycam_write_reg(sd, INDYCAM_REG_CONTROL, reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000247 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300248 case V4L2_CID_EXPOSURE:
Ladislav Michla637a112005-09-01 15:07:34 +0000249 reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1);
Hans Verkuil2b80a192009-02-13 19:38:10 -0300250 ret = indycam_write_reg(sd, INDYCAM_REG_SHUTTER, reg);
Ladislav Michla637a112005-09-01 15:07:34 +0000251 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300252 case V4L2_CID_GAIN:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300253 ret = indycam_write_reg(sd, INDYCAM_REG_GAIN, ctrl->value);
Ladislav Michla637a112005-09-01 15:07:34 +0000254 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300255 case V4L2_CID_RED_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300256 ret = indycam_write_reg(sd, INDYCAM_REG_RED_BALANCE,
Ladislav Michla637a112005-09-01 15:07:34 +0000257 ctrl->value);
258 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300259 case V4L2_CID_BLUE_BALANCE:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300260 ret = indycam_write_reg(sd, INDYCAM_REG_BLUE_BALANCE,
Ladislav Michla637a112005-09-01 15:07:34 +0000261 ctrl->value);
262 break;
263 case INDYCAM_CONTROL_RED_SATURATION:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300264 ret = indycam_write_reg(sd, INDYCAM_REG_RED_SATURATION,
Ladislav Michla637a112005-09-01 15:07:34 +0000265 ctrl->value);
266 break;
267 case INDYCAM_CONTROL_BLUE_SATURATION:
Hans Verkuil2b80a192009-02-13 19:38:10 -0300268 ret = indycam_write_reg(sd, INDYCAM_REG_BLUE_SATURATION,
Ladislav Michla637a112005-09-01 15:07:34 +0000269 ctrl->value);
270 break;
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300271 case V4L2_CID_GAMMA:
Ladislav Michla637a112005-09-01 15:07:34 +0000272 if (camera->version == CAMERA_VERSION_MOOSE) {
Hans Verkuil2b80a192009-02-13 19:38:10 -0300273 ret = indycam_write_reg(sd, INDYCAM_REG_GAMMA,
Ladislav Michla637a112005-09-01 15:07:34 +0000274 ctrl->value);
275 }
276 break;
277 default:
278 ret = -EINVAL;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700279 }
Ralf Baechled203a7e2005-09-06 15:19:37 -0700280
Ladislav Michla637a112005-09-01 15:07:34 +0000281 return ret;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700282}
283
284/* I2C-interface */
285
Hans Verkuil2b80a192009-02-13 19:38:10 -0300286static int indycam_g_chip_ident(struct v4l2_subdev *sd,
287 struct v4l2_dbg_chip_ident *chip)
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300288{
Hans Verkuil2b80a192009-02-13 19:38:10 -0300289 struct i2c_client *client = v4l2_get_subdevdata(sd);
290 struct indycam *camera = to_indycam(sd);
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300291
Hans Verkuil2b80a192009-02-13 19:38:10 -0300292 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_INDYCAM,
293 camera->version);
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300294}
295
Hans Verkuil2b80a192009-02-13 19:38:10 -0300296/* ----------------------------------------------------------------------- */
297
298static const struct v4l2_subdev_core_ops indycam_core_ops = {
299 .g_chip_ident = indycam_g_chip_ident,
300 .g_ctrl = indycam_g_ctrl,
301 .s_ctrl = indycam_s_ctrl,
302};
303
304static const struct v4l2_subdev_ops indycam_ops = {
305 .core = &indycam_core_ops,
306};
307
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300308static int indycam_probe(struct i2c_client *client,
309 const struct i2c_device_id *id)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700310{
311 int err = 0;
312 struct indycam *camera;
Hans Verkuil2b80a192009-02-13 19:38:10 -0300313 struct v4l2_subdev *sd;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700314
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300315 v4l_info(client, "chip found @ 0x%x (%s)\n",
316 client->addr << 1, client->adapter->name);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700317
Panagiotis Issaris74081872006-01-11 19:40:56 -0200318 camera = kzalloc(sizeof(struct indycam), GFP_KERNEL);
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300319 if (!camera)
320 return -ENOMEM;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700321
Hans Verkuil2b80a192009-02-13 19:38:10 -0300322 sd = &camera->sd;
323 v4l2_i2c_subdev_init(sd, client, &indycam_ops);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700324
Ladislav Michla637a112005-09-01 15:07:34 +0000325 camera->version = i2c_smbus_read_byte_data(client,
326 INDYCAM_REG_VERSION);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700327 if (camera->version != CAMERA_VERSION_INDY &&
328 camera->version != CAMERA_VERSION_MOOSE) {
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300329 kfree(camera);
330 return -ENODEV;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700331 }
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300332
Ralf Baechled203a7e2005-09-06 15:19:37 -0700333 printk(KERN_INFO "IndyCam v%d.%d detected\n",
334 INDYCAM_VERSION_MAJOR(camera->version),
335 INDYCAM_VERSION_MINOR(camera->version));
336
Hans Verkuil2b80a192009-02-13 19:38:10 -0300337 indycam_regdump(sd);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700338
339 // initialize
Hans Verkuil2b80a192009-02-13 19:38:10 -0300340 err = indycam_write_block(sd, 0, sizeof(initseq), (u8 *)&initseq);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700341 if (err) {
Joe Perchesc84e6032008-02-03 17:18:59 +0200342 printk(KERN_ERR "IndyCam initialization failed\n");
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300343 kfree(camera);
344 return -EIO;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700345 }
346
Hans Verkuil2b80a192009-02-13 19:38:10 -0300347 indycam_regdump(sd);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700348
349 // white balance
Hans Verkuil2b80a192009-02-13 19:38:10 -0300350 err = indycam_write_reg(sd, INDYCAM_REG_CONTROL,
Ralf Baechled203a7e2005-09-06 15:19:37 -0700351 INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL);
352 if (err) {
Ladislav Michla637a112005-09-01 15:07:34 +0000353 printk(KERN_ERR "IndyCam: White balancing camera failed\n");
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300354 kfree(camera);
355 return -EIO;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700356 }
357
Hans Verkuil2b80a192009-02-13 19:38:10 -0300358 indycam_regdump(sd);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700359
360 printk(KERN_INFO "IndyCam initialized\n");
361
362 return 0;
Ralf Baechled203a7e2005-09-06 15:19:37 -0700363}
364
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300365static int indycam_remove(struct i2c_client *client)
Ralf Baechled203a7e2005-09-06 15:19:37 -0700366{
Hans Verkuil2b80a192009-02-13 19:38:10 -0300367 struct v4l2_subdev *sd = i2c_get_clientdata(client);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700368
Hans Verkuil2b80a192009-02-13 19:38:10 -0300369 v4l2_device_unregister_subdev(sd);
370 kfree(to_indycam(sd));
Ralf Baechled203a7e2005-09-06 15:19:37 -0700371 return 0;
372}
373
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300374static const struct i2c_device_id indycam_id[] = {
375 { "indycam", 0 },
376 { }
Ralf Baechled203a7e2005-09-06 15:19:37 -0700377};
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300378MODULE_DEVICE_TABLE(i2c, indycam_id);
Ralf Baechled203a7e2005-09-06 15:19:37 -0700379
Hans Verkuil9f490cd2010-09-15 15:17:19 -0300380static struct i2c_driver indycam_driver = {
381 .driver = {
382 .owner = THIS_MODULE,
383 .name = "indycam",
384 },
385 .probe = indycam_probe,
386 .remove = indycam_remove,
387 .id_table = indycam_id,
Hans Verkuilcf4e9482009-02-27 09:05:10 -0300388};
Hans Verkuil9f490cd2010-09-15 15:17:19 -0300389
390static __init int init_indycam(void)
391{
392 return i2c_add_driver(&indycam_driver);
393}
394
395static __exit void exit_indycam(void)
396{
397 i2c_del_driver(&indycam_driver);
398}
399
400module_init(init_indycam);
401module_exit(exit_indycam);