Skip to content

Commit 189c9ef

Browse files
Loic PoulainBryan O'Donoghue
authored andcommitted
media: qcom: camss: csid-340: Add port-to-interface mapping
The CSID-340 block uses different register offsets for the PIX and RDI interfaces, but the driver previously indexed these registers directly with the camss port number. This happened to work for RDI because the port index matches the RDI register layout, but this assumption breaks with upcoming PIX interface support Introduce an explicit port-to-interface mapping and use the mapped iface index when programming CSID_CFG0 and CSID_CTRL. This replaces the standalone __csid_ctrl_rdi() helper and simplifies the RDI stream setup path. Also correct the CSID_CFG0/CTRL base offsets and clean up the code in preparation for full PIX path support. Like RDI, PIX outputs Bayer frames but can also achieve some image processing such as scaling, cropping and generating statitics (e.g. histogram), it also offer more flexebility in term of image alignment and stride. All of that can then later be leveraged to improve software or hardware frames post-processing. Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
1 parent 83fcf11 commit 189c9ef

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

drivers/media/platform/qcom/camss/camss-csid-340.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define CSI2_RX_CFG1_MISR_EN BIT(6)
4242
#define CSI2_RX_CFG1_CGC_MODE BIT(7)
4343

44-
#define CSID_CFG0(iface) (0x300 + 0x100 * (iface))
44+
#define CSID_CFG0(iface) (0x200 + 0x100 * (iface))
4545
#define CSID_CFG0_BYTE_CNTR_EN BIT(0)
4646
#define CSID_CFG0_TIMESTAMP_EN BIT(1)
4747
#define CSID_CFG0_DECODE_FORMAT_MASK GENMASK(15, 12)
@@ -51,10 +51,24 @@
5151
#define CSID_CFG0_DTID_MASK GENMASK(28, 27)
5252
#define CSID_CFG0_ENABLE BIT(31)
5353

54-
#define CSID_CTRL(iface) (0x308 + 0x100 * (iface))
54+
#define CSID_CTRL(iface) (0x208 + 0x100 * (iface))
5555
#define CSID_CTRL_HALT_AT_FRAME_BOUNDARY 0
5656
#define CSID_CTRL_RESUME_AT_FRAME_BOUNDARY 1
5757

58+
#define CSID_MAX_RDI_SRC_STREAMS (MSM_CSID_MAX_SRC_STREAMS - 1)
59+
60+
enum csid_iface {
61+
CSID_IFACE_PIX,
62+
CSID_IFACE_RDI0,
63+
CSID_IFACE_RDI1,
64+
CSID_IFACE_RDI2,
65+
};
66+
67+
static enum csid_iface csid_port_iface_map[CSID_MAX_RDI_SRC_STREAMS] = {
68+
[0] = CSID_IFACE_RDI0,
69+
[1] = CSID_IFACE_RDI1,
70+
[2] = CSID_IFACE_RDI2,
71+
};
5872

5973
static void __csid_configure_rx(struct csid_device *csid, struct csid_phy_config *phy)
6074
{
@@ -70,17 +84,13 @@ static void __csid_configure_rx(struct csid_device *csid, struct csid_phy_config
7084
writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
7185
}
7286

73-
static void __csid_ctrl_rdi(struct csid_device *csid, int enable, u8 rdi)
74-
{
75-
writel_relaxed(!!enable, csid->base + CSID_CTRL(rdi));
76-
}
77-
7887
static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8 port, u8 vc)
7988
{
8089
struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + port];
8190
const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
8291
csid->res->formats->nformats,
8392
input_format->code);
93+
enum csid_iface iface = csid_port_iface_map[port];
8494
u8 dt_id;
8595
u32 val;
8696

@@ -110,7 +120,8 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8
110120
csid->id, enable ? "enable" : "disable", format->data_type,
111121
port, vc);
112122

113-
writel_relaxed(val, csid->base + CSID_CFG0(port));
123+
writel_relaxed(val, csid->base + CSID_CFG0(iface));
124+
writel_relaxed(enable, csid->base + CSID_CTRL(iface));
114125
}
115126

116127
static void csid_configure_stream(struct csid_device *csid, u8 enable)
@@ -119,12 +130,10 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
119130

120131
__csid_configure_rx(csid, &csid->phy);
121132

122-
/* Loop through all enabled ports and configure a stream for each */
123-
for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++) {
124-
if (csid->phy.en_vc & BIT(i)) {
125-
__csid_configure_rdi_stream(csid, enable, i, 0);
126-
__csid_ctrl_rdi(csid, enable, i);
127-
}
133+
/* RDIs */
134+
for (i = 0; i < CSID_MAX_RDI_SRC_STREAMS; i++) {
135+
if (csid->phy.en_vc & BIT(i))
136+
__csid_configure_rdi_stream(csid, !!enable, i, 0);
128137
}
129138
}
130139

0 commit comments

Comments
 (0)