diff options
author | Manu Abraham <abraham.manu@gmail.com> | 2010-02-14 14:58:10 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:59 -0500 |
commit | 5f0e1cff5d19935bef1a6a2cdbd7f39b92031726 (patch) | |
tree | fd32e6e62c7b501cc6714c3a1ffe1c961b90197c /drivers | |
parent | 3c3233ec76118634cfd74d35c45d984e74acfc37 (diff) |
V4L/DVB: AZ6027: Fix checkpatch violations
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/dvb-usb/az6027.c | 612 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/az6027.h | 8 |
2 files changed, 320 insertions, 300 deletions
diff --git a/drivers/media/dvb/dvb-usb/az6027.c b/drivers/media/dvb/dvb-usb/az6027.c index 555c8f440793..30fd046d9d0d 100644 --- a/drivers/media/dvb/dvb-usb/az6027.c +++ b/drivers/media/dvb/dvb-usb/az6027.c | |||
@@ -10,18 +10,17 @@ | |||
10 | * see Documentation/dvb/README.dvb-usb for more information | 10 | * see Documentation/dvb/README.dvb-usb for more information |
11 | */ | 11 | */ |
12 | #include "az6027.h" | 12 | #include "az6027.h" |
13 | /* Demodulator */ | 13 | |
14 | #include "stb0899_drv.h" | 14 | #include "stb0899_drv.h" |
15 | #include "stb0899_reg.h" | 15 | #include "stb0899_reg.h" |
16 | #include "stb0899_cfg.h" | 16 | #include "stb0899_cfg.h" |
17 | /* Tuner */ | 17 | |
18 | #include "stb6100.h" | 18 | #include "stb6100.h" |
19 | #include "stb6100_cfg.h" | 19 | #include "stb6100_cfg.h" |
20 | #include "dvb_ca_en50221.h" | 20 | #include "dvb_ca_en50221.h" |
21 | 21 | ||
22 | /* debug */ | ||
23 | int dvb_usb_az6027_debug; | 22 | int dvb_usb_az6027_debug; |
24 | module_param_named(debug,dvb_usb_az6027_debug, int, 0644); | 23 | module_param_named(debug, dvb_usb_az6027_debug, int, 0644); |
25 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | 24 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); |
26 | 25 | ||
27 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 26 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
@@ -34,7 +33,7 @@ struct az6027_device_state { | |||
34 | 33 | ||
35 | static const struct stb0899_s1_reg az6027_stb0899_s1_init_1[] = { | 34 | static const struct stb0899_s1_reg az6027_stb0899_s1_init_1[] = { |
36 | 35 | ||
37 | // 0x0000000b , /* SYSREG */ | 36 | /* 0x0000000b, SYSREG */ |
38 | { STB0899_DEV_ID , 0x30 }, | 37 | { STB0899_DEV_ID , 0x30 }, |
39 | { STB0899_DISCNTRL1 , 0x32 }, | 38 | { STB0899_DISCNTRL1 , 0x32 }, |
40 | { STB0899_DISCNTRL2 , 0x80 }, | 39 | { STB0899_DISCNTRL2 , 0x80 }, |
@@ -45,7 +44,7 @@ static const struct stb0899_s1_reg az6027_stb0899_s1_init_1[] = { | |||
45 | { STB0899_DISSTATUS , 0x20 }, | 44 | { STB0899_DISSTATUS , 0x20 }, |
46 | { STB0899_DISF22 , 0x99 }, | 45 | { STB0899_DISF22 , 0x99 }, |
47 | { STB0899_DISF22RX , 0xa8 }, | 46 | { STB0899_DISF22RX , 0xa8 }, |
48 | //SYSREG ? | 47 | /* SYSREG ? */ |
49 | { STB0899_ACRPRESC , 0x11 }, | 48 | { STB0899_ACRPRESC , 0x11 }, |
50 | { STB0899_ACRDIV1 , 0x0a }, | 49 | { STB0899_ACRDIV1 , 0x0a }, |
51 | { STB0899_ACRDIV2 , 0x05 }, | 50 | { STB0899_ACRDIV2 , 0x05 }, |
@@ -263,7 +262,7 @@ struct stb0899_config az6027_stb0899_config = { | |||
263 | .init_s2_fec = stb0899_s2_init_4, | 262 | .init_s2_fec = stb0899_s2_init_4, |
264 | .init_tst = stb0899_s1_init_5, | 263 | .init_tst = stb0899_s1_init_5, |
265 | 264 | ||
266 | .demod_address = 0xd0,//0x68, /* 0xd0 >> 1 */ | 265 | .demod_address = 0xd0, /* 0x68, 0xd0 >> 1 */ |
267 | 266 | ||
268 | .xtal_freq = 27000000, | 267 | .xtal_freq = 27000000, |
269 | .inversion = IQ_SWAP_ON, /* 1 */ | 268 | .inversion = IQ_SWAP_ON, /* 1 */ |
@@ -303,15 +302,18 @@ struct stb6100_config az6027_stb6100_config = { | |||
303 | int az6027_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | 302 | int az6027_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) |
304 | { | 303 | { |
305 | int ret = -1; | 304 | int ret = -1; |
306 | if(mutex_lock_interruptible(&d->usb_mutex)) { | 305 | if (mutex_lock_interruptible(&d->usb_mutex)) |
307 | return -EAGAIN; | 306 | return -EAGAIN; |
308 | } | 307 | |
309 | ret = usb_control_msg(d->udev, | 308 | ret = usb_control_msg(d->udev, |
310 | usb_rcvctrlpipe(d->udev,0), | 309 | usb_rcvctrlpipe(d->udev, 0), |
311 | req, | 310 | req, |
312 | USB_TYPE_VENDOR | USB_DIR_IN, | 311 | USB_TYPE_VENDOR | USB_DIR_IN, |
313 | value,index,b,blen, | 312 | value, |
314 | 2000); | 313 | index, |
314 | b, | ||
315 | blen, | ||
316 | 2000); | ||
315 | 317 | ||
316 | if (ret < 0) { | 318 | if (ret < 0) { |
317 | warn("usb in operation failed. (%d)", ret); | 319 | warn("usb in operation failed. (%d)", ret); |
@@ -319,30 +321,40 @@ int az6027_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 | |||
319 | } else | 321 | } else |
320 | ret = 0; | 322 | ret = 0; |
321 | 323 | ||
324 | deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value, index); | ||
325 | debug_dump(b, blen, deb_xfer); | ||
322 | 326 | ||
323 | deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); | ||
324 | debug_dump(b,blen,deb_xfer); | ||
325 | mutex_unlock(&d->usb_mutex); | 327 | mutex_unlock(&d->usb_mutex); |
326 | return ret; | 328 | return ret; |
327 | } | 329 | } |
328 | 330 | ||
329 | static int az6027_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, | 331 | static int az6027_usb_out_op(struct dvb_usb_device *d, |
330 | u16 index, u8 *b, int blen) | 332 | u8 req, |
333 | u16 value, | ||
334 | u16 index, | ||
335 | u8 *b, | ||
336 | int blen) | ||
331 | { | 337 | { |
332 | int ret; | 338 | int ret; |
333 | deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index); | 339 | |
334 | debug_dump(b,blen,deb_xfer); | 340 | deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ", req, value, index); |
335 | if(mutex_lock_interruptible(&d->usb_mutex)) { | 341 | debug_dump(b, blen, deb_xfer); |
342 | |||
343 | if (mutex_lock_interruptible(&d->usb_mutex)) | ||
336 | return -EAGAIN; | 344 | return -EAGAIN; |
337 | } | ||
338 | 345 | ||
339 | if ((ret = usb_control_msg(d->udev, | 346 | ret = usb_control_msg(d->udev, |
340 | usb_sndctrlpipe(d->udev,0), | 347 | usb_sndctrlpipe(d->udev, 0), |
341 | req, | 348 | req, |
342 | USB_TYPE_VENDOR | USB_DIR_OUT, | 349 | USB_TYPE_VENDOR | USB_DIR_OUT, |
343 | value,index,b,blen, | 350 | value, |
344 | 2000)) != blen) { | 351 | index, |
345 | warn("usb out operation failed. (%d)",ret); | 352 | b, |
353 | blen, | ||
354 | 2000); | ||
355 | |||
356 | if (ret != blen) { | ||
357 | warn("usb out operation failed. (%d)", ret); | ||
346 | mutex_unlock(&d->usb_mutex); | 358 | mutex_unlock(&d->usb_mutex); |
347 | return -EIO; | 359 | return -EIO; |
348 | } else{ | 360 | } else{ |
@@ -358,16 +370,18 @@ static int az6027_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | |||
358 | u16 value; | 370 | u16 value; |
359 | u16 index; | 371 | u16 index; |
360 | int blen; | 372 | int blen; |
361 | deb_info("%s %d",__func__,onoff); | 373 | |
374 | deb_info("%s %d", __func__, onoff); | ||
375 | |||
362 | req = 0xBC; | 376 | req = 0xBC; |
363 | value = onoff; | 377 | value = onoff; |
364 | index = 0; | 378 | index = 0; |
365 | blen =0; | 379 | blen = 0; |
366 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) { | 380 | |
367 | warn("usb out operation failed. (%d)",ret); | 381 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); |
368 | } | 382 | if (ret != 0) |
369 | 383 | warn("usb out operation failed. (%d)", ret); | |
370 | //info("write CA | 384 | |
371 | return ret; | 385 | return ret; |
372 | } | 386 | } |
373 | 387 | ||
@@ -392,8 +406,8 @@ int az6027_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
392 | */ | 406 | */ |
393 | 407 | ||
394 | static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | 408 | static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, |
395 | int slot, | 409 | int slot, |
396 | int address) | 410 | int address) |
397 | { | 411 | { |
398 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 412 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
399 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 413 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
@@ -403,64 +417,65 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | |||
403 | u16 value; | 417 | u16 value; |
404 | u16 index; | 418 | u16 index; |
405 | int blen; | 419 | int blen; |
406 | u8 b[12]; | 420 | u8 b[12]; |
407 | 421 | ||
408 | //info ("%s %d", __func__, slot); | 422 | if (slot != 0) |
409 | if (0 != slot) | ||
410 | return -EINVAL; | 423 | return -EINVAL; |
411 | mutex_lock (&state->ca_mutex); | 424 | |
425 | mutex_lock(&state->ca_mutex); | ||
412 | 426 | ||
413 | req = 0xC1; | 427 | req = 0xC1; |
414 | value = address; | 428 | value = address; |
415 | index = 0; | 429 | index = 0; |
416 | blen = 1; | 430 | blen = 1; |
417 | ret = az6027_usb_in_op(d,req,value,index,b,blen); | 431 | |
432 | ret = az6027_usb_in_op(d, req, value, index, b, blen); | ||
418 | if (ret < 0) { | 433 | if (ret < 0) { |
419 | warn("usb in operation failed. (%d)", ret); | 434 | warn("usb in operation failed. (%d)", ret); |
420 | ret = -EINVAL; | 435 | ret = -EINVAL; |
421 | } else{ | 436 | } else { |
422 | ret = b[0]; | 437 | ret = b[0]; |
423 | //info("CI MEM 0x%x = %x",address,b[0]); | ||
424 | } | 438 | } |
425 | //mdelay(10); | 439 | |
426 | mutex_unlock (&state->ca_mutex); | 440 | mutex_unlock(&state->ca_mutex); |
427 | return ret; | 441 | return ret; |
428 | } | 442 | } |
429 | 443 | ||
430 | static int az6027_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, | 444 | static int az6027_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, |
431 | int slot, | 445 | int slot, |
432 | int address, | 446 | int address, |
433 | u8 value) | 447 | u8 value) |
434 | { | 448 | { |
435 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 449 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
436 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 450 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
451 | |||
437 | int ret; | 452 | int ret; |
438 | u8 req; | 453 | u8 req; |
439 | u16 value1; | 454 | u16 value1; |
440 | u16 index; | 455 | u16 index; |
441 | int blen; | 456 | int blen; |
442 | 457 | ||
443 | deb_info ("%s %d", __func__, slot); | 458 | deb_info("%s %d", __func__, slot); |
444 | if (0 != slot) | 459 | if (slot != 0) |
445 | return -EINVAL; | 460 | return -EINVAL; |
446 | 461 | ||
447 | mutex_lock (&state->ca_mutex); | 462 | mutex_lock(&state->ca_mutex); |
448 | req = 0xC2; | 463 | req = 0xC2; |
449 | value1 = address; | 464 | value1 = address; |
450 | index = value; | 465 | index = value; |
451 | blen =0; | 466 | blen = 0; |
452 | if((ret = az6027_usb_out_op(d,req,value1,index,NULL,blen)) != 0) { | ||
453 | warn("usb out operation failed. (%d)",ret); | ||
454 | } | ||
455 | //mdelay(10); | ||
456 | mutex_unlock (&state->ca_mutex); | ||
457 | 467 | ||
468 | ret = az6027_usb_out_op(d, req, value1, index, NULL, blen); | ||
469 | if (ret != 0) | ||
470 | warn("usb out operation failed. (%d)", ret); | ||
471 | |||
472 | mutex_unlock(&state->ca_mutex); | ||
458 | return ret; | 473 | return ret; |
459 | } | 474 | } |
460 | 475 | ||
461 | static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, | 476 | static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, |
462 | int slot, | 477 | int slot, |
463 | u8 address) | 478 | u8 address) |
464 | { | 479 | { |
465 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 480 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
466 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 481 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
@@ -470,81 +485,85 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, | |||
470 | u16 value; | 485 | u16 value; |
471 | u16 index; | 486 | u16 index; |
472 | int blen; | 487 | int blen; |
473 | u8 b[12]; | 488 | u8 b[12]; |
474 | 489 | ||
475 | //info ("%s %d", __func__, slot); | 490 | if (slot != 0) |
476 | if (0 != slot) | ||
477 | return -EINVAL; | 491 | return -EINVAL; |
478 | mutex_lock (&state->ca_mutex); | 492 | |
493 | mutex_lock(&state->ca_mutex); | ||
479 | 494 | ||
480 | req = 0xC3; | 495 | req = 0xC3; |
481 | value = address; | 496 | value = address; |
482 | index = 0; | 497 | index = 0; |
483 | blen = 2; | 498 | blen = 2; |
484 | ret = az6027_usb_in_op(d,req,value,index,b,blen); | 499 | |
500 | ret = az6027_usb_in_op(d, req, value, index, b, blen); | ||
485 | if (ret < 0) { | 501 | if (ret < 0) { |
486 | warn("usb in operation failed. (%d)", ret); | 502 | warn("usb in operation failed. (%d)", ret); |
487 | ret = -EINVAL; | 503 | ret = -EINVAL; |
488 | } else{ | 504 | } else { |
489 | if(b[0] == 0) | 505 | if (b[0] == 0) |
490 | warn("Read CI IO error"); | 506 | warn("Read CI IO error"); |
507 | |||
491 | ret = b[1]; | 508 | ret = b[1]; |
492 | deb_info("read cam data = %x from 0x%x",b[1],value); | 509 | deb_info("read cam data = %x from 0x%x", b[1], value); |
493 | } | 510 | } |
494 | //udelay(350); | 511 | |
495 | mutex_unlock (&state->ca_mutex); | 512 | mutex_unlock(&state->ca_mutex); |
496 | return ret; | 513 | return ret; |
497 | } | 514 | } |
498 | 515 | ||
499 | static int az6027_ci_write_cam_control(struct dvb_ca_en50221 *ca, | 516 | static int az6027_ci_write_cam_control(struct dvb_ca_en50221 *ca, |
500 | int slot, | 517 | int slot, |
501 | u8 address, | 518 | u8 address, |
502 | u8 value) | 519 | u8 value) |
503 | { | 520 | { |
504 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 521 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
505 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 522 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
523 | |||
506 | int ret; | 524 | int ret; |
507 | u8 req; | 525 | u8 req; |
508 | u16 value1; | 526 | u16 value1; |
509 | u16 index; | 527 | u16 index; |
510 | int blen; | 528 | int blen; |
511 | 529 | ||
512 | //info ("%s %d", __func__, slot); | 530 | if (slot != 0) |
513 | if (0 != slot) | ||
514 | return -EINVAL; | 531 | return -EINVAL; |
515 | 532 | ||
516 | mutex_lock (&state->ca_mutex); | 533 | mutex_lock(&state->ca_mutex); |
517 | req = 0xC4; | 534 | req = 0xC4; |
518 | value1 = address; | 535 | value1 = address; |
519 | index = value; | 536 | index = value; |
520 | blen =0; | 537 | blen = 0; |
521 | if((ret = az6027_usb_out_op(d,req,value1,index,NULL,blen)) != 0) { | 538 | |
522 | warn("usb out operation failed. (%d)",ret); | 539 | ret = az6027_usb_out_op(d, req, value1, index, NULL, blen); |
540 | if (ret != 0) { | ||
541 | warn("usb out operation failed. (%d)", ret); | ||
523 | goto failed; | 542 | goto failed; |
524 | } | 543 | } |
525 | //info("write CAM data(%x) to 0x%x ",index, value1); | 544 | |
526 | //udelay(350); | 545 | failed: |
527 | failed: | 546 | mutex_unlock(&state->ca_mutex); |
528 | mutex_unlock (&state->ca_mutex); | ||
529 | return ret; | 547 | return ret; |
530 | } | 548 | } |
531 | 549 | ||
532 | static int CI_CamReady(struct dvb_ca_en50221 *ca, | 550 | static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot) |
533 | int slot) | ||
534 | { | 551 | { |
535 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 552 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
553 | |||
536 | int ret; | 554 | int ret; |
537 | u8 req; | 555 | u8 req; |
538 | u16 value; | 556 | u16 value; |
539 | u16 index; | 557 | u16 index; |
540 | int blen; | 558 | int blen; |
541 | u8 b[12]; | 559 | u8 b[12]; |
542 | 560 | ||
543 | req = 0xC8; | 561 | req = 0xC8; |
544 | value = 0; | 562 | value = 0; |
545 | index = 0; | 563 | index = 0; |
546 | blen = 1; | 564 | blen = 1; |
547 | ret = az6027_usb_in_op(d,req,value,index,b,blen); | 565 | |
566 | ret = az6027_usb_in_op(d, req, value, index, b, blen); | ||
548 | if (ret < 0) { | 567 | if (ret < 0) { |
549 | warn("usb in operation failed. (%d)", ret); | 568 | warn("usb in operation failed. (%d)", ret); |
550 | ret = -EIO; | 569 | ret = -EIO; |
@@ -554,91 +573,92 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, | |||
554 | return ret; | 573 | return ret; |
555 | } | 574 | } |
556 | 575 | ||
557 | static int az6027_ci_slot_reset(struct dvb_ca_en50221 *ca, | 576 | static int az6027_ci_slot_reset(struct dvb_ca_en50221 *ca, int slot) |
558 | int slot) | ||
559 | { | 577 | { |
560 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 578 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
561 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 579 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
562 | int ret,i; | 580 | |
581 | int ret, i; | ||
563 | u8 req; | 582 | u8 req; |
564 | u16 value; | 583 | u16 value; |
565 | u16 index; | 584 | u16 index; |
566 | int blen; | 585 | int blen; |
567 | 586 | ||
568 | mutex_lock (&state->ca_mutex); | 587 | mutex_lock(&state->ca_mutex); |
569 | 588 | ||
570 | req = 0xC6; | 589 | req = 0xC6; |
571 | value = 1; | 590 | value = 1; |
572 | index = 0; | 591 | index = 0; |
573 | blen =0; | 592 | blen = 0; |
574 | if((ret = az6027_usb_out_op(d,req,value,index,NULL,blen)) != 0) { | 593 | |
575 | warn("usb out operation failed. (%d)",ret); | 594 | ret = az6027_usb_out_op(d, req, value, index, NULL, blen); |
595 | if (ret != 0) { | ||
596 | warn("usb out operation failed. (%d)", ret); | ||
576 | goto failed; | 597 | goto failed; |
577 | } | 598 | } |
578 | msleep (500); | 599 | |
600 | msleep(500); | ||
579 | req = 0xC6; | 601 | req = 0xC6; |
580 | value = 0; | 602 | value = 0; |
581 | index = 0; | 603 | index = 0; |
582 | blen =0; | 604 | blen = 0; |
583 | if((ret = az6027_usb_out_op(d,req,value,index,NULL,blen)) != 0) { | 605 | |
584 | warn("usb out operation failed. (%d)",ret); | 606 | ret = az6027_usb_out_op(d, req, value, index, NULL, blen); |
607 | if (ret != 0) { | ||
608 | warn("usb out operation failed. (%d)", ret); | ||
585 | goto failed; | 609 | goto failed; |
586 | } | 610 | } |
587 | 611 | ||
588 | for(i = 0;i < 15;i++) | 612 | for (i = 0; i < 15; i++) { |
589 | { | ||
590 | msleep(100); | 613 | msleep(100); |
591 | if(CI_CamReady(ca,slot)) | 614 | |
592 | { | 615 | if (CI_CamReady(ca, slot)) { |
593 | deb_info("CAM Ready"); | 616 | deb_info("CAM Ready"); |
594 | break; | 617 | break; |
595 | } | 618 | } |
596 | } | 619 | } |
597 | msleep(5000); | 620 | msleep(5000); |
598 | 621 | ||
599 | failed: | 622 | failed: |
600 | mutex_unlock (&state->ca_mutex); | 623 | mutex_unlock(&state->ca_mutex); |
601 | |||
602 | return ret; | 624 | return ret; |
603 | } | 625 | } |
604 | 626 | ||
605 | static int az6027_ci_slot_shutdown(struct dvb_ca_en50221 *ca, | 627 | static int az6027_ci_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) |
606 | int slot) | ||
607 | { | 628 | { |
608 | // do nothing here. | ||
609 | return 0; | 629 | return 0; |
610 | } | 630 | } |
611 | 631 | ||
612 | static int az6027_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, | 632 | static int az6027_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) |
613 | int slot) | ||
614 | { | 633 | { |
615 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 634 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
616 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 635 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
636 | |||
617 | int ret; | 637 | int ret; |
618 | u8 req; | 638 | u8 req; |
619 | u16 value; | 639 | u16 value; |
620 | u16 index; | 640 | u16 index; |
621 | int blen; | 641 | int blen; |
642 | |||
622 | deb_info("%s", __func__); | 643 | deb_info("%s", __func__); |
623 | mutex_lock (&state->ca_mutex); | 644 | mutex_lock(&state->ca_mutex); |
624 | req = 0xC7; | 645 | req = 0xC7; |
625 | value = 1; | 646 | value = 1; |
626 | index = 0; | 647 | index = 0; |
627 | blen =0; | 648 | blen = 0; |
628 | if((ret = az6027_usb_out_op(d,req,value,index,NULL,blen)) != 0) | 649 | |
629 | { | 650 | ret = az6027_usb_out_op(d, req, value, index, NULL, blen); |
630 | warn("usb out operation failed. (%d)",ret); | 651 | if (ret != 0) { |
652 | warn("usb out operation failed. (%d)", ret); | ||
631 | goto failed; | 653 | goto failed; |
632 | } | 654 | } |
633 | failed: | ||
634 | mutex_unlock (&state->ca_mutex); | ||
635 | 655 | ||
656 | failed: | ||
657 | mutex_unlock(&state->ca_mutex); | ||
636 | return ret; | 658 | return ret; |
637 | } | 659 | } |
638 | 660 | ||
639 | static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, | 661 | static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) |
640 | int slot, | ||
641 | int open) | ||
642 | { | 662 | { |
643 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; | 663 | struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; |
644 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 664 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
@@ -647,29 +667,31 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, | |||
647 | u16 value; | 667 | u16 value; |
648 | u16 index; | 668 | u16 index; |
649 | int blen; | 669 | int blen; |
650 | u8 b[12]; | 670 | u8 b[12]; |
651 | 671 | ||
652 | mutex_lock (&state->ca_mutex); | 672 | mutex_lock(&state->ca_mutex); |
653 | 673 | ||
654 | req = 0xC5; | 674 | req = 0xC5; |
655 | value = 0; | 675 | value = 0; |
656 | index = 0; | 676 | index = 0; |
657 | blen = 1; | 677 | blen = 1; |
658 | ret = az6027_usb_in_op(d,req,value,index,b,blen); | 678 | |
679 | ret = az6027_usb_in_op(d, req, value, index, b, blen); | ||
659 | if (ret < 0) { | 680 | if (ret < 0) { |
660 | warn("usb in operation failed. (%d)", ret); | 681 | warn("usb in operation failed. (%d)", ret); |
661 | ret = -EIO; | 682 | ret = -EIO; |
662 | } else | 683 | } else |
663 | ret = 0; | 684 | ret = 0; |
664 | if(b[0] == 0) | 685 | |
686 | if (b[0] == 0) { | ||
665 | ret = 0; | 687 | ret = 0; |
666 | else if(b[0] == 1){ | 688 | |
667 | ret = (DVB_CA_EN50221_POLL_CAM_PRESENT | | 689 | } else if (b[0] == 1) { |
668 | DVB_CA_EN50221_POLL_CAM_READY); | 690 | ret = DVB_CA_EN50221_POLL_CAM_PRESENT | |
669 | //info("CAM IN slot = %d", slot); | 691 | DVB_CA_EN50221_POLL_CAM_READY; |
670 | } | 692 | } |
671 | 693 | ||
672 | mutex_unlock (&state->ca_mutex); | 694 | mutex_unlock(&state->ca_mutex); |
673 | return ret; | 695 | return ret; |
674 | } | 696 | } |
675 | 697 | ||
@@ -702,38 +724,38 @@ static int az6027_ci_init(struct dvb_usb_adapter *a) | |||
702 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; | 724 | struct az6027_device_state *state = (struct az6027_device_state *)d->priv; |
703 | int ret; | 725 | int ret; |
704 | 726 | ||
705 | deb_info ("%s", __func__); | 727 | deb_info("%s", __func__); |
706 | 728 | ||
707 | mutex_init(&state->ca_mutex); | 729 | mutex_init(&state->ca_mutex); |
708 | 730 | ||
709 | state->ca.owner = THIS_MODULE; | 731 | state->ca.owner = THIS_MODULE; |
710 | state->ca.read_attribute_mem = az6027_ci_read_attribute_mem; | 732 | state->ca.read_attribute_mem = az6027_ci_read_attribute_mem; |
711 | state->ca.write_attribute_mem = az6027_ci_write_attribute_mem; | 733 | state->ca.write_attribute_mem = az6027_ci_write_attribute_mem; |
712 | state->ca.read_cam_control = az6027_ci_read_cam_control; | 734 | state->ca.read_cam_control = az6027_ci_read_cam_control; |
713 | state->ca.write_cam_control = az6027_ci_write_cam_control; | 735 | state->ca.write_cam_control = az6027_ci_write_cam_control; |
714 | state->ca.slot_reset = az6027_ci_slot_reset; | 736 | state->ca.slot_reset = az6027_ci_slot_reset; |
715 | state->ca.slot_shutdown = az6027_ci_slot_shutdown; | 737 | state->ca.slot_shutdown = az6027_ci_slot_shutdown; |
716 | state->ca.slot_ts_enable = az6027_ci_slot_ts_enable; | 738 | state->ca.slot_ts_enable = az6027_ci_slot_ts_enable; |
717 | state->ca.poll_slot_status = az6027_ci_poll_slot_status; | 739 | state->ca.poll_slot_status = az6027_ci_poll_slot_status; |
718 | state->ca.data = d; | 740 | state->ca.data = d; |
719 | 741 | ||
720 | ret = dvb_ca_en50221_init (&a->dvb_adap, | 742 | ret = dvb_ca_en50221_init(&a->dvb_adap, |
721 | &state->ca, | 743 | &state->ca, |
722 | /* flags */ 0, | 744 | 0, /* flags */ |
723 | /* n_slots */ 1); | 745 | 1);/* n_slots */ |
724 | if (0 != ret) { | 746 | if (ret != 0) { |
725 | err ("Cannot initialize CI: Error %d.", ret); | 747 | err("Cannot initialize CI: Error %d.", ret); |
726 | memset (&state->ca, 0, sizeof (state->ca)); | 748 | memset(&state->ca, 0, sizeof(state->ca)); |
727 | return ret; | 749 | return ret; |
728 | } | 750 | } |
729 | 751 | ||
730 | deb_info ("CI initialized."); | 752 | deb_info("CI initialized."); |
731 | 753 | ||
732 | return 0; | 754 | return 0; |
733 | } | 755 | } |
734 | 756 | ||
735 | 757 | ||
736 | static int az6027_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | 758 | static int az6027_read_mac_addr(struct dvb_usb_device *d, u8 mac[6]) |
737 | { | 759 | { |
738 | az6027_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6); | 760 | az6027_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6); |
739 | return 0; | 761 | return 0; |
@@ -742,29 +764,39 @@ static int az6027_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | |||
742 | 764 | ||
743 | static int az6027_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | 765 | static int az6027_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
744 | { | 766 | { |
745 | 767 | ||
746 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
747 | u8 buf; | 768 | u8 buf; |
769 | int ret; | ||
770 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
771 | |||
748 | struct i2c_msg i2c_msg = { | 772 | struct i2c_msg i2c_msg = { |
749 | .addr = 0x99, | 773 | .addr = 0x99, |
750 | .flags = 0, | 774 | .flags = 0, |
751 | .buf = &buf, | 775 | .buf = &buf, |
752 | .len = 1 | 776 | .len = 1 |
753 | }; | 777 | }; |
754 | int ret; | 778 | |
779 | /* | ||
780 | * 2 --18v | ||
781 | * 1 --13v | ||
782 | * 0 --off | ||
783 | */ | ||
755 | switch (voltage) { | 784 | switch (voltage) { |
756 | case SEC_VOLTAGE_13: | 785 | case SEC_VOLTAGE_13: |
757 | buf = 1;// 2 --18v 1 --13v 0 --off | 786 | buf = 1; |
758 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); | 787 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); |
759 | break; | 788 | break; |
789 | |||
760 | case SEC_VOLTAGE_18: | 790 | case SEC_VOLTAGE_18: |
761 | buf = 2;// 2 --18v 1 --13v 0 --off | 791 | buf = 2; |
762 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); | 792 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); |
763 | break; | 793 | break; |
794 | |||
764 | case SEC_VOLTAGE_OFF: | 795 | case SEC_VOLTAGE_OFF: |
765 | buf = 0;// 2 --18v 1 --13v 0 --off | 796 | buf = 0; |
766 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); | 797 | ret = i2c_transfer(&adap->dev->i2c_adap, &i2c_msg, 1); |
767 | break; | 798 | break; |
799 | |||
768 | default: | 800 | default: |
769 | return -EINVAL; | 801 | return -EINVAL; |
770 | } | 802 | } |
@@ -781,12 +813,14 @@ static int az6027_frontend_poweron(struct dvb_usb_adapter *adap) | |||
781 | int blen; | 813 | int blen; |
782 | 814 | ||
783 | req = 0xBC; | 815 | req = 0xBC; |
784 | value = 1;//power on | 816 | value = 1; /* power on */ |
785 | index = 3; | 817 | index = 3; |
786 | blen =0; | 818 | blen = 0; |
819 | |||
820 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); | ||
821 | if (ret != 0) | ||
822 | return -EIO; | ||
787 | 823 | ||
788 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) | ||
789 | return -EIO; | ||
790 | return 0; | 824 | return 0; |
791 | } | 825 | } |
792 | static int az6027_frontend_reset(struct dvb_usb_adapter *adap) | 826 | static int az6027_frontend_reset(struct dvb_usb_adapter *adap) |
@@ -797,49 +831,59 @@ static int az6027_frontend_reset(struct dvb_usb_adapter *adap) | |||
797 | u16 index; | 831 | u16 index; |
798 | int blen; | 832 | int blen; |
799 | 833 | ||
800 | //reset demodulator | 834 | /* reset demodulator */ |
801 | req = 0xC0; | 835 | req = 0xC0; |
802 | value = 1;//high | 836 | value = 1; /* high */ |
803 | index = 3; | 837 | index = 3; |
804 | blen =0; | 838 | blen = 0; |
839 | |||
840 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); | ||
841 | if (ret != 0) | ||
842 | return -EIO; | ||
805 | 843 | ||
806 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) | ||
807 | return -EIO; | ||
808 | |||
809 | req = 0xC0; | 844 | req = 0xC0; |
810 | value = 0;//low | 845 | value = 0; /* low */ |
811 | index = 3; | 846 | index = 3; |
812 | blen =0; | 847 | blen = 0; |
813 | msleep_interruptible(200); | 848 | msleep_interruptible(200); |
814 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) | 849 | |
815 | return -EIO; | 850 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); |
851 | if (ret != 0) | ||
852 | return -EIO; | ||
853 | |||
816 | msleep_interruptible(200); | 854 | msleep_interruptible(200); |
855 | |||
817 | req = 0xC0; | 856 | req = 0xC0; |
818 | value = 1;//high | 857 | value = 1; /*high */ |
819 | index = 3; | 858 | index = 3; |
820 | blen =0; | 859 | blen = 0; |
860 | |||
861 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); | ||
862 | if (ret != 0) | ||
863 | return -EIO; | ||
821 | 864 | ||
822 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) | ||
823 | return -EIO; | ||
824 | msleep_interruptible(200); | 865 | msleep_interruptible(200); |
825 | return 0; | 866 | return 0; |
826 | } | 867 | } |
827 | 868 | ||
828 | static int az6027_frontend_tsbypass(struct dvb_usb_adapter *adap,int onoff) | 869 | static int az6027_frontend_tsbypass(struct dvb_usb_adapter *adap, int onoff) |
829 | { | 870 | { |
830 | int ret; | 871 | int ret; |
831 | u8 req; | 872 | u8 req; |
832 | u16 value; | 873 | u16 value; |
833 | u16 index; | 874 | u16 index; |
834 | int blen; | 875 | int blen; |
835 | //TS through | 876 | |
877 | /* TS passthrough */ | ||
836 | req = 0xC7; | 878 | req = 0xC7; |
837 | value = onoff; | 879 | value = onoff; |
838 | index = 0; | 880 | index = 0; |
839 | blen =0; | 881 | blen = 0; |
882 | |||
883 | ret = az6027_usb_out_op(adap->dev, req, value, index, NULL, blen); | ||
884 | if (ret != 0) | ||
885 | return -EIO; | ||
840 | 886 | ||
841 | if((ret = az6027_usb_out_op(adap->dev,req,value,index,NULL,blen)) != 0) | ||
842 | return -EIO; | ||
843 | return 0; | 887 | return 0; |
844 | } | 888 | } |
845 | 889 | ||
@@ -848,164 +892,134 @@ static int az6027_frontend_attach(struct dvb_usb_adapter *adap) | |||
848 | 892 | ||
849 | az6027_frontend_poweron(adap); | 893 | az6027_frontend_poweron(adap); |
850 | az6027_frontend_reset(adap); | 894 | az6027_frontend_reset(adap); |
851 | deb_info("adap = %p,dev = %p\n",adap, adap->dev); | 895 | |
896 | deb_info("adap = %p, dev = %p\n", adap, adap->dev); | ||
852 | adap->fe = stb0899_attach(&az6027_stb0899_config, &adap->dev->i2c_adap); | 897 | adap->fe = stb0899_attach(&az6027_stb0899_config, &adap->dev->i2c_adap); |
898 | |||
853 | if (adap->fe) { | 899 | if (adap->fe) { |
854 | deb_info("found STB0899 DVB-S/DVB-S2 frontend @0x%02x",az6027_stb0899_config.demod_address); | 900 | deb_info("found STB0899 DVB-S/DVB-S2 frontend @0x%02x", az6027_stb0899_config.demod_address); |
855 | if (stb6100_attach(adap->fe, &az6027_stb6100_config, &adap->dev->i2c_adap)) { | 901 | if (stb6100_attach(adap->fe, &az6027_stb6100_config, &adap->dev->i2c_adap)) { |
856 | deb_info("found STB6100 DVB-S/DVB-S2 frontend @0x%02x",az6027_stb6100_config.tuner_address); | 902 | deb_info("found STB6100 DVB-S/DVB-S2 frontend @0x%02x", az6027_stb6100_config.tuner_address); |
857 | adap->fe->ops.set_voltage = az6027_set_voltage; | 903 | adap->fe->ops.set_voltage = az6027_set_voltage; |
858 | az6027_ci_init(adap); | 904 | az6027_ci_init(adap); |
859 | } else { | 905 | } else { |
860 | adap->fe = NULL; | 906 | adap->fe = NULL; |
861 | } | 907 | } |
862 | } | 908 | } else |
863 | else | ||
864 | warn("no front-end attached\n"); | 909 | warn("no front-end attached\n"); |
865 | 910 | ||
866 | 911 | az6027_frontend_tsbypass(adap, 0); | |
867 | az6027_frontend_tsbypass(adap,0); | ||
868 | 912 | ||
869 | return 0; | 913 | return 0; |
870 | } | 914 | } |
871 | 915 | ||
872 | static struct dvb_usb_device_properties az6027_properties; | 916 | static struct dvb_usb_device_properties az6027_properties; |
873 | 917 | ||
874 | static void | 918 | static void az6027_usb_disconnect(struct usb_interface *intf) |
875 | az6027_usb_disconnect(struct usb_interface *intf) | ||
876 | { | 919 | { |
877 | struct dvb_usb_device *d = usb_get_intfdata (intf); | 920 | struct dvb_usb_device *d = usb_get_intfdata(intf); |
878 | az6027_ci_uninit (d); | 921 | az6027_ci_uninit(d); |
879 | dvb_usb_device_exit (intf); | 922 | dvb_usb_device_exit(intf); |
880 | } | 923 | } |
881 | 924 | ||
882 | 925 | ||
883 | static int az6027_usb_probe(struct usb_interface *intf, | 926 | static int az6027_usb_probe(struct usb_interface *intf, |
884 | const struct usb_device_id *id) | 927 | const struct usb_device_id *id) |
885 | { | 928 | { |
886 | return dvb_usb_device_init(intf, &az6027_properties, | 929 | return dvb_usb_device_init(intf, |
887 | THIS_MODULE, NULL, adapter_nr); | 930 | &az6027_properties, |
931 | THIS_MODULE, | ||
932 | NULL, | ||
933 | adapter_nr); | ||
888 | } | 934 | } |
889 | 935 | ||
890 | /* I2C */ | 936 | /* I2C */ |
891 | static int az6027_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) | 937 | static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
892 | { | 938 | { |
893 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | 939 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
894 | int i=0,j=0,len=0; | 940 | int i = 0, j = 0, len = 0; |
895 | int ret; | 941 | int ret; |
896 | u16 index; | 942 | u16 index; |
897 | u16 value; | 943 | u16 value; |
898 | int length; | 944 | int length; |
899 | u8 req; | 945 | u8 req; |
900 | u8 data[256]; | 946 | u8 data[256]; |
901 | 947 | ||
902 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | 948 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
903 | return -EAGAIN; | 949 | return -EAGAIN; |
904 | //err("i2c func called\n"); | 950 | |
905 | if (num > 2) | 951 | if (num > 2) |
906 | warn("more than 2 i2c messages at a time is not handled yet. TODO."); | 952 | warn("more than 2 i2c messages at a time is not handled yet. TODO."); |
907 | 953 | ||
908 | for (i = 0; i < num; i++) { | 954 | for (i = 0; i < num; i++) { |
909 | if(msg[i].addr == 0x99) { | 955 | |
956 | if (msg[i].addr == 0x99) { | ||
910 | req = 0xBE; | 957 | req = 0xBE; |
911 | index = 0; | 958 | index = 0; |
912 | value = msg[i].buf[0] & 0x00ff; | 959 | value = msg[i].buf[0] & 0x00ff; |
913 | length = 1; | 960 | length = 1; |
914 | az6027_usb_out_op(d,req,value,index,data,length); | 961 | az6027_usb_out_op(d, req, value, index, data, length); |
915 | } | 962 | } |
916 | if(msg[i].addr == 0xd0){ | 963 | |
964 | if (msg[i].addr == 0xd0) { | ||
917 | /* write/read request */ | 965 | /* write/read request */ |
918 | if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { | 966 | if (i + 1 < num && (msg[i + 1].flags & I2C_M_RD)) { |
919 | /* | ||
920 | err("i2c read "); | ||
921 | err("addr0 = 0x%x",msg[i].addr); | ||
922 | err("buf0 = 0x%02x 0x%02x",msg[i].buf[0],msg[i].buf[1]); | ||
923 | err("len0 = %d",msg[i].len); | ||
924 | err("addr1 = 0x%x",msg[i+1].addr); | ||
925 | err("buf1 = 0x%02x 0x%02x",msg[i+1].buf[0], *msg[i+1].buf); | ||
926 | err("len1 = %d",msg[i+1].len); | ||
927 | |||
928 | */ | ||
929 | req = 0xB9; | 967 | req = 0xB9; |
930 | index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff)); | 968 | index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff)); |
931 | value = msg[i].addr + (msg[i].len << 8); | 969 | value = msg[i].addr + (msg[i].len << 8); |
932 | length = msg[i+1].len + 6; | 970 | length = msg[i + 1].len + 6; |
933 | //err("in: req. %02x, val: %04x, ind: %04x\n",req,value,index); | 971 | ret = az6027_usb_in_op(d, req, value, index, data, length); |
934 | ret = az6027_usb_in_op(d,req,value,index,data,length); | 972 | len = msg[i + 1].len; |
935 | //err("ret = %d data = %02x %02x",ret,data[5],data[6]); | 973 | for (j = 0; j < len; j++) |
936 | len = msg[i+1].len; | 974 | msg[i + 1].buf[j] = data[j + 5]; |
937 | for (j=0; j<len; j++) | 975 | |
938 | { | ||
939 | msg[i+1].buf[j] = data[j+5]; | ||
940 | } | ||
941 | i++; | 976 | i++; |
942 | //err("11111"); | 977 | } else { |
943 | } | 978 | |
944 | else | 979 | if (msg[i].addr == 0xd0) { |
945 | { | 980 | /* demod 16bit addr */ |
946 | //err("i2c write "); | ||
947 | //err("addr = 0x%x\n",msg[i].addr); | ||
948 | //err("buf = 0x%02x 0x%02x\n",msg[i].buf[0],msg[i].buf[1]); | ||
949 | //err("len = %d",msg[i].len); | ||
950 | if(msg[i].addr == 0xd0)//demod 16bit addr | ||
951 | { | ||
952 | req = 0xBD; | 981 | req = 0xBD; |
953 | index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff));//(msg[i].buf[0]<< 8) + msg[i].buf[1]; | 982 | index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff)); |
954 | value = msg[i].addr + (2 << 8); | 983 | value = msg[i].addr + (2 << 8); |
955 | length = msg[i].len - 2; | 984 | length = msg[i].len - 2; |
956 | len = msg[i].len - 2; | 985 | len = msg[i].len - 2; |
957 | for(j=0;j<len;j++) | 986 | for (j = 0; j < len; j++) |
958 | { | 987 | data[j] = msg[i].buf[j + 2]; |
959 | data[j] = msg[i].buf[j+2]; | 988 | |
960 | } | ||
961 | } | 989 | } |
962 | //err("out: req. %02x, val: %04x, ind: %04x\n",req,value,index); | 990 | az6027_usb_out_op(d, req, value, index, data, length); |
963 | az6027_usb_out_op(d,req,value,index,data,length); | ||
964 | //err("22222"); | ||
965 | } | 991 | } |
966 | } | 992 | } |
967 | if(msg[i].addr == 0xc0){ | 993 | |
994 | if (msg[i].addr == 0xc0) { | ||
968 | if (msg[i].flags & I2C_M_RD) { | 995 | if (msg[i].flags & I2C_M_RD) { |
969 | 996 | ||
970 | //err("i2c read "); | ||
971 | //err("addr0 = 0x%x",msg[i].addr); | ||
972 | //err("len0 = %d",msg[i].len); | ||
973 | |||
974 | req = 0xB9; | 997 | req = 0xB9; |
975 | index = 0x0; | 998 | index = 0x0; |
976 | value = msg[i].addr ;//+ (1 << 8); | 999 | value = msg[i].addr; |
977 | length = msg[i].len + 6; | 1000 | length = msg[i].len + 6; |
978 | //err("in: req. %02x, val: %04x, ind: %04x\n",req,value,index); | 1001 | ret = az6027_usb_in_op(d, req, value, index, data, length); |
979 | ret = az6027_usb_in_op(d,req,value,index,data,length); | ||
980 | //err("ret = %d data = %02x %02x",ret,data[5],data[6]); | ||
981 | len = msg[i].len; | 1002 | len = msg[i].len; |
982 | for (j=0; j<len; j++) | 1003 | for (j = 0; j < len; j++) |
983 | { | 1004 | msg[i].buf[j] = data[j + 5]; |
984 | msg[i].buf[j] = data[j+5]; | 1005 | |
985 | } | 1006 | } else { |
986 | } | 1007 | |
987 | else{ | ||
988 | //err("i2c write "); | ||
989 | //err("addr0 = 0x%x",msg[i].addr); | ||
990 | //err("buf0 = 0x%x",msg[i].buf[0]); | ||
991 | //err("len0 = %d",msg[i].len); | ||
992 | |||
993 | req = 0xBD; | 1008 | req = 0xBD; |
994 | index = msg[i].buf[0] & 0x00FF; | 1009 | index = msg[i].buf[0] & 0x00FF; |
995 | value = msg[i].addr + (1 << 8); | 1010 | value = msg[i].addr + (1 << 8); |
996 | length = msg[i].len - 1; | 1011 | length = msg[i].len - 1; |
997 | len = msg[i].len - 1; | 1012 | len = msg[i].len - 1; |
998 | for(j=0;j<len;j++) | 1013 | |
999 | { | 1014 | for (j = 0; j < len; j++) |
1000 | data[j] = msg[i].buf[j+1]; | 1015 | data[j] = msg[i].buf[j + 1]; |
1001 | } | 1016 | |
1002 | //err("out: req. %02x, val: %04x, ind: %04x\n",req,value,index); | 1017 | az6027_usb_out_op(d, req, value, index, data, length); |
1003 | az6027_usb_out_op(d,req,value,index,data,length); | ||
1004 | } | 1018 | } |
1005 | } | 1019 | } |
1006 | } | 1020 | } |
1007 | mutex_unlock(&d->i2c_mutex); | 1021 | mutex_unlock(&d->i2c_mutex); |
1008 | 1022 | ||
1009 | return i; | 1023 | return i; |
1010 | } | 1024 | } |
1011 | 1025 | ||
@@ -1020,15 +1034,21 @@ static struct i2c_algorithm az6027_i2c_algo = { | |||
1020 | .functionality = az6027_i2c_func, | 1034 | .functionality = az6027_i2c_func, |
1021 | }; | 1035 | }; |
1022 | 1036 | ||
1023 | 1037 | int az6027_identify_state(struct usb_device *udev, | |
1024 | int az6027_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, | 1038 | struct dvb_usb_device_properties *props, |
1025 | struct dvb_usb_device_description **desc, int *cold) | 1039 | struct dvb_usb_device_description **desc, |
1040 | int *cold) | ||
1026 | { | 1041 | { |
1027 | u8 b[16]; | 1042 | u8 b[16]; |
1028 | s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev,0), | 1043 | s16 ret = usb_control_msg(udev, |
1029 | 0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b, 6, USB_CTRL_GET_TIMEOUT); | 1044 | usb_rcvctrlpipe(udev, 0), |
1030 | 1045 | 0xb7, | |
1031 | //info("FW GET_VERSION length: %d\n",ret); | 1046 | USB_TYPE_VENDOR | USB_DIR_IN, |
1047 | 6, | ||
1048 | 0, | ||
1049 | b, | ||
1050 | 6, | ||
1051 | USB_CTRL_GET_TIMEOUT); | ||
1032 | 1052 | ||
1033 | *cold = ret <= 0; | 1053 | *cold = ret <= 0; |
1034 | 1054 | ||
@@ -1037,7 +1057,7 @@ int az6027_identify_state(struct usb_device *udev, struct dvb_usb_device_propert | |||
1037 | } | 1057 | } |
1038 | 1058 | ||
1039 | 1059 | ||
1040 | static struct usb_device_id az6027_usb_table [] = { | 1060 | static struct usb_device_id az6027_usb_table[] = { |
1041 | { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_AZ6027) }, | 1061 | { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_AZ6027) }, |
1042 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI) }, | 1062 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI) }, |
1043 | { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI) }, | 1063 | { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI) }, |
@@ -1049,7 +1069,6 @@ MODULE_DEVICE_TABLE(usb, az6027_usb_table); | |||
1049 | static struct dvb_usb_device_properties az6027_properties = { | 1069 | static struct dvb_usb_device_properties az6027_properties = { |
1050 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1070 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1051 | .usb_ctrl = CYPRESS_FX2, | 1071 | .usb_ctrl = CYPRESS_FX2, |
1052 | //.download_firmware = az6027_download_firmware, | ||
1053 | .firmware = "dvb-usb-az6027-03.fw", | 1072 | .firmware = "dvb-usb-az6027-03.fw", |
1054 | .no_reconnect = 1, | 1073 | .no_reconnect = 1, |
1055 | 1074 | ||
@@ -1058,8 +1077,6 @@ static struct dvb_usb_device_properties az6027_properties = { | |||
1058 | .num_adapters = 1, | 1077 | .num_adapters = 1, |
1059 | .adapter = { | 1078 | .adapter = { |
1060 | { | 1079 | { |
1061 | //.caps = DVB_USB_ADAP_RECEIVES_204_BYTE_TS, | ||
1062 | |||
1063 | .streaming_ctrl = az6027_streaming_ctrl, | 1080 | .streaming_ctrl = az6027_streaming_ctrl, |
1064 | .frontend_attach = az6027_frontend_attach, | 1081 | .frontend_attach = az6027_frontend_attach, |
1065 | 1082 | ||
@@ -1076,9 +1093,10 @@ static struct dvb_usb_device_properties az6027_properties = { | |||
1076 | }, | 1093 | }, |
1077 | } | 1094 | } |
1078 | }, | 1095 | }, |
1079 | //.power_ctrl = az6027_power_ctrl, | 1096 | /* |
1080 | //.read_mac_address = az6027_read_mac_addr, | 1097 | .power_ctrl = az6027_power_ctrl, |
1081 | 1098 | .read_mac_address = az6027_read_mac_addr, | |
1099 | */ | ||
1082 | .rc_key_map = az6027_rc_keys, | 1100 | .rc_key_map = az6027_rc_keys, |
1083 | .rc_key_map_size = ARRAY_SIZE(az6027_rc_keys), | 1101 | .rc_key_map_size = ARRAY_SIZE(az6027_rc_keys), |
1084 | .rc_interval = 400, | 1102 | .rc_interval = 400, |
@@ -1087,11 +1105,12 @@ static struct dvb_usb_device_properties az6027_properties = { | |||
1087 | 1105 | ||
1088 | .num_device_descs = 1, | 1106 | .num_device_descs = 1, |
1089 | .devices = { | 1107 | .devices = { |
1090 | { .name = "AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)", | 1108 | { |
1091 | .cold_ids = { &az6027_usb_table[0], NULL }, | 1109 | .name = "AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)", |
1092 | .warm_ids = { NULL }, | 1110 | .cold_ids = { &az6027_usb_table[0], NULL }, |
1111 | .warm_ids = { NULL }, | ||
1093 | }, | 1112 | }, |
1094 | { NULL }, | 1113 | { NULL }, |
1095 | } | 1114 | } |
1096 | }; | 1115 | }; |
1097 | 1116 | ||
@@ -1099,7 +1118,6 @@ static struct dvb_usb_device_properties az6027_properties = { | |||
1099 | static struct usb_driver az6027_usb_driver = { | 1118 | static struct usb_driver az6027_usb_driver = { |
1100 | .name = "dvb_usb_az6027", | 1119 | .name = "dvb_usb_az6027", |
1101 | .probe = az6027_usb_probe, | 1120 | .probe = az6027_usb_probe, |
1102 | //.disconnect = dvb_usb_device_exit, | ||
1103 | .disconnect = az6027_usb_disconnect, | 1121 | .disconnect = az6027_usb_disconnect, |
1104 | .id_table = az6027_usb_table, | 1122 | .id_table = az6027_usb_table, |
1105 | }; | 1123 | }; |
@@ -1108,8 +1126,10 @@ static struct usb_driver az6027_usb_driver = { | |||
1108 | static int __init az6027_usb_module_init(void) | 1126 | static int __init az6027_usb_module_init(void) |
1109 | { | 1127 | { |
1110 | int result; | 1128 | int result; |
1111 | if ((result = usb_register(&az6027_usb_driver))) { | 1129 | |
1112 | err("usb_register failed. (%d)",result); | 1130 | result = usb_register(&az6027_usb_driver); |
1131 | if (result) { | ||
1132 | err("usb_register failed. (%d)", result); | ||
1113 | return result; | 1133 | return result; |
1114 | } | 1134 | } |
1115 | 1135 | ||
diff --git a/drivers/media/dvb/dvb-usb/az6027.h b/drivers/media/dvb/dvb-usb/az6027.h index 76bd28c5c0cf..f3afe17f3f3d 100644 --- a/drivers/media/dvb/dvb-usb/az6027.h +++ b/drivers/media/dvb/dvb-usb/az6027.h | |||
@@ -6,9 +6,9 @@ | |||
6 | 6 | ||
7 | 7 | ||
8 | extern int dvb_usb_az6027_debug; | 8 | extern int dvb_usb_az6027_debug; |
9 | #define deb_info(args...) dprintk(dvb_usb_az6027_debug,0x01,args) | 9 | #define deb_info(args...) dprintk(dvb_usb_az6027_debug, 0x01, args) |
10 | #define deb_xfer(args...) dprintk(dvb_usb_az6027_debug,0x02,args) | 10 | #define deb_xfer(args...) dprintk(dvb_usb_az6027_debug, 0x02, args) |
11 | #define deb_rc(args...) dprintk(dvb_usb_az6027_debug,0x04,args) | 11 | #define deb_rc(args...) dprintk(dvb_usb_az6027_debug, 0x04, args) |
12 | #define deb_fe(args...) dprintk(dvb_usb_az6027_debug,0x08,args) | 12 | #define deb_fe(args...) dprintk(dvb_usb_az6027_debug, 0x08, args) |
13 | 13 | ||
14 | #endif | 14 | #endif |