Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (10861): vino/indycam/saa7191: convert to i2c modules to V4L2.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
cf4e9484 babb7dc7

+256 -647
+75 -157
drivers/media/video/indycam.c
··· 19 19 #include <linux/mm.h> 20 20 #include <linux/slab.h> 21 21 22 - #include <linux/videodev.h> 23 22 /* IndyCam decodes stream of photons into digital image representation ;-) */ 24 - #include <linux/video_decoder.h> 23 + #include <linux/videodev2.h> 25 24 #include <linux/i2c.h> 25 + #include <media/v4l2-common.h> 26 + #include <media/v4l2-i2c-drv-legacy.h> 26 27 27 28 #include "indycam.h" 28 29 ··· 33 32 MODULE_VERSION(INDYCAM_MODULE_VERSION); 34 33 MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); 35 34 MODULE_LICENSE("GPL"); 35 + 36 + static unsigned short normal_i2c[] = { 0x56 >> 1, I2C_CLIENT_END }; 37 + 38 + I2C_CLIENT_INSMOD; 36 39 37 40 // #define INDYCAM_DEBUG 38 41 ··· 52 47 struct i2c_client *client; 53 48 u8 version; 54 49 }; 55 - 56 - static struct i2c_driver i2c_driver_indycam; 57 50 58 51 static const u8 initseq[] = { 59 52 INDYCAM_CONTROL_AGCENA, /* INDYCAM_CONTROL */ ··· 141 138 #endif 142 139 143 140 static int indycam_get_control(struct i2c_client *client, 144 - struct indycam_control *ctrl) 141 + struct v4l2_control *ctrl) 145 142 { 146 143 struct indycam *camera = i2c_get_clientdata(client); 147 144 u8 reg; 148 145 int ret = 0; 149 146 150 - switch (ctrl->type) { 151 - case INDYCAM_CONTROL_AGC: 152 - case INDYCAM_CONTROL_AWB: 147 + switch (ctrl->id) { 148 + case V4L2_CID_AUTOGAIN: 149 + case V4L2_CID_AUTO_WHITE_BALANCE: 153 150 ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg); 154 151 if (ret) 155 152 return -EIO; 156 - if (ctrl->type == INDYCAM_CONTROL_AGC) 153 + if (ctrl->id == V4L2_CID_AUTOGAIN) 157 154 ctrl->value = (reg & INDYCAM_CONTROL_AGCENA) 158 155 ? 1 : 0; 159 156 else 160 157 ctrl->value = (reg & INDYCAM_CONTROL_AWBCTL) 161 158 ? 1 : 0; 162 159 break; 163 - case INDYCAM_CONTROL_SHUTTER: 160 + case V4L2_CID_EXPOSURE: 164 161 ret = indycam_read_reg(client, INDYCAM_REG_SHUTTER, &reg); 165 162 if (ret) 166 163 return -EIO; 167 164 ctrl->value = ((s32)reg == 0x00) ? 0xff : ((s32)reg - 1); 168 165 break; 169 - case INDYCAM_CONTROL_GAIN: 166 + case V4L2_CID_GAIN: 170 167 ret = indycam_read_reg(client, INDYCAM_REG_GAIN, &reg); 171 168 if (ret) 172 169 return -EIO; 173 170 ctrl->value = (s32)reg; 174 171 break; 175 - case INDYCAM_CONTROL_RED_BALANCE: 172 + case V4L2_CID_RED_BALANCE: 176 173 ret = indycam_read_reg(client, INDYCAM_REG_RED_BALANCE, &reg); 177 174 if (ret) 178 175 return -EIO; 179 176 ctrl->value = (s32)reg; 180 177 break; 181 - case INDYCAM_CONTROL_BLUE_BALANCE: 178 + case V4L2_CID_BLUE_BALANCE: 182 179 ret = indycam_read_reg(client, INDYCAM_REG_BLUE_BALANCE, &reg); 183 180 if (ret) 184 181 return -EIO; ··· 198 195 return -EIO; 199 196 ctrl->value = (s32)reg; 200 197 break; 201 - case INDYCAM_CONTROL_GAMMA: 198 + case V4L2_CID_GAMMA: 202 199 if (camera->version == CAMERA_VERSION_MOOSE) { 203 200 ret = indycam_read_reg(client, 204 201 INDYCAM_REG_GAMMA, &reg); ··· 217 214 } 218 215 219 216 static int indycam_set_control(struct i2c_client *client, 220 - struct indycam_control *ctrl) 217 + struct v4l2_control *ctrl) 221 218 { 222 219 struct indycam *camera = i2c_get_clientdata(client); 223 220 u8 reg; 224 221 int ret = 0; 225 222 226 - switch (ctrl->type) { 227 - case INDYCAM_CONTROL_AGC: 228 - case INDYCAM_CONTROL_AWB: 223 + switch (ctrl->id) { 224 + case V4L2_CID_AUTOGAIN: 225 + case V4L2_CID_AUTO_WHITE_BALANCE: 229 226 ret = indycam_read_reg(client, INDYCAM_REG_CONTROL, &reg); 230 227 if (ret) 231 228 break; 232 229 233 - if (ctrl->type == INDYCAM_CONTROL_AGC) { 230 + if (ctrl->id == V4L2_CID_AUTOGAIN) { 234 231 if (ctrl->value) 235 232 reg |= INDYCAM_CONTROL_AGCENA; 236 233 else ··· 244 241 245 242 ret = indycam_write_reg(client, INDYCAM_REG_CONTROL, reg); 246 243 break; 247 - case INDYCAM_CONTROL_SHUTTER: 244 + case V4L2_CID_EXPOSURE: 248 245 reg = (ctrl->value == 0xff) ? 0x00 : (ctrl->value + 1); 249 246 ret = indycam_write_reg(client, INDYCAM_REG_SHUTTER, reg); 250 247 break; 251 - case INDYCAM_CONTROL_GAIN: 248 + case V4L2_CID_GAIN: 252 249 ret = indycam_write_reg(client, INDYCAM_REG_GAIN, ctrl->value); 253 250 break; 254 - case INDYCAM_CONTROL_RED_BALANCE: 251 + case V4L2_CID_RED_BALANCE: 255 252 ret = indycam_write_reg(client, INDYCAM_REG_RED_BALANCE, 256 253 ctrl->value); 257 254 break; 258 - case INDYCAM_CONTROL_BLUE_BALANCE: 255 + case V4L2_CID_BLUE_BALANCE: 259 256 ret = indycam_write_reg(client, INDYCAM_REG_BLUE_BALANCE, 260 257 ctrl->value); 261 258 break; ··· 267 264 ret = indycam_write_reg(client, INDYCAM_REG_BLUE_SATURATION, 268 265 ctrl->value); 269 266 break; 270 - case INDYCAM_CONTROL_GAMMA: 267 + case V4L2_CID_GAMMA: 271 268 if (camera->version == CAMERA_VERSION_MOOSE) { 272 269 ret = indycam_write_reg(client, INDYCAM_REG_GAMMA, 273 270 ctrl->value); ··· 282 279 283 280 /* I2C-interface */ 284 281 285 - static int indycam_attach(struct i2c_adapter *adap, int addr, int kind) 282 + static int indycam_command(struct i2c_client *client, unsigned int cmd, 283 + void *arg) 284 + { 285 + /* The old video_decoder interface just isn't enough, 286 + * so we'll use some custom commands. */ 287 + switch (cmd) { 288 + case VIDIOC_G_CTRL: 289 + return indycam_get_control(client, arg); 290 + 291 + case VIDIOC_S_CTRL: 292 + return indycam_set_control(client, arg); 293 + 294 + default: 295 + return -EINVAL; 296 + } 297 + 298 + return 0; 299 + } 300 + 301 + static int indycam_probe(struct i2c_client *client, 302 + const struct i2c_device_id *id) 286 303 { 287 304 int err = 0; 288 305 struct indycam *camera; 289 - struct i2c_client *client; 290 306 291 - printk(KERN_INFO "SGI IndyCam driver version %s\n", 292 - INDYCAM_MODULE_VERSION); 307 + v4l_info(client, "chip found @ 0x%x (%s)\n", 308 + client->addr << 1, client->adapter->name); 293 309 294 - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 295 - if (!client) 296 - return -ENOMEM; 297 310 camera = kzalloc(sizeof(struct indycam), GFP_KERNEL); 298 - if (!camera) { 299 - err = -ENOMEM; 300 - goto out_free_client; 301 - } 311 + if (!camera) 312 + return -ENOMEM; 302 313 303 - client->addr = addr; 304 - client->adapter = adap; 305 - client->driver = &i2c_driver_indycam; 306 - client->flags = 0; 307 - strcpy(client->name, "IndyCam client"); 308 314 i2c_set_clientdata(client, camera); 309 315 310 316 camera->client = client; 311 - 312 - err = i2c_attach_client(client); 313 - if (err) 314 - goto out_free_camera; 315 317 316 318 camera->version = i2c_smbus_read_byte_data(client, 317 319 INDYCAM_REG_VERSION); 318 320 if (camera->version != CAMERA_VERSION_INDY && 319 321 camera->version != CAMERA_VERSION_MOOSE) { 320 - err = -ENODEV; 321 - goto out_detach_client; 322 + kfree(camera); 323 + return -ENODEV; 322 324 } 325 + 323 326 printk(KERN_INFO "IndyCam v%d.%d detected\n", 324 327 INDYCAM_VERSION_MAJOR(camera->version), 325 328 INDYCAM_VERSION_MINOR(camera->version)); ··· 336 327 err = indycam_write_block(client, 0, sizeof(initseq), (u8 *)&initseq); 337 328 if (err) { 338 329 printk(KERN_ERR "IndyCam initialization failed\n"); 339 - err = -EIO; 340 - goto out_detach_client; 330 + kfree(camera); 331 + return -EIO; 341 332 } 342 333 343 334 indycam_regdump(client); ··· 347 338 INDYCAM_CONTROL_AGCENA | INDYCAM_CONTROL_AWBCTL); 348 339 if (err) { 349 340 printk(KERN_ERR "IndyCam: White balancing camera failed\n"); 350 - err = -EIO; 351 - goto out_detach_client; 341 + kfree(camera); 342 + return -EIO; 352 343 } 353 344 354 345 indycam_regdump(client); ··· 356 347 printk(KERN_INFO "IndyCam initialized\n"); 357 348 358 349 return 0; 359 - 360 - out_detach_client: 361 - i2c_detach_client(client); 362 - out_free_camera: 363 - kfree(camera); 364 - out_free_client: 365 - kfree(client); 366 - return err; 367 350 } 368 351 369 - static int indycam_probe(struct i2c_adapter *adap) 370 - { 371 - /* Indy specific crap */ 372 - if (adap->id == I2C_HW_SGI_VINO) 373 - return indycam_attach(adap, INDYCAM_ADDR, 0); 374 - /* Feel free to add probe here :-) */ 375 - return -ENODEV; 376 - } 377 - 378 - static int indycam_detach(struct i2c_client *client) 352 + static int indycam_remove(struct i2c_client *client) 379 353 { 380 354 struct indycam *camera = i2c_get_clientdata(client); 381 355 382 - i2c_detach_client(client); 383 356 kfree(camera); 384 - kfree(client); 385 357 return 0; 386 358 } 387 359 388 - static int indycam_command(struct i2c_client *client, unsigned int cmd, 389 - void *arg) 360 + static int indycam_legacy_probe(struct i2c_adapter *adapter) 390 361 { 391 - // struct indycam *camera = i2c_get_clientdata(client); 392 - 393 - /* The old video_decoder interface just isn't enough, 394 - * so we'll use some custom commands. */ 395 - switch (cmd) { 396 - case DECODER_GET_CAPABILITIES: { 397 - struct video_decoder_capability *cap = arg; 398 - 399 - cap->flags = VIDEO_DECODER_NTSC; 400 - cap->inputs = 1; 401 - cap->outputs = 1; 402 - break; 403 - } 404 - case DECODER_GET_STATUS: { 405 - int *iarg = arg; 406 - 407 - *iarg = DECODER_STATUS_GOOD | DECODER_STATUS_NTSC | 408 - DECODER_STATUS_COLOR; 409 - break; 410 - } 411 - case DECODER_SET_NORM: { 412 - int *iarg = arg; 413 - 414 - switch (*iarg) { 415 - case VIDEO_MODE_NTSC: 416 - break; 417 - default: 418 - return -EINVAL; 419 - } 420 - break; 421 - } 422 - case DECODER_SET_INPUT: { 423 - int *iarg = arg; 424 - 425 - if (*iarg != 0) 426 - return -EINVAL; 427 - break; 428 - } 429 - case DECODER_SET_OUTPUT: { 430 - int *iarg = arg; 431 - 432 - if (*iarg != 0) 433 - return -EINVAL; 434 - break; 435 - } 436 - case DECODER_ENABLE_OUTPUT: { 437 - /* Always enabled */ 438 - break; 439 - } 440 - case DECODER_SET_PICTURE: { 441 - // struct video_picture *pic = arg; 442 - /* TODO: convert values for indycam_set_controls() */ 443 - break; 444 - } 445 - case DECODER_INDYCAM_GET_CONTROL: { 446 - return indycam_get_control(client, arg); 447 - } 448 - case DECODER_INDYCAM_SET_CONTROL: { 449 - return indycam_set_control(client, arg); 450 - } 451 - default: 452 - return -EINVAL; 453 - } 454 - 455 - return 0; 362 + return adapter->id == I2C_HW_SGI_VINO; 456 363 } 457 364 458 - static struct i2c_driver i2c_driver_indycam = { 459 - .driver = { 460 - .name = "indycam", 461 - }, 462 - .id = I2C_DRIVERID_INDYCAM, 463 - .attach_adapter = indycam_probe, 464 - .detach_client = indycam_detach, 465 - .command = indycam_command, 365 + static const struct i2c_device_id indycam_id[] = { 366 + { "indycam", 0 }, 367 + { } 466 368 }; 369 + MODULE_DEVICE_TABLE(i2c, indycam_id); 467 370 468 - static int __init indycam_init(void) 469 - { 470 - return i2c_add_driver(&i2c_driver_indycam); 471 - } 472 - 473 - static void __exit indycam_exit(void) 474 - { 475 - i2c_del_driver(&i2c_driver_indycam); 476 - } 477 - 478 - module_init(indycam_init); 479 - module_exit(indycam_exit); 371 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 372 + .name = "indycam", 373 + .driverid = I2C_DRIVERID_INDYCAM, 374 + .command = indycam_command, 375 + .probe = indycam_probe, 376 + .remove = indycam_remove, 377 + .legacy_probe = indycam_legacy_probe, 378 + .id_table = indycam_id, 379 + };
+2 -17
drivers/media/video/indycam.h
··· 87 87 88 88 /* Driver interface definitions */ 89 89 90 - #define INDYCAM_CONTROL_AGC 0 /* boolean */ 91 - #define INDYCAM_CONTROL_AWB 1 /* boolean */ 92 - #define INDYCAM_CONTROL_SHUTTER 2 93 - #define INDYCAM_CONTROL_GAIN 3 94 - #define INDYCAM_CONTROL_RED_BALANCE 4 95 - #define INDYCAM_CONTROL_BLUE_BALANCE 5 96 - #define INDYCAM_CONTROL_RED_SATURATION 6 97 - #define INDYCAM_CONTROL_BLUE_SATURATION 7 98 - #define INDYCAM_CONTROL_GAMMA 8 99 - 100 - struct indycam_control { 101 - u8 type; 102 - s32 value; 103 - }; 104 - 105 - #define DECODER_INDYCAM_GET_CONTROL _IOR('d', 193, struct indycam_control) 106 - #define DECODER_INDYCAM_SET_CONTROL _IOW('d', 194, struct indycam_control) 90 + #define INDYCAM_CONTROL_RED_SATURATION (V4L2_CID_PRIVATE_BASE + 0) 91 + #define INDYCAM_CONTROL_BLUE_SATURATION (V4L2_CID_PRIVATE_BASE + 1) 107 92 108 93 #endif
+58 -172
drivers/media/video/saa7191.c
··· 19 19 #include <linux/mm.h> 20 20 #include <linux/slab.h> 21 21 22 - #include <linux/videodev.h> 23 - #include <linux/video_decoder.h> 22 + #include <linux/videodev2.h> 24 23 #include <linux/i2c.h> 25 24 #include <media/v4l2-common.h> 26 25 #include <media/v4l2-i2c-drv-legacy.h> ··· 56 57 u8 reg[25]; 57 58 58 59 int input; 59 - int norm; 60 + v4l2_std_id norm; 60 61 }; 61 62 62 63 static const u8 initseq[] = { ··· 190 191 return 0; 191 192 } 192 193 193 - static int saa7191_set_norm(struct i2c_client *client, int norm) 194 + static int saa7191_set_norm(struct i2c_client *client, v4l2_std_id norm) 194 195 { 195 196 struct saa7191 *decoder = i2c_get_clientdata(client); 196 197 u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC); ··· 198 199 u8 chcv = saa7191_read_reg(client, SAA7191_REG_CHCV); 199 200 int err; 200 201 201 - switch(norm) { 202 - case SAA7191_NORM_PAL: 202 + if (norm & V4L2_STD_PAL) { 203 203 stdc &= ~SAA7191_STDC_SECS; 204 204 ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL); 205 205 chcv = SAA7191_CHCV_PAL; 206 - break; 207 - case SAA7191_NORM_NTSC: 206 + } else if (norm & V4L2_STD_NTSC) { 208 207 stdc &= ~SAA7191_STDC_SECS; 209 208 ctl3 &= ~SAA7191_CTL3_AUFD; 210 209 ctl3 |= SAA7191_CTL3_FSEL; 211 210 chcv = SAA7191_CHCV_NTSC; 212 - break; 213 - case SAA7191_NORM_SECAM: 211 + } else if (norm & V4L2_STD_SECAM) { 214 212 stdc |= SAA7191_STDC_SECS; 215 213 ctl3 &= ~(SAA7191_CTL3_AUFD | SAA7191_CTL3_FSEL); 216 214 chcv = SAA7191_CHCV_PAL; 217 - break; 218 - default: 215 + } else { 219 216 return -EINVAL; 220 217 } 221 218 ··· 229 234 230 235 dprintk("ctl3: %02x stdc: %02x chcv: %02x\n", ctl3, 231 236 stdc, chcv); 232 - dprintk("norm: %d\n", norm); 237 + dprintk("norm: %llx\n", norm); 233 238 234 239 return 0; 235 240 } ··· 257 262 return -EBUSY; 258 263 } 259 264 260 - static int saa7191_autodetect_norm_extended(struct i2c_client *client) 265 + static int saa7191_autodetect_norm_extended(struct i2c_client *client, 266 + v4l2_std_id *norm) 261 267 { 268 + struct saa7191 *decoder = i2c_get_clientdata(client); 262 269 u8 stdc = saa7191_read_reg(client, SAA7191_REG_STDC); 263 270 u8 ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3); 264 271 u8 status; 272 + v4l2_std_id old_norm = decoder->norm; 265 273 int err = 0; 266 274 267 275 dprintk("SAA7191 extended signal auto-detection...\n"); 268 276 277 + *norm = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; 269 278 stdc &= ~SAA7191_STDC_SECS; 270 279 ctl3 &= ~(SAA7191_CTL3_FSEL); 271 280 ··· 300 301 if (status & SAA7191_STATUS_FIDT) { 301 302 /* 60Hz signal -> NTSC */ 302 303 dprintk("60Hz signal: NTSC\n"); 303 - return saa7191_set_norm(client, SAA7191_NORM_NTSC); 304 + *norm = V4L2_STD_NTSC; 305 + return 0; 304 306 } 305 307 306 308 /* 50Hz signal */ 307 309 dprintk("50Hz signal: Trying PAL...\n"); 308 310 309 311 /* try PAL first */ 310 - err = saa7191_set_norm(client, SAA7191_NORM_PAL); 312 + err = saa7191_set_norm(client, V4L2_STD_PAL); 311 313 if (err) 312 314 goto out; 313 315 ··· 321 321 /* not 50Hz ? */ 322 322 if (status & SAA7191_STATUS_FIDT) { 323 323 dprintk("No 50Hz signal\n"); 324 - err = -EAGAIN; 325 - goto out; 324 + saa7191_set_norm(client, old_norm); 325 + return -EAGAIN; 326 326 } 327 327 328 328 if (status & SAA7191_STATUS_CODE) { 329 329 dprintk("PAL\n"); 330 - return 0; 330 + *norm = V4L2_STD_PAL; 331 + return saa7191_set_norm(client, old_norm); 331 332 } 332 333 333 334 dprintk("No color detected with PAL - Trying SECAM...\n"); 334 335 335 336 /* no color detected ? -> try SECAM */ 336 - err = saa7191_set_norm(client, 337 - SAA7191_NORM_SECAM); 337 + err = saa7191_set_norm(client, V4L2_STD_SECAM); 338 338 if (err) 339 339 goto out; 340 340 ··· 354 354 if (status & SAA7191_STATUS_CODE) { 355 355 /* Color detected -> SECAM */ 356 356 dprintk("SECAM\n"); 357 - return 0; 357 + *norm = V4L2_STD_SECAM; 358 + return saa7191_set_norm(client, old_norm); 358 359 } 359 360 360 361 dprintk("No color detected with SECAM - Going back to PAL.\n"); 361 362 362 - /* still no color detected ? 363 - * -> set norm back to PAL */ 364 - err = saa7191_set_norm(client, 365 - SAA7191_NORM_PAL); 366 - if (err) 367 - goto out; 368 - 369 363 out: 370 - ctl3 = saa7191_read_reg(client, SAA7191_REG_CTL3); 371 - if (ctl3 & SAA7191_CTL3_AUFD) { 372 - ctl3 &= ~(SAA7191_CTL3_AUFD); 373 - err = saa7191_write_reg(client, SAA7191_REG_CTL3, ctl3); 374 - if (err) { 375 - err = -EIO; 376 - } 377 - } 378 - 379 - return err; 364 + return saa7191_set_norm(client, old_norm); 380 365 } 381 366 382 367 static int saa7191_autodetect_norm(struct i2c_client *client) ··· 388 403 if (status & SAA7191_STATUS_FIDT) { 389 404 /* 60hz signal -> NTSC */ 390 405 dprintk("NTSC\n"); 391 - return saa7191_set_norm(client, SAA7191_NORM_NTSC); 406 + return saa7191_set_norm(client, V4L2_STD_NTSC); 392 407 } else { 393 408 /* 50hz signal -> PAL */ 394 409 dprintk("PAL\n"); 395 - return saa7191_set_norm(client, SAA7191_NORM_PAL); 410 + return saa7191_set_norm(client, V4L2_STD_PAL); 396 411 } 397 412 } 398 413 399 414 static int saa7191_get_control(struct i2c_client *client, 400 - struct saa7191_control *ctrl) 415 + struct v4l2_control *ctrl) 401 416 { 402 417 u8 reg; 403 418 int ret = 0; 404 419 405 - switch (ctrl->type) { 420 + switch (ctrl->id) { 406 421 case SAA7191_CONTROL_BANDPASS: 407 422 case SAA7191_CONTROL_BANDPASS_WEIGHT: 408 423 case SAA7191_CONTROL_CORING: 409 424 reg = saa7191_read_reg(client, SAA7191_REG_LUMA); 410 - switch (ctrl->type) { 425 + switch (ctrl->id) { 411 426 case SAA7191_CONTROL_BANDPASS: 412 427 ctrl->value = ((s32)reg & SAA7191_LUMA_BPSS_MASK) 413 428 >> SAA7191_LUMA_BPSS_SHIFT; ··· 425 440 case SAA7191_CONTROL_FORCE_COLOUR: 426 441 case SAA7191_CONTROL_CHROMA_GAIN: 427 442 reg = saa7191_read_reg(client, SAA7191_REG_GAIN); 428 - if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR) 443 + if (ctrl->id == SAA7191_CONTROL_FORCE_COLOUR) 429 444 ctrl->value = ((s32)reg & SAA7191_GAIN_COLO) ? 1 : 0; 430 445 else 431 446 ctrl->value = ((s32)reg & SAA7191_GAIN_LFIS_MASK) 432 447 >> SAA7191_GAIN_LFIS_SHIFT; 433 448 break; 434 - case SAA7191_CONTROL_HUE: 449 + case V4L2_CID_HUE: 435 450 reg = saa7191_read_reg(client, SAA7191_REG_HUEC); 436 451 if (reg < 0x80) 437 452 reg += 0x80; ··· 463 478 } 464 479 465 480 static int saa7191_set_control(struct i2c_client *client, 466 - struct saa7191_control *ctrl) 481 + struct v4l2_control *ctrl) 467 482 { 468 483 u8 reg; 469 484 int ret = 0; 470 485 471 - switch (ctrl->type) { 486 + switch (ctrl->id) { 472 487 case SAA7191_CONTROL_BANDPASS: 473 488 case SAA7191_CONTROL_BANDPASS_WEIGHT: 474 489 case SAA7191_CONTROL_CORING: 475 490 reg = saa7191_read_reg(client, SAA7191_REG_LUMA); 476 - switch (ctrl->type) { 491 + switch (ctrl->id) { 477 492 case SAA7191_CONTROL_BANDPASS: 478 493 reg &= ~SAA7191_LUMA_BPSS_MASK; 479 494 reg |= (ctrl->value << SAA7191_LUMA_BPSS_SHIFT) ··· 495 510 case SAA7191_CONTROL_FORCE_COLOUR: 496 511 case SAA7191_CONTROL_CHROMA_GAIN: 497 512 reg = saa7191_read_reg(client, SAA7191_REG_GAIN); 498 - if (ctrl->type == SAA7191_CONTROL_FORCE_COLOUR) { 513 + if (ctrl->id == SAA7191_CONTROL_FORCE_COLOUR) { 499 514 if (ctrl->value) 500 515 reg |= SAA7191_GAIN_COLO; 501 516 else ··· 507 522 } 508 523 ret = saa7191_write_reg(client, SAA7191_REG_GAIN, reg); 509 524 break; 510 - case SAA7191_CONTROL_HUE: 525 + case V4L2_CID_HUE: 511 526 reg = ctrl->value & 0xff; 512 527 if (reg < 0x80) 513 528 reg += 0x80; ··· 553 568 static int saa7191_command(struct i2c_client *client, unsigned int cmd, 554 569 void *arg) 555 570 { 556 - struct saa7191 *decoder = i2c_get_clientdata(client); 557 - 558 571 switch (cmd) { 559 - case DECODER_GET_CAPABILITIES: { 560 - struct video_decoder_capability *cap = arg; 561 - 562 - cap->flags = VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC | 563 - VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; 564 - cap->inputs = (client->adapter->id == I2C_HW_SGI_VINO) ? 2 : 1; 565 - cap->outputs = 1; 566 - break; 567 - } 568 - case DECODER_GET_STATUS: { 569 - int *iarg = arg; 572 + case VIDIOC_INT_G_INPUT_STATUS: { 573 + u32 *iarg = arg; 570 574 u8 status; 571 - int res = 0; 575 + int res = V4L2_IN_ST_NO_SIGNAL; 572 576 573 - if (saa7191_read_status(client, &status)) { 577 + if (saa7191_read_status(client, &status)) 574 578 return -EIO; 575 - } 576 579 if ((status & SAA7191_STATUS_HLCK) == 0) 577 - res |= DECODER_STATUS_GOOD; 578 - if (status & SAA7191_STATUS_CODE) 579 - res |= DECODER_STATUS_COLOR; 580 - switch (decoder->norm) { 581 - case SAA7191_NORM_NTSC: 582 - res |= DECODER_STATUS_NTSC; 583 - break; 584 - case SAA7191_NORM_PAL: 585 - res |= DECODER_STATUS_PAL; 586 - break; 587 - case SAA7191_NORM_SECAM: 588 - res |= DECODER_STATUS_SECAM; 589 - break; 590 - case SAA7191_NORM_AUTO: 591 - default: 592 - if (status & SAA7191_STATUS_FIDT) 593 - res |= DECODER_STATUS_NTSC; 594 - else 595 - res |= DECODER_STATUS_PAL; 596 - break; 597 - } 580 + res = 0; 581 + if (!(status & SAA7191_STATUS_CODE)) 582 + res |= V4L2_IN_ST_NO_COLOR; 598 583 *iarg = res; 599 584 break; 600 585 } 601 - case DECODER_SET_NORM: { 602 - int *iarg = arg; 603 586 604 - switch (*iarg) { 605 - case VIDEO_MODE_AUTO: 606 - return saa7191_autodetect_norm(client); 607 - case VIDEO_MODE_PAL: 608 - return saa7191_set_norm(client, SAA7191_NORM_PAL); 609 - case VIDEO_MODE_NTSC: 610 - return saa7191_set_norm(client, SAA7191_NORM_NTSC); 611 - case VIDEO_MODE_SECAM: 612 - return saa7191_set_norm(client, SAA7191_NORM_SECAM); 613 - default: 614 - return -EINVAL; 615 - } 616 - break; 587 + case VIDIOC_QUERYSTD: 588 + return saa7191_autodetect_norm_extended(client, arg); 589 + 590 + case VIDIOC_S_STD: { 591 + v4l2_std_id *istd = arg; 592 + 593 + return saa7191_set_norm(client, *istd); 617 594 } 618 - case DECODER_SET_INPUT: { 619 - int *iarg = arg; 595 + case VIDIOC_INT_S_VIDEO_ROUTING: { 596 + struct v4l2_routing *route = arg; 620 597 621 - switch (client->adapter->id) { 622 - case I2C_HW_SGI_VINO: 623 - return saa7191_set_input(client, *iarg); 624 - default: 625 - if (*iarg != 0) 626 - return -EINVAL; 627 - } 628 - break; 598 + return saa7191_set_input(client, route->input); 629 599 } 630 - case DECODER_SET_OUTPUT: { 631 - int *iarg = arg; 632 600 633 - /* not much choice of outputs */ 634 - if (*iarg != 0) 635 - return -EINVAL; 636 - break; 637 - } 638 - case DECODER_ENABLE_OUTPUT: { 639 - /* Always enabled */ 640 - break; 641 - } 642 - case DECODER_SET_PICTURE: { 643 - struct video_picture *pic = arg; 644 - unsigned val; 645 - int err; 646 - 647 - val = (pic->hue >> 8) - 0x80; 648 - 649 - err = saa7191_write_reg(client, SAA7191_REG_HUEC, val); 650 - if (err) 651 - return -EIO; 652 - 653 - break; 654 - } 655 - case DECODER_SAA7191_GET_STATUS: { 656 - struct saa7191_status *status = arg; 657 - u8 status_reg; 658 - 659 - if (saa7191_read_status(client, &status_reg)) 660 - return -EIO; 661 - 662 - status->signal = ((status_reg & SAA7191_STATUS_HLCK) == 0) 663 - ? 1 : 0; 664 - status->signal_60hz = (status_reg & SAA7191_STATUS_FIDT) 665 - ? 1 : 0; 666 - status->color = (status_reg & SAA7191_STATUS_CODE) ? 1 : 0; 667 - 668 - status->input = decoder->input; 669 - status->norm = decoder->norm; 670 - 671 - break; 672 - } 673 - case DECODER_SAA7191_SET_NORM: { 674 - int *norm = arg; 675 - 676 - switch (*norm) { 677 - case SAA7191_NORM_AUTO: 678 - return saa7191_autodetect_norm(client); 679 - case SAA7191_NORM_AUTO_EXT: 680 - return saa7191_autodetect_norm_extended(client); 681 - default: 682 - return saa7191_set_norm(client, *norm); 683 - } 684 - } 685 - case DECODER_SAA7191_GET_CONTROL: { 601 + case VIDIOC_G_CTRL: 686 602 return saa7191_get_control(client, arg); 687 - } 688 - case DECODER_SAA7191_SET_CONTROL: { 603 + 604 + case VIDIOC_S_CTRL: 689 605 return saa7191_set_control(client, arg); 690 - } 606 + 691 607 default: 692 608 return -EINVAL; 693 609 } ··· 623 737 printk(KERN_INFO "SAA7191 initialized\n"); 624 738 625 739 decoder->input = SAA7191_INPUT_COMPOSITE; 626 - decoder->norm = SAA7191_NORM_PAL; 740 + decoder->norm = V4L2_STD_PAL; 627 741 628 742 err = saa7191_autodetect_norm(client); 629 743 if (err && (err != -EBUSY))
+8 -18
drivers/media/video/saa7191.h
··· 176 176 #define SAA7191_INPUT_COMPOSITE 0 177 177 #define SAA7191_INPUT_SVIDEO 1 178 178 179 - #define SAA7191_NORM_AUTO 0 180 179 #define SAA7191_NORM_PAL 1 181 180 #define SAA7191_NORM_NTSC 2 182 181 #define SAA7191_NORM_SECAM 3 183 - #define SAA7191_NORM_AUTO_EXT 4 /* extended auto-detection */ 184 182 185 183 struct saa7191_status { 186 184 /* 0=no signal, 1=signal detected */ ··· 230 232 #define SAA7191_VNR_MAX 0x03 231 233 #define SAA7191_VNR_DEFAULT 0x00 232 234 233 - #define SAA7191_CONTROL_BANDPASS 0 234 - #define SAA7191_CONTROL_BANDPASS_WEIGHT 1 235 - #define SAA7191_CONTROL_CORING 2 236 - #define SAA7191_CONTROL_FORCE_COLOUR 3 /* boolean */ 237 - #define SAA7191_CONTROL_CHROMA_GAIN 4 238 - #define SAA7191_CONTROL_HUE 5 239 - #define SAA7191_CONTROL_VTRC 6 /* boolean */ 240 - #define SAA7191_CONTROL_LUMA_DELAY 7 241 - #define SAA7191_CONTROL_VNR 8 242 - 243 - struct saa7191_control { 244 - u8 type; 245 - s32 value; 246 - }; 235 + #define SAA7191_CONTROL_BANDPASS (V4L2_CID_PRIVATE_BASE + 0) 236 + #define SAA7191_CONTROL_BANDPASS_WEIGHT (V4L2_CID_PRIVATE_BASE + 1) 237 + #define SAA7191_CONTROL_CORING (V4L2_CID_PRIVATE_BASE + 2) 238 + #define SAA7191_CONTROL_FORCE_COLOUR (V4L2_CID_PRIVATE_BASE + 3) 239 + #define SAA7191_CONTROL_CHROMA_GAIN (V4L2_CID_PRIVATE_BASE + 4) 240 + #define SAA7191_CONTROL_VTRC (V4L2_CID_PRIVATE_BASE + 5) 241 + #define SAA7191_CONTROL_LUMA_DELAY (V4L2_CID_PRIVATE_BASE + 6) 242 + #define SAA7191_CONTROL_VNR (V4L2_CID_PRIVATE_BASE + 7) 247 243 248 244 #define DECODER_SAA7191_GET_STATUS _IOR('d', 195, struct saa7191_status) 249 245 #define DECODER_SAA7191_SET_NORM _IOW('d', 196, int) 250 - #define DECODER_SAA7191_GET_CONTROL _IOR('d', 197, struct saa7191_control) 251 - #define DECODER_SAA7191_SET_CONTROL _IOW('d', 198, struct saa7191_control) 252 246 253 247 #endif
+113 -283
drivers/media/video/vino.c
··· 38 38 #include <linux/videodev2.h> 39 39 #include <media/v4l2-common.h> 40 40 #include <media/v4l2-ioctl.h> 41 - #include <linux/video_decoder.h> 42 41 #include <linux/mutex.h> 43 42 44 43 #include <asm/paccess.h> ··· 138 139 #define VINO_DATA_NORM_PAL 1 139 140 #define VINO_DATA_NORM_SECAM 2 140 141 #define VINO_DATA_NORM_D1 3 141 - /* The following are special entries that can be used to 142 - * autodetect the norm. */ 143 - #define VINO_DATA_NORM_AUTO 0xfe 144 - #define VINO_DATA_NORM_AUTO_EXT 0xff 145 142 146 143 #define VINO_DATA_NORM_COUNT 4 147 144 ··· 355 360 .name = "Composite", 356 361 .std = V4L2_STD_NTSC | V4L2_STD_PAL 357 362 | V4L2_STD_SECAM, 358 - },{ 363 + }, { 359 364 .name = "S-Video", 360 365 .std = V4L2_STD_NTSC | V4L2_STD_PAL 361 366 | V4L2_STD_SECAM, 362 - },{ 367 + }, { 363 368 .name = "D1/IndyCam", 364 369 .std = V4L2_STD_NTSC, 365 370 } ··· 371 376 .bpp = 1, 372 377 .pixelformat = V4L2_PIX_FMT_GREY, 373 378 .colorspace = V4L2_COLORSPACE_SMPTE170M, 374 - },{ 379 + }, { 375 380 .description = "8-bit dithered RGB 3-3-2", 376 381 .bpp = 1, 377 382 .pixelformat = V4L2_PIX_FMT_RGB332, 378 383 .colorspace = V4L2_COLORSPACE_SRGB, 379 - },{ 384 + }, { 380 385 .description = "32-bit RGB", 381 386 .bpp = 4, 382 387 .pixelformat = V4L2_PIX_FMT_RGB32, 383 388 .colorspace = V4L2_COLORSPACE_SRGB, 384 - },{ 389 + }, { 385 390 .description = "YUV 4:2:2", 386 391 .bpp = 2, 387 392 .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? ··· 412 417 + VINO_NTSC_HEIGHT / 2 - 1, 413 418 .right = VINO_NTSC_WIDTH, 414 419 }, 415 - },{ 420 + }, { 416 421 .description = "PAL", 417 422 .std = V4L2_STD_PAL, 418 423 .fps_min = 5, ··· 434 439 + VINO_PAL_HEIGHT / 2 - 1, 435 440 .right = VINO_PAL_WIDTH, 436 441 }, 437 - },{ 442 + }, { 438 443 .description = "SECAM", 439 444 .std = V4L2_STD_SECAM, 440 445 .fps_min = 5, ··· 456 461 + VINO_PAL_HEIGHT / 2 - 1, 457 462 .right = VINO_PAL_WIDTH, 458 463 }, 459 - },{ 464 + }, { 460 465 .description = "NTSC/D1", 461 466 .std = V4L2_STD_NTSC, 462 467 .fps_min = 6, ··· 492 497 .maximum = 1, 493 498 .step = 1, 494 499 .default_value = INDYCAM_AGC_DEFAULT, 495 - .flags = 0, 496 - .reserved = { INDYCAM_CONTROL_AGC, 0 }, 497 - },{ 500 + }, { 498 501 .id = V4L2_CID_AUTO_WHITE_BALANCE, 499 502 .type = V4L2_CTRL_TYPE_BOOLEAN, 500 503 .name = "Automatic White Balance", ··· 500 507 .maximum = 1, 501 508 .step = 1, 502 509 .default_value = INDYCAM_AWB_DEFAULT, 503 - .flags = 0, 504 - .reserved = { INDYCAM_CONTROL_AWB, 0 }, 505 - },{ 510 + }, { 506 511 .id = V4L2_CID_GAIN, 507 512 .type = V4L2_CTRL_TYPE_INTEGER, 508 513 .name = "Gain", ··· 508 517 .maximum = INDYCAM_GAIN_MAX, 509 518 .step = 1, 510 519 .default_value = INDYCAM_GAIN_DEFAULT, 511 - .flags = 0, 512 - .reserved = { INDYCAM_CONTROL_GAIN, 0 }, 513 - },{ 514 - .id = V4L2_CID_PRIVATE_BASE, 520 + }, { 521 + .id = INDYCAM_CONTROL_RED_SATURATION, 515 522 .type = V4L2_CTRL_TYPE_INTEGER, 516 523 .name = "Red Saturation", 517 524 .minimum = INDYCAM_RED_SATURATION_MIN, 518 525 .maximum = INDYCAM_RED_SATURATION_MAX, 519 526 .step = 1, 520 527 .default_value = INDYCAM_RED_SATURATION_DEFAULT, 521 - .flags = 0, 522 - .reserved = { INDYCAM_CONTROL_RED_SATURATION, 0 }, 523 - },{ 524 - .id = V4L2_CID_PRIVATE_BASE + 1, 528 + }, { 529 + .id = INDYCAM_CONTROL_BLUE_SATURATION, 525 530 .type = V4L2_CTRL_TYPE_INTEGER, 526 531 .name = "Blue Saturation", 527 532 .minimum = INDYCAM_BLUE_SATURATION_MIN, 528 533 .maximum = INDYCAM_BLUE_SATURATION_MAX, 529 534 .step = 1, 530 535 .default_value = INDYCAM_BLUE_SATURATION_DEFAULT, 531 - .flags = 0, 532 - .reserved = { INDYCAM_CONTROL_BLUE_SATURATION, 0 }, 533 - },{ 536 + }, { 534 537 .id = V4L2_CID_RED_BALANCE, 535 538 .type = V4L2_CTRL_TYPE_INTEGER, 536 539 .name = "Red Balance", ··· 532 547 .maximum = INDYCAM_RED_BALANCE_MAX, 533 548 .step = 1, 534 549 .default_value = INDYCAM_RED_BALANCE_DEFAULT, 535 - .flags = 0, 536 - .reserved = { INDYCAM_CONTROL_RED_BALANCE, 0 }, 537 - },{ 550 + }, { 538 551 .id = V4L2_CID_BLUE_BALANCE, 539 552 .type = V4L2_CTRL_TYPE_INTEGER, 540 553 .name = "Blue Balance", ··· 540 557 .maximum = INDYCAM_BLUE_BALANCE_MAX, 541 558 .step = 1, 542 559 .default_value = INDYCAM_BLUE_BALANCE_DEFAULT, 543 - .flags = 0, 544 - .reserved = { INDYCAM_CONTROL_BLUE_BALANCE, 0 }, 545 - },{ 560 + }, { 546 561 .id = V4L2_CID_EXPOSURE, 547 562 .type = V4L2_CTRL_TYPE_INTEGER, 548 563 .name = "Shutter Control", ··· 548 567 .maximum = INDYCAM_SHUTTER_MAX, 549 568 .step = 1, 550 569 .default_value = INDYCAM_SHUTTER_DEFAULT, 551 - .flags = 0, 552 - .reserved = { INDYCAM_CONTROL_SHUTTER, 0 }, 553 - },{ 570 + }, { 554 571 .id = V4L2_CID_GAMMA, 555 572 .type = V4L2_CTRL_TYPE_INTEGER, 556 573 .name = "Gamma", ··· 556 577 .maximum = INDYCAM_GAMMA_MAX, 557 578 .step = 1, 558 579 .default_value = INDYCAM_GAMMA_DEFAULT, 559 - .flags = 0, 560 - .reserved = { INDYCAM_CONTROL_GAMMA, 0 }, 561 580 } 562 581 }; 563 582 ··· 570 593 .maximum = SAA7191_HUE_MAX, 571 594 .step = 1, 572 595 .default_value = SAA7191_HUE_DEFAULT, 573 - .flags = 0, 574 - .reserved = { SAA7191_CONTROL_HUE, 0 }, 575 - },{ 576 - .id = V4L2_CID_PRIVATE_BASE, 596 + }, { 597 + .id = SAA7191_CONTROL_BANDPASS, 577 598 .type = V4L2_CTRL_TYPE_INTEGER, 578 599 .name = "Luminance Bandpass", 579 600 .minimum = SAA7191_BANDPASS_MIN, 580 601 .maximum = SAA7191_BANDPASS_MAX, 581 602 .step = 1, 582 603 .default_value = SAA7191_BANDPASS_DEFAULT, 583 - .flags = 0, 584 - .reserved = { SAA7191_CONTROL_BANDPASS, 0 }, 585 - },{ 586 - .id = V4L2_CID_PRIVATE_BASE + 1, 604 + }, { 605 + .id = SAA7191_CONTROL_BANDPASS_WEIGHT, 587 606 .type = V4L2_CTRL_TYPE_INTEGER, 588 607 .name = "Luminance Bandpass Weight", 589 608 .minimum = SAA7191_BANDPASS_WEIGHT_MIN, 590 609 .maximum = SAA7191_BANDPASS_WEIGHT_MAX, 591 610 .step = 1, 592 611 .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT, 593 - .flags = 0, 594 - .reserved = { SAA7191_CONTROL_BANDPASS_WEIGHT, 0 }, 595 - },{ 596 - .id = V4L2_CID_PRIVATE_BASE + 2, 612 + }, { 613 + .id = SAA7191_CONTROL_CORING, 597 614 .type = V4L2_CTRL_TYPE_INTEGER, 598 615 .name = "HF Luminance Coring", 599 616 .minimum = SAA7191_CORING_MIN, 600 617 .maximum = SAA7191_CORING_MAX, 601 618 .step = 1, 602 619 .default_value = SAA7191_CORING_DEFAULT, 603 - .flags = 0, 604 - .reserved = { SAA7191_CONTROL_CORING, 0 }, 605 - },{ 606 - .id = V4L2_CID_PRIVATE_BASE + 3, 620 + }, { 621 + .id = SAA7191_CONTROL_FORCE_COLOUR, 607 622 .type = V4L2_CTRL_TYPE_BOOLEAN, 608 623 .name = "Force Colour", 609 624 .minimum = SAA7191_FORCE_COLOUR_MIN, 610 625 .maximum = SAA7191_FORCE_COLOUR_MAX, 611 626 .step = 1, 612 627 .default_value = SAA7191_FORCE_COLOUR_DEFAULT, 613 - .flags = 0, 614 - .reserved = { SAA7191_CONTROL_FORCE_COLOUR, 0 }, 615 - },{ 616 - .id = V4L2_CID_PRIVATE_BASE + 4, 628 + }, { 629 + .id = SAA7191_CONTROL_CHROMA_GAIN, 617 630 .type = V4L2_CTRL_TYPE_INTEGER, 618 631 .name = "Chrominance Gain Control", 619 632 .minimum = SAA7191_CHROMA_GAIN_MIN, 620 633 .maximum = SAA7191_CHROMA_GAIN_MAX, 621 634 .step = 1, 622 635 .default_value = SAA7191_CHROMA_GAIN_DEFAULT, 623 - .flags = 0, 624 - .reserved = { SAA7191_CONTROL_CHROMA_GAIN, 0 }, 625 - },{ 626 - .id = V4L2_CID_PRIVATE_BASE + 5, 636 + }, { 637 + .id = SAA7191_CONTROL_VTRC, 627 638 .type = V4L2_CTRL_TYPE_BOOLEAN, 628 639 .name = "VTR Time Constant", 629 640 .minimum = SAA7191_VTRC_MIN, 630 641 .maximum = SAA7191_VTRC_MAX, 631 642 .step = 1, 632 643 .default_value = SAA7191_VTRC_DEFAULT, 633 - .flags = 0, 634 - .reserved = { SAA7191_CONTROL_VTRC, 0 }, 635 - },{ 636 - .id = V4L2_CID_PRIVATE_BASE + 6, 644 + }, { 645 + .id = SAA7191_CONTROL_LUMA_DELAY, 637 646 .type = V4L2_CTRL_TYPE_INTEGER, 638 647 .name = "Luminance Delay Compensation", 639 648 .minimum = SAA7191_LUMA_DELAY_MIN, 640 649 .maximum = SAA7191_LUMA_DELAY_MAX, 641 650 .step = 1, 642 651 .default_value = SAA7191_LUMA_DELAY_DEFAULT, 643 - .flags = 0, 644 - .reserved = { SAA7191_CONTROL_LUMA_DELAY, 0 }, 645 - },{ 646 - .id = V4L2_CID_PRIVATE_BASE + 7, 652 + }, { 653 + .id = SAA7191_CONTROL_VNR, 647 654 .type = V4L2_CTRL_TYPE_INTEGER, 648 655 .name = "Vertical Noise Reduction", 649 656 .minimum = SAA7191_VNR_MIN, 650 657 .maximum = SAA7191_VNR_MAX, 651 658 .step = 1, 652 659 .default_value = SAA7191_VNR_DEFAULT, 653 - .flags = 0, 654 - .reserved = { SAA7191_CONTROL_VNR, 0 }, 655 660 } 656 661 }; 657 662 ··· 2449 2490 } 2450 2491 } 2451 2492 2452 - static int vino_get_saa7191_norm(unsigned int data_norm) 2453 - { 2454 - switch (data_norm) { 2455 - case VINO_DATA_NORM_AUTO: 2456 - return SAA7191_NORM_AUTO; 2457 - case VINO_DATA_NORM_AUTO_EXT: 2458 - return SAA7191_NORM_AUTO_EXT; 2459 - case VINO_DATA_NORM_PAL: 2460 - return SAA7191_NORM_PAL; 2461 - case VINO_DATA_NORM_NTSC: 2462 - return SAA7191_NORM_NTSC; 2463 - case VINO_DATA_NORM_SECAM: 2464 - return SAA7191_NORM_SECAM; 2465 - default: 2466 - printk(KERN_ERR "VINO: vino_get_saa7191_norm(): " 2467 - "invalid norm!\n"); 2468 - return -1; 2469 - } 2470 - } 2471 - 2472 - static int vino_get_from_saa7191_norm(int saa7191_norm) 2473 - { 2474 - switch (saa7191_norm) { 2475 - case SAA7191_NORM_PAL: 2476 - return VINO_DATA_NORM_PAL; 2477 - case SAA7191_NORM_NTSC: 2478 - return VINO_DATA_NORM_NTSC; 2479 - case SAA7191_NORM_SECAM: 2480 - return VINO_DATA_NORM_SECAM; 2481 - default: 2482 - printk(KERN_ERR "VINO: vino_get_from_saa7191_norm(): " 2483 - "invalid norm!\n"); 2484 - return VINO_DATA_NORM_NONE; 2485 - } 2486 - } 2487 - 2488 - static int vino_saa7191_set_norm(unsigned int *data_norm) 2489 - { 2490 - int saa7191_norm, new_data_norm; 2491 - int err = 0; 2492 - 2493 - saa7191_norm = vino_get_saa7191_norm(*data_norm); 2494 - 2495 - err = i2c_decoder_command(DECODER_SAA7191_SET_NORM, 2496 - &saa7191_norm); 2497 - if (err) 2498 - goto out; 2499 - 2500 - if ((*data_norm == VINO_DATA_NORM_AUTO) 2501 - || (*data_norm == VINO_DATA_NORM_AUTO_EXT)) { 2502 - struct saa7191_status status; 2503 - 2504 - err = i2c_decoder_command(DECODER_SAA7191_GET_STATUS, 2505 - &status); 2506 - if (err) 2507 - goto out; 2508 - 2509 - new_data_norm = 2510 - vino_get_from_saa7191_norm(status.norm); 2511 - if (new_data_norm == VINO_DATA_NORM_NONE) { 2512 - err = -EINVAL; 2513 - goto out; 2514 - } 2515 - 2516 - *data_norm = (unsigned int)new_data_norm; 2517 - } 2518 - 2519 - out: 2520 - return err; 2521 - } 2522 - 2523 2493 /* execute with input_lock locked */ 2524 2494 static int vino_is_input_owner(struct vino_channel_settings *vcs) 2525 2495 { ··· 2481 2593 vcs->data_norm = VINO_DATA_NORM_D1; 2482 2594 } else if (vino_drvdata->decoder.driver 2483 2595 && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { 2484 - int input, data_norm; 2485 - int saa7191_input; 2596 + int input; 2597 + int data_norm; 2598 + v4l2_std_id norm; 2599 + struct v4l2_routing route = { 0, 0 }; 2486 2600 2487 2601 i2c_use_client(vino_drvdata->decoder.driver); 2488 2602 input = VINO_INPUT_COMPOSITE; 2489 2603 2490 - saa7191_input = vino_get_saa7191_input(input); 2491 - ret = i2c_decoder_command(DECODER_SET_INPUT, 2492 - &saa7191_input); 2604 + route.input = vino_get_saa7191_input(input); 2605 + ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route); 2493 2606 if (ret) { 2494 2607 ret = -EINVAL; 2495 2608 goto out; ··· 2501 2612 /* Don't hold spinlocks while auto-detecting norm 2502 2613 * as it may take a while... */ 2503 2614 2504 - data_norm = VINO_DATA_NORM_AUTO_EXT; 2505 - 2506 - ret = vino_saa7191_set_norm(&data_norm); 2507 - if ((ret == -EBUSY) || (ret == -EAGAIN)) { 2508 - data_norm = VINO_DATA_NORM_PAL; 2509 - ret = vino_saa7191_set_norm(&data_norm); 2615 + ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm); 2616 + if (!ret) { 2617 + for (data_norm = 0; data_norm < 3; data_norm++) { 2618 + if (vino_data_norms[data_norm].std & norm) 2619 + break; 2620 + } 2621 + if (data_norm == 3) 2622 + data_norm = VINO_DATA_NORM_PAL; 2623 + ret = i2c_decoder_command(VIDIOC_S_STD, &norm); 2510 2624 } 2511 2625 2512 2626 spin_lock_irqsave(&vino_drvdata->input_lock, flags); ··· 2576 2684 2577 2685 if (vino_drvdata->decoder.owner == vcs->channel) { 2578 2686 int data_norm; 2579 - int saa7191_input; 2687 + v4l2_std_id norm; 2688 + struct v4l2_routing route = { 0, 0 }; 2580 2689 2581 - saa7191_input = vino_get_saa7191_input(input); 2582 - ret = i2c_decoder_command(DECODER_SET_INPUT, 2583 - &saa7191_input); 2690 + route.input = vino_get_saa7191_input(input); 2691 + ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route); 2584 2692 if (ret) { 2585 2693 vino_drvdata->decoder.owner = VINO_NO_CHANNEL; 2586 2694 ret = -EINVAL; ··· 2592 2700 /* Don't hold spinlocks while auto-detecting norm 2593 2701 * as it may take a while... */ 2594 2702 2595 - data_norm = VINO_DATA_NORM_AUTO_EXT; 2596 - 2597 - ret = vino_saa7191_set_norm(&data_norm); 2598 - if ((ret == -EBUSY) || (ret == -EAGAIN)) { 2599 - data_norm = VINO_DATA_NORM_PAL; 2600 - ret = vino_saa7191_set_norm(&data_norm); 2703 + ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm); 2704 + if (!ret) { 2705 + for (data_norm = 0; data_norm < 3; data_norm++) { 2706 + if (vino_data_norms[data_norm].std & norm) 2707 + break; 2708 + } 2709 + if (data_norm == 3) 2710 + data_norm = VINO_DATA_NORM_PAL; 2711 + ret = i2c_decoder_command(VIDIOC_S_STD, &norm); 2601 2712 } 2602 2713 2603 2714 spin_lock_irqsave(&vino_drvdata->input_lock, flags); ··· 2628 2733 if (vcs2->input == VINO_INPUT_D1) { 2629 2734 vino_drvdata->camera.owner = vcs2->channel; 2630 2735 } else { 2631 - i2c_release_client(vino_drvdata-> 2632 - camera.driver); 2736 + i2c_release_client(vino_drvdata->camera.driver); 2633 2737 vino_drvdata->camera.owner = VINO_NO_CHANNEL; 2634 2738 } 2635 2739 } ··· 2723 2829 switch (vcs->input) { 2724 2830 case VINO_INPUT_D1: 2725 2831 /* only one "norm" supported */ 2726 - if ((data_norm != VINO_DATA_NORM_D1) 2727 - && (data_norm != VINO_DATA_NORM_AUTO) 2728 - && (data_norm != VINO_DATA_NORM_AUTO_EXT)) 2832 + if (data_norm != VINO_DATA_NORM_D1) 2729 2833 return -EINVAL; 2730 2834 break; 2731 2835 case VINO_INPUT_COMPOSITE: 2732 2836 case VINO_INPUT_SVIDEO: { 2837 + v4l2_std_id norm; 2838 + 2733 2839 if ((data_norm != VINO_DATA_NORM_PAL) 2734 2840 && (data_norm != VINO_DATA_NORM_NTSC) 2735 - && (data_norm != VINO_DATA_NORM_SECAM) 2736 - && (data_norm != VINO_DATA_NORM_AUTO) 2737 - && (data_norm != VINO_DATA_NORM_AUTO_EXT)) 2841 + && (data_norm != VINO_DATA_NORM_SECAM)) 2738 2842 return -EINVAL; 2739 2843 2740 2844 spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags); ··· 2740 2848 /* Don't hold spinlocks while setting norm 2741 2849 * as it may take a while... */ 2742 2850 2743 - err = vino_saa7191_set_norm(&data_norm); 2851 + norm = vino_data_norms[data_norm].std; 2852 + err = i2c_decoder_command(VIDIOC_S_STD, &norm); 2744 2853 2745 2854 spin_lock_irqsave(&vino_drvdata->input_lock, *flags); 2746 2855 ··· 2891 2998 i->std = vino_inputs[input].std; 2892 2999 strcpy(i->name, vino_inputs[input].name); 2893 3000 2894 - if ((input == VINO_INPUT_COMPOSITE) 2895 - || (input == VINO_INPUT_SVIDEO)) { 2896 - struct saa7191_status status; 2897 - i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status); 2898 - i->status |= status.signal ? 0 : V4L2_IN_ST_NO_SIGNAL; 2899 - i->status |= status.color ? 0 : V4L2_IN_ST_NO_COLOR; 2900 - } 2901 - 3001 + if (input == VINO_INPUT_COMPOSITE || input == VINO_INPUT_SVIDEO) 3002 + i2c_decoder_command(VIDIOC_INT_G_INPUT_STATUS, &i->status); 2902 3003 return 0; 2903 3004 } 2904 3005 ··· 2949 3062 break; 2950 3063 case VINO_INPUT_COMPOSITE: 2951 3064 case VINO_INPUT_SVIDEO: { 2952 - struct saa7191_status status; 2953 - 2954 - i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status); 2955 - 2956 - if (status.signal) { 2957 - if (status.signal_60hz) { 2958 - *std = V4L2_STD_NTSC; 2959 - } else { 2960 - *std = V4L2_STD_PAL | V4L2_STD_SECAM; 2961 - } 2962 - } else { 2963 - *std = vino_inputs[vcs->input].std; 2964 - } 3065 + i2c_decoder_command(VIDIOC_QUERYSTD, std); 2965 3066 break; 2966 3067 } 2967 3068 default: ··· 3001 3126 if (vcs->input == VINO_INPUT_D1) 3002 3127 goto out; 3003 3128 3004 - if (((*std) & V4L2_STD_PAL) 3005 - && ((*std) & V4L2_STD_NTSC) 3006 - && ((*std) & V4L2_STD_SECAM)) { 3007 - ret = vino_set_data_norm(vcs, VINO_DATA_NORM_AUTO_EXT, 3008 - &flags); 3009 - } else if ((*std) & V4L2_STD_PAL) { 3129 + if ((*std) & V4L2_STD_PAL) { 3010 3130 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL, 3011 3131 &flags); 3012 3132 } else if ((*std) & V4L2_STD_NTSC) { ··· 3667 3797 3668 3798 switch (vcs->input) { 3669 3799 case VINO_INPUT_D1: { 3670 - struct indycam_control indycam_ctrl; 3671 - 3800 + err = -EINVAL; 3672 3801 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { 3673 - if (vino_indycam_v4l2_controls[i].id == 3674 - control->id) { 3675 - goto found1; 3802 + if (vino_indycam_v4l2_controls[i].id == control->id) { 3803 + err = 0; 3804 + break; 3676 3805 } 3677 3806 } 3678 3807 3679 - err = -EINVAL; 3680 - goto out; 3681 - 3682 - found1: 3683 - indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; 3684 - 3685 - err = i2c_camera_command(DECODER_INDYCAM_GET_CONTROL, 3686 - &indycam_ctrl); 3687 - if (err) { 3688 - err = -EINVAL; 3808 + if (err) 3689 3809 goto out; 3690 - } 3691 3810 3692 - control->value = indycam_ctrl.value; 3811 + err = i2c_camera_command(VIDIOC_G_CTRL, &control); 3812 + if (err) 3813 + err = -EINVAL; 3693 3814 break; 3694 3815 } 3695 3816 case VINO_INPUT_COMPOSITE: 3696 3817 case VINO_INPUT_SVIDEO: { 3697 - struct saa7191_control saa7191_ctrl; 3698 - 3818 + err = -EINVAL; 3699 3819 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { 3700 - if (vino_saa7191_v4l2_controls[i].id == 3701 - control->id) { 3702 - goto found2; 3820 + if (vino_saa7191_v4l2_controls[i].id == control->id) { 3821 + err = 0; 3822 + break; 3703 3823 } 3704 3824 } 3705 3825 3706 - err = -EINVAL; 3707 - goto out; 3708 - 3709 - found2: 3710 - saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; 3711 - 3712 - err = i2c_decoder_command(DECODER_SAA7191_GET_CONTROL, 3713 - &saa7191_ctrl); 3714 - if (err) { 3715 - err = -EINVAL; 3826 + if (err) 3716 3827 goto out; 3717 - } 3718 3828 3719 - control->value = saa7191_ctrl.value; 3829 + err = i2c_decoder_command(VIDIOC_G_CTRL, &control); 3830 + if (err) 3831 + err = -EINVAL; 3720 3832 break; 3721 3833 } 3722 3834 default: ··· 3728 3876 3729 3877 switch (vcs->input) { 3730 3878 case VINO_INPUT_D1: { 3731 - struct indycam_control indycam_ctrl; 3732 - 3879 + err = -EINVAL; 3733 3880 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { 3734 - if (vino_indycam_v4l2_controls[i].id == 3735 - control->id) { 3736 - if ((control->value >= 3737 - vino_indycam_v4l2_controls[i].minimum) 3738 - && (control->value <= 3739 - vino_indycam_v4l2_controls[i]. 3740 - maximum)) { 3741 - goto found1; 3742 - } else { 3743 - err = -ERANGE; 3744 - goto out; 3745 - } 3881 + if (vino_indycam_v4l2_controls[i].id == control->id) { 3882 + err = 0; 3883 + break; 3746 3884 } 3747 3885 } 3748 - 3749 - err = -EINVAL; 3750 - goto out; 3751 - 3752 - found1: 3753 - indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; 3754 - indycam_ctrl.value = control->value; 3755 - 3756 - err = i2c_camera_command(DECODER_INDYCAM_SET_CONTROL, 3757 - &indycam_ctrl); 3886 + if (err) 3887 + goto out; 3888 + if (control->value < vino_indycam_v4l2_controls[i].minimum || 3889 + control->value > vino_indycam_v4l2_controls[i].maximum) { 3890 + err = -ERANGE; 3891 + goto out; 3892 + } 3893 + err = i2c_camera_command(VIDIOC_S_CTRL, &control); 3758 3894 if (err) 3759 3895 err = -EINVAL; 3760 3896 break; 3761 3897 } 3762 3898 case VINO_INPUT_COMPOSITE: 3763 3899 case VINO_INPUT_SVIDEO: { 3764 - struct saa7191_control saa7191_ctrl; 3765 - 3900 + err = -EINVAL; 3766 3901 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { 3767 - if (vino_saa7191_v4l2_controls[i].id == 3768 - control->id) { 3769 - if ((control->value >= 3770 - vino_saa7191_v4l2_controls[i].minimum) 3771 - && (control->value <= 3772 - vino_saa7191_v4l2_controls[i]. 3773 - maximum)) { 3774 - goto found2; 3775 - } else { 3776 - err = -ERANGE; 3777 - goto out; 3778 - } 3902 + if (vino_saa7191_v4l2_controls[i].id == control->id) { 3903 + err = 0; 3904 + break; 3779 3905 } 3780 3906 } 3781 - err = -EINVAL; 3782 - goto out; 3907 + if (err) 3908 + goto out; 3909 + if (control->value < vino_saa7191_v4l2_controls[i].minimum || 3910 + control->value > vino_saa7191_v4l2_controls[i].maximum) { 3911 + err = -ERANGE; 3912 + goto out; 3913 + } 3783 3914 3784 - found2: 3785 - saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; 3786 - saa7191_ctrl.value = control->value; 3787 - 3788 - err = i2c_decoder_command(DECODER_SAA7191_SET_CONTROL, 3789 - &saa7191_ctrl); 3915 + err = i2c_decoder_command(VIDIOC_S_CTRL, &control); 3790 3916 if (err) 3791 3917 err = -EINVAL; 3792 3918 break;