V4L1 removal from:
(c) 2005-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+ Fixes to be fully V4L2 compliant by
+ (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+
Cropping and overscan support
Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at>
Sponsored by OPQ Systems AB
static ssize_t show_card(struct device *cd,
struct device_attribute *attr, char *buf)
{
- struct video_device *vfd = to_video_device(cd);
+ struct video_device *vfd = container_of(cd, struct video_device, class_dev);
struct bttv *btv = dev_get_drvdata(vfd->dev);
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
}
static const struct bttv_format bttv_formats[] = {
{
.name = "8 bpp, gray",
- .palette = VIDEO_PALETTE_GREY,
.fourcc = V4L2_PIX_FMT_GREY,
.btformat = BT848_COLOR_FMT_Y8,
.depth = 8,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "8 bpp, dithered color",
- .palette = VIDEO_PALETTE_HI240,
.fourcc = V4L2_PIX_FMT_HI240,
.btformat = BT848_COLOR_FMT_RGB8,
.depth = 8,
.flags = FORMAT_FLAGS_PACKED | FORMAT_FLAGS_DITHER,
},{
.name = "15 bpp RGB, le",
- .palette = VIDEO_PALETTE_RGB555,
.fourcc = V4L2_PIX_FMT_RGB555,
.btformat = BT848_COLOR_FMT_RGB15,
.depth = 16,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "15 bpp RGB, be",
- .palette = -1,
.fourcc = V4L2_PIX_FMT_RGB555X,
.btformat = BT848_COLOR_FMT_RGB15,
.btswap = 0x03, /* byteswap */
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "16 bpp RGB, le",
- .palette = VIDEO_PALETTE_RGB565,
.fourcc = V4L2_PIX_FMT_RGB565,
.btformat = BT848_COLOR_FMT_RGB16,
.depth = 16,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "16 bpp RGB, be",
- .palette = -1,
.fourcc = V4L2_PIX_FMT_RGB565X,
.btformat = BT848_COLOR_FMT_RGB16,
.btswap = 0x03, /* byteswap */
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "24 bpp RGB, le",
- .palette = VIDEO_PALETTE_RGB24,
.fourcc = V4L2_PIX_FMT_BGR24,
.btformat = BT848_COLOR_FMT_RGB24,
.depth = 24,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "32 bpp RGB, le",
- .palette = VIDEO_PALETTE_RGB32,
.fourcc = V4L2_PIX_FMT_BGR32,
.btformat = BT848_COLOR_FMT_RGB32,
.depth = 32,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "32 bpp RGB, be",
- .palette = -1,
.fourcc = V4L2_PIX_FMT_RGB32,
.btformat = BT848_COLOR_FMT_RGB32,
.btswap = 0x0f, /* byte+word swap */
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "4:2:2, packed, YUYV",
- .palette = VIDEO_PALETTE_YUV422,
.fourcc = V4L2_PIX_FMT_YUYV,
.btformat = BT848_COLOR_FMT_YUY2,
.depth = 16,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "4:2:2, packed, YUYV",
- .palette = VIDEO_PALETTE_YUYV,
.fourcc = V4L2_PIX_FMT_YUYV,
.btformat = BT848_COLOR_FMT_YUY2,
.depth = 16,
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "4:2:2, packed, UYVY",
- .palette = VIDEO_PALETTE_UYVY,
.fourcc = V4L2_PIX_FMT_UYVY,
.btformat = BT848_COLOR_FMT_YUY2,
.btswap = 0x03, /* byteswap */
.flags = FORMAT_FLAGS_PACKED,
},{
.name = "4:2:2, planar, Y-Cb-Cr",
- .palette = VIDEO_PALETTE_YUV422P,
.fourcc = V4L2_PIX_FMT_YUV422P,
.btformat = BT848_COLOR_FMT_YCrCb422,
.depth = 16,
.vshift = 0,
},{
.name = "4:2:0, planar, Y-Cb-Cr",
- .palette = VIDEO_PALETTE_YUV420P,
.fourcc = V4L2_PIX_FMT_YUV420,
.btformat = BT848_COLOR_FMT_YCrCb422,
.depth = 12,
.vshift = 1,
},{
.name = "4:2:0, planar, Y-Cr-Cb",
- .palette = -1,
.fourcc = V4L2_PIX_FMT_YVU420,
.btformat = BT848_COLOR_FMT_YCrCb422,
.depth = 12,
.vshift = 1,
},{
.name = "4:1:1, planar, Y-Cb-Cr",
- .palette = VIDEO_PALETTE_YUV411P,
.fourcc = V4L2_PIX_FMT_YUV411P,
.btformat = BT848_COLOR_FMT_YCrCb411,
.depth = 12,
.vshift = 0,
},{
.name = "4:1:0, planar, Y-Cb-Cr",
- .palette = VIDEO_PALETTE_YUV410P,
.fourcc = V4L2_PIX_FMT_YUV410,
.btformat = BT848_COLOR_FMT_YCrCb411,
.depth = 9,
.vshift = 2,
},{
.name = "4:1:0, planar, Y-Cr-Cb",
- .palette = -1,
.fourcc = V4L2_PIX_FMT_YVU410,
.btformat = BT848_COLOR_FMT_YCrCb411,
.depth = 9,
.vshift = 2,
},{
.name = "raw scanlines",
- .palette = VIDEO_PALETTE_RAW,
.fourcc = -1,
.btformat = BT848_COLOR_FMT_RAW,
.depth = 8,
static int get_control(struct bttv *btv, struct v4l2_control *c)
{
- struct video_audio va;
int i;
for (i = 0; i < BTTV_CTLS; i++)
break;
if (i == BTTV_CTLS)
return -EINVAL;
+#ifdef CONFIG_VIDEO_V4L1
if (btv->audio_hook && i >= 4 && i <= 8) {
+ struct video_audio va;
+
memset(&va,0,sizeof(va));
btv->audio_hook(btv,&va,0);
switch (c->id) {
}
return 0;
}
+#endif
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
c->value = btv->bright;
static int set_control(struct bttv *btv, struct v4l2_control *c)
{
- struct video_audio va;
int i,val;
for (i = 0; i < BTTV_CTLS; i++)
break;
if (i == BTTV_CTLS)
return -EINVAL;
+#ifdef CONFIG_VIDEO_V4L1
if (btv->audio_hook && i >= 4 && i <= 8) {
+ struct video_audio va;
+
memset(&va,0,sizeof(va));
btv->audio_hook(btv,&va,0);
switch (c->id) {
btv->audio_hook(btv,&va,1);
return 0;
}
+#endif
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
bt848_bright(btv,c->value);
}
}
-static const struct bttv_format*
-format_by_palette(int palette)
-{
- unsigned int i;
-
- for (i = 0; i < BTTV_FORMATS; i++) {
- if (-1 == bttv_formats[i].palette)
- continue;
- if (bttv_formats[i].palette == palette)
- return bttv_formats+i;
- }
- return NULL;
-}
-
static const struct bttv_format*
format_by_fourcc(int fourcc)
{
static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
{
switch (cmd) {
+#ifdef CONFIG_VIDEO_V4L1
case VIDIOCGAUDIO:
{
struct video_audio *v = arg;
mutex_unlock(&btv->lock);
return 0;
}
-
+#endif
/* *** v4l2 *** ************************************************ */
case VIDIOC_ENUMSTD:
{
return -EINVAL;
mutex_lock(&btv->lock);
bttv_call_i2c_clients(btv, VIDIOC_S_TUNER, t);
+#ifdef CONFIG_VIDEO_V4L1
if (btv->audio_hook) {
struct video_audio va;
memset(&va, 0, sizeof(struct video_audio));
va.mode = VIDEO_SOUND_LANG2;
btv->audio_hook(btv,&va,1);
}
+#endif
mutex_unlock(&btv->lock);
return 0;
}
return 0;
}
#endif
- case VIDIOCGVBIFMT:
- case VIDIOCSVBIFMT:
- case VIDIOCSYNC:
- case VIDIOCMCAPTURE:
- case VIDIOCCAPTURE:
- case VIDIOCGFBUF:
- case VIDIOCSFBUF:
- case VIDIOCGWIN:
- case VIDIOCSWIN:
- case VIDIOCGCAP:
- case VIDIOCGPICT:
- case VIDIOCSPICT:
- case VIDIOCGFREQ:
- case VIDIOCSFREQ:
- case VIDIOCGTUNER:
- case VIDIOCSTUNER:
- case VIDIOCGCHAN:
- case VIDIOCSCHAN:
- case VIDIOCGAUDIO:
- case VIDIOCSAUDIO:
- return v4l_compat_translate_ioctl(inode,file,cmd,arg,
- bttv_do_ioctl);
/* *** v4l2 *** ************************************************ */
case VIDIOC_QUERYCAP:
return 0;
}
*c = bttv_ctls[i];
+#ifdef CONFIG_VIDEO_V4L1
if (btv->audio_hook && i >= 4 && i <= 8) {
struct video_audio va;
memset(&va,0,sizeof(va));
break;
}
}
+#endif
return 0;
}
case VIDIOC_G_PARM:
t->type = V4L2_TUNER_ANALOG_TV;
if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
t->signal = 0xffff;
-
+#ifdef CONFIG_VIDEO_V4L1
if (btv->audio_hook) {
/* Hmmm ... */
struct video_audio va;
| V4L2_TUNER_SUB_LANG2;
}
}
+#endif
/* FIXME: fill capability+audmode */
mutex_unlock(&btv->lock);
return 0;
case VIDIOC_DBG_S_REGISTER:
return bttv_common_ioctls(btv,cmd,arg);
default:
- return -ENOIOCTLCMD;
+ return v4l_compat_translate_ioctl(inode,file,cmd,arg,
+ bttv_do_ioctl);
}
return 0;
case VIDIOC_DBG_G_REGISTER:
case VIDIOC_DBG_S_REGISTER:
return bttv_common_ioctls(btv,cmd,arg);
- case VIDIOCGCAP:
- case VIDIOCGFREQ:
- case VIDIOCSFREQ:
- case VIDIOCGTUNER:
- case VIDIOCSTUNER:
- case VIDIOCGAUDIO:
- case VIDIOCSAUDIO:
+ default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
radio_do_ioctl);
- default:
- return -ENOIOCTLCMD;
}
return 0;
}
btv->init.btv = btv;
btv->init.ov.w.width = 320;
btv->init.ov.w.height = 240;
- btv->init.fmt = format_by_palette(VIDEO_PALETTE_RGB24);
+ btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
btv->init.width = 320;
btv->init.height = 240;
btv->input = 0;