V4L/DVB (6793): Convert saa7134-empress to video_ioctl2
saa7134 were converted to video_ioctl2, but saa7134_empress weren't. This broke saa7134-empress, since it were dependent of saa7134_common_ioctl. With the conversion, the module had a size decrease of 436 bytes on x86_64: text data bss dec hex filename 5196 4912 4 10112 2780 old/saa7134-empress.ko 4760 4912 4 9676 25cc new/saa7134-empress.ko Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
@@ -161,20 +161,13 @@ ts_mmap(struct file *file, struct vm_area_struct * vma)
|
|||||||
* video_generic_ioctl (and maybe others). userspace
|
* video_generic_ioctl (and maybe others). userspace
|
||||||
* copying is done already, arg is a kernel pointer.
|
* copying is done already, arg is a kernel pointer.
|
||||||
*/
|
*/
|
||||||
static int ts_do_ioctl(struct inode *inode, struct file *file,
|
|
||||||
unsigned int cmd, void *arg)
|
|
||||||
{
|
|
||||||
struct saa7134_dev *dev = file->private_data;
|
|
||||||
struct v4l2_ext_controls *ctrls = arg;
|
|
||||||
|
|
||||||
if (debug > 1)
|
static int empress_querycap(struct file *file, void *priv,
|
||||||
v4l_print_ioctl(dev->name,cmd);
|
struct v4l2_capability *cap)
|
||||||
switch (cmd) {
|
|
||||||
case VIDIOC_QUERYCAP:
|
|
||||||
{
|
{
|
||||||
struct v4l2_capability *cap = arg;
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
memset(cap,0,sizeof(*cap));
|
|
||||||
strcpy(cap->driver, "saa7134");
|
strcpy(cap->driver, "saa7134");
|
||||||
strlcpy(cap->card, saa7134_boards[dev->board].name,
|
strlcpy(cap->card, saa7134_boards[dev->board].name,
|
||||||
sizeof(cap->card));
|
sizeof(cap->card));
|
||||||
@@ -187,128 +180,159 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- input switching --------------------------------------- */
|
static int empress_enum_input(struct file *file, void *priv,
|
||||||
case VIDIOC_ENUMINPUT:
|
struct v4l2_input *i)
|
||||||
{
|
{
|
||||||
struct v4l2_input *i = arg;
|
|
||||||
|
|
||||||
if (i->index != 0)
|
if (i->index != 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
i->type = V4L2_INPUT_TYPE_CAMERA;
|
i->type = V4L2_INPUT_TYPE_CAMERA;
|
||||||
strcpy(i->name, "CCIR656");
|
strcpy(i->name, "CCIR656");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case VIDIOC_G_INPUT:
|
|
||||||
|
static int empress_g_input(struct file *file, void *priv, unsigned int *i)
|
||||||
{
|
{
|
||||||
int *i = arg;
|
|
||||||
*i = 0;
|
*i = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case VIDIOC_S_INPUT:
|
|
||||||
{
|
|
||||||
int *i = arg;
|
|
||||||
|
|
||||||
if (*i != 0)
|
static int empress_s_input(struct file *file, void *priv, unsigned int i)
|
||||||
|
{
|
||||||
|
if (i != 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --- capture ioctls ---------------------------------------- */
|
|
||||||
|
|
||||||
case VIDIOC_ENUM_FMT:
|
static int empress_enum_fmt_cap(struct file *file, void *priv,
|
||||||
|
struct v4l2_fmtdesc *f)
|
||||||
{
|
{
|
||||||
struct v4l2_fmtdesc *f = arg;
|
if (f->index != 0)
|
||||||
int index;
|
|
||||||
|
|
||||||
index = f->index;
|
|
||||||
if (index != 0)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(f,0,sizeof(*f));
|
|
||||||
f->index = index;
|
|
||||||
strlcpy(f->description, "MPEG TS", sizeof(f->description));
|
strlcpy(f->description, "MPEG TS", sizeof(f->description));
|
||||||
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
f->pixelformat = V4L2_PIX_FMT_MPEG;
|
f->pixelformat = V4L2_PIX_FMT_MPEG;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_G_FMT:
|
static int empress_g_fmt_cap(struct file *file, void *priv,
|
||||||
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
struct v4l2_format *f = arg;
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
memset(f,0,sizeof(*f));
|
saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f);
|
||||||
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
|
|
||||||
saa7134_i2c_call_clients(dev, cmd, arg);
|
|
||||||
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
||||||
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_S_FMT:
|
static int empress_s_fmt_cap(struct file *file, void *priv,
|
||||||
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
struct v4l2_format *f = arg;
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
saa7134_i2c_call_clients(dev, cmd, arg);
|
|
||||||
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
||||||
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_REQBUFS:
|
|
||||||
return videobuf_reqbufs(&dev->empress_tsq,arg);
|
|
||||||
|
|
||||||
case VIDIOC_QUERYBUF:
|
static int empress_reqbufs(struct file *file, void *priv,
|
||||||
return videobuf_querybuf(&dev->empress_tsq,arg);
|
struct v4l2_requestbuffers *p)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
case VIDIOC_QBUF:
|
return videobuf_reqbufs(&dev->empress_tsq, p);
|
||||||
return videobuf_qbuf(&dev->empress_tsq,arg);
|
}
|
||||||
|
|
||||||
case VIDIOC_DQBUF:
|
static int empress_querybuf(struct file *file, void *priv,
|
||||||
return videobuf_dqbuf(&dev->empress_tsq,arg,
|
struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
|
return videobuf_querybuf(&dev->empress_tsq, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int empress_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
|
return videobuf_qbuf(&dev->empress_tsq, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
|
return videobuf_dqbuf(&dev->empress_tsq, b,
|
||||||
file->f_flags & O_NONBLOCK);
|
file->f_flags & O_NONBLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int empress_streamon(struct file *file, void *priv,
|
||||||
|
enum v4l2_buf_type type)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
case VIDIOC_STREAMON:
|
|
||||||
return videobuf_streamon(&dev->empress_tsq);
|
return videobuf_streamon(&dev->empress_tsq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int empress_streamoff(struct file *file, void *priv,
|
||||||
|
enum v4l2_buf_type type)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
case VIDIOC_STREAMOFF:
|
|
||||||
return videobuf_streamoff(&dev->empress_tsq);
|
return videobuf_streamoff(&dev->empress_tsq);
|
||||||
|
}
|
||||||
|
|
||||||
case VIDIOC_QUERYCTRL:
|
static int empress_s_ext_ctrls(struct file *file, void *priv,
|
||||||
case VIDIOC_G_CTRL:
|
struct v4l2_ext_controls *ctrls)
|
||||||
case VIDIOC_S_CTRL:
|
{
|
||||||
return saa7134_common_ioctl(dev, cmd, arg);
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
case VIDIOC_S_EXT_CTRLS:
|
|
||||||
/* count == 0 is abused in saa6752hs.c, so that special
|
/* count == 0 is abused in saa6752hs.c, so that special
|
||||||
case is handled here explicitly. */
|
case is handled here explicitly. */
|
||||||
if (ctrls->count == 0)
|
if (ctrls->count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
|
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, arg);
|
|
||||||
|
saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, ctrls);
|
||||||
ts_init_encoder(dev);
|
ts_init_encoder(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case VIDIOC_G_EXT_CTRLS:
|
}
|
||||||
|
|
||||||
|
static int empress_g_ext_ctrls(struct file *file, void *priv,
|
||||||
|
struct v4l2_ext_controls *ctrls)
|
||||||
|
{
|
||||||
|
struct saa7134_fh *fh = priv;
|
||||||
|
struct saa7134_dev *dev = fh->dev;
|
||||||
|
|
||||||
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
|
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, arg);
|
saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, ctrls);
|
||||||
return 0;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return -ENOIOCTLCMD;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ts_ioctl(struct inode *inode, struct file *file,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
return video_usercopy(inode, file, cmd, arg, ts_do_ioctl);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ts_fops =
|
static const struct file_operations ts_fops =
|
||||||
{
|
{
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
@@ -317,7 +341,7 @@ static const struct file_operations ts_fops =
|
|||||||
.read = ts_read,
|
.read = ts_read,
|
||||||
.poll = ts_poll,
|
.poll = ts_poll,
|
||||||
.mmap = ts_mmap,
|
.mmap = ts_mmap,
|
||||||
.ioctl = ts_ioctl,
|
.ioctl = video_ioctl2,
|
||||||
.llseek = no_llseek,
|
.llseek = no_llseek,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -330,6 +354,29 @@ static struct video_device saa7134_empress_template =
|
|||||||
.type2 = 0 /* FIXME */,
|
.type2 = 0 /* FIXME */,
|
||||||
.fops = &ts_fops,
|
.fops = &ts_fops,
|
||||||
.minor = -1,
|
.minor = -1,
|
||||||
|
|
||||||
|
.vidioc_querycap = empress_querycap,
|
||||||
|
.vidioc_enum_fmt_cap = empress_enum_fmt_cap,
|
||||||
|
.vidioc_s_fmt_cap = empress_s_fmt_cap,
|
||||||
|
.vidioc_g_fmt_cap = empress_g_fmt_cap,
|
||||||
|
.vidioc_reqbufs = empress_reqbufs,
|
||||||
|
.vidioc_querybuf = empress_querybuf,
|
||||||
|
.vidioc_qbuf = empress_qbuf,
|
||||||
|
.vidioc_dqbuf = empress_dqbuf,
|
||||||
|
.vidioc_streamon = empress_streamon,
|
||||||
|
.vidioc_streamoff = empress_streamoff,
|
||||||
|
.vidioc_s_ext_ctrls = empress_s_ext_ctrls,
|
||||||
|
.vidioc_g_ext_ctrls = empress_g_ext_ctrls,
|
||||||
|
.vidioc_enum_input = empress_enum_input,
|
||||||
|
.vidioc_g_input = empress_g_input,
|
||||||
|
.vidioc_s_input = empress_s_input,
|
||||||
|
|
||||||
|
.vidioc_queryctrl = saa7134_queryctrl,
|
||||||
|
.vidioc_g_ctrl = saa7134_g_ctrl,
|
||||||
|
.vidioc_s_ctrl = saa7134_s_ctrl,
|
||||||
|
|
||||||
|
.tvnorms = SAA7134_NORMS,
|
||||||
|
.current_norm = V4L2_STD_PAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void empress_signal_update(struct work_struct *work)
|
static void empress_signal_update(struct work_struct *work)
|
||||||
|
@@ -217,12 +217,6 @@ static struct saa7134_format formats[] = {
|
|||||||
.vbi_v_start_1 = 273, \
|
.vbi_v_start_1 = 273, \
|
||||||
.src_timing = 7
|
.src_timing = 7
|
||||||
|
|
||||||
#define SAA7134_NORMS \
|
|
||||||
V4L2_STD_PAL | V4L2_STD_PAL_N | \
|
|
||||||
V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
|
|
||||||
V4L2_STD_NTSC | V4L2_STD_PAL_M | \
|
|
||||||
V4L2_STD_PAL_60
|
|
||||||
|
|
||||||
static struct saa7134_tvnorm tvnorms[] = {
|
static struct saa7134_tvnorm tvnorms[] = {
|
||||||
{
|
{
|
||||||
.name = "PAL", /* autodetect */
|
.name = "PAL", /* autodetect */
|
||||||
@@ -1123,8 +1117,7 @@ static struct videobuf_queue_ops video_qops = {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
static int saa7134_g_ctrl(struct file *file, void *priv,
|
int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
|
||||||
struct v4l2_control *c)
|
|
||||||
{
|
{
|
||||||
struct saa7134_fh *fh = priv;
|
struct saa7134_fh *fh = priv;
|
||||||
struct saa7134_dev *dev = fh->dev;
|
struct saa7134_dev *dev = fh->dev;
|
||||||
@@ -1173,8 +1166,7 @@ static int saa7134_g_ctrl(struct file *file, void *priv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int saa7134_s_ctrl(struct file *file, void *f,
|
int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
|
||||||
struct v4l2_control *c)
|
|
||||||
{
|
{
|
||||||
const struct v4l2_queryctrl* ctrl;
|
const struct v4l2_queryctrl* ctrl;
|
||||||
struct saa7134_fh *fh = f;
|
struct saa7134_fh *fh = f;
|
||||||
@@ -1680,8 +1672,7 @@ static int saa7134_s_fmt_overlay(struct file *file, void *priv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int saa7134_queryctrl(struct file *file, void *priv,
|
int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c)
|
||||||
struct v4l2_queryctrl *c)
|
|
||||||
{
|
{
|
||||||
const struct v4l2_queryctrl *ctrl;
|
const struct v4l2_queryctrl *ctrl;
|
||||||
|
|
||||||
|
@@ -566,6 +566,12 @@ struct saa7134_dev {
|
|||||||
|
|
||||||
#define saa_wait(us) { udelay(us); }
|
#define saa_wait(us) { udelay(us); }
|
||||||
|
|
||||||
|
#define SAA7134_NORMS (\
|
||||||
|
V4L2_STD_PAL | V4L2_STD_PAL_N | \
|
||||||
|
V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
|
||||||
|
V4L2_STD_NTSC | V4L2_STD_PAL_M | \
|
||||||
|
V4L2_STD_PAL_60)
|
||||||
|
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
/* saa7134-core.c */
|
/* saa7134-core.c */
|
||||||
|
|
||||||
@@ -629,12 +635,13 @@ extern unsigned int video_debug;
|
|||||||
extern struct video_device saa7134_video_template;
|
extern struct video_device saa7134_video_template;
|
||||||
extern struct video_device saa7134_radio_template;
|
extern struct video_device saa7134_radio_template;
|
||||||
|
|
||||||
|
int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c);
|
||||||
|
int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c);
|
||||||
|
int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c);
|
||||||
|
|
||||||
int saa7134_videoport_init(struct saa7134_dev *dev);
|
int saa7134_videoport_init(struct saa7134_dev *dev);
|
||||||
void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
|
void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
|
||||||
|
|
||||||
int saa7134_common_ioctl(struct saa7134_dev *dev,
|
|
||||||
unsigned int cmd, void *arg);
|
|
||||||
|
|
||||||
int saa7134_video_init1(struct saa7134_dev *dev);
|
int saa7134_video_init1(struct saa7134_dev *dev);
|
||||||
int saa7134_video_init2(struct saa7134_dev *dev);
|
int saa7134_video_init2(struct saa7134_dev *dev);
|
||||||
void saa7134_irq_video_signalchange(struct saa7134_dev *dev);
|
void saa7134_irq_video_signalchange(struct saa7134_dev *dev);
|
||||||
|
Reference in New Issue
Block a user