|
@@ -224,14 +224,18 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, u32 pixel_clk,
|
|
|
* Find the CSI data format and data width for the given V4L2 media
|
|
|
* bus pixel format code.
|
|
|
*/
|
|
|
-static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
|
|
|
+static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code,
|
|
|
+ enum v4l2_mbus_type mbus_type)
|
|
|
{
|
|
|
switch (mbus_code) {
|
|
|
case MEDIA_BUS_FMT_BGR565_2X8_BE:
|
|
|
case MEDIA_BUS_FMT_BGR565_2X8_LE:
|
|
|
case MEDIA_BUS_FMT_RGB565_2X8_BE:
|
|
|
case MEDIA_BUS_FMT_RGB565_2X8_LE:
|
|
|
- cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
|
|
|
+ if (mbus_type == V4L2_MBUS_CSI2)
|
|
|
+ cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
|
|
|
+ else
|
|
|
+ cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
|
|
|
cfg->mipi_dt = MIPI_DT_RGB565;
|
|
|
cfg->data_width = IPU_CSI_DATA_WIDTH_8;
|
|
|
break;
|
|
@@ -247,6 +251,12 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
|
|
|
cfg->mipi_dt = MIPI_DT_RGB555;
|
|
|
cfg->data_width = IPU_CSI_DATA_WIDTH_8;
|
|
|
break;
|
|
|
+ case MEDIA_BUS_FMT_RGB888_1X24:
|
|
|
+ case MEDIA_BUS_FMT_BGR888_1X24:
|
|
|
+ cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB_YUV444;
|
|
|
+ cfg->mipi_dt = MIPI_DT_RGB888;
|
|
|
+ cfg->data_width = IPU_CSI_DATA_WIDTH_8;
|
|
|
+ break;
|
|
|
case MEDIA_BUS_FMT_UYVY8_2X8:
|
|
|
cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_YUV422_UYVY;
|
|
|
cfg->mipi_dt = MIPI_DT_YUV422;
|
|
@@ -318,13 +328,17 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
|
|
|
/*
|
|
|
* Fill a CSI bus config struct from mbus_config and mbus_framefmt.
|
|
|
*/
|
|
|
-static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
|
|
|
+static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
|
|
|
struct v4l2_mbus_config *mbus_cfg,
|
|
|
struct v4l2_mbus_framefmt *mbus_fmt)
|
|
|
{
|
|
|
+ int ret;
|
|
|
+
|
|
|
memset(csicfg, 0, sizeof(*csicfg));
|
|
|
|
|
|
- mbus_code_to_bus_cfg(csicfg, mbus_fmt->code);
|
|
|
+ ret = mbus_code_to_bus_cfg(csicfg, mbus_fmt->code, mbus_cfg->type);
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
|
|
|
switch (mbus_cfg->type) {
|
|
|
case V4L2_MBUS_PARALLEL:
|
|
@@ -339,7 +353,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
|
|
|
break;
|
|
|
case V4L2_MBUS_BT656:
|
|
|
csicfg->ext_vsync = 0;
|
|
|
- if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field))
|
|
|
+ if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) ||
|
|
|
+ mbus_fmt->field == V4L2_FIELD_ALTERNATE)
|
|
|
csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED;
|
|
|
else
|
|
|
csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
|
|
@@ -355,6 +370,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
|
|
|
/* will never get here, keep compiler quiet */
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
int ipu_csi_init_interface(struct ipu_csi *csi,
|
|
@@ -364,8 +381,11 @@ int ipu_csi_init_interface(struct ipu_csi *csi,
|
|
|
struct ipu_csi_bus_config cfg;
|
|
|
unsigned long flags;
|
|
|
u32 width, height, data = 0;
|
|
|
+ int ret;
|
|
|
|
|
|
- fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt);
|
|
|
+ ret = fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt);
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
|
|
|
/* set default sensor frame width and height */
|
|
|
width = mbus_fmt->width;
|
|
@@ -586,11 +606,14 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc,
|
|
|
struct ipu_csi_bus_config cfg;
|
|
|
unsigned long flags;
|
|
|
u32 temp;
|
|
|
+ int ret;
|
|
|
|
|
|
if (vc > 3)
|
|
|
return -EINVAL;
|
|
|
|
|
|
- mbus_code_to_bus_cfg(&cfg, mbus_fmt->code);
|
|
|
+ ret = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code, V4L2_MBUS_CSI2);
|
|
|
+ if (ret < 0)
|
|
|
+ return ret;
|
|
|
|
|
|
spin_lock_irqsave(&csi->lock, flags);
|
|
|
|