diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-12-11 10:56:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:03:31 -0500 |
commit | 2c10e8a8985e41addbbbe54b403418c27462f854 (patch) | |
tree | 077be89c28deb6848218bd78a690d46426ef3969 /drivers | |
parent | a9622391acbcdb124b55eb674dc5196eb55dc105 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-empress.c | 293 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-video.c | 15 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 13 |
3 files changed, 183 insertions, 138 deletions
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 9322f44865b8..b1b01fa86720 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -161,152 +161,176 @@ ts_mmap(struct file *file, struct vm_area_struct * vma) | |||
161 | * video_generic_ioctl (and maybe others). userspace | 161 | * video_generic_ioctl (and maybe others). userspace |
162 | * copying is done already, arg is a kernel pointer. | 162 | * copying is done already, arg is a kernel pointer. |
163 | */ | 163 | */ |
164 | static int ts_do_ioctl(struct inode *inode, struct file *file, | 164 | |
165 | unsigned int cmd, void *arg) | 165 | static int empress_querycap(struct file *file, void *priv, |
166 | struct v4l2_capability *cap) | ||
166 | { | 167 | { |
167 | struct saa7134_dev *dev = file->private_data; | 168 | struct saa7134_fh *fh = priv; |
168 | struct v4l2_ext_controls *ctrls = arg; | 169 | struct saa7134_dev *dev = fh->dev; |
169 | 170 | ||
170 | if (debug > 1) | 171 | strcpy(cap->driver, "saa7134"); |
171 | v4l_print_ioctl(dev->name,cmd); | 172 | strlcpy(cap->card, saa7134_boards[dev->board].name, |
172 | switch (cmd) { | 173 | sizeof(cap->card)); |
173 | case VIDIOC_QUERYCAP: | 174 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); |
174 | { | 175 | cap->version = SAA7134_VERSION_CODE; |
175 | struct v4l2_capability *cap = arg; | 176 | cap->capabilities = |
176 | 177 | V4L2_CAP_VIDEO_CAPTURE | | |
177 | memset(cap,0,sizeof(*cap)); | 178 | V4L2_CAP_READWRITE | |
178 | strcpy(cap->driver, "saa7134"); | 179 | V4L2_CAP_STREAMING; |
179 | strlcpy(cap->card, saa7134_boards[dev->board].name, | 180 | return 0; |
180 | sizeof(cap->card)); | 181 | } |
181 | sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); | ||
182 | cap->version = SAA7134_VERSION_CODE; | ||
183 | cap->capabilities = | ||
184 | V4L2_CAP_VIDEO_CAPTURE | | ||
185 | V4L2_CAP_READWRITE | | ||
186 | V4L2_CAP_STREAMING; | ||
187 | return 0; | ||
188 | } | ||
189 | 182 | ||
190 | /* --- input switching --------------------------------------- */ | 183 | static int empress_enum_input(struct file *file, void *priv, |
191 | case VIDIOC_ENUMINPUT: | 184 | struct v4l2_input *i) |
192 | { | 185 | { |
193 | struct v4l2_input *i = arg; | 186 | if (i->index != 0) |
187 | return -EINVAL; | ||
194 | 188 | ||
195 | if (i->index != 0) | 189 | i->type = V4L2_INPUT_TYPE_CAMERA; |
196 | return -EINVAL; | 190 | strcpy(i->name, "CCIR656"); |
197 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
198 | strcpy(i->name,"CCIR656"); | ||
199 | return 0; | ||
200 | } | ||
201 | case VIDIOC_G_INPUT: | ||
202 | { | ||
203 | int *i = arg; | ||
204 | *i = 0; | ||
205 | return 0; | ||
206 | } | ||
207 | case VIDIOC_S_INPUT: | ||
208 | { | ||
209 | int *i = arg; | ||
210 | 191 | ||
211 | if (*i != 0) | 192 | return 0; |
212 | return -EINVAL; | 193 | } |
213 | return 0; | ||
214 | } | ||
215 | /* --- capture ioctls ---------------------------------------- */ | ||
216 | |||
217 | case VIDIOC_ENUM_FMT: | ||
218 | { | ||
219 | struct v4l2_fmtdesc *f = arg; | ||
220 | int index; | ||
221 | |||
222 | index = f->index; | ||
223 | if (index != 0) | ||
224 | return -EINVAL; | ||
225 | |||
226 | memset(f,0,sizeof(*f)); | ||
227 | f->index = index; | ||
228 | strlcpy(f->description, "MPEG TS", sizeof(f->description)); | ||
229 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
230 | f->pixelformat = V4L2_PIX_FMT_MPEG; | ||
231 | return 0; | ||
232 | } | ||
233 | 194 | ||
234 | case VIDIOC_G_FMT: | 195 | static int empress_g_input(struct file *file, void *priv, unsigned int *i) |
235 | { | 196 | { |
236 | struct v4l2_format *f = arg; | 197 | *i = 0; |
198 | return 0; | ||
199 | } | ||
237 | 200 | ||
238 | memset(f,0,sizeof(*f)); | 201 | static int empress_s_input(struct file *file, void *priv, unsigned int i) |
239 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 202 | { |
203 | if (i != 0) | ||
204 | return -EINVAL; | ||
240 | 205 | ||
241 | saa7134_i2c_call_clients(dev, cmd, arg); | 206 | return 0; |
242 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 207 | } |
243 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; | ||
244 | return 0; | ||
245 | } | ||
246 | 208 | ||
247 | case VIDIOC_S_FMT: | 209 | static int empress_enum_fmt_cap(struct file *file, void *priv, |
248 | { | 210 | struct v4l2_fmtdesc *f) |
249 | struct v4l2_format *f = arg; | 211 | { |
212 | if (f->index != 0) | ||
213 | return -EINVAL; | ||
250 | 214 | ||
251 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 215 | strlcpy(f->description, "MPEG TS", sizeof(f->description)); |
252 | return -EINVAL; | 216 | f->pixelformat = V4L2_PIX_FMT_MPEG; |
253 | 217 | ||
254 | saa7134_i2c_call_clients(dev, cmd, arg); | 218 | return 0; |
255 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 219 | } |
256 | f->fmt.pix.sizeimage = TS_PACKET_SIZE* dev->ts.nr_packets; | ||
257 | return 0; | ||
258 | } | ||
259 | 220 | ||
260 | case VIDIOC_REQBUFS: | 221 | static int empress_g_fmt_cap(struct file *file, void *priv, |
261 | return videobuf_reqbufs(&dev->empress_tsq,arg); | 222 | struct v4l2_format *f) |
223 | { | ||
224 | struct saa7134_fh *fh = priv; | ||
225 | struct saa7134_dev *dev = fh->dev; | ||
262 | 226 | ||
263 | case VIDIOC_QUERYBUF: | 227 | saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f); |
264 | return videobuf_querybuf(&dev->empress_tsq,arg); | ||
265 | 228 | ||
266 | case VIDIOC_QBUF: | 229 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
267 | return videobuf_qbuf(&dev->empress_tsq,arg); | 230 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; |
268 | 231 | ||
269 | case VIDIOC_DQBUF: | 232 | return 0; |
270 | return videobuf_dqbuf(&dev->empress_tsq,arg, | 233 | } |
271 | file->f_flags & O_NONBLOCK); | ||
272 | 234 | ||
273 | case VIDIOC_STREAMON: | 235 | static int empress_s_fmt_cap(struct file *file, void *priv, |
274 | return videobuf_streamon(&dev->empress_tsq); | 236 | struct v4l2_format *f) |
237 | { | ||
238 | struct saa7134_fh *fh = priv; | ||
239 | struct saa7134_dev *dev = fh->dev; | ||
275 | 240 | ||
276 | case VIDIOC_STREAMOFF: | 241 | saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f); |
277 | return videobuf_streamoff(&dev->empress_tsq); | ||
278 | 242 | ||
279 | case VIDIOC_QUERYCTRL: | 243 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
280 | case VIDIOC_G_CTRL: | 244 | f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; |
281 | case VIDIOC_S_CTRL: | ||
282 | return saa7134_common_ioctl(dev, cmd, arg); | ||
283 | 245 | ||
284 | case VIDIOC_S_EXT_CTRLS: | 246 | return 0; |
285 | /* count == 0 is abused in saa6752hs.c, so that special | 247 | } |
286 | case is handled here explicitly. */ | 248 | |
287 | if (ctrls->count == 0) | 249 | |
288 | return 0; | 250 | static int empress_reqbufs(struct file *file, void *priv, |
289 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 251 | struct v4l2_requestbuffers *p) |
290 | return -EINVAL; | 252 | { |
291 | saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, arg); | 253 | struct saa7134_fh *fh = priv; |
292 | ts_init_encoder(dev); | 254 | struct saa7134_dev *dev = fh->dev; |
293 | return 0; | 255 | |
294 | case VIDIOC_G_EXT_CTRLS: | 256 | return videobuf_reqbufs(&dev->empress_tsq, p); |
295 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 257 | } |
296 | return -EINVAL; | 258 | |
297 | saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, arg); | 259 | static int empress_querybuf(struct file *file, void *priv, |
260 | struct v4l2_buffer *b) | ||
261 | { | ||
262 | struct saa7134_fh *fh = priv; | ||
263 | struct saa7134_dev *dev = fh->dev; | ||
264 | |||
265 | return videobuf_querybuf(&dev->empress_tsq, b); | ||
266 | } | ||
267 | |||
268 | static int empress_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
269 | { | ||
270 | struct saa7134_fh *fh = priv; | ||
271 | struct saa7134_dev *dev = fh->dev; | ||
272 | |||
273 | return videobuf_qbuf(&dev->empress_tsq, b); | ||
274 | } | ||
275 | |||
276 | static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
277 | { | ||
278 | struct saa7134_fh *fh = priv; | ||
279 | struct saa7134_dev *dev = fh->dev; | ||
280 | |||
281 | return videobuf_dqbuf(&dev->empress_tsq, b, | ||
282 | file->f_flags & O_NONBLOCK); | ||
283 | } | ||
284 | |||
285 | static int empress_streamon(struct file *file, void *priv, | ||
286 | enum v4l2_buf_type type) | ||
287 | { | ||
288 | struct saa7134_fh *fh = priv; | ||
289 | struct saa7134_dev *dev = fh->dev; | ||
290 | |||
291 | return videobuf_streamon(&dev->empress_tsq); | ||
292 | } | ||
293 | |||
294 | static int empress_streamoff(struct file *file, void *priv, | ||
295 | enum v4l2_buf_type type) | ||
296 | { | ||
297 | struct saa7134_fh *fh = priv; | ||
298 | struct saa7134_dev *dev = fh->dev; | ||
299 | |||
300 | return videobuf_streamoff(&dev->empress_tsq); | ||
301 | } | ||
302 | |||
303 | static int empress_s_ext_ctrls(struct file *file, void *priv, | ||
304 | struct v4l2_ext_controls *ctrls) | ||
305 | { | ||
306 | struct saa7134_fh *fh = priv; | ||
307 | struct saa7134_dev *dev = fh->dev; | ||
308 | |||
309 | /* count == 0 is abused in saa6752hs.c, so that special | ||
310 | case is handled here explicitly. */ | ||
311 | if (ctrls->count == 0) | ||
298 | return 0; | 312 | return 0; |
299 | 313 | ||
300 | default: | 314 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
301 | return -ENOIOCTLCMD; | 315 | return -EINVAL; |
302 | } | 316 | |
317 | saa7134_i2c_call_clients(dev, VIDIOC_S_EXT_CTRLS, ctrls); | ||
318 | ts_init_encoder(dev); | ||
319 | |||
303 | return 0; | 320 | return 0; |
304 | } | 321 | } |
305 | 322 | ||
306 | static int ts_ioctl(struct inode *inode, struct file *file, | 323 | static int empress_g_ext_ctrls(struct file *file, void *priv, |
307 | unsigned int cmd, unsigned long arg) | 324 | struct v4l2_ext_controls *ctrls) |
308 | { | 325 | { |
309 | return video_usercopy(inode, file, cmd, arg, ts_do_ioctl); | 326 | struct saa7134_fh *fh = priv; |
327 | struct saa7134_dev *dev = fh->dev; | ||
328 | |||
329 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
330 | return -EINVAL; | ||
331 | saa7134_i2c_call_clients(dev, VIDIOC_G_EXT_CTRLS, ctrls); | ||
332 | |||
333 | return 0; | ||
310 | } | 334 | } |
311 | 335 | ||
312 | static const struct file_operations ts_fops = | 336 | static const struct file_operations ts_fops = |
@@ -317,7 +341,7 @@ static const struct file_operations ts_fops = | |||
317 | .read = ts_read, | 341 | .read = ts_read, |
318 | .poll = ts_poll, | 342 | .poll = ts_poll, |
319 | .mmap = ts_mmap, | 343 | .mmap = ts_mmap, |
320 | .ioctl = ts_ioctl, | 344 | .ioctl = video_ioctl2, |
321 | .llseek = no_llseek, | 345 | .llseek = no_llseek, |
322 | }; | 346 | }; |
323 | 347 | ||
@@ -330,6 +354,29 @@ static struct video_device saa7134_empress_template = | |||
330 | .type2 = 0 /* FIXME */, | 354 | .type2 = 0 /* FIXME */, |
331 | .fops = &ts_fops, | 355 | .fops = &ts_fops, |
332 | .minor = -1, | 356 | .minor = -1, |
357 | |||
358 | .vidioc_querycap = empress_querycap, | ||
359 | .vidioc_enum_fmt_cap = empress_enum_fmt_cap, | ||
360 | .vidioc_s_fmt_cap = empress_s_fmt_cap, | ||
361 | .vidioc_g_fmt_cap = empress_g_fmt_cap, | ||
362 | .vidioc_reqbufs = empress_reqbufs, | ||
363 | .vidioc_querybuf = empress_querybuf, | ||
364 | .vidioc_qbuf = empress_qbuf, | ||
365 | .vidioc_dqbuf = empress_dqbuf, | ||
366 | .vidioc_streamon = empress_streamon, | ||
367 | .vidioc_streamoff = empress_streamoff, | ||
368 | .vidioc_s_ext_ctrls = empress_s_ext_ctrls, | ||
369 | .vidioc_g_ext_ctrls = empress_g_ext_ctrls, | ||
370 | .vidioc_enum_input = empress_enum_input, | ||
371 | .vidioc_g_input = empress_g_input, | ||
372 | .vidioc_s_input = empress_s_input, | ||
373 | |||
374 | .vidioc_queryctrl = saa7134_queryctrl, | ||
375 | .vidioc_g_ctrl = saa7134_g_ctrl, | ||
376 | .vidioc_s_ctrl = saa7134_s_ctrl, | ||
377 | |||
378 | .tvnorms = SAA7134_NORMS, | ||
379 | .current_norm = V4L2_STD_PAL, | ||
333 | }; | 380 | }; |
334 | 381 | ||
335 | static void empress_signal_update(struct work_struct *work) | 382 | static void empress_signal_update(struct work_struct *work) |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 6a29b75beaa6..9705f1f39509 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -217,12 +217,6 @@ static struct saa7134_format formats[] = { | |||
217 | .vbi_v_start_1 = 273, \ | 217 | .vbi_v_start_1 = 273, \ |
218 | .src_timing = 7 | 218 | .src_timing = 7 |
219 | 219 | ||
220 | #define SAA7134_NORMS \ | ||
221 | V4L2_STD_PAL | V4L2_STD_PAL_N | \ | ||
222 | V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \ | ||
223 | V4L2_STD_NTSC | V4L2_STD_PAL_M | \ | ||
224 | V4L2_STD_PAL_60 | ||
225 | |||
226 | static struct saa7134_tvnorm tvnorms[] = { | 220 | static struct saa7134_tvnorm tvnorms[] = { |
227 | { | 221 | { |
228 | .name = "PAL", /* autodetect */ | 222 | .name = "PAL", /* autodetect */ |
@@ -1123,8 +1117,7 @@ static struct videobuf_queue_ops video_qops = { | |||
1123 | 1117 | ||
1124 | /* ------------------------------------------------------------------ */ | 1118 | /* ------------------------------------------------------------------ */ |
1125 | 1119 | ||
1126 | static int saa7134_g_ctrl(struct file *file, void *priv, | 1120 | int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c) |
1127 | struct v4l2_control *c) | ||
1128 | { | 1121 | { |
1129 | struct saa7134_fh *fh = priv; | 1122 | struct saa7134_fh *fh = priv; |
1130 | struct saa7134_dev *dev = fh->dev; | 1123 | struct saa7134_dev *dev = fh->dev; |
@@ -1173,8 +1166,7 @@ static int saa7134_g_ctrl(struct file *file, void *priv, | |||
1173 | return 0; | 1166 | return 0; |
1174 | } | 1167 | } |
1175 | 1168 | ||
1176 | static int saa7134_s_ctrl(struct file *file, void *f, | 1169 | int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c) |
1177 | struct v4l2_control *c) | ||
1178 | { | 1170 | { |
1179 | const struct v4l2_queryctrl* ctrl; | 1171 | const struct v4l2_queryctrl* ctrl; |
1180 | struct saa7134_fh *fh = f; | 1172 | struct saa7134_fh *fh = f; |
@@ -1680,8 +1672,7 @@ static int saa7134_s_fmt_overlay(struct file *file, void *priv, | |||
1680 | return 0; | 1672 | return 0; |
1681 | } | 1673 | } |
1682 | 1674 | ||
1683 | static int saa7134_queryctrl(struct file *file, void *priv, | 1675 | int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c) |
1684 | struct v4l2_queryctrl *c) | ||
1685 | { | 1676 | { |
1686 | const struct v4l2_queryctrl *ctrl; | 1677 | const struct v4l2_queryctrl *ctrl; |
1687 | 1678 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 8fb95094ba84..3e77aeb7974f 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -566,6 +566,12 @@ struct saa7134_dev { | |||
566 | 566 | ||
567 | #define saa_wait(us) { udelay(us); } | 567 | #define saa_wait(us) { udelay(us); } |
568 | 568 | ||
569 | #define SAA7134_NORMS (\ | ||
570 | V4L2_STD_PAL | V4L2_STD_PAL_N | \ | ||
571 | V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \ | ||
572 | V4L2_STD_NTSC | V4L2_STD_PAL_M | \ | ||
573 | V4L2_STD_PAL_60) | ||
574 | |||
569 | /* ----------------------------------------------------------- */ | 575 | /* ----------------------------------------------------------- */ |
570 | /* saa7134-core.c */ | 576 | /* saa7134-core.c */ |
571 | 577 | ||
@@ -629,12 +635,13 @@ extern unsigned int video_debug; | |||
629 | extern struct video_device saa7134_video_template; | 635 | extern struct video_device saa7134_video_template; |
630 | extern struct video_device saa7134_radio_template; | 636 | extern struct video_device saa7134_radio_template; |
631 | 637 | ||
638 | int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c); | ||
639 | int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c); | ||
640 | int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c); | ||
641 | |||
632 | int saa7134_videoport_init(struct saa7134_dev *dev); | 642 | int saa7134_videoport_init(struct saa7134_dev *dev); |
633 | void saa7134_set_tvnorm_hw(struct saa7134_dev *dev); | 643 | void saa7134_set_tvnorm_hw(struct saa7134_dev *dev); |
634 | 644 | ||
635 | int saa7134_common_ioctl(struct saa7134_dev *dev, | ||
636 | unsigned int cmd, void *arg); | ||
637 | |||
638 | int saa7134_video_init1(struct saa7134_dev *dev); | 645 | int saa7134_video_init1(struct saa7134_dev *dev); |
639 | int saa7134_video_init2(struct saa7134_dev *dev); | 646 | int saa7134_video_init2(struct saa7134_dev *dev); |
640 | void saa7134_irq_video_signalchange(struct saa7134_dev *dev); | 647 | void saa7134_irq_video_signalchange(struct saa7134_dev *dev); |