Merge tag 'v3.8-rc1' into staging/for_v3.9
[sfrench/cifs-2.6.git] / drivers / media / platform / soc_camera / mx2_camera.c
index 791cd1d54a769c5321cca32d8fa7cc6665467324..28d5c84eef82a8c21ab34175ea83ed61bf975066 100644 (file)
@@ -559,7 +559,7 @@ static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
        dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%p %lu\n", __func__,
                vb, vb2_plane_vaddr(vb, 0), vb2_get_plane_payload(vb, 0));
 
-       do_gettimeofday(&vb->v4l2_buf.timestamp);
+       v4l2_get_timestamp(&vb->v4l2_buf.timestamp);
        vb->v4l2_buf.sequence++;
        vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
 
@@ -922,7 +922,7 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
                pcdev->discard_size = icd->user_height * bytesperline;
                pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev,
                                pcdev->discard_size, &pcdev->discard_buffer_dma,
-                               GFP_KERNEL);
+                               GFP_ATOMIC);
                if (!pcdev->discard_buffer) {
                        spin_unlock_irqrestore(&pcdev->lock, flags);
                        return -ENOMEM;
@@ -1437,8 +1437,6 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
                return -EINVAL;
        }
 
-       /* FIXME: implement MX27 limits */
-
        /* limit to MX25 hardware capabilities */
        if (is_imx25_camera(pcdev)) {
                if (xlate->host_fmt->bits_per_sample <= 8)
@@ -1470,6 +1468,12 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
                        pix->sizeimage = soc_mbus_image_size(xlate->host_fmt,
                                                pix->bytesperline, pix->height);
                }
+       } else {
+               /*
+                * Width must be a multiple of 8 as requested by the CSI.
+                * (Table 39-2 in the i.MX27 Reference Manual).
+                */
+               pix->width &= ~0x7;
        }
 
        /* limit to sensor capabilities */
@@ -1600,7 +1604,7 @@ static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
                                vb2_get_plane_payload(vb, 0));
 
                list_del_init(&buf->internal.queue);
-               do_gettimeofday(&vb->v4l2_buf.timestamp);
+               v4l2_get_timestamp(&vb->v4l2_buf.timestamp);
                vb->v4l2_buf.sequence = pcdev->frame_count;
                if (err)
                        vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);