media: tegra_camera: add line alignment check
Bryan Wu [Tue, 13 Oct 2015 19:47:09 +0000 (12:47 -0700)]
bytes_per_line should be 64 bytes aligned in Tegra. Add a function to
check that and return the right value for LINE_STRIDE register.

Bug 1694764

Change-Id: I1bb926a416719d19cad509f9a9a7c4fce06b851a
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/816975
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/media/platform/soc_camera/tegra_camera/vi2.c

index 6a75e8e..4d17cda 100644 (file)
@@ -808,12 +808,22 @@ static int vi2_capture_setup(struct tegra_camera_dev *cam)
                return -ENODEV;
 }
 
+static s32 vi2_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf)
+{
+       s32 bytes_per_line = soc_mbus_bytes_per_line(width, mf);
+
+       if (bytes_per_line % 64)
+               bytes_per_line = bytes_per_line + (64 - (bytes_per_line % 64));
+
+       return bytes_per_line;
+}
+
 static int vi2_capture_buffer_setup(struct tegra_camera_dev *cam,
                        struct tegra_camera_buffer *buf)
 {
        struct soc_camera_device *icd = buf->icd;
-       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
-                       icd->current_fmt->host_fmt);
+       int bytes_per_line = vi2_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
        struct soc_camera_subdev_desc *ssdesc = &icd->sdesc->subdev_desc;
        struct tegra_camera_platform_data *pdata = ssdesc->drv_priv;
        int port = pdata->port;