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

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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
babb7dc7 0ef4dbad

+68 -99
+68 -99
drivers/media/video/saa7191.c
··· 22 22 #include <linux/videodev.h> 23 23 #include <linux/video_decoder.h> 24 24 #include <linux/i2c.h> 25 + #include <media/v4l2-common.h> 26 + #include <media/v4l2-i2c-drv-legacy.h> 25 27 26 28 #include "saa7191.h" 27 29 ··· 33 31 MODULE_VERSION(SAA7191_MODULE_VERSION); 34 32 MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); 35 33 MODULE_LICENSE("GPL"); 34 + 35 + static unsigned short normal_i2c[] = { 0x8a >> 1, 0x8e >> 1, I2C_CLIENT_END }; 36 + 37 + I2C_CLIENT_INSMOD; 36 38 37 39 // #define SAA7191_DEBUG 38 40 ··· 59 53 int input; 60 54 int norm; 61 55 }; 62 - 63 - static struct i2c_driver i2c_driver_saa7191; 64 56 65 57 static const u8 initseq[] = { 66 58 0, /* Subaddress */ ··· 565 561 566 562 /* I2C-interface */ 567 563 568 - static int saa7191_attach(struct i2c_adapter *adap, int addr, int kind) 569 - { 570 - int err = 0; 571 - struct saa7191 *decoder; 572 - struct i2c_client *client; 573 - 574 - printk(KERN_INFO "Philips SAA7191 driver version %s\n", 575 - SAA7191_MODULE_VERSION); 576 - 577 - client = kzalloc(sizeof(*client), GFP_KERNEL); 578 - if (!client) 579 - return -ENOMEM; 580 - decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); 581 - if (!decoder) { 582 - err = -ENOMEM; 583 - goto out_free_client; 584 - } 585 - 586 - client->addr = addr; 587 - client->adapter = adap; 588 - client->driver = &i2c_driver_saa7191; 589 - client->flags = 0; 590 - strcpy(client->name, "saa7191 client"); 591 - i2c_set_clientdata(client, decoder); 592 - 593 - decoder->client = client; 594 - 595 - err = i2c_attach_client(client); 596 - if (err) 597 - goto out_free_decoder; 598 - 599 - err = saa7191_write_block(client, sizeof(initseq), initseq); 600 - if (err) { 601 - printk(KERN_ERR "SAA7191 initialization failed\n"); 602 - goto out_detach_client; 603 - } 604 - 605 - printk(KERN_INFO "SAA7191 initialized\n"); 606 - 607 - decoder->input = SAA7191_INPUT_COMPOSITE; 608 - decoder->norm = SAA7191_NORM_PAL; 609 - 610 - err = saa7191_autodetect_norm(client); 611 - if (err && (err != -EBUSY)) { 612 - printk(KERN_ERR "SAA7191: Signal auto-detection failed\n"); 613 - } 614 - 615 - return 0; 616 - 617 - out_detach_client: 618 - i2c_detach_client(client); 619 - out_free_decoder: 620 - kfree(decoder); 621 - out_free_client: 622 - kfree(client); 623 - return err; 624 - } 625 - 626 - static int saa7191_probe(struct i2c_adapter *adap) 627 - { 628 - /* Always connected to VINO */ 629 - if (adap->id == I2C_HW_SGI_VINO) 630 - return saa7191_attach(adap, SAA7191_ADDR, 0); 631 - /* Feel free to add probe here :-) */ 632 - return -ENODEV; 633 - } 634 - 635 - static int saa7191_detach(struct i2c_client *client) 636 - { 637 - struct saa7191 *decoder = i2c_get_clientdata(client); 638 - 639 - i2c_detach_client(client); 640 - kfree(decoder); 641 - kfree(client); 642 - return 0; 643 - } 644 - 645 564 static int saa7191_command(struct i2c_client *client, unsigned int cmd, 646 565 void *arg) 647 566 { ··· 710 783 return 0; 711 784 } 712 785 713 - static struct i2c_driver i2c_driver_saa7191 = { 714 - .driver = { 715 - .name = "saa7191", 716 - }, 717 - .id = I2C_DRIVERID_SAA7191, 718 - .attach_adapter = saa7191_probe, 719 - .detach_client = saa7191_detach, 720 - .command = saa7191_command 786 + static int saa7191_probe(struct i2c_client *client, 787 + const struct i2c_device_id *id) 788 + { 789 + int err = 0; 790 + struct saa7191 *decoder; 791 + 792 + v4l_info(client, "chip found @ 0x%x (%s)\n", 793 + client->addr << 1, client->adapter->name); 794 + 795 + decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); 796 + if (!decoder) 797 + return -ENOMEM; 798 + 799 + i2c_set_clientdata(client, decoder); 800 + 801 + decoder->client = client; 802 + 803 + err = saa7191_write_block(client, sizeof(initseq), initseq); 804 + if (err) { 805 + printk(KERN_ERR "SAA7191 initialization failed\n"); 806 + kfree(decoder); 807 + return err; 808 + } 809 + 810 + printk(KERN_INFO "SAA7191 initialized\n"); 811 + 812 + decoder->input = SAA7191_INPUT_COMPOSITE; 813 + decoder->norm = SAA7191_NORM_PAL; 814 + 815 + err = saa7191_autodetect_norm(client); 816 + if (err && (err != -EBUSY)) 817 + printk(KERN_ERR "SAA7191: Signal auto-detection failed\n"); 818 + 819 + return 0; 820 + } 821 + 822 + static int saa7191_remove(struct i2c_client *client) 823 + { 824 + struct saa7191 *decoder = i2c_get_clientdata(client); 825 + 826 + kfree(decoder); 827 + return 0; 828 + } 829 + 830 + static int saa7191_legacy_probe(struct i2c_adapter *adapter) 831 + { 832 + return adapter->id == I2C_HW_SGI_VINO; 833 + } 834 + 835 + static const struct i2c_device_id saa7191_id[] = { 836 + { "saa7191", 0 }, 837 + { } 721 838 }; 839 + MODULE_DEVICE_TABLE(i2c, saa7191_id); 722 840 723 - static int saa7191_init(void) 724 - { 725 - return i2c_add_driver(&i2c_driver_saa7191); 726 - } 727 - 728 - static void saa7191_exit(void) 729 - { 730 - i2c_del_driver(&i2c_driver_saa7191); 731 - } 732 - 733 - module_init(saa7191_init); 734 - module_exit(saa7191_exit); 841 + static struct v4l2_i2c_driver_data v4l2_i2c_data = { 842 + .name = "saa7191", 843 + .driverid = I2C_DRIVERID_SAA7191, 844 + .command = saa7191_command, 845 + .probe = saa7191_probe, 846 + .remove = saa7191_remove, 847 + .legacy_probe = saa7191_legacy_probe, 848 + .id_table = saa7191_id, 849 + };