Lines Matching refs:sd

81 	struct v4l2_subdev sd;  member
109 static void tc358743_enable_interrupts(struct v4l2_subdev *sd,
111 static int tc358743_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd);
113 static inline struct tc358743_state *to_state(struct v4l2_subdev *sd) in to_state() argument
115 return container_of(sd, struct tc358743_state, sd); in to_state()
120 static void i2c_rd(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) in i2c_rd() argument
122 struct tc358743_state *state = to_state(sd); in i2c_rd()
143 v4l2_err(sd, "%s: reading register 0x%x from 0x%x failed\n", in i2c_rd()
148 static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) in i2c_wr() argument
150 struct tc358743_state *state = to_state(sd); in i2c_wr()
157 v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n", in i2c_wr()
173 v4l2_err(sd, "%s: writing register 0x%x from 0x%x failed\n", in i2c_wr()
183 v4l2_info(sd, "I2C write 0x%04x = 0x%02x", in i2c_wr()
187 v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x", in i2c_wr()
191 v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x%02x%02x", in i2c_wr()
195 v4l2_info(sd, "I2C write %d bytes from address 0x%04x\n", in i2c_wr()
200 static u8 i2c_rd8(struct v4l2_subdev *sd, u16 reg) in i2c_rd8() argument
204 i2c_rd(sd, reg, &val, 1); in i2c_rd8()
209 static void i2c_wr8(struct v4l2_subdev *sd, u16 reg, u8 val) in i2c_wr8() argument
211 i2c_wr(sd, reg, &val, 1); in i2c_wr8()
214 static void i2c_wr8_and_or(struct v4l2_subdev *sd, u16 reg, in i2c_wr8_and_or() argument
217 i2c_wr8(sd, reg, (i2c_rd8(sd, reg) & mask) | val); in i2c_wr8_and_or()
220 static u16 i2c_rd16(struct v4l2_subdev *sd, u16 reg) in i2c_rd16() argument
224 i2c_rd(sd, reg, (u8 *)&val, 2); in i2c_rd16()
229 static void i2c_wr16(struct v4l2_subdev *sd, u16 reg, u16 val) in i2c_wr16() argument
231 i2c_wr(sd, reg, (u8 *)&val, 2); in i2c_wr16()
234 static void i2c_wr16_and_or(struct v4l2_subdev *sd, u16 reg, u16 mask, u16 val) in i2c_wr16_and_or() argument
236 i2c_wr16(sd, reg, (i2c_rd16(sd, reg) & mask) | val); in i2c_wr16_and_or()
239 static u32 i2c_rd32(struct v4l2_subdev *sd, u16 reg) in i2c_rd32() argument
243 i2c_rd(sd, reg, (u8 *)&val, 4); in i2c_rd32()
248 static void i2c_wr32(struct v4l2_subdev *sd, u16 reg, u32 val) in i2c_wr32() argument
250 i2c_wr(sd, reg, (u8 *)&val, 4); in i2c_wr32()
255 static inline bool is_hdmi(struct v4l2_subdev *sd) in is_hdmi() argument
257 return i2c_rd8(sd, SYS_STATUS) & MASK_S_HDMI; in is_hdmi()
260 static inline bool tx_5v_power_present(struct v4l2_subdev *sd) in tx_5v_power_present() argument
262 return i2c_rd8(sd, SYS_STATUS) & MASK_S_DDC5V; in tx_5v_power_present()
265 static inline bool no_signal(struct v4l2_subdev *sd) in no_signal() argument
267 return !(i2c_rd8(sd, SYS_STATUS) & MASK_S_TMDS); in no_signal()
270 static inline bool no_sync(struct v4l2_subdev *sd) in no_sync() argument
272 return !(i2c_rd8(sd, SYS_STATUS) & MASK_S_SYNC); in no_sync()
275 static inline bool audio_present(struct v4l2_subdev *sd) in audio_present() argument
277 return i2c_rd8(sd, AU_STATUS0) & MASK_S_A_SAMPLE; in audio_present()
280 static int get_audio_sampling_rate(struct v4l2_subdev *sd) in get_audio_sampling_rate() argument
288 if (no_signal(sd)) in get_audio_sampling_rate()
291 return code_to_rate[i2c_rd8(sd, FS_SET) & MASK_FS]; in get_audio_sampling_rate()
294 static unsigned tc358743_num_csi_lanes_in_use(struct v4l2_subdev *sd) in tc358743_num_csi_lanes_in_use() argument
296 return ((i2c_rd32(sd, CSI_CONTROL) & MASK_NOL) >> 1) + 1; in tc358743_num_csi_lanes_in_use()
310 static int tc358743_get_detected_timings(struct v4l2_subdev *sd, in tc358743_get_detected_timings() argument
318 if (no_signal(sd)) { in tc358743_get_detected_timings()
319 v4l2_dbg(1, debug, sd, "%s: no valid signal\n", __func__); in tc358743_get_detected_timings()
322 if (no_sync(sd)) { in tc358743_get_detected_timings()
323 v4l2_dbg(1, debug, sd, "%s: no sync on signal\n", __func__); in tc358743_get_detected_timings()
328 bt->interlaced = i2c_rd8(sd, VI_STATUS1) & MASK_S_V_INTERLACE ? in tc358743_get_detected_timings()
331 width = ((i2c_rd8(sd, DE_WIDTH_H_HI) & 0x1f) << 8) + in tc358743_get_detected_timings()
332 i2c_rd8(sd, DE_WIDTH_H_LO); in tc358743_get_detected_timings()
333 height = ((i2c_rd8(sd, DE_WIDTH_V_HI) & 0x1f) << 8) + in tc358743_get_detected_timings()
334 i2c_rd8(sd, DE_WIDTH_V_LO); in tc358743_get_detected_timings()
335 frame_width = ((i2c_rd8(sd, H_SIZE_HI) & 0x1f) << 8) + in tc358743_get_detected_timings()
336 i2c_rd8(sd, H_SIZE_LO); in tc358743_get_detected_timings()
337 frame_height = (((i2c_rd8(sd, V_SIZE_HI) & 0x3f) << 8) + in tc358743_get_detected_timings()
338 i2c_rd8(sd, V_SIZE_LO)) / 2; in tc358743_get_detected_timings()
341 frame_interval = ((i2c_rd8(sd, FV_CNT_HI) & 0x3) << 8) + in tc358743_get_detected_timings()
342 i2c_rd8(sd, FV_CNT_LO); in tc358743_get_detected_timings()
367 struct v4l2_subdev *sd = &state->sd; in tc358743_delayed_work_enable_hotplug() local
369 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc358743_delayed_work_enable_hotplug()
371 i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, MASK_HPD_OUT0); in tc358743_delayed_work_enable_hotplug()
374 static void tc358743_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable) in tc358743_set_hdmi_hdcp() argument
376 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? in tc358743_set_hdmi_hdcp()
379 i2c_wr8_and_or(sd, HDCP_REG1, in tc358743_set_hdmi_hdcp()
383 i2c_wr8_and_or(sd, HDCP_REG2, ~MASK_AUTO_P3_RESET, in tc358743_set_hdmi_hdcp()
390 i2c_wr8_and_or(sd, HDCP_REG3, ~KEY_RD_CMD, enable ? KEY_RD_CMD : 0); in tc358743_set_hdmi_hdcp()
391 i2c_wr8_and_or(sd, HDCP_MODE, ~(MASK_AUTO_CLR | MASK_MODE_RST_TN), in tc358743_set_hdmi_hdcp()
398 i2c_wr8_and_or(sd, BSTATUS1, ~MASK_MAX_EXCED, in tc358743_set_hdmi_hdcp()
400 i2c_wr8_and_or(sd, BCAPS, ~(MASK_REPEATER | MASK_READY), in tc358743_set_hdmi_hdcp()
404 static void tc358743_disable_edid(struct v4l2_subdev *sd) in tc358743_disable_edid() argument
406 struct tc358743_state *state = to_state(sd); in tc358743_disable_edid()
408 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc358743_disable_edid()
414 i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, 0x0); in tc358743_disable_edid()
417 static void tc358743_enable_edid(struct v4l2_subdev *sd) in tc358743_enable_edid() argument
419 struct tc358743_state *state = to_state(sd); in tc358743_enable_edid()
422 v4l2_dbg(2, debug, sd, "%s: no EDID -> no hotplug\n", __func__); in tc358743_enable_edid()
426 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc358743_enable_edid()
433 tc358743_enable_interrupts(sd, true); in tc358743_enable_edid()
434 tc358743_s_ctrl_detect_tx_5v(sd); in tc358743_enable_edid()
437 static void tc358743_erase_bksv(struct v4l2_subdev *sd) in tc358743_erase_bksv() argument
442 i2c_wr8(sd, BKSV + i, 0); in tc358743_erase_bksv()
447 static void print_avi_infoframe(struct v4l2_subdev *sd) in print_avi_infoframe() argument
449 struct i2c_client *client = v4l2_get_subdevdata(sd); in print_avi_infoframe()
454 if (!is_hdmi(sd)) { in print_avi_infoframe()
455 v4l2_info(sd, "DVI-D signal - AVI infoframe not supported\n"); in print_avi_infoframe()
459 i2c_rd(sd, PK_AVI_0HEAD, buffer, HDMI_INFOFRAME_SIZE(AVI)); in print_avi_infoframe()
462 v4l2_err(sd, "%s: unpack of AVI infoframe failed\n", __func__); in print_avi_infoframe()
471 static int tc358743_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd) in tc358743_s_ctrl_detect_tx_5v() argument
473 struct tc358743_state *state = to_state(sd); in tc358743_s_ctrl_detect_tx_5v()
476 tx_5v_power_present(sd)); in tc358743_s_ctrl_detect_tx_5v()
479 static int tc358743_s_ctrl_audio_sampling_rate(struct v4l2_subdev *sd) in tc358743_s_ctrl_audio_sampling_rate() argument
481 struct tc358743_state *state = to_state(sd); in tc358743_s_ctrl_audio_sampling_rate()
484 get_audio_sampling_rate(sd)); in tc358743_s_ctrl_audio_sampling_rate()
487 static int tc358743_s_ctrl_audio_present(struct v4l2_subdev *sd) in tc358743_s_ctrl_audio_present() argument
489 struct tc358743_state *state = to_state(sd); in tc358743_s_ctrl_audio_present()
492 audio_present(sd)); in tc358743_s_ctrl_audio_present()
495 static int tc358743_update_controls(struct v4l2_subdev *sd) in tc358743_update_controls() argument
499 ret |= tc358743_s_ctrl_detect_tx_5v(sd); in tc358743_update_controls()
500 ret |= tc358743_s_ctrl_audio_sampling_rate(sd); in tc358743_update_controls()
501 ret |= tc358743_s_ctrl_audio_present(sd); in tc358743_update_controls()
508 static void tc358743_reset_phy(struct v4l2_subdev *sd) in tc358743_reset_phy() argument
510 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in tc358743_reset_phy()
512 i2c_wr8_and_or(sd, PHY_RST, ~MASK_RESET_CTRL, 0); in tc358743_reset_phy()
513 i2c_wr8_and_or(sd, PHY_RST, ~MASK_RESET_CTRL, MASK_RESET_CTRL); in tc358743_reset_phy()
516 static void tc358743_reset(struct v4l2_subdev *sd, uint16_t mask) in tc358743_reset() argument
518 u16 sysctl = i2c_rd16(sd, SYSCTL); in tc358743_reset()
520 i2c_wr16(sd, SYSCTL, sysctl | mask); in tc358743_reset()
521 i2c_wr16(sd, SYSCTL, sysctl & ~mask); in tc358743_reset()
524 static inline void tc358743_sleep_mode(struct v4l2_subdev *sd, bool enable) in tc358743_sleep_mode() argument
526 i2c_wr16_and_or(sd, SYSCTL, ~MASK_SLEEP, in tc358743_sleep_mode()
530 static inline void enable_stream(struct v4l2_subdev *sd, bool enable) in enable_stream() argument
532 struct tc358743_state *state = to_state(sd); in enable_stream()
534 v4l2_dbg(3, debug, sd, "%s: %sable\n", in enable_stream()
541 i2c_wr32(sd, TXOPTIONCNTRL, 0); in enable_stream()
543 i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE); in enable_stream()
545 i2c_wr8(sd, VI_MUTE, MASK_AUTO_MUTE); in enable_stream()
549 i2c_wr8(sd, VI_MUTE, MASK_AUTO_MUTE | MASK_VI_MUTE); in enable_stream()
553 i2c_wr16_and_or(sd, CONFCTL, ~(MASK_VBUFEN | MASK_ABUFEN), in enable_stream()
558 static void tc358743_set_pll(struct v4l2_subdev *sd) in tc358743_set_pll() argument
560 struct tc358743_state *state = to_state(sd); in tc358743_set_pll()
562 u16 pllctl0 = i2c_rd16(sd, PLLCTL0); in tc358743_set_pll()
563 u16 pllctl1 = i2c_rd16(sd, PLLCTL1); in tc358743_set_pll()
568 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc358743_set_pll()
584 v4l2_dbg(1, debug, sd, "%s: updating PLL clock\n", __func__); in tc358743_set_pll()
585 tc358743_sleep_mode(sd, true); in tc358743_set_pll()
586 i2c_wr16(sd, PLLCTL0, pllctl0_new); in tc358743_set_pll()
587 i2c_wr16_and_or(sd, PLLCTL1, in tc358743_set_pll()
592 i2c_wr16_and_or(sd, PLLCTL1, ~MASK_CKEN, MASK_CKEN); in tc358743_set_pll()
593 tc358743_sleep_mode(sd, false); in tc358743_set_pll()
597 static void tc358743_set_ref_clk(struct v4l2_subdev *sd) in tc358743_set_ref_clk() argument
599 struct tc358743_state *state = to_state(sd); in tc358743_set_ref_clk()
611 i2c_wr8(sd, SYS_FREQ0, sys_freq & 0x00ff); in tc358743_set_ref_clk()
612 i2c_wr8(sd, SYS_FREQ1, (sys_freq & 0xff00) >> 8); in tc358743_set_ref_clk()
614 i2c_wr8_and_or(sd, PHY_CTL0, ~MASK_PHY_SYSCLK_IND, in tc358743_set_ref_clk()
619 i2c_wr8(sd, FH_MIN0, fh_min & 0x00ff); in tc358743_set_ref_clk()
620 i2c_wr8(sd, FH_MIN1, (fh_min & 0xff00) >> 8); in tc358743_set_ref_clk()
623 i2c_wr8(sd, FH_MAX0, fh_max & 0x00ff); in tc358743_set_ref_clk()
624 i2c_wr8(sd, FH_MAX1, (fh_max & 0xff00) >> 8); in tc358743_set_ref_clk()
627 i2c_wr8(sd, LOCKDET_REF0, lockdet_ref & 0x0000ff); in tc358743_set_ref_clk()
628 i2c_wr8(sd, LOCKDET_REF1, (lockdet_ref & 0x00ff00) >> 8); in tc358743_set_ref_clk()
629 i2c_wr8(sd, LOCKDET_REF2, (lockdet_ref & 0x0f0000) >> 16); in tc358743_set_ref_clk()
631 i2c_wr8_and_or(sd, NCO_F0_MOD, ~MASK_NCO_F0_MOD, in tc358743_set_ref_clk()
636 static void tc358743_set_csi_color_space(struct v4l2_subdev *sd) in tc358743_set_csi_color_space() argument
638 struct tc358743_state *state = to_state(sd); in tc358743_set_csi_color_space()
642 v4l2_dbg(2, debug, sd, "%s: YCbCr 422 16-bit\n", __func__); in tc358743_set_csi_color_space()
643 i2c_wr8_and_or(sd, VOUT_SET2, in tc358743_set_csi_color_space()
646 i2c_wr8_and_or(sd, VI_REP, ~MASK_VOUT_COLOR_SEL & 0xff, in tc358743_set_csi_color_space()
649 i2c_wr16_and_or(sd, CONFCTL, ~MASK_YCBCRFMT, in tc358743_set_csi_color_space()
654 v4l2_dbg(2, debug, sd, "%s: RGB 888 24-bit\n", __func__); in tc358743_set_csi_color_space()
655 i2c_wr8_and_or(sd, VOUT_SET2, in tc358743_set_csi_color_space()
658 i2c_wr8_and_or(sd, VI_REP, ~MASK_VOUT_COLOR_SEL & 0xff, in tc358743_set_csi_color_space()
661 i2c_wr16_and_or(sd, CONFCTL, ~MASK_YCBCRFMT, 0); in tc358743_set_csi_color_space()
665 v4l2_dbg(2, debug, sd, "%s: Unsupported format code 0x%x\n", in tc358743_set_csi_color_space()
670 static unsigned tc358743_num_csi_lanes_needed(struct v4l2_subdev *sd) in tc358743_num_csi_lanes_needed() argument
672 struct tc358743_state *state = to_state(sd); in tc358743_num_csi_lanes_needed()
683 static void tc358743_set_csi(struct v4l2_subdev *sd) in tc358743_set_csi() argument
685 struct tc358743_state *state = to_state(sd); in tc358743_set_csi()
687 unsigned lanes = tc358743_num_csi_lanes_needed(sd); in tc358743_set_csi()
689 v4l2_dbg(3, debug, sd, "%s:\n", __func__); in tc358743_set_csi()
691 tc358743_reset(sd, MASK_CTXRST); in tc358743_set_csi()
694 i2c_wr32(sd, CLW_CNTRL, MASK_CLW_LANEDISABLE); in tc358743_set_csi()
696 i2c_wr32(sd, D0W_CNTRL, MASK_D0W_LANEDISABLE); in tc358743_set_csi()
698 i2c_wr32(sd, D1W_CNTRL, MASK_D1W_LANEDISABLE); in tc358743_set_csi()
700 i2c_wr32(sd, D2W_CNTRL, MASK_D2W_LANEDISABLE); in tc358743_set_csi()
702 i2c_wr32(sd, D3W_CNTRL, MASK_D3W_LANEDISABLE); in tc358743_set_csi()
704 i2c_wr32(sd, LINEINITCNT, pdata->lineinitcnt); in tc358743_set_csi()
705 i2c_wr32(sd, LPTXTIMECNT, pdata->lptxtimecnt); in tc358743_set_csi()
706 i2c_wr32(sd, TCLK_HEADERCNT, pdata->tclk_headercnt); in tc358743_set_csi()
707 i2c_wr32(sd, TCLK_TRAILCNT, pdata->tclk_trailcnt); in tc358743_set_csi()
708 i2c_wr32(sd, THS_HEADERCNT, pdata->ths_headercnt); in tc358743_set_csi()
709 i2c_wr32(sd, TWAKEUP, pdata->twakeup); in tc358743_set_csi()
710 i2c_wr32(sd, TCLK_POSTCNT, pdata->tclk_postcnt); in tc358743_set_csi()
711 i2c_wr32(sd, THS_TRAILCNT, pdata->ths_trailcnt); in tc358743_set_csi()
712 i2c_wr32(sd, HSTXVREGCNT, pdata->hstxvregcnt); in tc358743_set_csi()
714 i2c_wr32(sd, HSTXVREGEN, in tc358743_set_csi()
721 i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags & in tc358743_set_csi()
723 i2c_wr32(sd, STARTCNTRL, MASK_START); in tc358743_set_csi()
724 i2c_wr32(sd, CSI_START, MASK_STRT); in tc358743_set_csi()
726 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc358743_set_csi()
734 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc358743_set_csi()
738 i2c_wr32(sd, CSI_CONFW, MASK_MODE_CLEAR | in tc358743_set_csi()
741 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc358743_set_csi()
745 static void tc358743_set_hdmi_phy(struct v4l2_subdev *sd) in tc358743_set_hdmi_phy() argument
747 struct tc358743_state *state = to_state(sd); in tc358743_set_hdmi_phy()
752 i2c_wr8_and_or(sd, PHY_EN, ~MASK_ENABLE_PHY, 0x0); in tc358743_set_hdmi_phy()
753 i2c_wr8(sd, PHY_CTL1, SET_PHY_AUTO_RST1_US(1600) | in tc358743_set_hdmi_phy()
755 i2c_wr8_and_or(sd, PHY_CTL2, ~MASK_PHY_AUTO_RSTn, in tc358743_set_hdmi_phy()
762 i2c_wr8(sd, PHY_BIAS, 0x40); in tc358743_set_hdmi_phy()
763 i2c_wr8(sd, PHY_CSQ, SET_CSQ_CNT_LEVEL(0x0a)); in tc358743_set_hdmi_phy()
764 i2c_wr8(sd, AVM_CTL, 45); in tc358743_set_hdmi_phy()
765 i2c_wr8_and_or(sd, HDMI_DET, ~MASK_HDMI_DET_V, in tc358743_set_hdmi_phy()
767 i2c_wr8_and_or(sd, HV_RST, ~(MASK_H_PI_RST | MASK_V_PI_RST), in tc358743_set_hdmi_phy()
772 i2c_wr8_and_or(sd, PHY_EN, ~MASK_ENABLE_PHY, MASK_ENABLE_PHY); in tc358743_set_hdmi_phy()
775 static void tc358743_set_hdmi_audio(struct v4l2_subdev *sd) in tc358743_set_hdmi_audio() argument
777 struct tc358743_state *state = to_state(sd); in tc358743_set_hdmi_audio()
780 i2c_wr8(sd, FORCE_MUTE, 0x00); in tc358743_set_hdmi_audio()
781 i2c_wr8(sd, AUTO_CMD0, MASK_AUTO_MUTE7 | MASK_AUTO_MUTE6 | in tc358743_set_hdmi_audio()
784 i2c_wr8(sd, AUTO_CMD1, MASK_AUTO_MUTE9); in tc358743_set_hdmi_audio()
785 i2c_wr8(sd, AUTO_CMD2, MASK_AUTO_PLAY3 | MASK_AUTO_PLAY2); in tc358743_set_hdmi_audio()
786 i2c_wr8(sd, BUFINIT_START, SET_BUFINIT_START_MS(500)); in tc358743_set_hdmi_audio()
787 i2c_wr8(sd, FS_MUTE, 0x00); in tc358743_set_hdmi_audio()
788 i2c_wr8(sd, FS_IMODE, MASK_NLPCM_SMODE | MASK_FS_SMODE); in tc358743_set_hdmi_audio()
789 i2c_wr8(sd, ACR_MODE, MASK_CTS_MODE); in tc358743_set_hdmi_audio()
790 i2c_wr8(sd, ACR_MDF0, MASK_ACR_L2MDF_1976_PPM | MASK_ACR_L1MDF_976_PPM); in tc358743_set_hdmi_audio()
791 i2c_wr8(sd, ACR_MDF1, MASK_ACR_L3MDF_3906_PPM); in tc358743_set_hdmi_audio()
792 i2c_wr8(sd, SDO_MODE1, MASK_SDO_FMT_I2S); in tc358743_set_hdmi_audio()
793 i2c_wr8(sd, DIV_MODE, SET_DIV_DLY_MS(100)); in tc358743_set_hdmi_audio()
796 i2c_wr16_and_or(sd, CONFCTL, 0xffff, MASK_AUDCHNUM_2 | in tc358743_set_hdmi_audio()
801 static void tc358743_set_hdmi_info_frame_mode(struct v4l2_subdev *sd) in tc358743_set_hdmi_info_frame_mode() argument
804 i2c_wr8(sd, PK_INT_MODE, MASK_ISRC2_INT_MODE | MASK_ISRC_INT_MODE | in tc358743_set_hdmi_info_frame_mode()
808 i2c_wr8(sd, NO_PKT_LIMIT, 0x2c); in tc358743_set_hdmi_info_frame_mode()
809 i2c_wr8(sd, NO_PKT_CLR, 0x53); in tc358743_set_hdmi_info_frame_mode()
810 i2c_wr8(sd, ERR_PK_LIMIT, 0x01); in tc358743_set_hdmi_info_frame_mode()
811 i2c_wr8(sd, NO_PKT_LIMIT2, 0x30); in tc358743_set_hdmi_info_frame_mode()
812 i2c_wr8(sd, NO_GDB_LIMIT, 0x10); in tc358743_set_hdmi_info_frame_mode()
815 static void tc358743_initial_setup(struct v4l2_subdev *sd) in tc358743_initial_setup() argument
817 struct tc358743_state *state = to_state(sd); in tc358743_initial_setup()
821 i2c_wr16_and_or(sd, SYSCTL, ~(MASK_CECRST | MASK_IRRST), in tc358743_initial_setup()
824 tc358743_reset(sd, MASK_CTXRST | MASK_HDMIRST); in tc358743_initial_setup()
825 tc358743_sleep_mode(sd, false); in tc358743_initial_setup()
827 i2c_wr16(sd, FIFOCTL, pdata->fifo_level); in tc358743_initial_setup()
829 tc358743_set_ref_clk(sd); in tc358743_initial_setup()
831 i2c_wr8_and_or(sd, DDC_CTL, ~MASK_DDC5V_MODE, in tc358743_initial_setup()
833 i2c_wr8_and_or(sd, EDID_MODE, ~MASK_EDID_MODE, MASK_EDID_MODE_E_DDC); in tc358743_initial_setup()
835 tc358743_set_hdmi_phy(sd); in tc358743_initial_setup()
836 tc358743_set_hdmi_hdcp(sd, pdata->enable_hdcp); in tc358743_initial_setup()
837 tc358743_set_hdmi_audio(sd); in tc358743_initial_setup()
838 tc358743_set_hdmi_info_frame_mode(sd); in tc358743_initial_setup()
841 i2c_wr8_and_or(sd, VI_MODE, ~MASK_RGB_DVI, 0); in tc358743_initial_setup()
843 i2c_wr8_and_or(sd, VOUT_SET2, ~MASK_VOUTCOLORMODE, in tc358743_initial_setup()
845 i2c_wr8(sd, VOUT_SET3, MASK_VOUT_EXTCNT); in tc358743_initial_setup()
850 static void tc358743_format_change(struct v4l2_subdev *sd) in tc358743_format_change() argument
852 struct tc358743_state *state = to_state(sd); in tc358743_format_change()
859 if (tc358743_get_detected_timings(sd, &timings)) { in tc358743_format_change()
860 enable_stream(sd, false); in tc358743_format_change()
862 v4l2_dbg(1, debug, sd, "%s: Format changed. No signal\n", in tc358743_format_change()
866 enable_stream(sd, false); in tc358743_format_change()
868 v4l2_print_dv_timings(sd->name, in tc358743_format_change()
873 if (sd->devnode) in tc358743_format_change()
874 v4l2_subdev_notify_event(sd, &tc358743_ev_fmt); in tc358743_format_change()
877 static void tc358743_init_interrupts(struct v4l2_subdev *sd) in tc358743_init_interrupts() argument
883 i2c_wr8(sd, i, 0xff); in tc358743_init_interrupts()
885 i2c_wr16(sd, INTSTATUS, 0xffff); in tc358743_init_interrupts()
888 static void tc358743_enable_interrupts(struct v4l2_subdev *sd, in tc358743_enable_interrupts() argument
891 v4l2_dbg(2, debug, sd, "%s: cable connected = %d\n", __func__, in tc358743_enable_interrupts()
895 i2c_wr8(sd, SYS_INTM, ~(MASK_M_DDC | MASK_M_DVI_DET | in tc358743_enable_interrupts()
897 i2c_wr8(sd, CLK_INTM, ~MASK_M_IN_DE_CHG); in tc358743_enable_interrupts()
898 i2c_wr8(sd, CBIT_INTM, ~(MASK_M_CBIT_FS | MASK_M_AF_LOCK | in tc358743_enable_interrupts()
900 i2c_wr8(sd, AUDIO_INTM, ~MASK_M_BUFINIT_END); in tc358743_enable_interrupts()
901 i2c_wr8(sd, MISC_INTM, ~MASK_M_SYNC_CHG); in tc358743_enable_interrupts()
903 i2c_wr8(sd, SYS_INTM, ~MASK_M_DDC & 0xff); in tc358743_enable_interrupts()
904 i2c_wr8(sd, CLK_INTM, 0xff); in tc358743_enable_interrupts()
905 i2c_wr8(sd, CBIT_INTM, 0xff); in tc358743_enable_interrupts()
906 i2c_wr8(sd, AUDIO_INTM, 0xff); in tc358743_enable_interrupts()
907 i2c_wr8(sd, MISC_INTM, 0xff); in tc358743_enable_interrupts()
911 static void tc358743_hdmi_audio_int_handler(struct v4l2_subdev *sd, in tc358743_hdmi_audio_int_handler() argument
914 u8 audio_int_mask = i2c_rd8(sd, AUDIO_INTM); in tc358743_hdmi_audio_int_handler()
915 u8 audio_int = i2c_rd8(sd, AUDIO_INT) & ~audio_int_mask; in tc358743_hdmi_audio_int_handler()
917 i2c_wr8(sd, AUDIO_INT, audio_int); in tc358743_hdmi_audio_int_handler()
919 v4l2_dbg(3, debug, sd, "%s: AUDIO_INT = 0x%02x\n", __func__, audio_int); in tc358743_hdmi_audio_int_handler()
921 tc358743_s_ctrl_audio_sampling_rate(sd); in tc358743_hdmi_audio_int_handler()
922 tc358743_s_ctrl_audio_present(sd); in tc358743_hdmi_audio_int_handler()
925 static void tc358743_csi_err_int_handler(struct v4l2_subdev *sd, bool *handled) in tc358743_csi_err_int_handler() argument
927 v4l2_err(sd, "%s: CSI_ERR = 0x%x\n", __func__, i2c_rd32(sd, CSI_ERR)); in tc358743_csi_err_int_handler()
929 i2c_wr32(sd, CSI_INT_CLR, MASK_ICRER); in tc358743_csi_err_int_handler()
932 static void tc358743_hdmi_misc_int_handler(struct v4l2_subdev *sd, in tc358743_hdmi_misc_int_handler() argument
935 u8 misc_int_mask = i2c_rd8(sd, MISC_INTM); in tc358743_hdmi_misc_int_handler()
936 u8 misc_int = i2c_rd8(sd, MISC_INT) & ~misc_int_mask; in tc358743_hdmi_misc_int_handler()
938 i2c_wr8(sd, MISC_INT, misc_int); in tc358743_hdmi_misc_int_handler()
940 v4l2_dbg(3, debug, sd, "%s: MISC_INT = 0x%02x\n", __func__, misc_int); in tc358743_hdmi_misc_int_handler()
946 if (no_sync(sd) || no_signal(sd)) { in tc358743_hdmi_misc_int_handler()
947 tc358743_reset_phy(sd); in tc358743_hdmi_misc_int_handler()
948 tc358743_erase_bksv(sd); in tc358743_hdmi_misc_int_handler()
951 tc358743_format_change(sd); in tc358743_hdmi_misc_int_handler()
959 v4l2_err(sd, "%s: Unhandled MISC_INT interrupts: 0x%02x\n", in tc358743_hdmi_misc_int_handler()
964 static void tc358743_hdmi_cbit_int_handler(struct v4l2_subdev *sd, in tc358743_hdmi_cbit_int_handler() argument
967 u8 cbit_int_mask = i2c_rd8(sd, CBIT_INTM); in tc358743_hdmi_cbit_int_handler()
968 u8 cbit_int = i2c_rd8(sd, CBIT_INT) & ~cbit_int_mask; in tc358743_hdmi_cbit_int_handler()
970 i2c_wr8(sd, CBIT_INT, cbit_int); in tc358743_hdmi_cbit_int_handler()
972 v4l2_dbg(3, debug, sd, "%s: CBIT_INT = 0x%02x\n", __func__, cbit_int); in tc358743_hdmi_cbit_int_handler()
976 v4l2_dbg(1, debug, sd, "%s: Audio sample rate changed\n", in tc358743_hdmi_cbit_int_handler()
978 tc358743_s_ctrl_audio_sampling_rate(sd); in tc358743_hdmi_cbit_int_handler()
987 v4l2_dbg(1, debug, sd, "%s: Audio present changed\n", in tc358743_hdmi_cbit_int_handler()
989 tc358743_s_ctrl_audio_present(sd); in tc358743_hdmi_cbit_int_handler()
997 v4l2_err(sd, "%s: Unhandled CBIT_INT interrupts: 0x%02x\n", in tc358743_hdmi_cbit_int_handler()
1002 static void tc358743_hdmi_clk_int_handler(struct v4l2_subdev *sd, bool *handled) in tc358743_hdmi_clk_int_handler() argument
1004 u8 clk_int_mask = i2c_rd8(sd, CLK_INTM); in tc358743_hdmi_clk_int_handler()
1005 u8 clk_int = i2c_rd8(sd, CLK_INT) & ~clk_int_mask; in tc358743_hdmi_clk_int_handler()
1008 i2c_wr8(sd, CLK_INT, clk_int | 0x80 | MASK_I_OUT_H_CHG); in tc358743_hdmi_clk_int_handler()
1010 v4l2_dbg(3, debug, sd, "%s: CLK_INT = 0x%02x\n", __func__, clk_int); in tc358743_hdmi_clk_int_handler()
1014 v4l2_dbg(1, debug, sd, "%s: DE size or position has changed\n", in tc358743_hdmi_clk_int_handler()
1023 if (!no_signal(sd) && !no_sync(sd)) in tc358743_hdmi_clk_int_handler()
1024 tc358743_format_change(sd); in tc358743_hdmi_clk_int_handler()
1032 v4l2_err(sd, "%s: Unhandled CLK_INT interrupts: 0x%02x\n", in tc358743_hdmi_clk_int_handler()
1037 static void tc358743_hdmi_sys_int_handler(struct v4l2_subdev *sd, bool *handled) in tc358743_hdmi_sys_int_handler() argument
1039 struct tc358743_state *state = to_state(sd); in tc358743_hdmi_sys_int_handler()
1040 u8 sys_int_mask = i2c_rd8(sd, SYS_INTM); in tc358743_hdmi_sys_int_handler()
1041 u8 sys_int = i2c_rd8(sd, SYS_INT) & ~sys_int_mask; in tc358743_hdmi_sys_int_handler()
1043 i2c_wr8(sd, SYS_INT, sys_int); in tc358743_hdmi_sys_int_handler()
1045 v4l2_dbg(3, debug, sd, "%s: SYS_INT = 0x%02x\n", __func__, sys_int); in tc358743_hdmi_sys_int_handler()
1048 bool tx_5v = tx_5v_power_present(sd); in tc358743_hdmi_sys_int_handler()
1050 v4l2_dbg(1, debug, sd, "%s: Tx 5V power present: %s\n", in tc358743_hdmi_sys_int_handler()
1054 tc358743_enable_edid(sd); in tc358743_hdmi_sys_int_handler()
1056 tc358743_enable_interrupts(sd, false); in tc358743_hdmi_sys_int_handler()
1057 tc358743_disable_edid(sd); in tc358743_hdmi_sys_int_handler()
1059 tc358743_erase_bksv(sd); in tc358743_hdmi_sys_int_handler()
1060 tc358743_update_controls(sd); in tc358743_hdmi_sys_int_handler()
1069 v4l2_dbg(1, debug, sd, "%s: HDMI->DVI change detected\n", in tc358743_hdmi_sys_int_handler()
1075 if (no_sync(sd) || no_signal(sd)) { in tc358743_hdmi_sys_int_handler()
1076 tc358743_reset_phy(sd); in tc358743_hdmi_sys_int_handler()
1077 tc358743_erase_bksv(sd); in tc358743_hdmi_sys_int_handler()
1086 v4l2_dbg(1, debug, sd, "%s: DVI->HDMI change detected\n", in tc358743_hdmi_sys_int_handler()
1090 i2c_wr8(sd, ANA_CTL, MASK_APPL_PCSX_NORMAL | MASK_ANALOG_ON); in tc358743_hdmi_sys_int_handler()
1098 v4l2_err(sd, "%s: Unhandled SYS_INT interrupts: 0x%02x\n", in tc358743_hdmi_sys_int_handler()
1105 static int tc358743_log_status(struct v4l2_subdev *sd) in tc358743_log_status() argument
1107 struct tc358743_state *state = to_state(sd); in tc358743_log_status()
1109 uint8_t hdmi_sys_status = i2c_rd8(sd, SYS_STATUS); in tc358743_log_status()
1110 uint16_t sysctl = i2c_rd16(sd, SYSCTL); in tc358743_log_status()
1111 u8 vi_status3 = i2c_rd8(sd, VI_STATUS3); in tc358743_log_status()
1118 v4l2_info(sd, "-----Chip status-----\n"); in tc358743_log_status()
1119 v4l2_info(sd, "Chip ID: 0x%02x\n", in tc358743_log_status()
1120 (i2c_rd16(sd, CHIPID) & MASK_CHIPID) >> 8); in tc358743_log_status()
1121 v4l2_info(sd, "Chip revision: 0x%02x\n", in tc358743_log_status()
1122 i2c_rd16(sd, CHIPID) & MASK_REVID); in tc358743_log_status()
1123 v4l2_info(sd, "Reset: IR: %d, CEC: %d, CSI TX: %d, HDMI: %d\n", in tc358743_log_status()
1128 v4l2_info(sd, "Sleep mode: %s\n", sysctl & MASK_SLEEP ? "on" : "off"); in tc358743_log_status()
1129 v4l2_info(sd, "Cable detected (+5V power): %s\n", in tc358743_log_status()
1131 v4l2_info(sd, "DDC lines enabled: %s\n", in tc358743_log_status()
1132 (i2c_rd8(sd, EDID_MODE) & MASK_EDID_MODE_E_DDC) ? in tc358743_log_status()
1134 v4l2_info(sd, "Hotplug enabled: %s\n", in tc358743_log_status()
1135 (i2c_rd8(sd, HPD_CTL) & MASK_HPD_OUT0) ? in tc358743_log_status()
1137 v4l2_info(sd, "CEC enabled: %s\n", in tc358743_log_status()
1138 (i2c_rd16(sd, CECEN) & MASK_CECEN) ? "yes" : "no"); in tc358743_log_status()
1139 v4l2_info(sd, "-----Signal status-----\n"); in tc358743_log_status()
1140 v4l2_info(sd, "TMDS signal detected: %s\n", in tc358743_log_status()
1142 v4l2_info(sd, "Stable sync signal: %s\n", in tc358743_log_status()
1144 v4l2_info(sd, "PHY PLL locked: %s\n", in tc358743_log_status()
1146 v4l2_info(sd, "PHY DE detected: %s\n", in tc358743_log_status()
1149 if (tc358743_get_detected_timings(sd, &timings)) { in tc358743_log_status()
1150 v4l2_info(sd, "No video detected\n"); in tc358743_log_status()
1152 v4l2_print_dv_timings(sd->name, "Detected format: ", &timings, in tc358743_log_status()
1155 v4l2_print_dv_timings(sd->name, "Configured format: ", &state->timings, in tc358743_log_status()
1158 v4l2_info(sd, "-----CSI-TX status-----\n"); in tc358743_log_status()
1159 v4l2_info(sd, "Lanes needed: %d\n", in tc358743_log_status()
1160 tc358743_num_csi_lanes_needed(sd)); in tc358743_log_status()
1161 v4l2_info(sd, "Lanes in use: %d\n", in tc358743_log_status()
1162 tc358743_num_csi_lanes_in_use(sd)); in tc358743_log_status()
1163 v4l2_info(sd, "Waiting for particular sync signal: %s\n", in tc358743_log_status()
1164 (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ? in tc358743_log_status()
1166 v4l2_info(sd, "Transmit mode: %s\n", in tc358743_log_status()
1167 (i2c_rd16(sd, CSI_STATUS) & MASK_S_TXACT) ? in tc358743_log_status()
1169 v4l2_info(sd, "Receive mode: %s\n", in tc358743_log_status()
1170 (i2c_rd16(sd, CSI_STATUS) & MASK_S_RXACT) ? in tc358743_log_status()
1172 v4l2_info(sd, "Stopped: %s\n", in tc358743_log_status()
1173 (i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT) ? in tc358743_log_status()
1175 v4l2_info(sd, "Color space: %s\n", in tc358743_log_status()
1181 v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D"); in tc358743_log_status()
1182 v4l2_info(sd, "HDCP encrypted content: %s\n", in tc358743_log_status()
1184 v4l2_info(sd, "Input color space: %s %s range\n", in tc358743_log_status()
1187 if (!is_hdmi(sd)) in tc358743_log_status()
1189 v4l2_info(sd, "AV Mute: %s\n", hdmi_sys_status & MASK_S_AVMUTE ? "on" : in tc358743_log_status()
1191 v4l2_info(sd, "Deep color mode: %d-bits per channel\n", in tc358743_log_status()
1192 deep_color_mode[(i2c_rd8(sd, VI_STATUS1) & in tc358743_log_status()
1194 print_avi_infoframe(sd); in tc358743_log_status()
1200 static void tc358743_print_register_map(struct v4l2_subdev *sd) in tc358743_print_register_map() argument
1202 v4l2_info(sd, "0x0000–0x00FF: Global Control Register\n"); in tc358743_print_register_map()
1203 v4l2_info(sd, "0x0100–0x01FF: CSI2-TX PHY Register\n"); in tc358743_print_register_map()
1204 v4l2_info(sd, "0x0200–0x03FF: CSI2-TX PPI Register\n"); in tc358743_print_register_map()
1205 v4l2_info(sd, "0x0400–0x05FF: Reserved\n"); in tc358743_print_register_map()
1206 v4l2_info(sd, "0x0600–0x06FF: CEC Register\n"); in tc358743_print_register_map()
1207 v4l2_info(sd, "0x0700–0x84FF: Reserved\n"); in tc358743_print_register_map()
1208 v4l2_info(sd, "0x8500–0x85FF: HDMIRX System Control Register\n"); in tc358743_print_register_map()
1209 v4l2_info(sd, "0x8600–0x86FF: HDMIRX Audio Control Register\n"); in tc358743_print_register_map()
1210 v4l2_info(sd, "0x8700–0x87FF: HDMIRX InfoFrame packet data Register\n"); in tc358743_print_register_map()
1211 v4l2_info(sd, "0x8800–0x88FF: HDMIRX HDCP Port Register\n"); in tc358743_print_register_map()
1212 v4l2_info(sd, "0x8900–0x89FF: HDMIRX Video Output Port & 3D Register\n"); in tc358743_print_register_map()
1213 v4l2_info(sd, "0x8A00–0x8BFF: Reserved\n"); in tc358743_print_register_map()
1214 v4l2_info(sd, "0x8C00–0x8FFF: HDMIRX EDID-RAM (1024bytes)\n"); in tc358743_print_register_map()
1215 v4l2_info(sd, "0x9000–0x90FF: HDMIRX GBD Extraction Control\n"); in tc358743_print_register_map()
1216 v4l2_info(sd, "0x9100–0x92FF: HDMIRX GBD RAM read\n"); in tc358743_print_register_map()
1217 v4l2_info(sd, "0x9300- : Reserved\n"); in tc358743_print_register_map()
1233 static int tc358743_g_register(struct v4l2_subdev *sd, in tc358743_g_register() argument
1237 tc358743_print_register_map(sd); in tc358743_g_register()
1243 i2c_rd(sd, reg->reg, (u8 *)&reg->val, reg->size); in tc358743_g_register()
1248 static int tc358743_s_register(struct v4l2_subdev *sd, in tc358743_s_register() argument
1252 tc358743_print_register_map(sd); in tc358743_s_register()
1269 i2c_wr(sd, (u16)reg->reg, (u8 *)&reg->val, in tc358743_s_register()
1276 static int tc358743_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in tc358743_isr() argument
1278 u16 intstatus = i2c_rd16(sd, INTSTATUS); in tc358743_isr()
1280 v4l2_dbg(1, debug, sd, "%s: IntStatus = 0x%04x\n", __func__, intstatus); in tc358743_isr()
1283 u8 hdmi_int0 = i2c_rd8(sd, HDMI_INT0); in tc358743_isr()
1284 u8 hdmi_int1 = i2c_rd8(sd, HDMI_INT1); in tc358743_isr()
1287 tc358743_hdmi_misc_int_handler(sd, handled); in tc358743_isr()
1289 tc358743_hdmi_cbit_int_handler(sd, handled); in tc358743_isr()
1291 tc358743_hdmi_clk_int_handler(sd, handled); in tc358743_isr()
1293 tc358743_hdmi_sys_int_handler(sd, handled); in tc358743_isr()
1295 tc358743_hdmi_audio_int_handler(sd, handled); in tc358743_isr()
1297 i2c_wr16(sd, INTSTATUS, MASK_HDMI_INT); in tc358743_isr()
1302 u32 csi_int = i2c_rd32(sd, CSI_INT); in tc358743_isr()
1305 tc358743_csi_err_int_handler(sd, handled); in tc358743_isr()
1307 i2c_wr16(sd, INTSTATUS, MASK_CSI_INT); in tc358743_isr()
1311 intstatus = i2c_rd16(sd, INTSTATUS); in tc358743_isr()
1313 v4l2_dbg(1, debug, sd, in tc358743_isr()
1326 tc358743_isr(&state->sd, 0, &handled); in tc358743_irq_handler()
1331 static int tc358743_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, in tc358743_subscribe_event() argument
1336 return v4l2_src_change_event_subdev_subscribe(sd, fh, sub); in tc358743_subscribe_event()
1338 return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub); in tc358743_subscribe_event()
1346 static int tc358743_g_input_status(struct v4l2_subdev *sd, u32 *status) in tc358743_g_input_status() argument
1349 *status |= no_signal(sd) ? V4L2_IN_ST_NO_SIGNAL : 0; in tc358743_g_input_status()
1350 *status |= no_sync(sd) ? V4L2_IN_ST_NO_SYNC : 0; in tc358743_g_input_status()
1352 v4l2_dbg(1, debug, sd, "%s: status = 0x%x\n", __func__, *status); in tc358743_g_input_status()
1357 static int tc358743_s_dv_timings(struct v4l2_subdev *sd, in tc358743_s_dv_timings() argument
1360 struct tc358743_state *state = to_state(sd); in tc358743_s_dv_timings()
1366 v4l2_print_dv_timings(sd->name, "tc358743_s_dv_timings: ", in tc358743_s_dv_timings()
1370 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); in tc358743_s_dv_timings()
1376 v4l2_dbg(1, debug, sd, "%s: timings out of range\n", __func__); in tc358743_s_dv_timings()
1382 enable_stream(sd, false); in tc358743_s_dv_timings()
1383 tc358743_set_pll(sd); in tc358743_s_dv_timings()
1384 tc358743_set_csi(sd); in tc358743_s_dv_timings()
1389 static int tc358743_g_dv_timings(struct v4l2_subdev *sd, in tc358743_g_dv_timings() argument
1392 struct tc358743_state *state = to_state(sd); in tc358743_g_dv_timings()
1399 static int tc358743_enum_dv_timings(struct v4l2_subdev *sd, in tc358743_enum_dv_timings() argument
1409 static int tc358743_query_dv_timings(struct v4l2_subdev *sd, in tc358743_query_dv_timings() argument
1414 ret = tc358743_get_detected_timings(sd, timings); in tc358743_query_dv_timings()
1419 v4l2_print_dv_timings(sd->name, "tc358743_query_dv_timings: ", in tc358743_query_dv_timings()
1424 v4l2_dbg(1, debug, sd, "%s: timings out of range\n", __func__); in tc358743_query_dv_timings()
1431 static int tc358743_dv_timings_cap(struct v4l2_subdev *sd, in tc358743_dv_timings_cap() argument
1442 static int tc358743_g_mbus_config(struct v4l2_subdev *sd, in tc358743_g_mbus_config() argument
1450 switch (tc358743_num_csi_lanes_in_use(sd)) { in tc358743_g_mbus_config()
1470 static int tc358743_s_stream(struct v4l2_subdev *sd, int enable) in tc358743_s_stream() argument
1472 enable_stream(sd, enable); in tc358743_s_stream()
1479 static int tc358743_get_fmt(struct v4l2_subdev *sd, in tc358743_get_fmt() argument
1483 struct tc358743_state *state = to_state(sd); in tc358743_get_fmt()
1484 u8 vi_rep = i2c_rd8(sd, VI_REP); in tc358743_get_fmt()
1515 static int tc358743_set_fmt(struct v4l2_subdev *sd, in tc358743_set_fmt() argument
1519 struct tc358743_state *state = to_state(sd); in tc358743_set_fmt()
1522 int ret = tc358743_get_fmt(sd, cfg, format); in tc358743_set_fmt()
1542 enable_stream(sd, false); in tc358743_set_fmt()
1543 tc358743_set_pll(sd); in tc358743_set_fmt()
1544 tc358743_set_csi(sd); in tc358743_set_fmt()
1545 tc358743_set_csi_color_space(sd); in tc358743_set_fmt()
1550 static int tc358743_g_edid(struct v4l2_subdev *sd, in tc358743_g_edid() argument
1553 struct tc358743_state *state = to_state(sd); in tc358743_g_edid()
1573 i2c_rd(sd, EDID_RAM + (edid->start_block * EDID_BLOCK_SIZE), edid->edid, in tc358743_g_edid()
1579 static int tc358743_s_edid(struct v4l2_subdev *sd, in tc358743_s_edid() argument
1582 struct tc358743_state *state = to_state(sd); in tc358743_s_edid()
1585 v4l2_dbg(2, debug, sd, "%s, pad %d, start block %d, blocks %d\n", in tc358743_s_edid()
1599 tc358743_disable_edid(sd); in tc358743_s_edid()
1601 i2c_wr8(sd, EDID_LEN1, edid_len & 0xff); in tc358743_s_edid()
1602 i2c_wr8(sd, EDID_LEN2, edid_len >> 8); in tc358743_s_edid()
1609 i2c_wr(sd, EDID_RAM, edid->edid, edid_len); in tc358743_s_edid()
1613 if (tx_5v_power_present(sd)) in tc358743_s_edid()
1614 tc358743_enable_edid(sd); in tc358743_s_edid()
1820 struct v4l2_subdev *sd; in tc358743_probe() local
1847 sd = &state->sd; in tc358743_probe()
1848 v4l2_i2c_subdev_init(sd, client, &tc358743_ops); in tc358743_probe()
1849 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in tc358743_probe()
1852 if ((i2c_rd16(sd, CHIPID) & MASK_CHIPID) != 0) { in tc358743_probe()
1853 v4l2_info(sd, "not a TC358743 on address 0x%x\n", in tc358743_probe()
1872 sd->ctrl_handler = &state->hdl; in tc358743_probe()
1878 if (tc358743_update_controls(sd)) { in tc358743_probe()
1886 v4l2_err(sd, "Could not create work queue\n"); in tc358743_probe()
1892 err = media_entity_init(&sd->entity, 1, &state->pad, 0); in tc358743_probe()
1896 sd->dev = &client->dev; in tc358743_probe()
1897 err = v4l2_async_register_subdev(sd); in tc358743_probe()
1906 tc358743_initial_setup(sd); in tc358743_probe()
1908 tc358743_s_dv_timings(sd, &default_timing); in tc358743_probe()
1911 tc358743_set_csi_color_space(sd); in tc358743_probe()
1913 tc358743_init_interrupts(sd); in tc358743_probe()
1925 tc358743_enable_interrupts(sd, tx_5v_power_present(sd)); in tc358743_probe()
1926 i2c_wr16(sd, INTMASK, ~(MASK_HDMI_MSK | MASK_CSI_MSK) & 0xffff); in tc358743_probe()
1928 err = v4l2_ctrl_handler_setup(sd->ctrl_handler); in tc358743_probe()
1932 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in tc358743_probe()
1942 media_entity_cleanup(&sd->entity); in tc358743_probe()
1949 struct v4l2_subdev *sd = i2c_get_clientdata(client); in tc358743_remove() local
1950 struct tc358743_state *state = to_state(sd); in tc358743_remove()
1954 v4l2_async_unregister_subdev(sd); in tc358743_remove()
1955 v4l2_device_unregister_subdev(sd); in tc358743_remove()
1957 media_entity_cleanup(&sd->entity); in tc358743_remove()