Skip to content

Commit

Permalink
media: st-mipid02: add support of V4L2_CID_LINK_FREQ
Browse files Browse the repository at this point in the history
Ask device connected on sink pad for link frequency
in order to configure CLK_LANE_REG1 (ui_x4).
If not available, ask for pixel rate information to compute it.

This is needed to deal with compressed format such as JPEG
where number of bits per pixel is unknown: computation of
link frequency from pixel rate is not possible.

Signed-off-by: Hugues Fruchet <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
hfr72 authored and mchehab committed Jun 24, 2019
1 parent 81a409b commit 6a381d1
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions drivers/media/i2c/st-mipid02.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@ static int mipid02_detect(struct mipid02_dev *bridge)
return mipid02_read_reg(bridge, MIPID02_CLK_LANE_WR_REG1, &reg);
}

static u32 mipid02_get_link_freq_from_cid_link_freq(struct mipid02_dev *bridge,
struct v4l2_subdev *subdev)
{
struct v4l2_querymenu qm = {.id = V4L2_CID_LINK_FREQ, };
struct v4l2_ctrl *ctrl;
int ret;

ctrl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_LINK_FREQ);
if (!ctrl)
return 0;
qm.index = v4l2_ctrl_g_ctrl(ctrl);

ret = v4l2_querymenu(subdev->ctrl_handler, &qm);
if (ret)
return 0;

return qm.value;
}

static u32 mipid02_get_link_freq_from_cid_pixel_rate(struct mipid02_dev *bridge,
struct v4l2_subdev *subdev)
{
Expand Down Expand Up @@ -358,10 +377,14 @@ static int mipid02_configure_from_rx_speed(struct mipid02_dev *bridge)
struct v4l2_subdev *subdev = bridge->s_subdev;
u32 link_freq;

link_freq = mipid02_get_link_freq_from_cid_pixel_rate(bridge, subdev);
link_freq = mipid02_get_link_freq_from_cid_link_freq(bridge, subdev);
if (!link_freq) {
dev_err(&client->dev, "Failed to detect link frequency");
return -EINVAL;
link_freq = mipid02_get_link_freq_from_cid_pixel_rate(bridge,
subdev);
if (!link_freq) {
dev_err(&client->dev, "Failed to get link frequency");
return -EINVAL;
}
}

dev_dbg(&client->dev, "detect link_freq = %d Hz", link_freq);
Expand Down

0 comments on commit 6a381d1

Please sign in to comment.