Commit 79a6fb1acec93ef829a59d88429aafddf42793d3

Authored by Linus Torvalds

Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:
 "Some driver fixes (em28xx, coda, usbtv, s5p, hdpvr and ml86v7667) and
  a fix for media DocBook"

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  [media] em28xx: fix assignment of the eeprom data
  [media] hdpvr: fix iteration over uninitialized lists in hdpvr_probe()
  [media] usbtv: fix dependency
  [media] usbtv: Throw corrupted frames away
  [media] usbtv: Fix deinterlacing
  [media] v4l2: added missing mutex.h include to v4l2-ctrls.h
  [media] DocBook: upgrade media_api DocBook version to 4.2
  [media] ml86v7667: fix compile warning: 'ret' set but not used
  [media] s5p-g2d: Fix registration failure
  [media] media: coda: Fix DT driver data pointer for i.MX27
  [media] s5p-mfc: Fix input/output format reporting

Showing 11 changed files Side-by-side Diff

Documentation/DocBook/media_api.tmpl
1 1 <?xml version="1.0"?>
2   -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3   - "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
  2 +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3 + "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 4 <!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities;
5 5 <!ENTITY media-indices SYSTEM "./media-indices.tmpl">
6 6  
drivers/media/i2c/ml86v7667.c
... ... @@ -117,7 +117,7 @@
117 117 {
118 118 struct v4l2_subdev *sd = to_sd(ctrl);
119 119 struct i2c_client *client = v4l2_get_subdevdata(sd);
120   - int ret;
  120 + int ret = -EINVAL;
121 121  
122 122 switch (ctrl->id) {
123 123 case V4L2_CID_BRIGHTNESS:
... ... @@ -157,7 +157,7 @@
157 157 break;
158 158 }
159 159  
160   - return 0;
  160 + return ret;
161 161 }
162 162  
163 163 static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
drivers/media/platform/coda.c
... ... @@ -1987,7 +1987,7 @@
1987 1987  
1988 1988 #ifdef CONFIG_OF
1989 1989 static const struct of_device_id coda_dt_ids[] = {
1990   - { .compatible = "fsl,imx27-vpu", .data = &coda_platform_ids[CODA_IMX27] },
  1990 + { .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
1991 1991 { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] },
1992 1992 { /* sentinel */ }
1993 1993 };
drivers/media/platform/s5p-g2d/g2d.c
... ... @@ -784,6 +784,7 @@
784 784 }
785 785 *vfd = g2d_videodev;
786 786 vfd->lock = &dev->mutex;
  787 + vfd->v4l2_dev = &dev->v4l2_dev;
787 788 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
788 789 if (ret) {
789 790 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
... ... @@ -344,7 +344,7 @@
344 344 pix_mp->num_planes = 2;
345 345 /* Set pixelformat to the format in which MFC
346 346 outputs the decoded frame */
347   - pix_mp->pixelformat = V4L2_PIX_FMT_NV12MT;
  347 + pix_mp->pixelformat = ctx->dst_fmt->fourcc;
348 348 pix_mp->plane_fmt[0].bytesperline = ctx->buf_width;
349 349 pix_mp->plane_fmt[0].sizeimage = ctx->luma_size;
350 350 pix_mp->plane_fmt[1].bytesperline = ctx->buf_width;
351 351  
... ... @@ -382,10 +382,16 @@
382 382 mfc_err("Unsupported format for source.\n");
383 383 return -EINVAL;
384 384 }
385   - if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
386   - mfc_err("Not supported format.\n");
  385 + if (fmt->codec_mode == S5P_FIMV_CODEC_NONE) {
  386 + mfc_err("Unknown codec\n");
387 387 return -EINVAL;
388 388 }
  389 + if (!IS_MFCV6(dev)) {
  390 + if (fmt->fourcc == V4L2_PIX_FMT_VP8) {
  391 + mfc_err("Not supported format.\n");
  392 + return -EINVAL;
  393 + }
  394 + }
389 395 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
390 396 fmt = find_format(f, MFC_FMT_RAW);
391 397 if (!fmt) {
... ... @@ -411,7 +417,6 @@
411 417 struct s5p_mfc_dev *dev = video_drvdata(file);
412 418 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
413 419 int ret = 0;
414   - struct s5p_mfc_fmt *fmt;
415 420 struct v4l2_pix_format_mplane *pix_mp;
416 421  
417 422 mfc_debug_enter();
418 423  
419 424  
... ... @@ -425,54 +430,32 @@
425 430 goto out;
426 431 }
427 432 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
428   - fmt = find_format(f, MFC_FMT_RAW);
429   - if (!fmt) {
430   - mfc_err("Unsupported format for source.\n");
431   - return -EINVAL;
432   - }
433   - if (!IS_MFCV6(dev) && (fmt->fourcc != V4L2_PIX_FMT_NV12MT)) {
434   - mfc_err("Not supported format.\n");
435   - return -EINVAL;
436   - } else if (IS_MFCV6(dev) &&
437   - (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
438   - mfc_err("Not supported format.\n");
439   - return -EINVAL;
440   - }
441   - ctx->dst_fmt = fmt;
442   - mfc_debug_leave();
443   - return ret;
444   - } else if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
  433 + /* dst_fmt is validated by call to vidioc_try_fmt */
  434 + ctx->dst_fmt = find_format(f, MFC_FMT_RAW);
  435 + ret = 0;
  436 + goto out;
  437 + } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
  438 + /* src_fmt is validated by call to vidioc_try_fmt */
  439 + ctx->src_fmt = find_format(f, MFC_FMT_DEC);
  440 + ctx->codec_mode = ctx->src_fmt->codec_mode;
  441 + mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
  442 + pix_mp->height = 0;
  443 + pix_mp->width = 0;
  444 + if (pix_mp->plane_fmt[0].sizeimage)
  445 + ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
  446 + else
  447 + pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
  448 + DEF_CPB_SIZE;
  449 + pix_mp->plane_fmt[0].bytesperline = 0;
  450 + ctx->state = MFCINST_INIT;
  451 + ret = 0;
  452 + goto out;
  453 + } else {
445 454 mfc_err("Wrong type error for S_FMT : %d", f->type);
446   - return -EINVAL;
447   - }
448   - fmt = find_format(f, MFC_FMT_DEC);
449   - if (!fmt || fmt->codec_mode == S5P_MFC_CODEC_NONE) {
450   - mfc_err("Unknown codec\n");
451 455 ret = -EINVAL;
452 456 goto out;
453 457 }
454   - if (fmt->type != MFC_FMT_DEC) {
455   - mfc_err("Wrong format selected, you should choose "
456   - "format for decoding\n");
457   - ret = -EINVAL;
458   - goto out;
459   - }
460   - if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
461   - mfc_err("Not supported format.\n");
462   - return -EINVAL;
463   - }
464   - ctx->src_fmt = fmt;
465   - ctx->codec_mode = fmt->codec_mode;
466   - mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
467   - pix_mp->height = 0;
468   - pix_mp->width = 0;
469   - if (pix_mp->plane_fmt[0].sizeimage)
470   - ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
471   - else
472   - pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
473   - DEF_CPB_SIZE;
474   - pix_mp->plane_fmt[0].bytesperline = 0;
475   - ctx->state = MFCINST_INIT;
  458 +
476 459 out:
477 460 mfc_debug_leave();
478 461 return ret;
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
... ... @@ -906,6 +906,7 @@
906 906  
907 907 static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
908 908 {
  909 + struct s5p_mfc_dev *dev = video_drvdata(file);
909 910 struct s5p_mfc_fmt *fmt;
910 911 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
911 912  
... ... @@ -930,6 +931,18 @@
930 931 return -EINVAL;
931 932 }
932 933  
  934 + if (!IS_MFCV6(dev)) {
  935 + if (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
  936 + mfc_err("Not supported format.\n");
  937 + return -EINVAL;
  938 + }
  939 + } else if (IS_MFCV6(dev)) {
  940 + if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
  941 + mfc_err("Not supported format.\n");
  942 + return -EINVAL;
  943 + }
  944 + }
  945 +
933 946 if (fmt->num_planes != pix_fmt_mp->num_planes) {
934 947 mfc_err("failed to try output format\n");
935 948 return -EINVAL;
... ... @@ -947,7 +960,6 @@
947 960 {
948 961 struct s5p_mfc_dev *dev = video_drvdata(file);
949 962 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
950   - struct s5p_mfc_fmt *fmt;
951 963 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
952 964 int ret = 0;
953 965  
954 966  
... ... @@ -960,13 +972,9 @@
960 972 goto out;
961 973 }
962 974 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
963   - fmt = find_format(f, MFC_FMT_ENC);
964   - if (!fmt) {
965   - mfc_err("failed to set capture format\n");
966   - return -EINVAL;
967   - }
  975 + /* dst_fmt is validated by call to vidioc_try_fmt */
  976 + ctx->dst_fmt = find_format(f, MFC_FMT_ENC);
968 977 ctx->state = MFCINST_INIT;
969   - ctx->dst_fmt = fmt;
970 978 ctx->codec_mode = ctx->dst_fmt->codec_mode;
971 979 ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage;
972 980 pix_fmt_mp->plane_fmt[0].bytesperline = 0;
... ... @@ -987,28 +995,8 @@
987 995 }
988 996 mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
989 997 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
990   - fmt = find_format(f, MFC_FMT_RAW);
991   - if (!fmt) {
992   - mfc_err("failed to set output format\n");
993   - return -EINVAL;
994   - }
995   -
996   - if (!IS_MFCV6(dev) &&
997   - (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)) {
998   - mfc_err("Not supported format.\n");
999   - return -EINVAL;
1000   - } else if (IS_MFCV6(dev) &&
1001   - (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
1002   - mfc_err("Not supported format.\n");
1003   - return -EINVAL;
1004   - }
1005   -
1006   - if (fmt->num_planes != pix_fmt_mp->num_planes) {
1007   - mfc_err("failed to set output format\n");
1008   - ret = -EINVAL;
1009   - goto out;
1010   - }
1011   - ctx->src_fmt = fmt;
  998 + /* src_fmt is validated by call to vidioc_try_fmt */
  999 + ctx->src_fmt = find_format(f, MFC_FMT_RAW);
1012 1000 ctx->img_width = pix_fmt_mp->width;
1013 1001 ctx->img_height = pix_fmt_mp->height;
1014 1002 mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode);
drivers/media/usb/em28xx/em28xx-i2c.c
... ... @@ -726,7 +726,7 @@
726 726  
727 727 *eedata = data;
728 728 *eedata_len = len;
729   - dev_config = (void *)eedata;
  729 + dev_config = (void *)*eedata;
730 730  
731 731 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) {
732 732 case 0:
drivers/media/usb/hdpvr/hdpvr-core.c
... ... @@ -303,6 +303,11 @@
303 303  
304 304 dev->workqueue = 0;
305 305  
  306 + /* init video transfer queues first of all */
  307 + /* to prevent oops in hdpvr_delete() on error paths */
  308 + INIT_LIST_HEAD(&dev->free_buff_list);
  309 + INIT_LIST_HEAD(&dev->rec_buff_list);
  310 +
306 311 /* register v4l2_device early so it can be used for printks */
307 312 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
308 313 dev_err(&interface->dev, "v4l2_device_register failed\n");
... ... @@ -325,10 +330,6 @@
325 330 if (!dev->workqueue)
326 331 goto error;
327 332  
328   - /* init video transfer queues */
329   - INIT_LIST_HEAD(&dev->free_buff_list);
330   - INIT_LIST_HEAD(&dev->rec_buff_list);
331   -
332 333 dev->options = hdpvr_default_options;
333 334  
334 335 if (default_video_input < HDPVR_VIDEO_INPUTS)
... ... @@ -405,7 +406,7 @@
405 406 video_nr[atomic_inc_return(&dev_nr)]);
406 407 if (retval < 0) {
407 408 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
408   - goto error;
  409 + goto reg_fail;
409 410 }
410 411  
411 412 /* let the user know what node this device is now attached to */
drivers/media/usb/usbtv/Kconfig
1 1 config VIDEO_USBTV
2 2 tristate "USBTV007 video capture support"
3   - depends on VIDEO_DEV
  3 + depends on VIDEO_V4L2
4 4 select VIDEOBUF2_VMALLOC
5 5  
6 6 ---help---
drivers/media/usb/usbtv/usbtv.c
... ... @@ -57,7 +57,7 @@
57 57 #define USBTV_CHUNK_SIZE 256
58 58 #define USBTV_CHUNK 240
59 59 #define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \
60   - / 2 / USBTV_CHUNK)
  60 + / 4 / USBTV_CHUNK)
61 61  
62 62 /* Chunk header. */
63 63 #define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
... ... @@ -89,6 +89,7 @@
89 89 /* Number of currently processed frame, useful find
90 90 * out when a new one begins. */
91 91 u32 frame_id;
  92 + int chunks_done;
92 93  
93 94 int iso_size;
94 95 unsigned int sequence;
... ... @@ -202,6 +203,26 @@
202 203 return 0;
203 204 }
204 205  
  206 +/* Copy data from chunk into a frame buffer, deinterlacing the data
  207 + * into every second line. Unfortunately, they don't align nicely into
  208 + * 720 pixel lines, as the chunk is 240 words long, which is 480 pixels.
  209 + * Therefore, we break down the chunk into two halves before copyting,
  210 + * so that we can interleave a line if needed. */
  211 +static void usbtv_chunk_to_vbuf(u32 *frame, u32 *src, int chunk_no, int odd)
  212 +{
  213 + int half;
  214 +
  215 + for (half = 0; half < 2; half++) {
  216 + int part_no = chunk_no * 2 + half;
  217 + int line = part_no / 3;
  218 + int part_index = (line * 2 + !odd) * 3 + (part_no % 3);
  219 +
  220 + u32 *dst = &frame[part_index * USBTV_CHUNK/2];
  221 + memcpy(dst, src, USBTV_CHUNK/2 * sizeof(*src));
  222 + src += USBTV_CHUNK/2;
  223 + }
  224 +}
  225 +
205 226 /* Called for each 256-byte image chunk.
206 227 * First word identifies the chunk, followed by 240 words of image
207 228 * data and padding. */
208 229  
209 230  
210 231  
... ... @@ -218,18 +239,18 @@
218 239 frame_id = USBTV_FRAME_ID(chunk);
219 240 odd = USBTV_ODD(chunk);
220 241 chunk_no = USBTV_CHUNK_NO(chunk);
221   -
222   - /* Deinterlace. TODO: Use interlaced frame format. */
223   - chunk_no = (chunk_no - chunk_no % 3) * 2 + chunk_no % 3;
224   - chunk_no += !odd * 3;
225   -
226 242 if (chunk_no >= USBTV_CHUNKS)
227 243 return;
228 244  
229 245 /* Beginning of a frame. */
230   - if (chunk_no == 0)
  246 + if (chunk_no == 0) {
231 247 usbtv->frame_id = frame_id;
  248 + usbtv->chunks_done = 0;
  249 + }
232 250  
  251 + if (usbtv->frame_id != frame_id)
  252 + return;
  253 +
233 254 spin_lock_irqsave(&usbtv->buflock, flags);
234 255 if (list_empty(&usbtv->bufs)) {
235 256 /* No free buffers. Userspace likely too slow. */
236 257  
237 258  
238 259  
... ... @@ -241,19 +262,23 @@
241 262 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list);
242 263 frame = vb2_plane_vaddr(&buf->vb, 0);
243 264  
244   - /* Copy the chunk. */
245   - memcpy(&frame[chunk_no * USBTV_CHUNK], &chunk[1],
246   - USBTV_CHUNK * sizeof(chunk[1]));
  265 + /* Copy the chunk data. */
  266 + usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
  267 + usbtv->chunks_done++;
247 268  
248 269 /* Last chunk in a frame, signalling an end */
249   - if (usbtv->frame_id && chunk_no == USBTV_CHUNKS-1) {
  270 + if (odd && chunk_no == USBTV_CHUNKS-1) {
250 271 int size = vb2_plane_size(&buf->vb, 0);
  272 + enum vb2_buffer_state state = usbtv->chunks_done ==
  273 + USBTV_CHUNKS ?
  274 + VB2_BUF_STATE_DONE :
  275 + VB2_BUF_STATE_ERROR;
251 276  
252 277 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
253 278 buf->vb.v4l2_buf.sequence = usbtv->sequence++;
254 279 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
255 280 vb2_set_plane_payload(&buf->vb, 0, size);
256   - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE);
  281 + vb2_buffer_done(&buf->vb, state);
257 282 list_del(&buf->list);
258 283 }
259 284  
... ... @@ -518,7 +543,7 @@
518 543 if (*nbuffers < 2)
519 544 *nbuffers = 2;
520 545 *nplanes = 1;
521   - sizes[0] = USBTV_CHUNK * USBTV_CHUNKS * sizeof(u32);
  546 + sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32);
522 547  
523 548 return 0;
524 549 }
include/media/v4l2-ctrls.h
... ... @@ -22,6 +22,7 @@
22 22 #define _V4L2_CTRLS_H
23 23  
24 24 #include <linux/list.h>
  25 +#include <linux/mutex.h>
25 26 #include <linux/videodev2.h>
26 27  
27 28 /* forward references */