mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
media: qcom: camss: Split testgen, RDI and RX for CSID 170
Split the RAW interface (RDI), the CSID receiver (RX) and test pattern generator (testgen), configurations for CSID on Titan 170 Signed-off-by: Milen Mitkov <quic_mmitkov@quicinc.com> Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016 Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil: folded https://lore.kernel.org/linux-media/20240626074730.85-1-quic_grosikop@quicinc.com/ into this patch]
This commit is contained in:
parent
ad458cb90f
commit
729fc005c8
@ -176,40 +176,51 @@
|
||||
#define TPG_COLOR_BOX_CFG_MODE 0
|
||||
#define TPG_COLOR_BOX_PATTERN_SEL 2
|
||||
|
||||
static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
|
||||
static void __csid_configure_rx(struct csid_device *csid,
|
||||
struct csid_phy_config *phy, int vc)
|
||||
{
|
||||
struct csid_testgen_config *tg = &csid->testgen;
|
||||
u32 val;
|
||||
u32 phy_sel = 0;
|
||||
u8 lane_cnt = csid->phy.lane_cnt;
|
||||
/* Source pads matching RDI channels on hardware. Pad 1 -> RDI0, Pad 2 -> RDI1, etc. */
|
||||
struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
|
||||
const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
|
||||
csid->res->formats->nformats,
|
||||
input_format->code);
|
||||
int val;
|
||||
|
||||
if (!lane_cnt)
|
||||
lane_cnt = 4;
|
||||
|
||||
if (!tg->enabled)
|
||||
phy_sel = csid->phy.csiphy_id;
|
||||
val = (lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
|
||||
val |= phy->lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
|
||||
val |= phy->csiphy_id << CSI2_RX_CFG0_PHY_NUM_SEL;
|
||||
writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
|
||||
|
||||
if (enable) {
|
||||
/*
|
||||
* DT_ID is a two bit bitfield that is concatenated with
|
||||
* the four least significant bits of the five bit VC
|
||||
* bitfield to generate an internal CID value.
|
||||
*
|
||||
* CSID_RDI_CFG0(vc)
|
||||
* DT_ID : 28:27
|
||||
* VC : 26:22
|
||||
* DT : 21:16
|
||||
*
|
||||
* CID : VC 3:0 << 2 | DT_ID 1:0
|
||||
*/
|
||||
u8 dt_id = vc & 0x03;
|
||||
val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
|
||||
if (vc > 3)
|
||||
val |= 1 << CSI2_RX_CFG1_VC_MODE;
|
||||
val |= 1 << CSI2_RX_CFG1_MISR_EN;
|
||||
writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
|
||||
}
|
||||
|
||||
static void __csid_ctrl_rdi(struct csid_device *csid, int enable, u8 rdi)
|
||||
{
|
||||
int val;
|
||||
|
||||
if (enable)
|
||||
val = HALT_CMD_RESUME_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
|
||||
else
|
||||
val = HALT_CMD_HALT_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
|
||||
writel_relaxed(val, csid->base + CSID_RDI_CTRL(rdi));
|
||||
}
|
||||
|
||||
static void __csid_configure_testgen(struct csid_device *csid, u8 enable, u8 vc)
|
||||
{
|
||||
struct csid_testgen_config *tg = &csid->testgen;
|
||||
struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
|
||||
const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
|
||||
csid->res->formats->nformats,
|
||||
input_format->code);
|
||||
u8 lane_cnt = csid->phy.lane_cnt;
|
||||
u32 val;
|
||||
|
||||
if (!lane_cnt)
|
||||
lane_cnt = 4;
|
||||
|
||||
if (tg->enabled) {
|
||||
/* configure one DT, infinite frames */
|
||||
val = vc << TPG_VC_CFG0_VC_NUM;
|
||||
val |= INTELEAVING_MODE_ONE_SHOT << TPG_VC_CFG0_LINE_INTERLEAVING_MODE;
|
||||
@ -237,8 +248,39 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
|
||||
writel_relaxed(0, csid->base + CSID_TPG_COLOR_BARS_CFG);
|
||||
|
||||
writel_relaxed(0, csid->base + CSID_TPG_COLOR_BOX_CFG);
|
||||
|
||||
val = enable << TPG_CTRL_TEST_EN;
|
||||
val |= 1 << TPG_CTRL_FS_PKT_EN;
|
||||
val |= 1 << TPG_CTRL_FE_PKT_EN;
|
||||
val |= (lane_cnt - 1) << TPG_CTRL_NUM_ACTIVE_LANES;
|
||||
val |= 0x64 << TPG_CTRL_CYCLES_BETWEEN_PKTS;
|
||||
val |= 0xA << TPG_CTRL_NUM_TRAIL_BYTES;
|
||||
writel_relaxed(val, csid->base + CSID_TPG_CTRL);
|
||||
}
|
||||
|
||||
static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8 vc)
|
||||
{
|
||||
/* Source pads matching RDI channels on hardware. Pad 1 -> RDI0, Pad 2 -> RDI1, etc. */
|
||||
struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
|
||||
const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
|
||||
csid->res->formats->nformats,
|
||||
input_format->code);
|
||||
u32 val;
|
||||
|
||||
/*
|
||||
* DT_ID is a two bit bitfield that is concatenated with
|
||||
* the four least significant bits of the five bit VC
|
||||
* bitfield to generate an internal CID value.
|
||||
*
|
||||
* CSID_RDI_CFG0(vc)
|
||||
* DT_ID : 28:27
|
||||
* VC : 26:22
|
||||
* DT : 21:16
|
||||
*
|
||||
* CID : VC 3:0 << 2 | DT_ID 1:0
|
||||
*/
|
||||
u8 dt_id = vc & 0x03;
|
||||
|
||||
val = 1 << RDI_CFG0_BYTE_CNTR_EN;
|
||||
val |= 1 << RDI_CFG0_FORMAT_MEASURE_EN;
|
||||
val |= 1 << RDI_CFG0_TIMESTAMP_EN;
|
||||
@ -281,45 +323,24 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
|
||||
writel_relaxed(val, csid->base + CSID_RDI_CTRL(vc));
|
||||
|
||||
val = readl_relaxed(csid->base + CSID_RDI_CFG0(vc));
|
||||
val |= 1 << RDI_CFG0_ENABLE;
|
||||
val |= enable << RDI_CFG0_ENABLE;
|
||||
writel_relaxed(val, csid->base + CSID_RDI_CFG0(vc));
|
||||
}
|
||||
|
||||
if (tg->enabled) {
|
||||
val = enable << TPG_CTRL_TEST_EN;
|
||||
val |= 1 << TPG_CTRL_FS_PKT_EN;
|
||||
val |= 1 << TPG_CTRL_FE_PKT_EN;
|
||||
val |= (lane_cnt - 1) << TPG_CTRL_NUM_ACTIVE_LANES;
|
||||
val |= 0x64 << TPG_CTRL_CYCLES_BETWEEN_PKTS;
|
||||
val |= 0xA << TPG_CTRL_NUM_TRAIL_BYTES;
|
||||
writel_relaxed(val, csid->base + CSID_TPG_CTRL);
|
||||
}
|
||||
|
||||
val = (lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
|
||||
val |= csid->phy.lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
|
||||
val |= phy_sel << CSI2_RX_CFG0_PHY_NUM_SEL;
|
||||
writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
|
||||
|
||||
val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
|
||||
if (vc > 3)
|
||||
val |= 1 << CSI2_RX_CFG1_VC_MODE;
|
||||
val |= 1 << CSI2_RX_CFG1_MISR_EN;
|
||||
writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
|
||||
|
||||
if (enable)
|
||||
val = HALT_CMD_RESUME_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
|
||||
else
|
||||
val = HALT_CMD_HALT_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
|
||||
writel_relaxed(val, csid->base + CSID_RDI_CTRL(vc));
|
||||
}
|
||||
|
||||
static void csid_configure_stream(struct csid_device *csid, u8 enable)
|
||||
{
|
||||
struct csid_testgen_config *tg = &csid->testgen;
|
||||
u8 i;
|
||||
/* Loop through all enabled VCs and configure stream for each */
|
||||
for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++)
|
||||
if (csid->phy.en_vc & BIT(i))
|
||||
__csid_configure_stream(csid, enable, i);
|
||||
if (csid->phy.en_vc & BIT(i)) {
|
||||
if (tg->enabled)
|
||||
__csid_configure_testgen(csid, enable, i);
|
||||
|
||||
__csid_configure_rdi_stream(csid, enable, i);
|
||||
__csid_configure_rx(csid, &csid->phy, i);
|
||||
__csid_ctrl_rdi(csid, enable, i);
|
||||
}
|
||||
}
|
||||
|
||||
static int csid_configure_testgen_pattern(struct csid_device *csid, s32 val)
|
||||
|
Loading…
Reference in New Issue
Block a user