Commit b524f7b0 authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Mauro Carvalho Chehab

V4L/DVB (7364): reduce stack usage of v4l_compat_translate_ioctl

v4l_compat_translate_ioctl used 1376 bytes of stack (x86_64),
so split this 800 lines long function into ~20 small noinline functions;
the biggest function takes now 712 bytes (v4l1_compat_sync)

fix VIDIOCSWIN handler which printked wrong errors
Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 8b3b90ac
...@@ -203,7 +203,7 @@ static int poll_one(struct file *file) ...@@ -203,7 +203,7 @@ static int poll_one(struct file *file)
{ {
int retval = 1; int retval = 1;
poll_table *table; poll_table *table;
struct poll_wqueues pwq; struct poll_wqueues pwq; /*TODO: allocate dynamically*/
poll_initwait(&pwq); poll_initwait(&pwq);
table = &pwq.pt; table = &pwq.pt;
...@@ -225,7 +225,8 @@ static int poll_one(struct file *file) ...@@ -225,7 +225,8 @@ static int poll_one(struct file *file)
return retval; return retval;
} }
static int count_inputs(struct inode *inode, static int count_inputs(
struct inode *inode,
struct file *file, struct file *file,
v4l2_kioctl drv) v4l2_kioctl drv)
{ {
...@@ -241,10 +242,12 @@ static int count_inputs(struct inode *inode, ...@@ -241,10 +242,12 @@ static int count_inputs(struct inode *inode,
return i; return i;
} }
static int check_size(struct inode *inode, static int check_size(
struct inode *inode,
struct file *file, struct file *file,
v4l2_kioctl drv, v4l2_kioctl drv,
int *maxw, int *maxh) int *maxw,
int *maxh)
{ {
struct v4l2_fmtdesc desc2; struct v4l2_fmtdesc desc2;
struct v4l2_format fmt2; struct v4l2_format fmt2;
...@@ -266,60 +269,40 @@ static int check_size(struct inode *inode, ...@@ -266,60 +269,40 @@ static int check_size(struct inode *inode,
*maxw = fmt2.fmt.pix.width; *maxw = fmt2.fmt.pix.width;
*maxh = fmt2.fmt.pix.height; *maxh = fmt2.fmt.pix.height;
done: done:
return 0; return 0;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* static noinline int v4l1_compat_get_capabilities(
* This function is exported. struct video_capability *cap,
*/ struct inode *inode,
int
v4l_compat_translate_ioctl(struct inode *inode,
struct file *file, struct file *file,
int cmd,
void *arg,
v4l2_kioctl drv) v4l2_kioctl drv)
{ {
struct v4l2_capability *cap2 = NULL; int err;
struct v4l2_format *fmt2 = NULL; struct v4l2_framebuffer fbuf;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; struct v4l2_capability *cap2;
struct v4l2_framebuffer fbuf2;
struct v4l2_input input2;
struct v4l2_tuner tun2;
struct v4l2_standard std2;
struct v4l2_frequency freq2;
struct v4l2_audio aud2;
struct v4l2_queryctrl qctrl2;
struct v4l2_buffer buf2;
v4l2_std_id sid;
int i, err = 0;
switch (cmd) {
case VIDIOCGCAP: /* capability */
{
struct video_capability *cap = arg;
cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL); cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL);
if (!cap2) { if (!cap2) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
memset(cap, 0, sizeof(*cap)); memset(cap, 0, sizeof(*cap));
memset(&fbuf2, 0, sizeof(fbuf2)); memset(&fbuf, 0, sizeof(fbuf));
err = drv(inode, file, VIDIOC_QUERYCAP, cap2); err = drv(inode, file, VIDIOC_QUERYCAP, cap2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err); dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err);
break; goto done;
} }
if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) {
err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); err = drv(inode, file, VIDIOC_G_FBUF, &fbuf);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err); dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err);
memset(&fbuf2, 0, sizeof(fbuf2)); memset(&fbuf, 0, sizeof(fbuf));
} }
err = 0; err = 0;
} }
...@@ -335,7 +318,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -335,7 +318,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
cap->type |= VID_TYPE_TELETEXT; cap->type |= VID_TYPE_TELETEXT;
if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY)
cap->type |= VID_TYPE_OVERLAY; cap->type |= VID_TYPE_OVERLAY;
if (fbuf2.capability & V4L2_FBUF_CAP_LIST_CLIPPING) if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING)
cap->type |= VID_TYPE_CLIPPING; cap->type |= VID_TYPE_CLIPPING;
cap->channels = count_inputs(inode, file, drv); cap->channels = count_inputs(inode, file, drv);
...@@ -344,25 +327,34 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -344,25 +327,34 @@ v4l_compat_translate_ioctl(struct inode *inode,
cap->audios = 0; /* FIXME */ cap->audios = 0; /* FIXME */
cap->minwidth = 48; /* FIXME */ cap->minwidth = 48; /* FIXME */
cap->minheight = 32; /* FIXME */ cap->minheight = 32; /* FIXME */
break;
} done:
case VIDIOCGFBUF: /* get frame buffer */ kfree(cap2);
{ return err;
struct video_buffer *buffer = arg; }
static noinline int v4l1_compat_get_frame_buffer(
struct video_buffer *buffer,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_framebuffer fbuf;
memset(buffer, 0, sizeof(*buffer)); memset(buffer, 0, sizeof(*buffer));
memset(&fbuf2, 0, sizeof(fbuf2)); memset(&fbuf, 0, sizeof(fbuf));
err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); err = drv(inode, file, VIDIOC_G_FBUF, &fbuf);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err);
break; goto done;
} }
buffer->base = fbuf2.base; buffer->base = fbuf.base;
buffer->height = fbuf2.fmt.height; buffer->height = fbuf.fmt.height;
buffer->width = fbuf2.fmt.width; buffer->width = fbuf.fmt.width;
switch (fbuf2.fmt.pixelformat) { switch (fbuf.fmt.pixelformat) {
case V4L2_PIX_FMT_RGB332: case V4L2_PIX_FMT_RGB332:
buffer->depth = 8; buffer->depth = 8;
break; break;
...@@ -381,10 +373,10 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -381,10 +373,10 @@ v4l_compat_translate_ioctl(struct inode *inode,
default: default:
buffer->depth = 0; buffer->depth = 0;
} }
if (fbuf2.fmt.bytesperline) { if (fbuf.fmt.bytesperline) {
buffer->bytesperline = fbuf2.fmt.bytesperline; buffer->bytesperline = fbuf.fmt.bytesperline;
if (!buffer->depth && buffer->width) if (!buffer->depth && buffer->width)
buffer->depth = ((fbuf2.fmt.bytesperline<<3) buffer->depth = ((fbuf.fmt.bytesperline<<3)
+ (buffer->width-1)) + (buffer->width-1))
/ buffer->width; / buffer->width;
} else { } else {
...@@ -392,128 +384,157 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -392,128 +384,157 @@ v4l_compat_translate_ioctl(struct inode *inode,
(buffer->width * buffer->depth + 7) & 7; (buffer->width * buffer->depth + 7) & 7;
buffer->bytesperline >>= 3; buffer->bytesperline >>= 3;
} }
break; done:
} return err;
case VIDIOCSFBUF: /* set frame buffer */ }
{
struct video_buffer *buffer = arg; static noinline int v4l1_compat_set_frame_buffer(
struct video_buffer *buffer,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_framebuffer fbuf;
memset(&fbuf2, 0, sizeof(fbuf2)); memset(&fbuf, 0, sizeof(fbuf));
fbuf2.base = buffer->base; fbuf.base = buffer->base;
fbuf2.fmt.height = buffer->height; fbuf.fmt.height = buffer->height;
fbuf2.fmt.width = buffer->width; fbuf.fmt.width = buffer->width;
switch (buffer->depth) { switch (buffer->depth) {
case 8: case 8:
fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB332; fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB332;
break; break;
case 15: case 15:
fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB555; fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555;
break; break;
case 16: case 16:
fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB565; fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565;
break; break;
case 24: case 24:
fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR24; fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24;
break; break;
case 32: case 32:
fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR32; fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
break; break;
} }
fbuf2.fmt.bytesperline = buffer->bytesperline; fbuf.fmt.bytesperline = buffer->bytesperline;
err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); err = drv(inode, file, VIDIOC_S_FBUF, &fbuf);
if (err < 0) if (err < 0)
dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err); dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err);
break; return err;
} }
case VIDIOCGWIN: /* get window or capture dimensions */
{
struct video_window *win = arg;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); static noinline int v4l1_compat_get_win_cap_dimensions(
if (!fmt2) { struct video_window *win,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_format *fmt;
fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
if (!fmt) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
memset(win, 0, sizeof(*win)); memset(win, 0, sizeof(*win));
fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt);
if (err < 0) if (err < 0)
dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err); dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err);
if (err == 0) { if (err == 0) {
win->x = fmt2->fmt.win.w.left; win->x = fmt->fmt.win.w.left;
win->y = fmt2->fmt.win.w.top; win->y = fmt->fmt.win.w.top;
win->width = fmt2->fmt.win.w.width; win->width = fmt->fmt.win.w.width;
win->height = fmt2->fmt.win.w.height; win->height = fmt->fmt.win.w.height;
win->chromakey = fmt2->fmt.win.chromakey; win->chromakey = fmt->fmt.win.chromakey;
win->clips = NULL; win->clips = NULL;
win->clipcount = 0; win->clipcount = 0;
break; goto done;
} }
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err);
break; goto done;
} }
win->x = 0; win->x = 0;
win->y = 0; win->y = 0;
win->width = fmt2->fmt.pix.width; win->width = fmt->fmt.pix.width;
win->height = fmt2->fmt.pix.height; win->height = fmt->fmt.pix.height;
win->chromakey = 0; win->chromakey = 0;
win->clips = NULL; win->clips = NULL;
win->clipcount = 0; win->clipcount = 0;
break; done:
} kfree(fmt);
case VIDIOCSWIN: /* set window and/or capture dimensions */ return err;
{ }
struct video_window *win = arg;
int err1, err2;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); static noinline int v4l1_compat_set_win_cap_dimensions(
if (!fmt2) { struct video_window *win,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err, err1, err2;
struct v4l2_format *fmt;
fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
if (!fmt) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type); drv(inode, file, VIDIOC_STREAMOFF, &fmt->type);
err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); err1 = drv(inode, file, VIDIOC_G_FMT, fmt);
if (err1 < 0) if (err1 < 0)
dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1);
if (err1 == 0) { if (err1 == 0) {
fmt2->fmt.pix.width = win->width; fmt->fmt.pix.width = win->width;
fmt2->fmt.pix.height = win->height; fmt->fmt.pix.height = win->height;
fmt2->fmt.pix.field = V4L2_FIELD_ANY; fmt->fmt.pix.field = V4L2_FIELD_ANY;
fmt2->fmt.pix.bytesperline = 0; fmt->fmt.pix.bytesperline = 0;
err = drv(inode, file, VIDIOC_S_FMT, fmt2); err = drv(inode, file, VIDIOC_S_FMT, fmt);
if (err < 0) if (err < 0)
dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n",
err); err);
win->width = fmt2->fmt.pix.width; win->width = fmt->fmt.pix.width;
win->height = fmt2->fmt.pix.height; win->height = fmt->fmt.pix.height;
} }
memset(fmt2, 0, sizeof(*fmt2)); memset(fmt, 0, sizeof(*fmt));
fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
fmt2->fmt.win.w.left = win->x; fmt->fmt.win.w.left = win->x;
fmt2->fmt.win.w.top = win->y; fmt->fmt.win.w.top = win->y;
fmt2->fmt.win.w.width = win->width; fmt->fmt.win.w.width = win->width;
fmt2->fmt.win.w.height = win->height; fmt->fmt.win.w.height = win->height;
fmt2->fmt.win.chromakey = win->chromakey; fmt->fmt.win.chromakey = win->chromakey;
fmt2->fmt.win.clips = (void __user *)win->clips; fmt->fmt.win.clips = (void __user *)win->clips;
fmt2->fmt.win.clipcount = win->clipcount; fmt->fmt.win.clipcount = win->clipcount;
err2 = drv(inode, file, VIDIOC_S_FMT, fmt2); err2 = drv(inode, file, VIDIOC_S_FMT, fmt);
if (err2 < 0) if (err2 < 0)
dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err); dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2);
if (err1 != 0 && err2 != 0) if (err1 != 0 && err2 != 0)
err = err1; err = err1;
break; else
} err = 0;
case VIDIOCCAPTURE: /* turn on/off preview */ kfree(fmt);
{ return err;
int *on = arg; }
static noinline int v4l1_compat_turn_preview_on_off(
int *on,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (0 == *on) { if (0 == *on) {
/* dirty hack time. But v4l1 has no STREAMOFF /* dirty hack time. But v4l1 has no STREAMOFF
...@@ -521,14 +542,21 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -521,14 +542,21 @@ v4l_compat_translate_ioctl(struct inode *inode,
* least comes close ... */ * least comes close ... */
drv(inode, file, VIDIOC_STREAMOFF, &captype); drv(inode, file, VIDIOC_STREAMOFF, &captype);
} }
err = drv(inode, file, VIDIOC_OVERLAY, arg); err = drv(inode, file, VIDIOC_OVERLAY, on);
if (err < 0) if (err < 0)
dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err); dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err);
break; return err;
} }
case VIDIOCGCHAN: /* get input information */
{ static noinline int v4l1_compat_get_input_info(
struct video_channel *chan = arg; struct video_channel *chan,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_input input2;
v4l2_std_id sid;
memset(&input2, 0, sizeof(input2)); memset(&input2, 0, sizeof(input2));
input2.index = chan->channel; input2.index = chan->channel;
...@@ -536,7 +564,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -536,7 +564,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: "
"channel=%d err=%d\n", chan->channel, err); "channel=%d err=%d\n", chan->channel, err);
break; goto done;
} }
chan->channel = input2.index; chan->channel = input2.index;
memcpy(chan->name, input2.name, memcpy(chan->name, input2.name,
...@@ -565,13 +593,19 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -565,13 +593,19 @@ v4l_compat_translate_ioctl(struct inode *inode,
if (sid & V4L2_STD_SECAM) if (sid & V4L2_STD_SECAM)
chan->norm = VIDEO_MODE_SECAM; chan->norm = VIDEO_MODE_SECAM;
} }
break; done:
} return err;
case VIDIOCSCHAN: /* set input */ }
{
struct video_channel *chan = arg; static noinline int v4l1_compat_set_input(
struct video_channel *chan,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
v4l2_std_id sid = 0;
sid = 0;
err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel); err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel);
if (err < 0) if (err < 0)
dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err); dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err);
...@@ -591,16 +625,22 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -591,16 +625,22 @@ v4l_compat_translate_ioctl(struct inode *inode,
if (err < 0) if (err < 0)
dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err); dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err);
} }
break; return err;
} }
case VIDIOCGPICT: /* get tone controls & partial capture format */
{
struct video_picture *pict = arg;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); static noinline int v4l1_compat_get_picture(
if (!fmt2) { struct video_picture *pict,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_format *fmt;
fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
if (!fmt) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
pict->brightness = get_v4l_control(inode, file, pict->brightness = get_v4l_control(inode, file,
...@@ -614,31 +654,40 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -614,31 +654,40 @@ v4l_compat_translate_ioctl(struct inode *inode,
pict->whiteness = get_v4l_control(inode, file, pict->whiteness = get_v4l_control(inode, file,
V4L2_CID_WHITENESS, drv); V4L2_CID_WHITENESS, drv);
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err);
break; goto done;
} }
pict->depth = ((fmt2->fmt.pix.bytesperline << 3) pict->depth = ((fmt->fmt.pix.bytesperline << 3)
+ (fmt2->fmt.pix.width - 1)) + (fmt->fmt.pix.width - 1))
/ fmt2->fmt.pix.width; / fmt->fmt.pix.width;
pict->palette = pixelformat_to_palette( pict->palette = pixelformat_to_palette(
fmt2->fmt.pix.pixelformat); fmt->fmt.pix.pixelformat);
break; done:
} kfree(fmt);
case VIDIOCSPICT: /* set tone controls & partial capture format */ return err;
{ }
struct video_picture *pict = arg;
static noinline int v4l1_compat_set_picture(
struct video_picture *pict,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_framebuffer fbuf;
int mem_err = 0, ovl_err = 0; int mem_err = 0, ovl_err = 0;
struct v4l2_format *fmt;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
if (!fmt2) { if (!fmt) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
memset(&fbuf2, 0, sizeof(fbuf2)); memset(&fbuf, 0, sizeof(fbuf));
set_v4l_control(inode, file, set_v4l_control(inode, file,
V4L2_CID_BRIGHTNESS, pict->brightness, drv); V4L2_CID_BRIGHTNESS, pict->brightness, drv);
...@@ -657,36 +706,36 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -657,36 +706,36 @@ v4l_compat_translate_ioctl(struct inode *inode,
* different pixel formats for memory vs overlay. * different pixel formats for memory vs overlay.
*/ */
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt);
/* If VIDIOC_G_FMT failed, then the driver likely doesn't /* If VIDIOC_G_FMT failed, then the driver likely doesn't
support memory capture. Trying to set the memory capture support memory capture. Trying to set the memory capture
parameters would be pointless. */ parameters would be pointless. */
if (err < 0) { if (err < 0) {
dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n", err);
mem_err = -1000; /* didn't even try */ mem_err = -1000; /* didn't even try */
} else if (fmt2->fmt.pix.pixelformat != } else if (fmt->fmt.pix.pixelformat !=
palette_to_pixelformat(pict->palette)) { palette_to_pixelformat(pict->palette)) {
fmt2->fmt.pix.pixelformat = palette_to_pixelformat( fmt->fmt.pix.pixelformat = palette_to_pixelformat(
pict->palette); pict->palette);
mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2); mem_err = drv(inode, file, VIDIOC_S_FMT, fmt);
if (mem_err < 0) if (mem_err < 0)
dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",
mem_err); mem_err);
} }
err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); err = drv(inode, file, VIDIOC_G_FBUF, &fbuf);
/* If VIDIOC_G_FBUF failed, then the driver likely doesn't /* If VIDIOC_G_FBUF failed, then the driver likely doesn't
support overlay. Trying to set the overlay parameters support overlay. Trying to set the overlay parameters
would be quite pointless. */ would be quite pointless. */
if (err < 0) { if (err < 0) {
dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n", err); dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n", err);
ovl_err = -1000; /* didn't even try */ ovl_err = -1000; /* didn't even try */
} else if (fbuf2.fmt.pixelformat != } else if (fbuf.fmt.pixelformat !=
palette_to_pixelformat(pict->palette)) { palette_to_pixelformat(pict->palette)) {
fbuf2.fmt.pixelformat = palette_to_pixelformat( fbuf.fmt.pixelformat = palette_to_pixelformat(
pict->palette); pict->palette);
ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf);
if (ovl_err < 0) if (ovl_err < 0)
dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",
ovl_err); ovl_err);
...@@ -701,17 +750,26 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -701,17 +750,26 @@ v4l_compat_translate_ioctl(struct inode *inode,
err = ovl_err; err = ovl_err;
} else } else
err = 0; err = 0;
break; kfree(fmt);
} return err;
case VIDIOCGTUNER: /* get tuner information */ }
{
struct video_tuner *tun = arg; static noinline int v4l1_compat_get_tuner(
struct video_tuner *tun,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err, i;
struct v4l2_tuner tun2;
struct v4l2_standard std2;
v4l2_std_id sid;
memset(&tun2, 0, sizeof(tun2)); memset(&tun2, 0, sizeof(tun2));
err = drv(inode, file, VIDIOC_G_TUNER, &tun2); err = drv(inode, file, VIDIOC_G_TUNER, &tun2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err); dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err);
break; goto done;
} }
memcpy(tun->name, tun2.name, memcpy(tun->name, tun2.name,
min(sizeof(tun->name), sizeof(tun2.name))); min(sizeof(tun->name), sizeof(tun2.name)));
...@@ -751,12 +809,18 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -751,12 +809,18 @@ v4l_compat_translate_ioctl(struct inode *inode,
if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO)
tun->flags |= VIDEO_TUNER_STEREO_ON; tun->flags |= VIDEO_TUNER_STEREO_ON;
tun->signal = tun2.signal; tun->signal = tun2.signal;
break; done:
} return err;
case VIDIOCSTUNER: /* select a tuner input */ }
{
struct video_tuner *tun = arg; static noinline int v4l1_compat_select_tuner(
struct v4l2_tuner t; struct video_tuner *tun,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_tuner t;/*84 bytes on x86_64*/
memset(&t, 0, sizeof(t)); memset(&t, 0, sizeof(t));
t.index = tun->tuner; t.index = tun->tuner;
...@@ -764,12 +828,17 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -764,12 +828,17 @@ v4l_compat_translate_ioctl(struct inode *inode,
err = drv(inode, file, VIDIOC_S_INPUT, &t); err = drv(inode, file, VIDIOC_S_INPUT, &t);
if (err < 0) if (err < 0)
dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err); dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err);
return err;
}
break; static noinline int v4l1_compat_get_frequency(
} unsigned long *freq,
case VIDIOCGFREQ: /* get frequency */ struct inode *inode,
{ struct file *file,
unsigned long *freq = arg; v4l2_kioctl drv)
{
int err;
struct v4l2_frequency freq2;
memset(&freq2, 0, sizeof(freq2)); memset(&freq2, 0, sizeof(freq2));
freq2.tuner = 0; freq2.tuner = 0;
...@@ -778,11 +847,17 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -778,11 +847,17 @@ v4l_compat_translate_ioctl(struct inode *inode,
dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err); dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err);
if (0 == err) if (0 == err)
*freq = freq2.frequency; *freq = freq2.frequency;
break; return err;
} }
case VIDIOCSFREQ: /* set frequency */
{ static noinline int v4l1_compat_set_frequency(
unsigned long *freq = arg; unsigned long *freq,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_frequency freq2;
memset(&freq2, 0, sizeof(freq2)); memset(&freq2, 0, sizeof(freq2));
drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); drv(inode, file, VIDIOC_G_FREQUENCY, &freq2);
...@@ -790,17 +865,25 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -790,17 +865,25 @@ v4l_compat_translate_ioctl(struct inode *inode,
err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2); err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2);
if (err < 0) if (err < 0)
dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err); dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err);
break; return err;
} }
case VIDIOCGAUDIO: /* get audio properties/controls */
{ static noinline int v4l1_compat_get_audio(
struct video_audio *aud = arg; struct video_audio *aud,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err, i;
struct v4l2_queryctrl qctrl2;
struct v4l2_audio aud2;
struct v4l2_tuner tun2;
memset(&aud2, 0, sizeof(aud2)); memset(&aud2, 0, sizeof(aud2));
err = drv(inode, file, VIDIOC_G_AUDIO, &aud2); err = drv(inode, file, VIDIOC_G_AUDIO, &aud2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err); dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err);
break; goto done;
} }
memcpy(aud->name, aud2.name, memcpy(aud->name, aud2.name,
min(sizeof(aud->name), sizeof(aud2.name))); min(sizeof(aud->name), sizeof(aud2.name)));
...@@ -845,7 +928,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -845,7 +928,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err); dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err);
err = 0; err = 0;
break; goto done;
} }
if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2) if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2)
...@@ -854,11 +937,19 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -854,11 +937,19 @@ v4l_compat_translate_ioctl(struct inode *inode,
aud->mode = VIDEO_SOUND_STEREO; aud->mode = VIDEO_SOUND_STEREO;
else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO) else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO)
aud->mode = VIDEO_SOUND_MONO; aud->mode = VIDEO_SOUND_MONO;
break; done:
} return err;
case VIDIOCSAUDIO: /* set audio controls */ }
{
struct video_audio *aud = arg; static noinline int v4l1_compat_set_audio(
struct video_audio *aud,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_audio aud2;
struct v4l2_tuner tun2;
memset(&aud2, 0, sizeof(aud2)); memset(&aud2, 0, sizeof(aud2));
memset(&tun2, 0, sizeof(tun2)); memset(&tun2, 0, sizeof(tun2));
...@@ -867,7 +958,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -867,7 +958,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
err = drv(inode, file, VIDIOC_S_AUDIO, &aud2); err = drv(inode, file, VIDIOC_S_AUDIO, &aud2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err); dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err);
break; goto done;
} }
set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME,
...@@ -903,126 +994,149 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -903,126 +994,149 @@ v4l_compat_translate_ioctl(struct inode *inode,
dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err); dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err);
} }
err = 0; err = 0;
break; done:
} return err;
case VIDIOCMCAPTURE: /* capture a frame */ }
{
struct video_mmap *mm = arg;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); static noinline int v4l1_compat_capture_frame(
if (!fmt2) { struct video_mmap *mm,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_buffer buf;
struct v4l2_format *fmt;
fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
if (!fmt) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
memset(&buf2, 0, sizeof(buf2)); memset(&buf, 0, sizeof(buf));
fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err);
break; goto done;
} }
if (mm->width != fmt2->fmt.pix.width || if (mm->width != fmt->fmt.pix.width ||
mm->height != fmt2->fmt.pix.height || mm->height != fmt->fmt.pix.height ||
palette_to_pixelformat(mm->format) != palette_to_pixelformat(mm->format) !=
fmt2->fmt.pix.pixelformat) { fmt->fmt.pix.pixelformat) {
/* New capture format... */ /* New capture format... */
fmt2->fmt.pix.width = mm->width; fmt->fmt.pix.width = mm->width;
fmt2->fmt.pix.height = mm->height; fmt->fmt.pix.height = mm->height;
fmt2->fmt.pix.pixelformat = fmt->fmt.pix.pixelformat =
palette_to_pixelformat(mm->format); palette_to_pixelformat(mm->format);
fmt2->fmt.pix.field = V4L2_FIELD_ANY; fmt->fmt.pix.field = V4L2_FIELD_ANY;
fmt2->fmt.pix.bytesperline = 0; fmt->fmt.pix.bytesperline = 0;
err = drv(inode, file, VIDIOC_S_FMT, fmt2); err = drv(inode, file, VIDIOC_S_FMT, fmt);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err); dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err);
break; goto done;
} }
} }
buf2.index = mm->frame; buf.index = mm->frame;
buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); err = drv(inode, file, VIDIOC_QUERYBUF, &buf);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err); dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err);
break; goto done;
} }
err = drv(inode, file, VIDIOC_QBUF, &buf2); err = drv(inode, file, VIDIOC_QBUF, &buf);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err); dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err);
break; goto done;
} }
err = drv(inode, file, VIDIOC_STREAMON, &captype); err = drv(inode, file, VIDIOC_STREAMON, &captype);
if (err < 0) if (err < 0)
dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err); dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err);
break; done:
} kfree(fmt);
case VIDIOCSYNC: /* wait for a frame */ return err;
{ }
int *i = arg;
static noinline int v4l1_compat_sync(
int *i,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
struct v4l2_buffer buf;
memset(&buf2, 0, sizeof(buf2)); memset(&buf, 0, sizeof(buf));
buf2.index = *i; buf.index = *i;
buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); err = drv(inode, file, VIDIOC_QUERYBUF, &buf);
if (err < 0) { if (err < 0) {
/* No such buffer */ /* No such buffer */
dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
break; goto done;
} }
if (!(buf2.flags & V4L2_BUF_FLAG_MAPPED)) { if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) {
/* Buffer is not mapped */ /* Buffer is not mapped */
err = -EINVAL; err = -EINVAL;
break; goto done;
} }
/* make sure capture actually runs so we don't block forever */ /* make sure capture actually runs so we don't block forever */
err = drv(inode, file, VIDIOC_STREAMON, &captype); err = drv(inode, file, VIDIOC_STREAMON, &captype);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err); dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err);
break; goto done;
} }
/* Loop as long as the buffer is queued, but not done */ /* Loop as long as the buffer is queued, but not done */
while ((buf2.flags & while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))
(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE))
== V4L2_BUF_FLAG_QUEUED) { == V4L2_BUF_FLAG_QUEUED) {
err = poll_one(file); err = poll_one(file);
if (err < 0 || /* error or sleep was interrupted */ if (err < 0 || /* error or sleep was interrupted */
err == 0) /* timeout? Shouldn't occur. */ err == 0) /* timeout? Shouldn't occur. */
break; break;
err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); err = drv(inode, file, VIDIOC_QUERYBUF, &buf);
if (err < 0) if (err < 0)
dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err);
} }
if (!(buf2.flags & V4L2_BUF_FLAG_DONE)) /* not done */ if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */
break; goto done;
do { do {
err = drv(inode, file, VIDIOC_DQBUF, &buf2); err = drv(inode, file, VIDIOC_DQBUF, &buf);
if (err < 0) if (err < 0)
dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err); dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err);
} while (err == 0 && buf2.index != *i); } while (err == 0 && buf.index != *i);
break; done:
} return err;
}
case VIDIOCGVBIFMT: /* query VBI data capture format */ static noinline int v4l1_compat_get_vbi_format(
{ struct vbi_format *fmt,
struct vbi_format *fmt = arg; struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_format *fmt2;
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
if (!fmt2) { if (!fmt2) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
err = drv(inode, file, VIDIOC_G_FMT, fmt2); err = drv(inode, file, VIDIOC_G_FMT, fmt2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err);
break; goto done;
} }
if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) {
err = -EINVAL; err = -EINVAL;
break; goto done;
} }
memset(fmt, 0, sizeof(*fmt)); memset(fmt, 0, sizeof(*fmt));
fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line;
...@@ -1033,21 +1147,29 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -1033,21 +1147,29 @@ v4l_compat_translate_ioctl(struct inode *inode,
fmt->start[1] = fmt2->fmt.vbi.start[1]; fmt->start[1] = fmt2->fmt.vbi.start[1];
fmt->count[1] = fmt2->fmt.vbi.count[1]; fmt->count[1] = fmt2->fmt.vbi.count[1];
fmt->flags = fmt2->fmt.vbi.flags & 0x03; fmt->flags = fmt2->fmt.vbi.flags & 0x03;
break; done:
} kfree(fmt2);
case VIDIOCSVBIFMT: return err;
{ }
struct vbi_format *fmt = arg;
static noinline int v4l1_compat_set_vbi_format(
struct vbi_format *fmt,
struct inode *inode,
struct file *file,
v4l2_kioctl drv)
{
int err;
struct v4l2_format *fmt2 = NULL;
if (VIDEO_PALETTE_RAW != fmt->sample_format) { if (VIDEO_PALETTE_RAW != fmt->sample_format) {
err = -EINVAL; err = -EINVAL;
break; return err;
} }
fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
if (!fmt2) { if (!fmt2) {
err = -ENOMEM; err = -ENOMEM;
break; return err;
} }
fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line;
...@@ -1061,7 +1183,7 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -1061,7 +1183,7 @@ v4l_compat_translate_ioctl(struct inode *inode,
err = drv(inode, file, VIDIOC_TRY_FMT, fmt2); err = drv(inode, file, VIDIOC_TRY_FMT, fmt2);
if (err < 0) { if (err < 0) {
dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err);
break; goto done;
} }
if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line ||
...@@ -1073,21 +1195,94 @@ v4l_compat_translate_ioctl(struct inode *inode, ...@@ -1073,21 +1195,94 @@ v4l_compat_translate_ioctl(struct inode *inode,
fmt2->fmt.vbi.count[1] != fmt->count[1] || fmt2->fmt.vbi.count[1] != fmt->count[1] ||
fmt2->fmt.vbi.flags != fmt->flags) { fmt2->fmt.vbi.flags != fmt->flags) {
err = -EINVAL; err = -EINVAL;
break; goto done;
} }
err = drv(inode, file, VIDIOC_S_FMT, fmt2); err = drv(inode, file, VIDIOC_S_FMT, fmt2);
if (err < 0) if (err < 0)
dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err);
break; done:
} kfree(fmt2);
return err;
}
/*
* This function is exported.
*/
int
v4l_compat_translate_ioctl(struct inode *inode,
struct file *file,
int cmd,
void *arg,
v4l2_kioctl drv)
{
int err;
switch (cmd) {
case VIDIOCGCAP: /* capability */
err = v4l1_compat_get_capabilities(arg, inode, file, drv);
break;
case VIDIOCGFBUF: /* get frame buffer */
err = v4l1_compat_get_frame_buffer(arg, inode, file, drv);
break;
case VIDIOCSFBUF: /* set frame buffer */
err = v4l1_compat_set_frame_buffer(arg, inode, file, drv);
break;
case VIDIOCGWIN: /* get window or capture dimensions */
err = v4l1_compat_get_win_cap_dimensions(arg, inode, file, drv);
break;
case VIDIOCSWIN: /* set window and/or capture dimensions */
err = v4l1_compat_set_win_cap_dimensions(arg, inode, file, drv);
break;
case VIDIOCCAPTURE: /* turn on/off preview */
err = v4l1_compat_turn_preview_on_off(arg, inode, file, drv);
break;
case VIDIOCGCHAN: /* get input information */
err = v4l1_compat_get_input_info(arg, inode, file, drv);
break;
case VIDIOCSCHAN: /* set input */
err = v4l1_compat_set_input(arg, inode, file, drv);
break;
case VIDIOCGPICT: /* get tone controls & partial capture format */
err = v4l1_compat_get_picture(arg, inode, file, drv);
break;
case VIDIOCSPICT: /* set tone controls & partial capture format */
err = v4l1_compat_set_picture(arg, inode, file, drv);
break;
case VIDIOCGTUNER: /* get tuner information */
err = v4l1_compat_get_tuner(arg, inode, file, drv);
break;
case VIDIOCSTUNER: /* select a tuner input */
err = v4l1_compat_select_tuner(arg, inode, file, drv);
break;
case VIDIOCGFREQ: /* get frequency */
err = v4l1_compat_get_frequency(arg, inode, file, drv);
break;
case VIDIOCSFREQ: /* set frequency */
err = v4l1_compat_set_frequency(arg, inode, file, drv);
break;
case VIDIOCGAUDIO: /* get audio properties/controls */
err = v4l1_compat_get_audio(arg, inode, file, drv);
break;
case VIDIOCSAUDIO: /* set audio controls */
err = v4l1_compat_set_audio(arg, inode, file, drv);
break;
case VIDIOCMCAPTURE: /* capture a frame */
err = v4l1_compat_capture_frame(arg, inode, file, drv);
break;
case VIDIOCSYNC: /* wait for a frame */
err = v4l1_compat_sync(arg, inode, file, drv);
break;
case VIDIOCGVBIFMT: /* query VBI data capture format */
err = v4l1_compat_get_vbi_format(arg, inode, file, drv);
break;
case VIDIOCSVBIFMT:
err = v4l1_compat_set_vbi_format(arg, inode, file, drv);
break;
default: default:
err = -ENOIOCTLCMD; err = -ENOIOCTLCMD;
break; break;
} }
kfree(cap2);
kfree(fmt2);
return err; return err;
} }
EXPORT_SYMBOL(v4l_compat_translate_ioctl); EXPORT_SYMBOL(v4l_compat_translate_ioctl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment