aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mx2_camera.c
diff options
context:
space:
mode:
authorJavier Martin <javier.martin@vista-silicon.com>2012-07-11 11:34:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-11 15:48:24 -0400
commit8a76e5383fb5f58868fdd3a2fe1f4b95988f10a8 (patch)
treee79b736e3b863f4f2764743eb7307954595ce5b8 /drivers/media/video/mx2_camera.c
parent887eafd29bce6e6e0b2df91d1d0da3331490fd5d (diff)
media: mx2_camera: Fix mbus format handling
Do not use MX2_CAMERA_SWAP16 and MX2_CAMERA_PACK_DIR_MSB flags. The driver must negotiate with the attached sensor whether the mbus format is UYUV or YUYV and set CSICR1 configuration accordingly. This is needed for the video function on mach-imx27_visstrim_m10.c to perform properly, since an earlier version of this patch has been proven wrong and has been reverted and a commit, depending on it: "[media] i.MX27: visstrim_m10: Remove use of MX2_CAMERA_SWAP16" is in the mainline. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Reviewed-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [ g.liakhovetski@gmx.de: move a macro definition to a more logical place ] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> [ Applying directly because Mauro is on vacation - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/media/video/mx2_camera.c')
-rw-r--r--drivers/media/video/mx2_camera.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 41f9a254b245..637bde8aca28 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -83,6 +83,7 @@
83#define CSICR1_INV_DATA (1 << 3) 83#define CSICR1_INV_DATA (1 << 3)
84#define CSICR1_INV_PCLK (1 << 2) 84#define CSICR1_INV_PCLK (1 << 2)
85#define CSICR1_REDGE (1 << 1) 85#define CSICR1_REDGE (1 << 1)
86#define CSICR1_FMT_MASK (CSICR1_PACK_DIR | CSICR1_SWAP16_EN)
86 87
87#define SHIFT_STATFF_LEVEL 22 88#define SHIFT_STATFF_LEVEL 22
88#define SHIFT_RXFF_LEVEL 19 89#define SHIFT_RXFF_LEVEL 19
@@ -230,6 +231,7 @@ struct mx2_prp_cfg {
230 u32 src_pixel; 231 u32 src_pixel;
231 u32 ch1_pixel; 232 u32 ch1_pixel;
232 u32 irq_flags; 233 u32 irq_flags;
234 u32 csicr1;
233}; 235};
234 236
235/* prp resizing parameters */ 237/* prp resizing parameters */
@@ -330,6 +332,7 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = {
330 .ch1_pixel = 0x2ca00565, /* RGB565 */ 332 .ch1_pixel = 0x2ca00565, /* RGB565 */
331 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH1WERR | 333 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH1WERR |
332 PRP_INTR_CH1FC | PRP_INTR_LBOVF, 334 PRP_INTR_CH1FC | PRP_INTR_LBOVF,
335 .csicr1 = 0,
333 } 336 }
334 }, 337 },
335 { 338 {
@@ -343,6 +346,21 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = {
343 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR | 346 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR |
344 PRP_INTR_CH2FC | PRP_INTR_LBOVF | 347 PRP_INTR_CH2FC | PRP_INTR_LBOVF |
345 PRP_INTR_CH2OVF, 348 PRP_INTR_CH2OVF,
349 .csicr1 = CSICR1_PACK_DIR,
350 }
351 },
352 {
353 .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8,
354 .out_fmt = V4L2_PIX_FMT_YUV420,
355 .cfg = {
356 .channel = 2,
357 .in_fmt = PRP_CNTL_DATA_IN_YUV422,
358 .out_fmt = PRP_CNTL_CH2_OUT_YUV420,
359 .src_pixel = 0x22000888, /* YUV422 (YUYV) */
360 .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR |
361 PRP_INTR_CH2FC | PRP_INTR_LBOVF |
362 PRP_INTR_CH2OVF,
363 .csicr1 = CSICR1_SWAP16_EN,
346 } 364 }
347 }, 365 },
348}; 366};
@@ -1015,14 +1033,14 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1015 return ret; 1033 return ret;
1016 } 1034 }
1017 1035
1036 csicr1 = (csicr1 & ~CSICR1_FMT_MASK) | pcdev->emma_prp->cfg.csicr1;
1037
1018 if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) 1038 if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
1019 csicr1 |= CSICR1_REDGE; 1039 csicr1 |= CSICR1_REDGE;
1020 if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) 1040 if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
1021 csicr1 |= CSICR1_SOF_POL; 1041 csicr1 |= CSICR1_SOF_POL;
1022 if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 1042 if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
1023 csicr1 |= CSICR1_HSYNC_POL; 1043 csicr1 |= CSICR1_HSYNC_POL;
1024 if (pcdev->platform_flags & MX2_CAMERA_SWAP16)
1025 csicr1 |= CSICR1_SWAP16_EN;
1026 if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC) 1044 if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC)
1027 csicr1 |= CSICR1_EXT_VSYNC; 1045 csicr1 |= CSICR1_EXT_VSYNC;
1028 if (pcdev->platform_flags & MX2_CAMERA_CCIR) 1046 if (pcdev->platform_flags & MX2_CAMERA_CCIR)
@@ -1033,8 +1051,6 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1033 csicr1 |= CSICR1_GCLK_MODE; 1051 csicr1 |= CSICR1_GCLK_MODE;
1034 if (pcdev->platform_flags & MX2_CAMERA_INV_DATA) 1052 if (pcdev->platform_flags & MX2_CAMERA_INV_DATA)
1035 csicr1 |= CSICR1_INV_DATA; 1053 csicr1 |= CSICR1_INV_DATA;
1036 if (pcdev->platform_flags & MX2_CAMERA_PACK_DIR_MSB)
1037 csicr1 |= CSICR1_PACK_DIR;
1038 1054
1039 pcdev->csicr1 = csicr1; 1055 pcdev->csicr1 = csicr1;
1040 1056
@@ -1109,7 +1125,8 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd,
1109 return 0; 1125 return 0;
1110 } 1126 }
1111 1127
1112 if (code == V4L2_MBUS_FMT_YUYV8_2X8) { 1128 if (code == V4L2_MBUS_FMT_YUYV8_2X8 ||
1129 code == V4L2_MBUS_FMT_UYVY8_2X8) {
1113 formats++; 1130 formats++;
1114 if (xlate) { 1131 if (xlate) {
1115 /* 1132 /*