aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-03-24 15:33:14 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-23 12:14:53 -0400
commit753aee7738ed2ee8c810524ee32b556ac7617f2e (patch)
tree06d6bfb97f0e07606afa4e79529b31d69609349d /drivers
parent27a36df63b5befa3b142d4aef54f3a240c8bd977 (diff)
[media] em28xx: move v4l2 frame resolutions and scale data from struct em28xx to struct v4l2
The em28xx scaler data are used only for analog video. Move them to struct em28xx_v4l2. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/usb/em28xx/em28xx-vbi.c10
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c80
-rw-r--r--drivers/media/usb/em28xx/em28xx.h16
3 files changed, 61 insertions, 45 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c
index db3d655600df..6d7f657f6f55 100644
--- a/drivers/media/usb/em28xx/em28xx-vbi.c
+++ b/drivers/media/usb/em28xx/em28xx-vbi.c
@@ -47,12 +47,13 @@ static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
47 unsigned int sizes[], void *alloc_ctxs[]) 47 unsigned int sizes[], void *alloc_ctxs[])
48{ 48{
49 struct em28xx *dev = vb2_get_drv_priv(vq); 49 struct em28xx *dev = vb2_get_drv_priv(vq);
50 struct em28xx_v4l2 *v4l2 = dev->v4l2;
50 unsigned long size; 51 unsigned long size;
51 52
52 if (fmt) 53 if (fmt)
53 size = fmt->fmt.pix.sizeimage; 54 size = fmt->fmt.pix.sizeimage;
54 else 55 else
55 size = dev->vbi_width * dev->vbi_height * 2; 56 size = v4l2->vbi_width * v4l2->vbi_height * 2;
56 57
57 if (0 == *nbuffers) 58 if (0 == *nbuffers)
58 *nbuffers = 32; 59 *nbuffers = 32;
@@ -69,11 +70,12 @@ static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
69 70
70static int vbi_buffer_prepare(struct vb2_buffer *vb) 71static int vbi_buffer_prepare(struct vb2_buffer *vb)
71{ 72{
72 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); 73 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue);
73 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); 74 struct em28xx_v4l2 *v4l2 = dev->v4l2;
75 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb);
74 unsigned long size; 76 unsigned long size;
75 77
76 size = dev->vbi_width * dev->vbi_height * 2; 78 size = v4l2->vbi_width * v4l2->vbi_height * 2;
77 79
78 if (vb2_plane_size(vb, 0) < size) { 80 if (vb2_plane_size(vb, 0) < size) {
79 printk(KERN_INFO "%s data will not fit into plane (%lu < %lu)\n", 81 printk(KERN_INFO "%s data will not fit into plane (%lu < %lu)\n",
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 1e2ea6032f5f..eeb58ebd98f6 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -218,6 +218,7 @@ static int em28xx_set_outfmt(struct em28xx *dev)
218{ 218{
219 int ret; 219 int ret;
220 u8 fmt, vinctrl; 220 u8 fmt, vinctrl;
221 struct em28xx_v4l2 *v4l2 = dev->v4l2;
221 222
222 fmt = dev->format->reg; 223 fmt = dev->format->reg;
223 if (!dev->is_em25xx) 224 if (!dev->is_em25xx)
@@ -243,8 +244,8 @@ static int em28xx_set_outfmt(struct em28xx *dev)
243 if (em28xx_vbi_supported(dev) == 1) { 244 if (em28xx_vbi_supported(dev) == 1) {
244 vinctrl |= EM28XX_VINCTRL_VBI_RAW; 245 vinctrl |= EM28XX_VINCTRL_VBI_RAW;
245 em28xx_write_reg(dev, EM28XX_R34_VBI_START_H, 0x00); 246 em28xx_write_reg(dev, EM28XX_R34_VBI_START_H, 0x00);
246 em28xx_write_reg(dev, EM28XX_R36_VBI_WIDTH, dev->vbi_width/4); 247 em28xx_write_reg(dev, EM28XX_R36_VBI_WIDTH, v4l2->vbi_width/4);
247 em28xx_write_reg(dev, EM28XX_R37_VBI_HEIGHT, dev->vbi_height); 248 em28xx_write_reg(dev, EM28XX_R37_VBI_HEIGHT, v4l2->vbi_height);
248 if (dev->norm & V4L2_STD_525_60) { 249 if (dev->norm & V4L2_STD_525_60) {
249 /* NTSC */ 250 /* NTSC */
250 em28xx_write_reg(dev, EM28XX_R35_VBI_START_V, 0x09); 251 em28xx_write_reg(dev, EM28XX_R35_VBI_START_V, 0x09);
@@ -323,16 +324,16 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
323/* FIXME: this only function read values from dev */ 324/* FIXME: this only function read values from dev */
324static int em28xx_resolution_set(struct em28xx *dev) 325static int em28xx_resolution_set(struct em28xx *dev)
325{ 326{
326 int width, height; 327 struct em28xx_v4l2 *v4l2 = dev->v4l2;
327 width = norm_maxw(dev); 328 int width = norm_maxw(dev);
328 height = norm_maxh(dev); 329 int height = norm_maxh(dev);
329 330
330 /* Properly setup VBI */ 331 /* Properly setup VBI */
331 dev->vbi_width = 720; 332 v4l2->vbi_width = 720;
332 if (dev->norm & V4L2_STD_525_60) 333 if (dev->norm & V4L2_STD_525_60)
333 dev->vbi_height = 12; 334 v4l2->vbi_height = 12;
334 else 335 else
335 dev->vbi_height = 18; 336 v4l2->vbi_height = 18;
336 337
337 em28xx_set_outfmt(dev); 338 em28xx_set_outfmt(dev);
338 339
@@ -350,15 +351,16 @@ static int em28xx_resolution_set(struct em28xx *dev)
350 else 351 else
351 em28xx_capture_area_set(dev, 0, 0, width, height); 352 em28xx_capture_area_set(dev, 0, 0, width, height);
352 353
353 return em28xx_scaler_set(dev, dev->hscale, dev->vscale); 354 return em28xx_scaler_set(dev, v4l2->hscale, v4l2->vscale);
354} 355}
355 356
356/* Set USB alternate setting for analog video */ 357/* Set USB alternate setting for analog video */
357static int em28xx_set_alternate(struct em28xx *dev) 358static int em28xx_set_alternate(struct em28xx *dev)
358{ 359{
360 struct em28xx_v4l2 *v4l2 = dev->v4l2;
359 int errCode; 361 int errCode;
360 int i; 362 int i;
361 unsigned int min_pkt_size = dev->width * 2 + 4; 363 unsigned int min_pkt_size = v4l2->width * 2 + 4;
362 364
363 /* NOTE: for isoc transfers, only alt settings > 0 are allowed 365 /* NOTE: for isoc transfers, only alt settings > 0 are allowed
364 bulk transfers seem to work only with alt=0 ! */ 366 bulk transfers seem to work only with alt=0 ! */
@@ -375,7 +377,7 @@ static int em28xx_set_alternate(struct em28xx *dev)
375 the frame size should be increased, otherwise, only 377 the frame size should be increased, otherwise, only
376 green screen will be received. 378 green screen will be received.
377 */ 379 */
378 if (dev->width * 2 * dev->height > 720 * 240 * 2) 380 if (v4l2->width * 2 * v4l2->height > 720 * 240 * 2)
379 min_pkt_size *= 2; 381 min_pkt_size *= 2;
380 382
381 for (i = 0; i < dev->num_alt; i++) { 383 for (i = 0; i < dev->num_alt; i++) {
@@ -445,7 +447,7 @@ static void em28xx_copy_video(struct em28xx *dev,
445{ 447{
446 void *fieldstart, *startwrite, *startread; 448 void *fieldstart, *startwrite, *startread;
447 int linesdone, currlinedone, offset, lencopy, remain; 449 int linesdone, currlinedone, offset, lencopy, remain;
448 int bytesperline = dev->width << 1; 450 int bytesperline = dev->v4l2->width << 1;
449 451
450 if (buf->pos + len > buf->length) 452 if (buf->pos + len > buf->length)
451 len = buf->length - buf->pos; 453 len = buf->length - buf->pos;
@@ -531,7 +533,7 @@ static void em28xx_copy_vbi(struct em28xx *dev,
531 offset = buf->pos; 533 offset = buf->pos;
532 /* Make sure the bottom field populates the second half of the frame */ 534 /* Make sure the bottom field populates the second half of the frame */
533 if (buf->top_field == 0) 535 if (buf->top_field == 0)
534 offset += dev->vbi_width * dev->vbi_height; 536 offset += dev->v4l2->vbi_width * dev->v4l2->vbi_height;
535 537
536 memcpy(buf->vb_buf + offset, usb_buf, len); 538 memcpy(buf->vb_buf + offset, usb_buf, len);
537 buf->pos += len; 539 buf->pos += len;
@@ -627,6 +629,7 @@ static inline void process_frame_data_em28xx(struct em28xx *dev,
627 unsigned char *data_pkt, 629 unsigned char *data_pkt,
628 unsigned int data_len) 630 unsigned int data_len)
629{ 631{
632 struct em28xx_v4l2 *v4l2 = dev->v4l2;
630 struct em28xx_buffer *buf = dev->usb_ctl.vid_buf; 633 struct em28xx_buffer *buf = dev->usb_ctl.vid_buf;
631 struct em28xx_buffer *vbi_buf = dev->usb_ctl.vbi_buf; 634 struct em28xx_buffer *vbi_buf = dev->usb_ctl.vbi_buf;
632 struct em28xx_dmaqueue *dma_q = &dev->vidq; 635 struct em28xx_dmaqueue *dma_q = &dev->vidq;
@@ -671,7 +674,7 @@ static inline void process_frame_data_em28xx(struct em28xx *dev,
671 } 674 }
672 675
673 if (dev->capture_type == 1) { 676 if (dev->capture_type == 1) {
674 int vbi_size = dev->vbi_width * dev->vbi_height; 677 int vbi_size = v4l2->vbi_width * v4l2->vbi_height;
675 int vbi_data_len = ((dev->vbi_read + data_len) > vbi_size) ? 678 int vbi_data_len = ((dev->vbi_read + data_len) > vbi_size) ?
676 (vbi_size - dev->vbi_read) : data_len; 679 (vbi_size - dev->vbi_read) : data_len;
677 680
@@ -865,12 +868,14 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
865 unsigned int sizes[], void *alloc_ctxs[]) 868 unsigned int sizes[], void *alloc_ctxs[])
866{ 869{
867 struct em28xx *dev = vb2_get_drv_priv(vq); 870 struct em28xx *dev = vb2_get_drv_priv(vq);
871 struct em28xx_v4l2 *v4l2 = dev->v4l2;
868 unsigned long size; 872 unsigned long size;
869 873
870 if (fmt) 874 if (fmt)
871 size = fmt->fmt.pix.sizeimage; 875 size = fmt->fmt.pix.sizeimage;
872 else 876 else
873 size = (dev->width * dev->height * dev->format->depth + 7) >> 3; 877 size =
878 (v4l2->width * v4l2->height * dev->format->depth + 7) >> 3;
874 879
875 if (size == 0) 880 if (size == 0)
876 return -EINVAL; 881 return -EINVAL;
@@ -888,12 +893,13 @@ static int
888buffer_prepare(struct vb2_buffer *vb) 893buffer_prepare(struct vb2_buffer *vb)
889{ 894{
890 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); 895 struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue);
896 struct em28xx_v4l2 *v4l2 = dev->v4l2;
891 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); 897 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb);
892 unsigned long size; 898 unsigned long size;
893 899
894 em28xx_videodbg("%s, field=%d\n", __func__, vb->v4l2_buf.field); 900 em28xx_videodbg("%s, field=%d\n", __func__, vb->v4l2_buf.field);
895 901
896 size = (dev->width * dev->height * dev->format->depth + 7) >> 3; 902 size = (v4l2->width * v4l2->height * dev->format->depth + 7) >> 3;
897 903
898 if (vb2_plane_size(vb, 0) < size) { 904 if (vb2_plane_size(vb, 0) < size) {
899 em28xx_videodbg("%s data will not fit into plane (%lu < %lu)\n", 905 em28xx_videodbg("%s data will not fit into plane (%lu < %lu)\n",
@@ -1212,12 +1218,13 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1212{ 1218{
1213 struct em28xx_fh *fh = priv; 1219 struct em28xx_fh *fh = priv;
1214 struct em28xx *dev = fh->dev; 1220 struct em28xx *dev = fh->dev;
1221 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1215 1222
1216 f->fmt.pix.width = dev->width; 1223 f->fmt.pix.width = v4l2->width;
1217 f->fmt.pix.height = dev->height; 1224 f->fmt.pix.height = v4l2->height;
1218 f->fmt.pix.pixelformat = dev->format->fourcc; 1225 f->fmt.pix.pixelformat = dev->format->fourcc;
1219 f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3; 1226 f->fmt.pix.bytesperline = (v4l2->width * dev->format->depth + 7) >> 3;
1220 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; 1227 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * v4l2->height;
1221 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1228 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1222 1229
1223 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ 1230 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
@@ -1300,17 +1307,19 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc,
1300 unsigned width, unsigned height) 1307 unsigned width, unsigned height)
1301{ 1308{
1302 struct em28xx_fmt *fmt; 1309 struct em28xx_fmt *fmt;
1310 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1303 1311
1304 fmt = format_by_fourcc(fourcc); 1312 fmt = format_by_fourcc(fourcc);
1305 if (!fmt) 1313 if (!fmt)
1306 return -EINVAL; 1314 return -EINVAL;
1307 1315
1308 dev->format = fmt; 1316 dev->format = fmt;
1309 dev->width = width; 1317 v4l2->width = width;
1310 dev->height = height; 1318 v4l2->height = height;
1311 1319
1312 /* set new image size */ 1320 /* set new image size */
1313 size_to_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1321 size_to_scale(dev, v4l2->width, v4l2->height,
1322 &v4l2->hscale, &v4l2->vscale);
1314 1323
1315 em28xx_resolution_set(dev); 1324 em28xx_resolution_set(dev);
1316 1325
@@ -1353,8 +1362,9 @@ static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *norm)
1353 1362
1354static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) 1363static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
1355{ 1364{
1356 struct em28xx_fh *fh = priv; 1365 struct em28xx_fh *fh = priv;
1357 struct em28xx *dev = fh->dev; 1366 struct em28xx *dev = fh->dev;
1367 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1358 struct v4l2_format f; 1368 struct v4l2_format f;
1359 1369
1360 if (norm == dev->norm) 1370 if (norm == dev->norm)
@@ -1371,12 +1381,13 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
1371 vidioc_try_fmt_vid_cap(file, priv, &f); 1381 vidioc_try_fmt_vid_cap(file, priv, &f);
1372 1382
1373 /* set new image size */ 1383 /* set new image size */
1374 dev->width = f.fmt.pix.width; 1384 v4l2->width = f.fmt.pix.width;
1375 dev->height = f.fmt.pix.height; 1385 v4l2->height = f.fmt.pix.height;
1376 size_to_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); 1386 size_to_scale(dev, v4l2->width, v4l2->height,
1387 &v4l2->hscale, &v4l2->vscale);
1377 1388
1378 em28xx_resolution_set(dev); 1389 em28xx_resolution_set(dev);
1379 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, core, s_std, dev->norm); 1390 v4l2_device_call_all(&v4l2->v4l2_dev, 0, core, s_std, dev->norm);
1380 1391
1381 return 0; 1392 return 0;
1382} 1393}
@@ -1780,16 +1791,17 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
1780static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, 1791static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
1781 struct v4l2_format *format) 1792 struct v4l2_format *format)
1782{ 1793{
1783 struct em28xx_fh *fh = priv; 1794 struct em28xx_fh *fh = priv;
1784 struct em28xx *dev = fh->dev; 1795 struct em28xx *dev = fh->dev;
1796 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1785 1797
1786 format->fmt.vbi.samples_per_line = dev->vbi_width; 1798 format->fmt.vbi.samples_per_line = v4l2->vbi_width;
1787 format->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 1799 format->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
1788 format->fmt.vbi.offset = 0; 1800 format->fmt.vbi.offset = 0;
1789 format->fmt.vbi.flags = 0; 1801 format->fmt.vbi.flags = 0;
1790 format->fmt.vbi.sampling_rate = 6750000 * 4 / 2; 1802 format->fmt.vbi.sampling_rate = 6750000 * 4 / 2;
1791 format->fmt.vbi.count[0] = dev->vbi_height; 1803 format->fmt.vbi.count[0] = v4l2->vbi_height;
1792 format->fmt.vbi.count[1] = dev->vbi_height; 1804 format->fmt.vbi.count[1] = v4l2->vbi_height;
1793 memset(format->fmt.vbi.reserved, 0, sizeof(format->fmt.vbi.reserved)); 1805 memset(format->fmt.vbi.reserved, 0, sizeof(format->fmt.vbi.reserved));
1794 1806
1795 /* Varies by video standard (NTSC, PAL, etc.) */ 1807 /* Varies by video standard (NTSC, PAL, etc.) */
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 71d88570395a..a1b76f796f55 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -515,6 +515,14 @@ struct em28xx_v4l2 {
515 struct vb2_queue vb_vbiq; 515 struct vb2_queue vb_vbiq;
516 struct mutex vb_queue_lock; 516 struct mutex vb_queue_lock;
517 struct mutex vb_vbi_queue_lock; 517 struct mutex vb_vbi_queue_lock;
518
519 /* Frame properties */
520 int width; /* current frame width */
521 int height; /* current frame height */
522 unsigned hscale; /* horizontal scale factor (see datasheet) */
523 unsigned vscale; /* vertical scale factor (see datasheet) */
524 unsigned int vbi_width;
525 unsigned int vbi_height; /* lines per field */
518}; 526};
519 527
520struct em28xx_audio { 528struct em28xx_audio {
@@ -632,11 +640,7 @@ struct em28xx {
632 unsigned int ctl_aoutput;/* selected audio output */ 640 unsigned int ctl_aoutput;/* selected audio output */
633 int mute; 641 int mute;
634 int volume; 642 int volume;
635 /* frame properties */ 643
636 int width; /* current frame width */
637 int height; /* current frame height */
638 unsigned hscale; /* horizontal scale factor (see datasheet) */
639 unsigned vscale; /* vertical scale factor (see datasheet) */
640 int interlaced; /* 1=interlace fileds, 0=just top fileds */ 644 int interlaced; /* 1=interlace fileds, 0=just top fileds */
641 645
642 unsigned long hash; /* eeprom hash - for boards with generic ID */ 646 unsigned long hash; /* eeprom hash - for boards with generic ID */
@@ -647,8 +651,6 @@ struct em28xx {
647 int capture_type; 651 int capture_type;
648 unsigned char top_field:1; 652 unsigned char top_field:1;
649 int vbi_read; 653 int vbi_read;
650 unsigned int vbi_width;
651 unsigned int vbi_height; /* lines per field */
652 654
653 struct work_struct request_module_wk; 655 struct work_struct request_module_wk;
654 656