media: i2c: tc35874x: Fix tc35874x cannot work properly

1.Change the format to MEDIA_BUS_FMT_UYVY8_2X8.
2.Add the PIXEL_RATE for control handlers.

Change-Id: I4f40e3d90765c12702210f88ad60f2147d328456
Signed-off-by: Leo Wen <leo.wen@rock-chips.com>
This commit is contained in:
Leo Wen
2018-10-18 09:10:21 +08:00
committed by Tao Huang
parent 795691a170
commit b08beb0cd8

View File

@@ -66,8 +66,10 @@ MODULE_LICENSE("GPL");
#define POLL_INTERVAL_MS 1000
#define TC35874X_LINK_FREQ_300MHZ 300000000
#define TC35874X_PIXEL_RATE (TC35874X_LINK_FREQ_300MHZ * 2 * 2 / 8)
static const s64 link_freq_menu_items[] = {
300000000,
TC35874X_LINK_FREQ_300MHZ,
};
static const struct v4l2_dv_timings_cap tc35874x_timings_cap = {
@@ -661,7 +663,7 @@ static void tc35874x_set_csi_color_space(struct v4l2_subdev *sd)
struct tc35874x_state *state = to_state(sd);
switch (state->mbus_fmt_code) {
case MEDIA_BUS_FMT_UYVY8_1X16:
case MEDIA_BUS_FMT_UYVY8_2X8:
v4l2_dbg(2, debug, sd, "%s: YCbCr 422 16-bit\n", __func__);
i2c_wr8_and_or(sd, VOUT_SET2,
~(MASK_SEL422 | MASK_VOUT_422FIL_100) & 0xff,
@@ -1184,7 +1186,7 @@ static int tc35874x_log_status(struct v4l2_subdev *sd)
(i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT) ?
"yes" : "no");
v4l2_info(sd, "Color space: %s\n",
state->mbus_fmt_code == MEDIA_BUS_FMT_UYVY8_1X16 ?
state->mbus_fmt_code == MEDIA_BUS_FMT_UYVY8_2X8 ?
"YCbCr 422 16-bit" :
state->mbus_fmt_code == MEDIA_BUS_FMT_RGB888_1X24 ?
"RGB 888 24-bit" : "Unsupported");
@@ -1515,7 +1517,7 @@ static int tc35874x_enum_mbus_code(struct v4l2_subdev *sd,
code->code = MEDIA_BUS_FMT_RGB888_1X24;
break;
case 1:
code->code = MEDIA_BUS_FMT_UYVY8_1X16;
code->code = MEDIA_BUS_FMT_UYVY8_2X8;
break;
default:
return -EINVAL;
@@ -1572,7 +1574,7 @@ static int tc35874x_set_fmt(struct v4l2_subdev *sd,
switch (code) {
case MEDIA_BUS_FMT_RGB888_1X24:
case MEDIA_BUS_FMT_UYVY8_1X16:
case MEDIA_BUS_FMT_UYVY8_2X8:
break;
default:
return -EINVAL;
@@ -1918,7 +1920,13 @@ static int tc35874x_probe(struct i2c_client *client,
}
/* control handlers */
v4l2_ctrl_handler_init(&state->hdl, 3);
v4l2_ctrl_handler_init(&state->hdl, 4);
v4l2_ctrl_new_int_menu(&state->hdl, NULL, V4L2_CID_LINK_FREQ,
0, 0, link_freq_menu_items);
v4l2_ctrl_new_std(&state->hdl, NULL, V4L2_CID_PIXEL_RATE,
0, TC35874X_PIXEL_RATE, 1, TC35874X_PIXEL_RATE);
state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(&state->hdl, NULL,
V4L2_CID_DV_RX_POWER_PRESENT, 0, 1, 0, 0);
@@ -1930,9 +1938,6 @@ static int tc35874x_probe(struct i2c_client *client,
state->audio_present_ctrl = v4l2_ctrl_new_custom(&state->hdl,
&tc35874x_ctrl_audio_present, NULL);
v4l2_ctrl_new_int_menu(&state->hdl, NULL, V4L2_CID_LINK_FREQ,
0, 0, link_freq_menu_items);
sd->ctrl_handler = &state->hdl;
if (state->hdl.error) {
err = state->hdl.error;
@@ -1945,11 +1950,12 @@ static int tc35874x_probe(struct i2c_client *client,
}
state->pad.flags = MEDIA_PAD_FL_SOURCE;
sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
err = media_entity_init(&sd->entity, 1, &state->pad, 0);
if (err < 0)
goto err_hdl;
state->mbus_fmt_code = MEDIA_BUS_FMT_UYVY8_1X16;
state->mbus_fmt_code = MEDIA_BUS_FMT_UYVY8_2X8;
sd->dev = &client->dev;
err = v4l2_async_register_subdev(sd);