• Home
  • Raw
  • Download

Lines Matching refs:sd

69 	struct v4l2_subdev sd;  member
92 static void ad9389b_check_monitor_present_status(struct v4l2_subdev *sd);
93 static bool ad9389b_check_edid_status(struct v4l2_subdev *sd);
94 static void ad9389b_setup(struct v4l2_subdev *sd);
95 static int ad9389b_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq);
96 static int ad9389b_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
98 static inline struct ad9389b_state *get_ad9389b_state(struct v4l2_subdev *sd) in get_ad9389b_state() argument
100 return container_of(sd, struct ad9389b_state, sd); in get_ad9389b_state()
105 return &container_of(ctrl->handler, struct ad9389b_state, hdl)->sd; in to_sd()
110 static int ad9389b_rd(struct v4l2_subdev *sd, u8 reg) in ad9389b_rd() argument
112 struct i2c_client *client = v4l2_get_subdevdata(sd); in ad9389b_rd()
117 static int ad9389b_wr(struct v4l2_subdev *sd, u8 reg, u8 val) in ad9389b_wr() argument
119 struct i2c_client *client = v4l2_get_subdevdata(sd); in ad9389b_wr()
128 v4l2_err(sd, "%s: failed reg 0x%x, val 0x%x\n", __func__, reg, val); in ad9389b_wr()
134 static inline void ad9389b_wr_and_or(struct v4l2_subdev *sd, u8 reg, in ad9389b_wr_and_or() argument
137 ad9389b_wr(sd, reg, (ad9389b_rd(sd, reg) & clr_mask) | val_mask); in ad9389b_wr_and_or()
140 static void ad9389b_edid_rd(struct v4l2_subdev *sd, u16 len, u8 *buf) in ad9389b_edid_rd() argument
142 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_edid_rd()
145 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in ad9389b_edid_rd()
151 static inline bool ad9389b_have_hotplug(struct v4l2_subdev *sd) in ad9389b_have_hotplug() argument
153 return ad9389b_rd(sd, 0x42) & MASK_AD9389B_HPD_DETECT; in ad9389b_have_hotplug()
156 static inline bool ad9389b_have_rx_sense(struct v4l2_subdev *sd) in ad9389b_have_rx_sense() argument
158 return ad9389b_rd(sd, 0x42) & MASK_AD9389B_MSEN_DETECT; in ad9389b_have_rx_sense()
161 static void ad9389b_csc_conversion_mode(struct v4l2_subdev *sd, u8 mode) in ad9389b_csc_conversion_mode() argument
163 ad9389b_wr_and_or(sd, 0x17, 0xe7, (mode & 0x3)<<3); in ad9389b_csc_conversion_mode()
164 ad9389b_wr_and_or(sd, 0x18, 0x9f, (mode & 0x3)<<5); in ad9389b_csc_conversion_mode()
167 static void ad9389b_csc_coeff(struct v4l2_subdev *sd, in ad9389b_csc_coeff() argument
173 ad9389b_wr_and_or(sd, 0x18, 0xe0, A1>>8); in ad9389b_csc_coeff()
174 ad9389b_wr(sd, 0x19, A1); in ad9389b_csc_coeff()
175 ad9389b_wr_and_or(sd, 0x1A, 0xe0, A2>>8); in ad9389b_csc_coeff()
176 ad9389b_wr(sd, 0x1B, A2); in ad9389b_csc_coeff()
177 ad9389b_wr_and_or(sd, 0x1c, 0xe0, A3>>8); in ad9389b_csc_coeff()
178 ad9389b_wr(sd, 0x1d, A3); in ad9389b_csc_coeff()
179 ad9389b_wr_and_or(sd, 0x1e, 0xe0, A4>>8); in ad9389b_csc_coeff()
180 ad9389b_wr(sd, 0x1f, A4); in ad9389b_csc_coeff()
183 ad9389b_wr_and_or(sd, 0x20, 0xe0, B1>>8); in ad9389b_csc_coeff()
184 ad9389b_wr(sd, 0x21, B1); in ad9389b_csc_coeff()
185 ad9389b_wr_and_or(sd, 0x22, 0xe0, B2>>8); in ad9389b_csc_coeff()
186 ad9389b_wr(sd, 0x23, B2); in ad9389b_csc_coeff()
187 ad9389b_wr_and_or(sd, 0x24, 0xe0, B3>>8); in ad9389b_csc_coeff()
188 ad9389b_wr(sd, 0x25, B3); in ad9389b_csc_coeff()
189 ad9389b_wr_and_or(sd, 0x26, 0xe0, B4>>8); in ad9389b_csc_coeff()
190 ad9389b_wr(sd, 0x27, B4); in ad9389b_csc_coeff()
193 ad9389b_wr_and_or(sd, 0x28, 0xe0, C1>>8); in ad9389b_csc_coeff()
194 ad9389b_wr(sd, 0x29, C1); in ad9389b_csc_coeff()
195 ad9389b_wr_and_or(sd, 0x2A, 0xe0, C2>>8); in ad9389b_csc_coeff()
196 ad9389b_wr(sd, 0x2B, C2); in ad9389b_csc_coeff()
197 ad9389b_wr_and_or(sd, 0x2C, 0xe0, C3>>8); in ad9389b_csc_coeff()
198 ad9389b_wr(sd, 0x2D, C3); in ad9389b_csc_coeff()
199 ad9389b_wr_and_or(sd, 0x2E, 0xe0, C4>>8); in ad9389b_csc_coeff()
200 ad9389b_wr(sd, 0x2F, C4); in ad9389b_csc_coeff()
203 static void ad9389b_csc_rgb_full2limit(struct v4l2_subdev *sd, bool enable) in ad9389b_csc_rgb_full2limit() argument
208 ad9389b_csc_conversion_mode(sd, csc_mode); in ad9389b_csc_rgb_full2limit()
209 ad9389b_csc_coeff(sd, in ad9389b_csc_rgb_full2limit()
214 ad9389b_wr_and_or(sd, 0x3b, 0xfe, 0x1); in ad9389b_csc_rgb_full2limit()
216 ad9389b_wr_and_or(sd, 0xcd, 0xf9, 0x02); in ad9389b_csc_rgb_full2limit()
219 ad9389b_wr_and_or(sd, 0x3b, 0xfe, 0x0); in ad9389b_csc_rgb_full2limit()
221 ad9389b_wr_and_or(sd, 0xcd, 0xf9, 0x04); in ad9389b_csc_rgb_full2limit()
225 static void ad9389b_set_IT_content_AVI_InfoFrame(struct v4l2_subdev *sd) in ad9389b_set_IT_content_AVI_InfoFrame() argument
227 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_set_IT_content_AVI_InfoFrame()
231 ad9389b_wr_and_or(sd, 0xcd, 0xbf, 0x00); in ad9389b_set_IT_content_AVI_InfoFrame()
234 ad9389b_wr_and_or(sd, 0xcd, 0xbf, 0x40); in ad9389b_set_IT_content_AVI_InfoFrame()
238 static int ad9389b_set_rgb_quantization_mode(struct v4l2_subdev *sd, struct v4l2_ctrl *ctrl) in ad9389b_set_rgb_quantization_mode() argument
240 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_set_rgb_quantization_mode()
247 ad9389b_csc_rgb_full2limit(sd, true); in ad9389b_set_rgb_quantization_mode()
250 ad9389b_csc_rgb_full2limit(sd, false); in ad9389b_set_rgb_quantization_mode()
255 ad9389b_csc_rgb_full2limit(sd, true); in ad9389b_set_rgb_quantization_mode()
259 ad9389b_csc_rgb_full2limit(sd, false); in ad9389b_set_rgb_quantization_mode()
267 static void ad9389b_set_manual_pll_gear(struct v4l2_subdev *sd, u32 pixelclock) in ad9389b_set_manual_pll_gear() argument
295 ad9389b_wr_and_or(sd, 0x98, 0x0f, gear); in ad9389b_set_manual_pll_gear()
302 struct v4l2_subdev *sd = to_sd(ctrl); in ad9389b_s_ctrl() local
303 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_s_ctrl()
305 v4l2_dbg(1, debug, sd, in ad9389b_s_ctrl()
310 ad9389b_wr_and_or(sd, 0xaf, 0xfd, in ad9389b_s_ctrl()
315 return ad9389b_set_rgb_quantization_mode(sd, ctrl); in ad9389b_s_ctrl()
326 static int ad9389b_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in ad9389b_g_register() argument
328 reg->val = ad9389b_rd(sd, reg->reg & 0xff); in ad9389b_g_register()
333 static int ad9389b_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in ad9389b_s_register() argument
335 ad9389b_wr(sd, reg->reg & 0xff, reg->val & 0xff); in ad9389b_s_register()
340 static int ad9389b_log_status(struct v4l2_subdev *sd) in ad9389b_log_status() argument
342 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_log_status()
369 v4l2_info(sd, "chip revision %d\n", state->chip_revision); in ad9389b_log_status()
370 v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off"); in ad9389b_log_status()
371 v4l2_info(sd, "%s hotplug, %s Rx Sense, %s EDID (%d block(s))\n", in ad9389b_log_status()
372 (ad9389b_rd(sd, 0x42) & MASK_AD9389B_HPD_DETECT) ? in ad9389b_log_status()
374 (ad9389b_rd(sd, 0x42) & MASK_AD9389B_MSEN_DETECT) ? in ad9389b_log_status()
377 v4l2_info(sd, "%s output %s\n", in ad9389b_log_status()
378 (ad9389b_rd(sd, 0xaf) & 0x02) ? in ad9389b_log_status()
380 (ad9389b_rd(sd, 0xa1) & 0x3c) ? in ad9389b_log_status()
382 v4l2_info(sd, "ad9389b: %s\n", (ad9389b_rd(sd, 0xb8) & 0x40) ? in ad9389b_log_status()
384 v4l2_info(sd, "state: %s, error: %s, detect count: %u, msk/irq: %02x/%02x\n", in ad9389b_log_status()
385 states[ad9389b_rd(sd, 0xc8) & 0xf], in ad9389b_log_status()
386 errors[ad9389b_rd(sd, 0xc8) >> 4], in ad9389b_log_status()
388 ad9389b_rd(sd, 0x94), ad9389b_rd(sd, 0x96)); in ad9389b_log_status()
389 manual_gear = ad9389b_rd(sd, 0x98) & 0x80; in ad9389b_log_status()
390 v4l2_info(sd, "ad9389b: RGB quantization: %s range\n", in ad9389b_log_status()
391 ad9389b_rd(sd, 0x3b) & 0x01 ? "limited" : "full"); in ad9389b_log_status()
392 v4l2_info(sd, "ad9389b: %s gear %d\n", in ad9389b_log_status()
394 manual_gear ? ((ad9389b_rd(sd, 0x98) & 0x70) >> 4) : in ad9389b_log_status()
395 ((ad9389b_rd(sd, 0x9e) & 0x0e) >> 1)); in ad9389b_log_status()
396 if (ad9389b_rd(sd, 0xaf) & 0x02) { in ad9389b_log_status()
398 u8 manual_cts = ad9389b_rd(sd, 0x0a) & 0x80; in ad9389b_log_status()
399 u32 N = (ad9389b_rd(sd, 0x01) & 0xf) << 16 | in ad9389b_log_status()
400 ad9389b_rd(sd, 0x02) << 8 | in ad9389b_log_status()
401 ad9389b_rd(sd, 0x03); in ad9389b_log_status()
402 u8 vic_detect = ad9389b_rd(sd, 0x3e) >> 2; in ad9389b_log_status()
403 u8 vic_sent = ad9389b_rd(sd, 0x3d) & 0x3f; in ad9389b_log_status()
407 CTS = (ad9389b_rd(sd, 0x07) & 0xf) << 16 | in ad9389b_log_status()
408 ad9389b_rd(sd, 0x08) << 8 | in ad9389b_log_status()
409 ad9389b_rd(sd, 0x09); in ad9389b_log_status()
411 CTS = (ad9389b_rd(sd, 0x04) & 0xf) << 16 | in ad9389b_log_status()
412 ad9389b_rd(sd, 0x05) << 8 | in ad9389b_log_status()
413 ad9389b_rd(sd, 0x06); in ad9389b_log_status()
414 N = (ad9389b_rd(sd, 0x01) & 0xf) << 16 | in ad9389b_log_status()
415 ad9389b_rd(sd, 0x02) << 8 | in ad9389b_log_status()
416 ad9389b_rd(sd, 0x03); in ad9389b_log_status()
418 v4l2_info(sd, "ad9389b: CTS %s mode: N %d, CTS %d\n", in ad9389b_log_status()
421 v4l2_info(sd, "ad9389b: VIC: detected %d, sent %d\n", in ad9389b_log_status()
425 v4l2_print_dv_timings(sd->name, "timings: ", in ad9389b_log_status()
428 v4l2_info(sd, "no timings set\n"); in ad9389b_log_status()
433 static int ad9389b_s_power(struct v4l2_subdev *sd, int on) in ad9389b_s_power() argument
435 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_s_power()
440 v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off"); in ad9389b_s_power()
446 ad9389b_wr_and_or(sd, 0x41, 0xbf, 0x40); in ad9389b_s_power()
454 ad9389b_wr_and_or(sd, 0x41, 0xbf, 0x0); in ad9389b_s_power()
455 if ((ad9389b_rd(sd, 0x41) & 0x40) == 0) in ad9389b_s_power()
457 ad9389b_wr_and_or(sd, 0x41, 0xbf, 0x40); in ad9389b_s_power()
461 v4l2_dbg(1, debug, sd, "failed to powerup the ad9389b\n"); in ad9389b_s_power()
462 ad9389b_s_power(sd, 0); in ad9389b_s_power()
466 v4l2_dbg(1, debug, sd, in ad9389b_s_power()
470 ad9389b_wr_and_or(sd, 0xba, 0xef, 0x10); in ad9389b_s_power()
473 ad9389b_wr_and_or(sd, 0x98, 0xf0, 0x07); in ad9389b_s_power()
474 ad9389b_wr(sd, 0x9c, 0x38); in ad9389b_s_power()
475 ad9389b_wr_and_or(sd, 0x9d, 0xfc, 0x01); in ad9389b_s_power()
479 ad9389b_wr(sd, 0xa2, pdata->diff_data_drive_strength); in ad9389b_s_power()
481 ad9389b_wr(sd, 0xa2, 0x87); in ad9389b_s_power()
484 ad9389b_wr(sd, 0xa3, pdata->diff_clk_drive_strength); in ad9389b_s_power()
486 ad9389b_wr(sd, 0xa3, 0x87); in ad9389b_s_power()
488 ad9389b_wr(sd, 0x0a, 0x01); in ad9389b_s_power()
489 ad9389b_wr(sd, 0xbb, 0xff); in ad9389b_s_power()
492 ad9389b_wr(sd, 0xc9, 0xf); in ad9389b_s_power()
497 static void ad9389b_set_isr(struct v4l2_subdev *sd, bool enable) in ad9389b_set_isr() argument
507 else if (ad9389b_have_hotplug(sd)) in ad9389b_set_isr()
519 ad9389b_wr(sd, 0x94, irqs); in ad9389b_set_isr()
520 irqs_rd = ad9389b_rd(sd, 0x94); in ad9389b_set_isr()
524 v4l2_err(sd, "Could not set interrupts: hw failure?\n"); in ad9389b_set_isr()
528 static int ad9389b_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in ad9389b_isr() argument
533 ad9389b_set_isr(sd, false); in ad9389b_isr()
534 irq_status = ad9389b_rd(sd, 0x96); in ad9389b_isr()
536 ad9389b_wr(sd, 0x96, irq_status); in ad9389b_isr()
538 ad9389b_set_isr(sd, true); in ad9389b_isr()
540 v4l2_dbg(1, debug, sd, "%s: irq_status 0x%x\n", __func__, irq_status); in ad9389b_isr()
543 ad9389b_check_monitor_present_status(sd); in ad9389b_isr()
545 ad9389b_check_edid_status(sd); in ad9389b_isr()
564 static int ad9389b_s_stream(struct v4l2_subdev *sd, int enable) in ad9389b_s_stream() argument
566 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in ad9389b_s_stream()
568 ad9389b_wr_and_or(sd, 0xa1, ~0x3c, (enable ? 0 : 0x3c)); in ad9389b_s_stream()
570 ad9389b_check_monitor_present_status(sd); in ad9389b_s_stream()
572 ad9389b_s_power(sd, 0); in ad9389b_s_stream()
588 static int ad9389b_s_dv_timings(struct v4l2_subdev *sd, in ad9389b_s_dv_timings() argument
591 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_s_dv_timings()
593 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in ad9389b_s_dv_timings()
609 ad9389b_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in ad9389b_s_dv_timings()
613 ad9389b_set_manual_pll_gear(sd, (u32)timings->bt.pixelclock); in ad9389b_s_dv_timings()
616 ad9389b_set_IT_content_AVI_InfoFrame(sd); in ad9389b_s_dv_timings()
621 static int ad9389b_g_dv_timings(struct v4l2_subdev *sd, in ad9389b_g_dv_timings() argument
624 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_g_dv_timings()
626 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in ad9389b_g_dv_timings()
636 static int ad9389b_enum_dv_timings(struct v4l2_subdev *sd, in ad9389b_enum_dv_timings() argument
646 static int ad9389b_dv_timings_cap(struct v4l2_subdev *sd, in ad9389b_dv_timings_cap() argument
664 static int ad9389b_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in ad9389b_get_edid() argument
666 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_get_edid()
673 v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n"); in ad9389b_get_edid()
693 static int ad9389b_s_audio_stream(struct v4l2_subdev *sd, int enable) in ad9389b_s_audio_stream() argument
695 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in ad9389b_s_audio_stream()
698 ad9389b_wr_and_or(sd, 0x45, 0x3f, 0x80); in ad9389b_s_audio_stream()
700 ad9389b_wr_and_or(sd, 0x45, 0x3f, 0x40); in ad9389b_s_audio_stream()
705 static int ad9389b_s_clock_freq(struct v4l2_subdev *sd, u32 freq) in ad9389b_s_clock_freq() argument
722 ad9389b_wr(sd, 0x01, (N >> 16) & 0xf); in ad9389b_s_clock_freq()
723 ad9389b_wr(sd, 0x02, (N >> 8) & 0xff); in ad9389b_s_clock_freq()
724 ad9389b_wr(sd, 0x03, N & 0xff); in ad9389b_s_clock_freq()
729 static int ad9389b_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq) in ad9389b_s_i2s_clock_freq() argument
746 ad9389b_wr_and_or(sd, 0x15, 0xf, i2s_sf); in ad9389b_s_i2s_clock_freq()
751 static int ad9389b_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) in ad9389b_s_routing() argument
757 ad9389b_wr_and_or(sd, 0x50, 0x1f, 0x20); in ad9389b_s_routing()
759 ad9389b_wr(sd, 0x51, 0x00); in ad9389b_s_routing()
763 ad9389b_wr_and_or(sd, 0x14, 0xf0, 0x02); in ad9389b_s_routing()
785 static void ad9389b_dbg_dump_edid(int lvl, int debug, struct v4l2_subdev *sd, in ad9389b_dbg_dump_edid() argument
793 v4l2_dbg(lvl, debug, sd, "edid segment %d\n", segment); in ad9389b_dbg_dump_edid()
799 v4l2_dbg(lvl, debug, sd, "\n"); in ad9389b_dbg_dump_edid()
805 v4l2_dbg(lvl, debug, sd, "%s\n", b); in ad9389b_dbg_dump_edid()
814 struct v4l2_subdev *sd = &state->sd; in ad9389b_edid_handler() local
817 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in ad9389b_edid_handler()
819 if (ad9389b_check_edid_status(sd)) { in ad9389b_edid_handler()
824 if (ad9389b_have_hotplug(sd)) { in ad9389b_edid_handler()
830 v4l2_dbg(1, debug, sd, "%s: edid read failed\n", __func__); in ad9389b_edid_handler()
831 ad9389b_s_power(sd, false); in ad9389b_edid_handler()
832 ad9389b_s_power(sd, true); in ad9389b_edid_handler()
840 ed.segment = ad9389b_rd(sd, 0xc4); in ad9389b_edid_handler()
841 v4l2_subdev_notify(sd, AD9389B_EDID_DETECT, (void *)&ed); in ad9389b_edid_handler()
842 v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__); in ad9389b_edid_handler()
845 static void ad9389b_audio_setup(struct v4l2_subdev *sd) in ad9389b_audio_setup() argument
847 v4l2_dbg(1, debug, sd, "%s\n", __func__); in ad9389b_audio_setup()
849 ad9389b_s_i2s_clock_freq(sd, 48000); in ad9389b_audio_setup()
850 ad9389b_s_clock_freq(sd, 48000); in ad9389b_audio_setup()
851 ad9389b_s_routing(sd, 0, 0, 0); in ad9389b_audio_setup()
857 static void ad9389b_setup(struct v4l2_subdev *sd) in ad9389b_setup() argument
859 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_setup()
861 v4l2_dbg(1, debug, sd, "%s\n", __func__); in ad9389b_setup()
864 ad9389b_wr_and_or(sd, 0x15, 0xf1, 0x0); in ad9389b_setup()
866 ad9389b_wr_and_or(sd, 0x16, 0x3f, 0x0); in ad9389b_setup()
869 ad9389b_wr_and_or(sd, 0x17, 0xf9, 0x06); in ad9389b_setup()
871 ad9389b_wr_and_or(sd, 0x45, 0xc7, 0x08); in ad9389b_setup()
873 ad9389b_wr_and_or(sd, 0x46, 0x3f, 0x80); in ad9389b_setup()
875 ad9389b_wr(sd, 0x3c, 0x0); in ad9389b_setup()
877 ad9389b_wr(sd, 0x47, 0x80); in ad9389b_setup()
879 ad9389b_wr_and_or(sd, 0xaf, 0xef, 0x0); in ad9389b_setup()
881 ad9389b_wr_and_or(sd, 0xba, 0x1f, 0x60); in ad9389b_setup()
883 ad9389b_audio_setup(sd); in ad9389b_setup()
887 ad9389b_set_IT_content_AVI_InfoFrame(sd); in ad9389b_setup()
890 static void ad9389b_notify_monitor_detect(struct v4l2_subdev *sd) in ad9389b_notify_monitor_detect() argument
893 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_notify_monitor_detect()
896 v4l2_subdev_notify(sd, AD9389B_MONITOR_DETECT, (void *)&mdt); in ad9389b_notify_monitor_detect()
899 static void ad9389b_update_monitor_present_status(struct v4l2_subdev *sd) in ad9389b_update_monitor_present_status() argument
901 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_update_monitor_present_status()
903 u8 status = ad9389b_rd(sd, 0x42); in ad9389b_update_monitor_present_status()
905 v4l2_dbg(1, debug, sd, "%s: status: 0x%x%s%s\n", in ad9389b_update_monitor_present_status()
912 v4l2_dbg(1, debug, sd, "%s: hotplug detected\n", __func__); in ad9389b_update_monitor_present_status()
914 if (!ad9389b_s_power(sd, true)) { in ad9389b_update_monitor_present_status()
915 v4l2_dbg(1, debug, sd, in ad9389b_update_monitor_present_status()
919 ad9389b_setup(sd); in ad9389b_update_monitor_present_status()
920 ad9389b_notify_monitor_detect(sd); in ad9389b_update_monitor_present_status()
924 v4l2_dbg(1, debug, sd, "%s: hotplug not detected\n", __func__); in ad9389b_update_monitor_present_status()
926 ad9389b_notify_monitor_detect(sd); in ad9389b_update_monitor_present_status()
927 ad9389b_s_power(sd, false); in ad9389b_update_monitor_present_status()
932 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, ad9389b_have_hotplug(sd) ? 0x1 : 0x0); in ad9389b_update_monitor_present_status()
933 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, ad9389b_have_rx_sense(sd) ? 0x1 : 0x0); in ad9389b_update_monitor_present_status()
941 static void ad9389b_check_monitor_present_status(struct v4l2_subdev *sd) in ad9389b_check_monitor_present_status() argument
943 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_check_monitor_present_status()
946 ad9389b_update_monitor_present_status(sd); in ad9389b_check_monitor_present_status()
952 while (state->power_on && (ad9389b_rd(sd, 0x41) & 0x40)) { in ad9389b_check_monitor_present_status()
954 v4l2_err(sd, "retried %d times, give up\n", retry); in ad9389b_check_monitor_present_status()
957 v4l2_dbg(1, debug, sd, "%s: reset and re-check status (%d)\n", __func__, retry); in ad9389b_check_monitor_present_status()
958 ad9389b_notify_monitor_detect(sd); in ad9389b_check_monitor_present_status()
961 ad9389b_s_power(sd, false); in ad9389b_check_monitor_present_status()
962 ad9389b_update_monitor_present_status(sd); in ad9389b_check_monitor_present_status()
976 static bool edid_verify_crc(struct v4l2_subdev *sd, u32 segment) in edid_verify_crc() argument
978 struct ad9389b_state *state = get_ad9389b_state(sd); in edid_verify_crc()
990 static bool edid_verify_header(struct v4l2_subdev *sd, u32 segment) in edid_verify_header() argument
995 struct ad9389b_state *state = get_ad9389b_state(sd); in edid_verify_header()
1009 static bool ad9389b_check_edid_status(struct v4l2_subdev *sd) in ad9389b_check_edid_status() argument
1011 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_check_edid_status()
1014 u8 edidRdy = ad9389b_rd(sd, 0xc5); in ad9389b_check_edid_status()
1016 v4l2_dbg(1, debug, sd, "%s: edid ready (retries: %d)\n", in ad9389b_check_edid_status()
1022 segment = ad9389b_rd(sd, 0xc4); in ad9389b_check_edid_status()
1024 v4l2_err(sd, "edid segment number too big\n"); in ad9389b_check_edid_status()
1027 v4l2_dbg(1, debug, sd, "%s: got segment %d\n", __func__, segment); in ad9389b_check_edid_status()
1028 ad9389b_edid_rd(sd, 256, &state->edid.data[segment * 256]); in ad9389b_check_edid_status()
1029 ad9389b_dbg_dump_edid(2, debug, sd, segment, in ad9389b_check_edid_status()
1033 v4l2_dbg(1, debug, sd, "%s: %d blocks in total\n", in ad9389b_check_edid_status()
1036 if (!edid_verify_crc(sd, segment) || in ad9389b_check_edid_status()
1037 !edid_verify_header(sd, segment)) { in ad9389b_check_edid_status()
1039 v4l2_err(sd, "%s: edid crc or header error\n", __func__); in ad9389b_check_edid_status()
1040 ad9389b_s_power(sd, false); in ad9389b_check_edid_status()
1041 ad9389b_s_power(sd, true); in ad9389b_check_edid_status()
1048 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", in ad9389b_check_edid_status()
1050 ad9389b_wr(sd, 0xc9, 0xf); in ad9389b_check_edid_status()
1051 ad9389b_wr(sd, 0xc4, state->edid.segments); in ad9389b_check_edid_status()
1060 v4l2_subdev_notify(sd, AD9389B_EDID_DETECT, (void *)&ed); in ad9389b_check_edid_status()
1068 static void ad9389b_init_setup(struct v4l2_subdev *sd) in ad9389b_init_setup() argument
1070 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_init_setup()
1073 v4l2_dbg(1, debug, sd, "%s\n", __func__); in ad9389b_init_setup()
1076 ad9389b_wr(sd, 0x96, 0xff); in ad9389b_init_setup()
1080 ad9389b_set_isr(sd, false); in ad9389b_init_setup()
1089 struct v4l2_subdev *sd; in ad9389b_probe() local
1110 sd = &state->sd; in ad9389b_probe()
1111 v4l2_i2c_subdev_init(sd, client, &ad9389b_ops); in ad9389b_probe()
1112 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ad9389b_probe()
1130 sd->ctrl_handler = hdl; in ad9389b_probe()
1137 sd->entity.function = MEDIA_ENT_F_DV_ENCODER; in ad9389b_probe()
1138 err = media_entity_pads_init(&sd->entity, 1, &state->pad); in ad9389b_probe()
1142 state->chip_revision = ad9389b_rd(sd, 0x0); in ad9389b_probe()
1144 v4l2_err(sd, "chip_revision %d != 2\n", state->chip_revision); in ad9389b_probe()
1148 v4l2_dbg(1, debug, sd, "reg 0x41 0x%x, chip version (reg 0x00) 0x%x\n", in ad9389b_probe()
1149 ad9389b_rd(sd, 0x41), state->chip_revision); in ad9389b_probe()
1153 v4l2_err(sd, "failed to register edid i2c client\n"); in ad9389b_probe()
1161 ad9389b_init_setup(sd); in ad9389b_probe()
1162 ad9389b_set_isr(sd, true); in ad9389b_probe()
1164 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in ad9389b_probe()
1169 media_entity_cleanup(&sd->entity); in ad9389b_probe()
1179 struct v4l2_subdev *sd = i2c_get_clientdata(client); in ad9389b_remove() local
1180 struct ad9389b_state *state = get_ad9389b_state(sd); in ad9389b_remove()
1184 v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, in ad9389b_remove()
1187 ad9389b_s_stream(sd, false); in ad9389b_remove()
1188 ad9389b_s_audio_stream(sd, false); in ad9389b_remove()
1189 ad9389b_init_setup(sd); in ad9389b_remove()
1192 v4l2_device_unregister_subdev(sd); in ad9389b_remove()
1193 media_entity_cleanup(&sd->entity); in ad9389b_remove()
1194 v4l2_ctrl_handler_free(sd->ctrl_handler); in ad9389b_remove()