return &csi_dev->fmt[pad];
}
+static u32 code_to_data_type(int code)
+{
+ switch (code) {
+ case MEDIA_BUS_FMT_SRGGB10_1X10:
+ case MEDIA_BUS_FMT_SGRBG10_1X10:
+ case MEDIA_BUS_FMT_SGBRG10_1X10:
+ case MEDIA_BUS_FMT_SBGGR10_1X10:
+ return 0x2b;
+ case MEDIA_BUS_FMT_YUYV8_2X8:
+ return 0x1E;
+ case MEDIA_BUS_FMT_RGB565_2X8_LE:
+ return 0x22;
+ default:
+ return 0x2b;
+ }
+}
+
static int csi_set_stream(struct v4l2_subdev *sd, int enable)
{
struct stf_csi_dev *csi_dev = v4l2_get_subdevdata(sd);
struct v4l2_mbus_framefmt *format;
- int ret = 0, is_raw10 = 0;
- u32 code;
+ int ret = 0;
+ u32 code, width, dt;
format = __csi_get_format(csi_dev, NULL, STF_CSI_PAD_SRC,
V4L2_SUBDEV_FORMAT_ACTIVE);
if (format == NULL)
return -EINVAL;
+
+ width = format->width;
+
ret = csi_find_format(format->code,
csi_dev->formats,
csi_dev->nformats);
return ret;
code = csi_dev->formats[ret].code;
- if (code == MEDIA_BUS_FMT_SBGGR10_1X10 ||
- code == MEDIA_BUS_FMT_SGBRG10_1X10 ||
- code == MEDIA_BUS_FMT_SGRBG10_1X10 ||
- code == MEDIA_BUS_FMT_SRGGB10_1X10)
- is_raw10 = 1;
+ dt = code_to_data_type(code);
mutex_lock(&csi_dev->stream_lock);
if (enable) {
if (csi_dev->stream_count == 0) {
csi_dev->hw_ops->csi_clk_enable(csi_dev);
- csi_dev->hw_ops->csi_set_format(csi_dev,
- format->height,
- csi_dev->formats[ret].bpp, is_raw10);
- csi_dev->hw_ops->csi_stream_set(csi_dev, enable);
+ csi_dev->hw_ops->csi_stream_set(csi_dev, enable, dt, width);
}
csi_dev->stream_count++;
} else {
if (csi_dev->stream_count == 0)
goto exit;
if (csi_dev->stream_count == 1) {
- csi_dev->hw_ops->csi_stream_set(csi_dev, enable);
+ csi_dev->hw_ops->csi_stream_set(csi_dev, enable, dt, width);
csi_dev->hw_ops->csi_clk_disable(csi_dev);
}
csi_dev->stream_count--;
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31)
+#define CSI2RX_STREAM_DATA_CFG_EN_DATA_TYPE_0 BIT(7)
#define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16)
#define CSI2RX_STREAM_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x00c)
return 0;
}
-static int stf_csi_set_format(struct stf_csi_dev *csi_dev,
- u32 vsize, u8 bpp, int is_raw10)
-{
- struct stf_vin_dev *vin = csi_dev->stfcamss->vin;
-
- switch (csi_dev->s_type) {
- case SENSOR_VIN:
- st_err(ST_CSI, "%s, %d: need todo\n", __func__, __LINE__);
- break;
- case SENSOR_ISP:
- if (is_raw10)
- reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_36,
- BIT(12),
- 1 << 12);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
static void csi2rx_reset(void *reg_base)
{
writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT,
writel(0, reg_base + CSI2RX_SOFT_RESET_REG);
}
-static int csi2rx_start(struct stf_csi_dev *csi_dev, void *reg_base)
+static int csi2rx_start(struct stf_csi_dev *csi_dev, void *reg_base, u32 dt)
{
struct stfcamss *stfcamss = csi_dev->stfcamss;
struct csi2phy_cfg *csiphy =
reg_base + CSI2RX_STREAM_CFG_REG(i));
writel(CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT |
- CSI2RX_STREAM_DATA_CFG_VC_SELECT(i),
+ CSI2RX_STREAM_DATA_CFG_VC_SELECT(i) |
+ CSI2RX_STREAM_DATA_CFG_EN_DATA_TYPE_0 | dt,
reg_base + CSI2RX_STREAM_DATA_CFG_REG(i));
writel(CSI2RX_STREAM_CTRL_START,
writel(0, reg_base + CSI2RX_STREAM_CTRL_REG(i));
}
-static int stf_csi_stream_set(struct stf_csi_dev *csi_dev, int on)
+static int stf_csi_stream_set(struct stf_csi_dev *csi_dev,
+ int on, u32 dt, u32 width)
{
struct stfcamss *stfcamss = csi_dev->stfcamss;
struct stf_vin_dev *vin = csi_dev->stfcamss->vin;
0<<15); //u0_vin_cnfg_axiwr0_pixel_high_bit_sel
reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_28,
BIT(12)|BIT(11)|BIT(10)|BIT(9)|BIT(8)|BIT(7)|BIT(6)|BIT(5)|BIT(4)|BIT(3)|BIT(2),
- (1920 / 4 - 1)<<2); //u0_vin_cnfg_axiwr0_pix_cnt_end
+ (width / 4 - 1)<<2); //u0_vin_cnfg_axiwr0_pix_cnt_end
break;
case SENSOR_ISP:
clk_set_parent(stfcamss->sys_clk[STFCLK_WRAPPER_CLK_C].clk,
reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_36,
BIT(16)|BIT(15)|BIT(14)|BIT(13),
0<<13); //u0_vin_cnfg_pix_num
+
+ if (dt == 0x2b)
+ reg_set_bit(vin->sysctrl_base, SYSCONSAIF_SYSCFG_36,
+ BIT(12),
+ 1 << 12);
break;
default:
break;
}
if (on)
- csi2rx_start(csi_dev, reg_base);
+ csi2rx_start(csi_dev, reg_base, dt);
else
csi2rx_stop(csi_dev, reg_base);
.csi_power_on = stf_csi_power_on,
.csi_clk_enable = stf_csi_clk_enable,
.csi_clk_disable = stf_csi_clk_disable,
- .csi_set_format = stf_csi_set_format,
.csi_stream_set = stf_csi_stream_set,
};