Skip to content

Commit 6311a0d

Browse files
Niklas SöderlundHans Verkuil
authored andcommitted
media: staging: max96712: Add support for 3-lane C-PHY
Add basic support for outputting the test patterns on a 3-lane CSI-2 C-PHY bus. As the driver only can output frames form its internal test pattern generator, enabling C-PHY output is as simple as setting the output mode to C-PHY instead of D-PHY. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> [Sakari Ailus: Wrap long lines.] Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent 9f43234 commit 6311a0d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

drivers/staging/media/max96712/max96712.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct max96712_priv {
3030
struct regmap *regmap;
3131
struct gpio_desc *gpiod_pwdn;
3232

33+
bool cphy;
3334
struct v4l2_mbus_config_mipi_csi2 mipi;
3435

3536
struct v4l2_subdev sd;
@@ -127,10 +128,18 @@ static void max96712_mipi_configure(struct max96712_priv *priv)
127128
/* Select 2x4 mode. */
128129
max96712_write(priv, 0x8a0, 0x04);
129130

130-
/* Configure a 4-lane DPHY using PHY0 and PHY1. */
131131
/* TODO: Add support for 2-lane and 1-lane configurations. */
132-
/* TODO: Add support CPHY mode. */
133-
max96712_write(priv, 0x94a, 0xc0);
132+
if (priv->cphy) {
133+
/* Configure a 3-lane C-PHY using PHY0 and PHY1. */
134+
max96712_write(priv, 0x94a, 0xa0);
135+
136+
/* Configure C-PHY timings. */
137+
max96712_write(priv, 0x8ad, 0x3f);
138+
max96712_write(priv, 0x8ae, 0x7d);
139+
} else {
140+
/* Configure a 4-lane D-PHY using PHY0 and PHY1. */
141+
max96712_write(priv, 0x94a, 0xc0);
142+
}
134143

135144
/* Configure lane mapping for PHY0 and PHY1. */
136145
/* TODO: Add support for lane swapping. */
@@ -332,8 +341,9 @@ static int max96712_parse_dt(struct max96712_priv *priv)
332341
{
333342
struct fwnode_handle *ep;
334343
struct v4l2_fwnode_endpoint v4l2_ep = {
335-
.bus_type = V4L2_MBUS_CSI2_DPHY
344+
.bus_type = V4L2_MBUS_UNKNOWN,
336345
};
346+
unsigned int supported_lanes;
337347
int ret;
338348

339349
ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(&priv->client->dev), 4,
@@ -350,8 +360,24 @@ static int max96712_parse_dt(struct max96712_priv *priv)
350360
return -EINVAL;
351361
}
352362

353-
if (v4l2_ep.bus.mipi_csi2.num_data_lanes != 4) {
354-
dev_err(&priv->client->dev, "Only 4 data lanes supported\n");
363+
switch (v4l2_ep.bus_type) {
364+
case V4L2_MBUS_CSI2_DPHY:
365+
supported_lanes = 4;
366+
priv->cphy = false;
367+
break;
368+
case V4L2_MBUS_CSI2_CPHY:
369+
supported_lanes = 3;
370+
priv->cphy = true;
371+
break;
372+
default:
373+
dev_err(&priv->client->dev, "Unsupported bus-type %u\n",
374+
v4l2_ep.bus_type);
375+
return -EINVAL;
376+
}
377+
378+
if (v4l2_ep.bus.mipi_csi2.num_data_lanes != supported_lanes) {
379+
dev_err(&priv->client->dev, "Only %u data lanes supported\n",
380+
supported_lanes);
355381
return -EINVAL;
356382
}
357383

0 commit comments

Comments
 (0)