diff options
Diffstat (limited to 'drivers/media/video/bttv-driver.c')
-rw-r--r-- | drivers/media/video/bttv-driver.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 0e6970346788..aa4c4c521880 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c | |||
@@ -48,47 +48,46 @@ | |||
48 | unsigned int bttv_num; /* number of Bt848s in use */ | 48 | unsigned int bttv_num; /* number of Bt848s in use */ |
49 | struct bttv bttvs[BTTV_MAX]; | 49 | struct bttv bttvs[BTTV_MAX]; |
50 | 50 | ||
51 | unsigned int bttv_debug = 0; | 51 | unsigned int bttv_debug; |
52 | unsigned int bttv_verbose = 1; | 52 | unsigned int bttv_verbose = 1; |
53 | unsigned int bttv_gpio = 0; | 53 | unsigned int bttv_gpio; |
54 | 54 | ||
55 | /* config variables */ | 55 | /* config variables */ |
56 | #ifdef __BIG_ENDIAN | 56 | #ifdef __BIG_ENDIAN |
57 | static unsigned int bigendian=1; | 57 | static unsigned int bigendian=1; |
58 | #else | 58 | #else |
59 | static unsigned int bigendian=0; | 59 | static unsigned int bigendian; |
60 | #endif | 60 | #endif |
61 | static unsigned int radio[BTTV_MAX]; | 61 | static unsigned int radio[BTTV_MAX]; |
62 | static unsigned int irq_debug = 0; | 62 | static unsigned int irq_debug; |
63 | static unsigned int gbuffers = 8; | 63 | static unsigned int gbuffers = 8; |
64 | static unsigned int gbufsize = 0x208000; | 64 | static unsigned int gbufsize = 0x208000; |
65 | 65 | ||
66 | static int video_nr = -1; | 66 | static int video_nr = -1; |
67 | static int radio_nr = -1; | 67 | static int radio_nr = -1; |
68 | static int vbi_nr = -1; | 68 | static int vbi_nr = -1; |
69 | static int debug_latency = 0; | 69 | static int debug_latency; |
70 | 70 | ||
71 | static unsigned int fdsr = 0; | 71 | static unsigned int fdsr; |
72 | 72 | ||
73 | /* options */ | 73 | /* options */ |
74 | static unsigned int combfilter = 0; | 74 | static unsigned int combfilter; |
75 | static unsigned int lumafilter = 0; | 75 | static unsigned int lumafilter; |
76 | static unsigned int automute = 1; | 76 | static unsigned int automute = 1; |
77 | static unsigned int chroma_agc = 0; | 77 | static unsigned int chroma_agc; |
78 | static unsigned int adc_crush = 1; | 78 | static unsigned int adc_crush = 1; |
79 | static unsigned int whitecrush_upper = 0xCF; | 79 | static unsigned int whitecrush_upper = 0xCF; |
80 | static unsigned int whitecrush_lower = 0x7F; | 80 | static unsigned int whitecrush_lower = 0x7F; |
81 | static unsigned int vcr_hack = 0; | 81 | static unsigned int vcr_hack; |
82 | static unsigned int irq_iswitch = 0; | 82 | static unsigned int irq_iswitch; |
83 | static unsigned int uv_ratio = 50; | 83 | static unsigned int uv_ratio = 50; |
84 | static unsigned int full_luma_range = 0; | 84 | static unsigned int full_luma_range; |
85 | static unsigned int coring = 0; | 85 | static unsigned int coring; |
86 | extern int no_overlay; | 86 | extern int no_overlay; |
87 | 87 | ||
88 | /* API features (turn on/off stuff for testing) */ | 88 | /* API features (turn on/off stuff for testing) */ |
89 | static unsigned int v4l2 = 1; | 89 | static unsigned int v4l2 = 1; |
90 | 90 | ||
91 | |||
92 | /* insmod args */ | 91 | /* insmod args */ |
93 | module_param(bttv_verbose, int, 0644); | 92 | module_param(bttv_verbose, int, 0644); |
94 | module_param(bttv_gpio, int, 0644); | 93 | module_param(bttv_gpio, int, 0644); |
@@ -685,16 +684,16 @@ int check_alloc_btres(struct bttv *btv, struct bttv_fh *fh, int bit) | |||
685 | return 1; | 684 | return 1; |
686 | 685 | ||
687 | /* is it free? */ | 686 | /* is it free? */ |
688 | down(&btv->reslock); | 687 | mutex_lock(&btv->reslock); |
689 | if (btv->resources & bit) { | 688 | if (btv->resources & bit) { |
690 | /* no, someone else uses it */ | 689 | /* no, someone else uses it */ |
691 | up(&btv->reslock); | 690 | mutex_unlock(&btv->reslock); |
692 | return 0; | 691 | return 0; |
693 | } | 692 | } |
694 | /* it's free, grab it */ | 693 | /* it's free, grab it */ |
695 | fh->resources |= bit; | 694 | fh->resources |= bit; |
696 | btv->resources |= bit; | 695 | btv->resources |= bit; |
697 | up(&btv->reslock); | 696 | mutex_unlock(&btv->reslock); |
698 | return 1; | 697 | return 1; |
699 | } | 698 | } |
700 | 699 | ||
@@ -717,10 +716,10 @@ void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits) | |||
717 | /* trying to free ressources not allocated by us ... */ | 716 | /* trying to free ressources not allocated by us ... */ |
718 | printk("bttv: BUG! (btres)\n"); | 717 | printk("bttv: BUG! (btres)\n"); |
719 | } | 718 | } |
720 | down(&btv->reslock); | 719 | mutex_lock(&btv->reslock); |
721 | fh->resources &= ~bits; | 720 | fh->resources &= ~bits; |
722 | btv->resources &= ~bits; | 721 | btv->resources &= ~bits; |
723 | up(&btv->reslock); | 722 | mutex_unlock(&btv->reslock); |
724 | } | 723 | } |
725 | 724 | ||
726 | /* ----------------------------------------------------------------------- */ | 725 | /* ----------------------------------------------------------------------- */ |
@@ -1537,12 +1536,12 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1537 | case VIDIOCSFREQ: | 1536 | case VIDIOCSFREQ: |
1538 | { | 1537 | { |
1539 | unsigned long *freq = arg; | 1538 | unsigned long *freq = arg; |
1540 | down(&btv->lock); | 1539 | mutex_lock(&btv->lock); |
1541 | btv->freq=*freq; | 1540 | btv->freq=*freq; |
1542 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); | 1541 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); |
1543 | if (btv->has_matchbox && btv->radio_user) | 1542 | if (btv->has_matchbox && btv->radio_user) |
1544 | tea5757_set_freq(btv,*freq); | 1543 | tea5757_set_freq(btv,*freq); |
1545 | up(&btv->lock); | 1544 | mutex_unlock(&btv->lock); |
1546 | return 0; | 1545 | return 0; |
1547 | } | 1546 | } |
1548 | 1547 | ||
@@ -1572,10 +1571,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1572 | if (v->mode >= BTTV_TVNORMS) | 1571 | if (v->mode >= BTTV_TVNORMS) |
1573 | return -EINVAL; | 1572 | return -EINVAL; |
1574 | 1573 | ||
1575 | down(&btv->lock); | 1574 | mutex_lock(&btv->lock); |
1576 | set_tvnorm(btv,v->mode); | 1575 | set_tvnorm(btv,v->mode); |
1577 | bttv_call_i2c_clients(btv,cmd,v); | 1576 | bttv_call_i2c_clients(btv,cmd,v); |
1578 | up(&btv->lock); | 1577 | mutex_unlock(&btv->lock); |
1579 | return 0; | 1578 | return 0; |
1580 | } | 1579 | } |
1581 | 1580 | ||
@@ -1612,17 +1611,17 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1612 | if (v->norm >= BTTV_TVNORMS) | 1611 | if (v->norm >= BTTV_TVNORMS) |
1613 | return -EINVAL; | 1612 | return -EINVAL; |
1614 | 1613 | ||
1615 | down(&btv->lock); | 1614 | mutex_lock(&btv->lock); |
1616 | if (channel == btv->input && | 1615 | if (channel == btv->input && |
1617 | v->norm == btv->tvnorm) { | 1616 | v->norm == btv->tvnorm) { |
1618 | /* nothing to do */ | 1617 | /* nothing to do */ |
1619 | up(&btv->lock); | 1618 | mutex_unlock(&btv->lock); |
1620 | return 0; | 1619 | return 0; |
1621 | } | 1620 | } |
1622 | 1621 | ||
1623 | btv->tvnorm = v->norm; | 1622 | btv->tvnorm = v->norm; |
1624 | set_input(btv,v->channel); | 1623 | set_input(btv,v->channel); |
1625 | up(&btv->lock); | 1624 | mutex_unlock(&btv->lock); |
1626 | return 0; | 1625 | return 0; |
1627 | } | 1626 | } |
1628 | 1627 | ||
@@ -1635,14 +1634,14 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1635 | v->flags |= VIDEO_AUDIO_MUTABLE; | 1634 | v->flags |= VIDEO_AUDIO_MUTABLE; |
1636 | v->mode = VIDEO_SOUND_MONO; | 1635 | v->mode = VIDEO_SOUND_MONO; |
1637 | 1636 | ||
1638 | down(&btv->lock); | 1637 | mutex_lock(&btv->lock); |
1639 | bttv_call_i2c_clients(btv,cmd,v); | 1638 | bttv_call_i2c_clients(btv,cmd,v); |
1640 | 1639 | ||
1641 | /* card specific hooks */ | 1640 | /* card specific hooks */ |
1642 | if (btv->audio_hook) | 1641 | if (btv->audio_hook) |
1643 | btv->audio_hook(btv,v,0); | 1642 | btv->audio_hook(btv,v,0); |
1644 | 1643 | ||
1645 | up(&btv->lock); | 1644 | mutex_unlock(&btv->lock); |
1646 | return 0; | 1645 | return 0; |
1647 | } | 1646 | } |
1648 | case VIDIOCSAUDIO: | 1647 | case VIDIOCSAUDIO: |
@@ -1653,7 +1652,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1653 | if (audio >= bttv_tvcards[btv->c.type].audio_inputs) | 1652 | if (audio >= bttv_tvcards[btv->c.type].audio_inputs) |
1654 | return -EINVAL; | 1653 | return -EINVAL; |
1655 | 1654 | ||
1656 | down(&btv->lock); | 1655 | mutex_lock(&btv->lock); |
1657 | audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE); | 1656 | audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE); |
1658 | bttv_call_i2c_clients(btv,cmd,v); | 1657 | bttv_call_i2c_clients(btv,cmd,v); |
1659 | 1658 | ||
@@ -1661,7 +1660,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1661 | if (btv->audio_hook) | 1660 | if (btv->audio_hook) |
1662 | btv->audio_hook(btv,v,1); | 1661 | btv->audio_hook(btv,v,1); |
1663 | 1662 | ||
1664 | up(&btv->lock); | 1663 | mutex_unlock(&btv->lock); |
1665 | return 0; | 1664 | return 0; |
1666 | } | 1665 | } |
1667 | 1666 | ||
@@ -1695,10 +1694,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1695 | if (i == BTTV_TVNORMS) | 1694 | if (i == BTTV_TVNORMS) |
1696 | return -EINVAL; | 1695 | return -EINVAL; |
1697 | 1696 | ||
1698 | down(&btv->lock); | 1697 | mutex_lock(&btv->lock); |
1699 | set_tvnorm(btv,i); | 1698 | set_tvnorm(btv,i); |
1700 | i2c_vidiocschan(btv); | 1699 | i2c_vidiocschan(btv); |
1701 | up(&btv->lock); | 1700 | mutex_unlock(&btv->lock); |
1702 | return 0; | 1701 | return 0; |
1703 | } | 1702 | } |
1704 | case VIDIOC_QUERYSTD: | 1703 | case VIDIOC_QUERYSTD: |
@@ -1756,9 +1755,9 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1756 | 1755 | ||
1757 | if (*i > bttv_tvcards[btv->c.type].video_inputs) | 1756 | if (*i > bttv_tvcards[btv->c.type].video_inputs) |
1758 | return -EINVAL; | 1757 | return -EINVAL; |
1759 | down(&btv->lock); | 1758 | mutex_lock(&btv->lock); |
1760 | set_input(btv,*i); | 1759 | set_input(btv,*i); |
1761 | up(&btv->lock); | 1760 | mutex_unlock(&btv->lock); |
1762 | return 0; | 1761 | return 0; |
1763 | } | 1762 | } |
1764 | 1763 | ||
@@ -1770,7 +1769,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1770 | return -EINVAL; | 1769 | return -EINVAL; |
1771 | if (0 != t->index) | 1770 | if (0 != t->index) |
1772 | return -EINVAL; | 1771 | return -EINVAL; |
1773 | down(&btv->lock); | 1772 | mutex_lock(&btv->lock); |
1774 | memset(t,0,sizeof(*t)); | 1773 | memset(t,0,sizeof(*t)); |
1775 | strcpy(t->name, "Television"); | 1774 | strcpy(t->name, "Television"); |
1776 | t->type = V4L2_TUNER_ANALOG_TV; | 1775 | t->type = V4L2_TUNER_ANALOG_TV; |
@@ -1805,7 +1804,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1805 | } | 1804 | } |
1806 | } | 1805 | } |
1807 | /* FIXME: fill capability+audmode */ | 1806 | /* FIXME: fill capability+audmode */ |
1808 | up(&btv->lock); | 1807 | mutex_unlock(&btv->lock); |
1809 | return 0; | 1808 | return 0; |
1810 | } | 1809 | } |
1811 | case VIDIOC_S_TUNER: | 1810 | case VIDIOC_S_TUNER: |
@@ -1816,7 +1815,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1816 | return -EINVAL; | 1815 | return -EINVAL; |
1817 | if (0 != t->index) | 1816 | if (0 != t->index) |
1818 | return -EINVAL; | 1817 | return -EINVAL; |
1819 | down(&btv->lock); | 1818 | mutex_lock(&btv->lock); |
1820 | { | 1819 | { |
1821 | struct video_audio va; | 1820 | struct video_audio va; |
1822 | memset(&va, 0, sizeof(struct video_audio)); | 1821 | memset(&va, 0, sizeof(struct video_audio)); |
@@ -1833,7 +1832,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1833 | if (btv->audio_hook) | 1832 | if (btv->audio_hook) |
1834 | btv->audio_hook(btv,&va,1); | 1833 | btv->audio_hook(btv,&va,1); |
1835 | } | 1834 | } |
1836 | up(&btv->lock); | 1835 | mutex_unlock(&btv->lock); |
1837 | return 0; | 1836 | return 0; |
1838 | } | 1837 | } |
1839 | 1838 | ||
@@ -1854,12 +1853,12 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1854 | return -EINVAL; | 1853 | return -EINVAL; |
1855 | if (unlikely (f->type != V4L2_TUNER_ANALOG_TV)) | 1854 | if (unlikely (f->type != V4L2_TUNER_ANALOG_TV)) |
1856 | return -EINVAL; | 1855 | return -EINVAL; |
1857 | down(&btv->lock); | 1856 | mutex_lock(&btv->lock); |
1858 | btv->freq = f->frequency; | 1857 | btv->freq = f->frequency; |
1859 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq); | 1858 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq); |
1860 | if (btv->has_matchbox && btv->radio_user) | 1859 | if (btv->has_matchbox && btv->radio_user) |
1861 | tea5757_set_freq(btv,btv->freq); | 1860 | tea5757_set_freq(btv,btv->freq); |
1862 | up(&btv->lock); | 1861 | mutex_unlock(&btv->lock); |
1863 | return 0; | 1862 | return 0; |
1864 | } | 1863 | } |
1865 | case VIDIOC_LOG_STATUS: | 1864 | case VIDIOC_LOG_STATUS: |
@@ -3157,7 +3156,7 @@ static int radio_open(struct inode *inode, struct file *file) | |||
3157 | return -ENODEV; | 3156 | return -ENODEV; |
3158 | 3157 | ||
3159 | dprintk("bttv%d: open called (radio)\n",btv->c.nr); | 3158 | dprintk("bttv%d: open called (radio)\n",btv->c.nr); |
3160 | down(&btv->lock); | 3159 | mutex_lock(&btv->lock); |
3161 | 3160 | ||
3162 | btv->radio_user++; | 3161 | btv->radio_user++; |
3163 | 3162 | ||
@@ -3166,7 +3165,7 @@ static int radio_open(struct inode *inode, struct file *file) | |||
3166 | bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); | 3165 | bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); |
3167 | audio_mux(btv,AUDIO_RADIO); | 3166 | audio_mux(btv,AUDIO_RADIO); |
3168 | 3167 | ||
3169 | up(&btv->lock); | 3168 | mutex_unlock(&btv->lock); |
3170 | return 0; | 3169 | return 0; |
3171 | } | 3170 | } |
3172 | 3171 | ||
@@ -3921,8 +3920,8 @@ static int __devinit bttv_probe(struct pci_dev *dev, | |||
3921 | sprintf(btv->c.name,"bttv%d",btv->c.nr); | 3920 | sprintf(btv->c.name,"bttv%d",btv->c.nr); |
3922 | 3921 | ||
3923 | /* initialize structs / fill in defaults */ | 3922 | /* initialize structs / fill in defaults */ |
3924 | init_MUTEX(&btv->lock); | 3923 | mutex_init(&btv->lock); |
3925 | init_MUTEX(&btv->reslock); | 3924 | mutex_init(&btv->reslock); |
3926 | spin_lock_init(&btv->s_lock); | 3925 | spin_lock_init(&btv->s_lock); |
3927 | spin_lock_init(&btv->gpio_lock); | 3926 | spin_lock_init(&btv->gpio_lock); |
3928 | init_waitqueue_head(&btv->gpioq); | 3927 | init_waitqueue_head(&btv->gpioq); |