Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 1 | /* |
| 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 Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 12 | #include <linux/delay.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/fs.h> |
Ladislav Michl | 495515b | 2005-09-23 10:52:27 +0000 | [diff] [blame] | 15 | #include <linux/init.h> |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/major.h> |
Ladislav Michl | 495515b | 2005-09-23 10:52:27 +0000 | [diff] [blame] | 18 | #include <linux/module.h> |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 19 | #include <linux/mm.h> |
| 20 | #include <linux/sched.h> |
Ladislav Michl | 495515b | 2005-09-23 10:52:27 +0000 | [diff] [blame] | 21 | #include <linux/slab.h> |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 22 | |
| 23 | #include <linux/videodev.h> |
| 24 | /* IndyCam decodes stream of photons into digital image representation ;-) */ |
| 25 | #include <linux/video_decoder.h> |
| 26 | #include <linux/i2c.h> |
| 27 | |
| 28 | #include "indycam.h" |
| 29 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 30 | #define INDYCAM_MODULE_VERSION "0.0.5" |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 31 | |
| 32 | MODULE_DESCRIPTION("SGI IndyCam driver"); |
| 33 | MODULE_VERSION(INDYCAM_MODULE_VERSION); |
| 34 | MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); |
| 35 | MODULE_LICENSE("GPL"); |
| 36 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 37 | // #define INDYCAM_DEBUG |
| 38 | |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 39 | #ifdef INDYCAM_DEBUG |
| 40 | #define dprintk(x...) printk("IndyCam: " x); |
| 41 | #define indycam_regdump(client) indycam_regdump_debug(client) |
| 42 | #else |
| 43 | #define dprintk(x...) |
| 44 | #define indycam_regdump(client) |
| 45 | #endif |
| 46 | |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 47 | struct indycam { |
| 48 | struct i2c_client *client; |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 49 | u8 version; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static struct i2c_driver i2c_driver_indycam; |
| 53 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 54 | static const u8 initseq[] = { |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 55 | INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */ |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 56 | INDYCAM_SHUTTER_60, /* INDYCAM_SHUTTER */ |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 57 | INDYCAM_GAIN_DEFAULT, /* INDYCAM_GAIN */ |
| 58 | 0x00, /* INDYCAM_BRIGHTNESS (read-only) */ |
| 59 | INDYCAM_RED_BALANCE_DEFAULT, /* INDYCAM_RED_BALANCE */ |
| 60 | INDYCAM_BLUE_BALANCE_DEFAULT, /* INDYCAM_BLUE_BALANCE */ |
| 61 | INDYCAM_RED_SATURATION_DEFAULT, /* INDYCAM_RED_SATURATION */ |
| 62 | INDYCAM_BLUE_SATURATION_DEFAULT,/* INDYCAM_BLUE_SATURATION */ |
| 63 | }; |
| 64 | |
| 65 | /* IndyCam register handling */ |
| 66 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 67 | static int indycam_read_reg(struct i2c_client *client, u8 reg, u8 *value) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 68 | { |
| 69 | int ret; |
| 70 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 71 | if (reg == INDYCAM_REG_RESET) { |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 72 | dprintk("indycam_read_reg(): " |
| 73 | "skipping write-only register %d\n", reg); |
| 74 | *value = 0; |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | ret = i2c_smbus_read_byte_data(client, reg); |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 79 | |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 80 | if (ret < 0) { |
| 81 | printk(KERN_ERR "IndyCam: indycam_read_reg(): read failed, " |
| 82 | "register = 0x%02x\n", reg); |
| 83 | return ret; |
| 84 | } |
| 85 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 86 | *value = (u8)ret; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 91 | static int indycam_write_reg(struct i2c_client *client, u8 reg, u8 value) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 92 | { |
| 93 | int err; |
| 94 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 95 | if ((reg == INDYCAM_REG_BRIGHTNESS) |
| 96 | || (reg == INDYCAM_REG_VERSION)) { |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 97 | dprintk("indycam_write_reg(): " |
| 98 | "skipping read-only register %d\n", reg); |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | dprintk("Writing Reg %d = 0x%02x\n", reg, value); |
| 103 | err = i2c_smbus_write_byte_data(client, reg, value); |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 104 | |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 105 | if (err) { |
| 106 | printk(KERN_ERR "IndyCam: indycam_write_reg(): write failed, " |
| 107 | "register = 0x%02x, value = 0x%02x\n", reg, value); |
| 108 | } |
| 109 | return err; |
| 110 | } |
| 111 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 112 | static int indycam_write_block(struct i2c_client *client, u8 reg, |
| 113 | u8 length, u8 *data) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 114 | { |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 115 | int i, err; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 116 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 117 | for (i = 0; i < length; i++) { |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 118 | err = indycam_write_reg(client, reg + i, data[i]); |
| 119 | if (err) |
| 120 | return err; |
| 121 | } |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | /* Helper functions */ |
| 127 | |
| 128 | #ifdef INDYCAM_DEBUG |
| 129 | static void indycam_regdump_debug(struct i2c_client *client) |
| 130 | { |
| 131 | int i; |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 132 | u8 val; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 133 | |
| 134 | for (i = 0; i < 9; i++) { |
| 135 | indycam_read_reg(client, i, &val); |
| 136 | dprintk("Reg %d = 0x%02x\n", i, val); |
| 137 | } |
| 138 | } |
| 139 | #endif |
| 140 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 141 | static int indycam_get_control(struct i2c_client *client, |
| 142 | struct indycam_control *ctrl) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 143 | { |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 144 | struct indycam *camera = i2c_get_clientdata(client); |
| 145 | u8 reg; |
| 146 | int ret = 0; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 147 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 148 | switch (ctrl->type) { |
| 149 | case INDYCAM_CONTROL_AGC: |
| 150 | case INDYCAM_CONTROL_AWB: |
| 151 | ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, ®); |
| 152 | if (ret) |
| 153 | return -EIO; |
| 154 | if (ctrl->type == INDYCAM_CONTROL_AGC) |
| 155 | ctrl->value = (reg & INDYCAM_CONTROL_AGCENA) |
| 156 | ? 1 : 0; |
| 157 | else |
| 158 | ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL) |
| 159 | ? 1 : 0; |
| 160 | break; |
| 161 | case INDYCAM_CONTROL_SHUTTER: |
| 162 | ret = indycam_read_reg(client, INDYCAM_REG_SHUTTER, ®); |
| 163 | if (ret) |
| 164 | return -EIO; |
| 165 | ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1); |
| 166 | break; |
| 167 | case INDYCAM_CONTROL_GAIN: |
| 168 | ret = indycam_read_reg(client, INDYCAM_REG_GAIN, ®); |
| 169 | if (ret) |
| 170 | return -EIO; |
| 171 | ctrl->value = (s32)reg; |
| 172 | break; |
| 173 | case INDYCAM_CONTROL_RED_BALANCE: |
| 174 | ret = indycam_read_reg(client, INDYCAM_REG_RED_BALANCE, ®); |
| 175 | if (ret) |
| 176 | return -EIO; |
| 177 | ctrl->value = (s32)reg; |
| 178 | break; |
| 179 | case INDYCAM_CONTROL_BLUE_BALANCE: |
| 180 | ret = indycam_read_reg(client, INDYCAM_REG_BLUE_BALANCE, ®); |
| 181 | if (ret) |
| 182 | return -EIO; |
| 183 | ctrl->value = (s32)reg; |
| 184 | break; |
| 185 | case INDYCAM_CONTROL_RED_SATURATION: |
| 186 | ret = indycam_read_reg(client, |
| 187 | INDYCAM_REG_RED_SATURATION, ®); |
| 188 | if (ret) |
| 189 | return -EIO; |
| 190 | ctrl->value = (s32)reg; |
| 191 | break; |
| 192 | case INDYCAM_CONTROL_BLUE_SATURATION: |
| 193 | ret = indycam_read_reg(client, |
| 194 | INDYCAM_REG_BLUE_SATURATION, ®); |
| 195 | if (ret) |
| 196 | return -EIO; |
| 197 | ctrl->value = (s32)reg; |
| 198 | break; |
| 199 | case INDYCAM_CONTROL_GAMMA: |
| 200 | if (camera->version == CAMERA_VERSION_MOOSE) { |
| 201 | ret = indycam_read_reg(client, |
| 202 | INDYCAM_REG_GAMMA, ®); |
| 203 | if (ret) |
| 204 | return -EIO; |
| 205 | ctrl->value = (s32)reg; |
| 206 | } else { |
| 207 | ctrl->value = INDYCAM_GAMMA_DEFAULT; |
| 208 | } |
| 209 | break; |
| 210 | default: |
| 211 | ret = -EINVAL; |
| 212 | } |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 213 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 214 | return ret; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 217 | static int indycam_set_control(struct i2c_client *client, |
| 218 | struct indycam_control *ctrl) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 219 | { |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 220 | struct indycam *camera = i2c_get_clientdata(client); |
| 221 | u8 reg; |
| 222 | int ret = 0; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 223 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 224 | switch (ctrl->type) { |
| 225 | case INDYCAM_CONTROL_AGC: |
| 226 | case INDYCAM_CONTROL_AWB: |
| 227 | ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, ®); |
| 228 | if (ret) |
| 229 | break; |
| 230 | |
| 231 | if (ctrl->type == INDYCAM_CONTROL_AGC) { |
| 232 | if (ctrl->value) |
| 233 | reg |= INDYCAM_CONTROL_AGCENA; |
| 234 | else |
| 235 | reg &= ~INDYCAM_CONTROL_AGCENA; |
| 236 | } else { |
| 237 | if (ctrl->value) |
| 238 | reg |= INDYCAM_CONTROL_AWBCTL; |
| 239 | else |
| 240 | reg &= ~INDYCAM_CONTROL_AWBCTL; |
| 241 | } |
| 242 | |
| 243 | ret = indycam_write_reg(client, INDYCAM_REG_CONTROL, reg); |
| 244 | break; |
| 245 | case INDYCAM_CONTROL_SHUTTER: |
| 246 | reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1); |
| 247 | ret = indycam_write_reg(client, INDYCAM_REG_SHUTTER, reg); |
| 248 | break; |
| 249 | case INDYCAM_CONTROL_GAIN: |
| 250 | ret = indycam_write_reg(client, INDYCAM_REG_GAIN, ctrl->value); |
| 251 | break; |
| 252 | case INDYCAM_CONTROL_RED_BALANCE: |
| 253 | ret = indycam_write_reg(client, INDYCAM_REG_RED_BALANCE, |
| 254 | ctrl->value); |
| 255 | break; |
| 256 | case INDYCAM_CONTROL_BLUE_BALANCE: |
| 257 | ret = indycam_write_reg(client, INDYCAM_REG_BLUE_BALANCE, |
| 258 | ctrl->value); |
| 259 | break; |
| 260 | case INDYCAM_CONTROL_RED_SATURATION: |
| 261 | ret = indycam_write_reg(client, INDYCAM_REG_RED_SATURATION, |
| 262 | ctrl->value); |
| 263 | break; |
| 264 | case INDYCAM_CONTROL_BLUE_SATURATION: |
| 265 | ret = indycam_write_reg(client, INDYCAM_REG_BLUE_SATURATION, |
| 266 | ctrl->value); |
| 267 | break; |
| 268 | case INDYCAM_CONTROL_GAMMA: |
| 269 | if (camera->version == CAMERA_VERSION_MOOSE) { |
| 270 | ret = indycam_write_reg(client, INDYCAM_REG_GAMMA, |
| 271 | ctrl->value); |
| 272 | } |
| 273 | break; |
| 274 | default: |
| 275 | ret = -EINVAL; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 276 | } |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 277 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 278 | return ret; |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /* I2C-interface */ |
| 282 | |
| 283 | static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) |
| 284 | { |
| 285 | int err = 0; |
| 286 | struct indycam *camera; |
| 287 | struct i2c_client *client; |
| 288 | |
| 289 | printk(KERN_INFO "SGI IndyCam driver version %s\n", |
| 290 | INDYCAM_MODULE_VERSION); |
| 291 | |
| 292 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); |
| 293 | if (!client) |
| 294 | return -ENOMEM; |
| 295 | camera = kmalloc(sizeof(struct indycam), GFP_KERNEL); |
| 296 | if (!camera) { |
| 297 | err = -ENOMEM; |
| 298 | goto out_free_client; |
| 299 | } |
| 300 | |
| 301 | memset(client, 0, sizeof(struct i2c_client)); |
| 302 | memset(camera, 0, sizeof(struct indycam)); |
| 303 | |
| 304 | client->addr = addr; |
| 305 | client->adapter = adap; |
| 306 | client->driver = &i2c_driver_indycam; |
| 307 | client->flags = 0; |
| 308 | strcpy(client->name, "IndyCam client"); |
| 309 | i2c_set_clientdata(client, camera); |
| 310 | |
| 311 | camera->client = client; |
| 312 | |
| 313 | err = i2c_attach_client(client); |
| 314 | if (err) |
| 315 | goto out_free_camera; |
| 316 | |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 317 | camera->version = i2c_smbus_read_byte_data(client, |
| 318 | INDYCAM_REG_VERSION); |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 319 | if (camera->version != CAMERA_VERSION_INDY && |
| 320 | camera->version != CAMERA_VERSION_MOOSE) { |
| 321 | err = -ENODEV; |
| 322 | goto out_detach_client; |
| 323 | } |
| 324 | printk(KERN_INFO "IndyCam v%d.%d detected\n", |
| 325 | INDYCAM_VERSION_MAJOR(camera->version), |
| 326 | INDYCAM_VERSION_MINOR(camera->version)); |
| 327 | |
| 328 | indycam_regdump(client); |
| 329 | |
| 330 | // initialize |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 331 | err = indycam_write_block(client, 0, sizeof(initseq), (u8 *)&initseq); |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 332 | if (err) { |
| 333 | printk(KERN_ERR "IndyCam initalization failed\n"); |
| 334 | err = -EIO; |
| 335 | goto out_detach_client; |
| 336 | } |
| 337 | |
| 338 | indycam_regdump(client); |
| 339 | |
| 340 | // white balance |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 341 | err = indycam_write_reg(client, INDYCAM_REG_CONTROL, |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 342 | INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL); |
| 343 | if (err) { |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 344 | printk(KERN_ERR "IndyCam: White balancing camera failed\n"); |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 345 | err = -EIO; |
| 346 | goto out_detach_client; |
| 347 | } |
| 348 | |
| 349 | indycam_regdump(client); |
| 350 | |
| 351 | printk(KERN_INFO "IndyCam initialized\n"); |
| 352 | |
| 353 | return 0; |
| 354 | |
| 355 | out_detach_client: |
| 356 | i2c_detach_client(client); |
| 357 | out_free_camera: |
| 358 | kfree(camera); |
| 359 | out_free_client: |
| 360 | kfree(client); |
| 361 | return err; |
| 362 | } |
| 363 | |
| 364 | static int indycam_probe(struct i2c_adapter *adap) |
| 365 | { |
| 366 | /* Indy specific crap */ |
Ladislav Michl | 495515b | 2005-09-23 10:52:27 +0000 | [diff] [blame] | 367 | if (adap->id == I2C_HW_SGI_VINO) |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 368 | return indycam_attach(adap, INDYCAM_ADDR, 0); |
| 369 | /* Feel free to add probe here :-) */ |
| 370 | return -ENODEV; |
| 371 | } |
| 372 | |
| 373 | static int indycam_detach(struct i2c_client *client) |
| 374 | { |
| 375 | struct indycam *camera = i2c_get_clientdata(client); |
| 376 | |
| 377 | i2c_detach_client(client); |
| 378 | kfree(camera); |
| 379 | kfree(client); |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | static int indycam_command(struct i2c_client *client, unsigned int cmd, |
| 384 | void *arg) |
| 385 | { |
| 386 | // struct indycam *camera = i2c_get_clientdata(client); |
| 387 | |
| 388 | /* The old video_decoder interface just isn't enough, |
| 389 | * so we'll use some custom commands. */ |
| 390 | switch (cmd) { |
| 391 | case DECODER_GET_CAPABILITIES: { |
| 392 | struct video_decoder_capability *cap = arg; |
| 393 | |
| 394 | cap->flags = VIDEO_DECODER_NTSC; |
| 395 | cap->inputs = 1; |
| 396 | cap->outputs = 1; |
| 397 | break; |
| 398 | } |
| 399 | case DECODER_GET_STATUS: { |
| 400 | int *iarg = arg; |
| 401 | |
| 402 | *iarg = DECODER_STATUS_GOOD | DECODER_STATUS_NTSC | |
| 403 | DECODER_STATUS_COLOR; |
| 404 | break; |
| 405 | } |
| 406 | case DECODER_SET_NORM: { |
| 407 | int *iarg = arg; |
| 408 | |
| 409 | switch (*iarg) { |
| 410 | case VIDEO_MODE_NTSC: |
| 411 | break; |
| 412 | default: |
| 413 | return -EINVAL; |
| 414 | } |
| 415 | break; |
| 416 | } |
| 417 | case DECODER_SET_INPUT: { |
| 418 | int *iarg = arg; |
| 419 | |
| 420 | if (*iarg != 0) |
| 421 | return -EINVAL; |
| 422 | break; |
| 423 | } |
| 424 | case DECODER_SET_OUTPUT: { |
| 425 | int *iarg = arg; |
| 426 | |
| 427 | if (*iarg != 0) |
| 428 | return -EINVAL; |
| 429 | break; |
| 430 | } |
| 431 | case DECODER_ENABLE_OUTPUT: { |
| 432 | /* Always enabled */ |
| 433 | break; |
| 434 | } |
| 435 | case DECODER_SET_PICTURE: { |
| 436 | // struct video_picture *pic = arg; |
| 437 | /* TODO: convert values for indycam_set_controls() */ |
| 438 | break; |
| 439 | } |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 440 | case DECODER_INDYCAM_GET_CONTROL: { |
| 441 | return indycam_get_control(client, arg); |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 442 | } |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 443 | case DECODER_INDYCAM_SET_CONTROL: { |
| 444 | return indycam_set_control(client, arg); |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 445 | } |
| 446 | default: |
| 447 | return -EINVAL; |
| 448 | } |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | static struct i2c_driver i2c_driver_indycam = { |
Laurent Riffard | 604f28e | 2005-11-26 20:43:39 +0100 | [diff] [blame^] | 454 | .driver = { |
| 455 | .owner = THIS_MODULE, |
| 456 | .name = "indycam", |
| 457 | }, |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 458 | .id = I2C_DRIVERID_INDYCAM, |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 459 | .attach_adapter = indycam_probe, |
Ladislav Michl | a637a11 | 2005-09-01 15:07:34 +0000 | [diff] [blame] | 460 | .detach_client = indycam_detach, |
| 461 | .command = indycam_command, |
Ralf Baechle | d203a7e | 2005-09-06 15:19:37 -0700 | [diff] [blame] | 462 | }; |
| 463 | |
| 464 | static int __init indycam_init(void) |
| 465 | { |
| 466 | return i2c_add_driver(&i2c_driver_indycam); |
| 467 | } |
| 468 | |
| 469 | static void __exit indycam_exit(void) |
| 470 | { |
| 471 | i2c_del_driver(&i2c_driver_indycam); |
| 472 | } |
| 473 | |
| 474 | module_init(indycam_init); |
| 475 | module_exit(indycam_exit); |