Lines Matching refs:sd
116 void (*set_termination)(struct v4l2_subdev *sd, bool enable);
117 void (*setup_irqs)(struct v4l2_subdev *sd);
118 unsigned int (*read_hdmi_pixelclock)(struct v4l2_subdev *sd);
119 unsigned int (*read_cable_det)(struct v4l2_subdev *sd);
142 struct v4l2_subdev sd; member
331 static inline struct adv7604_state *to_state(struct v4l2_subdev *sd) in to_state() argument
333 return container_of(sd, struct adv7604_state, sd); in to_state()
422 static inline int io_read(struct v4l2_subdev *sd, u8 reg) in io_read() argument
424 struct adv7604_state *state = to_state(sd); in io_read()
429 static inline int io_write(struct v4l2_subdev *sd, u8 reg, u8 val) in io_write() argument
431 struct adv7604_state *state = to_state(sd); in io_write()
436 static inline int io_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) in io_write_clr_set() argument
438 return io_write(sd, reg, (io_read(sd, reg) & ~mask) | val); in io_write_clr_set()
441 static inline int avlink_read(struct v4l2_subdev *sd, u8 reg) in avlink_read() argument
443 struct adv7604_state *state = to_state(sd); in avlink_read()
448 static inline int avlink_write(struct v4l2_subdev *sd, u8 reg, u8 val) in avlink_write() argument
450 struct adv7604_state *state = to_state(sd); in avlink_write()
455 static inline int cec_read(struct v4l2_subdev *sd, u8 reg) in cec_read() argument
457 struct adv7604_state *state = to_state(sd); in cec_read()
462 static inline int cec_write(struct v4l2_subdev *sd, u8 reg, u8 val) in cec_write() argument
464 struct adv7604_state *state = to_state(sd); in cec_write()
469 static inline int cec_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) in cec_write_clr_set() argument
471 return cec_write(sd, reg, (cec_read(sd, reg) & ~mask) | val); in cec_write_clr_set()
474 static inline int infoframe_read(struct v4l2_subdev *sd, u8 reg) in infoframe_read() argument
476 struct adv7604_state *state = to_state(sd); in infoframe_read()
481 static inline int infoframe_write(struct v4l2_subdev *sd, u8 reg, u8 val) in infoframe_write() argument
483 struct adv7604_state *state = to_state(sd); in infoframe_write()
489 static inline int esdp_read(struct v4l2_subdev *sd, u8 reg) in esdp_read() argument
491 struct adv7604_state *state = to_state(sd); in esdp_read()
496 static inline int esdp_write(struct v4l2_subdev *sd, u8 reg, u8 val) in esdp_write() argument
498 struct adv7604_state *state = to_state(sd); in esdp_write()
503 static inline int dpp_read(struct v4l2_subdev *sd, u8 reg) in dpp_read() argument
505 struct adv7604_state *state = to_state(sd); in dpp_read()
510 static inline int dpp_write(struct v4l2_subdev *sd, u8 reg, u8 val) in dpp_write() argument
512 struct adv7604_state *state = to_state(sd); in dpp_write()
517 static inline int afe_read(struct v4l2_subdev *sd, u8 reg) in afe_read() argument
519 struct adv7604_state *state = to_state(sd); in afe_read()
524 static inline int afe_write(struct v4l2_subdev *sd, u8 reg, u8 val) in afe_write() argument
526 struct adv7604_state *state = to_state(sd); in afe_write()
531 static inline int rep_read(struct v4l2_subdev *sd, u8 reg) in rep_read() argument
533 struct adv7604_state *state = to_state(sd); in rep_read()
538 static inline int rep_write(struct v4l2_subdev *sd, u8 reg, u8 val) in rep_write() argument
540 struct adv7604_state *state = to_state(sd); in rep_write()
545 static inline int rep_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) in rep_write_clr_set() argument
547 return rep_write(sd, reg, (rep_read(sd, reg) & ~mask) | val); in rep_write_clr_set()
550 static inline int edid_read(struct v4l2_subdev *sd, u8 reg) in edid_read() argument
552 struct adv7604_state *state = to_state(sd); in edid_read()
557 static inline int edid_write(struct v4l2_subdev *sd, u8 reg, u8 val) in edid_write() argument
559 struct adv7604_state *state = to_state(sd); in edid_write()
564 static inline int edid_read_block(struct v4l2_subdev *sd, unsigned len, u8 *val) in edid_read_block() argument
566 struct adv7604_state *state = to_state(sd); in edid_read_block()
590 static inline int edid_write_block(struct v4l2_subdev *sd, in edid_write_block() argument
593 struct adv7604_state *state = to_state(sd); in edid_write_block()
597 v4l2_dbg(2, debug, sd, "%s: write EDID block (%d byte)\n", __func__, len); in edid_write_block()
616 v4l2_subdev_notify(&state->sd, ADV7604_HOTPLUG, &hpd); in adv7604_set_hpd()
624 struct v4l2_subdev *sd = &state->sd; in adv7604_delayed_work_enable_hotplug() local
626 v4l2_dbg(2, debug, sd, "%s: enable hotplug\n", __func__); in adv7604_delayed_work_enable_hotplug()
631 static inline int hdmi_read(struct v4l2_subdev *sd, u8 reg) in hdmi_read() argument
633 struct adv7604_state *state = to_state(sd); in hdmi_read()
638 static u16 hdmi_read16(struct v4l2_subdev *sd, u8 reg, u16 mask) in hdmi_read16() argument
640 return ((hdmi_read(sd, reg) << 8) | hdmi_read(sd, reg + 1)) & mask; in hdmi_read16()
643 static inline int hdmi_write(struct v4l2_subdev *sd, u8 reg, u8 val) in hdmi_write() argument
645 struct adv7604_state *state = to_state(sd); in hdmi_write()
650 static inline int hdmi_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) in hdmi_write_clr_set() argument
652 return hdmi_write(sd, reg, (hdmi_read(sd, reg) & ~mask) | val); in hdmi_write_clr_set()
655 static inline int test_read(struct v4l2_subdev *sd, u8 reg) in test_read() argument
657 struct adv7604_state *state = to_state(sd); in test_read()
662 static inline int test_write(struct v4l2_subdev *sd, u8 reg, u8 val) in test_write() argument
664 struct adv7604_state *state = to_state(sd); in test_write()
669 static inline int cp_read(struct v4l2_subdev *sd, u8 reg) in cp_read() argument
671 struct adv7604_state *state = to_state(sd); in cp_read()
676 static u16 cp_read16(struct v4l2_subdev *sd, u8 reg, u16 mask) in cp_read16() argument
678 return ((cp_read(sd, reg) << 8) | cp_read(sd, reg + 1)) & mask; in cp_read16()
681 static inline int cp_write(struct v4l2_subdev *sd, u8 reg, u8 val) in cp_write() argument
683 struct adv7604_state *state = to_state(sd); in cp_write()
688 static inline int cp_write_clr_set(struct v4l2_subdev *sd, u8 reg, u8 mask, u8 val) in cp_write_clr_set() argument
690 return cp_write(sd, reg, (cp_read(sd, reg) & ~mask) | val); in cp_write_clr_set()
693 static inline int vdp_read(struct v4l2_subdev *sd, u8 reg) in vdp_read() argument
695 struct adv7604_state *state = to_state(sd); in vdp_read()
700 static inline int vdp_write(struct v4l2_subdev *sd, u8 reg, u8 val) in vdp_write() argument
702 struct adv7604_state *state = to_state(sd); in vdp_write()
711 static int adv7604_read_reg(struct v4l2_subdev *sd, unsigned int reg) in adv7604_read_reg() argument
713 struct adv7604_state *state = to_state(sd); in adv7604_read_reg()
725 static int adv7604_write_reg(struct v4l2_subdev *sd, unsigned int reg, u8 val) in adv7604_write_reg() argument
727 struct adv7604_state *state = to_state(sd); in adv7604_write_reg()
738 static void adv7604_write_reg_seq(struct v4l2_subdev *sd, in adv7604_write_reg_seq() argument
744 adv7604_write_reg(sd, reg_seq[i].reg, reg_seq[i].val); in adv7604_write_reg_seq()
836 static inline bool is_analog_input(struct v4l2_subdev *sd) in is_analog_input() argument
838 struct adv7604_state *state = to_state(sd); in is_analog_input()
844 static inline bool is_digital_input(struct v4l2_subdev *sd) in is_digital_input() argument
846 struct adv7604_state *state = to_state(sd); in is_digital_input()
857 static void adv7604_inv_register(struct v4l2_subdev *sd) in adv7604_inv_register() argument
859 v4l2_info(sd, "0x000-0x0ff: IO Map\n"); in adv7604_inv_register()
860 v4l2_info(sd, "0x100-0x1ff: AVLink Map\n"); in adv7604_inv_register()
861 v4l2_info(sd, "0x200-0x2ff: CEC Map\n"); in adv7604_inv_register()
862 v4l2_info(sd, "0x300-0x3ff: InfoFrame Map\n"); in adv7604_inv_register()
863 v4l2_info(sd, "0x400-0x4ff: ESDP Map\n"); in adv7604_inv_register()
864 v4l2_info(sd, "0x500-0x5ff: DPP Map\n"); in adv7604_inv_register()
865 v4l2_info(sd, "0x600-0x6ff: AFE Map\n"); in adv7604_inv_register()
866 v4l2_info(sd, "0x700-0x7ff: Repeater Map\n"); in adv7604_inv_register()
867 v4l2_info(sd, "0x800-0x8ff: EDID Map\n"); in adv7604_inv_register()
868 v4l2_info(sd, "0x900-0x9ff: HDMI Map\n"); in adv7604_inv_register()
869 v4l2_info(sd, "0xa00-0xaff: Test Map\n"); in adv7604_inv_register()
870 v4l2_info(sd, "0xb00-0xbff: CP Map\n"); in adv7604_inv_register()
871 v4l2_info(sd, "0xc00-0xcff: VDP Map\n"); in adv7604_inv_register()
874 static int adv7604_g_register(struct v4l2_subdev *sd, in adv7604_g_register() argument
879 ret = adv7604_read_reg(sd, reg->reg); in adv7604_g_register()
881 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7604_g_register()
882 adv7604_inv_register(sd); in adv7604_g_register()
892 static int adv7604_s_register(struct v4l2_subdev *sd, in adv7604_s_register() argument
897 ret = adv7604_write_reg(sd, reg->reg, reg->val); in adv7604_s_register()
899 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7604_s_register()
900 adv7604_inv_register(sd); in adv7604_s_register()
908 static unsigned int adv7604_read_cable_det(struct v4l2_subdev *sd) in adv7604_read_cable_det() argument
910 u8 value = io_read(sd, 0x6f); in adv7604_read_cable_det()
918 static unsigned int adv7611_read_cable_det(struct v4l2_subdev *sd) in adv7611_read_cable_det() argument
920 u8 value = io_read(sd, 0x6f); in adv7611_read_cable_det()
925 static int adv7604_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd) in adv7604_s_detect_tx_5v_ctrl() argument
927 struct adv7604_state *state = to_state(sd); in adv7604_s_detect_tx_5v_ctrl()
931 info->read_cable_det(sd)); in adv7604_s_detect_tx_5v_ctrl()
934 static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd, in find_and_set_predefined_video_timings() argument
943 is_digital_input(sd) ? 250000 : 1000000)) in find_and_set_predefined_video_timings()
945 io_write(sd, 0x00, predef_vid_timings[i].vid_std); /* video std */ in find_and_set_predefined_video_timings()
946 io_write(sd, 0x01, (predef_vid_timings[i].v_freq << 4) + in find_and_set_predefined_video_timings()
954 static int configure_predefined_video_timings(struct v4l2_subdev *sd, in configure_predefined_video_timings() argument
957 struct adv7604_state *state = to_state(sd); in configure_predefined_video_timings()
960 v4l2_dbg(1, debug, sd, "%s", __func__); in configure_predefined_video_timings()
964 io_write(sd, 0x16, 0x43); in configure_predefined_video_timings()
965 io_write(sd, 0x17, 0x5a); in configure_predefined_video_timings()
968 cp_write_clr_set(sd, 0x81, 0x10, 0x00); in configure_predefined_video_timings()
969 cp_write(sd, 0x8f, 0x00); in configure_predefined_video_timings()
970 cp_write(sd, 0x90, 0x00); in configure_predefined_video_timings()
971 cp_write(sd, 0xa2, 0x00); in configure_predefined_video_timings()
972 cp_write(sd, 0xa3, 0x00); in configure_predefined_video_timings()
973 cp_write(sd, 0xa4, 0x00); in configure_predefined_video_timings()
974 cp_write(sd, 0xa5, 0x00); in configure_predefined_video_timings()
975 cp_write(sd, 0xa6, 0x00); in configure_predefined_video_timings()
976 cp_write(sd, 0xa7, 0x00); in configure_predefined_video_timings()
977 cp_write(sd, 0xab, 0x00); in configure_predefined_video_timings()
978 cp_write(sd, 0xac, 0x00); in configure_predefined_video_timings()
980 if (is_analog_input(sd)) { in configure_predefined_video_timings()
981 err = find_and_set_predefined_video_timings(sd, in configure_predefined_video_timings()
984 err = find_and_set_predefined_video_timings(sd, in configure_predefined_video_timings()
986 } else if (is_digital_input(sd)) { in configure_predefined_video_timings()
987 err = find_and_set_predefined_video_timings(sd, in configure_predefined_video_timings()
990 err = find_and_set_predefined_video_timings(sd, in configure_predefined_video_timings()
993 v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n", in configure_predefined_video_timings()
1002 static void configure_custom_video_timings(struct v4l2_subdev *sd, in configure_custom_video_timings() argument
1005 struct adv7604_state *state = to_state(sd); in configure_custom_video_timings()
1019 v4l2_dbg(2, debug, sd, "%s\n", __func__); in configure_custom_video_timings()
1021 if (is_analog_input(sd)) { in configure_custom_video_timings()
1023 io_write(sd, 0x00, 0x07); /* video std */ in configure_custom_video_timings()
1024 io_write(sd, 0x01, 0x02); /* prim mode */ in configure_custom_video_timings()
1026 cp_write_clr_set(sd, 0x81, 0x10, 0x10); in configure_custom_video_timings()
1033 v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n"); in configure_custom_video_timings()
1036 cp_write(sd, 0xa2, (cp_start_sav >> 4) & 0xff); in configure_custom_video_timings()
1037 cp_write(sd, 0xa3, ((cp_start_sav & 0x0f) << 4) | in configure_custom_video_timings()
1039 cp_write(sd, 0xa4, cp_start_eav & 0xff); in configure_custom_video_timings()
1042 cp_write(sd, 0xa5, (cp_start_vbi >> 4) & 0xff); in configure_custom_video_timings()
1043 cp_write(sd, 0xa6, ((cp_start_vbi & 0xf) << 4) | in configure_custom_video_timings()
1045 cp_write(sd, 0xa7, cp_end_vbi & 0xff); in configure_custom_video_timings()
1046 } else if (is_digital_input(sd)) { in configure_custom_video_timings()
1049 io_write(sd, 0x00, 0x02); /* video std */ in configure_custom_video_timings()
1050 io_write(sd, 0x01, 0x06); /* prim mode */ in configure_custom_video_timings()
1052 v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n", in configure_custom_video_timings()
1056 cp_write(sd, 0x8f, (ch1_fr_ll >> 8) & 0x7); in configure_custom_video_timings()
1057 cp_write(sd, 0x90, ch1_fr_ll & 0xff); in configure_custom_video_timings()
1058 cp_write(sd, 0xab, (height >> 4) & 0xff); in configure_custom_video_timings()
1059 cp_write(sd, 0xac, (height & 0x0f) << 4); in configure_custom_video_timings()
1062 static void adv7604_set_offset(struct v4l2_subdev *sd, bool auto_offset, u16 offset_a, u16 offset_b… in adv7604_set_offset() argument
1064 struct adv7604_state *state = to_state(sd); in adv7604_set_offset()
1073 v4l2_dbg(2, debug, sd, "%s: %s offset: a = 0x%x, b = 0x%x, c = 0x%x\n", in adv7604_set_offset()
1077 offset_buf[0] = (cp_read(sd, 0x77) & 0xc0) | ((offset_a & 0x3f0) >> 4); in adv7604_set_offset()
1085 v4l2_err(sd, "%s: i2c error writing to CP reg 0x77, 0x78, 0x79, 0x7a\n", __func__); in adv7604_set_offset()
1088 static void adv7604_set_gain(struct v4l2_subdev *sd, bool auto_gain, u16 gain_a, u16 gain_b, u16 ga… in adv7604_set_gain() argument
1090 struct adv7604_state *state = to_state(sd); in adv7604_set_gain()
1103 v4l2_dbg(2, debug, sd, "%s: %s gain: a = 0x%x, b = 0x%x, c = 0x%x\n", in adv7604_set_gain()
1115 v4l2_err(sd, "%s: i2c error writing to CP reg 0x73, 0x74, 0x75, 0x76\n", __func__); in adv7604_set_gain()
1118 static void set_rgb_quantization_range(struct v4l2_subdev *sd) in set_rgb_quantization_range() argument
1120 struct adv7604_state *state = to_state(sd); in set_rgb_quantization_range()
1121 bool rgb_output = io_read(sd, 0x02) & 0x02; in set_rgb_quantization_range()
1122 bool hdmi_signal = hdmi_read(sd, 0x05) & 0x80; in set_rgb_quantization_range()
1124 v4l2_dbg(2, debug, sd, "%s: RGB quantization range: %d, RGB out: %d, HDMI: %d\n", in set_rgb_quantization_range()
1128 adv7604_set_gain(sd, true, 0x0, 0x0, 0x0); in set_rgb_quantization_range()
1129 adv7604_set_offset(sd, true, 0x0, 0x0, 0x0); in set_rgb_quantization_range()
1136 io_write_clr_set(sd, 0x02, 0xf0, 0x10); in set_rgb_quantization_range()
1143 io_write_clr_set(sd, 0x02, 0xf0, 0xf0); in set_rgb_quantization_range()
1150 io_write_clr_set(sd, 0x02, 0xf0, 0xf0); in set_rgb_quantization_range()
1159 io_write_clr_set(sd, 0x02, 0xf0, 0x00); in set_rgb_quantization_range()
1162 io_write_clr_set(sd, 0x02, 0xf0, 0x10); in set_rgb_quantization_range()
1164 if (is_digital_input(sd) && rgb_output) { in set_rgb_quantization_range()
1165 adv7604_set_offset(sd, false, 0x40, 0x40, 0x40); in set_rgb_quantization_range()
1167 adv7604_set_gain(sd, false, 0xe0, 0xe0, 0xe0); in set_rgb_quantization_range()
1168 adv7604_set_offset(sd, false, 0x70, 0x70, 0x70); in set_rgb_quantization_range()
1175 io_write_clr_set(sd, 0x02, 0xf0, 0x20); in set_rgb_quantization_range()
1180 io_write_clr_set(sd, 0x02, 0xf0, 0x00); in set_rgb_quantization_range()
1186 io_write_clr_set(sd, 0x02, 0xf0, 0x60); in set_rgb_quantization_range()
1191 io_write_clr_set(sd, 0x02, 0xf0, 0x10); in set_rgb_quantization_range()
1193 if (is_analog_input(sd) || hdmi_signal) in set_rgb_quantization_range()
1198 adv7604_set_offset(sd, false, 0x40, 0x40, 0x40); in set_rgb_quantization_range()
1200 adv7604_set_gain(sd, false, 0xe0, 0xe0, 0xe0); in set_rgb_quantization_range()
1201 adv7604_set_offset(sd, false, 0x70, 0x70, 0x70); in set_rgb_quantization_range()
1209 struct v4l2_subdev *sd = in adv7604_s_ctrl() local
1210 &container_of(ctrl->handler, struct adv7604_state, hdl)->sd; in adv7604_s_ctrl()
1212 struct adv7604_state *state = to_state(sd); in adv7604_s_ctrl()
1216 cp_write(sd, 0x3c, ctrl->val); in adv7604_s_ctrl()
1219 cp_write(sd, 0x3a, ctrl->val); in adv7604_s_ctrl()
1222 cp_write(sd, 0x3b, ctrl->val); in adv7604_s_ctrl()
1225 cp_write(sd, 0x3d, ctrl->val); in adv7604_s_ctrl()
1229 set_rgb_quantization_range(sd); in adv7604_s_ctrl()
1238 afe_write(sd, 0xc8, ctrl->val); in adv7604_s_ctrl()
1243 cp_write_clr_set(sd, 0xbf, 0x04, ctrl->val << 2); in adv7604_s_ctrl()
1246 cp_write(sd, 0xc0, (ctrl->val & 0xff0000) >> 16); in adv7604_s_ctrl()
1247 cp_write(sd, 0xc1, (ctrl->val & 0x00ff00) >> 8); in adv7604_s_ctrl()
1248 cp_write(sd, 0xc2, (u8)(ctrl->val & 0x0000ff)); in adv7604_s_ctrl()
1256 static inline bool no_power(struct v4l2_subdev *sd) in no_power() argument
1259 return io_read(sd, 0x0c) & 0x24; in no_power()
1262 static inline bool no_signal_tmds(struct v4l2_subdev *sd) in no_signal_tmds() argument
1264 struct adv7604_state *state = to_state(sd); in no_signal_tmds()
1266 return !(io_read(sd, 0x6a) & (0x10 >> state->selected_input)); in no_signal_tmds()
1269 static inline bool no_lock_tmds(struct v4l2_subdev *sd) in no_lock_tmds() argument
1271 struct adv7604_state *state = to_state(sd); in no_lock_tmds()
1274 return (io_read(sd, 0x6a) & info->tdms_lock_mask) != info->tdms_lock_mask; in no_lock_tmds()
1277 static inline bool is_hdmi(struct v4l2_subdev *sd) in is_hdmi() argument
1279 return hdmi_read(sd, 0x05) & 0x80; in is_hdmi()
1282 static inline bool no_lock_sspd(struct v4l2_subdev *sd) in no_lock_sspd() argument
1284 struct adv7604_state *state = to_state(sd); in no_lock_sspd()
1294 return ((cp_read(sd, 0xb5) & 0xd0) != 0xd0); in no_lock_sspd()
1297 static inline bool no_lock_stdi(struct v4l2_subdev *sd) in no_lock_stdi() argument
1300 return !(cp_read(sd, 0xb1) & 0x80); in no_lock_stdi()
1303 static inline bool no_signal(struct v4l2_subdev *sd) in no_signal() argument
1307 ret = no_power(sd); in no_signal()
1309 ret |= no_lock_stdi(sd); in no_signal()
1310 ret |= no_lock_sspd(sd); in no_signal()
1312 if (is_digital_input(sd)) { in no_signal()
1313 ret |= no_lock_tmds(sd); in no_signal()
1314 ret |= no_signal_tmds(sd); in no_signal()
1320 static inline bool no_lock_cp(struct v4l2_subdev *sd) in no_lock_cp() argument
1322 struct adv7604_state *state = to_state(sd); in no_lock_cp()
1329 return io_read(sd, 0x12) & 0x01; in no_lock_cp()
1332 static int adv7604_g_input_status(struct v4l2_subdev *sd, u32 *status) in adv7604_g_input_status() argument
1335 *status |= no_power(sd) ? V4L2_IN_ST_NO_POWER : 0; in adv7604_g_input_status()
1336 *status |= no_signal(sd) ? V4L2_IN_ST_NO_SIGNAL : 0; in adv7604_g_input_status()
1337 if (no_lock_cp(sd)) in adv7604_g_input_status()
1338 *status |= is_digital_input(sd) ? V4L2_IN_ST_NO_SYNC : V4L2_IN_ST_NO_H_LOCK; in adv7604_g_input_status()
1340 v4l2_dbg(1, debug, sd, "%s: status = 0x%x\n", __func__, *status); in adv7604_g_input_status()
1353 static int stdi2dv_timings(struct v4l2_subdev *sd, in stdi2dv_timings() argument
1357 struct adv7604_state *state = to_state(sd); in stdi2dv_timings()
1388 v4l2_dbg(2, debug, sd, in stdi2dv_timings()
1396 static int read_stdi(struct v4l2_subdev *sd, struct stdi_readback *stdi) in read_stdi() argument
1398 struct adv7604_state *state = to_state(sd); in read_stdi()
1402 if (no_lock_stdi(sd) || no_lock_sspd(sd)) { in read_stdi()
1403 v4l2_dbg(2, debug, sd, "%s: STDI and/or SSPD not locked\n", __func__); in read_stdi()
1408 stdi->bl = cp_read16(sd, 0xb1, 0x3fff); in read_stdi()
1409 stdi->lcf = cp_read16(sd, info->lcf_reg, 0x7ff); in read_stdi()
1410 stdi->lcvs = cp_read(sd, 0xb3) >> 3; in read_stdi()
1411 stdi->interlaced = io_read(sd, 0x12) & 0x10; in read_stdi()
1415 polarity = cp_read(sd, 0xb5); in read_stdi()
1426 polarity = hdmi_read(sd, 0x05); in read_stdi()
1431 if (no_lock_stdi(sd) || no_lock_sspd(sd)) { in read_stdi()
1432 v4l2_dbg(2, debug, sd, in read_stdi()
1438 v4l2_dbg(2, debug, sd, "%s: invalid signal\n", __func__); in read_stdi()
1443 v4l2_dbg(2, debug, sd, in read_stdi()
1452 static int adv7604_enum_dv_timings(struct v4l2_subdev *sd, in adv7604_enum_dv_timings() argument
1455 struct adv7604_state *state = to_state(sd); in adv7604_enum_dv_timings()
1468 static int adv7604_dv_timings_cap(struct v4l2_subdev *sd, in adv7604_dv_timings_cap() argument
1471 struct adv7604_state *state = to_state(sd); in adv7604_dv_timings_cap()
1504 static void adv7604_fill_optional_dv_timings_fields(struct v4l2_subdev *sd, in adv7604_fill_optional_dv_timings_fields() argument
1511 is_digital_input(sd) ? 250000 : 1000000)) { in adv7604_fill_optional_dv_timings_fields()
1518 static unsigned int adv7604_read_hdmi_pixelclock(struct v4l2_subdev *sd) in adv7604_read_hdmi_pixelclock() argument
1523 a = hdmi_read(sd, 0x06); in adv7604_read_hdmi_pixelclock()
1524 b = hdmi_read(sd, 0x3b); in adv7604_read_hdmi_pixelclock()
1529 if (is_hdmi(sd)) { in adv7604_read_hdmi_pixelclock()
1531 unsigned bits_per_channel = ((hdmi_read(sd, 0x0b) & 0x60) >> 4) + 8; in adv7604_read_hdmi_pixelclock()
1539 static unsigned int adv7611_read_hdmi_pixelclock(struct v4l2_subdev *sd) in adv7611_read_hdmi_pixelclock() argument
1543 a = hdmi_read(sd, 0x51); in adv7611_read_hdmi_pixelclock()
1544 b = hdmi_read(sd, 0x52); in adv7611_read_hdmi_pixelclock()
1550 static int adv7604_query_dv_timings(struct v4l2_subdev *sd, in adv7604_query_dv_timings() argument
1553 struct adv7604_state *state = to_state(sd); in adv7604_query_dv_timings()
1563 if (no_signal(sd)) { in adv7604_query_dv_timings()
1565 v4l2_dbg(1, debug, sd, "%s: no valid signal\n", __func__); in adv7604_query_dv_timings()
1570 if (read_stdi(sd, &stdi)) { in adv7604_query_dv_timings()
1571 v4l2_dbg(1, debug, sd, "%s: STDI/SSPD not locked\n", __func__); in adv7604_query_dv_timings()
1577 if (is_digital_input(sd)) { in adv7604_query_dv_timings()
1581 bt->width = hdmi_read16(sd, 0x07, 0xfff); in adv7604_query_dv_timings()
1582 bt->height = hdmi_read16(sd, 0x09, 0xfff); in adv7604_query_dv_timings()
1583 bt->pixelclock = info->read_hdmi_pixelclock(sd); in adv7604_query_dv_timings()
1584 bt->hfrontporch = hdmi_read16(sd, 0x20, 0x3ff); in adv7604_query_dv_timings()
1585 bt->hsync = hdmi_read16(sd, 0x22, 0x3ff); in adv7604_query_dv_timings()
1586 bt->hbackporch = hdmi_read16(sd, 0x24, 0x3ff); in adv7604_query_dv_timings()
1587 bt->vfrontporch = hdmi_read16(sd, 0x2a, 0x1fff) / 2; in adv7604_query_dv_timings()
1588 bt->vsync = hdmi_read16(sd, 0x2e, 0x1fff) / 2; in adv7604_query_dv_timings()
1589 bt->vbackporch = hdmi_read16(sd, 0x32, 0x1fff) / 2; in adv7604_query_dv_timings()
1590 bt->polarities = ((hdmi_read(sd, 0x05) & 0x10) ? V4L2_DV_VSYNC_POS_POL : 0) | in adv7604_query_dv_timings()
1591 ((hdmi_read(sd, 0x05) & 0x20) ? V4L2_DV_HSYNC_POS_POL : 0); in adv7604_query_dv_timings()
1593 bt->height += hdmi_read16(sd, 0x0b, 0xfff); in adv7604_query_dv_timings()
1594 bt->il_vfrontporch = hdmi_read16(sd, 0x2c, 0x1fff) / 2; in adv7604_query_dv_timings()
1595 bt->il_vsync = hdmi_read16(sd, 0x30, 0x1fff) / 2; in adv7604_query_dv_timings()
1596 bt->il_vbackporch = hdmi_read16(sd, 0x34, 0x1fff) / 2; in adv7604_query_dv_timings()
1598 adv7604_fill_optional_dv_timings_fields(sd, timings); in adv7604_query_dv_timings()
1604 if (!stdi2dv_timings(sd, &stdi, timings)) in adv7604_query_dv_timings()
1607 v4l2_dbg(1, debug, sd, "%s: lcvs + 1 = %d\n", __func__, stdi.lcvs); in adv7604_query_dv_timings()
1608 if (!stdi2dv_timings(sd, &stdi, timings)) in adv7604_query_dv_timings()
1611 v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs); in adv7604_query_dv_timings()
1612 if (stdi2dv_timings(sd, &stdi, timings)) { in adv7604_query_dv_timings()
1623 v4l2_dbg(1, debug, sd, "%s: restart STDI\n", __func__); in adv7604_query_dv_timings()
1626 cp_write_clr_set(sd, 0x86, 0x06, 0x00); in adv7604_query_dv_timings()
1628 cp_write_clr_set(sd, 0x86, 0x06, 0x04); in adv7604_query_dv_timings()
1630 cp_write_clr_set(sd, 0x86, 0x06, 0x02); in adv7604_query_dv_timings()
1634 v4l2_dbg(1, debug, sd, "%s: format not supported\n", __func__); in adv7604_query_dv_timings()
1641 if (no_signal(sd)) { in adv7604_query_dv_timings()
1642 v4l2_dbg(1, debug, sd, "%s: signal lost during readout\n", __func__); in adv7604_query_dv_timings()
1647 if ((is_analog_input(sd) && bt->pixelclock > 170000000) || in adv7604_query_dv_timings()
1648 (is_digital_input(sd) && bt->pixelclock > 225000000)) { in adv7604_query_dv_timings()
1649 v4l2_dbg(1, debug, sd, "%s: pixelclock out of range %d\n", in adv7604_query_dv_timings()
1655 v4l2_print_dv_timings(sd->name, "adv7604_query_dv_timings: ", in adv7604_query_dv_timings()
1661 static int adv7604_s_dv_timings(struct v4l2_subdev *sd, in adv7604_s_dv_timings() argument
1664 struct adv7604_state *state = to_state(sd); in adv7604_s_dv_timings()
1672 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); in adv7604_s_dv_timings()
1678 if ((is_analog_input(sd) && bt->pixelclock > 170000000) || in adv7604_s_dv_timings()
1679 (is_digital_input(sd) && bt->pixelclock > 225000000)) { in adv7604_s_dv_timings()
1680 v4l2_dbg(1, debug, sd, "%s: pixelclock out of range %d\n", in adv7604_s_dv_timings()
1685 adv7604_fill_optional_dv_timings_fields(sd, timings); in adv7604_s_dv_timings()
1689 cp_write_clr_set(sd, 0x91, 0x40, bt->interlaced ? 0x40 : 0x00); in adv7604_s_dv_timings()
1692 err = configure_predefined_video_timings(sd, timings); in adv7604_s_dv_timings()
1696 configure_custom_video_timings(sd, bt); in adv7604_s_dv_timings()
1699 set_rgb_quantization_range(sd); in adv7604_s_dv_timings()
1702 v4l2_print_dv_timings(sd->name, "adv7604_s_dv_timings: ", in adv7604_s_dv_timings()
1707 static int adv7604_g_dv_timings(struct v4l2_subdev *sd, in adv7604_g_dv_timings() argument
1710 struct adv7604_state *state = to_state(sd); in adv7604_g_dv_timings()
1716 static void adv7604_set_termination(struct v4l2_subdev *sd, bool enable) in adv7604_set_termination() argument
1718 hdmi_write(sd, 0x01, enable ? 0x00 : 0x78); in adv7604_set_termination()
1721 static void adv7611_set_termination(struct v4l2_subdev *sd, bool enable) in adv7611_set_termination() argument
1723 hdmi_write(sd, 0x83, enable ? 0xfe : 0xff); in adv7611_set_termination()
1726 static void enable_input(struct v4l2_subdev *sd) in enable_input() argument
1728 struct adv7604_state *state = to_state(sd); in enable_input()
1730 if (is_analog_input(sd)) { in enable_input()
1731 io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */ in enable_input()
1732 } else if (is_digital_input(sd)) { in enable_input()
1733 hdmi_write_clr_set(sd, 0x00, 0x03, state->selected_input); in enable_input()
1734 state->info->set_termination(sd, true); in enable_input()
1735 io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */ in enable_input()
1736 hdmi_write_clr_set(sd, 0x1a, 0x10, 0x00); /* Unmute audio */ in enable_input()
1738 v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n", in enable_input()
1743 static void disable_input(struct v4l2_subdev *sd) in disable_input() argument
1745 struct adv7604_state *state = to_state(sd); in disable_input()
1747 hdmi_write_clr_set(sd, 0x1a, 0x10, 0x10); /* Mute audio */ in disable_input()
1749 io_write(sd, 0x15, 0xbe); /* Tristate all outputs from video core */ in disable_input()
1750 state->info->set_termination(sd, false); in disable_input()
1753 static void select_input(struct v4l2_subdev *sd) in select_input() argument
1755 struct adv7604_state *state = to_state(sd); in select_input()
1758 if (is_analog_input(sd)) { in select_input()
1759 adv7604_write_reg_seq(sd, info->recommended_settings[0]); in select_input()
1761 afe_write(sd, 0x00, 0x08); /* power up ADC */ in select_input()
1762 afe_write(sd, 0x01, 0x06); /* power up Analog Front End */ in select_input()
1763 afe_write(sd, 0xc8, 0x00); /* phase control */ in select_input()
1764 } else if (is_digital_input(sd)) { in select_input()
1765 hdmi_write(sd, 0x00, state->selected_input & 0x03); in select_input()
1767 adv7604_write_reg_seq(sd, info->recommended_settings[1]); in select_input()
1770 afe_write(sd, 0x00, 0xff); /* power down ADC */ in select_input()
1771 afe_write(sd, 0x01, 0xfe); /* power down Analog Front End */ in select_input()
1772 afe_write(sd, 0xc8, 0x40); /* phase control */ in select_input()
1775 cp_write(sd, 0x3e, 0x00); /* CP core pre-gain control */ in select_input()
1776 cp_write(sd, 0xc3, 0x39); /* CP coast control. Graphics mode */ in select_input()
1777 cp_write(sd, 0x40, 0x80); /* CP core pre-gain control. Graphics mode */ in select_input()
1779 v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n", in select_input()
1784 static int adv7604_s_routing(struct v4l2_subdev *sd, in adv7604_s_routing() argument
1787 struct adv7604_state *state = to_state(sd); in adv7604_s_routing()
1789 v4l2_dbg(2, debug, sd, "%s: input %d, selected input %d", in adv7604_s_routing()
1800 disable_input(sd); in adv7604_s_routing()
1802 select_input(sd); in adv7604_s_routing()
1804 enable_input(sd); in adv7604_s_routing()
1809 static int adv7604_enum_mbus_code(struct v4l2_subdev *sd, in adv7604_enum_mbus_code() argument
1813 struct adv7604_state *state = to_state(sd); in adv7604_enum_mbus_code()
1876 struct v4l2_subdev *sd = &state->sd; in adv7604_setup_format() local
1878 io_write_clr_set(sd, 0x02, 0x02, in adv7604_setup_format()
1880 io_write(sd, 0x03, state->format->op_format_sel | in adv7604_setup_format()
1882 io_write_clr_set(sd, 0x04, 0xe0, adv7604_op_ch_sel(state)); in adv7604_setup_format()
1883 io_write_clr_set(sd, 0x05, 0x01, in adv7604_setup_format()
1887 static int adv7604_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, in adv7604_get_format() argument
1890 struct adv7604_state *state = to_state(sd); in adv7604_get_format()
1909 static int adv7604_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, in adv7604_set_format() argument
1912 struct adv7604_state *state = to_state(sd); in adv7604_set_format()
1938 static int adv7604_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in adv7604_isr() argument
1940 struct adv7604_state *state = to_state(sd); in adv7604_isr()
1942 const u8 irq_reg_0x43 = io_read(sd, 0x43); in adv7604_isr()
1943 const u8 irq_reg_0x6b = io_read(sd, 0x6b); in adv7604_isr()
1944 const u8 irq_reg_0x70 = io_read(sd, 0x70); in adv7604_isr()
1950 io_write(sd, 0x44, irq_reg_0x43); in adv7604_isr()
1952 io_write(sd, 0x71, irq_reg_0x70); in adv7604_isr()
1954 io_write(sd, 0x6c, irq_reg_0x6b); in adv7604_isr()
1956 v4l2_dbg(2, debug, sd, "%s: ", __func__); in adv7604_isr()
1960 fmt_change_digital = is_digital_input(sd) in adv7604_isr()
1965 v4l2_dbg(1, debug, sd, in adv7604_isr()
1969 v4l2_subdev_notify(sd, ADV7604_FMT_CHANGE, NULL); in adv7604_isr()
1976 v4l2_dbg(1, debug, sd, "%s: irq %s mode\n", __func__, in adv7604_isr()
1977 (io_read(sd, 0x6a) & 0x01) ? "HDMI" : "DVI"); in adv7604_isr()
1978 set_rgb_quantization_range(sd); in adv7604_isr()
1986 v4l2_dbg(1, debug, sd, "%s: tx_5v: 0x%x\n", __func__, tx_5v); in adv7604_isr()
1987 adv7604_s_detect_tx_5v_ctrl(sd); in adv7604_isr()
1994 static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in adv7604_get_edid() argument
1996 struct adv7604_state *state = to_state(sd); in adv7604_get_edid()
2062 static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in adv7604_set_edid() argument
2064 struct adv7604_state *state = to_state(sd); in adv7604_set_edid()
2078 rep_write_clr_set(sd, info->edid_enable_reg, 0x0f, state->edid.present); in adv7604_set_edid()
2087 v4l2_dbg(2, debug, sd, "%s: clear EDID pad %d, edid.present = 0x%x\n", in adv7604_set_edid()
2096 v4l2_dbg(2, debug, sd, "%s: write EDID pad %d, edid.present = 0x%x\n", in adv7604_set_edid()
2102 rep_write_clr_set(sd, info->edid_enable_reg, 0x0f, 0x00); in adv7604_set_edid()
2114 rep_write(sd, 0x70, edid->edid[spa_loc]); in adv7604_set_edid()
2115 rep_write(sd, 0x71, edid->edid[spa_loc + 1]); in adv7604_set_edid()
2118 rep_write(sd, 0x72, edid->edid[spa_loc]); in adv7604_set_edid()
2119 rep_write(sd, 0x73, edid->edid[spa_loc + 1]); in adv7604_set_edid()
2122 rep_write(sd, 0x74, edid->edid[spa_loc]); in adv7604_set_edid()
2123 rep_write(sd, 0x75, edid->edid[spa_loc + 1]); in adv7604_set_edid()
2130 rep_write(sd, 0x76, spa_loc & 0xff); in adv7604_set_edid()
2131 rep_write_clr_set(sd, 0x77, 0x40, (spa_loc & 0x100) >> 2); in adv7604_set_edid()
2134 rep_write_clr_set(sd, 0x71, 0x01, (spa_loc & 0x100) >> 8); in adv7604_set_edid()
2146 err = edid_write_block(sd, 128 * edid->blocks, state->edid.edid); in adv7604_set_edid()
2148 v4l2_err(sd, "error %d writing edid pad %d\n", err, edid->pad); in adv7604_set_edid()
2154 rep_write_clr_set(sd, info->edid_enable_reg, 0x0f, state->edid.present); in adv7604_set_edid()
2157 if (rep_read(sd, info->edid_status_reg) & state->edid.present) in adv7604_set_edid()
2162 v4l2_err(sd, "error enabling edid (0x%x)\n", state->edid.present); in adv7604_set_edid()
2175 static void print_avi_infoframe(struct v4l2_subdev *sd) in print_avi_infoframe() argument
2182 if (!is_hdmi(sd)) { in print_avi_infoframe()
2183 v4l2_info(sd, "receive DVI-D signal (AVI infoframe not supported)\n"); in print_avi_infoframe()
2186 if (!(io_read(sd, 0x60) & 0x01)) { in print_avi_infoframe()
2187 v4l2_info(sd, "AVI infoframe not received\n"); in print_avi_infoframe()
2191 if (io_read(sd, 0x83) & 0x01) { in print_avi_infoframe()
2192 v4l2_info(sd, "AVI infoframe checksum error has occurred earlier\n"); in print_avi_infoframe()
2193 io_write(sd, 0x85, 0x01); /* clear AVI_INF_CKS_ERR_RAW */ in print_avi_infoframe()
2194 if (io_read(sd, 0x83) & 0x01) { in print_avi_infoframe()
2195 v4l2_info(sd, "AVI infoframe checksum error still present\n"); in print_avi_infoframe()
2196 io_write(sd, 0x85, 0x01); /* clear AVI_INF_CKS_ERR_RAW */ in print_avi_infoframe()
2200 avi_len = infoframe_read(sd, 0xe2); in print_avi_infoframe()
2201 avi_ver = infoframe_read(sd, 0xe1); in print_avi_infoframe()
2202 v4l2_info(sd, "AVI infoframe version %d (%d byte)\n", in print_avi_infoframe()
2209 buf[i] = infoframe_read(sd, i); in print_avi_infoframe()
2211 v4l2_info(sd, in print_avi_infoframe()
2217 static int adv7604_log_status(struct v4l2_subdev *sd) in adv7604_log_status() argument
2219 struct adv7604_state *state = to_state(sd); in adv7604_log_status()
2223 u8 reg_io_0x02 = io_read(sd, 0x02); in adv7604_log_status()
2253 v4l2_info(sd, "-----Chip status-----\n"); in adv7604_log_status()
2254 v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on"); in adv7604_log_status()
2255 edid_enabled = rep_read(sd, info->edid_status_reg); in adv7604_log_status()
2256 v4l2_info(sd, "EDID enabled port A: %s, B: %s, C: %s, D: %s\n", in adv7604_log_status()
2261 v4l2_info(sd, "CEC: %s\n", !!(cec_read(sd, 0x2a) & 0x01) ? in adv7604_log_status()
2264 v4l2_info(sd, "-----Signal status-----\n"); in adv7604_log_status()
2265 cable_det = info->read_cable_det(sd); in adv7604_log_status()
2266 v4l2_info(sd, "Cable detected (+5V power) port A: %s, B: %s, C: %s, D: %s\n", in adv7604_log_status()
2271 v4l2_info(sd, "TMDS signal detected: %s\n", in adv7604_log_status()
2272 no_signal_tmds(sd) ? "false" : "true"); in adv7604_log_status()
2273 v4l2_info(sd, "TMDS signal locked: %s\n", in adv7604_log_status()
2274 no_lock_tmds(sd) ? "false" : "true"); in adv7604_log_status()
2275 v4l2_info(sd, "SSPD locked: %s\n", no_lock_sspd(sd) ? "false" : "true"); in adv7604_log_status()
2276 v4l2_info(sd, "STDI locked: %s\n", no_lock_stdi(sd) ? "false" : "true"); in adv7604_log_status()
2277 v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true"); in adv7604_log_status()
2278 v4l2_info(sd, "CP free run: %s\n", in adv7604_log_status()
2279 (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off")); in adv7604_log_status()
2280 v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n", in adv7604_log_status()
2281 io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f, in adv7604_log_status()
2282 (io_read(sd, 0x01) & 0x70) >> 4); in adv7604_log_status()
2284 v4l2_info(sd, "-----Video Timings-----\n"); in adv7604_log_status()
2285 if (read_stdi(sd, &stdi)) in adv7604_log_status()
2286 v4l2_info(sd, "STDI: not locked\n"); in adv7604_log_status()
2288 …v4l2_info(sd, "STDI: lcf (frame height - 1) = %d, bl = %d, lcvs (vsync) = %d, %s, %chsync, %cvsync… in adv7604_log_status()
2292 if (adv7604_query_dv_timings(sd, &timings)) in adv7604_log_status()
2293 v4l2_info(sd, "No video detected\n"); in adv7604_log_status()
2295 v4l2_print_dv_timings(sd->name, "Detected format: ", in adv7604_log_status()
2297 v4l2_print_dv_timings(sd->name, "Configured format: ", in adv7604_log_status()
2300 if (no_signal(sd)) in adv7604_log_status()
2303 v4l2_info(sd, "-----Color space-----\n"); in adv7604_log_status()
2304 v4l2_info(sd, "RGB quantization range ctrl: %s\n", in adv7604_log_status()
2306 v4l2_info(sd, "Input color space: %s\n", in adv7604_log_status()
2308 v4l2_info(sd, "Output color space: %s %s, saturator %s\n", in adv7604_log_status()
2313 v4l2_info(sd, "Color space conversion: %s\n", in adv7604_log_status()
2314 csc_coeff_sel_rb[cp_read(sd, 0xfc) >> 4]); in adv7604_log_status()
2316 if (!is_digital_input(sd)) in adv7604_log_status()
2319 v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D"); in adv7604_log_status()
2320 v4l2_info(sd, "Digital video port selected: %c\n", in adv7604_log_status()
2321 (hdmi_read(sd, 0x00) & 0x03) + 'A'); in adv7604_log_status()
2322 v4l2_info(sd, "HDCP encrypted content: %s\n", in adv7604_log_status()
2323 (hdmi_read(sd, 0x05) & 0x40) ? "true" : "false"); in adv7604_log_status()
2324 v4l2_info(sd, "HDCP keys read: %s%s\n", in adv7604_log_status()
2325 (hdmi_read(sd, 0x04) & 0x20) ? "yes" : "no", in adv7604_log_status()
2326 (hdmi_read(sd, 0x04) & 0x10) ? "ERROR" : ""); in adv7604_log_status()
2327 if (is_hdmi(sd)) { in adv7604_log_status()
2328 bool audio_pll_locked = hdmi_read(sd, 0x04) & 0x01; in adv7604_log_status()
2329 bool audio_sample_packet_detect = hdmi_read(sd, 0x18) & 0x01; in adv7604_log_status()
2330 bool audio_mute = io_read(sd, 0x65) & 0x40; in adv7604_log_status()
2332 v4l2_info(sd, "Audio: pll %s, samples %s, %s\n", in adv7604_log_status()
2337 v4l2_info(sd, "Audio format: %s\n", in adv7604_log_status()
2338 (hdmi_read(sd, 0x07) & 0x20) ? "multi-channel" : "stereo"); in adv7604_log_status()
2340 v4l2_info(sd, "Audio CTS: %u\n", (hdmi_read(sd, 0x5b) << 12) + in adv7604_log_status()
2341 (hdmi_read(sd, 0x5c) << 8) + in adv7604_log_status()
2342 (hdmi_read(sd, 0x5d) & 0xf0)); in adv7604_log_status()
2343 v4l2_info(sd, "Audio N: %u\n", ((hdmi_read(sd, 0x5d) & 0x0f) << 16) + in adv7604_log_status()
2344 (hdmi_read(sd, 0x5e) << 8) + in adv7604_log_status()
2345 hdmi_read(sd, 0x5f)); in adv7604_log_status()
2346 v4l2_info(sd, "AV Mute: %s\n", (hdmi_read(sd, 0x04) & 0x40) ? "on" : "off"); in adv7604_log_status()
2348 v4l2_info(sd, "Deep color mode: %s\n", deep_color_mode_txt[(hdmi_read(sd, 0x0b) & 0x60) >> 5]); in adv7604_log_status()
2350 print_avi_infoframe(sd); in adv7604_log_status()
2432 static int adv7604_core_init(struct v4l2_subdev *sd) in adv7604_core_init() argument
2434 struct adv7604_state *state = to_state(sd); in adv7604_core_init()
2438 hdmi_write(sd, 0x48, in adv7604_core_init()
2442 disable_input(sd); in adv7604_core_init()
2447 select_input(sd); in adv7604_core_init()
2448 enable_input(sd); in adv7604_core_init()
2452 io_write(sd, 0x0c, 0x42); /* Power up part and power down VDP */ in adv7604_core_init()
2453 io_write(sd, 0x0b, 0x44); /* Power down ESDP block */ in adv7604_core_init()
2454 cp_write(sd, 0xcf, 0x01); /* Power down macrovision */ in adv7604_core_init()
2457 io_write_clr_set(sd, 0x02, 0x0f, in adv7604_core_init()
2461 io_write_clr_set(sd, 0x05, 0x0e, pdata->blank_data << 3 | in adv7604_core_init()
2466 cp_write(sd, 0x69, 0x30); /* Enable CP CSC */ in adv7604_core_init()
2469 io_write(sd, 0x06, 0xa0 | pdata->inv_vs_pol << 2 | in adv7604_core_init()
2473 io_write(sd, 0x14, 0x40 | pdata->dr_str_data << 4 | in adv7604_core_init()
2477 cp_write(sd, 0xba, (pdata->hdmi_free_run_mode << 1) | 0x01); /* HDMI free run */ in adv7604_core_init()
2478 cp_write(sd, 0xf3, 0xdc); /* Low threshold to enter/exit free run mode */ in adv7604_core_init()
2479 cp_write(sd, 0xf9, 0x23); /* STDI ch. 1 - LCVS change threshold - in adv7604_core_init()
2481 cp_write(sd, 0x45, 0x23); /* STDI ch. 2 - LCVS change threshold - in adv7604_core_init()
2483 cp_write(sd, 0xc9, 0x2d); /* use prim_mode and vid_std as free run resolution in adv7604_core_init()
2487 hdmi_write_clr_set(sd, 0x15, 0x03, 0x03); /* Mute on FIFO over-/underflow [REF_01, c. 1.2.18] */ in adv7604_core_init()
2488 hdmi_write_clr_set(sd, 0x1a, 0x0e, 0x08); /* Wait 1 s before unmute */ in adv7604_core_init()
2489 hdmi_write_clr_set(sd, 0x68, 0x06, 0x06); /* FIFO reset on over-/underflow [REF_01, c. 1.2.19] */ in adv7604_core_init()
2492 afe_write(sd, 0xb5, 0x01); /* Setting MCLK to 256Fs */ in adv7604_core_init()
2495 afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */ in adv7604_core_init()
2496 io_write_clr_set(sd, 0x30, 1 << 4, pdata->output_bus_lsb_to_msb << 4); in adv7604_core_init()
2500 io_write(sd, 0x40, 0xc0 | pdata->int1_config); /* Configure INT1 */ in adv7604_core_init()
2501 io_write(sd, 0x46, 0x98); /* Enable SSPD, STDI and CP unlocked interrupts */ in adv7604_core_init()
2502 …io_write(sd, 0x6e, info->fmt_change_digital_mask); /* Enable V_LOCKED and DE_REGEN_LCK interrupts … in adv7604_core_init()
2503 io_write(sd, 0x73, info->cable_det_mask); /* Enable cable detection (+5v) interrupts */ in adv7604_core_init()
2504 info->setup_irqs(sd); in adv7604_core_init()
2506 return v4l2_ctrl_handler_setup(sd->ctrl_handler); in adv7604_core_init()
2509 static void adv7604_setup_irqs(struct v4l2_subdev *sd) in adv7604_setup_irqs() argument
2511 io_write(sd, 0x41, 0xd7); /* STDI irq for any change, disable INT2 */ in adv7604_setup_irqs()
2514 static void adv7611_setup_irqs(struct v4l2_subdev *sd) in adv7611_setup_irqs() argument
2516 io_write(sd, 0x41, 0xd0); /* STDI irq for any change, disable INT2 */ in adv7611_setup_irqs()
2529 static struct i2c_client *adv7604_dummy_client(struct v4l2_subdev *sd, in adv7604_dummy_client() argument
2532 struct i2c_client *client = v4l2_get_subdevdata(sd); in adv7604_dummy_client()
2535 io_write(sd, io_reg, addr << 1); in adv7604_dummy_client()
2536 return i2c_new_dummy(client->adapter, io_read(sd, io_reg) >> 1); in adv7604_dummy_client()
2752 struct v4l2_subdev *sd; in adv7604_probe() local
2811 sd = &state->sd; in adv7604_probe()
2812 v4l2_i2c_subdev_init(sd, client, &adv7604_ops); in adv7604_probe()
2813 snprintf(sd->name, sizeof(sd->name), "%s %d-%04x", in adv7604_probe()
2816 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adv7604_probe()
2826 v4l2_info(sd, "not an adv7604 on address 0x%x\n", in adv7604_probe()
2834 v4l2_info(sd, "not an adv7611 on address 0x%x\n", in adv7604_probe()
2871 sd->ctrl_handler = hdl; in adv7604_probe()
2883 if (adv7604_s_detect_tx_5v_ctrl(sd)) { in adv7604_probe()
2893 adv7604_dummy_client(sd, state->pdata.i2c_addresses[i], in adv7604_probe()
2897 v4l2_err(sd, "failed to create i2c client %u\n", i); in adv7604_probe()
2905 v4l2_err(sd, "Could not create work queue\n"); in adv7604_probe()
2919 err = media_entity_init(&sd->entity, state->source_pad + 1, in adv7604_probe()
2924 err = adv7604_core_init(sd); in adv7604_probe()
2927 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in adv7604_probe()
2930 err = v4l2_async_register_subdev(sd); in adv7604_probe()
2937 media_entity_cleanup(&sd->entity); in adv7604_probe()
2952 struct v4l2_subdev *sd = i2c_get_clientdata(client); in adv7604_remove() local
2953 struct adv7604_state *state = to_state(sd); in adv7604_remove()
2957 v4l2_async_unregister_subdev(sd); in adv7604_remove()
2958 v4l2_device_unregister_subdev(sd); in adv7604_remove()
2959 media_entity_cleanup(&sd->entity); in adv7604_remove()
2960 adv7604_unregister_clients(to_state(sd)); in adv7604_remove()
2961 v4l2_ctrl_handler_free(sd->ctrl_handler); in adv7604_remove()