Skip to content

Commit

Permalink
media: i2c: adv7180: Add support for V4L2_CID_LINK_FREQ
Browse files Browse the repository at this point in the history
For CSI2 receivers that need to know the link frequency,
add it as a control to the driver.
Interlaced modes are 216Mbp/s or 108MHz, whilst going through
the I2P to deinterlace gives 432Mb/s or 216MHz.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
  • Loading branch information
6by9 committed Dec 21, 2023
1 parent 4b993bb commit f6bcd6b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion drivers/media/i2c/adv7180.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@
/* Initial number of frames to skip to avoid possible garbage */
#define ADV7180_NUM_OF_SKIP_FRAMES 2

enum adv7180_link_freq_idx {
INTERLACED_IDX,
I2P_IDX,
};

static const s64 adv7180_link_freqs[] = {
[INTERLACED_IDX] = 108000000,
[I2P_IDX] = 216000000,
};

static int dbg_input;
module_param(dbg_input, int, 0644);
MODULE_PARM_DESC(dbg_input, "Input number (0-31)");
Expand Down Expand Up @@ -227,6 +237,7 @@ struct adv7180_state {
const struct adv7180_chip_info *chip_info;
enum v4l2_field field;
bool force_bt656_4;
struct v4l2_ctrl *link_freq;
};
#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \
struct adv7180_state, \
Expand Down Expand Up @@ -681,7 +692,7 @@ static const struct v4l2_ctrl_config adv7180_ctrl_fast_switch = {

static int adv7180_init_controls(struct adv7180_state *state)
{
v4l2_ctrl_handler_init(&state->ctrl_hdl, 4);
v4l2_ctrl_handler_init(&state->ctrl_hdl, 5);

v4l2_ctrl_new_std(&state->ctrl_hdl, &adv7180_ctrl_ops,
V4L2_CID_BRIGHTNESS, ADV7180_BRI_MIN,
Expand All @@ -703,6 +714,12 @@ static int adv7180_init_controls(struct adv7180_state *state)
0, ARRAY_SIZE(test_pattern_menu) - 1,
test_pattern_menu);

state->link_freq =
v4l2_ctrl_new_int_menu(&state->ctrl_hdl, &adv7180_ctrl_ops,
V4L2_CID_LINK_FREQ,
ARRAY_SIZE(adv7180_link_freqs) - 1, 0,
adv7180_link_freqs);

state->sd.ctrl_handler = &state->ctrl_hdl;
if (state->ctrl_hdl.error) {
int err = state->ctrl_hdl.error;
Expand Down Expand Up @@ -835,6 +852,11 @@ static int adv7180_set_pad_format(struct v4l2_subdev *sd,
adv7180_set_power(state, false);
adv7180_set_field_mode(state);
adv7180_set_power(state, true);
if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
__v4l2_ctrl_s_ctrl(state->link_freq,
state->field == V4L2_FIELD_NONE ?
I2P_IDX : INTERLACED_IDX);
}
}
} else {
framefmt = v4l2_subdev_get_try_format(sd, sd_state, 0);
Expand Down

0 comments on commit f6bcd6b

Please sign in to comment.