diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-video.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index d7e8fcee559..48c450f4a85 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -75,10 +75,6 @@ MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); | |||
75 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ | 75 | #define dprintk(level,fmt, arg...) if (video_debug >= level) \ |
76 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) | 76 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) |
77 | 77 | ||
78 | /* ------------------------------------------------------------------ */ | ||
79 | |||
80 | static LIST_HEAD(cx8800_devlist); | ||
81 | |||
82 | /* ------------------------------------------------------------------- */ | 78 | /* ------------------------------------------------------------------- */ |
83 | /* static data */ | 79 | /* static data */ |
84 | 80 | ||
@@ -753,38 +749,31 @@ static int get_ressource(struct cx8800_fh *fh) | |||
753 | 749 | ||
754 | static int video_open(struct file *file) | 750 | static int video_open(struct file *file) |
755 | { | 751 | { |
756 | int minor = video_devdata(file)->minor; | 752 | struct video_device *vdev = video_devdata(file); |
757 | struct cx8800_dev *h,*dev = NULL; | 753 | struct cx8800_dev *dev = video_drvdata(file); |
758 | struct cx88_core *core; | 754 | struct cx88_core *core; |
759 | struct cx8800_fh *fh; | 755 | struct cx8800_fh *fh; |
760 | enum v4l2_buf_type type = 0; | 756 | enum v4l2_buf_type type = 0; |
761 | int radio = 0; | 757 | int radio = 0; |
762 | 758 | ||
763 | lock_kernel(); | 759 | switch (vdev->vfl_type) { |
764 | list_for_each_entry(h, &cx8800_devlist, devlist) { | 760 | case VFL_TYPE_GRABBER: |
765 | if (h->video_dev->minor == minor) { | 761 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
766 | dev = h; | 762 | break; |
767 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 763 | case VFL_TYPE_VBI: |
768 | } | 764 | type = V4L2_BUF_TYPE_VBI_CAPTURE; |
769 | if (h->vbi_dev->minor == minor) { | 765 | break; |
770 | dev = h; | 766 | case VFL_TYPE_RADIO: |
771 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | 767 | radio = 1; |
772 | } | 768 | break; |
773 | if (h->radio_dev && | ||
774 | h->radio_dev->minor == minor) { | ||
775 | radio = 1; | ||
776 | dev = h; | ||
777 | } | ||
778 | } | ||
779 | if (NULL == dev) { | ||
780 | unlock_kernel(); | ||
781 | return -ENODEV; | ||
782 | } | 769 | } |
783 | 770 | ||
771 | lock_kernel(); | ||
772 | |||
784 | core = dev->core; | 773 | core = dev->core; |
785 | 774 | ||
786 | dprintk(1,"open minor=%d radio=%d type=%s\n", | 775 | dprintk(1, "open dev=%s radio=%d type=%s\n", |
787 | minor,radio,v4l2_type_names[type]); | 776 | video_device_node_name(vdev), radio, v4l2_type_names[type]); |
788 | 777 | ||
789 | /* allocate + initialize per filehandle data */ | 778 | /* allocate + initialize per filehandle data */ |
790 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); | 779 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); |
@@ -1733,7 +1722,6 @@ static struct video_device cx8800_vbi_template; | |||
1733 | static struct video_device cx8800_video_template = { | 1722 | static struct video_device cx8800_video_template = { |
1734 | .name = "cx8800-video", | 1723 | .name = "cx8800-video", |
1735 | .fops = &video_fops, | 1724 | .fops = &video_fops, |
1736 | .minor = -1, | ||
1737 | .ioctl_ops = &video_ioctl_ops, | 1725 | .ioctl_ops = &video_ioctl_ops, |
1738 | .tvnorms = CX88_NORMS, | 1726 | .tvnorms = CX88_NORMS, |
1739 | .current_norm = V4L2_STD_NTSC_M, | 1727 | .current_norm = V4L2_STD_NTSC_M, |
@@ -1769,7 +1757,6 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { | |||
1769 | static struct video_device cx8800_radio_template = { | 1757 | static struct video_device cx8800_radio_template = { |
1770 | .name = "cx8800-radio", | 1758 | .name = "cx8800-radio", |
1771 | .fops = &radio_fops, | 1759 | .fops = &radio_fops, |
1772 | .minor = -1, | ||
1773 | .ioctl_ops = &radio_ioctl_ops, | 1760 | .ioctl_ops = &radio_ioctl_ops, |
1774 | }; | 1761 | }; |
1775 | 1762 | ||
@@ -1778,21 +1765,21 @@ static struct video_device cx8800_radio_template = { | |||
1778 | static void cx8800_unregister_video(struct cx8800_dev *dev) | 1765 | static void cx8800_unregister_video(struct cx8800_dev *dev) |
1779 | { | 1766 | { |
1780 | if (dev->radio_dev) { | 1767 | if (dev->radio_dev) { |
1781 | if (-1 != dev->radio_dev->minor) | 1768 | if (video_is_registered(dev->radio_dev)) |
1782 | video_unregister_device(dev->radio_dev); | 1769 | video_unregister_device(dev->radio_dev); |
1783 | else | 1770 | else |
1784 | video_device_release(dev->radio_dev); | 1771 | video_device_release(dev->radio_dev); |
1785 | dev->radio_dev = NULL; | 1772 | dev->radio_dev = NULL; |
1786 | } | 1773 | } |
1787 | if (dev->vbi_dev) { | 1774 | if (dev->vbi_dev) { |
1788 | if (-1 != dev->vbi_dev->minor) | 1775 | if (video_is_registered(dev->vbi_dev)) |
1789 | video_unregister_device(dev->vbi_dev); | 1776 | video_unregister_device(dev->vbi_dev); |
1790 | else | 1777 | else |
1791 | video_device_release(dev->vbi_dev); | 1778 | video_device_release(dev->vbi_dev); |
1792 | dev->vbi_dev = NULL; | 1779 | dev->vbi_dev = NULL; |
1793 | } | 1780 | } |
1794 | if (dev->video_dev) { | 1781 | if (dev->video_dev) { |
1795 | if (-1 != dev->video_dev->minor) | 1782 | if (video_is_registered(dev->video_dev)) |
1796 | video_unregister_device(dev->video_dev); | 1783 | video_unregister_device(dev->video_dev); |
1797 | else | 1784 | else |
1798 | video_device_release(dev->video_dev); | 1785 | video_device_release(dev->video_dev); |
@@ -1909,6 +1896,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1909 | /* register v4l devices */ | 1896 | /* register v4l devices */ |
1910 | dev->video_dev = cx88_vdev_init(core,dev->pci, | 1897 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
1911 | &cx8800_video_template,"video"); | 1898 | &cx8800_video_template,"video"); |
1899 | video_set_drvdata(dev->video_dev, dev); | ||
1912 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, | 1900 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
1913 | video_nr[core->nr]); | 1901 | video_nr[core->nr]); |
1914 | if (err < 0) { | 1902 | if (err < 0) { |
@@ -1916,10 +1904,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1916 | core->name); | 1904 | core->name); |
1917 | goto fail_unreg; | 1905 | goto fail_unreg; |
1918 | } | 1906 | } |
1919 | printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n", | 1907 | printk(KERN_INFO "%s/0: registered device %s [v4l2]\n", |
1920 | core->name, dev->video_dev->num); | 1908 | core->name, video_device_node_name(dev->video_dev)); |
1921 | 1909 | ||
1922 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); | 1910 | dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi"); |
1911 | video_set_drvdata(dev->vbi_dev, dev); | ||
1923 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, | 1912 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
1924 | vbi_nr[core->nr]); | 1913 | vbi_nr[core->nr]); |
1925 | if (err < 0) { | 1914 | if (err < 0) { |
@@ -1927,12 +1916,13 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1927 | core->name); | 1916 | core->name); |
1928 | goto fail_unreg; | 1917 | goto fail_unreg; |
1929 | } | 1918 | } |
1930 | printk(KERN_INFO "%s/0: registered device vbi%d\n", | 1919 | printk(KERN_INFO "%s/0: registered device %s\n", |
1931 | core->name, dev->vbi_dev->num); | 1920 | core->name, video_device_node_name(dev->vbi_dev)); |
1932 | 1921 | ||
1933 | if (core->board.radio.type == CX88_RADIO) { | 1922 | if (core->board.radio.type == CX88_RADIO) { |
1934 | dev->radio_dev = cx88_vdev_init(core,dev->pci, | 1923 | dev->radio_dev = cx88_vdev_init(core,dev->pci, |
1935 | &cx8800_radio_template,"radio"); | 1924 | &cx8800_radio_template,"radio"); |
1925 | video_set_drvdata(dev->radio_dev, dev); | ||
1936 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, | 1926 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
1937 | radio_nr[core->nr]); | 1927 | radio_nr[core->nr]); |
1938 | if (err < 0) { | 1928 | if (err < 0) { |
@@ -1940,12 +1930,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1940 | core->name); | 1930 | core->name); |
1941 | goto fail_unreg; | 1931 | goto fail_unreg; |
1942 | } | 1932 | } |
1943 | printk(KERN_INFO "%s/0: registered device radio%d\n", | 1933 | printk(KERN_INFO "%s/0: registered device %s\n", |
1944 | core->name, dev->radio_dev->num); | 1934 | core->name, video_device_node_name(dev->radio_dev)); |
1945 | } | 1935 | } |
1946 | 1936 | ||
1947 | /* everything worked */ | 1937 | /* everything worked */ |
1948 | list_add_tail(&dev->devlist,&cx8800_devlist); | ||
1949 | pci_set_drvdata(pci_dev,dev); | 1938 | pci_set_drvdata(pci_dev,dev); |
1950 | 1939 | ||
1951 | /* initial device configuration */ | 1940 | /* initial device configuration */ |
@@ -2001,7 +1990,6 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) | |||
2001 | 1990 | ||
2002 | /* free memory */ | 1991 | /* free memory */ |
2003 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); | 1992 | btcx_riscmem_free(dev->pci,&dev->vidq.stopper); |
2004 | list_del(&dev->devlist); | ||
2005 | cx88_core_put(core,dev->pci); | 1993 | cx88_core_put(core,dev->pci); |
2006 | kfree(dev); | 1994 | kfree(dev); |
2007 | } | 1995 | } |