diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2012-03-26 08:17:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-15 08:42:17 -0400 |
commit | d509835e32bd761a2b7b446034a273da568e5573 (patch) | |
tree | 4cd012fe6c16d6d1814a4a51ece733b91f358587 /drivers/media/video/mx2_camera.c | |
parent | 5ff203b5d82edd581b1220aedbf55492f12cf416 (diff) |
[media] media: mx2_camera: Fix mbus format handling
Remove MX2_CAMERA_SWAP16 and MX2_CAMERA_PACK_DIR_MSB flags
so that the driver can negotiate with the attached sensor
whether the mbus format needs convertion from UYUV to YUYV
or not.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mx2_camera.c')
-rw-r--r-- | drivers/media/video/mx2_camera.c | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 18afaeeadb7b..7c3c0e8eda42 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c | |||
@@ -344,6 +344,19 @@ static struct mx2_fmt_cfg mx27_emma_prp_table[] = { | |||
344 | PRP_INTR_CH2OVF, | 344 | PRP_INTR_CH2OVF, |
345 | } | 345 | } |
346 | }, | 346 | }, |
347 | { | ||
348 | .in_fmt = V4L2_MBUS_FMT_UYVY8_2X8, | ||
349 | .out_fmt = V4L2_PIX_FMT_YUV420, | ||
350 | .cfg = { | ||
351 | .channel = 2, | ||
352 | .in_fmt = PRP_CNTL_DATA_IN_YUV422, | ||
353 | .out_fmt = PRP_CNTL_CH2_OUT_YUV420, | ||
354 | .src_pixel = 0x22000888, /* YUV422 (YUYV) */ | ||
355 | .irq_flags = PRP_INTR_RDERR | PRP_INTR_CH2WERR | | ||
356 | PRP_INTR_CH2FC | PRP_INTR_LBOVF | | ||
357 | PRP_INTR_CH2OVF, | ||
358 | } | ||
359 | }, | ||
347 | }; | 360 | }; |
348 | 361 | ||
349 | static struct mx2_fmt_cfg *mx27_emma_prp_get_format( | 362 | static struct mx2_fmt_cfg *mx27_emma_prp_get_format( |
@@ -980,6 +993,7 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) | |||
980 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 993 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
981 | struct mx2_camera_dev *pcdev = ici->priv; | 994 | struct mx2_camera_dev *pcdev = ici->priv; |
982 | struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,}; | 995 | struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,}; |
996 | const struct soc_camera_format_xlate *xlate; | ||
983 | unsigned long common_flags; | 997 | unsigned long common_flags; |
984 | int ret; | 998 | int ret; |
985 | int bytesperline; | 999 | int bytesperline; |
@@ -1024,14 +1038,31 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) | |||
1024 | return ret; | 1038 | return ret; |
1025 | } | 1039 | } |
1026 | 1040 | ||
1041 | xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); | ||
1042 | if (!xlate) { | ||
1043 | dev_warn(icd->parent, "Format %x not found\n", pixfmt); | ||
1044 | return -EINVAL; | ||
1045 | } | ||
1046 | |||
1047 | if (xlate->code == V4L2_MBUS_FMT_YUYV8_2X8) { | ||
1048 | csicr1 |= CSICR1_PACK_DIR; | ||
1049 | csicr1 &= ~CSICR1_SWAP16_EN; | ||
1050 | dev_dbg(icd->parent, "already yuyv format, don't convert\n"); | ||
1051 | } else if (xlate->code == V4L2_MBUS_FMT_UYVY8_2X8) { | ||
1052 | csicr1 &= ~CSICR1_PACK_DIR; | ||
1053 | csicr1 |= CSICR1_SWAP16_EN; | ||
1054 | dev_dbg(icd->parent, "convert uyvy mbus format into yuyv\n"); | ||
1055 | } else { | ||
1056 | dev_warn(icd->parent, "mbus format not supported\n"); | ||
1057 | return -EINVAL; | ||
1058 | } | ||
1059 | |||
1027 | if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) | 1060 | if (common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) |
1028 | csicr1 |= CSICR1_REDGE; | 1061 | csicr1 |= CSICR1_REDGE; |
1029 | if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) | 1062 | if (common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) |
1030 | csicr1 |= CSICR1_SOF_POL; | 1063 | csicr1 |= CSICR1_SOF_POL; |
1031 | if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) | 1064 | if (common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) |
1032 | csicr1 |= CSICR1_HSYNC_POL; | 1065 | csicr1 |= CSICR1_HSYNC_POL; |
1033 | if (pcdev->platform_flags & MX2_CAMERA_SWAP16) | ||
1034 | csicr1 |= CSICR1_SWAP16_EN; | ||
1035 | if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC) | 1066 | if (pcdev->platform_flags & MX2_CAMERA_EXT_VSYNC) |
1036 | csicr1 |= CSICR1_EXT_VSYNC; | 1067 | csicr1 |= CSICR1_EXT_VSYNC; |
1037 | if (pcdev->platform_flags & MX2_CAMERA_CCIR) | 1068 | if (pcdev->platform_flags & MX2_CAMERA_CCIR) |
@@ -1042,8 +1073,6 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) | |||
1042 | csicr1 |= CSICR1_GCLK_MODE; | 1073 | csicr1 |= CSICR1_GCLK_MODE; |
1043 | if (pcdev->platform_flags & MX2_CAMERA_INV_DATA) | 1074 | if (pcdev->platform_flags & MX2_CAMERA_INV_DATA) |
1044 | csicr1 |= CSICR1_INV_DATA; | 1075 | csicr1 |= CSICR1_INV_DATA; |
1045 | if (pcdev->platform_flags & MX2_CAMERA_PACK_DIR_MSB) | ||
1046 | csicr1 |= CSICR1_PACK_DIR; | ||
1047 | 1076 | ||
1048 | pcdev->csicr1 = csicr1; | 1077 | pcdev->csicr1 = csicr1; |
1049 | 1078 | ||
@@ -1118,7 +1147,8 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
1118 | return 0; | 1147 | return 0; |
1119 | } | 1148 | } |
1120 | 1149 | ||
1121 | if (code == V4L2_MBUS_FMT_YUYV8_2X8) { | 1150 | if (code == V4L2_MBUS_FMT_YUYV8_2X8 || |
1151 | code == V4L2_MBUS_FMT_UYVY8_2X8) { | ||
1122 | formats++; | 1152 | formats++; |
1123 | if (xlate) { | 1153 | if (xlate) { |
1124 | /* | 1154 | /* |
@@ -1134,6 +1164,18 @@ static int mx2_camera_get_formats(struct soc_camera_device *icd, | |||
1134 | } | 1164 | } |
1135 | } | 1165 | } |
1136 | 1166 | ||
1167 | if (code == V4L2_MBUS_FMT_UYVY8_2X8) { | ||
1168 | formats++; | ||
1169 | if (xlate) { | ||
1170 | xlate->host_fmt = | ||
1171 | soc_mbus_get_fmtdesc(V4L2_MBUS_FMT_YUYV8_2X8); | ||
1172 | xlate->code = code; | ||
1173 | dev_dbg(dev, "Providing host format %s for sensor code %d\n", | ||
1174 | xlate->host_fmt->name, code); | ||
1175 | xlate++; | ||
1176 | } | ||
1177 | } | ||
1178 | |||
1137 | /* Generic pass-trough */ | 1179 | /* Generic pass-trough */ |
1138 | formats++; | 1180 | formats++; |
1139 | if (xlate) { | 1181 | if (xlate) { |