diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-19 14:18:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:58 -0400 |
commit | 0ab6e1c38d80ab586e3a1ca9e71844131d9f51dc (patch) | |
tree | 38a5c97475d77896510297b67885a4a486dda291 | |
parent | 35631dcc7f09522ff3119ba72d1252f80419779a (diff) |
V4L/DVB (10729): zoran: convert to v4l2_device/v4l2_subdev.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/zoran/zoran.h | 19 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_card.c | 263 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_device.c | 74 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_device.h | 13 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_driver.c | 78 |
5 files changed, 159 insertions, 288 deletions
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h index a323eb66e7c..ab1ced26276 100644 --- a/drivers/media/video/zoran/zoran.h +++ b/drivers/media/video/zoran/zoran.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #ifndef _BUZ_H_ | 31 | #ifndef _BUZ_H_ |
32 | #define _BUZ_H_ | 32 | #define _BUZ_H_ |
33 | 33 | ||
34 | #include <media/v4l2-device.h> | ||
35 | |||
34 | struct zoran_requestbuffers { | 36 | struct zoran_requestbuffers { |
35 | unsigned long count; /* Number of buffers for MJPEG grabbing */ | 37 | unsigned long count; /* Number of buffers for MJPEG grabbing */ |
36 | unsigned long size; /* Size PER BUFFER in bytes */ | 38 | unsigned long size; /* Size PER BUFFER in bytes */ |
@@ -339,7 +341,12 @@ struct zoran_fh { | |||
339 | struct card_info { | 341 | struct card_info { |
340 | enum card_type type; | 342 | enum card_type type; |
341 | char name[32]; | 343 | char name[32]; |
342 | u16 i2c_decoder, i2c_encoder; /* I2C types */ | 344 | const char *i2c_decoder; /* i2c decoder device */ |
345 | const char *mod_decoder; /* i2c decoder module */ | ||
346 | const unsigned short *addrs_decoder; | ||
347 | const char *i2c_encoder; /* i2c encoder device */ | ||
348 | const char *mod_encoder; /* i2c encoder module */ | ||
349 | const unsigned short *addrs_encoder; | ||
343 | u16 video_vfe, video_codec; /* videocodec types */ | 350 | u16 video_vfe, video_codec; /* videocodec types */ |
344 | u16 audio_chip; /* audio type */ | 351 | u16 audio_chip; /* audio type */ |
345 | 352 | ||
@@ -370,14 +377,15 @@ struct card_info { | |||
370 | }; | 377 | }; |
371 | 378 | ||
372 | struct zoran { | 379 | struct zoran { |
380 | struct v4l2_device v4l2_dev; | ||
373 | struct video_device *video_dev; | 381 | struct video_device *video_dev; |
374 | 382 | ||
375 | struct i2c_adapter i2c_adapter; /* */ | 383 | struct i2c_adapter i2c_adapter; /* */ |
376 | struct i2c_algo_bit_data i2c_algo; /* */ | 384 | struct i2c_algo_bit_data i2c_algo; /* */ |
377 | u32 i2cbr; | 385 | u32 i2cbr; |
378 | 386 | ||
379 | struct i2c_client *decoder; /* video decoder i2c client */ | 387 | struct v4l2_subdev *decoder; /* video decoder sub-device */ |
380 | struct i2c_client *encoder; /* video encoder i2c client */ | 388 | struct v4l2_subdev *encoder; /* video encoder sub-device */ |
381 | 389 | ||
382 | struct videocodec *codec; /* video codec */ | 390 | struct videocodec *codec; /* video codec */ |
383 | struct videocodec *vfe; /* video front end */ | 391 | struct videocodec *vfe; /* video front end */ |
@@ -481,6 +489,11 @@ struct zoran { | |||
481 | wait_queue_head_t test_q; | 489 | wait_queue_head_t test_q; |
482 | }; | 490 | }; |
483 | 491 | ||
492 | static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev) | ||
493 | { | ||
494 | return container_of(v4l2_dev, struct zoran, v4l2_dev); | ||
495 | } | ||
496 | |||
484 | /* There was something called _ALPHA_BUZ that used the PCI address instead of | 497 | /* There was something called _ALPHA_BUZ that used the PCI address instead of |
485 | * the kernel iomapped address for btread/btwrite. */ | 498 | * the kernel iomapped address for btread/btwrite. */ |
486 | #define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) | 499 | #define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) |
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index 38166d40c71..0b64612e35b 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -332,47 +332,6 @@ avs6eyes_init (struct zoran *zr) | |||
332 | } | 332 | } |
333 | 333 | ||
334 | static char * | 334 | static char * |
335 | i2cid_to_modulename (u16 i2c_id) | ||
336 | { | ||
337 | char *name = NULL; | ||
338 | |||
339 | switch (i2c_id) { | ||
340 | case I2C_DRIVERID_SAA7110: | ||
341 | name = "saa7110"; | ||
342 | break; | ||
343 | case I2C_DRIVERID_SAA711X: | ||
344 | name = "saa7115"; | ||
345 | break; | ||
346 | case I2C_DRIVERID_SAA7185B: | ||
347 | name = "saa7185"; | ||
348 | break; | ||
349 | case I2C_DRIVERID_ADV7170: | ||
350 | name = "adv7170"; | ||
351 | break; | ||
352 | case I2C_DRIVERID_ADV7175: | ||
353 | name = "adv7175"; | ||
354 | break; | ||
355 | case I2C_DRIVERID_BT819: | ||
356 | name = "bt819"; | ||
357 | break; | ||
358 | case I2C_DRIVERID_BT856: | ||
359 | name = "bt856"; | ||
360 | break; | ||
361 | case I2C_DRIVERID_BT866: | ||
362 | name = "bt866"; | ||
363 | break; | ||
364 | case I2C_DRIVERID_VPX3220: | ||
365 | name = "vpx3220"; | ||
366 | break; | ||
367 | case I2C_DRIVERID_KS0127: | ||
368 | name = "ks0127"; | ||
369 | break; | ||
370 | } | ||
371 | |||
372 | return name; | ||
373 | } | ||
374 | |||
375 | static char * | ||
376 | codecid_to_modulename (u16 codecid) | 335 | codecid_to_modulename (u16 codecid) |
377 | { | 336 | { |
378 | char *name = NULL; | 337 | char *name = NULL; |
@@ -422,11 +381,24 @@ static struct tvnorm f60ccir601_lm33r10 = { 858, 720, 56+54, 788, 525, 480, 16 } | |||
422 | static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 }; | 381 | static struct tvnorm f50ccir601_avs6eyes = { 864, 720, 74, 804, 625, 576, 18 }; |
423 | static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 }; | 382 | static struct tvnorm f60ccir601_avs6eyes = { 858, 720, 56, 788, 525, 480, 16 }; |
424 | 383 | ||
384 | static const unsigned short vpx3220_addrs[] = { 0x43, 0x47, I2C_CLIENT_END }; | ||
385 | static const unsigned short saa7110_addrs[] = { 0x4e, 0x4f, I2C_CLIENT_END }; | ||
386 | static const unsigned short saa7111_addrs[] = { 0x25, 0x24, I2C_CLIENT_END }; | ||
387 | static const unsigned short saa7114_addrs[] = { 0x21, 0x20, I2C_CLIENT_END }; | ||
388 | static const unsigned short adv717x_addrs[] = { 0x6a, 0x6b, 0x2a, 0x2b, I2C_CLIENT_END }; | ||
389 | static const unsigned short ks0127_addrs[] = { 0x6c, 0x6d, I2C_CLIENT_END }; | ||
390 | static const unsigned short saa7185_addrs[] = { 0x44, I2C_CLIENT_END }; | ||
391 | static const unsigned short bt819_addrs[] = { 0x45, I2C_CLIENT_END }; | ||
392 | static const unsigned short bt856_addrs[] = { 0x44, I2C_CLIENT_END }; | ||
393 | static const unsigned short bt866_addrs[] = { 0x44, I2C_CLIENT_END }; | ||
394 | |||
425 | static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | 395 | static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { |
426 | { | 396 | { |
427 | .type = DC10_old, | 397 | .type = DC10_old, |
428 | .name = "DC10(old)", | 398 | .name = "DC10(old)", |
429 | .i2c_decoder = I2C_DRIVERID_VPX3220, | 399 | .i2c_decoder = "vpx3220a", |
400 | .mod_decoder = "vpx3220", | ||
401 | .addrs_decoder = vpx3220_addrs, | ||
430 | .video_codec = CODEC_TYPE_ZR36050, | 402 | .video_codec = CODEC_TYPE_ZR36050, |
431 | .video_vfe = CODEC_TYPE_ZR36016, | 403 | .video_vfe = CODEC_TYPE_ZR36016, |
432 | 404 | ||
@@ -454,8 +426,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
454 | }, { | 426 | }, { |
455 | .type = DC10_new, | 427 | .type = DC10_new, |
456 | .name = "DC10(new)", | 428 | .name = "DC10(new)", |
457 | .i2c_decoder = I2C_DRIVERID_SAA7110, | 429 | .i2c_decoder = "saa7110", |
458 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 430 | .mod_decoder = "saa7110", |
431 | .addrs_decoder = saa7110_addrs, | ||
432 | .i2c_encoder = "adv7175", | ||
433 | .mod_encoder = "adv7175", | ||
434 | .addrs_encoder = adv717x_addrs, | ||
459 | .video_codec = CODEC_TYPE_ZR36060, | 435 | .video_codec = CODEC_TYPE_ZR36060, |
460 | 436 | ||
461 | .inputs = 3, | 437 | .inputs = 3, |
@@ -481,8 +457,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
481 | }, { | 457 | }, { |
482 | .type = DC10plus, | 458 | .type = DC10plus, |
483 | .name = "DC10plus", | 459 | .name = "DC10plus", |
484 | .i2c_decoder = I2C_DRIVERID_SAA7110, | 460 | .i2c_decoder = "saa7110", |
485 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 461 | .mod_decoder = "saa7110", |
462 | .addrs_decoder = saa7110_addrs, | ||
463 | .i2c_encoder = "adv7175", | ||
464 | .mod_encoder = "adv7175", | ||
465 | .addrs_encoder = adv717x_addrs, | ||
486 | .video_codec = CODEC_TYPE_ZR36060, | 466 | .video_codec = CODEC_TYPE_ZR36060, |
487 | 467 | ||
488 | .inputs = 3, | 468 | .inputs = 3, |
@@ -509,8 +489,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
509 | }, { | 489 | }, { |
510 | .type = DC30, | 490 | .type = DC30, |
511 | .name = "DC30", | 491 | .name = "DC30", |
512 | .i2c_decoder = I2C_DRIVERID_VPX3220, | 492 | .i2c_decoder = "vpx3220a", |
513 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 493 | .mod_decoder = "vpx3220", |
494 | .addrs_decoder = vpx3220_addrs, | ||
495 | .i2c_encoder = "adv7175", | ||
496 | .mod_encoder = "adv7175", | ||
497 | .addrs_encoder = adv717x_addrs, | ||
514 | .video_codec = CODEC_TYPE_ZR36050, | 498 | .video_codec = CODEC_TYPE_ZR36050, |
515 | .video_vfe = CODEC_TYPE_ZR36016, | 499 | .video_vfe = CODEC_TYPE_ZR36016, |
516 | 500 | ||
@@ -538,8 +522,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
538 | }, { | 522 | }, { |
539 | .type = DC30plus, | 523 | .type = DC30plus, |
540 | .name = "DC30plus", | 524 | .name = "DC30plus", |
541 | .i2c_decoder = I2C_DRIVERID_VPX3220, | 525 | .i2c_decoder = "vpx3220a", |
542 | .i2c_encoder = I2C_DRIVERID_ADV7175, | 526 | .mod_decoder = "vpx3220", |
527 | .addrs_decoder = vpx3220_addrs, | ||
528 | .i2c_encoder = "adv7175", | ||
529 | .mod_encoder = "adv7175", | ||
530 | .addrs_encoder = adv717x_addrs, | ||
543 | .video_codec = CODEC_TYPE_ZR36050, | 531 | .video_codec = CODEC_TYPE_ZR36050, |
544 | .video_vfe = CODEC_TYPE_ZR36016, | 532 | .video_vfe = CODEC_TYPE_ZR36016, |
545 | 533 | ||
@@ -567,8 +555,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
567 | }, { | 555 | }, { |
568 | .type = LML33, | 556 | .type = LML33, |
569 | .name = "LML33", | 557 | .name = "LML33", |
570 | .i2c_decoder = I2C_DRIVERID_BT819, | 558 | .i2c_decoder = "bt819a", |
571 | .i2c_encoder = I2C_DRIVERID_BT856, | 559 | .mod_decoder = "bt819", |
560 | .addrs_decoder = bt819_addrs, | ||
561 | .i2c_encoder = "bt856", | ||
562 | .mod_encoder = "bt856", | ||
563 | .addrs_encoder = bt856_addrs, | ||
572 | .video_codec = CODEC_TYPE_ZR36060, | 564 | .video_codec = CODEC_TYPE_ZR36060, |
573 | 565 | ||
574 | .inputs = 2, | 566 | .inputs = 2, |
@@ -594,8 +586,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
594 | }, { | 586 | }, { |
595 | .type = LML33R10, | 587 | .type = LML33R10, |
596 | .name = "LML33R10", | 588 | .name = "LML33R10", |
597 | .i2c_decoder = I2C_DRIVERID_SAA711X, | 589 | .i2c_decoder = "saa7114", |
598 | .i2c_encoder = I2C_DRIVERID_ADV7170, | 590 | .mod_decoder = "saa7115", |
591 | .addrs_decoder = saa7114_addrs, | ||
592 | .i2c_encoder = "adv7170", | ||
593 | .mod_encoder = "adv7170", | ||
594 | .addrs_encoder = adv717x_addrs, | ||
599 | .video_codec = CODEC_TYPE_ZR36060, | 595 | .video_codec = CODEC_TYPE_ZR36060, |
600 | 596 | ||
601 | .inputs = 2, | 597 | .inputs = 2, |
@@ -621,8 +617,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
621 | }, { | 617 | }, { |
622 | .type = BUZ, | 618 | .type = BUZ, |
623 | .name = "Buz", | 619 | .name = "Buz", |
624 | .i2c_decoder = I2C_DRIVERID_SAA711X, | 620 | .i2c_decoder = "saa7111", |
625 | .i2c_encoder = I2C_DRIVERID_SAA7185B, | 621 | .mod_decoder = "saa7115", |
622 | .addrs_decoder = saa7111_addrs, | ||
623 | .i2c_encoder = "saa7185", | ||
624 | .mod_encoder = "saa7185", | ||
625 | .addrs_encoder = saa7185_addrs, | ||
626 | .video_codec = CODEC_TYPE_ZR36060, | 626 | .video_codec = CODEC_TYPE_ZR36060, |
627 | 627 | ||
628 | .inputs = 2, | 628 | .inputs = 2, |
@@ -650,8 +650,12 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
650 | .name = "6-Eyes", | 650 | .name = "6-Eyes", |
651 | /* AverMedia chose not to brand the 6-Eyes. Thus it | 651 | /* AverMedia chose not to brand the 6-Eyes. Thus it |
652 | can't be autodetected, and requires card=x. */ | 652 | can't be autodetected, and requires card=x. */ |
653 | .i2c_decoder = I2C_DRIVERID_KS0127, | 653 | .i2c_decoder = "ks0127", |
654 | .i2c_encoder = I2C_DRIVERID_BT866, | 654 | .mod_decoder = "ks0127", |
655 | .addrs_decoder = ks0127_addrs, | ||
656 | .i2c_encoder = "bt866", | ||
657 | .mod_encoder = "bt866", | ||
658 | .addrs_encoder = bt866_addrs, | ||
655 | .video_codec = CODEC_TYPE_ZR36060, | 659 | .video_codec = CODEC_TYPE_ZR36060, |
656 | 660 | ||
657 | .inputs = 10, | 661 | .inputs = 10, |
@@ -732,69 +736,6 @@ zoran_i2c_setscl (void *data, | |||
732 | btwrite(zr->i2cbr, ZR36057_I2CBR); | 736 | btwrite(zr->i2cbr, ZR36057_I2CBR); |
733 | } | 737 | } |
734 | 738 | ||
735 | static int | ||
736 | zoran_i2c_client_register (struct i2c_client *client) | ||
737 | { | ||
738 | struct zoran *zr = (struct zoran *) i2c_get_adapdata(client->adapter); | ||
739 | int res = 0; | ||
740 | |||
741 | dprintk(2, | ||
742 | KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n", | ||
743 | ZR_DEVNAME(zr), client->driver->id); | ||
744 | |||
745 | mutex_lock(&zr->resource_lock); | ||
746 | |||
747 | if (zr->user > 0) { | ||
748 | /* we're already busy, so we keep a reference to | ||
749 | * them... Could do a lot of stuff here, but this | ||
750 | * is easiest. (Did I ever mention I'm a lazy ass?) | ||
751 | */ | ||
752 | res = -EBUSY; | ||
753 | goto clientreg_unlock_and_return; | ||
754 | } | ||
755 | |||
756 | if (client->driver->id == zr->card.i2c_decoder) | ||
757 | zr->decoder = client; | ||
758 | else if (client->driver->id == zr->card.i2c_encoder) | ||
759 | zr->encoder = client; | ||
760 | else { | ||
761 | res = -ENODEV; | ||
762 | goto clientreg_unlock_and_return; | ||
763 | } | ||
764 | |||
765 | clientreg_unlock_and_return: | ||
766 | mutex_unlock(&zr->resource_lock); | ||
767 | |||
768 | return res; | ||
769 | } | ||
770 | |||
771 | static int | ||
772 | zoran_i2c_client_unregister (struct i2c_client *client) | ||
773 | { | ||
774 | struct zoran *zr = (struct zoran *) i2c_get_adapdata(client->adapter); | ||
775 | int res = 0; | ||
776 | |||
777 | dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr)); | ||
778 | |||
779 | mutex_lock(&zr->resource_lock); | ||
780 | |||
781 | if (zr->user > 0) { | ||
782 | res = -EBUSY; | ||
783 | goto clientunreg_unlock_and_return; | ||
784 | } | ||
785 | |||
786 | /* try to locate it */ | ||
787 | if (client == zr->encoder) { | ||
788 | zr->encoder = NULL; | ||
789 | } else if (client == zr->decoder) { | ||
790 | zr->decoder = NULL; | ||
791 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id); | ||
792 | } | ||
793 | clientunreg_unlock_and_return: | ||
794 | mutex_unlock(&zr->resource_lock); | ||
795 | return res; | ||
796 | } | ||
797 | |||
798 | static const struct i2c_algo_bit_data zoran_i2c_bit_data_template = { | 739 | static const struct i2c_algo_bit_data zoran_i2c_bit_data_template = { |
799 | .setsda = zoran_i2c_setsda, | 740 | .setsda = zoran_i2c_setsda, |
800 | .setscl = zoran_i2c_setscl, | 741 | .setscl = zoran_i2c_setscl, |
@@ -810,13 +751,10 @@ zoran_register_i2c (struct zoran *zr) | |||
810 | memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, | 751 | memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, |
811 | sizeof(struct i2c_algo_bit_data)); | 752 | sizeof(struct i2c_algo_bit_data)); |
812 | zr->i2c_algo.data = zr; | 753 | zr->i2c_algo.data = zr; |
813 | zr->i2c_adapter.class = I2C_CLASS_TV_ANALOG; | ||
814 | zr->i2c_adapter.id = I2C_HW_B_ZR36067; | 754 | zr->i2c_adapter.id = I2C_HW_B_ZR36067; |
815 | zr->i2c_adapter.client_register = zoran_i2c_client_register; | ||
816 | zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister; | ||
817 | strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), | 755 | strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), |
818 | sizeof(zr->i2c_adapter.name)); | 756 | sizeof(zr->i2c_adapter.name)); |
819 | i2c_set_adapdata(&zr->i2c_adapter, zr); | 757 | i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev); |
820 | zr->i2c_adapter.algo_data = &zr->i2c_algo; | 758 | zr->i2c_adapter.algo_data = &zr->i2c_algo; |
821 | zr->i2c_adapter.dev.parent = &zr->pci_dev->dev; | 759 | zr->i2c_adapter.dev.parent = &zr->pci_dev->dev; |
822 | return i2c_bit_add_bus(&zr->i2c_adapter); | 760 | return i2c_bit_add_bus(&zr->i2c_adapter); |
@@ -1173,8 +1111,8 @@ zr36057_init (struct zoran *zr) | |||
1173 | if (!pass_through) { | 1111 | if (!pass_through) { |
1174 | struct v4l2_routing route = { 2, 0 }; | 1112 | struct v4l2_routing route = { 2, 0 }; |
1175 | 1113 | ||
1176 | decoder_command(zr, VIDIOC_STREAMOFF, 0); | 1114 | decoder_call(zr, video, s_stream, 0); |
1177 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1115 | encoder_call(zr, video, s_routing, &route); |
1178 | } | 1116 | } |
1179 | 1117 | ||
1180 | zr->zoran_proc = NULL; | 1118 | zr->zoran_proc = NULL; |
@@ -1189,7 +1127,8 @@ exit_free: | |||
1189 | 1127 | ||
1190 | static void __devexit zoran_remove(struct pci_dev *pdev) | 1128 | static void __devexit zoran_remove(struct pci_dev *pdev) |
1191 | { | 1129 | { |
1192 | struct zoran *zr = pci_get_drvdata(pdev); | 1130 | struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev); |
1131 | struct zoran *zr = to_zoran(v4l2_dev); | ||
1193 | 1132 | ||
1194 | if (!zr->initialized) | 1133 | if (!zr->initialized) |
1195 | goto exit_free; | 1134 | goto exit_free; |
@@ -1222,7 +1161,7 @@ static void __devexit zoran_remove(struct pci_dev *pdev) | |||
1222 | pci_disable_device(zr->pci_dev); | 1161 | pci_disable_device(zr->pci_dev); |
1223 | video_unregister_device(zr->video_dev); | 1162 | video_unregister_device(zr->video_dev); |
1224 | exit_free: | 1163 | exit_free: |
1225 | pci_set_drvdata(pdev, NULL); | 1164 | v4l2_device_unregister(&zr->v4l2_dev); |
1226 | kfree(zr); | 1165 | kfree(zr); |
1227 | } | 1166 | } |
1228 | 1167 | ||
@@ -1294,7 +1233,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1294 | struct videocodec_master *master_vfe = NULL; | 1233 | struct videocodec_master *master_vfe = NULL; |
1295 | struct videocodec_master *master_codec = NULL; | 1234 | struct videocodec_master *master_codec = NULL; |
1296 | int card_num; | 1235 | int card_num; |
1297 | char *i2c_enc_name, *i2c_dec_name, *codec_name, *vfe_name; | 1236 | char *codec_name, *vfe_name; |
1298 | unsigned int nr; | 1237 | unsigned int nr; |
1299 | 1238 | ||
1300 | 1239 | ||
@@ -1315,13 +1254,15 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1315 | ZORAN_NAME); | 1254 | ZORAN_NAME); |
1316 | return -ENOMEM; | 1255 | return -ENOMEM; |
1317 | } | 1256 | } |
1257 | if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev)) | ||
1258 | goto zr_free_mem; | ||
1318 | zr->pci_dev = pdev; | 1259 | zr->pci_dev = pdev; |
1319 | zr->id = nr; | 1260 | zr->id = nr; |
1320 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); | 1261 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); |
1321 | spin_lock_init(&zr->spinlock); | 1262 | spin_lock_init(&zr->spinlock); |
1322 | mutex_init(&zr->resource_lock); | 1263 | mutex_init(&zr->resource_lock); |
1323 | if (pci_enable_device(pdev)) | 1264 | if (pci_enable_device(pdev)) |
1324 | goto zr_free_mem; | 1265 | goto zr_unreg; |
1325 | pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision); | 1266 | pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision); |
1326 | 1267 | ||
1327 | dprintk(1, | 1268 | dprintk(1, |
@@ -1348,7 +1289,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1348 | KERN_ERR | 1289 | KERN_ERR |
1349 | "%s: It is not possible to auto-detect ZR36057 based cards\n", | 1290 | "%s: It is not possible to auto-detect ZR36057 based cards\n", |
1350 | ZR_DEVNAME(zr)); | 1291 | ZR_DEVNAME(zr)); |
1351 | goto zr_free_mem; | 1292 | goto zr_unreg; |
1352 | } | 1293 | } |
1353 | 1294 | ||
1354 | card_num = ent->driver_data; | 1295 | card_num = ent->driver_data; |
@@ -1357,7 +1298,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1357 | KERN_ERR | 1298 | KERN_ERR |
1358 | "%s: Unknown card, try specifying card=X module parameter\n", | 1299 | "%s: Unknown card, try specifying card=X module parameter\n", |
1359 | ZR_DEVNAME(zr)); | 1300 | ZR_DEVNAME(zr)); |
1360 | goto zr_free_mem; | 1301 | goto zr_unreg; |
1361 | } | 1302 | } |
1362 | dprintk(3, | 1303 | dprintk(3, |
1363 | KERN_DEBUG | 1304 | KERN_DEBUG |
@@ -1370,7 +1311,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1370 | KERN_ERR | 1311 | KERN_ERR |
1371 | "%s: User specified card type %d out of range (0 .. %d)\n", | 1312 | "%s: User specified card type %d out of range (0 .. %d)\n", |
1372 | ZR_DEVNAME(zr), card_num, NUM_CARDS - 1); | 1313 | ZR_DEVNAME(zr), card_num, NUM_CARDS - 1); |
1373 | goto zr_free_mem; | 1314 | goto zr_unreg; |
1374 | } | 1315 | } |
1375 | } | 1316 | } |
1376 | 1317 | ||
@@ -1389,7 +1330,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1389 | KERN_ERR | 1330 | KERN_ERR |
1390 | "%s: %s() - ioremap failed\n", | 1331 | "%s: %s() - ioremap failed\n", |
1391 | ZR_DEVNAME(zr), __func__); | 1332 | ZR_DEVNAME(zr), __func__); |
1392 | goto zr_free_mem; | 1333 | goto zr_unreg; |
1393 | } | 1334 | } |
1394 | 1335 | ||
1395 | result = request_irq(zr->pci_dev->irq, zoran_irq, | 1336 | result = request_irq(zr->pci_dev->irq, zoran_irq, |
@@ -1432,46 +1373,6 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1432 | dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", | 1373 | dprintk(2, KERN_INFO "%s: Initializing i2c bus...\n", |
1433 | ZR_DEVNAME(zr)); | 1374 | ZR_DEVNAME(zr)); |
1434 | 1375 | ||
1435 | /* i2c decoder */ | ||
1436 | if (decoder[zr->id] != -1) { | ||
1437 | i2c_dec_name = i2cid_to_modulename(decoder[zr->id]); | ||
1438 | zr->card.i2c_decoder = decoder[zr->id]; | ||
1439 | } else if (zr->card.i2c_decoder != 0) { | ||
1440 | i2c_dec_name = i2cid_to_modulename(zr->card.i2c_decoder); | ||
1441 | } else { | ||
1442 | i2c_dec_name = NULL; | ||
1443 | } | ||
1444 | |||
1445 | if (i2c_dec_name) { | ||
1446 | result = request_module(i2c_dec_name); | ||
1447 | if (result < 0) { | ||
1448 | dprintk(1, | ||
1449 | KERN_ERR | ||
1450 | "%s: failed to load module %s: %d\n", | ||
1451 | ZR_DEVNAME(zr), i2c_dec_name, result); | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | /* i2c encoder */ | ||
1456 | if (encoder[zr->id] != -1) { | ||
1457 | i2c_enc_name = i2cid_to_modulename(encoder[zr->id]); | ||
1458 | zr->card.i2c_encoder = encoder[zr->id]; | ||
1459 | } else if (zr->card.i2c_encoder != 0) { | ||
1460 | i2c_enc_name = i2cid_to_modulename(zr->card.i2c_encoder); | ||
1461 | } else { | ||
1462 | i2c_enc_name = NULL; | ||
1463 | } | ||
1464 | |||
1465 | if (i2c_enc_name) { | ||
1466 | result = request_module(i2c_enc_name); | ||
1467 | if (result < 0) { | ||
1468 | dprintk(1, | ||
1469 | KERN_ERR | ||
1470 | "%s: failed to load module %s: %d\n", | ||
1471 | ZR_DEVNAME(zr), i2c_enc_name, result); | ||
1472 | } | ||
1473 | } | ||
1474 | |||
1475 | if (zoran_register_i2c(zr) < 0) { | 1376 | if (zoran_register_i2c(zr) < 0) { |
1476 | dprintk(1, | 1377 | dprintk(1, |
1477 | KERN_ERR | 1378 | KERN_ERR |
@@ -1480,6 +1381,14 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1480 | goto zr_free_irq; | 1381 | goto zr_free_irq; |
1481 | } | 1382 | } |
1482 | 1383 | ||
1384 | zr->decoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, | ||
1385 | zr->card.mod_decoder, zr->card.i2c_decoder, zr->card.addrs_decoder); | ||
1386 | |||
1387 | if (zr->card.mod_encoder) | ||
1388 | zr->encoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, | ||
1389 | zr->card.mod_encoder, zr->card.i2c_encoder, | ||
1390 | zr->card.addrs_encoder); | ||
1391 | |||
1483 | dprintk(2, | 1392 | dprintk(2, |
1484 | KERN_INFO "%s: Initializing videocodec bus...\n", | 1393 | KERN_INFO "%s: Initializing videocodec bus...\n", |
1485 | ZR_DEVNAME(zr)); | 1394 | ZR_DEVNAME(zr)); |
@@ -1569,8 +1478,6 @@ static int __devinit zoran_probe(struct pci_dev *pdev, | |||
1569 | 1478 | ||
1570 | zoran_proc_init(zr); | 1479 | zoran_proc_init(zr); |
1571 | 1480 | ||
1572 | pci_set_drvdata(pdev, zr); | ||
1573 | |||
1574 | return 0; | 1481 | return 0; |
1575 | 1482 | ||
1576 | zr_detach_vfe: | 1483 | zr_detach_vfe: |
@@ -1588,6 +1495,8 @@ zr_free_irq: | |||
1588 | free_irq(zr->pci_dev->irq, zr); | 1495 | free_irq(zr->pci_dev->irq, zr); |
1589 | zr_unmap: | 1496 | zr_unmap: |
1590 | iounmap(zr->zr36057_mem); | 1497 | iounmap(zr->zr36057_mem); |
1498 | zr_unreg: | ||
1499 | v4l2_device_unregister(&zr->v4l2_dev); | ||
1591 | zr_free_mem: | 1500 | zr_free_mem: |
1592 | kfree(zr); | 1501 | kfree(zr); |
1593 | 1502 | ||
diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c index 712599a5ed7..3336611c0cd 100644 --- a/drivers/media/video/zoran/zoran_device.c +++ b/drivers/media/video/zoran/zoran_device.c | |||
@@ -36,15 +36,12 @@ | |||
36 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
37 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
38 | #include <linux/i2c-algo-bit.h> | 38 | #include <linux/i2c-algo-bit.h> |
39 | #include <linux/videodev.h> | ||
40 | #include <linux/videodev2.h> | 39 | #include <linux/videodev2.h> |
41 | #include <media/v4l2-common.h> | 40 | #include <media/v4l2-common.h> |
42 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
43 | #include <linux/sem.h> | 42 | #include <linux/sem.h> |
44 | 43 | ||
45 | #include <linux/pci.h> | 44 | #include <linux/pci.h> |
46 | #include <linux/video_decoder.h> | ||
47 | #include <linux/video_encoder.h> | ||
48 | #include <linux/delay.h> | 45 | #include <linux/delay.h> |
49 | #include <linux/wait.h> | 46 | #include <linux/wait.h> |
50 | 47 | ||
@@ -1000,9 +997,9 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1000 | * the video bus direction set to input. | 997 | * the video bus direction set to input. |
1001 | */ | 998 | */ |
1002 | set_videobus_dir(zr, 0); | 999 | set_videobus_dir(zr, 0); |
1003 | decoder_command(zr, VIDIOC_STREAMON, 0); | 1000 | decoder_call(zr, video, s_stream, 1); |
1004 | route.input = 0; | 1001 | route.input = 0; |
1005 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1002 | encoder_call(zr, video, s_routing, &route); |
1006 | 1003 | ||
1007 | /* Take the JPEG codec and the VFE out of sleep */ | 1004 | /* Take the JPEG codec and the VFE out of sleep */ |
1008 | jpeg_codec_sleep(zr, 0); | 1005 | jpeg_codec_sleep(zr, 0); |
@@ -1048,10 +1045,10 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1048 | /* In motion decompression mode, the decoder output must be disabled, and | 1045 | /* In motion decompression mode, the decoder output must be disabled, and |
1049 | * the video bus direction set to output. | 1046 | * the video bus direction set to output. |
1050 | */ | 1047 | */ |
1051 | decoder_command(zr, VIDIOC_STREAMOFF, 0); | 1048 | decoder_call(zr, video, s_stream, 0); |
1052 | set_videobus_dir(zr, 1); | 1049 | set_videobus_dir(zr, 1); |
1053 | route.input = 1; | 1050 | route.input = 1; |
1054 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1051 | encoder_call(zr, video, s_routing, &route); |
1055 | 1052 | ||
1056 | /* Take the JPEG codec and the VFE out of sleep */ | 1053 | /* Take the JPEG codec and the VFE out of sleep */ |
1057 | jpeg_codec_sleep(zr, 0); | 1054 | jpeg_codec_sleep(zr, 0); |
@@ -1095,9 +1092,9 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1095 | jpeg_codec_sleep(zr, 1); | 1092 | jpeg_codec_sleep(zr, 1); |
1096 | zr36057_adjust_vfe(zr, mode); | 1093 | zr36057_adjust_vfe(zr, mode); |
1097 | 1094 | ||
1098 | decoder_command(zr, VIDIOC_STREAMON, 0); | 1095 | decoder_call(zr, video, s_stream, 1); |
1099 | route.input = 0; | 1096 | route.input = 0; |
1100 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1097 | encoder_call(zr, video, s_routing, &route); |
1101 | 1098 | ||
1102 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); | 1099 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); |
1103 | break; | 1100 | break; |
@@ -1210,7 +1207,7 @@ static void zoran_restart(struct zoran *zr) | |||
1210 | int status = 0, mode; | 1207 | int status = 0, mode; |
1211 | 1208 | ||
1212 | if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { | 1209 | if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { |
1213 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); | 1210 | decoder_call(zr, video, g_input_status, &status); |
1214 | mode = CODEC_DO_COMPRESSION; | 1211 | mode = CODEC_DO_COMPRESSION; |
1215 | } else { | 1212 | } else { |
1216 | status = V4L2_IN_ST_NO_SIGNAL; | 1213 | status = V4L2_IN_ST_NO_SIGNAL; |
@@ -1590,14 +1587,14 @@ zoran_init_hardware (struct zoran *zr) | |||
1590 | 1587 | ||
1591 | route.input = zr->card.input[zr->input].muxsel; | 1588 | route.input = zr->card.input[zr->input].muxsel; |
1592 | 1589 | ||
1593 | decoder_command(zr, VIDIOC_INT_INIT, NULL); | 1590 | decoder_call(zr, core, init, 0); |
1594 | decoder_command(zr, VIDIOC_S_STD, &zr->norm); | 1591 | decoder_s_std(zr, zr->norm); |
1595 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1592 | decoder_s_routing(zr, &route); |
1596 | 1593 | ||
1597 | encoder_command(zr, VIDIOC_INT_INIT, NULL); | 1594 | encoder_call(zr, core, init, 0); |
1598 | encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &zr->norm); | 1595 | encoder_call(zr, video, s_std_output, zr->norm); |
1599 | route.input = 0; | 1596 | route.input = 0; |
1600 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1597 | encoder_call(zr, video, s_routing, &route); |
1601 | 1598 | ||
1602 | /* toggle JPEG codec sleep to sync PLL */ | 1599 | /* toggle JPEG codec sleep to sync PLL */ |
1603 | jpeg_codec_sleep(zr, 1); | 1600 | jpeg_codec_sleep(zr, 1); |
@@ -1662,37 +1659,30 @@ zr36057_init_vfe (struct zoran *zr) | |||
1662 | * Interface to decoder and encoder chips using i2c bus | 1659 | * Interface to decoder and encoder chips using i2c bus |
1663 | */ | 1660 | */ |
1664 | 1661 | ||
1665 | int | 1662 | int decoder_s_std(struct zoran *zr, v4l2_std_id std) |
1666 | decoder_command (struct zoran *zr, | ||
1667 | int cmd, | ||
1668 | void *data) | ||
1669 | { | 1663 | { |
1670 | if (zr->decoder == NULL) | 1664 | int res; |
1671 | return -EIO; | ||
1672 | |||
1673 | if (zr->card.type == LML33 && | ||
1674 | (cmd == VIDIOC_S_STD || cmd == VIDIOC_INT_S_VIDEO_ROUTING)) { | ||
1675 | int res; | ||
1676 | 1665 | ||
1677 | // Bt819 needs to reset its FIFO buffer using #FRST pin and | 1666 | /* Bt819 needs to reset its FIFO buffer using #FRST pin and |
1678 | // LML33 card uses GPIO(7) for that. | 1667 | LML33 card uses GPIO(7) for that. */ |
1668 | if (zr->card.type == LML33) | ||
1679 | GPIO(zr, 7, 0); | 1669 | GPIO(zr, 7, 0); |
1680 | res = zr->decoder->driver->command(zr->decoder, cmd, data); | 1670 | res = decoder_call(zr, tuner, s_std, std); |
1681 | // Pull #FRST high. | 1671 | if (zr->card.type == LML33) |
1682 | GPIO(zr, 7, 1); | 1672 | GPIO(zr, 7, 1); /* Pull #FRST high. */ |
1683 | return res; | 1673 | return res; |
1684 | } else | ||
1685 | return zr->decoder->driver->command(zr->decoder, cmd, | ||
1686 | data); | ||
1687 | } | 1674 | } |
1688 | 1675 | ||
1689 | int | 1676 | int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route) |
1690 | encoder_command (struct zoran *zr, | ||
1691 | int cmd, | ||
1692 | void *data) | ||
1693 | { | 1677 | { |
1694 | if (zr->encoder == NULL) | 1678 | int res; |
1695 | return -1; | ||
1696 | 1679 | ||
1697 | return zr->encoder->driver->command(zr->encoder, cmd, data); | 1680 | /* Bt819 needs to reset its FIFO buffer using #FRST pin and |
1681 | LML33 card uses GPIO(7) for that. */ | ||
1682 | if (zr->card.type == LML33) | ||
1683 | GPIO(zr, 7, 0); | ||
1684 | res = decoder_call(zr, video, s_routing, route); | ||
1685 | if (zr->card.type == LML33) | ||
1686 | GPIO(zr, 7, 1); /* Pull #FRST high. */ | ||
1687 | return res; | ||
1698 | } | 1688 | } |
diff --git a/drivers/media/video/zoran/zoran_device.h b/drivers/media/video/zoran/zoran_device.h index 74c6c8edb7d..14d4e7aa6ce 100644 --- a/drivers/media/video/zoran/zoran_device.h +++ b/drivers/media/video/zoran/zoran_device.h | |||
@@ -87,11 +87,12 @@ extern int jpg_bufsize; | |||
87 | extern int pass_through; | 87 | extern int pass_through; |
88 | 88 | ||
89 | /* i2c */ | 89 | /* i2c */ |
90 | extern int decoder_command(struct zoran *zr, | 90 | #define decoder_call(zr, o, f, args...) \ |
91 | int cmd, | 91 | v4l2_subdev_call(zr->decoder, o, f, ##args) |
92 | void *data); | 92 | #define encoder_call(zr, o, f, args...) \ |
93 | extern int encoder_command(struct zoran *zr, | 93 | v4l2_subdev_call(zr->encoder, o, f, ##args) |
94 | int cmd, | 94 | |
95 | void *data); | 95 | int decoder_s_std(struct zoran *zr, v4l2_std_id std); |
96 | int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route); | ||
96 | 97 | ||
97 | #endif /* __ZORAN_DEVICE_H__ */ | 98 | #endif /* __ZORAN_DEVICE_H__ */ |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index 611fc7f18e1..b027a68e8c6 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -963,10 +963,6 @@ static int zoran_open(struct file *file) | |||
963 | 963 | ||
964 | lock_kernel(); | 964 | lock_kernel(); |
965 | 965 | ||
966 | /* see fs/device.c - the kernel already locks during open(), | ||
967 | * so locking ourselves only causes deadlocks */ | ||
968 | /*mutex_lock(&zr->resource_lock);*/ | ||
969 | |||
970 | if (zr->user >= 2048) { | 966 | if (zr->user >= 2048) { |
971 | dprintk(1, KERN_ERR "%s: too many users (%d) on device\n", | 967 | dprintk(1, KERN_ERR "%s: too many users (%d) on device\n", |
972 | ZR_DEVNAME(zr), zr->user); | 968 | ZR_DEVNAME(zr), zr->user); |
@@ -974,32 +970,6 @@ static int zoran_open(struct file *file) | |||
974 | goto fail_unlock; | 970 | goto fail_unlock; |
975 | } | 971 | } |
976 | 972 | ||
977 | if (!zr->decoder) { | ||
978 | dprintk(1, | ||
979 | KERN_ERR "%s: no TV decoder loaded for device!\n", | ||
980 | ZR_DEVNAME(zr)); | ||
981 | res = -EIO; | ||
982 | goto fail_unlock; | ||
983 | } | ||
984 | |||
985 | if (!try_module_get(zr->decoder->driver->driver.owner)) { | ||
986 | dprintk(1, | ||
987 | KERN_ERR | ||
988 | "%s: failed to grab ownership of video decoder\n", | ||
989 | ZR_DEVNAME(zr)); | ||
990 | res = -EIO; | ||
991 | goto fail_unlock; | ||
992 | } | ||
993 | if (zr->encoder && | ||
994 | !try_module_get(zr->encoder->driver->driver.owner)) { | ||
995 | dprintk(1, | ||
996 | KERN_ERR | ||
997 | "%s: failed to grab ownership of video encoder\n", | ||
998 | ZR_DEVNAME(zr)); | ||
999 | res = -EIO; | ||
1000 | goto fail_decoder; | ||
1001 | } | ||
1002 | |||
1003 | /* now, create the open()-specific file_ops struct */ | 973 | /* now, create the open()-specific file_ops struct */ |
1004 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); | 974 | fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL); |
1005 | if (!fh) { | 975 | if (!fh) { |
@@ -1008,7 +978,7 @@ static int zoran_open(struct file *file) | |||
1008 | "%s: zoran_open() - allocation of zoran_fh failed\n", | 978 | "%s: zoran_open() - allocation of zoran_fh failed\n", |
1009 | ZR_DEVNAME(zr)); | 979 | ZR_DEVNAME(zr)); |
1010 | res = -ENOMEM; | 980 | res = -ENOMEM; |
1011 | goto fail_encoder; | 981 | goto fail_unlock; |
1012 | } | 982 | } |
1013 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows | 983 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows |
1014 | * on norm-change! */ | 984 | * on norm-change! */ |
@@ -1047,11 +1017,6 @@ static int zoran_open(struct file *file) | |||
1047 | 1017 | ||
1048 | fail_fh: | 1018 | fail_fh: |
1049 | kfree(fh); | 1019 | kfree(fh); |
1050 | fail_encoder: | ||
1051 | if (zr->encoder) | ||
1052 | module_put(zr->encoder->driver->driver.owner); | ||
1053 | fail_decoder: | ||
1054 | module_put(zr->decoder->driver->driver.owner); | ||
1055 | fail_unlock: | 1020 | fail_unlock: |
1056 | unlock_kernel(); | 1021 | unlock_kernel(); |
1057 | 1022 | ||
@@ -1104,8 +1069,8 @@ zoran_close(struct file *file) | |||
1104 | if (!pass_through) { /* Switch to color bar */ | 1069 | if (!pass_through) { /* Switch to color bar */ |
1105 | struct v4l2_routing route = { 2, 0 }; | 1070 | struct v4l2_routing route = { 2, 0 }; |
1106 | 1071 | ||
1107 | decoder_command(zr, VIDIOC_STREAMOFF, 0); | 1072 | decoder_call(zr, video, s_stream, 0); |
1108 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1073 | encoder_call(zr, video, s_routing, &route); |
1109 | } | 1074 | } |
1110 | } | 1075 | } |
1111 | 1076 | ||
@@ -1113,13 +1078,6 @@ zoran_close(struct file *file) | |||
1113 | kfree(fh->overlay_mask); | 1078 | kfree(fh->overlay_mask); |
1114 | kfree(fh); | 1079 | kfree(fh); |
1115 | 1080 | ||
1116 | /* release locks on the i2c modules */ | ||
1117 | module_put(zr->decoder->driver->driver.owner); | ||
1118 | if (zr->encoder) | ||
1119 | module_put(zr->encoder->driver->driver.owner); | ||
1120 | |||
1121 | /*mutex_unlock(&zr->resource_lock);*/ | ||
1122 | |||
1123 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); | 1081 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); |
1124 | 1082 | ||
1125 | return 0; | 1083 | return 0; |
@@ -1567,20 +1525,20 @@ zoran_set_norm (struct zoran *zr, | |||
1567 | int status = 0; | 1525 | int status = 0; |
1568 | v4l2_std_id std = 0; | 1526 | v4l2_std_id std = 0; |
1569 | 1527 | ||
1570 | decoder_command(zr, VIDIOC_QUERYSTD, &std); | 1528 | decoder_call(zr, video, querystd, &std); |
1571 | decoder_command(zr, VIDIOC_S_STD, &std); | 1529 | decoder_s_std(zr, std); |
1572 | 1530 | ||
1573 | /* let changes come into effect */ | 1531 | /* let changes come into effect */ |
1574 | ssleep(2); | 1532 | ssleep(2); |
1575 | 1533 | ||
1576 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); | 1534 | decoder_call(zr, video, g_input_status, &status); |
1577 | if (status & V4L2_IN_ST_NO_SIGNAL) { | 1535 | if (status & V4L2_IN_ST_NO_SIGNAL) { |
1578 | dprintk(1, | 1536 | dprintk(1, |
1579 | KERN_ERR | 1537 | KERN_ERR |
1580 | "%s: set_norm() - no norm detected\n", | 1538 | "%s: set_norm() - no norm detected\n", |
1581 | ZR_DEVNAME(zr)); | 1539 | ZR_DEVNAME(zr)); |
1582 | /* reset norm */ | 1540 | /* reset norm */ |
1583 | decoder_command(zr, VIDIOC_S_STD, &zr->norm); | 1541 | decoder_s_std(zr, zr->norm); |
1584 | return -EIO; | 1542 | return -EIO; |
1585 | } | 1543 | } |
1586 | 1544 | ||
@@ -1599,8 +1557,8 @@ zoran_set_norm (struct zoran *zr, | |||
1599 | if (on) | 1557 | if (on) |
1600 | zr36057_overlay(zr, 0); | 1558 | zr36057_overlay(zr, 0); |
1601 | 1559 | ||
1602 | decoder_command(zr, VIDIOC_S_STD, &norm); | 1560 | decoder_s_std(zr, norm); |
1603 | encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &norm); | 1561 | encoder_call(zr, video, s_std_output, norm); |
1604 | 1562 | ||
1605 | if (on) | 1563 | if (on) |
1606 | zr36057_overlay(zr, 1); | 1564 | zr36057_overlay(zr, 1); |
@@ -1641,7 +1599,7 @@ zoran_set_input (struct zoran *zr, | |||
1641 | route.input = zr->card.input[input].muxsel; | 1599 | route.input = zr->card.input[input].muxsel; |
1642 | zr->input = input; | 1600 | zr->input = input; |
1643 | 1601 | ||
1644 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1602 | decoder_s_routing(zr, &route); |
1645 | 1603 | ||
1646 | return 0; | 1604 | return 0; |
1647 | } | 1605 | } |
@@ -1886,18 +1844,18 @@ jpgreqbuf_unlock_and_return: | |||
1886 | goto gstat_unlock_and_return; | 1844 | goto gstat_unlock_and_return; |
1887 | } | 1845 | } |
1888 | 1846 | ||
1889 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1847 | decoder_s_routing(zr, &route); |
1890 | 1848 | ||
1891 | /* sleep 1 second */ | 1849 | /* sleep 1 second */ |
1892 | ssleep(1); | 1850 | ssleep(1); |
1893 | 1851 | ||
1894 | /* Get status of video decoder */ | 1852 | /* Get status of video decoder */ |
1895 | decoder_command(zr, VIDIOC_QUERYSTD, &norm); | 1853 | decoder_call(zr, video, querystd, &norm); |
1896 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); | 1854 | decoder_call(zr, video, g_input_status, &status); |
1897 | 1855 | ||
1898 | /* restore previous input and norm */ | 1856 | /* restore previous input and norm */ |
1899 | route.input = zr->card.input[zr->input].muxsel; | 1857 | route.input = zr->card.input[zr->input].muxsel; |
1900 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 1858 | decoder_s_routing(zr, &route); |
1901 | gstat_unlock_and_return: | 1859 | gstat_unlock_and_return: |
1902 | mutex_unlock(&zr->resource_lock); | 1860 | mutex_unlock(&zr->resource_lock); |
1903 | 1861 | ||
@@ -2836,7 +2794,7 @@ static int zoran_queryctrl(struct file *file, void *__fh, | |||
2836 | ctrl->id > V4L2_CID_HUE) | 2794 | ctrl->id > V4L2_CID_HUE) |
2837 | return -EINVAL; | 2795 | return -EINVAL; |
2838 | 2796 | ||
2839 | decoder_command(zr, VIDIOC_QUERYCTRL, ctrl); | 2797 | decoder_call(zr, core, queryctrl, ctrl); |
2840 | 2798 | ||
2841 | return 0; | 2799 | return 0; |
2842 | } | 2800 | } |
@@ -2852,7 +2810,7 @@ static int zoran_g_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl | |||
2852 | return -EINVAL; | 2810 | return -EINVAL; |
2853 | 2811 | ||
2854 | mutex_lock(&zr->resource_lock); | 2812 | mutex_lock(&zr->resource_lock); |
2855 | decoder_command(zr, VIDIOC_G_CTRL, ctrl); | 2813 | decoder_call(zr, core, g_ctrl, ctrl); |
2856 | mutex_unlock(&zr->resource_lock); | 2814 | mutex_unlock(&zr->resource_lock); |
2857 | 2815 | ||
2858 | return 0; | 2816 | return 0; |
@@ -2869,7 +2827,7 @@ static int zoran_s_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl | |||
2869 | return -EINVAL; | 2827 | return -EINVAL; |
2870 | 2828 | ||
2871 | mutex_lock(&zr->resource_lock); | 2829 | mutex_lock(&zr->resource_lock); |
2872 | decoder_command(zr, VIDIOC_S_CTRL, ctrl); | 2830 | decoder_call(zr, core, s_ctrl, ctrl); |
2873 | mutex_unlock(&zr->resource_lock); | 2831 | mutex_unlock(&zr->resource_lock); |
2874 | 2832 | ||
2875 | return 0; | 2833 | return 0; |
@@ -2924,7 +2882,7 @@ static int zoran_enum_input(struct file *file, void *__fh, | |||
2924 | 2882 | ||
2925 | /* Get status of video decoder */ | 2883 | /* Get status of video decoder */ |
2926 | mutex_lock(&zr->resource_lock); | 2884 | mutex_lock(&zr->resource_lock); |
2927 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &inp->status); | 2885 | decoder_call(zr, video, g_input_status, &inp->status); |
2928 | mutex_unlock(&zr->resource_lock); | 2886 | mutex_unlock(&zr->resource_lock); |
2929 | return 0; | 2887 | return 0; |
2930 | } | 2888 | } |