Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: adv7180: fix adv7280 BT.656-4 compatibility

Captured video would be out of sync when using the adv7280 with
the BT.656-4 protocol. Certain registers (0x04, 0x31, 0xE6) had to
be configured properly to ensure BT.656-4 compatibility.

An error in the adv7280 reference manual suggested that EAV/SAV mode
was enabled by default, however upon inspecting register 0x31, it was
determined to be disabled by default.

[fabio: Introduce "adv,force-bt656-4" to not affect the existing users]
[hverkuil: fix a small checkpatch alignment warning]

Signed-off-by: Matthew Michilot <matthew.michilot@gmail.com>
Reviewed-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Matthew Michilot and committed by
Mauro Carvalho Chehab
ed771d75 28d1e476

+26 -4
+26 -4
drivers/media/i2c/adv7180.c
··· 94 94 #define ADV7180_REG_SHAP_FILTER_CTL_1 0x0017 95 95 #define ADV7180_REG_CTRL_2 0x001d 96 96 #define ADV7180_REG_VSYNC_FIELD_CTL_1 0x0031 97 + #define ADV7180_VSYNC_FIELD_CTL_1_NEWAV 0x12 97 98 #define ADV7180_REG_MANUAL_WIN_CTL_1 0x003d 98 99 #define ADV7180_REG_MANUAL_WIN_CTL_2 0x003e 99 100 #define ADV7180_REG_MANUAL_WIN_CTL_3 0x003f ··· 218 217 struct i2c_client *vpp_client; 219 218 const struct adv7180_chip_info *chip_info; 220 219 enum v4l2_field field; 220 + bool force_bt656_4; 221 221 }; 222 222 #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \ 223 223 struct adv7180_state, \ ··· 979 977 adv7180_write(state, ADV7180_REG_EXTENDED_OUTPUT_CONTROL, 0x57); 980 978 adv7180_write(state, ADV7180_REG_CTRL_2, 0xc0); 981 979 } else { 982 - if (state->chip_info->flags & ADV7180_FLAG_V2) 983 - adv7180_write(state, 984 - ADV7180_REG_EXTENDED_OUTPUT_CONTROL, 985 - 0x17); 980 + if (state->chip_info->flags & ADV7180_FLAG_V2) { 981 + if (state->force_bt656_4) { 982 + /* ITU-R BT.656-4 compatible */ 983 + adv7180_write(state, 984 + ADV7180_REG_EXTENDED_OUTPUT_CONTROL, 985 + ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS); 986 + /* Manually set NEWAVMODE */ 987 + adv7180_write(state, 988 + ADV7180_REG_VSYNC_FIELD_CTL_1, 989 + ADV7180_VSYNC_FIELD_CTL_1_NEWAV); 990 + /* Manually set V bit end position in NTSC mode */ 991 + adv7180_write(state, 992 + ADV7180_REG_NTSC_V_BIT_END, 993 + ADV7180_NTSC_V_BIT_END_MANUAL_NVEND); 994 + } else { 995 + adv7180_write(state, 996 + ADV7180_REG_EXTENDED_OUTPUT_CONTROL, 997 + 0x17); 998 + } 999 + } 986 1000 else 987 1001 adv7180_write(state, 988 1002 ADV7180_REG_EXTENDED_OUTPUT_CONTROL, ··· 1347 1329 static int adv7180_probe(struct i2c_client *client, 1348 1330 const struct i2c_device_id *id) 1349 1331 { 1332 + struct device_node *np = client->dev.of_node; 1350 1333 struct adv7180_state *state; 1351 1334 struct v4l2_subdev *sd; 1352 1335 int ret; ··· 1379 1360 v4l_err(client, "request for reset pin failed: %d\n", ret); 1380 1361 return ret; 1381 1362 } 1363 + 1364 + if (of_property_read_bool(np, "adv,force-bt656-4")) 1365 + state->force_bt656_4 = true; 1382 1366 1383 1367 if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) { 1384 1368 state->csi_client = i2c_new_dummy_device(client->adapter,