]> err.no Git - linux-2.6/commitdiff
V4L/DVB (6793): Convert saa7134-empress to video_ioctl2
authorMauro Carvalho Chehab <mchehab@infradead.org>
Tue, 11 Dec 2007 15:56:23 +0000 (12:56 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 25 Jan 2008 21:03:31 +0000 (19:03 -0200)
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>
drivers/media/video/saa7134/saa7134-empress.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/saa7134/saa7134.h

index 9322f44865b8341ee74976b76c0fb107e1bf0088..b1b01fa867203ff03a98673e3d7fddfc70e7334a 100644 (file)
@@ -161,152 +161,176 @@ ts_mmap(struct file *file, struct vm_area_struct * vma)
  * video_generic_ioctl (and maybe others).  userspace
  * 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)
+
+static int empress_querycap(struct file *file, void  *priv,
+                                       struct v4l2_capability *cap)
 {
-       struct saa7134_dev *dev = file->private_data;
-       struct v4l2_ext_controls *ctrls = arg;
-
-       if (debug > 1)
-               v4l_print_ioctl(dev->name,cmd);
-       switch (cmd) {
-       case VIDIOC_QUERYCAP:
-       {
-               struct v4l2_capability *cap = arg;
-
-               memset(cap,0,sizeof(*cap));
-               strcpy(cap->driver, "saa7134");
-               strlcpy(cap->card, saa7134_boards[dev->board].name,
-                       sizeof(cap->card));
-               sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
-               cap->version = SAA7134_VERSION_CODE;
-               cap->capabilities =
-                       V4L2_CAP_VIDEO_CAPTURE |
-                       V4L2_CAP_READWRITE |
-                       V4L2_CAP_STREAMING;
-               return 0;
-       }
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
+
+       strcpy(cap->driver, "saa7134");
+       strlcpy(cap->card, saa7134_boards[dev->board].name,
+               sizeof(cap->card));
+       sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
+       cap->version = SAA7134_VERSION_CODE;
+       cap->capabilities =
+               V4L2_CAP_VIDEO_CAPTURE |
+               V4L2_CAP_READWRITE |
+               V4L2_CAP_STREAMING;
+       return 0;
+}
 
-       /* --- input switching --------------------------------------- */
-       case VIDIOC_ENUMINPUT:
-       {
-               struct v4l2_input *i = arg;
+static int empress_enum_input(struct file *file, void *priv,
+                                       struct v4l2_input *i)
+{
+       if (i->index != 0)
+               return -EINVAL;
 
-               if (i->index != 0)
-                       return -EINVAL;
-               i->type = V4L2_INPUT_TYPE_CAMERA;
-               strcpy(i->name,"CCIR656");
-               return 0;
-       }
-       case VIDIOC_G_INPUT:
-       {
-               int *i = arg;
-               *i = 0;
-               return 0;
-       }
-       case VIDIOC_S_INPUT:
-       {
-               int *i = arg;
+       i->type = V4L2_INPUT_TYPE_CAMERA;
+       strcpy(i->name, "CCIR656");
 
-               if (*i != 0)
-                       return -EINVAL;
-               return 0;
-       }
-       /* --- capture ioctls ---------------------------------------- */
-
-       case VIDIOC_ENUM_FMT:
-       {
-               struct v4l2_fmtdesc *f = arg;
-               int index;
-
-               index = f->index;
-               if (index != 0)
-                       return -EINVAL;
-
-               memset(f,0,sizeof(*f));
-               f->index = index;
-               strlcpy(f->description, "MPEG TS", sizeof(f->description));
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               f->pixelformat = V4L2_PIX_FMT_MPEG;
-               return 0;
-       }
+       return 0;
+}
 
-       case VIDIOC_G_FMT:
-       {
-               struct v4l2_format *f = arg;
+static int empress_g_input(struct file *file, void *priv, unsigned int *i)
+{
+       *i = 0;
+       return 0;
+}
 
-               memset(f,0,sizeof(*f));
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+static int empress_s_input(struct file *file, void *priv, unsigned int i)
+{
+       if (i != 0)
+               return -EINVAL;
 
-               saa7134_i2c_call_clients(dev, cmd, arg);
-               f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
-               f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
-               return 0;
-       }
+       return 0;
+}
 
-       case VIDIOC_S_FMT:
-       {
-               struct v4l2_format *f = arg;
+static int empress_enum_fmt_cap(struct file *file, void  *priv,
+                                       struct v4l2_fmtdesc *f)
+{
+       if (f->index != 0)
+               return -EINVAL;
 
-               if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-                   return -EINVAL;
+       strlcpy(f->description, "MPEG TS", sizeof(f->description));
+       f->pixelformat = V4L2_PIX_FMT_MPEG;
 
-               saa7134_i2c_call_clients(dev, cmd, arg);
-               f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
-               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);
+static int empress_g_fmt_cap(struct file *file, void *priv,
+                               struct v4l2_format *f)
+{
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
 
-       case VIDIOC_QUERYBUF:
-               return videobuf_querybuf(&dev->empress_tsq,arg);
+       saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f);
 
-       case VIDIOC_QBUF:
-               return videobuf_qbuf(&dev->empress_tsq,arg);
+       f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+       f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
 
-       case VIDIOC_DQBUF:
-               return videobuf_dqbuf(&dev->empress_tsq,arg,
-                                     file->f_flags & O_NONBLOCK);
+       return 0;
+}
 
-       case VIDIOC_STREAMON:
-               return videobuf_streamon(&dev->empress_tsq);
+static int empress_s_fmt_cap(struct file *file, void *priv,
+                               struct v4l2_format *f)
+{
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
 
-       case VIDIOC_STREAMOFF:
-               return videobuf_streamoff(&dev->empress_tsq);
+       saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f);
 
-       case VIDIOC_QUERYCTRL:
-       case VIDIOC_G_CTRL:
-       case VIDIOC_S_CTRL:
-               return saa7134_common_ioctl(dev, cmd, arg);
+       f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
+       f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
 
-       case VIDIOC_S_EXT_CTRLS:
-               /* count == 0 is abused in saa6752hs.c, so that special
-                  case is handled here explicitly. */
-               if (ctrls->count == 0)
-                       return 0;
-               if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
-                       return -EINVAL;
-               saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, arg);
-               ts_init_encoder(dev);
-               return 0;
-       case VIDIOC_G_EXT_CTRLS:
-               if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
-                       return -EINVAL;
-               saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, arg);
+       return 0;
+}
+
+
+static int empress_reqbufs(struct file *file, void *priv,
+                                       struct v4l2_requestbuffers *p)
+{
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
+
+       return videobuf_reqbufs(&dev->empress_tsq, p);
+}
+
+static int empress_querybuf(struct file *file, void *priv,
+                                       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);
+}
+
+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;
+
+       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;
+
+       return videobuf_streamoff(&dev->empress_tsq);
+}
+
+static int empress_s_ext_ctrls(struct file *file, void *priv,
+                              struct v4l2_ext_controls *ctrls)
+{
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
+
+       /* count == 0 is abused in saa6752hs.c, so that special
+               case is handled here explicitly. */
+       if (ctrls->count == 0)
                return 0;
 
-       default:
-               return -ENOIOCTLCMD;
-       }
+       if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
+               return -EINVAL;
+
+       saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, ctrls);
+       ts_init_encoder(dev);
+
        return 0;
 }
 
-static int ts_ioctl(struct inode *inode, struct file *file,
-                    unsigned int cmd, unsigned long arg)
+static int empress_g_ext_ctrls(struct file *file, void *priv,
+                              struct v4l2_ext_controls *ctrls)
 {
-       return video_usercopy(inode, file, cmd, arg, ts_do_ioctl);
+       struct saa7134_fh *fh = priv;
+       struct saa7134_dev *dev = fh->dev;
+
+       if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
+               return -EINVAL;
+       saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, ctrls);
+
+       return 0;
 }
 
 static const struct file_operations ts_fops =
@@ -317,7 +341,7 @@ static const struct file_operations ts_fops =
        .read     = ts_read,
        .poll     = ts_poll,
        .mmap     = ts_mmap,
-       .ioctl    = ts_ioctl,
+       .ioctl    = video_ioctl2,
        .llseek   = no_llseek,
 };
 
@@ -330,6 +354,29 @@ static struct video_device saa7134_empress_template =
        .type2         = 0 /* FIXME */,
        .fops          = &ts_fops,
        .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)
index 6a29b75beaa69cde8e0d63f11be08b5423303f1e..9705f1f395093cf3cdc2efb6336ffcdffcaeebf1 100644 (file)
@@ -217,12 +217,6 @@ static struct saa7134_format formats[] = {
                .vbi_v_start_1 = 273,   \
                .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[] = {
        {
                .name          = "PAL", /* autodetect */
@@ -1123,8 +1117,7 @@ static struct videobuf_queue_ops video_qops = {
 
 /* ------------------------------------------------------------------ */
 
-static int saa7134_g_ctrl(struct file *file, void *priv,
-                                       struct v4l2_control *c)
+int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
 {
        struct saa7134_fh *fh = priv;
        struct saa7134_dev *dev = fh->dev;
@@ -1173,8 +1166,7 @@ static int saa7134_g_ctrl(struct file *file, void *priv,
        return 0;
 }
 
-static int saa7134_s_ctrl(struct file *file, void *f,
-                                       struct v4l2_control *c)
+int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
 {
        const struct v4l2_queryctrl* ctrl;
        struct saa7134_fh *fh = f;
@@ -1680,8 +1672,7 @@ static int saa7134_s_fmt_overlay(struct file *file, void *priv,
        return 0;
 }
 
-static int saa7134_queryctrl(struct file *file, void *priv,
-                                       struct v4l2_queryctrl *c)
+int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c)
 {
        const struct v4l2_queryctrl *ctrl;
 
index 8fb95094ba840d78dae57f814559c92468844960..3e77aeb7974fdfd81a01aa25f0f6f3ea75c91c8b 100644 (file)
@@ -566,6 +566,12 @@ struct saa7134_dev {
 
 #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                                              */
 
@@ -629,12 +635,13 @@ extern unsigned int video_debug;
 extern struct video_device saa7134_video_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);
 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_init2(struct saa7134_dev *dev);
 void saa7134_irq_video_signalchange(struct saa7134_dev *dev);