diff options
-rw-r--r-- | drivers/media/video/bt8xx/bttv-driver.c | 97 |
1 files changed, 3 insertions, 94 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 3da6e80e1041..c14b819d6b78 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -855,7 +855,6 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) | |||
855 | xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM; | 855 | xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM; |
856 | 856 | ||
857 | /* is it free? */ | 857 | /* is it free? */ |
858 | mutex_lock(&btv->lock); | ||
859 | if (btv->resources & xbits) { | 858 | if (btv->resources & xbits) { |
860 | /* no, someone else uses it */ | 859 | /* no, someone else uses it */ |
861 | goto fail; | 860 | goto fail; |
@@ -885,11 +884,9 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) | |||
885 | /* it's free, grab it */ | 884 | /* it's free, grab it */ |
886 | fh->resources |= bit; | 885 | fh->resources |= bit; |
887 | btv->resources |= bit; | 886 | btv->resources |= bit; |
888 | mutex_unlock(&btv->lock); | ||
889 | return 1; | 887 | return 1; |
890 | 888 | ||
891 | fail: | 889 | fail: |
892 | mutex_unlock(&btv->lock); | ||
893 | return 0; | 890 | return 0; |
894 | } | 891 | } |
895 | 892 | ||
@@ -941,7 +938,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) | |||
941 | /* trying to free ressources not allocated by us ... */ | 938 | /* trying to free ressources not allocated by us ... */ |
942 | printk("bttv: BUG! (btres)\n"); | 939 | printk("bttv: BUG! (btres)\n"); |
943 | } | 940 | } |
944 | mutex_lock(&btv->lock); | ||
945 | fh->resources &= ~bits; | 941 | fh->resources &= ~bits; |
946 | btv->resources &= ~bits; | 942 | btv->resources &= ~bits; |
947 | 943 | ||
@@ -952,8 +948,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) | |||
952 | 948 | ||
953 | if (0 == (bits & VBI_RESOURCES)) | 949 | if (0 == (bits & VBI_RESOURCES)) |
954 | disclaim_vbi_lines(btv); | 950 | disclaim_vbi_lines(btv); |
955 | |||
956 | mutex_unlock(&btv->lock); | ||
957 | } | 951 | } |
958 | 952 | ||
959 | /* ----------------------------------------------------------------------- */ | 953 | /* ----------------------------------------------------------------------- */ |
@@ -1714,28 +1708,20 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv, | |||
1714 | 1708 | ||
1715 | /* Make sure tvnorm and vbi_end remain consistent | 1709 | /* Make sure tvnorm and vbi_end remain consistent |
1716 | until we're done. */ | 1710 | until we're done. */ |
1717 | mutex_lock(&btv->lock); | ||
1718 | 1711 | ||
1719 | norm = btv->tvnorm; | 1712 | norm = btv->tvnorm; |
1720 | 1713 | ||
1721 | /* In this mode capturing always starts at defrect.top | 1714 | /* In this mode capturing always starts at defrect.top |
1722 | (default VDELAY), ignoring cropping parameters. */ | 1715 | (default VDELAY), ignoring cropping parameters. */ |
1723 | if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { | 1716 | if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { |
1724 | mutex_unlock(&btv->lock); | ||
1725 | return -EINVAL; | 1717 | return -EINVAL; |
1726 | } | 1718 | } |
1727 | 1719 | ||
1728 | mutex_unlock(&btv->lock); | ||
1729 | |||
1730 | c.rect = bttv_tvnorms[norm].cropcap.defrect; | 1720 | c.rect = bttv_tvnorms[norm].cropcap.defrect; |
1731 | } else { | 1721 | } else { |
1732 | mutex_lock(&btv->lock); | ||
1733 | |||
1734 | norm = btv->tvnorm; | 1722 | norm = btv->tvnorm; |
1735 | c = btv->crop[!!fh->do_crop]; | 1723 | c = btv->crop[!!fh->do_crop]; |
1736 | 1724 | ||
1737 | mutex_unlock(&btv->lock); | ||
1738 | |||
1739 | if (width < c.min_scaled_width || | 1725 | if (width < c.min_scaled_width || |
1740 | width > c.max_scaled_width || | 1726 | width > c.max_scaled_width || |
1741 | height < c.min_scaled_height) | 1727 | height < c.min_scaled_height) |
@@ -1859,7 +1845,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id) | |||
1859 | unsigned int i; | 1845 | unsigned int i; |
1860 | int err; | 1846 | int err; |
1861 | 1847 | ||
1862 | mutex_lock(&btv->lock); | ||
1863 | err = v4l2_prio_check(&btv->prio, fh->prio); | 1848 | err = v4l2_prio_check(&btv->prio, fh->prio); |
1864 | if (err) | 1849 | if (err) |
1865 | goto err; | 1850 | goto err; |
@@ -1875,7 +1860,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id) | |||
1875 | set_tvnorm(btv, i); | 1860 | set_tvnorm(btv, i); |
1876 | 1861 | ||
1877 | err: | 1862 | err: |
1878 | mutex_unlock(&btv->lock); | ||
1879 | 1863 | ||
1880 | return err; | 1864 | return err; |
1881 | } | 1865 | } |
@@ -1899,7 +1883,6 @@ static int bttv_enum_input(struct file *file, void *priv, | |||
1899 | struct bttv *btv = fh->btv; | 1883 | struct bttv *btv = fh->btv; |
1900 | int rc = 0; | 1884 | int rc = 0; |
1901 | 1885 | ||
1902 | mutex_lock(&btv->lock); | ||
1903 | if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { | 1886 | if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { |
1904 | rc = -EINVAL; | 1887 | rc = -EINVAL; |
1905 | goto err; | 1888 | goto err; |
@@ -1929,7 +1912,6 @@ static int bttv_enum_input(struct file *file, void *priv, | |||
1929 | i->std = BTTV_NORMS; | 1912 | i->std = BTTV_NORMS; |
1930 | 1913 | ||
1931 | err: | 1914 | err: |
1932 | mutex_unlock(&btv->lock); | ||
1933 | 1915 | ||
1934 | return rc; | 1916 | return rc; |
1935 | } | 1917 | } |
@@ -1939,9 +1921,7 @@ static int bttv_g_input(struct file *file, void *priv, unsigned int *i) | |||
1939 | struct bttv_fh *fh = priv; | 1921 | struct bttv_fh *fh = priv; |
1940 | struct bttv *btv = fh->btv; | 1922 | struct bttv *btv = fh->btv; |
1941 | 1923 | ||
1942 | mutex_lock(&btv->lock); | ||
1943 | *i = btv->input; | 1924 | *i = btv->input; |
1944 | mutex_unlock(&btv->lock); | ||
1945 | 1925 | ||
1946 | return 0; | 1926 | return 0; |
1947 | } | 1927 | } |
@@ -1953,7 +1933,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i) | |||
1953 | 1933 | ||
1954 | int err; | 1934 | int err; |
1955 | 1935 | ||
1956 | mutex_lock(&btv->lock); | ||
1957 | err = v4l2_prio_check(&btv->prio, fh->prio); | 1936 | err = v4l2_prio_check(&btv->prio, fh->prio); |
1958 | if (unlikely(err)) | 1937 | if (unlikely(err)) |
1959 | goto err; | 1938 | goto err; |
@@ -1966,7 +1945,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i) | |||
1966 | set_input(btv, i, btv->tvnorm); | 1945 | set_input(btv, i, btv->tvnorm); |
1967 | 1946 | ||
1968 | err: | 1947 | err: |
1969 | mutex_unlock(&btv->lock); | ||
1970 | return 0; | 1948 | return 0; |
1971 | } | 1949 | } |
1972 | 1950 | ||
@@ -1980,7 +1958,6 @@ static int bttv_s_tuner(struct file *file, void *priv, | |||
1980 | if (unlikely(0 != t->index)) | 1958 | if (unlikely(0 != t->index)) |
1981 | return -EINVAL; | 1959 | return -EINVAL; |
1982 | 1960 | ||
1983 | mutex_lock(&btv->lock); | ||
1984 | if (unlikely(btv->tuner_type == TUNER_ABSENT)) { | 1961 | if (unlikely(btv->tuner_type == TUNER_ABSENT)) { |
1985 | err = -EINVAL; | 1962 | err = -EINVAL; |
1986 | goto err; | 1963 | goto err; |
@@ -1996,7 +1973,6 @@ static int bttv_s_tuner(struct file *file, void *priv, | |||
1996 | btv->audio_mode_gpio(btv, t, 1); | 1973 | btv->audio_mode_gpio(btv, t, 1); |
1997 | 1974 | ||
1998 | err: | 1975 | err: |
1999 | mutex_unlock(&btv->lock); | ||
2000 | 1976 | ||
2001 | return 0; | 1977 | return 0; |
2002 | } | 1978 | } |
@@ -2007,10 +1983,8 @@ static int bttv_g_frequency(struct file *file, void *priv, | |||
2007 | struct bttv_fh *fh = priv; | 1983 | struct bttv_fh *fh = priv; |
2008 | struct bttv *btv = fh->btv; | 1984 | struct bttv *btv = fh->btv; |
2009 | 1985 | ||
2010 | mutex_lock(&btv->lock); | ||
2011 | f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1986 | f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
2012 | f->frequency = btv->freq; | 1987 | f->frequency = btv->freq; |
2013 | mutex_unlock(&btv->lock); | ||
2014 | 1988 | ||
2015 | return 0; | 1989 | return 0; |
2016 | } | 1990 | } |
@@ -2025,7 +1999,6 @@ static int bttv_s_frequency(struct file *file, void *priv, | |||
2025 | if (unlikely(f->tuner != 0)) | 1999 | if (unlikely(f->tuner != 0)) |
2026 | return -EINVAL; | 2000 | return -EINVAL; |
2027 | 2001 | ||
2028 | mutex_lock(&btv->lock); | ||
2029 | err = v4l2_prio_check(&btv->prio, fh->prio); | 2002 | err = v4l2_prio_check(&btv->prio, fh->prio); |
2030 | if (unlikely(err)) | 2003 | if (unlikely(err)) |
2031 | goto err; | 2004 | goto err; |
@@ -2040,7 +2013,6 @@ static int bttv_s_frequency(struct file *file, void *priv, | |||
2040 | if (btv->has_matchbox && btv->radio_user) | 2013 | if (btv->has_matchbox && btv->radio_user) |
2041 | tea5757_set_freq(btv, btv->freq); | 2014 | tea5757_set_freq(btv, btv->freq); |
2042 | err: | 2015 | err: |
2043 | mutex_unlock(&btv->lock); | ||
2044 | 2016 | ||
2045 | return 0; | 2017 | return 0; |
2046 | } | 2018 | } |
@@ -2173,7 +2145,6 @@ limit_scaled_size_lock (struct bttv_fh * fh, | |||
2173 | 2145 | ||
2174 | /* Make sure tvnorm, vbi_end and the current cropping parameters | 2146 | /* Make sure tvnorm, vbi_end and the current cropping parameters |
2175 | remain consistent until we're done. */ | 2147 | remain consistent until we're done. */ |
2176 | mutex_lock(&btv->lock); | ||
2177 | 2148 | ||
2178 | b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; | 2149 | b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; |
2179 | 2150 | ||
@@ -2251,7 +2222,6 @@ limit_scaled_size_lock (struct bttv_fh * fh, | |||
2251 | rc = 0; /* success */ | 2222 | rc = 0; /* success */ |
2252 | 2223 | ||
2253 | fail: | 2224 | fail: |
2254 | mutex_unlock(&btv->lock); | ||
2255 | 2225 | ||
2256 | return rc; | 2226 | return rc; |
2257 | } | 2227 | } |
@@ -2283,9 +2253,7 @@ verify_window_lock (struct bttv_fh * fh, | |||
2283 | if (V4L2_FIELD_ANY == field) { | 2253 | if (V4L2_FIELD_ANY == field) { |
2284 | __s32 height2; | 2254 | __s32 height2; |
2285 | 2255 | ||
2286 | mutex_lock(&fh->btv->lock); | ||
2287 | height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; | 2256 | height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; |
2288 | mutex_unlock(&fh->btv->lock); | ||
2289 | field = (win->w.height > height2) | 2257 | field = (win->w.height > height2) |
2290 | ? V4L2_FIELD_INTERLACED | 2258 | ? V4L2_FIELD_INTERLACED |
2291 | : V4L2_FIELD_TOP; | 2259 | : V4L2_FIELD_TOP; |
@@ -2361,7 +2329,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, | |||
2361 | } | 2329 | } |
2362 | } | 2330 | } |
2363 | 2331 | ||
2364 | mutex_lock(&fh->cap.vb_lock); | ||
2365 | /* clip against screen */ | 2332 | /* clip against screen */ |
2366 | if (NULL != btv->fbuf.base) | 2333 | if (NULL != btv->fbuf.base) |
2367 | n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, | 2334 | n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, |
@@ -2413,7 +2380,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, | |||
2413 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2380 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
2414 | retval = bttv_switch_overlay(btv,fh,new); | 2381 | retval = bttv_switch_overlay(btv,fh,new); |
2415 | } | 2382 | } |
2416 | mutex_unlock(&fh->cap.vb_lock); | ||
2417 | return retval; | 2383 | return retval; |
2418 | } | 2384 | } |
2419 | 2385 | ||
@@ -2527,9 +2493,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv, | |||
2527 | if (V4L2_FIELD_ANY == field) { | 2493 | if (V4L2_FIELD_ANY == field) { |
2528 | __s32 height2; | 2494 | __s32 height2; |
2529 | 2495 | ||
2530 | mutex_lock(&btv->lock); | ||
2531 | height2 = btv->crop[!!fh->do_crop].rect.height >> 1; | 2496 | height2 = btv->crop[!!fh->do_crop].rect.height >> 1; |
2532 | mutex_unlock(&btv->lock); | ||
2533 | field = (f->fmt.pix.height > height2) | 2497 | field = (f->fmt.pix.height > height2) |
2534 | ? V4L2_FIELD_INTERLACED | 2498 | ? V4L2_FIELD_INTERLACED |
2535 | : V4L2_FIELD_BOTTOM; | 2499 | : V4L2_FIELD_BOTTOM; |
@@ -2615,7 +2579,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv, | |||
2615 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 2579 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
2616 | 2580 | ||
2617 | /* update our state informations */ | 2581 | /* update our state informations */ |
2618 | mutex_lock(&fh->cap.vb_lock); | ||
2619 | fh->fmt = fmt; | 2582 | fh->fmt = fmt; |
2620 | fh->cap.field = f->fmt.pix.field; | 2583 | fh->cap.field = f->fmt.pix.field; |
2621 | fh->cap.last = V4L2_FIELD_NONE; | 2584 | fh->cap.last = V4L2_FIELD_NONE; |
@@ -2624,7 +2587,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv, | |||
2624 | btv->init.fmt = fmt; | 2587 | btv->init.fmt = fmt; |
2625 | btv->init.width = f->fmt.pix.width; | 2588 | btv->init.width = f->fmt.pix.width; |
2626 | btv->init.height = f->fmt.pix.height; | 2589 | btv->init.height = f->fmt.pix.height; |
2627 | mutex_unlock(&fh->cap.vb_lock); | ||
2628 | 2590 | ||
2629 | return 0; | 2591 | return 0; |
2630 | } | 2592 | } |
@@ -2650,11 +2612,9 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | |||
2650 | unsigned int i; | 2612 | unsigned int i; |
2651 | struct bttv_fh *fh = priv; | 2613 | struct bttv_fh *fh = priv; |
2652 | 2614 | ||
2653 | mutex_lock(&fh->cap.vb_lock); | ||
2654 | retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, | 2615 | retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, |
2655 | V4L2_MEMORY_MMAP); | 2616 | V4L2_MEMORY_MMAP); |
2656 | if (retval < 0) { | 2617 | if (retval < 0) { |
2657 | mutex_unlock(&fh->cap.vb_lock); | ||
2658 | return retval; | 2618 | return retval; |
2659 | } | 2619 | } |
2660 | 2620 | ||
@@ -2666,7 +2626,6 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) | |||
2666 | for (i = 0; i < gbuffers; i++) | 2626 | for (i = 0; i < gbuffers; i++) |
2667 | mbuf->offsets[i] = i * gbufsize; | 2627 | mbuf->offsets[i] = i * gbufsize; |
2668 | 2628 | ||
2669 | mutex_unlock(&fh->cap.vb_lock); | ||
2670 | return 0; | 2629 | return 0; |
2671 | } | 2630 | } |
2672 | #endif | 2631 | #endif |
@@ -2776,10 +2735,8 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
2776 | int retval = 0; | 2735 | int retval = 0; |
2777 | 2736 | ||
2778 | if (on) { | 2737 | if (on) { |
2779 | mutex_lock(&fh->cap.vb_lock); | ||
2780 | /* verify args */ | 2738 | /* verify args */ |
2781 | if (unlikely(!btv->fbuf.base)) { | 2739 | if (unlikely(!btv->fbuf.base)) { |
2782 | mutex_unlock(&fh->cap.vb_lock); | ||
2783 | return -EINVAL; | 2740 | return -EINVAL; |
2784 | } | 2741 | } |
2785 | if (unlikely(!fh->ov.setup_ok)) { | 2742 | if (unlikely(!fh->ov.setup_ok)) { |
@@ -2788,13 +2745,11 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
2788 | } | 2745 | } |
2789 | if (retval) | 2746 | if (retval) |
2790 | return retval; | 2747 | return retval; |
2791 | mutex_unlock(&fh->cap.vb_lock); | ||
2792 | } | 2748 | } |
2793 | 2749 | ||
2794 | if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) | 2750 | if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) |
2795 | return -EBUSY; | 2751 | return -EBUSY; |
2796 | 2752 | ||
2797 | mutex_lock(&fh->cap.vb_lock); | ||
2798 | if (on) { | 2753 | if (on) { |
2799 | fh->ov.tvnorm = btv->tvnorm; | 2754 | fh->ov.tvnorm = btv->tvnorm; |
2800 | new = videobuf_sg_alloc(sizeof(*new)); | 2755 | new = videobuf_sg_alloc(sizeof(*new)); |
@@ -2806,7 +2761,6 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
2806 | 2761 | ||
2807 | /* switch over */ | 2762 | /* switch over */ |
2808 | retval = bttv_switch_overlay(btv, fh, new); | 2763 | retval = bttv_switch_overlay(btv, fh, new); |
2809 | mutex_unlock(&fh->cap.vb_lock); | ||
2810 | return retval; | 2764 | return retval; |
2811 | } | 2765 | } |
2812 | 2766 | ||
@@ -2845,7 +2799,6 @@ static int bttv_s_fbuf(struct file *file, void *f, | |||
2845 | } | 2799 | } |
2846 | 2800 | ||
2847 | /* ok, accept it */ | 2801 | /* ok, accept it */ |
2848 | mutex_lock(&fh->cap.vb_lock); | ||
2849 | btv->fbuf.base = fb->base; | 2802 | btv->fbuf.base = fb->base; |
2850 | btv->fbuf.fmt.width = fb->fmt.width; | 2803 | btv->fbuf.fmt.width = fb->fmt.width; |
2851 | btv->fbuf.fmt.height = fb->fmt.height; | 2804 | btv->fbuf.fmt.height = fb->fmt.height; |
@@ -2877,7 +2830,6 @@ static int bttv_s_fbuf(struct file *file, void *f, | |||
2877 | retval = bttv_switch_overlay(btv, fh, new); | 2830 | retval = bttv_switch_overlay(btv, fh, new); |
2878 | } | 2831 | } |
2879 | } | 2832 | } |
2880 | mutex_unlock(&fh->cap.vb_lock); | ||
2881 | return retval; | 2833 | return retval; |
2882 | } | 2834 | } |
2883 | 2835 | ||
@@ -2956,7 +2908,6 @@ static int bttv_queryctrl(struct file *file, void *priv, | |||
2956 | c->id >= V4L2_CID_PRIVATE_LASTP1)) | 2908 | c->id >= V4L2_CID_PRIVATE_LASTP1)) |
2957 | return -EINVAL; | 2909 | return -EINVAL; |
2958 | 2910 | ||
2959 | mutex_lock(&btv->lock); | ||
2960 | if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME)) | 2911 | if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME)) |
2961 | *c = no_ctl; | 2912 | *c = no_ctl; |
2962 | else { | 2913 | else { |
@@ -2964,7 +2915,6 @@ static int bttv_queryctrl(struct file *file, void *priv, | |||
2964 | 2915 | ||
2965 | *c = (NULL != ctrl) ? *ctrl : no_ctl; | 2916 | *c = (NULL != ctrl) ? *ctrl : no_ctl; |
2966 | } | 2917 | } |
2967 | mutex_unlock(&btv->lock); | ||
2968 | 2918 | ||
2969 | return 0; | 2919 | return 0; |
2970 | } | 2920 | } |
@@ -2975,10 +2925,8 @@ static int bttv_g_parm(struct file *file, void *f, | |||
2975 | struct bttv_fh *fh = f; | 2925 | struct bttv_fh *fh = f; |
2976 | struct bttv *btv = fh->btv; | 2926 | struct bttv *btv = fh->btv; |
2977 | 2927 | ||
2978 | mutex_lock(&btv->lock); | ||
2979 | v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, | 2928 | v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, |
2980 | &parm->parm.capture.timeperframe); | 2929 | &parm->parm.capture.timeperframe); |
2981 | mutex_unlock(&btv->lock); | ||
2982 | 2930 | ||
2983 | return 0; | 2931 | return 0; |
2984 | } | 2932 | } |
@@ -2994,7 +2942,6 @@ static int bttv_g_tuner(struct file *file, void *priv, | |||
2994 | if (0 != t->index) | 2942 | if (0 != t->index) |
2995 | return -EINVAL; | 2943 | return -EINVAL; |
2996 | 2944 | ||
2997 | mutex_lock(&btv->lock); | ||
2998 | t->rxsubchans = V4L2_TUNER_SUB_MONO; | 2945 | t->rxsubchans = V4L2_TUNER_SUB_MONO; |
2999 | bttv_call_all(btv, tuner, g_tuner, t); | 2946 | bttv_call_all(btv, tuner, g_tuner, t); |
3000 | strcpy(t->name, "Television"); | 2947 | strcpy(t->name, "Television"); |
@@ -3006,7 +2953,6 @@ static int bttv_g_tuner(struct file *file, void *priv, | |||
3006 | if (btv->audio_mode_gpio) | 2953 | if (btv->audio_mode_gpio) |
3007 | btv->audio_mode_gpio(btv, t, 0); | 2954 | btv->audio_mode_gpio(btv, t, 0); |
3008 | 2955 | ||
3009 | mutex_unlock(&btv->lock); | ||
3010 | return 0; | 2956 | return 0; |
3011 | } | 2957 | } |
3012 | 2958 | ||
@@ -3015,9 +2961,7 @@ static int bttv_g_priority(struct file *file, void *f, enum v4l2_priority *p) | |||
3015 | struct bttv_fh *fh = f; | 2961 | struct bttv_fh *fh = f; |
3016 | struct bttv *btv = fh->btv; | 2962 | struct bttv *btv = fh->btv; |
3017 | 2963 | ||
3018 | mutex_lock(&btv->lock); | ||
3019 | *p = v4l2_prio_max(&btv->prio); | 2964 | *p = v4l2_prio_max(&btv->prio); |
3020 | mutex_unlock(&btv->lock); | ||
3021 | 2965 | ||
3022 | return 0; | 2966 | return 0; |
3023 | } | 2967 | } |
@@ -3029,9 +2973,7 @@ static int bttv_s_priority(struct file *file, void *f, | |||
3029 | struct bttv *btv = fh->btv; | 2973 | struct bttv *btv = fh->btv; |
3030 | int rc; | 2974 | int rc; |
3031 | 2975 | ||
3032 | mutex_lock(&btv->lock); | ||
3033 | rc = v4l2_prio_change(&btv->prio, &fh->prio, prio); | 2976 | rc = v4l2_prio_change(&btv->prio, &fh->prio, prio); |
3034 | mutex_unlock(&btv->lock); | ||
3035 | 2977 | ||
3036 | return rc; | 2978 | return rc; |
3037 | } | 2979 | } |
@@ -3046,9 +2988,7 @@ static int bttv_cropcap(struct file *file, void *priv, | |||
3046 | cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) | 2988 | cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) |
3047 | return -EINVAL; | 2989 | return -EINVAL; |
3048 | 2990 | ||
3049 | mutex_lock(&btv->lock); | ||
3050 | *cap = bttv_tvnorms[btv->tvnorm].cropcap; | 2991 | *cap = bttv_tvnorms[btv->tvnorm].cropcap; |
3051 | mutex_unlock(&btv->lock); | ||
3052 | 2992 | ||
3053 | return 0; | 2993 | return 0; |
3054 | } | 2994 | } |
@@ -3066,9 +3006,7 @@ static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3066 | inconsistent with fh->width or fh->height and apps | 3006 | inconsistent with fh->width or fh->height and apps |
3067 | do not expect a change here. */ | 3007 | do not expect a change here. */ |
3068 | 3008 | ||
3069 | mutex_lock(&btv->lock); | ||
3070 | crop->c = btv->crop[!!fh->do_crop].rect; | 3009 | crop->c = btv->crop[!!fh->do_crop].rect; |
3071 | mutex_unlock(&btv->lock); | ||
3072 | 3010 | ||
3073 | return 0; | 3011 | return 0; |
3074 | } | 3012 | } |
@@ -3092,17 +3030,14 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3092 | /* Make sure tvnorm, vbi_end and the current cropping | 3030 | /* Make sure tvnorm, vbi_end and the current cropping |
3093 | parameters remain consistent until we're done. Note | 3031 | parameters remain consistent until we're done. Note |
3094 | read() may change vbi_end in check_alloc_btres_lock(). */ | 3032 | read() may change vbi_end in check_alloc_btres_lock(). */ |
3095 | mutex_lock(&btv->lock); | ||
3096 | retval = v4l2_prio_check(&btv->prio, fh->prio); | 3033 | retval = v4l2_prio_check(&btv->prio, fh->prio); |
3097 | if (0 != retval) { | 3034 | if (0 != retval) { |
3098 | mutex_unlock(&btv->lock); | ||
3099 | return retval; | 3035 | return retval; |
3100 | } | 3036 | } |
3101 | 3037 | ||
3102 | retval = -EBUSY; | 3038 | retval = -EBUSY; |
3103 | 3039 | ||
3104 | if (locked_btres(fh->btv, VIDEO_RESOURCES)) { | 3040 | if (locked_btres(fh->btv, VIDEO_RESOURCES)) { |
3105 | mutex_unlock(&btv->lock); | ||
3106 | return retval; | 3041 | return retval; |
3107 | } | 3042 | } |
3108 | 3043 | ||
@@ -3114,7 +3049,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3114 | 3049 | ||
3115 | b_top = max(b->top, btv->vbi_end); | 3050 | b_top = max(b->top, btv->vbi_end); |
3116 | if (b_top + 32 >= b_bottom) { | 3051 | if (b_top + 32 >= b_bottom) { |
3117 | mutex_unlock(&btv->lock); | ||
3118 | return retval; | 3052 | return retval; |
3119 | } | 3053 | } |
3120 | 3054 | ||
@@ -3137,12 +3071,8 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3137 | 3071 | ||
3138 | btv->crop[1] = c; | 3072 | btv->crop[1] = c; |
3139 | 3073 | ||
3140 | mutex_unlock(&btv->lock); | ||
3141 | |||
3142 | fh->do_crop = 1; | 3074 | fh->do_crop = 1; |
3143 | 3075 | ||
3144 | mutex_lock(&fh->cap.vb_lock); | ||
3145 | |||
3146 | if (fh->width < c.min_scaled_width) { | 3076 | if (fh->width < c.min_scaled_width) { |
3147 | fh->width = c.min_scaled_width; | 3077 | fh->width = c.min_scaled_width; |
3148 | btv->init.width = c.min_scaled_width; | 3078 | btv->init.width = c.min_scaled_width; |
@@ -3159,8 +3089,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
3159 | btv->init.height = c.max_scaled_height; | 3089 | btv->init.height = c.max_scaled_height; |
3160 | } | 3090 | } |
3161 | 3091 | ||
3162 | mutex_unlock(&fh->cap.vb_lock); | ||
3163 | |||
3164 | return 0; | 3092 | return 0; |
3165 | } | 3093 | } |
3166 | 3094 | ||
@@ -3228,7 +3156,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
3228 | return videobuf_poll_stream(file, &fh->vbi, wait); | 3156 | return videobuf_poll_stream(file, &fh->vbi, wait); |
3229 | } | 3157 | } |
3230 | 3158 | ||
3231 | mutex_lock(&fh->cap.vb_lock); | ||
3232 | if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { | 3159 | if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { |
3233 | /* streaming capture */ | 3160 | /* streaming capture */ |
3234 | if (list_empty(&fh->cap.stream)) | 3161 | if (list_empty(&fh->cap.stream)) |
@@ -3263,7 +3190,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
3263 | else | 3190 | else |
3264 | rc = 0; | 3191 | rc = 0; |
3265 | err: | 3192 | err: |
3266 | mutex_unlock(&fh->cap.vb_lock); | ||
3267 | return rc; | 3193 | return rc; |
3268 | } | 3194 | } |
3269 | 3195 | ||
@@ -3303,14 +3229,11 @@ static int bttv_open(struct file *file) | |||
3303 | * Let's first copy btv->init at fh, holding cap.vb_lock, and then work | 3229 | * Let's first copy btv->init at fh, holding cap.vb_lock, and then work |
3304 | * with the rest of init, holding btv->lock. | 3230 | * with the rest of init, holding btv->lock. |
3305 | */ | 3231 | */ |
3306 | mutex_lock(&fh->cap.vb_lock); | ||
3307 | *fh = btv->init; | 3232 | *fh = btv->init; |
3308 | mutex_unlock(&fh->cap.vb_lock); | ||
3309 | 3233 | ||
3310 | fh->type = type; | 3234 | fh->type = type; |
3311 | fh->ov.setup_ok = 0; | 3235 | fh->ov.setup_ok = 0; |
3312 | 3236 | ||
3313 | mutex_lock(&btv->lock); | ||
3314 | v4l2_prio_open(&btv->prio, &fh->prio); | 3237 | v4l2_prio_open(&btv->prio, &fh->prio); |
3315 | 3238 | ||
3316 | videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, | 3239 | videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, |
@@ -3318,13 +3241,13 @@ static int bttv_open(struct file *file) | |||
3318 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 3241 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
3319 | V4L2_FIELD_INTERLACED, | 3242 | V4L2_FIELD_INTERLACED, |
3320 | sizeof(struct bttv_buffer), | 3243 | sizeof(struct bttv_buffer), |
3321 | fh, NULL); | 3244 | fh, &btv->lock); |
3322 | videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, | 3245 | videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, |
3323 | &btv->c.pci->dev, &btv->s_lock, | 3246 | &btv->c.pci->dev, &btv->s_lock, |
3324 | V4L2_BUF_TYPE_VBI_CAPTURE, | 3247 | V4L2_BUF_TYPE_VBI_CAPTURE, |
3325 | V4L2_FIELD_SEQ_TB, | 3248 | V4L2_FIELD_SEQ_TB, |
3326 | sizeof(struct bttv_buffer), | 3249 | sizeof(struct bttv_buffer), |
3327 | fh, NULL); | 3250 | fh, &btv->lock); |
3328 | set_tvnorm(btv,btv->tvnorm); | 3251 | set_tvnorm(btv,btv->tvnorm); |
3329 | set_input(btv, btv->input, btv->tvnorm); | 3252 | set_input(btv, btv->input, btv->tvnorm); |
3330 | 3253 | ||
@@ -3347,7 +3270,6 @@ static int bttv_open(struct file *file) | |||
3347 | bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); | 3270 | bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); |
3348 | 3271 | ||
3349 | bttv_field_count(btv); | 3272 | bttv_field_count(btv); |
3350 | mutex_unlock(&btv->lock); | ||
3351 | return 0; | 3273 | return 0; |
3352 | } | 3274 | } |
3353 | 3275 | ||
@@ -3356,7 +3278,6 @@ static int bttv_release(struct file *file) | |||
3356 | struct bttv_fh *fh = file->private_data; | 3278 | struct bttv_fh *fh = file->private_data; |
3357 | struct bttv *btv = fh->btv; | 3279 | struct bttv *btv = fh->btv; |
3358 | 3280 | ||
3359 | mutex_lock(&btv->lock); | ||
3360 | /* turn off overlay */ | 3281 | /* turn off overlay */ |
3361 | if (check_btres(fh, RESOURCE_OVERLAY)) | 3282 | if (check_btres(fh, RESOURCE_OVERLAY)) |
3362 | bttv_switch_overlay(btv,fh,NULL); | 3283 | bttv_switch_overlay(btv,fh,NULL); |
@@ -3386,10 +3307,8 @@ static int bttv_release(struct file *file) | |||
3386 | * videobuf uses cap.vb_lock - we should avoid holding btv->lock, | 3307 | * videobuf uses cap.vb_lock - we should avoid holding btv->lock, |
3387 | * otherwise we may have dead lock conditions | 3308 | * otherwise we may have dead lock conditions |
3388 | */ | 3309 | */ |
3389 | mutex_unlock(&btv->lock); | ||
3390 | videobuf_mmap_free(&fh->cap); | 3310 | videobuf_mmap_free(&fh->cap); |
3391 | videobuf_mmap_free(&fh->vbi); | 3311 | videobuf_mmap_free(&fh->vbi); |
3392 | mutex_lock(&btv->lock); | ||
3393 | v4l2_prio_close(&btv->prio, fh->prio); | 3312 | v4l2_prio_close(&btv->prio, fh->prio); |
3394 | file->private_data = NULL; | 3313 | file->private_data = NULL; |
3395 | kfree(fh); | 3314 | kfree(fh); |
@@ -3399,7 +3318,6 @@ static int bttv_release(struct file *file) | |||
3399 | 3318 | ||
3400 | if (!btv->users) | 3319 | if (!btv->users) |
3401 | audio_mute(btv, 1); | 3320 | audio_mute(btv, 1); |
3402 | mutex_unlock(&btv->lock); | ||
3403 | 3321 | ||
3404 | return 0; | 3322 | return 0; |
3405 | } | 3323 | } |
@@ -3503,11 +3421,8 @@ static int radio_open(struct file *file) | |||
3503 | if (unlikely(!fh)) | 3421 | if (unlikely(!fh)) |
3504 | return -ENOMEM; | 3422 | return -ENOMEM; |
3505 | file->private_data = fh; | 3423 | file->private_data = fh; |
3506 | mutex_lock(&fh->cap.vb_lock); | ||
3507 | *fh = btv->init; | 3424 | *fh = btv->init; |
3508 | mutex_unlock(&fh->cap.vb_lock); | ||
3509 | 3425 | ||
3510 | mutex_lock(&btv->lock); | ||
3511 | v4l2_prio_open(&btv->prio, &fh->prio); | 3426 | v4l2_prio_open(&btv->prio, &fh->prio); |
3512 | 3427 | ||
3513 | btv->radio_user++; | 3428 | btv->radio_user++; |
@@ -3515,7 +3430,6 @@ static int radio_open(struct file *file) | |||
3515 | bttv_call_all(btv, tuner, s_radio); | 3430 | bttv_call_all(btv, tuner, s_radio); |
3516 | audio_input(btv,TVAUDIO_INPUT_RADIO); | 3431 | audio_input(btv,TVAUDIO_INPUT_RADIO); |
3517 | 3432 | ||
3518 | mutex_unlock(&btv->lock); | ||
3519 | return 0; | 3433 | return 0; |
3520 | } | 3434 | } |
3521 | 3435 | ||
@@ -3525,7 +3439,6 @@ static int radio_release(struct file *file) | |||
3525 | struct bttv *btv = fh->btv; | 3439 | struct bttv *btv = fh->btv; |
3526 | struct rds_command cmd; | 3440 | struct rds_command cmd; |
3527 | 3441 | ||
3528 | mutex_lock(&btv->lock); | ||
3529 | v4l2_prio_close(&btv->prio, fh->prio); | 3442 | v4l2_prio_close(&btv->prio, fh->prio); |
3530 | file->private_data = NULL; | 3443 | file->private_data = NULL; |
3531 | kfree(fh); | 3444 | kfree(fh); |
@@ -3533,7 +3446,6 @@ static int radio_release(struct file *file) | |||
3533 | btv->radio_user--; | 3446 | btv->radio_user--; |
3534 | 3447 | ||
3535 | bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd); | 3448 | bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd); |
3536 | mutex_unlock(&btv->lock); | ||
3537 | 3449 | ||
3538 | return 0; | 3450 | return 0; |
3539 | } | 3451 | } |
@@ -3562,7 +3474,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
3562 | return -EINVAL; | 3474 | return -EINVAL; |
3563 | if (0 != t->index) | 3475 | if (0 != t->index) |
3564 | return -EINVAL; | 3476 | return -EINVAL; |
3565 | mutex_lock(&btv->lock); | ||
3566 | strcpy(t->name, "Radio"); | 3477 | strcpy(t->name, "Radio"); |
3567 | t->type = V4L2_TUNER_RADIO; | 3478 | t->type = V4L2_TUNER_RADIO; |
3568 | 3479 | ||
@@ -3571,8 +3482,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | |||
3571 | if (btv->audio_mode_gpio) | 3482 | if (btv->audio_mode_gpio) |
3572 | btv->audio_mode_gpio(btv, t, 0); | 3483 | btv->audio_mode_gpio(btv, t, 0); |
3573 | 3484 | ||
3574 | mutex_unlock(&btv->lock); | ||
3575 | |||
3576 | return 0; | 3485 | return 0; |
3577 | } | 3486 | } |
3578 | 3487 | ||
@@ -3693,7 +3602,7 @@ static const struct v4l2_file_operations radio_fops = | |||
3693 | .open = radio_open, | 3602 | .open = radio_open, |
3694 | .read = radio_read, | 3603 | .read = radio_read, |
3695 | .release = radio_release, | 3604 | .release = radio_release, |
3696 | .ioctl = video_ioctl2, | 3605 | .unlocked_ioctl = video_ioctl2, |
3697 | .poll = radio_poll, | 3606 | .poll = radio_poll, |
3698 | }; | 3607 | }; |
3699 | 3608 | ||