aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mx3_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mx3_camera.c')
-rw-r--r--drivers/media/video/mx3_camera.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index 3e5435b539b..c7680eb8366 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -688,8 +688,8 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
688 688
689 fmt = soc_mbus_get_fmtdesc(code); 689 fmt = soc_mbus_get_fmtdesc(code);
690 if (!fmt) { 690 if (!fmt) {
691 dev_err(icd->dev.parent, 691 dev_warn(icd->dev.parent,
692 "Invalid format code #%u: %d\n", idx, code); 692 "Unsupported format code #%u: %d\n", idx, code);
693 return 0; 693 return 0;
694 } 694 }
695 695
@@ -742,13 +742,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
742 742
743static void configure_geometry(struct mx3_camera_dev *mx3_cam, 743static void configure_geometry(struct mx3_camera_dev *mx3_cam,
744 unsigned int width, unsigned int height, 744 unsigned int width, unsigned int height,
745 enum v4l2_mbus_pixelcode code) 745 const struct soc_mbus_pixelfmt *fmt)
746{ 746{
747 u32 ctrl, width_field, height_field; 747 u32 ctrl, width_field, height_field;
748 const struct soc_mbus_pixelfmt *fmt;
749
750 fmt = soc_mbus_get_fmtdesc(code);
751 BUG_ON(!fmt);
752 748
753 if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) { 749 if (fourcc_to_ipu_pix(fmt->fourcc) == IPU_PIX_FMT_GENERIC) {
754 /* 750 /*
@@ -806,8 +802,8 @@ static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam)
806 */ 802 */
807static inline void stride_align(__u32 *width) 803static inline void stride_align(__u32 *width)
808{ 804{
809 if (((*width + 7) & ~7) < 4096) 805 if (ALIGN(*width, 8) < 4096)
810 *width = (*width + 7) & ~7; 806 *width = ALIGN(*width, 8);
811 else 807 else
812 *width = *width & ~7; 808 *width = *width & ~7;
813} 809}
@@ -833,11 +829,14 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
833 if (ret < 0) 829 if (ret < 0)
834 return ret; 830 return ret;
835 831
836 /* The capture device might have changed its output */ 832 /* The capture device might have changed its output sizes */
837 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf); 833 ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
838 if (ret < 0) 834 if (ret < 0)
839 return ret; 835 return ret;
840 836
837 if (mf.code != icd->current_fmt->code)
838 return -EINVAL;
839
841 if (mf.width & 7) { 840 if (mf.width & 7) {
842 /* Ouch! We can only handle 8-byte aligned width... */ 841 /* Ouch! We can only handle 8-byte aligned width... */
843 stride_align(&mf.width); 842 stride_align(&mf.width);
@@ -847,7 +846,8 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
847 } 846 }
848 847
849 if (mf.width != icd->user_width || mf.height != icd->user_height) 848 if (mf.width != icd->user_width || mf.height != icd->user_height)
850 configure_geometry(mx3_cam, mf.width, mf.height, mf.code); 849 configure_geometry(mx3_cam, mf.width, mf.height,
850 icd->current_fmt->host_fmt);
851 851
852 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n", 852 dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n",
853 mf.width, mf.height); 853 mf.width, mf.height);
@@ -885,7 +885,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
885 * mxc_v4l2_s_fmt() 885 * mxc_v4l2_s_fmt()
886 */ 886 */
887 887
888 configure_geometry(mx3_cam, pix->width, pix->height, xlate->code); 888 configure_geometry(mx3_cam, pix->width, pix->height, xlate->host_fmt);
889 889
890 mf.width = pix->width; 890 mf.width = pix->width;
891 mf.height = pix->height; 891 mf.height = pix->height;