Lines Matching full:sd
192 struct v4l2_subdev sd; member
228 static void tc35874x_enable_interrupts(struct v4l2_subdev *sd,
230 static int tc35874x_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd);
231 static int tc35874x_s_dv_timings(struct v4l2_subdev *sd,
234 static inline struct tc35874x_state *to_state(struct v4l2_subdev *sd) in to_state() argument
236 return container_of(sd, struct tc35874x_state, sd); in to_state()
241 static void i2c_rd(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) in i2c_rd() argument
243 struct tc35874x_state *state = to_state(sd); in i2c_rd()
264 v4l2_err(sd, "%s: reading register 0x%x from 0x%x failed\n", in i2c_rd()
269 static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) in i2c_wr() argument
271 struct tc35874x_state *state = to_state(sd); in i2c_wr()
279 v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n", in i2c_wr()
296 v4l2_err(sd, "%s: writing register 0x%x from 0x%x failed\n", in i2c_wr()
306 v4l2_info(sd, "I2C write 0x%04x = 0x%02x\n", in i2c_wr()
310 v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x\n", in i2c_wr()
314 v4l2_info(sd, "I2C write 0x%04x = 0x%02x%02x%02x%02x\n", in i2c_wr()
318 v4l2_info(sd, "I2C write %d bytes from address 0x%04x\n", in i2c_wr()
323 static noinline u32 i2c_rdreg(struct v4l2_subdev *sd, u16 reg, u32 n) in i2c_rdreg() argument
327 i2c_rd(sd, reg, (u8 __force *)&val, n); in i2c_rdreg()
332 static noinline void i2c_wrreg(struct v4l2_subdev *sd, u16 reg, u32 val, u32 n) in i2c_wrreg() argument
336 i2c_wr(sd, reg, (u8 __force *)&raw, n); in i2c_wrreg()
339 static u8 i2c_rd8(struct v4l2_subdev *sd, u16 reg) in i2c_rd8() argument
341 return i2c_rdreg(sd, reg, 1); in i2c_rd8()
344 static void i2c_wr8(struct v4l2_subdev *sd, u16 reg, u8 val) in i2c_wr8() argument
346 i2c_wrreg(sd, reg, val, 1); in i2c_wr8()
349 static void i2c_wr8_and_or(struct v4l2_subdev *sd, u16 reg, in i2c_wr8_and_or() argument
352 i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 1) & mask) | val, 1); in i2c_wr8_and_or()
355 static u16 i2c_rd16(struct v4l2_subdev *sd, u16 reg) in i2c_rd16() argument
357 return i2c_rdreg(sd, reg, 2); in i2c_rd16()
360 static void i2c_wr16(struct v4l2_subdev *sd, u16 reg, u16 val) in i2c_wr16() argument
362 i2c_wrreg(sd, reg, val, 2); in i2c_wr16()
365 static void i2c_wr16_and_or(struct v4l2_subdev *sd, u16 reg, u16 mask, u16 val) in i2c_wr16_and_or() argument
367 i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 2) & mask) | val, 2); in i2c_wr16_and_or()
370 static u32 i2c_rd32(struct v4l2_subdev *sd, u16 reg) in i2c_rd32() argument
372 return i2c_rdreg(sd, reg, 4); in i2c_rd32()
375 static void i2c_wr32(struct v4l2_subdev *sd, u16 reg, u32 val) in i2c_wr32() argument
377 i2c_wrreg(sd, reg, val, 4); in i2c_wr32()
382 static inline bool is_hdmi(struct v4l2_subdev *sd) in is_hdmi() argument
384 return i2c_rd8(sd, SYS_STATUS) & MASK_S_HDMI; in is_hdmi()
387 static inline bool tx_5v_power_present(struct v4l2_subdev *sd) in tx_5v_power_present() argument
389 return i2c_rd8(sd, SYS_STATUS) & MASK_S_DDC5V; in tx_5v_power_present()
392 static inline bool no_signal(struct v4l2_subdev *sd) in no_signal() argument
394 return !(i2c_rd8(sd, SYS_STATUS) & MASK_S_TMDS); in no_signal()
397 static inline bool no_sync(struct v4l2_subdev *sd) in no_sync() argument
399 return !(i2c_rd8(sd, SYS_STATUS) & MASK_S_SYNC); in no_sync()
402 static inline bool audio_present(struct v4l2_subdev *sd) in audio_present() argument
404 return i2c_rd8(sd, AU_STATUS0) & MASK_S_A_SAMPLE; in audio_present()
407 static int get_audio_sampling_rate(struct v4l2_subdev *sd) in get_audio_sampling_rate() argument
415 if (no_signal(sd)) in get_audio_sampling_rate()
418 return code_to_rate[i2c_rd8(sd, FS_SET) & MASK_FS]; in get_audio_sampling_rate()
432 static int tc35874x_get_detected_timings(struct v4l2_subdev *sd, in tc35874x_get_detected_timings() argument
437 struct tc35874x_state *state = to_state(sd); in tc35874x_get_detected_timings()
442 if (no_signal(sd)) { in tc35874x_get_detected_timings()
443 v4l2_dbg(1, debug, sd, "%s: no valid signal\n", __func__); in tc35874x_get_detected_timings()
446 if (no_sync(sd)) { in tc35874x_get_detected_timings()
447 v4l2_dbg(1, debug, sd, "%s: no sync on signal\n", __func__); in tc35874x_get_detected_timings()
452 bt->interlaced = i2c_rd8(sd, VI_STATUS1) & MASK_S_V_INTERLACE ? in tc35874x_get_detected_timings()
455 width = ((i2c_rd8(sd, DE_WIDTH_H_HI) & 0x1f) << 8) + in tc35874x_get_detected_timings()
456 i2c_rd8(sd, DE_WIDTH_H_LO); in tc35874x_get_detected_timings()
457 height = ((i2c_rd8(sd, DE_WIDTH_V_HI) & 0x1f) << 8) + in tc35874x_get_detected_timings()
458 i2c_rd8(sd, DE_WIDTH_V_LO); in tc35874x_get_detected_timings()
459 frame_width = ((i2c_rd8(sd, H_SIZE_HI) & 0x1f) << 8) + in tc35874x_get_detected_timings()
460 i2c_rd8(sd, H_SIZE_LO); in tc35874x_get_detected_timings()
461 frame_height = (((i2c_rd8(sd, V_SIZE_HI) & 0x3f) << 8) + in tc35874x_get_detected_timings()
462 i2c_rd8(sd, V_SIZE_LO)) / 2; in tc35874x_get_detected_timings()
465 frame_interval = ((i2c_rd8(sd, FV_CNT_HI) & 0x3) << 8) + in tc35874x_get_detected_timings()
466 i2c_rd8(sd, FV_CNT_LO); in tc35874x_get_detected_timings()
481 i2c_wr16(sd, FCCTL, 0x0002); in tc35874x_get_detected_timings()
483 i2c_wr16(sd, PACKETID1, 0x1e1e); in tc35874x_get_detected_timings()
485 i2c_wr16(sd, FCCTL, 0); in tc35874x_get_detected_timings()
502 v4l2_dbg(2, debug, sd, "%s interlaced:%d, fifo_level:%d\n", in tc35874x_get_detected_timings()
504 i2c_wr16(sd, FIFOCTL, fifo_level); in tc35874x_get_detected_timings()
517 struct v4l2_subdev *sd = &state->sd; in tc35874x_delayed_work_enable_hotplug() local
519 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc35874x_delayed_work_enable_hotplug()
521 i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, MASK_HPD_OUT0); in tc35874x_delayed_work_enable_hotplug()
524 static void tc35874x_set_hdmi_hdcp(struct v4l2_subdev *sd, bool enable) in tc35874x_set_hdmi_hdcp() argument
526 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? in tc35874x_set_hdmi_hdcp()
530 i2c_wr8_and_or(sd, HDCP_REG3, ~KEY_RD_CMD, KEY_RD_CMD); in tc35874x_set_hdmi_hdcp()
532 i2c_wr8_and_or(sd, HDCP_MODE, ~MASK_MANUAL_AUTHENTICATION, 0); in tc35874x_set_hdmi_hdcp()
534 i2c_wr8_and_or(sd, HDCP_REG1, 0xff, in tc35874x_set_hdmi_hdcp()
538 i2c_wr8_and_or(sd, HDCP_REG2, ~MASK_AUTO_P3_RESET, in tc35874x_set_hdmi_hdcp()
541 i2c_wr8_and_or(sd, HDCP_MODE, ~MASK_MANUAL_AUTHENTICATION, in tc35874x_set_hdmi_hdcp()
546 static void tc35874x_disable_edid(struct v4l2_subdev *sd) in tc35874x_disable_edid() argument
548 struct tc35874x_state *state = to_state(sd); in tc35874x_disable_edid()
550 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc35874x_disable_edid()
556 i2c_wr8_and_or(sd, HPD_CTL, ~MASK_HPD_OUT0, 0x0); in tc35874x_disable_edid()
559 static void tc35874x_enable_edid(struct v4l2_subdev *sd) in tc35874x_enable_edid() argument
561 struct tc35874x_state *state = to_state(sd); in tc35874x_enable_edid()
564 v4l2_dbg(2, debug, sd, "%s: no EDID -> no hotplug\n", __func__); in tc35874x_enable_edid()
565 tc35874x_s_ctrl_detect_tx_5v(sd); in tc35874x_enable_edid()
569 v4l2_dbg(2, debug, sd, "%s:\n", __func__); in tc35874x_enable_edid()
575 tc35874x_enable_interrupts(sd, true); in tc35874x_enable_edid()
576 tc35874x_s_ctrl_detect_tx_5v(sd); in tc35874x_enable_edid()
579 static void tc35874x_erase_bksv(struct v4l2_subdev *sd) in tc35874x_erase_bksv() argument
584 i2c_wr8(sd, BKSV + i, 0); in tc35874x_erase_bksv()
589 static void print_avi_infoframe(struct v4l2_subdev *sd) in print_avi_infoframe() argument
591 struct i2c_client *client = v4l2_get_subdevdata(sd); in print_avi_infoframe()
596 if (!is_hdmi(sd)) { in print_avi_infoframe()
597 v4l2_info(sd, "DVI-D signal - AVI infoframe not supported\n"); in print_avi_infoframe()
601 i2c_rd(sd, PK_AVI_0HEAD, buffer, HDMI_INFOFRAME_SIZE(AVI)); in print_avi_infoframe()
604 v4l2_err(sd, "%s: unpack of AVI infoframe failed\n", __func__); in print_avi_infoframe()
613 static int tc35874x_s_ctrl_detect_tx_5v(struct v4l2_subdev *sd) in tc35874x_s_ctrl_detect_tx_5v() argument
615 struct tc35874x_state *state = to_state(sd); in tc35874x_s_ctrl_detect_tx_5v()
618 tx_5v_power_present(sd)); in tc35874x_s_ctrl_detect_tx_5v()
621 static int tc35874x_s_ctrl_audio_sampling_rate(struct v4l2_subdev *sd) in tc35874x_s_ctrl_audio_sampling_rate() argument
623 struct tc35874x_state *state = to_state(sd); in tc35874x_s_ctrl_audio_sampling_rate()
626 get_audio_sampling_rate(sd)); in tc35874x_s_ctrl_audio_sampling_rate()
629 static int tc35874x_s_ctrl_audio_present(struct v4l2_subdev *sd) in tc35874x_s_ctrl_audio_present() argument
631 struct tc35874x_state *state = to_state(sd); in tc35874x_s_ctrl_audio_present()
634 audio_present(sd)); in tc35874x_s_ctrl_audio_present()
637 static int tc35874x_update_controls(struct v4l2_subdev *sd) in tc35874x_update_controls() argument
641 ret |= tc35874x_s_ctrl_detect_tx_5v(sd); in tc35874x_update_controls()
642 ret |= tc35874x_s_ctrl_audio_sampling_rate(sd); in tc35874x_update_controls()
643 ret |= tc35874x_s_ctrl_audio_present(sd); in tc35874x_update_controls()
650 static void tc35874x_reset_phy(struct v4l2_subdev *sd) in tc35874x_reset_phy() argument
652 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in tc35874x_reset_phy()
654 i2c_wr8_and_or(sd, PHY_RST, ~MASK_RESET_CTRL, 0); in tc35874x_reset_phy()
655 i2c_wr8_and_or(sd, PHY_RST, ~MASK_RESET_CTRL, MASK_RESET_CTRL); in tc35874x_reset_phy()
658 static void tc35874x_reset(struct v4l2_subdev *sd, uint16_t mask) in tc35874x_reset() argument
660 u16 sysctl = i2c_rd16(sd, SYSCTL); in tc35874x_reset()
662 i2c_wr16(sd, SYSCTL, sysctl | mask); in tc35874x_reset()
663 i2c_wr16(sd, SYSCTL, sysctl & ~mask); in tc35874x_reset()
666 static inline void tc35874x_sleep_mode(struct v4l2_subdev *sd, bool enable) in tc35874x_sleep_mode() argument
668 i2c_wr16_and_or(sd, SYSCTL, ~MASK_SLEEP, in tc35874x_sleep_mode()
672 static inline void enable_stream(struct v4l2_subdev *sd, bool enable) in enable_stream() argument
674 struct tc35874x_state *state = to_state(sd); in enable_stream()
676 v4l2_dbg(3, debug, sd, "%s: %sable\n", in enable_stream()
683 i2c_wr32(sd, TXOPTIONCNTRL, 0); in enable_stream()
685 i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE); in enable_stream()
687 i2c_wr8(sd, VI_MUTE, MASK_AUTO_MUTE); in enable_stream()
691 i2c_wr8(sd, VI_MUTE, MASK_AUTO_MUTE | MASK_VI_MUTE); in enable_stream()
693 i2c_wr32(sd, TXOPTIONCNTRL, 0); in enable_stream()
697 i2c_wr16_and_or(sd, CONFCTL, ~(MASK_VBUFEN | MASK_ABUFEN), in enable_stream()
702 static void tc35874x_set_pll(struct v4l2_subdev *sd) in tc35874x_set_pll() argument
704 struct tc35874x_state *state = to_state(sd); in tc35874x_set_pll()
706 u16 pllctl0 = i2c_rd16(sd, PLLCTL0); in tc35874x_set_pll()
707 u16 pllctl1 = i2c_rd16(sd, PLLCTL1); in tc35874x_set_pll()
740 v4l2_dbg(1, debug, sd, in tc35874x_set_pll()
750 v4l2_dbg(1, debug, sd, "%s: updating PLL clock\n", __func__); in tc35874x_set_pll()
751 tc35874x_sleep_mode(sd, true); in tc35874x_set_pll()
752 i2c_wr16(sd, PLLCTL0, pllctl0_new); in tc35874x_set_pll()
753 i2c_wr16_and_or(sd, PLLCTL1, in tc35874x_set_pll()
758 i2c_wr16_and_or(sd, PLLCTL1, ~MASK_CKEN, MASK_CKEN); in tc35874x_set_pll()
759 tc35874x_sleep_mode(sd, false); in tc35874x_set_pll()
763 static void tc35874x_set_ref_clk(struct v4l2_subdev *sd) in tc35874x_set_ref_clk() argument
765 struct tc35874x_state *state = to_state(sd); in tc35874x_set_ref_clk()
777 i2c_wr8(sd, SYS_FREQ0, sys_freq & 0x00ff); in tc35874x_set_ref_clk()
778 i2c_wr8(sd, SYS_FREQ1, (sys_freq & 0xff00) >> 8); in tc35874x_set_ref_clk()
780 i2c_wr8_and_or(sd, PHY_CTL0, ~MASK_PHY_SYSCLK_IND, in tc35874x_set_ref_clk()
785 i2c_wr8(sd, FH_MIN0, fh_min & 0x00ff); in tc35874x_set_ref_clk()
786 i2c_wr8(sd, FH_MIN1, (fh_min & 0xff00) >> 8); in tc35874x_set_ref_clk()
789 i2c_wr8(sd, FH_MAX0, fh_max & 0x00ff); in tc35874x_set_ref_clk()
790 i2c_wr8(sd, FH_MAX1, (fh_max & 0xff00) >> 8); in tc35874x_set_ref_clk()
793 i2c_wr8(sd, LOCKDET_REF0, lockdet_ref & 0x0000ff); in tc35874x_set_ref_clk()
794 i2c_wr8(sd, LOCKDET_REF1, (lockdet_ref & 0x00ff00) >> 8); in tc35874x_set_ref_clk()
795 i2c_wr8(sd, LOCKDET_REF2, (lockdet_ref & 0x0f0000) >> 16); in tc35874x_set_ref_clk()
797 i2c_wr8_and_or(sd, NCO_F0_MOD, ~MASK_NCO_F0_MOD, in tc35874x_set_ref_clk()
802 static void tc35874x_set_csi_color_space(struct v4l2_subdev *sd) in tc35874x_set_csi_color_space() argument
804 struct tc35874x_state *state = to_state(sd); in tc35874x_set_csi_color_space()
808 v4l2_dbg(2, debug, sd, "%s: YCbCr 422 16-bit\n", __func__); in tc35874x_set_csi_color_space()
809 i2c_wr8_and_or(sd, VOUT_SET2, in tc35874x_set_csi_color_space()
812 i2c_wr8_and_or(sd, VI_REP, ~MASK_VOUT_COLOR_SEL & 0xff, in tc35874x_set_csi_color_space()
815 i2c_wr16_and_or(sd, CONFCTL, ~MASK_YCBCRFMT, in tc35874x_set_csi_color_space()
820 v4l2_dbg(2, debug, sd, "%s: RGB 888 24-bit\n", __func__); in tc35874x_set_csi_color_space()
821 i2c_wr8_and_or(sd, VOUT_SET2, in tc35874x_set_csi_color_space()
824 i2c_wr8_and_or(sd, VI_REP, ~MASK_VOUT_COLOR_SEL & 0xff, in tc35874x_set_csi_color_space()
827 i2c_wr16_and_or(sd, CONFCTL, ~MASK_YCBCRFMT, 0); in tc35874x_set_csi_color_space()
831 v4l2_dbg(2, debug, sd, "%s: Unsupported format code 0x%x\n", in tc35874x_set_csi_color_space()
836 static void tc35874x_set_csi(struct v4l2_subdev *sd) in tc35874x_set_csi() argument
838 struct tc35874x_state *state = to_state(sd); in tc35874x_set_csi()
842 v4l2_dbg(3, debug, sd, "%s:\n", __func__); in tc35874x_set_csi()
844 tc35874x_reset(sd, MASK_CTXRST); in tc35874x_set_csi()
847 i2c_wr32(sd, CLW_CNTRL, MASK_CLW_LANEDISABLE); in tc35874x_set_csi()
849 i2c_wr32(sd, D0W_CNTRL, MASK_D0W_LANEDISABLE); in tc35874x_set_csi()
851 i2c_wr32(sd, D1W_CNTRL, MASK_D1W_LANEDISABLE); in tc35874x_set_csi()
853 i2c_wr32(sd, D2W_CNTRL, MASK_D2W_LANEDISABLE); in tc35874x_set_csi()
855 i2c_wr32(sd, D3W_CNTRL, MASK_D3W_LANEDISABLE); in tc35874x_set_csi()
857 v4l2_dbg(1, debug, sd, "%s: interlaced:%d, fps:%d\n", __func__, in tc35874x_set_csi()
884 i2c_wr32(sd, LINEINITCNT, pdata->lineinitcnt); in tc35874x_set_csi()
885 i2c_wr32(sd, LPTXTIMECNT, pdata->lptxtimecnt); in tc35874x_set_csi()
886 i2c_wr32(sd, TCLK_HEADERCNT, pdata->tclk_headercnt); in tc35874x_set_csi()
887 i2c_wr32(sd, TCLK_TRAILCNT, pdata->tclk_trailcnt); in tc35874x_set_csi()
888 i2c_wr32(sd, THS_HEADERCNT, pdata->ths_headercnt); in tc35874x_set_csi()
889 i2c_wr32(sd, TWAKEUP, pdata->twakeup); in tc35874x_set_csi()
890 i2c_wr32(sd, TCLK_POSTCNT, pdata->tclk_postcnt); in tc35874x_set_csi()
891 i2c_wr32(sd, THS_TRAILCNT, pdata->ths_trailcnt); in tc35874x_set_csi()
892 i2c_wr32(sd, HSTXVREGCNT, pdata->hstxvregcnt); in tc35874x_set_csi()
894 i2c_wr32(sd, HSTXVREGEN, in tc35874x_set_csi()
901 i2c_wr32(sd, TXOPTIONCNTRL, (state->bus.flags & in tc35874x_set_csi()
903 i2c_wr32(sd, STARTCNTRL, MASK_START); in tc35874x_set_csi()
904 i2c_wr32(sd, CSI_START, MASK_STRT); in tc35874x_set_csi()
906 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc35874x_set_csi()
914 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc35874x_set_csi()
918 i2c_wr32(sd, CSI_CONFW, MASK_MODE_CLEAR | in tc35874x_set_csi()
921 i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET | in tc35874x_set_csi()
925 static void tc35874x_set_hdmi_phy(struct v4l2_subdev *sd) in tc35874x_set_hdmi_phy() argument
927 struct tc35874x_state *state = to_state(sd); in tc35874x_set_hdmi_phy()
932 i2c_wr8_and_or(sd, PHY_EN, ~MASK_ENABLE_PHY, 0x0); in tc35874x_set_hdmi_phy()
933 i2c_wr8(sd, PHY_CTL1, SET_PHY_AUTO_RST1_US(1600) | in tc35874x_set_hdmi_phy()
935 i2c_wr8_and_or(sd, PHY_CTL2, ~MASK_PHY_AUTO_RSTn, in tc35874x_set_hdmi_phy()
942 i2c_wr8(sd, PHY_BIAS, 0x40); in tc35874x_set_hdmi_phy()
943 i2c_wr8(sd, PHY_CSQ, SET_CSQ_CNT_LEVEL(0x0a)); in tc35874x_set_hdmi_phy()
944 i2c_wr8(sd, AVM_CTL, 45); in tc35874x_set_hdmi_phy()
945 i2c_wr8_and_or(sd, HDMI_DET, ~MASK_HDMI_DET_V, in tc35874x_set_hdmi_phy()
947 i2c_wr8_and_or(sd, HV_RST, ~(MASK_H_PI_RST | MASK_V_PI_RST), in tc35874x_set_hdmi_phy()
952 i2c_wr8_and_or(sd, PHY_EN, ~MASK_ENABLE_PHY, MASK_ENABLE_PHY); in tc35874x_set_hdmi_phy()
955 static void tc35874x_set_hdmi_audio(struct v4l2_subdev *sd) in tc35874x_set_hdmi_audio() argument
957 struct tc35874x_state *state = to_state(sd); in tc35874x_set_hdmi_audio()
960 i2c_wr8(sd, FORCE_MUTE, 0x00); in tc35874x_set_hdmi_audio()
961 i2c_wr8(sd, AUTO_CMD0, MASK_AUTO_MUTE7 | MASK_AUTO_MUTE6 | in tc35874x_set_hdmi_audio()
964 i2c_wr8(sd, AUTO_CMD1, MASK_AUTO_MUTE9); in tc35874x_set_hdmi_audio()
965 i2c_wr8(sd, AUTO_CMD2, MASK_AUTO_PLAY3 | MASK_AUTO_PLAY2); in tc35874x_set_hdmi_audio()
966 i2c_wr8(sd, BUFINIT_START, SET_BUFINIT_START_MS(500)); in tc35874x_set_hdmi_audio()
967 i2c_wr8(sd, FS_MUTE, 0x00); in tc35874x_set_hdmi_audio()
968 i2c_wr8(sd, FS_IMODE, MASK_NLPCM_SMODE | MASK_FS_SMODE); in tc35874x_set_hdmi_audio()
969 i2c_wr8(sd, ACR_MODE, MASK_CTS_MODE); in tc35874x_set_hdmi_audio()
970 i2c_wr8(sd, ACR_MDF0, MASK_ACR_L2MDF_1976_PPM | MASK_ACR_L1MDF_976_PPM); in tc35874x_set_hdmi_audio()
971 i2c_wr8(sd, ACR_MDF1, MASK_ACR_L3MDF_3906_PPM); in tc35874x_set_hdmi_audio()
972 i2c_wr8(sd, SDO_MODE1, MASK_SDO_FMT_I2S); in tc35874x_set_hdmi_audio()
973 i2c_wr8(sd, DIV_MODE, SET_DIV_DLY_MS(100)); in tc35874x_set_hdmi_audio()
976 i2c_wr16_and_or(sd, CONFCTL, 0xffff, MASK_AUDCHNUM_2 | in tc35874x_set_hdmi_audio()
981 static void tc35874x_set_hdmi_info_frame_mode(struct v4l2_subdev *sd) in tc35874x_set_hdmi_info_frame_mode() argument
984 i2c_wr8(sd, PK_INT_MODE, MASK_ISRC2_INT_MODE | MASK_ISRC_INT_MODE | in tc35874x_set_hdmi_info_frame_mode()
988 i2c_wr8(sd, NO_PKT_LIMIT, 0x2c); in tc35874x_set_hdmi_info_frame_mode()
989 i2c_wr8(sd, NO_PKT_CLR, 0x53); in tc35874x_set_hdmi_info_frame_mode()
990 i2c_wr8(sd, ERR_PK_LIMIT, 0x01); in tc35874x_set_hdmi_info_frame_mode()
991 i2c_wr8(sd, NO_PKT_LIMIT2, 0x30); in tc35874x_set_hdmi_info_frame_mode()
992 i2c_wr8(sd, NO_GDB_LIMIT, 0x10); in tc35874x_set_hdmi_info_frame_mode()
995 static void tc35874x_initial_setup(struct v4l2_subdev *sd) in tc35874x_initial_setup() argument
997 struct tc35874x_state *state = to_state(sd); in tc35874x_initial_setup()
1001 i2c_wr16_and_or(sd, SYSCTL, ~(MASK_CECRST | MASK_IRRST | MASK_I2SDIS), in tc35874x_initial_setup()
1004 tc35874x_reset(sd, MASK_CTXRST | MASK_HDMIRST); in tc35874x_initial_setup()
1005 tc35874x_sleep_mode(sd, false); in tc35874x_initial_setup()
1007 i2c_wr16(sd, FIFOCTL, pdata->fifo_level); in tc35874x_initial_setup()
1009 tc35874x_set_ref_clk(sd); in tc35874x_initial_setup()
1011 i2c_wr8_and_or(sd, DDC_CTL, ~MASK_DDC5V_MODE, in tc35874x_initial_setup()
1013 i2c_wr8_and_or(sd, EDID_MODE, ~MASK_EDID_MODE, MASK_EDID_MODE_E_DDC); in tc35874x_initial_setup()
1015 tc35874x_set_hdmi_phy(sd); in tc35874x_initial_setup()
1016 tc35874x_set_hdmi_hdcp(sd, pdata->enable_hdcp); in tc35874x_initial_setup()
1017 tc35874x_set_hdmi_audio(sd); in tc35874x_initial_setup()
1018 tc35874x_set_hdmi_info_frame_mode(sd); in tc35874x_initial_setup()
1021 i2c_wr8_and_or(sd, VI_MODE, ~MASK_RGB_DVI, 0); in tc35874x_initial_setup()
1023 i2c_wr8_and_or(sd, VOUT_SET2, ~MASK_VOUTCOLORMODE, in tc35874x_initial_setup()
1025 i2c_wr8(sd, VOUT_SET3, MASK_VOUT_EXTCNT); in tc35874x_initial_setup()
1030 static void tc35874x_format_change(struct v4l2_subdev *sd) in tc35874x_format_change() argument
1032 struct tc35874x_state *state = to_state(sd); in tc35874x_format_change()
1039 if (tc35874x_get_detected_timings(sd, &timings)) { in tc35874x_format_change()
1040 enable_stream(sd, false); in tc35874x_format_change()
1042 v4l2_dbg(1, debug, sd, "%s: No signal\n", in tc35874x_format_change()
1046 enable_stream(sd, false); in tc35874x_format_change()
1048 tc35874x_s_dv_timings(sd, &timings); in tc35874x_format_change()
1051 v4l2_print_dv_timings(sd->name, in tc35874x_format_change()
1056 if (sd->devnode) in tc35874x_format_change()
1057 v4l2_subdev_notify_event(sd, &tc35874x_ev_fmt); in tc35874x_format_change()
1060 static void tc35874x_init_interrupts(struct v4l2_subdev *sd) in tc35874x_init_interrupts() argument
1066 i2c_wr8(sd, i, 0xff); in tc35874x_init_interrupts()
1068 i2c_wr16(sd, INTSTATUS, 0xffff); in tc35874x_init_interrupts()
1071 static void tc35874x_enable_interrupts(struct v4l2_subdev *sd, in tc35874x_enable_interrupts() argument
1074 v4l2_dbg(2, debug, sd, "%s: cable connected = %d\n", __func__, in tc35874x_enable_interrupts()
1078 i2c_wr8(sd, SYS_INTM, ~(MASK_M_DDC | MASK_M_DVI_DET | in tc35874x_enable_interrupts()
1080 i2c_wr8(sd, CLK_INTM, ~MASK_M_IN_DE_CHG); in tc35874x_enable_interrupts()
1081 i2c_wr8(sd, CBIT_INTM, ~(MASK_M_CBIT_FS | MASK_M_AF_LOCK | in tc35874x_enable_interrupts()
1083 i2c_wr8(sd, AUDIO_INTM, ~MASK_M_BUFINIT_END); in tc35874x_enable_interrupts()
1084 i2c_wr8(sd, MISC_INTM, ~MASK_M_SYNC_CHG); in tc35874x_enable_interrupts()
1086 i2c_wr8(sd, SYS_INTM, ~MASK_M_DDC & 0xff); in tc35874x_enable_interrupts()
1087 i2c_wr8(sd, CLK_INTM, 0xff); in tc35874x_enable_interrupts()
1088 i2c_wr8(sd, CBIT_INTM, 0xff); in tc35874x_enable_interrupts()
1089 i2c_wr8(sd, AUDIO_INTM, 0xff); in tc35874x_enable_interrupts()
1090 i2c_wr8(sd, MISC_INTM, 0xff); in tc35874x_enable_interrupts()
1094 static void tc35874x_hdmi_audio_int_handler(struct v4l2_subdev *sd, in tc35874x_hdmi_audio_int_handler() argument
1097 u8 audio_int_mask = i2c_rd8(sd, AUDIO_INTM); in tc35874x_hdmi_audio_int_handler()
1098 u8 audio_int = i2c_rd8(sd, AUDIO_INT) & ~audio_int_mask; in tc35874x_hdmi_audio_int_handler()
1100 i2c_wr8(sd, AUDIO_INT, audio_int); in tc35874x_hdmi_audio_int_handler()
1102 v4l2_dbg(3, debug, sd, "%s: AUDIO_INT = 0x%02x\n", __func__, audio_int); in tc35874x_hdmi_audio_int_handler()
1104 tc35874x_s_ctrl_audio_sampling_rate(sd); in tc35874x_hdmi_audio_int_handler()
1105 tc35874x_s_ctrl_audio_present(sd); in tc35874x_hdmi_audio_int_handler()
1108 static void tc35874x_csi_err_int_handler(struct v4l2_subdev *sd, bool *handled) in tc35874x_csi_err_int_handler() argument
1110 v4l2_err(sd, "%s: CSI_ERR = 0x%x\n", __func__, i2c_rd32(sd, CSI_ERR)); in tc35874x_csi_err_int_handler()
1112 i2c_wr32(sd, CSI_INT_CLR, MASK_ICRER); in tc35874x_csi_err_int_handler()
1115 static void tc35874x_hdmi_misc_int_handler(struct v4l2_subdev *sd, in tc35874x_hdmi_misc_int_handler() argument
1118 u8 misc_int_mask = i2c_rd8(sd, MISC_INTM); in tc35874x_hdmi_misc_int_handler()
1119 u8 misc_int = i2c_rd8(sd, MISC_INT) & ~misc_int_mask; in tc35874x_hdmi_misc_int_handler()
1121 i2c_wr8(sd, MISC_INT, misc_int); in tc35874x_hdmi_misc_int_handler()
1123 v4l2_dbg(3, debug, sd, "%s: MISC_INT = 0x%02x\n", __func__, misc_int); in tc35874x_hdmi_misc_int_handler()
1129 if (no_sync(sd) || no_signal(sd)) { in tc35874x_hdmi_misc_int_handler()
1130 tc35874x_reset_phy(sd); in tc35874x_hdmi_misc_int_handler()
1131 tc35874x_erase_bksv(sd); in tc35874x_hdmi_misc_int_handler()
1134 tc35874x_format_change(sd); in tc35874x_hdmi_misc_int_handler()
1142 v4l2_err(sd, "%s: Unhandled MISC_INT interrupts: 0x%02x\n", in tc35874x_hdmi_misc_int_handler()
1147 static void tc35874x_hdmi_cbit_int_handler(struct v4l2_subdev *sd, in tc35874x_hdmi_cbit_int_handler() argument
1150 u8 cbit_int_mask = i2c_rd8(sd, CBIT_INTM); in tc35874x_hdmi_cbit_int_handler()
1151 u8 cbit_int = i2c_rd8(sd, CBIT_INT) & ~cbit_int_mask; in tc35874x_hdmi_cbit_int_handler()
1153 i2c_wr8(sd, CBIT_INT, cbit_int); in tc35874x_hdmi_cbit_int_handler()
1155 v4l2_dbg(3, debug, sd, "%s: CBIT_INT = 0x%02x\n", __func__, cbit_int); in tc35874x_hdmi_cbit_int_handler()
1159 v4l2_dbg(1, debug, sd, "%s: Audio sample rate changed\n", in tc35874x_hdmi_cbit_int_handler()
1161 tc35874x_s_ctrl_audio_sampling_rate(sd); in tc35874x_hdmi_cbit_int_handler()
1170 v4l2_dbg(1, debug, sd, "%s: Audio present changed\n", in tc35874x_hdmi_cbit_int_handler()
1172 tc35874x_s_ctrl_audio_present(sd); in tc35874x_hdmi_cbit_int_handler()
1180 v4l2_err(sd, "%s: Unhandled CBIT_INT interrupts: 0x%02x\n", in tc35874x_hdmi_cbit_int_handler()
1185 static void tc35874x_hdmi_clk_int_handler(struct v4l2_subdev *sd, bool *handled) in tc35874x_hdmi_clk_int_handler() argument
1187 u8 clk_int_mask = i2c_rd8(sd, CLK_INTM); in tc35874x_hdmi_clk_int_handler()
1188 u8 clk_int = i2c_rd8(sd, CLK_INT) & ~clk_int_mask; in tc35874x_hdmi_clk_int_handler()
1191 i2c_wr8(sd, CLK_INT, clk_int | 0x80 | MASK_I_OUT_H_CHG); in tc35874x_hdmi_clk_int_handler()
1193 v4l2_dbg(3, debug, sd, "%s: CLK_INT = 0x%02x\n", __func__, clk_int); in tc35874x_hdmi_clk_int_handler()
1197 v4l2_dbg(1, debug, sd, "%s: DE size or position has changed\n", in tc35874x_hdmi_clk_int_handler()
1206 if (!no_signal(sd) && !no_sync(sd)) in tc35874x_hdmi_clk_int_handler()
1207 tc35874x_format_change(sd); in tc35874x_hdmi_clk_int_handler()
1215 v4l2_err(sd, "%s: Unhandled CLK_INT interrupts: 0x%02x\n", in tc35874x_hdmi_clk_int_handler()
1220 static void tc35874x_hdmi_sys_int_handler(struct v4l2_subdev *sd, bool *handled) in tc35874x_hdmi_sys_int_handler() argument
1222 struct tc35874x_state *state = to_state(sd); in tc35874x_hdmi_sys_int_handler()
1223 u8 sys_int_mask = i2c_rd8(sd, SYS_INTM); in tc35874x_hdmi_sys_int_handler()
1224 u8 sys_int = i2c_rd8(sd, SYS_INT) & ~sys_int_mask; in tc35874x_hdmi_sys_int_handler()
1226 i2c_wr8(sd, SYS_INT, sys_int); in tc35874x_hdmi_sys_int_handler()
1228 v4l2_dbg(3, debug, sd, "%s: SYS_INT = 0x%02x\n", __func__, sys_int); in tc35874x_hdmi_sys_int_handler()
1231 bool tx_5v = tx_5v_power_present(sd); in tc35874x_hdmi_sys_int_handler()
1233 v4l2_dbg(1, debug, sd, "%s: Tx 5V power present: %s\n", in tc35874x_hdmi_sys_int_handler()
1237 tc35874x_enable_edid(sd); in tc35874x_hdmi_sys_int_handler()
1239 tc35874x_enable_interrupts(sd, false); in tc35874x_hdmi_sys_int_handler()
1240 tc35874x_disable_edid(sd); in tc35874x_hdmi_sys_int_handler()
1242 tc35874x_erase_bksv(sd); in tc35874x_hdmi_sys_int_handler()
1243 tc35874x_update_controls(sd); in tc35874x_hdmi_sys_int_handler()
1252 v4l2_dbg(1, debug, sd, "%s: HDMI->DVI change detected\n", in tc35874x_hdmi_sys_int_handler()
1258 if (no_sync(sd) || no_signal(sd)) { in tc35874x_hdmi_sys_int_handler()
1259 tc35874x_reset_phy(sd); in tc35874x_hdmi_sys_int_handler()
1260 tc35874x_erase_bksv(sd); in tc35874x_hdmi_sys_int_handler()
1269 v4l2_dbg(1, debug, sd, "%s: DVI->HDMI change detected\n", in tc35874x_hdmi_sys_int_handler()
1273 i2c_wr8(sd, ANA_CTL, MASK_APPL_PCSX_NORMAL | MASK_ANALOG_ON); in tc35874x_hdmi_sys_int_handler()
1281 v4l2_err(sd, "%s: Unhandled SYS_INT interrupts: 0x%02x\n", in tc35874x_hdmi_sys_int_handler()
1293 struct v4l2_subdev *sd = &(state->sd); in tc35874x_get_ctrl() local
1296 ret = tx_5v_power_present(sd); in tc35874x_get_ctrl()
1305 static int tc35874x_log_status(struct v4l2_subdev *sd) in tc35874x_log_status() argument
1307 struct tc35874x_state *state = to_state(sd); in tc35874x_log_status()
1309 uint8_t hdmi_sys_status = i2c_rd8(sd, SYS_STATUS); in tc35874x_log_status()
1310 uint16_t sysctl = i2c_rd16(sd, SYSCTL); in tc35874x_log_status()
1311 u8 vi_status3 = i2c_rd8(sd, VI_STATUS3); in tc35874x_log_status()
1318 v4l2_info(sd, "-----Chip status-----\n"); in tc35874x_log_status()
1319 v4l2_info(sd, "Chip ID: 0x%02x\n", in tc35874x_log_status()
1320 (i2c_rd16(sd, CHIPID) & MASK_CHIPID) >> 8); in tc35874x_log_status()
1321 v4l2_info(sd, "Chip revision: 0x%02x\n", in tc35874x_log_status()
1322 i2c_rd16(sd, CHIPID) & MASK_REVID); in tc35874x_log_status()
1323 v4l2_info(sd, "Reset: IR: %d, CEC: %d, CSI TX: %d, HDMI: %d\n", in tc35874x_log_status()
1328 v4l2_info(sd, "Sleep mode: %s\n", sysctl & MASK_SLEEP ? "on" : "off"); in tc35874x_log_status()
1329 v4l2_info(sd, "Cable detected (+5V power): %s\n", in tc35874x_log_status()
1331 v4l2_info(sd, "DDC lines enabled: %s\n", in tc35874x_log_status()
1332 (i2c_rd8(sd, EDID_MODE) & MASK_EDID_MODE_E_DDC) ? in tc35874x_log_status()
1334 v4l2_info(sd, "Hotplug enabled: %s\n", in tc35874x_log_status()
1335 (i2c_rd8(sd, HPD_CTL) & MASK_HPD_OUT0) ? in tc35874x_log_status()
1337 v4l2_info(sd, "CEC enabled: %s\n", in tc35874x_log_status()
1338 (i2c_rd16(sd, CECEN) & MASK_CECEN) ? "yes" : "no"); in tc35874x_log_status()
1339 v4l2_info(sd, "-----Signal status-----\n"); in tc35874x_log_status()
1340 v4l2_info(sd, "TMDS signal detected: %s\n", in tc35874x_log_status()
1342 v4l2_info(sd, "Stable sync signal: %s\n", in tc35874x_log_status()
1344 v4l2_info(sd, "PHY PLL locked: %s\n", in tc35874x_log_status()
1346 v4l2_info(sd, "PHY DE detected: %s\n", in tc35874x_log_status()
1349 if (tc35874x_get_detected_timings(sd, &timings)) { in tc35874x_log_status()
1350 v4l2_info(sd, "No video detected\n"); in tc35874x_log_status()
1352 v4l2_print_dv_timings(sd->name, "Detected format: ", &timings, in tc35874x_log_status()
1355 v4l2_print_dv_timings(sd->name, "Configured format: ", &state->timings, in tc35874x_log_status()
1358 v4l2_info(sd, "-----CSI-TX status-----\n"); in tc35874x_log_status()
1359 v4l2_info(sd, "Lanes in use: %d\n", in tc35874x_log_status()
1361 v4l2_info(sd, "Waiting for particular sync signal: %s\n", in tc35874x_log_status()
1362 (i2c_rd16(sd, CSI_STATUS) & MASK_S_WSYNC) ? in tc35874x_log_status()
1364 v4l2_info(sd, "Transmit mode: %s\n", in tc35874x_log_status()
1365 (i2c_rd16(sd, CSI_STATUS) & MASK_S_TXACT) ? in tc35874x_log_status()
1367 v4l2_info(sd, "Receive mode: %s\n", in tc35874x_log_status()
1368 (i2c_rd16(sd, CSI_STATUS) & MASK_S_RXACT) ? in tc35874x_log_status()
1370 v4l2_info(sd, "Stopped: %s\n", in tc35874x_log_status()
1371 (i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT) ? in tc35874x_log_status()
1373 v4l2_info(sd, "Color space: %s\n", in tc35874x_log_status()
1379 v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D"); in tc35874x_log_status()
1380 v4l2_info(sd, "HDCP encrypted content: %s\n", in tc35874x_log_status()
1382 v4l2_info(sd, "Input color space: %s %s range\n", in tc35874x_log_status()
1385 if (!is_hdmi(sd)) in tc35874x_log_status()
1387 v4l2_info(sd, "AV Mute: %s\n", hdmi_sys_status & MASK_S_AVMUTE ? "on" : in tc35874x_log_status()
1389 v4l2_info(sd, "Deep color mode: %d-bits per channel\n", in tc35874x_log_status()
1390 deep_color_mode[(i2c_rd8(sd, VI_STATUS1) & in tc35874x_log_status()
1392 print_avi_infoframe(sd); in tc35874x_log_status()
1398 static void tc35874x_print_register_map(struct v4l2_subdev *sd) in tc35874x_print_register_map() argument
1400 v4l2_info(sd, "0x0000-0x00FF: Global Control Register\n"); in tc35874x_print_register_map()
1401 v4l2_info(sd, "0x0100-0x01FF: CSI2-TX PHY Register\n"); in tc35874x_print_register_map()
1402 v4l2_info(sd, "0x0200-0x03FF: CSI2-TX PPI Register\n"); in tc35874x_print_register_map()
1403 v4l2_info(sd, "0x0400-0x05FF: Reserved\n"); in tc35874x_print_register_map()
1404 v4l2_info(sd, "0x0600-0x06FF: CEC Register\n"); in tc35874x_print_register_map()
1405 v4l2_info(sd, "0x0700-0x84FF: Reserved\n"); in tc35874x_print_register_map()
1406 v4l2_info(sd, "0x8500-0x85FF: HDMIRX System Control Register\n"); in tc35874x_print_register_map()
1407 v4l2_info(sd, "0x8600-0x86FF: HDMIRX Audio Control Register\n"); in tc35874x_print_register_map()
1408 v4l2_info(sd, "0x8700-0x87FF: HDMIRX InfoFrame packet data Register\n"); in tc35874x_print_register_map()
1409 v4l2_info(sd, "0x8800-0x88FF: HDMIRX HDCP Port Register\n"); in tc35874x_print_register_map()
1410 v4l2_info(sd, "0x8900-0x89FF: HDMIRX Video Output Port & 3D Register\n"); in tc35874x_print_register_map()
1411 v4l2_info(sd, "0x8A00-0x8BFF: Reserved\n"); in tc35874x_print_register_map()
1412 v4l2_info(sd, "0x8C00-0x8FFF: HDMIRX EDID-RAM (1024bytes)\n"); in tc35874x_print_register_map()
1413 v4l2_info(sd, "0x9000-0x90FF: HDMIRX GBD Extraction Control\n"); in tc35874x_print_register_map()
1414 v4l2_info(sd, "0x9100-0x92FF: HDMIRX GBD RAM read\n"); in tc35874x_print_register_map()
1415 v4l2_info(sd, "0x9300- : Reserved\n"); in tc35874x_print_register_map()
1431 static int tc35874x_g_register(struct v4l2_subdev *sd, in tc35874x_g_register() argument
1435 tc35874x_print_register_map(sd); in tc35874x_g_register()
1441 reg->val = i2c_rdreg(sd, reg->reg, reg->size); in tc35874x_g_register()
1446 static int tc35874x_s_register(struct v4l2_subdev *sd, in tc35874x_s_register() argument
1450 tc35874x_print_register_map(sd); in tc35874x_s_register()
1467 i2c_wrreg(sd, (u16)reg->reg, reg->val, in tc35874x_s_register()
1474 static int tc35874x_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in tc35874x_isr() argument
1476 u16 intstatus = i2c_rd16(sd, INTSTATUS); in tc35874x_isr()
1478 v4l2_dbg(1, debug, sd, "%s: IntStatus = 0x%04x\n", __func__, intstatus); in tc35874x_isr()
1481 u8 hdmi_int0 = i2c_rd8(sd, HDMI_INT0); in tc35874x_isr()
1482 u8 hdmi_int1 = i2c_rd8(sd, HDMI_INT1); in tc35874x_isr()
1485 tc35874x_hdmi_misc_int_handler(sd, handled); in tc35874x_isr()
1487 tc35874x_hdmi_cbit_int_handler(sd, handled); in tc35874x_isr()
1489 tc35874x_hdmi_clk_int_handler(sd, handled); in tc35874x_isr()
1491 tc35874x_hdmi_sys_int_handler(sd, handled); in tc35874x_isr()
1493 tc35874x_hdmi_audio_int_handler(sd, handled); in tc35874x_isr()
1495 i2c_wr16(sd, INTSTATUS, MASK_HDMI_INT); in tc35874x_isr()
1500 u32 csi_int = i2c_rd32(sd, CSI_INT); in tc35874x_isr()
1503 tc35874x_csi_err_int_handler(sd, handled); in tc35874x_isr()
1505 i2c_wr16(sd, INTSTATUS, MASK_CSI_INT); in tc35874x_isr()
1508 intstatus = i2c_rd16(sd, INTSTATUS); in tc35874x_isr()
1510 v4l2_dbg(1, debug, sd, in tc35874x_isr()
1523 tc35874x_isr(&state->sd, 0, &handled); in tc35874x_irq_handler()
1549 tc35874x_isr(&state->sd, 0, &handled); in tc35874x_work_i2c_poll()
1552 static int tc35874x_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, in tc35874x_subscribe_event() argument
1557 return v4l2_src_change_event_subdev_subscribe(sd, fh, sub); in tc35874x_subscribe_event()
1559 return v4l2_ctrl_subdev_subscribe_event(sd, fh, sub); in tc35874x_subscribe_event()
1567 static int tc35874x_g_input_status(struct v4l2_subdev *sd, u32 *status) in tc35874x_g_input_status() argument
1570 *status |= no_signal(sd) ? V4L2_IN_ST_NO_SIGNAL : 0; in tc35874x_g_input_status()
1571 *status |= no_sync(sd) ? V4L2_IN_ST_NO_SYNC : 0; in tc35874x_g_input_status()
1573 v4l2_dbg(1, debug, sd, "%s: status = 0x%x\n", __func__, *status); in tc35874x_g_input_status()
1578 static int tc35874x_s_dv_timings(struct v4l2_subdev *sd, in tc35874x_s_dv_timings() argument
1581 struct tc35874x_state *state = to_state(sd); in tc35874x_s_dv_timings()
1587 v4l2_print_dv_timings(sd->name, "tc35874x_s_dv_timings: ", in tc35874x_s_dv_timings()
1591 v4l2_dbg(1, debug, sd, "%s: no change\n", __func__); in tc35874x_s_dv_timings()
1597 v4l2_dbg(1, debug, sd, "%s: timings out of range\n", __func__); in tc35874x_s_dv_timings()
1603 enable_stream(sd, false); in tc35874x_s_dv_timings()
1604 tc35874x_set_pll(sd); in tc35874x_s_dv_timings()
1605 tc35874x_set_csi(sd); in tc35874x_s_dv_timings()
1610 static int tc35874x_g_dv_timings(struct v4l2_subdev *sd, in tc35874x_g_dv_timings() argument
1613 struct tc35874x_state *state = to_state(sd); in tc35874x_g_dv_timings()
1620 static int tc35874x_enum_dv_timings(struct v4l2_subdev *sd, in tc35874x_enum_dv_timings() argument
1630 static int tc35874x_query_dv_timings(struct v4l2_subdev *sd, in tc35874x_query_dv_timings() argument
1635 ret = tc35874x_get_detected_timings(sd, timings); in tc35874x_query_dv_timings()
1640 v4l2_print_dv_timings(sd->name, "tc35874x_query_dv_timings: ", in tc35874x_query_dv_timings()
1645 v4l2_dbg(1, debug, sd, "%s: timings out of range\n", __func__); in tc35874x_query_dv_timings()
1652 static int tc35874x_dv_timings_cap(struct v4l2_subdev *sd, in tc35874x_dv_timings_cap() argument
1663 static int tc35874x_g_mbus_config(struct v4l2_subdev *sd, in tc35874x_g_mbus_config() argument
1666 struct tc35874x_state *state = to_state(sd); in tc35874x_g_mbus_config()
1693 static int tc35874x_s_stream(struct v4l2_subdev *sd, int enable) in tc35874x_s_stream() argument
1695 enable_stream(sd, enable); in tc35874x_s_stream()
1699 tc35874x_set_csi(sd); in tc35874x_s_stream()
1705 static int tc35874x_enum_mbus_code(struct v4l2_subdev *sd, in tc35874x_enum_mbus_code() argument
1724 static int tc35874x_enum_frame_sizes(struct v4l2_subdev *sd, in tc35874x_enum_frame_sizes() argument
1728 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in tc35874x_enum_frame_sizes()
1744 static int tc35874x_enum_frame_interval(struct v4l2_subdev *sd, in tc35874x_enum_frame_interval() argument
1759 static int tc35874x_get_fmt(struct v4l2_subdev *sd, in tc35874x_get_fmt() argument
1763 struct tc35874x_state *state = to_state(sd); in tc35874x_get_fmt()
1764 u8 vi_rep = i2c_rd8(sd, VI_REP); in tc35874x_get_fmt()
1821 static int tc35874x_set_fmt(struct v4l2_subdev *sd, in tc35874x_set_fmt() argument
1825 struct tc35874x_state *state = to_state(sd); in tc35874x_set_fmt()
1829 int ret = tc35874x_get_fmt(sd, cfg, format); in tc35874x_set_fmt()
1849 enable_stream(sd, false); in tc35874x_set_fmt()
1858 tc35874x_set_pll(sd); in tc35874x_set_fmt()
1859 tc35874x_set_csi(sd); in tc35874x_set_fmt()
1860 tc35874x_set_csi_color_space(sd); in tc35874x_set_fmt()
1865 static int tc35874x_g_edid(struct v4l2_subdev *sd, in tc35874x_g_edid() argument
1868 struct tc35874x_state *state = to_state(sd); in tc35874x_g_edid()
1890 i2c_rd(sd, EDID_RAM + (edid->start_block * EDID_BLOCK_SIZE), edid->edid, in tc35874x_g_edid()
1896 static int tc35874x_s_edid(struct v4l2_subdev *sd, in tc35874x_s_edid() argument
1899 struct tc35874x_state *state = to_state(sd); in tc35874x_s_edid()
1903 v4l2_dbg(2, debug, sd, "%s, pad %d, start block %d, blocks %d\n", in tc35874x_s_edid()
1919 tc35874x_disable_edid(sd); in tc35874x_s_edid()
1921 i2c_wr8(sd, EDID_LEN1, edid_len & 0xff); in tc35874x_s_edid()
1922 i2c_wr8(sd, EDID_LEN2, edid_len >> 8); in tc35874x_s_edid()
1930 i2c_wr(sd, EDID_RAM + i, edid->edid + i, EDID_BLOCK_SIZE); in tc35874x_s_edid()
1931 i2c_wr(sd, EDID_EXT_RAM + i, EDID_extend + i, EDID_BLOCK_SIZE); in tc35874x_s_edid()
1936 if (tx_5v_power_present(sd)) in tc35874x_s_edid()
1937 tc35874x_enable_edid(sd); in tc35874x_s_edid()
1942 static int tc35874x_g_frame_interval(struct v4l2_subdev *sd, in tc35874x_g_frame_interval() argument
1945 struct tc35874x_state *state = to_state(sd); in tc35874x_g_frame_interval()
1965 static long tc35874x_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) in tc35874x_ioctl() argument
1967 struct tc35874x_state *tc35874x = to_state(sd); in tc35874x_ioctl()
1983 static long tc35874x_compat_ioctl32(struct v4l2_subdev *sd, in tc35874x_compat_ioctl32() argument
1999 ret = tc35874x_ioctl(sd, cmd, inf); in tc35874x_compat_ioctl32()
2016 ret = tc35874x_ioctl(sd, cmd, cfg); in tc35874x_compat_ioctl32()
2085 struct v4l2_subdev *sd = &state->sd; in tc35874x_get_custom_ctrl() local
2088 ret = get_audio_sampling_rate(sd); in tc35874x_get_custom_ctrl()
2269 struct v4l2_subdev *sd; in tc35874x_probe() local
2319 sd = &state->sd; in tc35874x_probe()
2320 v4l2_i2c_subdev_init(sd, client, &tc35874x_ops); in tc35874x_probe()
2321 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in tc35874x_probe()
2324 data = i2c_rd16(sd, CHIPID) & MASK_CHIPID; in tc35874x_probe()
2330 v4l2_info(sd, "not a tc35874x on address 0x%x\n", in tc35874x_probe()
2362 sd->ctrl_handler = &state->hdl; in tc35874x_probe()
2368 if (tc35874x_update_controls(sd)) { in tc35874x_probe()
2374 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in tc35874x_probe()
2375 err = media_entity_pads_init(&sd->entity, 1, &state->pad); in tc35874x_probe()
2381 sd->dev = &client->dev; in tc35874x_probe()
2388 snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", in tc35874x_probe()
2390 TC35874X_NAME, dev_name(sd->dev)); in tc35874x_probe()
2391 err = v4l2_async_register_subdev(sd); in tc35874x_probe()
2400 tc35874x_initial_setup(sd); in tc35874x_probe()
2402 tc35874x_s_dv_timings(sd, &default_timing); in tc35874x_probe()
2404 tc35874x_set_csi_color_space(sd); in tc35874x_probe()
2411 tc35874x_s_edid(sd, &def_edid); in tc35874x_probe()
2413 tc35874x_init_interrupts(sd); in tc35874x_probe()
2432 tc35874x_enable_interrupts(sd, tx_5v_power_present(sd)); in tc35874x_probe()
2433 i2c_wr16(sd, INTMASK, ~(MASK_HDMI_MSK | MASK_CSI_MSK) & 0xffff); in tc35874x_probe()
2435 err = v4l2_ctrl_handler_setup(sd->ctrl_handler); in tc35874x_probe()
2439 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in tc35874x_probe()
2450 media_entity_cleanup(&sd->entity); in tc35874x_probe()
2457 struct v4l2_subdev *sd = i2c_get_clientdata(client); in tc35874x_remove() local
2458 struct tc35874x_state *state = to_state(sd); in tc35874x_remove()
2465 v4l2_async_unregister_subdev(sd); in tc35874x_remove()
2466 v4l2_device_unregister_subdev(sd); in tc35874x_remove()
2468 media_entity_cleanup(&sd->entity); in tc35874x_remove()