aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>2007-10-26 10:01:08 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:00:57 -0500
commite84619b17440ccca4e4db7583d126c4189b987e5 (patch)
tree33314395996c204ad52ddb239faaa2cefc5bca6b /drivers
parent302f61ad5db0e6a4c265e1f6454c102e2283a926 (diff)
V4L/DVB (6410): Partial conversion from V4L1 to V4L2
This is part of the old V4L1->V4L2 bttv patch, ported to current tree by Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/bt8xx/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c663
-rw-r--r--drivers/media/video/bt8xx/bttvp.h4
3 files changed, 131 insertions, 538 deletions
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 2ca162b390a2..ce93312cf843 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L1 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER 5 select FW_LOADER
6 select VIDEO_BTCX 6 select VIDEO_BTCX
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 3e5c50ac9139..cb50fde2be86 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -9,6 +9,9 @@
9 some v4l2 code lines are taken from Justin's bttv2 driver which is 9 some v4l2 code lines are taken from Justin's bttv2 driver which is
10 (c) 2000 Justin Schoeman <justin@suntiger.ee.up.ac.za> 10 (c) 2000 Justin Schoeman <justin@suntiger.ee.up.ac.za>
11 11
12 V4L1 removal from:
13 (c) 2005-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
14
12 Cropping and overscan support 15 Cropping and overscan support
13 Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at> 16 Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at>
14 Sponsored by OPQ Systems AB 17 Sponsored by OPQ Systems AB
@@ -1912,111 +1915,6 @@ static struct videobuf_queue_ops bttv_video_qops = {
1912static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) 1915static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1913{ 1916{
1914 switch (cmd) { 1917 switch (cmd) {
1915 case BTTV_VERSION:
1916 return BTTV_VERSION_CODE;
1917
1918 /* *** v4l1 *** ************************************************ */
1919 case VIDIOCGFREQ:
1920 {
1921 unsigned long *freq = arg;
1922 *freq = btv->freq;
1923 return 0;
1924 }
1925 case VIDIOCSFREQ:
1926 {
1927 struct v4l2_frequency freq;
1928
1929 memset(&freq, 0, sizeof(freq));
1930 freq.frequency = *(unsigned long *)arg;
1931 mutex_lock(&btv->lock);
1932 freq.type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1933 btv->freq = *(unsigned long *)arg;
1934 bttv_call_i2c_clients(btv,VIDIOC_S_FREQUENCY,&freq);
1935 if (btv->has_matchbox && btv->radio_user)
1936 tea5757_set_freq(btv,*(unsigned long *)arg);
1937 mutex_unlock(&btv->lock);
1938 return 0;
1939 }
1940
1941 case VIDIOCGTUNER:
1942 {
1943 struct video_tuner *v = arg;
1944
1945 if (UNSET == bttv_tvcards[btv->c.type].tuner)
1946 return -EINVAL;
1947 if (v->tuner) /* Only tuner 0 */
1948 return -EINVAL;
1949 strcpy(v->name, "Television");
1950 v->rangelow = 0;
1951 v->rangehigh = 0x7FFFFFFF;
1952 v->flags = VIDEO_TUNER_PAL|VIDEO_TUNER_NTSC|VIDEO_TUNER_SECAM;
1953 v->mode = btv->tvnorm;
1954 v->signal = (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) ? 0xFFFF : 0;
1955 bttv_call_i2c_clients(btv,cmd,v);
1956 return 0;
1957 }
1958 case VIDIOCSTUNER:
1959 {
1960 struct video_tuner *v = arg;
1961
1962 if (v->tuner) /* Only tuner 0 */
1963 return -EINVAL;
1964 if (v->mode >= BTTV_TVNORMS)
1965 return -EINVAL;
1966
1967 mutex_lock(&btv->lock);
1968 set_tvnorm(btv,v->mode);
1969 bttv_call_i2c_clients(btv,cmd,v);
1970 mutex_unlock(&btv->lock);
1971 return 0;
1972 }
1973
1974 case VIDIOCGCHAN:
1975 {
1976 struct video_channel *v = arg;
1977 unsigned int channel = v->channel;
1978
1979 if (channel >= bttv_tvcards[btv->c.type].video_inputs)
1980 return -EINVAL;
1981 v->tuners=0;
1982 v->flags = VIDEO_VC_AUDIO;
1983 v->type = VIDEO_TYPE_CAMERA;
1984 v->norm = btv->tvnorm;
1985 if (channel == bttv_tvcards[btv->c.type].tuner) {
1986 strcpy(v->name,"Television");
1987 v->flags|=VIDEO_VC_TUNER;
1988 v->type=VIDEO_TYPE_TV;
1989 v->tuners=1;
1990 } else if (channel == btv->svhs) {
1991 strcpy(v->name,"S-Video");
1992 } else {
1993 sprintf(v->name,"Composite%d",channel);
1994 }
1995 return 0;
1996 }
1997 case VIDIOCSCHAN:
1998 {
1999 struct video_channel *v = arg;
2000 unsigned int channel = v->channel;
2001
2002 if (channel >= bttv_tvcards[btv->c.type].video_inputs)
2003 return -EINVAL;
2004 if (v->norm >= BTTV_TVNORMS)
2005 return -EINVAL;
2006
2007 mutex_lock(&btv->lock);
2008 if (channel == btv->input &&
2009 v->norm == btv->tvnorm) {
2010 /* nothing to do */
2011 mutex_unlock(&btv->lock);
2012 return 0;
2013 }
2014
2015 set_input(btv, v->channel, v->norm);
2016 mutex_unlock(&btv->lock);
2017 return 0;
2018 }
2019
2020 case VIDIOCGAUDIO: 1918 case VIDIOCGAUDIO:
2021 { 1919 {
2022 struct video_audio *v = arg; 1920 struct video_audio *v = arg;
@@ -2152,45 +2050,6 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
2152 return 0; 2050 return 0;
2153 } 2051 }
2154 2052
2155 case VIDIOC_G_TUNER:
2156 {
2157 struct v4l2_tuner *t = arg;
2158
2159 if (UNSET == bttv_tvcards[btv->c.type].tuner)
2160 return -EINVAL;
2161 if (0 != t->index)
2162 return -EINVAL;
2163 mutex_lock(&btv->lock);
2164 memset(t,0,sizeof(*t));
2165 t->rxsubchans = V4L2_TUNER_SUB_MONO;
2166 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t);
2167 strcpy(t->name, "Television");
2168 t->capability = V4L2_TUNER_CAP_NORM;
2169 t->type = V4L2_TUNER_ANALOG_TV;
2170 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
2171 t->signal = 0xffff;
2172
2173 if (btv->audio_hook) {
2174 /* Hmmm ... */
2175 struct video_audio va;
2176 memset(&va, 0, sizeof(struct video_audio));
2177 btv->audio_hook(btv,&va,0);
2178 t->audmode = V4L2_TUNER_MODE_MONO;
2179 t->rxsubchans = V4L2_TUNER_SUB_MONO;
2180 if(va.mode & VIDEO_SOUND_STEREO) {
2181 t->audmode = V4L2_TUNER_MODE_STEREO;
2182 t->rxsubchans = V4L2_TUNER_SUB_STEREO;
2183 }
2184 if(va.mode & VIDEO_SOUND_LANG2) {
2185 t->audmode = V4L2_TUNER_MODE_LANG1;
2186 t->rxsubchans = V4L2_TUNER_SUB_LANG1
2187 | V4L2_TUNER_SUB_LANG2;
2188 }
2189 }
2190 /* FIXME: fill capability+audmode */
2191 mutex_unlock(&btv->lock);
2192 return 0;
2193 }
2194 case VIDIOC_S_TUNER: 2053 case VIDIOC_S_TUNER:
2195 { 2054 {
2196 struct v4l2_tuner *t = arg; 2055 struct v4l2_tuner *t = arg;
@@ -2251,6 +2110,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
2251 printk(KERN_INFO "bttv%d: ================== END STATUS CARD #%d ==================\n", btv->c.nr, btv->c.nr); 2110 printk(KERN_INFO "bttv%d: ================== END STATUS CARD #%d ==================\n", btv->c.nr, btv->c.nr);
2252 return 0; 2111 return 0;
2253 } 2112 }
2113 case VIDIOC_G_CTRL:
2114 return get_control(btv,arg);
2115 case VIDIOC_S_CTRL:
2116 return set_control(btv,arg);
2254#ifdef CONFIG_VIDEO_ADV_DEBUG 2117#ifdef CONFIG_VIDEO_ADV_DEBUG
2255 case VIDIOC_DBG_G_REGISTER: 2118 case VIDIOC_DBG_G_REGISTER:
2256 case VIDIOC_DBG_S_REGISTER: 2119 case VIDIOC_DBG_S_REGISTER:
@@ -2795,7 +2658,6 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2795{ 2658{
2796 struct bttv_fh *fh = file->private_data; 2659 struct bttv_fh *fh = file->private_data;
2797 struct bttv *btv = fh->btv; 2660 struct bttv *btv = fh->btv;
2798 unsigned long flags;
2799 int retval = 0; 2661 int retval = 0;
2800 2662
2801 if (bttv_debug > 1) 2663 if (bttv_debug > 1)
@@ -2805,9 +2667,6 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2805 bttv_reinit_bt848(btv); 2667 bttv_reinit_bt848(btv);
2806 2668
2807 switch (cmd) { 2669 switch (cmd) {
2808 case VIDIOCSFREQ:
2809 case VIDIOCSTUNER:
2810 case VIDIOCSCHAN:
2811 case VIDIOC_S_CTRL: 2670 case VIDIOC_S_CTRL:
2812 case VIDIOC_S_STD: 2671 case VIDIOC_S_STD:
2813 case VIDIOC_S_INPUT: 2672 case VIDIOC_S_INPUT:
@@ -2819,237 +2678,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2819 }; 2678 };
2820 2679
2821 switch (cmd) { 2680 switch (cmd) {
2822 2681#ifdef CONFIG_VIDEO_V4L1_COMPAT
2823 /* *** v4l1 *** ************************************************ */
2824 case VIDIOCGCAP:
2825 {
2826 struct video_capability *cap = arg;
2827
2828 memset(cap,0,sizeof(*cap));
2829 strcpy(cap->name,btv->video_dev->name);
2830 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
2831 /* vbi */
2832 cap->type = VID_TYPE_TUNER|VID_TYPE_TELETEXT;
2833 } else {
2834 /* others */
2835 cap->type = VID_TYPE_CAPTURE|
2836 VID_TYPE_TUNER|
2837 VID_TYPE_CLIPPING|
2838 VID_TYPE_SCALES;
2839 if (no_overlay <= 0)
2840 cap->type |= VID_TYPE_OVERLAY;
2841
2842 cap->maxwidth = bttv_tvnorms[btv->tvnorm].swidth;
2843 cap->maxheight = bttv_tvnorms[btv->tvnorm].sheight;
2844 cap->minwidth = 48;
2845 cap->minheight = 32;
2846 }
2847 cap->channels = bttv_tvcards[btv->c.type].video_inputs;
2848 cap->audios = bttv_tvcards[btv->c.type].audio_inputs;
2849 return 0;
2850 }
2851
2852 case VIDIOCGPICT:
2853 {
2854 struct video_picture *pic = arg;
2855
2856 memset(pic,0,sizeof(*pic));
2857 pic->brightness = btv->bright;
2858 pic->contrast = btv->contrast;
2859 pic->hue = btv->hue;
2860 pic->colour = btv->saturation;
2861 if (fh->fmt) {
2862 pic->depth = fh->fmt->depth;
2863 pic->palette = fh->fmt->palette;
2864 }
2865 return 0;
2866 }
2867 case VIDIOCSPICT:
2868 {
2869 struct video_picture *pic = arg;
2870 const struct bttv_format *fmt;
2871
2872 fmt = format_by_palette(pic->palette);
2873 if (NULL == fmt)
2874 return -EINVAL;
2875 mutex_lock(&fh->cap.lock);
2876 if (fmt->flags & FORMAT_FLAGS_RAW) {
2877 /* VIDIOCMCAPTURE uses gbufsize, not RAW_BPL *
2878 RAW_LINES * 2. F1 is stored at offset 0, F2
2879 at buffer size / 2. */
2880 fh->width = RAW_BPL;
2881 fh->height = gbufsize / RAW_BPL;
2882 btv->init.width = RAW_BPL;
2883 btv->init.height = gbufsize / RAW_BPL;
2884 }
2885 fh->ovfmt = fmt;
2886 fh->fmt = fmt;
2887 btv->init.ovfmt = fmt;
2888 btv->init.fmt = fmt;
2889 if (bigendian) {
2890 /* dirty hack time: swap bytes for overlay if the
2891 display adaptor is big endian (insmod option) */
2892 if (fmt->palette == VIDEO_PALETTE_RGB555 ||
2893 fmt->palette == VIDEO_PALETTE_RGB565 ||
2894 fmt->palette == VIDEO_PALETTE_RGB32) {
2895 fh->ovfmt = fmt+1;
2896 }
2897 }
2898 bt848_bright(btv,pic->brightness);
2899 bt848_contrast(btv,pic->contrast);
2900 bt848_hue(btv,pic->hue);
2901 bt848_sat(btv,pic->colour);
2902 mutex_unlock(&fh->cap.lock);
2903 return 0;
2904 }
2905
2906 case VIDIOCGWIN:
2907 {
2908 struct video_window *win = arg;
2909
2910 memset(win,0,sizeof(*win));
2911 win->x = fh->ov.w.left;
2912 win->y = fh->ov.w.top;
2913 win->width = fh->ov.w.width;
2914 win->height = fh->ov.w.height;
2915 return 0;
2916 }
2917 case VIDIOCSWIN:
2918 {
2919 struct video_window *win = arg;
2920 struct v4l2_window w2;
2921
2922 if (no_overlay > 0) {
2923 printk ("VIDIOCSWIN: no_overlay\n");
2924 return -EINVAL;
2925 }
2926
2927 w2.field = V4L2_FIELD_ANY;
2928 w2.w.left = win->x;
2929 w2.w.top = win->y;
2930 w2.w.width = win->width;
2931 w2.w.height = win->height;
2932 w2.clipcount = win->clipcount;
2933 w2.clips = (struct v4l2_clip __user *)win->clips;
2934 retval = setup_window(fh, btv, &w2, 0);
2935 if (0 == retval) {
2936 /* on v4l1 this ioctl affects the read() size too */
2937 fh->width = fh->ov.w.width;
2938 fh->height = fh->ov.w.height;
2939 btv->init.width = fh->ov.w.width;
2940 btv->init.height = fh->ov.w.height;
2941 }
2942 return retval;
2943 }
2944
2945 case VIDIOCGFBUF:
2946 {
2947 struct video_buffer *fbuf = arg;
2948
2949 fbuf->base = btv->fbuf.base;
2950 fbuf->width = btv->fbuf.fmt.width;
2951 fbuf->height = btv->fbuf.fmt.height;
2952 fbuf->bytesperline = btv->fbuf.fmt.bytesperline;
2953 if (fh->ovfmt)
2954 fbuf->depth = fh->ovfmt->depth;
2955 else {
2956 if (fbuf->width)
2957 fbuf->depth = ((fbuf->bytesperline<<3)
2958 + (fbuf->width-1) )
2959 /fbuf->width;
2960 else
2961 fbuf->depth = 0;
2962 }
2963 return 0;
2964 }
2965 case VIDIOCSFBUF:
2966 {
2967 struct video_buffer *fbuf = arg;
2968 const struct bttv_format *fmt;
2969 unsigned long end;
2970
2971 if(!capable(CAP_SYS_ADMIN) &&
2972 !capable(CAP_SYS_RAWIO))
2973 return -EPERM;
2974 end = (unsigned long)fbuf->base +
2975 fbuf->height * fbuf->bytesperline;
2976 mutex_lock(&fh->cap.lock);
2977 retval = -EINVAL;
2978
2979 switch (fbuf->depth) {
2980 case 8:
2981 fmt = format_by_palette(VIDEO_PALETTE_HI240);
2982 break;
2983 case 16:
2984 fmt = format_by_palette(VIDEO_PALETTE_RGB565);
2985 break;
2986 case 24:
2987 fmt = format_by_palette(VIDEO_PALETTE_RGB24);
2988 break;
2989 case 32:
2990 fmt = format_by_palette(VIDEO_PALETTE_RGB32);
2991 break;
2992 case 15:
2993 fbuf->depth = 16;
2994 fmt = format_by_palette(VIDEO_PALETTE_RGB555);
2995 break;
2996 default:
2997 fmt = NULL;
2998 break;
2999 }
3000 if (NULL == fmt)
3001 goto fh_unlock_and_return;
3002
3003 fh->ovfmt = fmt;
3004 fh->fmt = fmt;
3005 btv->init.ovfmt = fmt;
3006 btv->init.fmt = fmt;
3007 btv->fbuf.base = fbuf->base;
3008 btv->fbuf.fmt.width = fbuf->width;
3009 btv->fbuf.fmt.height = fbuf->height;
3010 if (fbuf->bytesperline)
3011 btv->fbuf.fmt.bytesperline = fbuf->bytesperline;
3012 else
3013 btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fbuf->depth/8;
3014 mutex_unlock(&fh->cap.lock);
3015 return 0;
3016 }
3017
3018 case VIDIOCCAPTURE:
3019 case VIDIOC_OVERLAY:
3020 {
3021 struct bttv_buffer *new;
3022 int *on = arg;
3023
3024 if (*on) {
3025 /* verify args */
3026 if (NULL == btv->fbuf.base)
3027 return -EINVAL;
3028 if (!fh->ov.setup_ok) {
3029 dprintk("bttv%d: overlay: !setup_ok\n",btv->c.nr);
3030 return -EINVAL;
3031 }
3032 }
3033
3034 if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY))
3035 return -EBUSY;
3036
3037 mutex_lock(&fh->cap.lock);
3038 if (*on) {
3039 fh->ov.tvnorm = btv->tvnorm;
3040 new = videobuf_pci_alloc(sizeof(*new));
3041 new->crop = btv->crop[!!fh->do_crop].rect;
3042 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
3043 } else {
3044 new = NULL;
3045 }
3046
3047 /* switch over */
3048 retval = bttv_switch_overlay(btv,fh,new);
3049 mutex_unlock(&fh->cap.lock);
3050 return retval;
3051 }
3052
3053 case VIDIOCGMBUF: 2682 case VIDIOCGMBUF:
3054 { 2683 {
3055 struct video_mbuf *mbuf = arg; 2684 struct video_mbuf *mbuf = arg;
@@ -3068,98 +2697,19 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3068 mbuf->offsets[i] = i * gbufsize; 2697 mbuf->offsets[i] = i * gbufsize;
3069 return 0; 2698 return 0;
3070 } 2699 }
3071 case VIDIOCMCAPTURE: 2700#endif
3072 {
3073 struct video_mmap *vm = arg;
3074 struct bttv_buffer *buf;
3075 enum v4l2_field field;
3076 __s32 height2;
3077 int res;
3078
3079 if (vm->frame >= VIDEO_MAX_FRAME)
3080 return -EINVAL;
3081
3082 res = bttv_resource(fh);
3083 if (!check_alloc_btres(btv, fh, res))
3084 return -EBUSY;
3085
3086 mutex_lock(&fh->cap.lock);
3087 retval = -EINVAL;
3088 buf = (struct bttv_buffer *)fh->cap.bufs[vm->frame];
3089 if (NULL == buf)
3090 goto fh_unlock_and_return;
3091 if (0 == buf->vb.baddr)
3092 goto fh_unlock_and_return;
3093 if (buf->vb.state == STATE_QUEUED ||
3094 buf->vb.state == STATE_ACTIVE)
3095 goto fh_unlock_and_return;
3096
3097 height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
3098 field = (vm->height > height2)
3099 ? V4L2_FIELD_INTERLACED
3100 : V4L2_FIELD_BOTTOM;
3101 retval = bttv_prepare_buffer(&fh->cap,btv,buf,
3102 format_by_palette(vm->format),
3103 vm->width,vm->height,field);
3104 if (0 != retval)
3105 goto fh_unlock_and_return;
3106 btv->init.width = vm->width;
3107 btv->init.height = vm->height;
3108 spin_lock_irqsave(&btv->s_lock,flags);
3109 buffer_queue(&fh->cap,&buf->vb);
3110 spin_unlock_irqrestore(&btv->s_lock,flags);
3111 mutex_unlock(&fh->cap.lock);
3112 return 0;
3113 }
3114 case VIDIOCSYNC:
3115 {
3116 int *frame = arg;
3117 struct bttv_buffer *buf;
3118
3119 if (*frame >= VIDEO_MAX_FRAME)
3120 return -EINVAL;
3121
3122 mutex_lock(&fh->cap.lock);
3123 retval = -EINVAL;
3124 buf = (struct bttv_buffer *)fh->cap.bufs[*frame];
3125 if (NULL == buf)
3126 goto fh_unlock_and_return;
3127 retval = videobuf_waiton(&buf->vb,0,1);
3128 if (0 != retval)
3129 goto fh_unlock_and_return;
3130 switch (buf->vb.state) {
3131 case STATE_ERROR:
3132 retval = -EIO;
3133 /* fall through */
3134 case STATE_DONE:
3135 {
3136 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
3137 videobuf_dma_sync(&fh->cap,dma);
3138 bttv_dma_free(&fh->cap,btv,buf);
3139 break;
3140 }
3141 default:
3142 retval = -EINVAL;
3143 break;
3144 }
3145 mutex_unlock(&fh->cap.lock);
3146 return retval;
3147 }
3148
3149 case VIDIOCGVBIFMT: 2701 case VIDIOCGVBIFMT:
3150 if (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE) {
3151 retval = bttv_switch_type(fh,V4L2_BUF_TYPE_VBI_CAPTURE);
3152 if (0 != retval)
3153 return retval;
3154 }
3155
3156 /* fall through */
3157
3158 case VIDIOCSVBIFMT: 2702 case VIDIOCSVBIFMT:
3159 return v4l_compat_translate_ioctl(inode, file, cmd, 2703 case VIDIOCSYNC:
3160 arg, bttv_do_ioctl); 2704 case VIDIOCMCAPTURE:
3161 2705 case VIDIOCCAPTURE:
3162 case BTTV_VERSION: 2706 case VIDIOCGFBUF:
2707 case VIDIOCSFBUF:
2708 case VIDIOCGWIN:
2709 case VIDIOCSWIN:
2710 case VIDIOCGCAP:
2711 case VIDIOCGPICT:
2712 case VIDIOCSPICT:
3163 case VIDIOCGFREQ: 2713 case VIDIOCGFREQ:
3164 case VIDIOCSFREQ: 2714 case VIDIOCSFREQ:
3165 case VIDIOCGTUNER: 2715 case VIDIOCGTUNER:
@@ -3168,7 +2718,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3168 case VIDIOCSCHAN: 2718 case VIDIOCSCHAN:
3169 case VIDIOCGAUDIO: 2719 case VIDIOCGAUDIO:
3170 case VIDIOCSAUDIO: 2720 case VIDIOCSAUDIO:
3171 return bttv_common_ioctls(btv,cmd,arg); 2721 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
2722 bttv_do_ioctl);
3172 2723
3173 /* *** v4l2 *** ************************************************ */ 2724 /* *** v4l2 *** ************************************************ */
3174 case VIDIOC_QUERYCAP: 2725 case VIDIOC_QUERYCAP:
@@ -3196,7 +2747,6 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3196 cap->capabilities |= V4L2_CAP_TUNER; 2747 cap->capabilities |= V4L2_CAP_TUNER;
3197 return 0; 2748 return 0;
3198 } 2749 }
3199
3200 case VIDIOC_ENUM_FMT: 2750 case VIDIOC_ENUM_FMT:
3201 { 2751 {
3202 struct v4l2_fmtdesc *f = arg; 2752 struct v4l2_fmtdesc *f = arg;
@@ -3246,7 +2796,6 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3246 strlcpy(f->description,bttv_formats[i].name,sizeof(f->description)); 2796 strlcpy(f->description,bttv_formats[i].name,sizeof(f->description));
3247 return 0; 2797 return 0;
3248 } 2798 }
3249
3250 case VIDIOC_TRY_FMT: 2799 case VIDIOC_TRY_FMT:
3251 { 2800 {
3252 struct v4l2_format *f = arg; 2801 struct v4l2_format *f = arg;
@@ -3273,6 +2822,38 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3273 fb->fmt.pixelformat = fh->ovfmt->fourcc; 2822 fb->fmt.pixelformat = fh->ovfmt->fourcc;
3274 return 0; 2823 return 0;
3275 } 2824 }
2825 case VIDIOC_OVERLAY:
2826 {
2827 struct bttv_buffer *new;
2828 int *on = arg;
2829
2830 if (*on) {
2831 /* verify args */
2832 if (NULL == btv->fbuf.base)
2833 return -EINVAL;
2834 if (!fh->ov.setup_ok) {
2835 dprintk("bttv%d: overlay: !setup_ok\n",btv->c.nr);
2836 return -EINVAL;
2837 }
2838 }
2839
2840 if (!check_alloc_btres(btv,fh,RESOURCE_OVERLAY))
2841 return -EBUSY;
2842
2843 mutex_lock(&fh->cap.lock);
2844 if (*on) {
2845 fh->ov.tvnorm = btv->tvnorm;
2846 new = videobuf_pci_alloc(sizeof(*new));
2847 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2848 } else {
2849 new = NULL;
2850 }
2851
2852 /* switch over */
2853 retval = bttv_switch_overlay(btv,fh,new);
2854 mutex_unlock(&fh->cap.lock);
2855 return retval;
2856 }
3276 case VIDIOC_S_FBUF: 2857 case VIDIOC_S_FBUF:
3277 { 2858 {
3278 struct v4l2_framebuffer *fb = arg; 2859 struct v4l2_framebuffer *fb = arg;
@@ -3340,13 +2921,10 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3340 mutex_unlock(&fh->cap.lock); 2921 mutex_unlock(&fh->cap.lock);
3341 return retval; 2922 return retval;
3342 } 2923 }
3343
3344 case VIDIOC_REQBUFS: 2924 case VIDIOC_REQBUFS:
3345 return videobuf_reqbufs(bttv_queue(fh),arg); 2925 return videobuf_reqbufs(bttv_queue(fh),arg);
3346
3347 case VIDIOC_QUERYBUF: 2926 case VIDIOC_QUERYBUF:
3348 return videobuf_querybuf(bttv_queue(fh),arg); 2927 return videobuf_querybuf(bttv_queue(fh),arg);
3349
3350 case VIDIOC_QBUF: 2928 case VIDIOC_QBUF:
3351 { 2929 {
3352 int res = bttv_resource(fh); 2930 int res = bttv_resource(fh);
@@ -3355,11 +2933,9 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3355 return -EBUSY; 2933 return -EBUSY;
3356 return videobuf_qbuf(bttv_queue(fh),arg); 2934 return videobuf_qbuf(bttv_queue(fh),arg);
3357 } 2935 }
3358
3359 case VIDIOC_DQBUF: 2936 case VIDIOC_DQBUF:
3360 return videobuf_dqbuf(bttv_queue(fh),arg, 2937 return videobuf_dqbuf(bttv_queue(fh),arg,
3361 file->f_flags & O_NONBLOCK); 2938 file->f_flags & O_NONBLOCK);
3362
3363 case VIDIOC_STREAMON: 2939 case VIDIOC_STREAMON:
3364 { 2940 {
3365 int res = bttv_resource(fh); 2941 int res = bttv_resource(fh);
@@ -3422,10 +2998,6 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3422 } 2998 }
3423 return 0; 2999 return 0;
3424 } 3000 }
3425 case VIDIOC_G_CTRL:
3426 return get_control(btv,arg);
3427 case VIDIOC_S_CTRL:
3428 return set_control(btv,arg);
3429 case VIDIOC_G_PARM: 3001 case VIDIOC_G_PARM:
3430 { 3002 {
3431 struct v4l2_streamparm *parm = arg; 3003 struct v4l2_streamparm *parm = arg;
@@ -3438,6 +3010,45 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3438 parm->parm.capture.timeperframe = s.frameperiod; 3010 parm->parm.capture.timeperframe = s.frameperiod;
3439 return 0; 3011 return 0;
3440 } 3012 }
3013 case VIDIOC_G_TUNER:
3014 {
3015 struct v4l2_tuner *t = arg;
3016
3017 if (UNSET == bttv_tvcards[btv->c.type].tuner)
3018 return -EINVAL;
3019 if (0 != t->index)
3020 return -EINVAL;
3021 mutex_lock(&btv->lock);
3022 memset(t,0,sizeof(*t));
3023 t->rxsubchans = V4L2_TUNER_SUB_MONO;
3024 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t);
3025 strcpy(t->name, "Television");
3026 t->capability = V4L2_TUNER_CAP_NORM;
3027 t->type = V4L2_TUNER_ANALOG_TV;
3028 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
3029 t->signal = 0xffff;
3030
3031 if (btv->audio_hook) {
3032 /* Hmmm ... */
3033 struct video_audio va;
3034 memset(&va, 0, sizeof(struct video_audio));
3035 btv->audio_hook(btv,&va,0);
3036 t->audmode = V4L2_TUNER_MODE_MONO;
3037 t->rxsubchans = V4L2_TUNER_SUB_MONO;
3038 if(va.mode & VIDEO_SOUND_STEREO) {
3039 t->audmode = V4L2_TUNER_MODE_STEREO;
3040 t->rxsubchans = V4L2_TUNER_SUB_STEREO;
3041 }
3042 if(va.mode & VIDEO_SOUND_LANG2) {
3043 t->audmode = V4L2_TUNER_MODE_LANG1;
3044 t->rxsubchans = V4L2_TUNER_SUB_LANG1
3045 | V4L2_TUNER_SUB_LANG2;
3046 }
3047 }
3048 /* FIXME: fill capability+audmode */
3049 mutex_unlock(&btv->lock);
3050 return 0;
3051 }
3441 3052
3442 case VIDIOC_G_PRIORITY: 3053 case VIDIOC_G_PRIORITY:
3443 { 3054 {
@@ -3575,15 +3186,15 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3575 case VIDIOC_ENUMINPUT: 3186 case VIDIOC_ENUMINPUT:
3576 case VIDIOC_G_INPUT: 3187 case VIDIOC_G_INPUT:
3577 case VIDIOC_S_INPUT: 3188 case VIDIOC_S_INPUT:
3578 case VIDIOC_G_TUNER:
3579 case VIDIOC_S_TUNER: 3189 case VIDIOC_S_TUNER:
3580 case VIDIOC_G_FREQUENCY: 3190 case VIDIOC_G_FREQUENCY:
3581 case VIDIOC_S_FREQUENCY: 3191 case VIDIOC_S_FREQUENCY:
3582 case VIDIOC_LOG_STATUS: 3192 case VIDIOC_LOG_STATUS:
3193 case VIDIOC_G_CTRL:
3194 case VIDIOC_S_CTRL:
3583 case VIDIOC_DBG_G_REGISTER: 3195 case VIDIOC_DBG_G_REGISTER:
3584 case VIDIOC_DBG_S_REGISTER: 3196 case VIDIOC_DBG_S_REGISTER:
3585 return bttv_common_ioctls(btv,cmd,arg); 3197 return bttv_common_ioctls(btv,cmd,arg);
3586
3587 default: 3198 default:
3588 return -ENOIOCTLCMD; 3199 return -ENOIOCTLCMD;
3589 } 3200 }
@@ -3601,33 +3212,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3601static int bttv_ioctl(struct inode *inode, struct file *file, 3212static int bttv_ioctl(struct inode *inode, struct file *file,
3602 unsigned int cmd, unsigned long arg) 3213 unsigned int cmd, unsigned long arg)
3603{ 3214{
3604 struct bttv_fh *fh = file->private_data; 3215 return video_usercopy(inode, file, cmd, arg, bttv_do_ioctl);
3605
3606 switch (cmd) {
3607 case BTTV_VBISIZE:
3608 {
3609 const struct bttv_tvnorm *tvnorm;
3610
3611 tvnorm = fh->vbi_fmt.tvnorm;
3612
3613 if (fh->vbi_fmt.fmt.start[0] != tvnorm->vbistart[0] ||
3614 fh->vbi_fmt.fmt.start[1] != tvnorm->vbistart[1] ||
3615 fh->vbi_fmt.fmt.count[0] != fh->vbi_fmt.fmt.count[1]) {
3616 /* BTTV_VBISIZE cannot express these parameters,
3617 however open() resets the paramters to defaults
3618 and apps shouldn't call BTTV_VBISIZE after
3619 VIDIOC_S_FMT. */
3620 return -EINVAL;
3621 }
3622
3623 bttv_switch_type(fh,V4L2_BUF_TYPE_VBI_CAPTURE);
3624 return (fh->vbi_fmt.fmt.count[0] * 2
3625 * fh->vbi_fmt.fmt.samples_per_line);
3626 }
3627
3628 default:
3629 return video_usercopy(inode, file, cmd, arg, bttv_do_ioctl);
3630 }
3631} 3216}
3632 3217
3633static ssize_t bttv_read(struct file *file, char __user *data, 3218static ssize_t bttv_read(struct file *file, char __user *data,
@@ -3926,43 +3511,55 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
3926 struct bttv *btv = file->private_data; 3511 struct bttv *btv = file->private_data;
3927 3512
3928 switch (cmd) { 3513 switch (cmd) {
3929 case VIDIOCGCAP: 3514 case VIDIOC_QUERYCAP:
3930 { 3515 {
3931 struct video_capability *cap = arg; 3516 struct v4l2_capability *cap = arg;
3932 3517
3933 memset(cap,0,sizeof(*cap)); 3518 memset(cap,0,sizeof(*cap));
3934 strcpy(cap->name,btv->radio_dev->name); 3519 strcpy(cap->driver, "bttv");
3935 cap->type = VID_TYPE_TUNER; 3520 strlcpy(cap->card, btv->radio_dev->name,sizeof(cap->card));
3936 cap->channels = 1; 3521 sprintf(cap->bus_info,"PCI:%s",pci_name(btv->c.pci));
3937 cap->audios = 1; 3522 cap->version = BTTV_VERSION_CODE;
3523 cap->capabilities = V4L2_CAP_TUNER;
3938 return 0; 3524 return 0;
3939 } 3525 }
3940 3526 case VIDIOC_G_TUNER:
3941 case VIDIOCGTUNER:
3942 { 3527 {
3943 struct video_tuner *v = arg; 3528 struct v4l2_tuner *t = arg;
3944 3529
3945 if(v->tuner) 3530 if (UNSET == bttv_tvcards[btv->c.type].tuner)
3946 return -EINVAL; 3531 return -EINVAL;
3947 memset(v,0,sizeof(*v)); 3532 if (0 != t->index)
3948 strcpy(v->name, "Radio"); 3533 return -EINVAL;
3949 bttv_call_i2c_clients(btv,cmd,v); 3534 mutex_lock(&btv->lock);
3535 memset(t,0,sizeof(*t));
3536 strcpy(t->name, "Radio");
3537 t->type = V4L2_TUNER_RADIO;
3538
3539 bttv_call_i2c_clients(btv, VIDIOC_G_TUNER, t);
3540
3541 mutex_unlock(&btv->lock);
3542
3950 return 0; 3543 return 0;
3951 } 3544 }
3952 case VIDIOCSTUNER: 3545 case VIDIOC_S_TUNER:
3953 /* nothing to do */ 3546 case VIDIOC_G_FREQUENCY:
3954 return 0; 3547 case VIDIOC_S_FREQUENCY:
3955 3548 case VIDIOC_G_CTRL:
3956 case BTTV_VERSION: 3549 case VIDIOC_S_CTRL:
3957 case VIDIOCGFREQ:
3958 case VIDIOCSFREQ:
3959 case VIDIOCGAUDIO:
3960 case VIDIOCSAUDIO:
3961 case VIDIOC_LOG_STATUS: 3550 case VIDIOC_LOG_STATUS:
3962 case VIDIOC_DBG_G_REGISTER: 3551 case VIDIOC_DBG_G_REGISTER:
3963 case VIDIOC_DBG_S_REGISTER: 3552 case VIDIOC_DBG_S_REGISTER:
3964 return bttv_common_ioctls(btv,cmd,arg); 3553 return bttv_common_ioctls(btv,cmd,arg);
3965 3554 case VIDIOCGCAP:
3555 case VIDIOCGFREQ:
3556 case VIDIOCSFREQ:
3557 case VIDIOCGTUNER:
3558 case VIDIOCSTUNER:
3559 case VIDIOCGAUDIO:
3560 case VIDIOCSAUDIO:
3561 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
3562 radio_do_ioctl);
3966 default: 3563 default:
3967 return -ENOIOCTLCMD; 3564 return -ENOIOCTLCMD;
3968 } 3565 }
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index d4ac4c4b49b4..e60e54ad173a 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -458,10 +458,6 @@ struct bttv {
458extern unsigned int bttv_num; 458extern unsigned int bttv_num;
459extern struct bttv bttvs[BTTV_MAX]; 459extern struct bttv bttvs[BTTV_MAX];
460 460
461/* private ioctls */
462#define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
463#define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
464
465#endif 461#endif
466 462
467#define btwrite(dat,adr) writel((dat), btv->bt848_mmio+(adr)) 463#define btwrite(dat,adr) writel((dat), btv->bt848_mmio+(adr))