diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-13 05:31:05 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:10 -0400 |
commit | babb7dc7776dd6ded4e1e6cb7acc34c25c0eb521 (patch) | |
tree | 42dfd75c2ce4687def82c8bbc684a77cc46470cf /drivers/media/video/saa7191.c | |
parent | 0ef4dbad4f2303b9210cd382bca430d016db5452 (diff) |
V4L/DVB (10860): saa7191: convert to v4l2-i2c-drv-legacy.h
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7191.c')
-rw-r--r-- | drivers/media/video/saa7191.c | 157 |
1 files changed, 63 insertions, 94 deletions
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index b4018cce3285..9943e5c35e15 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/videodev.h> | 22 | #include <linux/videodev.h> |
23 | #include <linux/video_decoder.h> | 23 | #include <linux/video_decoder.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <media/v4l2-common.h> | ||
26 | #include <media/v4l2-i2c-drv-legacy.h> | ||
25 | 27 | ||
26 | #include "saa7191.h" | 28 | #include "saa7191.h" |
27 | 29 | ||
@@ -32,6 +34,10 @@ MODULE_VERSION(SAA7191_MODULE_VERSION); | |||
32 | MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); | 34 | MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); |
33 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
34 | 36 | ||
37 | static unsigned short normal_i2c[] = { 0x8a >> 1, 0x8e >> 1, I2C_CLIENT_END }; | ||
38 | |||
39 | I2C_CLIENT_INSMOD; | ||
40 | |||
35 | // #define SAA7191_DEBUG | 41 | // #define SAA7191_DEBUG |
36 | 42 | ||
37 | #ifdef SAA7191_DEBUG | 43 | #ifdef SAA7191_DEBUG |
@@ -54,8 +60,6 @@ struct saa7191 { | |||
54 | int norm; | 60 | int norm; |
55 | }; | 61 | }; |
56 | 62 | ||
57 | static struct i2c_driver i2c_driver_saa7191; | ||
58 | |||
59 | static const u8 initseq[] = { | 63 | static const u8 initseq[] = { |
60 | 0, /* Subaddress */ | 64 | 0, /* Subaddress */ |
61 | 65 | ||
@@ -561,83 +565,6 @@ static int saa7191_set_control(struct i2c_client *client, | |||
561 | 565 | ||
562 | /* I2C-interface */ | 566 | /* I2C-interface */ |
563 | 567 | ||
564 | static int saa7191_attach(struct i2c_adapter *adap, int addr, int kind) | ||
565 | { | ||
566 | int err = 0; | ||
567 | struct saa7191 *decoder; | ||
568 | struct i2c_client *client; | ||
569 | |||
570 | printk(KERN_INFO "Philips SAA7191 driver version %s\n", | ||
571 | SAA7191_MODULE_VERSION); | ||
572 | |||
573 | client = kzalloc(sizeof(*client), GFP_KERNEL); | ||
574 | if (!client) | ||
575 | return -ENOMEM; | ||
576 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); | ||
577 | if (!decoder) { | ||
578 | err = -ENOMEM; | ||
579 | goto out_free_client; | ||
580 | } | ||
581 | |||
582 | client->addr = addr; | ||
583 | client->adapter = adap; | ||
584 | client->driver = &i2c_driver_saa7191; | ||
585 | client->flags = 0; | ||
586 | strcpy(client->name, "saa7191 client"); | ||
587 | i2c_set_clientdata(client, decoder); | ||
588 | |||
589 | decoder->client = client; | ||
590 | |||
591 | err = i2c_attach_client(client); | ||
592 | if (err) | ||
593 | goto out_free_decoder; | ||
594 | |||
595 | err = saa7191_write_block(client, sizeof(initseq), initseq); | ||
596 | if (err) { | ||
597 | printk(KERN_ERR "SAA7191 initialization failed\n"); | ||
598 | goto out_detach_client; | ||
599 | } | ||
600 | |||
601 | printk(KERN_INFO "SAA7191 initialized\n"); | ||
602 | |||
603 | decoder->input = SAA7191_INPUT_COMPOSITE; | ||
604 | decoder->norm = SAA7191_NORM_PAL; | ||
605 | |||
606 | err = saa7191_autodetect_norm(client); | ||
607 | if (err && (err != -EBUSY)) { | ||
608 | printk(KERN_ERR "SAA7191: Signal auto-detection failed\n"); | ||
609 | } | ||
610 | |||
611 | return 0; | ||
612 | |||
613 | out_detach_client: | ||
614 | i2c_detach_client(client); | ||
615 | out_free_decoder: | ||
616 | kfree(decoder); | ||
617 | out_free_client: | ||
618 | kfree(client); | ||
619 | return err; | ||
620 | } | ||
621 | |||
622 | static int saa7191_probe(struct i2c_adapter *adap) | ||
623 | { | ||
624 | /* Always connected to VINO */ | ||
625 | if (adap->id == I2C_HW_SGI_VINO) | ||
626 | return saa7191_attach(adap, SAA7191_ADDR, 0); | ||
627 | /* Feel free to add probe here :-) */ | ||
628 | return -ENODEV; | ||
629 | } | ||
630 | |||
631 | static int saa7191_detach(struct i2c_client *client) | ||
632 | { | ||
633 | struct saa7191 *decoder = i2c_get_clientdata(client); | ||
634 | |||
635 | i2c_detach_client(client); | ||
636 | kfree(decoder); | ||
637 | kfree(client); | ||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static int saa7191_command(struct i2c_client *client, unsigned int cmd, | 568 | static int saa7191_command(struct i2c_client *client, unsigned int cmd, |
642 | void *arg) | 569 | void *arg) |
643 | { | 570 | { |
@@ -783,25 +710,67 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd, | |||
783 | return 0; | 710 | return 0; |
784 | } | 711 | } |
785 | 712 | ||
786 | static struct i2c_driver i2c_driver_saa7191 = { | 713 | static int saa7191_probe(struct i2c_client *client, |
787 | .driver = { | 714 | const struct i2c_device_id *id) |
788 | .name = "saa7191", | 715 | { |
789 | }, | 716 | int err = 0; |
790 | .id = I2C_DRIVERID_SAA7191, | 717 | struct saa7191 *decoder; |
791 | .attach_adapter = saa7191_probe, | ||
792 | .detach_client = saa7191_detach, | ||
793 | .command = saa7191_command | ||
794 | }; | ||
795 | 718 | ||
796 | static int saa7191_init(void) | 719 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
720 | client->addr << 1, client->adapter->name); | ||
721 | |||
722 | decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); | ||
723 | if (!decoder) | ||
724 | return -ENOMEM; | ||
725 | |||
726 | i2c_set_clientdata(client, decoder); | ||
727 | |||
728 | decoder->client = client; | ||
729 | |||
730 | err = saa7191_write_block(client, sizeof(initseq), initseq); | ||
731 | if (err) { | ||
732 | printk(KERN_ERR "SAA7191 initialization failed\n"); | ||
733 | kfree(decoder); | ||
734 | return err; | ||
735 | } | ||
736 | |||
737 | printk(KERN_INFO "SAA7191 initialized\n"); | ||
738 | |||
739 | decoder->input = SAA7191_INPUT_COMPOSITE; | ||
740 | decoder->norm = SAA7191_NORM_PAL; | ||
741 | |||
742 | err = saa7191_autodetect_norm(client); | ||
743 | if (err && (err != -EBUSY)) | ||
744 | printk(KERN_ERR "SAA7191: Signal auto-detection failed\n"); | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | static int saa7191_remove(struct i2c_client *client) | ||
797 | { | 750 | { |
798 | return i2c_add_driver(&i2c_driver_saa7191); | 751 | struct saa7191 *decoder = i2c_get_clientdata(client); |
752 | |||
753 | kfree(decoder); | ||
754 | return 0; | ||
799 | } | 755 | } |
800 | 756 | ||
801 | static void saa7191_exit(void) | 757 | static int saa7191_legacy_probe(struct i2c_adapter *adapter) |
802 | { | 758 | { |
803 | i2c_del_driver(&i2c_driver_saa7191); | 759 | return adapter->id == I2C_HW_SGI_VINO; |
804 | } | 760 | } |
805 | 761 | ||
806 | module_init(saa7191_init); | 762 | static const struct i2c_device_id saa7191_id[] = { |
807 | module_exit(saa7191_exit); | 763 | { "saa7191", 0 }, |
764 | { } | ||
765 | }; | ||
766 | MODULE_DEVICE_TABLE(i2c, saa7191_id); | ||
767 | |||
768 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | ||
769 | .name = "saa7191", | ||
770 | .driverid = I2C_DRIVERID_SAA7191, | ||
771 | .command = saa7191_command, | ||
772 | .probe = saa7191_probe, | ||
773 | .remove = saa7191_remove, | ||
774 | .legacy_probe = saa7191_legacy_probe, | ||
775 | .id_table = saa7191_id, | ||
776 | }; | ||