Lines Matching +full:vs +full:- +full:soft +full:- +full:start +full:- +full:strength
1 // SPDX-License-Identifier: GPL-2.0-only
3 * adv7842 - Analog Devices ADV7842 video decoder driver
10 * REF_01 - Analog devices, ADV7842,
12 * REF_02 - Analog devices, Software User Guide, UG-206,
14 * REF_03 - Analog devices, Hardware User Guide, UG-214,
15 * ADV7842 Fast Switching 2:1 HDMI 1.4 Receiver with 3D-Comb
27 #include <linux/v4l2-dv-timings.h>
30 #include <media/v4l2-device.h>
31 #include <media/v4l2-event.h>
32 #include <media/v4l2-ctrls.h>
33 #include <media/v4l2-dv-timings.h>
38 MODULE_PARM_DESC(debug, "debug level (0-2)");
247 /* ----------------------------------------------------------------------- */
256 return &container_of(ctrl->handler, struct adv7842_state, hdl)->sd; in to_sd()
270 /* ----------------------------------------------------------------------- */
277 if (!i2c_smbus_xfer(client->adapter, client->addr, client->flags, in adv_smbus_read_byte_data_check()
283 client->addr, command); in adv_smbus_read_byte_data_check()
284 return -EIO; in adv_smbus_read_byte_data_check()
301 return -EIO; in adv_smbus_read_byte_data()
313 err = i2c_smbus_xfer(client->adapter, client->addr, in adv_smbus_write_byte_data()
314 client->flags, in adv_smbus_write_byte_data()
322 client->addr, command, value); in adv_smbus_write_byte_data()
332 i2c_smbus_xfer(client->adapter, client->addr, in adv_smbus_write_byte_no_check()
333 client->flags, in adv_smbus_write_byte_no_check()
338 /* ----------------------------------------------------------------------- */
369 return adv_smbus_read_byte_data(state->i2c_avlink, reg); in avlink_read()
376 return adv_smbus_write_byte_data(state->i2c_avlink, reg, val); in avlink_write()
383 return adv_smbus_read_byte_data(state->i2c_cec, reg); in cec_read()
390 return adv_smbus_write_byte_data(state->i2c_cec, reg, val); in cec_write()
402 return adv_smbus_read_byte_data(state->i2c_infoframe, reg); in infoframe_read()
409 return adv_smbus_write_byte_data(state->i2c_infoframe, reg, val); in infoframe_write()
416 return adv_smbus_read_byte_data(state->i2c_sdp_io, reg); in sdp_io_read()
423 return adv_smbus_write_byte_data(state->i2c_sdp_io, reg, val); in sdp_io_write()
435 return adv_smbus_read_byte_data(state->i2c_sdp, reg); in sdp_read()
442 return adv_smbus_write_byte_data(state->i2c_sdp, reg, val); in sdp_write()
454 return adv_smbus_read_byte_data(state->i2c_afe, reg); in afe_read()
461 return adv_smbus_write_byte_data(state->i2c_afe, reg, val); in afe_write()
473 return adv_smbus_read_byte_data(state->i2c_repeater, reg); in rep_read()
480 return adv_smbus_write_byte_data(state->i2c_repeater, reg, val); in rep_write()
492 return adv_smbus_read_byte_data(state->i2c_edid, reg); in edid_read()
499 return adv_smbus_write_byte_data(state->i2c_edid, reg, val); in edid_write()
506 return adv_smbus_read_byte_data(state->i2c_hdmi, reg); in hdmi_read()
513 return adv_smbus_write_byte_data(state->i2c_hdmi, reg, val); in hdmi_write()
525 return adv_smbus_read_byte_data(state->i2c_cp, reg); in cp_read()
532 return adv_smbus_write_byte_data(state->i2c_cp, reg, val); in cp_write()
544 return adv_smbus_read_byte_data(state->i2c_vdp, reg); in vdp_read()
551 return adv_smbus_write_byte_data(state->i2c_vdp, reg, val); in vdp_write()
565 /* -----------------------------------------------------------------------------
623 /* ----------------------------------------------------------------------- */
629 return ((state->mode == ADV7842_MODE_RGB) || in is_analog_input()
630 (state->mode == ADV7842_MODE_COMP)); in is_analog_input()
637 return state->mode == ADV7842_MODE_HDMI; in is_digital_input()
669 /* ----------------------------------------------------------------------- */
688 struct v4l2_subdev *sd = &state->sd; in adv7842_delayed_work_enable_hotplug()
689 int present = state->hdmi_edid.present; in adv7842_delayed_work_enable_hotplug()
706 const u8 *edid = state->vga_edid.edid; in edid_write_vga_segment()
707 u32 blocks = state->vga_edid.blocks; in edid_write_vga_segment()
713 if (!state->vga_edid.present) in edid_write_vga_segment()
726 err = i2c_smbus_write_i2c_block_data(state->i2c_edid, i, in edid_write_vga_segment()
744 return -EIO; in edid_write_vga_segment()
748 schedule_delayed_work(&state->delayed_work_enable_hotplug, HZ / 5); in edid_write_vga_segment()
757 const u8 *edid = state->hdmi_edid.edid; in edid_write_hdmi_segment()
758 u32 blocks = state->hdmi_edid.blocks; in edid_write_hdmi_segment()
773 if (!state->hdmi_edid.present) { in edid_write_hdmi_segment()
774 cec_phys_addr_invalidate(state->cec_adap); in edid_write_hdmi_segment()
797 err = i2c_smbus_write_i2c_block_data(state->i2c_edid, i, in edid_write_hdmi_segment()
816 rep_write_and_or(sd, 0x77, 0xf3, state->hdmi_edid.present); in edid_write_hdmi_segment()
819 if (rep_read(sd, 0x7d) & state->hdmi_edid.present) in edid_write_hdmi_segment()
826 return -EIO; in edid_write_hdmi_segment()
828 cec_s_phys_addr(state->cec_adap, parent_pa, false); in edid_write_hdmi_segment()
831 schedule_delayed_work(&state->delayed_work_enable_hotplug, HZ / 5); in edid_write_hdmi_segment()
836 /* ----------------------------------------------------------------------- */
841 v4l2_info(sd, "0x000-0x0ff: IO Map\n"); in adv7842_inv_register()
842 v4l2_info(sd, "0x100-0x1ff: AVLink Map\n"); in adv7842_inv_register()
843 v4l2_info(sd, "0x200-0x2ff: CEC Map\n"); in adv7842_inv_register()
844 v4l2_info(sd, "0x300-0x3ff: InfoFrame Map\n"); in adv7842_inv_register()
845 v4l2_info(sd, "0x400-0x4ff: SDP_IO Map\n"); in adv7842_inv_register()
846 v4l2_info(sd, "0x500-0x5ff: SDP Map\n"); in adv7842_inv_register()
847 v4l2_info(sd, "0x600-0x6ff: AFE Map\n"); in adv7842_inv_register()
848 v4l2_info(sd, "0x700-0x7ff: Repeater Map\n"); in adv7842_inv_register()
849 v4l2_info(sd, "0x800-0x8ff: EDID Map\n"); in adv7842_inv_register()
850 v4l2_info(sd, "0x900-0x9ff: HDMI Map\n"); in adv7842_inv_register()
851 v4l2_info(sd, "0xa00-0xaff: CP Map\n"); in adv7842_inv_register()
852 v4l2_info(sd, "0xb00-0xbff: VDP Map\n"); in adv7842_inv_register()
858 reg->size = 1; in adv7842_g_register()
859 switch (reg->reg >> 8) { in adv7842_g_register()
861 reg->val = io_read(sd, reg->reg & 0xff); in adv7842_g_register()
864 reg->val = avlink_read(sd, reg->reg & 0xff); in adv7842_g_register()
867 reg->val = cec_read(sd, reg->reg & 0xff); in adv7842_g_register()
870 reg->val = infoframe_read(sd, reg->reg & 0xff); in adv7842_g_register()
873 reg->val = sdp_io_read(sd, reg->reg & 0xff); in adv7842_g_register()
876 reg->val = sdp_read(sd, reg->reg & 0xff); in adv7842_g_register()
879 reg->val = afe_read(sd, reg->reg & 0xff); in adv7842_g_register()
882 reg->val = rep_read(sd, reg->reg & 0xff); in adv7842_g_register()
885 reg->val = edid_read(sd, reg->reg & 0xff); in adv7842_g_register()
888 reg->val = hdmi_read(sd, reg->reg & 0xff); in adv7842_g_register()
891 reg->val = cp_read(sd, reg->reg & 0xff); in adv7842_g_register()
894 reg->val = vdp_read(sd, reg->reg & 0xff); in adv7842_g_register()
897 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7842_g_register()
907 u8 val = reg->val & 0xff; in adv7842_s_register()
909 switch (reg->reg >> 8) { in adv7842_s_register()
911 io_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
914 avlink_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
917 cec_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
920 infoframe_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
923 sdp_io_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
926 sdp_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
929 afe_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
932 rep_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
935 edid_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
938 hdmi_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
941 cp_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
944 vdp_write(sd, reg->reg & 0xff, val); in adv7842_s_register()
947 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7842_s_register()
962 return v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, cable_det); in adv7842_s_detect_tx_5v_ctrl()
983 return -1; in find_and_set_predefined_video_timings()
1011 switch (state->mode) { in configure_predefined_video_timings()
1029 __func__, state->mode); in configure_predefined_video_timings()
1030 err = -1; in configure_predefined_video_timings()
1045 u16 cp_start_sav = bt->hsync + bt->hbackporch - 4; in configure_custom_video_timings()
1046 u16 cp_start_eav = width - bt->hfrontporch; in configure_custom_video_timings()
1047 u16 cp_start_vbi = height - bt->vfrontporch + 1; in configure_custom_video_timings()
1048 u16 cp_end_vbi = bt->vsync + bt->vbackporch + 1; in configure_custom_video_timings()
1049 u16 ch1_fr_ll = (((u32)bt->pixelclock / 100) > 0) ? in configure_custom_video_timings()
1050 ((width * (ADV7842_fsc / 100)) / ((u32)bt->pixelclock / 100)) : 0; in configure_custom_video_timings()
1058 switch (state->mode) { in configure_custom_video_timings()
1067 /* Should only be set in auto-graphics mode [REF_02, p. 91-92] */ in configure_custom_video_timings()
1069 /* IO-map reg. 0x16 and 0x17 should be written in sequence */ in configure_custom_video_timings()
1075 /* active video - horizontal timing */ in configure_custom_video_timings()
1081 /* active video - vertical timing */ in configure_custom_video_timings()
1095 __func__, state->mode); in configure_custom_video_timings()
1126 if (i2c_smbus_write_i2c_block_data(state->i2c_cp, 0x77, 4, offset_buf)) in adv7842_set_offset()
1155 if (i2c_smbus_write_i2c_block_data(state->i2c_cp, 0x73, 4, gain_buf)) in adv7842_set_gain()
1170 __func__, state->rgb_quantization_range, in set_rgb_quantization_range()
1177 switch (state->rgb_quantization_range) { in set_rgb_quantization_range()
1179 if (state->mode == ADV7842_MODE_RGB) { in set_rgb_quantization_range()
1181 * Set RGB full range (0-255) */ in set_rgb_quantization_range()
1186 if (state->mode == ADV7842_MODE_COMP) { in set_rgb_quantization_range()
1200 /* Receiving DVI-D signal in set_rgb_quantization_range()
1203 if (state->timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) { in set_rgb_quantization_range()
1204 /* RGB limited range (16-235) */ in set_rgb_quantization_range()
1207 /* RGB full range (0-255) */ in set_rgb_quantization_range()
1219 if (state->mode == ADV7842_MODE_COMP) { in set_rgb_quantization_range()
1220 /* YCrCb limited range (16-235) */ in set_rgb_quantization_range()
1228 /* RGB limited range (16-235) */ in set_rgb_quantization_range()
1233 if (state->mode == ADV7842_MODE_COMP) { in set_rgb_quantization_range()
1234 /* YCrCb full range (0-255) */ in set_rgb_quantization_range()
1242 /* RGB full range (0-255) */ in set_rgb_quantization_range()
1248 /* Adjust gain/offset for DVI-D signals only */ in set_rgb_quantization_range()
1268 switch (ctrl->id) { in adv7842_s_ctrl()
1271 cp_write(sd, 0x3c, ctrl->val); in adv7842_s_ctrl()
1272 sdp_write(sd, 0x14, ctrl->val); in adv7842_s_ctrl()
1276 cp_write(sd, 0x3a, ctrl->val); in adv7842_s_ctrl()
1277 sdp_write(sd, 0x13, ctrl->val); in adv7842_s_ctrl()
1281 cp_write(sd, 0x3b, ctrl->val); in adv7842_s_ctrl()
1282 sdp_write(sd, 0x15, ctrl->val); in adv7842_s_ctrl()
1286 cp_write(sd, 0x3d, ctrl->val); in adv7842_s_ctrl()
1287 sdp_write(sd, 0x16, ctrl->val); in adv7842_s_ctrl()
1292 afe_write(sd, 0xc8, ctrl->val); in adv7842_s_ctrl()
1295 cp_write_and_or(sd, 0xbf, ~0x04, (ctrl->val << 2)); in adv7842_s_ctrl()
1296 sdp_write_and_or(sd, 0xdd, ~0x04, (ctrl->val << 2)); in adv7842_s_ctrl()
1299 u8 R = (ctrl->val & 0xff0000) >> 16; in adv7842_s_ctrl()
1300 u8 G = (ctrl->val & 0x00ff00) >> 8; in adv7842_s_ctrl()
1301 u8 B = (ctrl->val & 0x0000ff); in adv7842_s_ctrl()
1302 /* RGB -> YUV, numerical approximation */ in adv7842_s_ctrl()
1304 int U = -38 * R - 74 * G + 112 * B; in adv7842_s_ctrl()
1305 int V = 112 * R - 94 * G - 18 * B; in adv7842_s_ctrl()
1329 state->rgb_quantization_range = ctrl->val; in adv7842_s_ctrl()
1333 return -EINVAL; in adv7842_s_ctrl()
1340 if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) { in adv7842_g_volatile_ctrl()
1341 ctrl->val = V4L2_DV_IT_CONTENT_TYPE_NO_ITC; in adv7842_g_volatile_ctrl()
1343 ctrl->val = (infoframe_read(sd, 0x05) >> 4) & 3; in adv7842_g_volatile_ctrl()
1346 return -EINVAL; in adv7842_g_volatile_ctrl()
1373 if (state->mode == ADV7842_MODE_SDP) { in adv7842_g_input_status()
1408 u32 hfreq = (ADV7842_fsc * 8) / stdi->bl; in stdi2dv_timings()
1419 if (vtotal(bt) != stdi->lcf + 1) in stdi2dv_timings()
1421 if (bt->vsync != stdi->lcvs) in stdi2dv_timings()
1426 if ((pix_clk < bt->pixelclock + 1000000) && in stdi2dv_timings()
1427 (pix_clk > bt->pixelclock - 1000000)) { in stdi2dv_timings()
1433 if (v4l2_detect_cvt(stdi->lcf + 1, hfreq, stdi->lcvs, 0, in stdi2dv_timings()
1434 (stdi->hs_pol == '+' ? V4L2_DV_HSYNC_POS_POL : 0) | in stdi2dv_timings()
1435 (stdi->vs_pol == '+' ? V4L2_DV_VSYNC_POS_POL : 0), in stdi2dv_timings()
1438 if (v4l2_detect_gtf(stdi->lcf + 1, hfreq, stdi->lcvs, in stdi2dv_timings()
1439 (stdi->hs_pol == '+' ? V4L2_DV_HSYNC_POS_POL : 0) | in stdi2dv_timings()
1440 (stdi->vs_pol == '+' ? V4L2_DV_VSYNC_POS_POL : 0), in stdi2dv_timings()
1441 false, state->aspect_ratio, timings)) in stdi2dv_timings()
1446 __func__, stdi->lcvs, stdi->lcf, stdi->bl, in stdi2dv_timings()
1447 stdi->hs_pol, stdi->vs_pol); in stdi2dv_timings()
1448 return -1; in stdi2dv_timings()
1458 return -ENOLINK; in read_stdi()
1461 stdi->bl = ((cp_read(sd, 0xb1) & 0x3f) << 8) | cp_read(sd, 0xb2); in read_stdi()
1462 stdi->lcf = ((cp_read(sd, 0xb3) & 0x7) << 8) | cp_read(sd, 0xb4); in read_stdi()
1463 stdi->lcvs = cp_read(sd, 0xb3) >> 3; in read_stdi()
1466 stdi->hs_pol = ((cp_read(sd, 0xb5) & 0x10) ? in read_stdi()
1467 ((cp_read(sd, 0xb5) & 0x08) ? '+' : '-') : 'x'); in read_stdi()
1468 stdi->vs_pol = ((cp_read(sd, 0xb5) & 0x40) ? in read_stdi()
1469 ((cp_read(sd, 0xb5) & 0x20) ? '+' : '-') : 'x'); in read_stdi()
1471 stdi->hs_pol = 'x'; in read_stdi()
1472 stdi->vs_pol = 'x'; in read_stdi()
1474 stdi->interlaced = (cp_read(sd, 0xb1) & 0x40) ? true : false; in read_stdi()
1476 if (stdi->lcf < 239 || stdi->bl < 8 || stdi->bl == 0x3fff) { in read_stdi()
1478 return -ENOLINK; in read_stdi()
1482 "%s: lcf (frame height - 1) = %d, bl = %d, lcvs (vsync) = %d, %chsync, %cvsync, %s\n", in read_stdi()
1483 __func__, stdi->lcf, stdi->bl, stdi->lcvs, in read_stdi()
1484 stdi->hs_pol, stdi->vs_pol, in read_stdi()
1485 stdi->interlaced ? "interlaced" : "progressive"); in read_stdi()
1493 if (timings->pad != 0) in adv7842_enum_dv_timings()
1494 return -EINVAL; in adv7842_enum_dv_timings()
1503 if (cap->pad != 0) in adv7842_dv_timings_cap()
1504 return -EINVAL; in adv7842_dv_timings_cap()
1518 timings->bt.flags |= V4L2_DV_FL_CAN_DETECT_REDUCED_FPS; in adv7842_fill_optional_dv_timings_fields()
1525 struct v4l2_bt_timings *bt = &timings->bt; in adv7842_query_dv_timings()
1533 if (state->mode == ADV7842_MODE_SDP) in adv7842_query_dv_timings()
1534 return -ENODATA; in adv7842_query_dv_timings()
1538 state->restart_stdi_once = true; in adv7842_query_dv_timings()
1540 return -ENOLINK; in adv7842_query_dv_timings()
1542 bt->interlaced = stdi.interlaced ? in adv7842_query_dv_timings()
1544 bt->standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT | in adv7842_query_dv_timings()
1550 timings->type = V4L2_DV_BT_656_1120; in adv7842_query_dv_timings()
1552 bt->width = (hdmi_read(sd, 0x07) & 0x0f) * 256 + hdmi_read(sd, 0x08); in adv7842_query_dv_timings()
1553 bt->height = (hdmi_read(sd, 0x09) & 0x0f) * 256 + hdmi_read(sd, 0x0a); in adv7842_query_dv_timings()
1560 bt->pixelclock = freq; in adv7842_query_dv_timings()
1561 bt->hfrontporch = (hdmi_read(sd, 0x20) & 0x03) * 256 + in adv7842_query_dv_timings()
1563 bt->hsync = (hdmi_read(sd, 0x22) & 0x03) * 256 + in adv7842_query_dv_timings()
1565 bt->hbackporch = (hdmi_read(sd, 0x24) & 0x03) * 256 + in adv7842_query_dv_timings()
1567 bt->vfrontporch = ((hdmi_read(sd, 0x2a) & 0x1f) * 256 + in adv7842_query_dv_timings()
1569 bt->vsync = ((hdmi_read(sd, 0x2e) & 0x1f) * 256 + in adv7842_query_dv_timings()
1571 bt->vbackporch = ((hdmi_read(sd, 0x32) & 0x1f) * 256 + in adv7842_query_dv_timings()
1573 bt->polarities = ((hdmi_read(sd, 0x05) & 0x10) ? V4L2_DV_VSYNC_POS_POL : 0) | in adv7842_query_dv_timings()
1575 if (bt->interlaced == V4L2_DV_INTERLACED) { in adv7842_query_dv_timings()
1576 bt->height += (hdmi_read(sd, 0x0b) & 0x0f) * 256 + in adv7842_query_dv_timings()
1578 bt->il_vfrontporch = ((hdmi_read(sd, 0x2c) & 0x1f) * 256 + in adv7842_query_dv_timings()
1580 bt->il_vsync = ((hdmi_read(sd, 0x30) & 0x1f) * 256 + in adv7842_query_dv_timings()
1582 bt->il_vbackporch = ((hdmi_read(sd, 0x34) & 0x1f) * 256 + in adv7842_query_dv_timings()
1585 bt->il_vfrontporch = 0; in adv7842_query_dv_timings()
1586 bt->il_vsync = 0; in adv7842_query_dv_timings()
1587 bt->il_vbackporch = 0; in adv7842_query_dv_timings()
1590 if ((timings->bt.flags & V4L2_DV_FL_CAN_REDUCE_FPS) && in adv7842_query_dv_timings()
1591 freq < bt->pixelclock) { in adv7842_query_dv_timings()
1592 u32 reduced_freq = ((u32)bt->pixelclock / 1001) * 1000; in adv7842_query_dv_timings()
1593 u32 delta_freq = abs(freq - reduced_freq); in adv7842_query_dv_timings()
1595 if (delta_freq < ((u32)bt->pixelclock - reduced_freq) / 2) in adv7842_query_dv_timings()
1596 timings->bt.flags |= V4L2_DV_FL_REDUCED_FPS; in adv7842_query_dv_timings()
1600 * Since LCVS values are inaccurate [REF_03, p. 339-340], in adv7842_query_dv_timings()
1601 * stdi2dv_timings() is called with lcvs +-1 if the first attempt fails. in adv7842_query_dv_timings()
1609 stdi.lcvs -= 2; in adv7842_query_dv_timings()
1610 v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs); in adv7842_query_dv_timings()
1621 if (state->restart_stdi_once) { in adv7842_query_dv_timings()
1624 /* enter one-shot mode */ in adv7842_query_dv_timings()
1630 state->restart_stdi_once = false; in adv7842_query_dv_timings()
1631 return -ENOLINK; in adv7842_query_dv_timings()
1634 return -ERANGE; in adv7842_query_dv_timings()
1636 state->restart_stdi_once = true; in adv7842_query_dv_timings()
1641 v4l2_print_dv_timings(sd->name, "adv7842_query_dv_timings:", in adv7842_query_dv_timings()
1655 if (state->mode == ADV7842_MODE_SDP) in adv7842_s_dv_timings()
1656 return -ENODATA; in adv7842_s_dv_timings()
1658 if (v4l2_match_dv_timings(&state->timings, timings, 0, false)) { in adv7842_s_dv_timings()
1663 bt = &timings->bt; in adv7842_s_dv_timings()
1667 return -ERANGE; in adv7842_s_dv_timings()
1671 state->timings = *timings; in adv7842_s_dv_timings()
1673 cp_write(sd, 0x91, bt->interlaced ? 0x40 : 0x00); in adv7842_s_dv_timings()
1687 v4l2_print_dv_timings(sd->name, "adv7842_s_dv_timings: ", in adv7842_s_dv_timings()
1697 if (state->mode == ADV7842_MODE_SDP) in adv7842_g_dv_timings()
1698 return -ENODATA; in adv7842_g_dv_timings()
1699 *timings = state->timings; in adv7842_g_dv_timings()
1708 switch (state->mode) { in enable_input()
1721 __func__, state->mode); in enable_input()
1738 sdp_io_write_and_or(sd, 0xe0, 0xbf, c->manual ? 0x00 : 0x40); in sdp_csc_coeff()
1740 if (!c->manual) in sdp_csc_coeff()
1744 sdp_io_write_and_or(sd, 0xe0, 0x7f, c->scaling == 2 ? 0x80 : 0x00); in sdp_csc_coeff()
1747 sdp_io_write_and_or(sd, 0xe0, 0xe0, c->A1 >> 8); in sdp_csc_coeff()
1748 sdp_io_write(sd, 0xe1, c->A1); in sdp_csc_coeff()
1749 sdp_io_write_and_or(sd, 0xe2, 0xe0, c->A2 >> 8); in sdp_csc_coeff()
1750 sdp_io_write(sd, 0xe3, c->A2); in sdp_csc_coeff()
1751 sdp_io_write_and_or(sd, 0xe4, 0xe0, c->A3 >> 8); in sdp_csc_coeff()
1752 sdp_io_write(sd, 0xe5, c->A3); in sdp_csc_coeff()
1755 sdp_io_write_and_or(sd, 0xe6, 0x80, c->A4 >> 8); in sdp_csc_coeff()
1756 sdp_io_write(sd, 0xe7, c->A4); in sdp_csc_coeff()
1759 sdp_io_write_and_or(sd, 0xe8, 0xe0, c->B1 >> 8); in sdp_csc_coeff()
1760 sdp_io_write(sd, 0xe9, c->B1); in sdp_csc_coeff()
1761 sdp_io_write_and_or(sd, 0xea, 0xe0, c->B2 >> 8); in sdp_csc_coeff()
1762 sdp_io_write(sd, 0xeb, c->B2); in sdp_csc_coeff()
1763 sdp_io_write_and_or(sd, 0xec, 0xe0, c->B3 >> 8); in sdp_csc_coeff()
1764 sdp_io_write(sd, 0xed, c->B3); in sdp_csc_coeff()
1767 sdp_io_write_and_or(sd, 0xee, 0x80, c->B4 >> 8); in sdp_csc_coeff()
1768 sdp_io_write(sd, 0xef, c->B4); in sdp_csc_coeff()
1771 sdp_io_write_and_or(sd, 0xf0, 0xe0, c->C1 >> 8); in sdp_csc_coeff()
1772 sdp_io_write(sd, 0xf1, c->C1); in sdp_csc_coeff()
1773 sdp_io_write_and_or(sd, 0xf2, 0xe0, c->C2 >> 8); in sdp_csc_coeff()
1774 sdp_io_write(sd, 0xf3, c->C2); in sdp_csc_coeff()
1775 sdp_io_write_and_or(sd, 0xf4, 0xe0, c->C3 >> 8); in sdp_csc_coeff()
1776 sdp_io_write(sd, 0xf5, c->C3); in sdp_csc_coeff()
1779 sdp_io_write_and_or(sd, 0xf6, 0x80, c->C4 >> 8); in sdp_csc_coeff()
1780 sdp_io_write(sd, 0xf7, c->C4); in sdp_csc_coeff()
1788 switch (state->mode) { in select_input()
1845 if (state->mode == ADV7842_MODE_COMP) { in select_input()
1865 cp_write(sd, 0x3e, 0x04); /* CP core pre-gain control */ in select_input()
1867 cp_write(sd, 0x40, 0x5c); /* CP core pre-gain control. Graphics mode */ in select_input()
1874 if (state->hdmi_port_a) in select_input()
1897 hdmi_write(sd, 0x75, 0x10); /* DDC drive strength */ in select_input()
1922 cp_write(sd, 0x3e, 0x00); /* CP core pre-gain control */ in select_input()
1933 __func__, state->mode); in select_input()
1947 state->mode = ADV7842_MODE_HDMI; in adv7842_s_routing()
1948 state->vid_std_select = ADV7842_HDMI_COMP_VID_STD_HD_1250P; in adv7842_s_routing()
1949 state->hdmi_port_a = true; in adv7842_s_routing()
1952 state->mode = ADV7842_MODE_HDMI; in adv7842_s_routing()
1953 state->vid_std_select = ADV7842_HDMI_COMP_VID_STD_HD_1250P; in adv7842_s_routing()
1954 state->hdmi_port_a = false; in adv7842_s_routing()
1957 state->mode = ADV7842_MODE_COMP; in adv7842_s_routing()
1958 state->vid_std_select = ADV7842_RGB_VID_STD_AUTO_GRAPH_MODE; in adv7842_s_routing()
1961 state->mode = ADV7842_MODE_RGB; in adv7842_s_routing()
1962 state->vid_std_select = ADV7842_RGB_VID_STD_AUTO_GRAPH_MODE; in adv7842_s_routing()
1965 state->mode = ADV7842_MODE_SDP; in adv7842_s_routing()
1966 state->vid_std_select = ADV7842_SDP_VID_STD_CVBS_SD_4x1; in adv7842_s_routing()
1969 state->mode = ADV7842_MODE_SDP; in adv7842_s_routing()
1970 state->vid_std_select = ADV7842_SDP_VID_STD_YC_SD4_x1; in adv7842_s_routing()
1973 return -EINVAL; in adv7842_s_routing()
1977 select_input(sd, state->vid_std_select); in adv7842_s_routing()
1989 if (code->index >= ARRAY_SIZE(adv7842_formats)) in adv7842_enum_mbus_code()
1990 return -EINVAL; in adv7842_enum_mbus_code()
1991 code->code = adv7842_formats[code->index].code; in adv7842_enum_mbus_code()
2000 format->width = state->timings.bt.width; in adv7842_fill_format()
2001 format->height = state->timings.bt.height; in adv7842_fill_format()
2002 format->field = V4L2_FIELD_NONE; in adv7842_fill_format()
2003 format->colorspace = V4L2_COLORSPACE_SRGB; in adv7842_fill_format()
2005 if (state->timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) in adv7842_fill_format()
2006 format->colorspace = (state->timings.bt.height <= 576) ? in adv7842_fill_format()
2020 * ----------+-------------------------------------------------
2022 * GRB (1-2) | BGR RGB GBR GRB RBG BRG
2023 * RBG (2-3) | GRB GBR BRG RBG BGR RGB
2024 * BGR (1-3) | RBG BRG RGB BGR GRB GBR
2037 _BUS(GRB) /* 1-2 */ = _SEL(BGR, RGB, GBR, GRB, RBG, BRG), in adv7842_op_ch_sel()
2038 _BUS(RBG) /* 2-3 */ = _SEL(GRB, GBR, BRG, RBG, BGR, RGB), in adv7842_op_ch_sel()
2039 _BUS(BGR) /* 1-3 */ = _SEL(RBG, BRG, RGB, BGR, GRB, GBR), in adv7842_op_ch_sel()
2044 return op_ch_sel[state->pdata.bus_order][state->format->op_ch_sel >> 5]; in adv7842_op_ch_sel()
2049 struct v4l2_subdev *sd = &state->sd; in adv7842_setup_format()
2052 state->format->rgb_out ? ADV7842_RGB_OUT : 0); in adv7842_setup_format()
2053 io_write(sd, 0x03, state->format->op_format_sel | in adv7842_setup_format()
2054 state->pdata.op_format_mode_sel); in adv7842_setup_format()
2057 state->format->swap_cb_cr ? ADV7842_OP_SWAP_CB_CR : 0); in adv7842_setup_format()
2067 if (format->pad != ADV7842_PAD_SOURCE) in adv7842_get_format()
2068 return -EINVAL; in adv7842_get_format()
2070 if (state->mode == ADV7842_MODE_SDP) { in adv7842_get_format()
2073 return -EINVAL; in adv7842_get_format()
2074 format->format.code = MEDIA_BUS_FMT_YUYV8_2X8; in adv7842_get_format()
2075 format->format.width = 720; in adv7842_get_format()
2077 if (state->norm & V4L2_STD_525_60) in adv7842_get_format()
2078 format->format.height = 480; in adv7842_get_format()
2080 format->format.height = 576; in adv7842_get_format()
2081 format->format.colorspace = V4L2_COLORSPACE_SMPTE170M; in adv7842_get_format()
2085 adv7842_fill_format(state, &format->format); in adv7842_get_format()
2087 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in adv7842_get_format()
2090 fmt = v4l2_subdev_state_get_format(sd_state, format->pad); in adv7842_get_format()
2091 format->format.code = fmt->code; in adv7842_get_format()
2093 format->format.code = state->format->code; in adv7842_get_format()
2106 if (format->pad != ADV7842_PAD_SOURCE) in adv7842_set_format()
2107 return -EINVAL; in adv7842_set_format()
2109 if (state->mode == ADV7842_MODE_SDP) in adv7842_set_format()
2112 info = adv7842_format_info(state, format->format.code); in adv7842_set_format()
2116 adv7842_fill_format(state, &format->format); in adv7842_set_format()
2117 format->format.code = info->code; in adv7842_set_format()
2119 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in adv7842_set_format()
2122 fmt = v4l2_subdev_state_get_format(sd_state, format->pad); in adv7842_set_format()
2123 fmt->code = format->format.code; in adv7842_set_format()
2125 state->format = info; in adv7842_set_format()
2170 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST, in adv7842_cec_tx_raw_status()
2191 cec_transmit_done(state->cec_adap, status, in adv7842_cec_tx_raw_status()
2197 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_OK, 0, 0, 0, 0); in adv7842_cec_tx_raw_status()
2226 cec_write(sd, 0x26, 0x01); /* re-enable rx */ in adv7842_cec_isr()
2227 cec_received_msg(state->cec_adap, &msg); in adv7842_cec_isr()
2240 struct v4l2_subdev *sd = &state->sd; in adv7842_cec_adap_enable()
2242 if (!state->cec_enabled_adap && enable) { in adv7842_cec_adap_enable()
2244 cec_write(sd, 0x2c, 0x01); /* cec soft reset */ in adv7842_cec_adap_enable()
2253 } else if (state->cec_enabled_adap && !enable) { in adv7842_cec_adap_enable()
2256 /* disable address mask 1-3 */ in adv7842_cec_adap_enable()
2260 state->cec_valid_addrs = 0; in adv7842_cec_adap_enable()
2262 state->cec_enabled_adap = enable; in adv7842_cec_adap_enable()
2269 struct v4l2_subdev *sd = &state->sd; in adv7842_cec_adap_log_addr()
2272 if (!state->cec_enabled_adap) in adv7842_cec_adap_log_addr()
2273 return addr == CEC_LOG_ADDR_INVALID ? 0 : -EIO; in adv7842_cec_adap_log_addr()
2277 state->cec_valid_addrs = 0; in adv7842_cec_adap_log_addr()
2282 bool is_valid = state->cec_valid_addrs & (1 << i); in adv7842_cec_adap_log_addr()
2286 if (is_valid && state->cec_addr[i] == addr) in adv7842_cec_adap_log_addr()
2292 return -ENXIO; in adv7842_cec_adap_log_addr()
2294 state->cec_addr[i] = addr; in adv7842_cec_adap_log_addr()
2295 state->cec_valid_addrs |= 1 << i; in adv7842_cec_adap_log_addr()
2324 struct v4l2_subdev *sd = &state->sd; in adv7842_cec_adap_transmit()
2325 u8 len = msg->len; in adv7842_cec_adap_transmit()
2329 * The number of retries is the number of attempts - 1, but retry in adv7842_cec_adap_transmit()
2333 cec_write_clr_set(sd, 0x12, 0x70, max(1, attempts - 1) << 4); in adv7842_cec_adap_transmit()
2337 return -EINVAL; in adv7842_cec_adap_transmit()
2342 cec_write(sd, i, msg->msg[i]); in adv7842_cec_adap_transmit()
2346 /* start transmit, enable tx */ in adv7842_cec_adap_transmit()
2398 if (state->mode == ADV7842_MODE_SDP) in adv7842_isr()
2450 memset(edid->reserved, 0, sizeof(edid->reserved)); in adv7842_get_edid()
2452 switch (edid->pad) { in adv7842_get_edid()
2455 if (state->hdmi_edid.present & (0x04 << edid->pad)) { in adv7842_get_edid()
2456 data = state->hdmi_edid.edid; in adv7842_get_edid()
2457 blocks = state->hdmi_edid.blocks; in adv7842_get_edid()
2461 if (state->vga_edid.present) { in adv7842_get_edid()
2462 data = state->vga_edid.edid; in adv7842_get_edid()
2463 blocks = state->vga_edid.blocks; in adv7842_get_edid()
2467 return -EINVAL; in adv7842_get_edid()
2470 if (edid->start_block == 0 && edid->blocks == 0) { in adv7842_get_edid()
2471 edid->blocks = blocks; in adv7842_get_edid()
2476 return -ENODATA; in adv7842_get_edid()
2478 if (edid->start_block >= blocks) in adv7842_get_edid()
2479 return -EINVAL; in adv7842_get_edid()
2481 if (edid->start_block + edid->blocks > blocks) in adv7842_get_edid()
2482 edid->blocks = blocks - edid->start_block; in adv7842_get_edid()
2484 memcpy(edid->edid, data + edid->start_block * 128, edid->blocks * 128); in adv7842_get_edid()
2499 unsigned int max_blocks = e->pad == ADV7842_EDID_PORT_VGA ? 1 : 4; in adv7842_set_edid()
2502 memset(e->reserved, 0, sizeof(e->reserved)); in adv7842_set_edid()
2504 if (e->pad > ADV7842_EDID_PORT_VGA) in adv7842_set_edid()
2505 return -EINVAL; in adv7842_set_edid()
2506 if (e->start_block != 0) in adv7842_set_edid()
2507 return -EINVAL; in adv7842_set_edid()
2508 if (e->pad < ADV7842_EDID_PORT_VGA && state->vga_edid.blocks) in adv7842_set_edid()
2510 if (e->pad == ADV7842_EDID_PORT_VGA && state->hdmi_edid.blocks > 2) in adv7842_set_edid()
2511 return -EBUSY; in adv7842_set_edid()
2512 if (e->blocks > max_blocks) { in adv7842_set_edid()
2513 e->blocks = max_blocks; in adv7842_set_edid()
2514 return -E2BIG; in adv7842_set_edid()
2518 if (e->blocks) in adv7842_set_edid()
2519 state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15], in adv7842_set_edid()
2520 e->edid[0x16]); in adv7842_set_edid()
2522 switch (e->pad) { in adv7842_set_edid()
2524 memset(state->vga_edid.edid, 0, sizeof(state->vga_edid.edid)); in adv7842_set_edid()
2525 state->vga_edid.blocks = e->blocks; in adv7842_set_edid()
2526 state->vga_edid.present = e->blocks ? 0x1 : 0x0; in adv7842_set_edid()
2527 if (e->blocks) in adv7842_set_edid()
2528 memcpy(state->vga_edid.edid, e->edid, 128); in adv7842_set_edid()
2533 memset(state->hdmi_edid.edid, 0, sizeof(state->hdmi_edid.edid)); in adv7842_set_edid()
2534 state->hdmi_edid.blocks = e->blocks; in adv7842_set_edid()
2535 if (e->blocks) { in adv7842_set_edid()
2536 state->hdmi_edid.present |= 0x04 << e->pad; in adv7842_set_edid()
2537 memcpy(state->hdmi_edid.edid, e->edid, 128 * e->blocks); in adv7842_set_edid()
2539 state->hdmi_edid.present &= ~(0x04 << e->pad); in adv7842_set_edid()
2542 err = edid_write_hdmi_segment(sd, e->pad); in adv7842_set_edid()
2545 return -EINVAL; in adv7842_set_edid()
2548 v4l2_err(sd, "error %d writing edid on port %d\n", err, e->pad); in adv7842_set_edid()
2566 struct device *dev = &client->dev; in log_infoframe()
2568 if (!(io_read(sd, 0x60) & cri->present_mask)) { in log_infoframe()
2569 v4l2_info(sd, "%s infoframe not received\n", cri->desc); in log_infoframe()
2574 buffer[i] = infoframe_read(sd, cri->head_addr + i); in log_infoframe()
2579 v4l2_err(sd, "%s: invalid %s infoframe length %d\n", __func__, cri->desc, len); in log_infoframe()
2584 buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i); in log_infoframe()
2587 v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc); in log_infoframe()
2605 v4l2_info(sd, "receive DVI-D signal, no infoframes\n"); in adv7842_log_infoframes()
2621 "HDMI-Comp",
2622 "HDMI-GR",
2641 v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x\n", in adv7842_sdp_log_status()
2650 "NTSC-M/J", in adv7842_sdp_log_status()
2652 "NTSC-443", in adv7842_sdp_log_status()
2654 "PAL-M", in adv7842_sdp_log_status()
2656 "PAL-60", in adv7842_sdp_log_status()
2658 "PAL-CombN", in adv7842_sdp_log_status()
2660 "PAL-BGHID", in adv7842_sdp_log_status()
2691 "bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB", in adv7842_cp_log_status()
2692 "reserved", "RGB -> YPbPr601", "reserved", "RGB -> YPbPr709", in adv7842_cp_log_status()
2693 "reserved", "YPbPr709 -> YPbPr601", "YPbPr601 -> YPbPr709", in adv7842_cp_log_status()
2697 "RGB limited range (16-235)", "RGB full range (0-255)", in adv7842_cp_log_status()
2698 "YCbCr Bt.601 (16-235)", "YCbCr Bt.709 (16-235)", in adv7842_cp_log_status()
2700 "YCbCr Bt.601 (0-255)", "YCbCr Bt.709 (0-255)", in adv7842_cp_log_status()
2706 "RGB limited range (16-235)", in adv7842_cp_log_status()
2707 "RGB full range (0-255)", in adv7842_cp_log_status()
2710 "8-bits per channel", in adv7842_cp_log_status()
2711 "10-bits per channel", in adv7842_cp_log_status()
2712 "12-bits per channel", in adv7842_cp_log_status()
2713 "16-bits per channel (not supported)" in adv7842_cp_log_status()
2716 v4l2_info(sd, "-----Chip status-----\n"); in adv7842_cp_log_status()
2718 v4l2_info(sd, "HDMI/DVI-D port selected: %s\n", in adv7842_cp_log_status()
2719 state->hdmi_port_a ? "A" : "B"); in adv7842_cp_log_status()
2728 v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ? in adv7842_cp_log_status()
2730 if (state->cec_enabled_adap) { in adv7842_cp_log_status()
2734 bool is_valid = state->cec_valid_addrs & (1 << i); in adv7842_cp_log_status()
2738 state->cec_addr[i]); in adv7842_cp_log_status()
2742 v4l2_info(sd, "-----Signal status-----\n"); in adv7842_cp_log_status()
2743 if (state->hdmi_port_a) { in adv7842_cp_log_status()
2760 v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n", in adv7842_cp_log_status()
2764 v4l2_info(sd, "-----Video Timings-----\n"); in adv7842_cp_log_status()
2773 ((cp_read(sd, 0xb5) & 0x08) ? '+' : '-') : 'x'); in adv7842_cp_log_status()
2775 ((cp_read(sd, 0xb5) & 0x20) ? '+' : '-') : 'x'); in adv7842_cp_log_status()
2777 … "STDI: lcf (frame height - 1) = %d, bl = %d, lcvs (vsync) = %d, fcl = %d, %s, %chsync, %cvsync\n", in adv7842_cp_log_status()
2786 v4l2_print_dv_timings(sd->name, "Detected format: ", in adv7842_cp_log_status()
2788 v4l2_print_dv_timings(sd->name, "Configured format: ", in adv7842_cp_log_status()
2789 &state->timings, true); in adv7842_cp_log_status()
2794 v4l2_info(sd, "-----Color space-----\n"); in adv7842_cp_log_status()
2796 rgb_quantization_range_txt[state->rgb_quantization_range]); in adv7842_cp_log_status()
2799 v4l2_info(sd, "Output color space: %s %s, alt-gamma %s\n", in adv7842_cp_log_status()
2802 "(16-235)" : "(0-255)", in adv7842_cp_log_status()
2810 v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D"); in adv7842_cp_log_status()
2825 (hdmi_read(sd, 0x07) & 0x40) ? "multi-channel" : "stereo"); in adv7842_cp_log_status()
2847 if (state->mode == ADV7842_MODE_SDP) in adv7842_log_status()
2858 if (state->mode != ADV7842_MODE_SDP) in adv7842_querystd()
2859 return -ENODATA; in adv7842_querystd()
2869 /* NTSC-M/J */ in adv7842_querystd()
2873 /* NTSC-443 */ in adv7842_querystd()
2881 /* PAL-M */ in adv7842_querystd()
2885 /* PAL-60 */ in adv7842_querystd()
2889 /* PAL-CombN */ in adv7842_querystd()
2893 /* PAL-BGHID */ in adv7842_querystd()
2909 if (s && s->adjust) { in adv7842_s_sdp_io()
2910 sdp_io_write(sd, 0x94, (s->hs_beg >> 8) & 0xf); in adv7842_s_sdp_io()
2911 sdp_io_write(sd, 0x95, s->hs_beg & 0xff); in adv7842_s_sdp_io()
2912 sdp_io_write(sd, 0x96, (s->hs_width >> 8) & 0xf); in adv7842_s_sdp_io()
2913 sdp_io_write(sd, 0x97, s->hs_width & 0xff); in adv7842_s_sdp_io()
2914 sdp_io_write(sd, 0x98, (s->de_beg >> 8) & 0xf); in adv7842_s_sdp_io()
2915 sdp_io_write(sd, 0x99, s->de_beg & 0xff); in adv7842_s_sdp_io()
2916 sdp_io_write(sd, 0x9a, (s->de_end >> 8) & 0xf); in adv7842_s_sdp_io()
2917 sdp_io_write(sd, 0x9b, s->de_end & 0xff); in adv7842_s_sdp_io()
2918 sdp_io_write(sd, 0xa8, s->vs_beg_o); in adv7842_s_sdp_io()
2919 sdp_io_write(sd, 0xa9, s->vs_beg_e); in adv7842_s_sdp_io()
2920 sdp_io_write(sd, 0xaa, s->vs_end_o); in adv7842_s_sdp_io()
2921 sdp_io_write(sd, 0xab, s->vs_end_e); in adv7842_s_sdp_io()
2922 sdp_io_write(sd, 0xac, s->de_v_beg_o); in adv7842_s_sdp_io()
2923 sdp_io_write(sd, 0xad, s->de_v_beg_e); in adv7842_s_sdp_io()
2924 sdp_io_write(sd, 0xae, s->de_v_end_o); in adv7842_s_sdp_io()
2925 sdp_io_write(sd, 0xaf, s->de_v_end_e); in adv7842_s_sdp_io()
2950 struct adv7842_platform_data *pdata = &state->pdata; in adv7842_s_std()
2954 if (state->mode != ADV7842_MODE_SDP) in adv7842_s_std()
2955 return -ENODATA; in adv7842_s_std()
2958 adv7842_s_sdp_io(sd, &pdata->sdp_io_sync_625); in adv7842_s_std()
2960 adv7842_s_sdp_io(sd, &pdata->sdp_io_sync_525); in adv7842_s_std()
2965 state->norm = norm; in adv7842_s_std()
2968 return -EINVAL; in adv7842_s_std()
2977 if (state->mode != ADV7842_MODE_SDP) in adv7842_g_std()
2978 return -ENODATA; in adv7842_g_std()
2980 *norm = state->norm; in adv7842_g_std()
2984 /* ----------------------------------------------------------------------- */
2989 struct adv7842_platform_data *pdata = &state->pdata; in adv7842_core_init()
2991 (pdata->disable_pwrdnb ? 0x80 : 0) | in adv7842_core_init()
2992 (pdata->disable_cable_det_rst ? 0x40 : 0)); in adv7842_core_init()
3007 io_write(sd, 0x02, 0xf0 | pdata->alt_gamma << 3); in adv7842_core_init()
3008 io_write_and_or(sd, 0x05, 0xf0, pdata->blank_data << 3 | in adv7842_core_init()
3009 pdata->insert_av_codes << 2 | in adv7842_core_init()
3010 pdata->replicate_av_codes << 1); in adv7842_core_init()
3016 /* Drive strength */ in adv7842_core_init()
3018 pdata->dr_str_data << 4 | in adv7842_core_init()
3019 pdata->dr_str_clk << 2 | in adv7842_core_init()
3020 pdata->dr_str_sync); in adv7842_core_init()
3023 cp_write_and_or(sd, 0xba, 0xfc, pdata->hdmi_free_run_enable | in adv7842_core_init()
3024 (pdata->hdmi_free_run_mode << 1)); in adv7842_core_init()
3027 sdp_write_and_or(sd, 0xdd, 0xf0, pdata->sdp_free_run_force | in adv7842_core_init()
3028 (pdata->sdp_free_run_cbar_en << 1) | in adv7842_core_init()
3029 (pdata->sdp_free_run_man_col_en << 2) | in adv7842_core_init()
3030 (pdata->sdp_free_run_auto << 3)); in adv7842_core_init()
3034 io_write(sd, 0x06, 0xa6); /* positive VS and HS and DE */ in adv7842_core_init()
3038 afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */ in adv7842_core_init()
3039 io_write_and_or(sd, 0x30, ~(1 << 4), pdata->output_bus_lsb_to_msb << 4); in adv7842_core_init()
3041 sdp_csc_coeff(sd, &pdata->sdp_csc_coeff); in adv7842_core_init()
3044 if (pdata->sd_ram_size >= 128) { in adv7842_core_init()
3046 if (pdata->sd_ram_ddr) { in adv7842_core_init()
3065 * Manual UG-214, rev 0 is bit confusing on this bit in adv7842_core_init()
3071 select_input(sd, pdata->vid_std_select); in adv7842_core_init()
3075 if (pdata->hpa_auto) { in adv7842_core_init()
3086 io_write(sd, 0x19, 0x80 | pdata->llc_dll_phase); in adv7842_core_init()
3094 return v4l2_ctrl_handler_setup(sd->ctrl_handler); in adv7842_core_init()
3097 /* ----------------------------------------------------------------------- */
3163 return -EIO; in adv7842_ddr_ram_test()
3170 io_write(sd, 0xf1, pdata->i2c_sdp << 1); in adv7842_rewrite_i2c_addresses()
3171 io_write(sd, 0xf2, pdata->i2c_sdp_io << 1); in adv7842_rewrite_i2c_addresses()
3172 io_write(sd, 0xf3, pdata->i2c_avlink << 1); in adv7842_rewrite_i2c_addresses()
3173 io_write(sd, 0xf4, pdata->i2c_cec << 1); in adv7842_rewrite_i2c_addresses()
3174 io_write(sd, 0xf5, pdata->i2c_infoframe << 1); in adv7842_rewrite_i2c_addresses()
3176 io_write(sd, 0xf8, pdata->i2c_afe << 1); in adv7842_rewrite_i2c_addresses()
3177 io_write(sd, 0xf9, pdata->i2c_repeater << 1); in adv7842_rewrite_i2c_addresses()
3178 io_write(sd, 0xfa, pdata->i2c_edid << 1); in adv7842_rewrite_i2c_addresses()
3179 io_write(sd, 0xfb, pdata->i2c_hdmi << 1); in adv7842_rewrite_i2c_addresses()
3181 io_write(sd, 0xfd, pdata->i2c_cp << 1); in adv7842_rewrite_i2c_addresses()
3182 io_write(sd, 0xfe, pdata->i2c_vdp << 1); in adv7842_rewrite_i2c_addresses()
3189 struct adv7842_platform_data *pdata = client->dev.platform_data; in adv7842_command_ram_test()
3194 return -ENODEV; in adv7842_command_ram_test()
3196 if (!pdata->sd_ram_size || !pdata->sd_ram_ddr) { in adv7842_command_ram_test()
3198 return -EINVAL; in adv7842_command_ram_test()
3212 /* and re-init chip and state */ in adv7842_command_ram_test()
3217 select_input(sd, state->vid_std_select); in adv7842_command_ram_test()
3225 timings = state->timings; in adv7842_command_ram_test()
3227 memset(&state->timings, 0, sizeof(struct v4l2_dv_timings)); in adv7842_command_ram_test()
3240 return -ENOTTY; in adv7842_ioctl()
3247 switch (sub->type) { in adv7842_subscribe_event()
3253 return -EINVAL; in adv7842_subscribe_event()
3263 err = cec_register_adapter(state->cec_adap, &client->dev); in adv7842_registered()
3265 cec_delete_adapter(state->cec_adap); in adv7842_registered()
3273 cec_unregister_adapter(state->cec_adap); in adv7842_unregistered()
3276 /* ----------------------------------------------------------------------- */
3327 /* -------------------------- custom ctrls ---------------------------------- */
3363 i2c_unregister_device(state->i2c_avlink); in adv7842_unregister_clients()
3364 i2c_unregister_device(state->i2c_cec); in adv7842_unregister_clients()
3365 i2c_unregister_device(state->i2c_infoframe); in adv7842_unregister_clients()
3366 i2c_unregister_device(state->i2c_sdp_io); in adv7842_unregister_clients()
3367 i2c_unregister_device(state->i2c_sdp); in adv7842_unregister_clients()
3368 i2c_unregister_device(state->i2c_afe); in adv7842_unregister_clients()
3369 i2c_unregister_device(state->i2c_repeater); in adv7842_unregister_clients()
3370 i2c_unregister_device(state->i2c_edid); in adv7842_unregister_clients()
3371 i2c_unregister_device(state->i2c_hdmi); in adv7842_unregister_clients()
3372 i2c_unregister_device(state->i2c_cp); in adv7842_unregister_clients()
3373 i2c_unregister_device(state->i2c_vdp); in adv7842_unregister_clients()
3375 state->i2c_avlink = NULL; in adv7842_unregister_clients()
3376 state->i2c_cec = NULL; in adv7842_unregister_clients()
3377 state->i2c_infoframe = NULL; in adv7842_unregister_clients()
3378 state->i2c_sdp_io = NULL; in adv7842_unregister_clients()
3379 state->i2c_sdp = NULL; in adv7842_unregister_clients()
3380 state->i2c_afe = NULL; in adv7842_unregister_clients()
3381 state->i2c_repeater = NULL; in adv7842_unregister_clients()
3382 state->i2c_edid = NULL; in adv7842_unregister_clients()
3383 state->i2c_hdmi = NULL; in adv7842_unregister_clients()
3384 state->i2c_cp = NULL; in adv7842_unregister_clients()
3385 state->i2c_vdp = NULL; in adv7842_unregister_clients()
3401 cp = i2c_new_dummy_device(client->adapter, io_read(sd, io_reg) >> 1); in adv7842_dummy_client()
3414 struct adv7842_platform_data *pdata = &state->pdata; in adv7842_register_clients()
3416 state->i2c_avlink = adv7842_dummy_client(sd, "avlink", pdata->i2c_avlink, 0xf3); in adv7842_register_clients()
3417 state->i2c_cec = adv7842_dummy_client(sd, "cec", pdata->i2c_cec, 0xf4); in adv7842_register_clients()
3418 state->i2c_infoframe = adv7842_dummy_client(sd, "infoframe", pdata->i2c_infoframe, 0xf5); in adv7842_register_clients()
3419 state->i2c_sdp_io = adv7842_dummy_client(sd, "sdp_io", pdata->i2c_sdp_io, 0xf2); in adv7842_register_clients()
3420 state->i2c_sdp = adv7842_dummy_client(sd, "sdp", pdata->i2c_sdp, 0xf1); in adv7842_register_clients()
3421 state->i2c_afe = adv7842_dummy_client(sd, "afe", pdata->i2c_afe, 0xf8); in adv7842_register_clients()
3422 state->i2c_repeater = adv7842_dummy_client(sd, "repeater", pdata->i2c_repeater, 0xf9); in adv7842_register_clients()
3423 state->i2c_edid = adv7842_dummy_client(sd, "edid", pdata->i2c_edid, 0xfa); in adv7842_register_clients()
3424 state->i2c_hdmi = adv7842_dummy_client(sd, "hdmi", pdata->i2c_hdmi, 0xfb); in adv7842_register_clients()
3425 state->i2c_cp = adv7842_dummy_client(sd, "cp", pdata->i2c_cp, 0xfd); in adv7842_register_clients()
3426 state->i2c_vdp = adv7842_dummy_client(sd, "vdp", pdata->i2c_vdp, 0xfe); in adv7842_register_clients()
3428 if (!state->i2c_avlink || in adv7842_register_clients()
3429 !state->i2c_cec || in adv7842_register_clients()
3430 !state->i2c_infoframe || in adv7842_register_clients()
3431 !state->i2c_sdp_io || in adv7842_register_clients()
3432 !state->i2c_sdp || in adv7842_register_clients()
3433 !state->i2c_afe || in adv7842_register_clients()
3434 !state->i2c_repeater || in adv7842_register_clients()
3435 !state->i2c_edid || in adv7842_register_clients()
3436 !state->i2c_hdmi || in adv7842_register_clients()
3437 !state->i2c_cp || in adv7842_register_clients()
3438 !state->i2c_vdp) in adv7842_register_clients()
3439 return -1; in adv7842_register_clients()
3449 struct adv7842_platform_data *pdata = client->dev.platform_data; in adv7842_probe()
3458 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in adv7842_probe()
3459 return -EIO; in adv7842_probe()
3462 client->addr << 1); in adv7842_probe()
3466 return -ENODEV; in adv7842_probe()
3469 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); in adv7842_probe()
3471 return -ENOMEM; in adv7842_probe()
3474 state->pdata = *pdata; in adv7842_probe()
3475 state->timings = cea640x480; in adv7842_probe()
3476 state->format = adv7842_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8); in adv7842_probe()
3478 sd = &state->sd; in adv7842_probe()
3480 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in adv7842_probe()
3481 sd->internal_ops = &adv7842_int_ops; in adv7842_probe()
3482 state->mode = pdata->mode; in adv7842_probe()
3484 state->hdmi_port_a = pdata->input == ADV7842_SELECT_HDMI_PORT_A; in adv7842_probe()
3485 state->restart_stdi_once = true; in adv7842_probe()
3497 client->addr << 1, rev); in adv7842_probe()
3498 return -ENODEV; in adv7842_probe()
3501 if (pdata->chip_reset) in adv7842_probe()
3505 hdl = &state->hdl; in adv7842_probe()
3510 V4L2_CID_BRIGHTNESS, -128, 127, 1, 0); in adv7842_probe()
3521 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in adv7842_probe()
3524 state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL, in adv7842_probe()
3526 state->analog_sampling_phase_ctrl = v4l2_ctrl_new_custom(hdl, in adv7842_probe()
3528 state->free_run_color_ctrl_manual = v4l2_ctrl_new_custom(hdl, in adv7842_probe()
3530 state->free_run_color_ctrl = v4l2_ctrl_new_custom(hdl, in adv7842_probe()
3532 state->rgb_quantization_range_ctrl = in adv7842_probe()
3536 sd->ctrl_handler = hdl; in adv7842_probe()
3537 if (hdl->error) { in adv7842_probe()
3538 err = hdl->error; in adv7842_probe()
3542 err = -ENODEV; in adv7842_probe()
3547 err = -ENOMEM; in adv7842_probe()
3553 INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug, in adv7842_probe()
3556 sd->entity.function = MEDIA_ENT_F_DV_DECODER; in adv7842_probe()
3558 state->pads[i].flags = MEDIA_PAD_FL_SINK; in adv7842_probe()
3559 state->pads[ADV7842_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in adv7842_probe()
3560 err = media_entity_pads_init(&sd->entity, ADV7842_PAD_SOURCE + 1, in adv7842_probe()
3561 state->pads); in adv7842_probe()
3570 state->cec_adap = cec_allocate_adapter(&adv7842_cec_adap_ops, in adv7842_probe()
3571 state, dev_name(&client->dev), in adv7842_probe()
3573 err = PTR_ERR_OR_ZERO(state->cec_adap); in adv7842_probe()
3578 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in adv7842_probe()
3579 client->addr << 1, client->adapter->name); in adv7842_probe()
3583 media_entity_cleanup(&sd->entity); in adv7842_probe()
3585 cancel_delayed_work(&state->delayed_work_enable_hotplug); in adv7842_probe()
3593 /* ----------------------------------------------------------------------- */
3601 cancel_delayed_work_sync(&state->delayed_work_enable_hotplug); in adv7842_remove()
3603 media_entity_cleanup(&sd->entity); in adv7842_remove()
3605 v4l2_ctrl_handler_free(sd->ctrl_handler); in adv7842_remove()
3608 /* ----------------------------------------------------------------------- */
3616 /* ----------------------------------------------------------------------- */