Lines Matching refs:sd
88 struct v4l2_subdev sd; member
121 static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd);
122 static bool adv7511_check_edid_status(struct v4l2_subdev *sd);
123 static void adv7511_setup(struct v4l2_subdev *sd);
124 static int adv7511_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq);
125 static int adv7511_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
140 static inline struct adv7511_state *get_adv7511_state(struct v4l2_subdev *sd) in get_adv7511_state() argument
142 return container_of(sd, struct adv7511_state, sd); in get_adv7511_state()
147 return &container_of(ctrl->handler, struct adv7511_state, hdl)->sd; in to_sd()
182 static int adv7511_rd(struct v4l2_subdev *sd, u8 reg) in adv7511_rd() argument
184 struct i2c_client *client = v4l2_get_subdevdata(sd); in adv7511_rd()
189 static int adv7511_wr(struct v4l2_subdev *sd, u8 reg, u8 val) in adv7511_wr() argument
191 struct i2c_client *client = v4l2_get_subdevdata(sd); in adv7511_wr()
200 v4l2_err(sd, "%s: i2c write error\n", __func__); in adv7511_wr()
206 static inline void adv7511_wr_and_or(struct v4l2_subdev *sd, u8 reg, u8 clr_mask, u8 val_mask) in adv7511_wr_and_or() argument
208 adv7511_wr(sd, reg, (adv7511_rd(sd, reg) & clr_mask) | val_mask); in adv7511_wr_and_or()
228 static inline void adv7511_edid_rd(struct v4l2_subdev *sd, u16 len, u8 *buf) in adv7511_edid_rd() argument
230 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_edid_rd()
234 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_edid_rd()
240 v4l2_err(sd, "%s: i2c read error\n", __func__); in adv7511_edid_rd()
243 static int adv7511_pktmem_rd(struct v4l2_subdev *sd, u8 reg) in adv7511_pktmem_rd() argument
245 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_pktmem_rd()
250 static int adv7511_pktmem_wr(struct v4l2_subdev *sd, u8 reg, u8 val) in adv7511_pktmem_wr() argument
252 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_pktmem_wr()
261 v4l2_err(sd, "%s: i2c write error\n", __func__); in adv7511_pktmem_wr()
267 static inline void adv7511_pktmem_wr_and_or(struct v4l2_subdev *sd, u8 reg, u8 clr_mask, u8 val_mas… in adv7511_pktmem_wr_and_or() argument
269 adv7511_pktmem_wr(sd, reg, (adv7511_pktmem_rd(sd, reg) & clr_mask) | val_mask); in adv7511_pktmem_wr_and_or()
272 static inline bool adv7511_have_hotplug(struct v4l2_subdev *sd) in adv7511_have_hotplug() argument
274 return adv7511_rd(sd, 0x42) & MASK_ADV7511_HPD_DETECT; in adv7511_have_hotplug()
277 static inline bool adv7511_have_rx_sense(struct v4l2_subdev *sd) in adv7511_have_rx_sense() argument
279 return adv7511_rd(sd, 0x42) & MASK_ADV7511_MSEN_DETECT; in adv7511_have_rx_sense()
282 static void adv7511_csc_conversion_mode(struct v4l2_subdev *sd, u8 mode) in adv7511_csc_conversion_mode() argument
284 adv7511_wr_and_or(sd, 0x18, 0x9f, (mode & 0x3)<<5); in adv7511_csc_conversion_mode()
287 static void adv7511_csc_coeff(struct v4l2_subdev *sd, in adv7511_csc_coeff() argument
293 adv7511_wr_and_or(sd, 0x18, 0xe0, A1>>8); in adv7511_csc_coeff()
294 adv7511_wr(sd, 0x19, A1); in adv7511_csc_coeff()
295 adv7511_wr_and_or(sd, 0x1A, 0xe0, A2>>8); in adv7511_csc_coeff()
296 adv7511_wr(sd, 0x1B, A2); in adv7511_csc_coeff()
297 adv7511_wr_and_or(sd, 0x1c, 0xe0, A3>>8); in adv7511_csc_coeff()
298 adv7511_wr(sd, 0x1d, A3); in adv7511_csc_coeff()
299 adv7511_wr_and_or(sd, 0x1e, 0xe0, A4>>8); in adv7511_csc_coeff()
300 adv7511_wr(sd, 0x1f, A4); in adv7511_csc_coeff()
303 adv7511_wr_and_or(sd, 0x20, 0xe0, B1>>8); in adv7511_csc_coeff()
304 adv7511_wr(sd, 0x21, B1); in adv7511_csc_coeff()
305 adv7511_wr_and_or(sd, 0x22, 0xe0, B2>>8); in adv7511_csc_coeff()
306 adv7511_wr(sd, 0x23, B2); in adv7511_csc_coeff()
307 adv7511_wr_and_or(sd, 0x24, 0xe0, B3>>8); in adv7511_csc_coeff()
308 adv7511_wr(sd, 0x25, B3); in adv7511_csc_coeff()
309 adv7511_wr_and_or(sd, 0x26, 0xe0, B4>>8); in adv7511_csc_coeff()
310 adv7511_wr(sd, 0x27, B4); in adv7511_csc_coeff()
313 adv7511_wr_and_or(sd, 0x28, 0xe0, C1>>8); in adv7511_csc_coeff()
314 adv7511_wr(sd, 0x29, C1); in adv7511_csc_coeff()
315 adv7511_wr_and_or(sd, 0x2A, 0xe0, C2>>8); in adv7511_csc_coeff()
316 adv7511_wr(sd, 0x2B, C2); in adv7511_csc_coeff()
317 adv7511_wr_and_or(sd, 0x2C, 0xe0, C3>>8); in adv7511_csc_coeff()
318 adv7511_wr(sd, 0x2D, C3); in adv7511_csc_coeff()
319 adv7511_wr_and_or(sd, 0x2E, 0xe0, C4>>8); in adv7511_csc_coeff()
320 adv7511_wr(sd, 0x2F, C4); in adv7511_csc_coeff()
323 static void adv7511_csc_rgb_full2limit(struct v4l2_subdev *sd, bool enable) in adv7511_csc_rgb_full2limit() argument
327 adv7511_csc_conversion_mode(sd, csc_mode); in adv7511_csc_rgb_full2limit()
328 adv7511_csc_coeff(sd, in adv7511_csc_rgb_full2limit()
333 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x80); in adv7511_csc_rgb_full2limit()
335 adv7511_wr_and_or(sd, 0x57, 0xf3, 0x04); in adv7511_csc_rgb_full2limit()
338 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x0); in adv7511_csc_rgb_full2limit()
340 adv7511_wr_and_or(sd, 0x57, 0xf3, 0x08); in adv7511_csc_rgb_full2limit()
344 static void adv7511_set_IT_content_AVI_InfoFrame(struct v4l2_subdev *sd) in adv7511_set_IT_content_AVI_InfoFrame() argument
346 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_IT_content_AVI_InfoFrame()
349 adv7511_wr_and_or(sd, 0x57, 0x7f, 0x00); in adv7511_set_IT_content_AVI_InfoFrame()
352 adv7511_wr_and_or(sd, 0x57, 0x7f, 0x80); in adv7511_set_IT_content_AVI_InfoFrame()
356 static int adv7511_set_rgb_quantization_mode(struct v4l2_subdev *sd, struct v4l2_ctrl *ctrl) in adv7511_set_rgb_quantization_mode() argument
364 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_rgb_quantization_mode()
368 adv7511_csc_rgb_full2limit(sd, true); in adv7511_set_rgb_quantization_mode()
371 adv7511_csc_rgb_full2limit(sd, false); in adv7511_set_rgb_quantization_mode()
377 adv7511_csc_rgb_full2limit(sd, true); in adv7511_set_rgb_quantization_mode()
381 adv7511_csc_rgb_full2limit(sd, false); in adv7511_set_rgb_quantization_mode()
391 struct v4l2_subdev *sd = to_sd(ctrl); in adv7511_s_ctrl() local
392 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_ctrl()
394 v4l2_dbg(1, debug, sd, "%s: ctrl id: %d, ctrl->val %d\n", __func__, ctrl->id, ctrl->val); in adv7511_s_ctrl()
398 adv7511_wr_and_or(sd, 0xaf, 0xfd, ctrl->val == V4L2_DV_TX_MODE_HDMI ? 0x02 : 0x00); in adv7511_s_ctrl()
402 return adv7511_set_rgb_quantization_mode(sd, ctrl); in adv7511_s_ctrl()
414 static void adv7511_inv_register(struct v4l2_subdev *sd) in adv7511_inv_register() argument
416 v4l2_info(sd, "0x000-0x0ff: Main Map\n"); in adv7511_inv_register()
419 static int adv7511_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in adv7511_g_register() argument
424 reg->val = adv7511_rd(sd, reg->reg & 0xff); in adv7511_g_register()
427 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_g_register()
428 adv7511_inv_register(sd); in adv7511_g_register()
434 static int adv7511_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in adv7511_s_register() argument
438 adv7511_wr(sd, reg->reg & 0xff, reg->val & 0xff); in adv7511_s_register()
441 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_s_register()
442 adv7511_inv_register(sd); in adv7511_s_register()
469 static void log_infoframe(struct v4l2_subdev *sd, const struct adv7511_cfg_read_infoframe *cri) in log_infoframe() argument
471 struct i2c_client *client = v4l2_get_subdevdata(sd); in log_infoframe()
478 if (!(adv7511_rd(sd, cri->present_reg) & cri->present_mask)) { in log_infoframe()
479 v4l2_info(sd, "%s infoframe not transmitted\n", cri->desc); in log_infoframe()
488 v4l2_err(sd, "%s: invalid %s infoframe length %d\n", __func__, cri->desc, len); in log_infoframe()
494 buffer[i + 4] = adv7511_pktmem_rd(sd, cri->payload_addr + i - 0x100); in log_infoframe()
497 buffer[i + 4] = adv7511_rd(sd, cri->payload_addr + i); in log_infoframe()
503 v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc); in log_infoframe()
510 static void adv7511_log_infoframes(struct v4l2_subdev *sd) in adv7511_log_infoframes() argument
520 log_infoframe(sd, &cri[i]); in adv7511_log_infoframes()
523 static int adv7511_log_status(struct v4l2_subdev *sd) in adv7511_log_status() argument
525 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_log_status()
550 v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off"); in adv7511_log_status()
551 v4l2_info(sd, "%s hotplug, %s Rx Sense, %s EDID (%d block(s))\n", in adv7511_log_status()
552 (adv7511_rd(sd, 0x42) & MASK_ADV7511_HPD_DETECT) ? "detected" : "no", in adv7511_log_status()
553 (adv7511_rd(sd, 0x42) & MASK_ADV7511_MSEN_DETECT) ? "detected" : "no", in adv7511_log_status()
556 v4l2_info(sd, "%s output %s\n", in adv7511_log_status()
557 (adv7511_rd(sd, 0xaf) & 0x02) ? in adv7511_log_status()
559 (adv7511_rd(sd, 0xa1) & 0x3c) ? in adv7511_log_status()
561 v4l2_info(sd, "state: %s, error: %s, detect count: %u, msk/irq: %02x/%02x\n", in adv7511_log_status()
562 states[adv7511_rd(sd, 0xc8) & 0xf], in adv7511_log_status()
563 errors[adv7511_rd(sd, 0xc8) >> 4], state->edid_detect_counter, in adv7511_log_status()
564 adv7511_rd(sd, 0x94), adv7511_rd(sd, 0x96)); in adv7511_log_status()
565 v4l2_info(sd, "RGB quantization: %s range\n", adv7511_rd(sd, 0x18) & 0x80 ? "limited" : "full"); in adv7511_log_status()
566 if (adv7511_rd(sd, 0xaf) & 0x02) { in adv7511_log_status()
568 u8 manual_cts = adv7511_rd(sd, 0x0a) & 0x80; in adv7511_log_status()
569 u32 N = (adv7511_rd(sd, 0x01) & 0xf) << 16 | in adv7511_log_status()
570 adv7511_rd(sd, 0x02) << 8 | in adv7511_log_status()
571 adv7511_rd(sd, 0x03); in adv7511_log_status()
572 u8 vic_detect = adv7511_rd(sd, 0x3e) >> 2; in adv7511_log_status()
573 u8 vic_sent = adv7511_rd(sd, 0x3d) & 0x3f; in adv7511_log_status()
577 CTS = (adv7511_rd(sd, 0x07) & 0xf) << 16 | in adv7511_log_status()
578 adv7511_rd(sd, 0x08) << 8 | in adv7511_log_status()
579 adv7511_rd(sd, 0x09); in adv7511_log_status()
581 CTS = (adv7511_rd(sd, 0x04) & 0xf) << 16 | in adv7511_log_status()
582 adv7511_rd(sd, 0x05) << 8 | in adv7511_log_status()
583 adv7511_rd(sd, 0x06); in adv7511_log_status()
584 v4l2_info(sd, "CTS %s mode: N %d, CTS %d\n", in adv7511_log_status()
586 v4l2_info(sd, "VIC: detected %d, sent %d\n", in adv7511_log_status()
588 adv7511_log_infoframes(sd); in adv7511_log_status()
591 v4l2_print_dv_timings(sd->name, "timings: ", in adv7511_log_status()
594 v4l2_info(sd, "no timings set\n"); in adv7511_log_status()
595 v4l2_info(sd, "i2c edid addr: 0x%x\n", state->i2c_edid_addr); in adv7511_log_status()
596 v4l2_info(sd, "i2c cec addr: 0x%x\n", state->i2c_cec_addr); in adv7511_log_status()
597 v4l2_info(sd, "i2c pktmem addr: 0x%x\n", state->i2c_pktmem_addr); in adv7511_log_status()
602 static int adv7511_s_power(struct v4l2_subdev *sd, int on) in adv7511_s_power() argument
604 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_power()
608 v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off"); in adv7511_s_power()
614 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x40); in adv7511_s_power()
622 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x0); in adv7511_s_power()
623 if ((adv7511_rd(sd, 0x41) & 0x40) == 0) in adv7511_s_power()
625 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x40); in adv7511_s_power()
629 v4l2_dbg(1, debug, sd, "%s: failed to powerup the adv7511!\n", __func__); in adv7511_s_power()
630 adv7511_s_power(sd, 0); in adv7511_s_power()
634 v4l2_dbg(1, debug, sd, "%s: needed %d retries to powerup the adv7511\n", __func__, i); in adv7511_s_power()
637 adv7511_wr(sd, 0x98, 0x03); in adv7511_s_power()
638 adv7511_wr_and_or(sd, 0x9a, 0xfe, 0x70); in adv7511_s_power()
639 adv7511_wr(sd, 0x9c, 0x30); in adv7511_s_power()
640 adv7511_wr_and_or(sd, 0x9d, 0xfc, 0x01); in adv7511_s_power()
641 adv7511_wr(sd, 0xa2, 0xa4); in adv7511_s_power()
642 adv7511_wr(sd, 0xa3, 0xa4); in adv7511_s_power()
643 adv7511_wr(sd, 0xe0, 0xd0); in adv7511_s_power()
644 adv7511_wr(sd, 0xf9, 0x00); in adv7511_s_power()
646 adv7511_wr(sd, 0x43, state->i2c_edid_addr); in adv7511_s_power()
647 adv7511_wr(sd, 0x45, state->i2c_pktmem_addr); in adv7511_s_power()
650 adv7511_wr(sd, 0xc9, 0xf); in adv7511_s_power()
655 static void adv7511_set_isr(struct v4l2_subdev *sd, bool enable) in adv7511_set_isr() argument
661 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? "enable" : "disable"); in adv7511_set_isr()
667 else if (adv7511_have_hotplug(sd)) in adv7511_set_isr()
679 adv7511_wr(sd, 0x94, irqs); in adv7511_set_isr()
680 irqs_rd = adv7511_rd(sd, 0x94); in adv7511_set_isr()
685 v4l2_err(sd, "Could not set interrupts: hw failure?\n"); in adv7511_set_isr()
689 static int adv7511_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in adv7511_isr() argument
694 adv7511_set_isr(sd, false); in adv7511_isr()
695 irq_status = adv7511_rd(sd, 0x96); in adv7511_isr()
697 adv7511_wr(sd, 0x96, irq_status); in adv7511_isr()
699 v4l2_dbg(1, debug, sd, "%s: irq 0x%x\n", __func__, irq_status); in adv7511_isr()
702 adv7511_check_monitor_present_status(sd); in adv7511_isr()
704 adv7511_check_edid_status(sd); in adv7511_isr()
707 adv7511_set_isr(sd, true); in adv7511_isr()
727 static int adv7511_s_stream(struct v4l2_subdev *sd, int enable) in adv7511_s_stream() argument
729 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_stream()
731 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in adv7511_s_stream()
732 adv7511_wr_and_or(sd, 0xa1, ~0x3c, (enable ? 0 : 0x3c)); in adv7511_s_stream()
734 adv7511_check_monitor_present_status(sd); in adv7511_s_stream()
736 adv7511_s_power(sd, 0); in adv7511_s_stream()
742 static int adv7511_s_dv_timings(struct v4l2_subdev *sd, in adv7511_s_dv_timings() argument
745 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_dv_timings()
747 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_s_dv_timings()
763 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in adv7511_s_dv_timings()
766 adv7511_set_IT_content_AVI_InfoFrame(sd); in adv7511_s_dv_timings()
771 static int adv7511_g_dv_timings(struct v4l2_subdev *sd, in adv7511_g_dv_timings() argument
774 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_g_dv_timings()
776 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_g_dv_timings()
786 static int adv7511_enum_dv_timings(struct v4l2_subdev *sd, in adv7511_enum_dv_timings() argument
795 static int adv7511_dv_timings_cap(struct v4l2_subdev *sd, in adv7511_dv_timings_cap() argument
812 static int adv7511_s_audio_stream(struct v4l2_subdev *sd, int enable) in adv7511_s_audio_stream() argument
814 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in adv7511_s_audio_stream()
817 adv7511_wr_and_or(sd, 0x4b, 0x3f, 0x80); in adv7511_s_audio_stream()
819 adv7511_wr_and_or(sd, 0x4b, 0x3f, 0x40); in adv7511_s_audio_stream()
824 static int adv7511_s_clock_freq(struct v4l2_subdev *sd, u32 freq) in adv7511_s_clock_freq() argument
841 adv7511_wr(sd, 0x01, (N >> 16) & 0xf); in adv7511_s_clock_freq()
842 adv7511_wr(sd, 0x02, (N >> 8) & 0xff); in adv7511_s_clock_freq()
843 adv7511_wr(sd, 0x03, N & 0xff); in adv7511_s_clock_freq()
848 static int adv7511_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq) in adv7511_s_i2s_clock_freq() argument
865 adv7511_wr_and_or(sd, 0x15, 0xf, i2s_sf); in adv7511_s_i2s_clock_freq()
870 static int adv7511_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) in adv7511_s_routing() argument
873 adv7511_wr_and_or(sd, 0x73, 0xf8, 0x1); in adv7511_s_routing()
875 adv7511_wr(sd, 0x76, 0x00); in adv7511_s_routing()
878 adv7511_wr_and_or(sd, 0x14, 0xf0, 0x02); in adv7511_s_routing()
892 static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in adv7511_get_edid() argument
894 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_get_edid()
921 static int adv7511_enum_mbus_code(struct v4l2_subdev *sd, in adv7511_enum_mbus_code() argument
954 static int adv7511_get_fmt(struct v4l2_subdev *sd, in adv7511_get_fmt() argument
958 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_get_fmt()
968 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in adv7511_get_fmt()
985 static int adv7511_set_fmt(struct v4l2_subdev *sd, in adv7511_set_fmt() argument
989 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_fmt()
1021 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in adv7511_set_fmt()
1032 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); in adv7511_set_fmt()
1033 adv7511_wr_and_or(sd, 0x16, 0x03, 0xb8); in adv7511_set_fmt()
1037 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); in adv7511_set_fmt()
1038 adv7511_wr_and_or(sd, 0x16, 0x03, 0xbc); in adv7511_set_fmt()
1043 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x00); in adv7511_set_fmt()
1044 adv7511_wr_and_or(sd, 0x16, 0x03, 0x00); in adv7511_set_fmt()
1115 adv7511_wr_and_or(sd, 0x4a, 0xbf, 0); in adv7511_set_fmt()
1116 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5); in adv7511_set_fmt()
1117 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6); in adv7511_set_fmt()
1118 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2)); in adv7511_set_fmt()
1119 adv7511_wr_and_or(sd, 0x59, 0x0f, yq << 4); in adv7511_set_fmt()
1120 adv7511_wr_and_or(sd, 0x4a, 0xff, 1); in adv7511_set_fmt()
1144 static void adv7511_dbg_dump_edid(int lvl, int debug, struct v4l2_subdev *sd, int segment, u8 *buf) in adv7511_dbg_dump_edid() argument
1148 v4l2_dbg(lvl, debug, sd, "edid segment %d\n", segment); in adv7511_dbg_dump_edid()
1153 v4l2_dbg(lvl, debug, sd, "\n"); in adv7511_dbg_dump_edid()
1159 v4l2_dbg(lvl, debug, sd, "%s\n", b); in adv7511_dbg_dump_edid()
1164 static void adv7511_notify_no_edid(struct v4l2_subdev *sd) in adv7511_notify_no_edid() argument
1166 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_notify_no_edid()
1171 ed.segment = adv7511_rd(sd, 0xc4); in adv7511_notify_no_edid()
1172 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed); in adv7511_notify_no_edid()
1180 struct v4l2_subdev *sd = &state->sd; in adv7511_edid_handler() local
1182 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_edid_handler()
1184 if (adv7511_check_edid_status(sd)) { in adv7511_edid_handler()
1189 if (adv7511_have_hotplug(sd)) { in adv7511_edid_handler()
1195 v4l2_dbg(1, debug, sd, "%s: edid read failed\n", __func__); in adv7511_edid_handler()
1197 adv7511_s_power(sd, false); in adv7511_edid_handler()
1198 adv7511_s_power(sd, true); in adv7511_edid_handler()
1205 adv7511_notify_no_edid(sd); in adv7511_edid_handler()
1206 v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__); in adv7511_edid_handler()
1209 static void adv7511_audio_setup(struct v4l2_subdev *sd) in adv7511_audio_setup() argument
1211 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_audio_setup()
1213 adv7511_s_i2s_clock_freq(sd, 48000); in adv7511_audio_setup()
1214 adv7511_s_clock_freq(sd, 48000); in adv7511_audio_setup()
1215 adv7511_s_routing(sd, 0, 0, 0); in adv7511_audio_setup()
1219 static void adv7511_setup(struct v4l2_subdev *sd) in adv7511_setup() argument
1221 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_setup()
1222 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_setup()
1225 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x0); in adv7511_setup()
1227 adv7511_wr_and_or(sd, 0x16, 0x7f, 0x0); in adv7511_setup()
1229 adv7511_wr_and_or(sd, 0x17, 0xf9, 0x06); in adv7511_setup()
1231 adv7511_wr_and_or(sd, 0x3b, 0x9f, 0x0); in adv7511_setup()
1233 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x0); in adv7511_setup()
1236 adv7511_wr_and_or(sd, 0x55, 0x9c, 0x12); in adv7511_setup()
1238 adv7511_wr_and_or(sd, 0x44, 0xe7, 0x10); in adv7511_setup()
1240 adv7511_wr(sd, 0x56, 0xa8); in adv7511_setup()
1242 adv7511_wr_and_or(sd, 0xaf, 0xed, 0x0); in adv7511_setup()
1245 adv7511_wr_and_or(sd, 0xba, 0x1f, 0x60); in adv7511_setup()
1247 adv7511_audio_setup(sd); in adv7511_setup()
1252 static void adv7511_notify_monitor_detect(struct v4l2_subdev *sd) in adv7511_notify_monitor_detect() argument
1255 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_notify_monitor_detect()
1258 v4l2_subdev_notify(sd, ADV7511_MONITOR_DETECT, (void *)&mdt); in adv7511_notify_monitor_detect()
1261 static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd) in adv7511_check_monitor_present_status() argument
1263 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_check_monitor_present_status()
1265 u8 status = adv7511_rd(sd, 0x42); in adv7511_check_monitor_present_status()
1267 v4l2_dbg(1, debug, sd, "%s: status: 0x%x%s%s\n", in adv7511_check_monitor_present_status()
1274 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1275 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1278 v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__); in adv7511_check_monitor_present_status()
1280 v4l2_dbg(1, debug, sd, "%s: monitor detected\n", __func__); in adv7511_check_monitor_present_status()
1282 adv7511_set_isr(sd, true); in adv7511_check_monitor_present_status()
1283 if (!adv7511_s_power(sd, true)) { in adv7511_check_monitor_present_status()
1284 v4l2_dbg(1, debug, sd, "%s: monitor detected, powerup failed\n", __func__); in adv7511_check_monitor_present_status()
1287 adv7511_setup(sd); in adv7511_check_monitor_present_status()
1288 adv7511_notify_monitor_detect(sd); in adv7511_check_monitor_present_status()
1293 v4l2_dbg(1, debug, sd, "%s: hotplug detected\n", __func__); in adv7511_check_monitor_present_status()
1297 v4l2_dbg(1, debug, sd, "%s: hotplug not detected\n", __func__); in adv7511_check_monitor_present_status()
1299 v4l2_dbg(1, debug, sd, "%s: monitor not detected\n", __func__); in adv7511_check_monitor_present_status()
1301 adv7511_notify_monitor_detect(sd); in adv7511_check_monitor_present_status()
1303 adv7511_s_power(sd, false); in adv7511_check_monitor_present_status()
1305 adv7511_notify_no_edid(sd); in adv7511_check_monitor_present_status()
1319 static bool edid_verify_crc(struct v4l2_subdev *sd, u32 segment) in edid_verify_crc() argument
1321 struct adv7511_state *state = get_adv7511_state(sd); in edid_verify_crc()
1332 static bool edid_verify_header(struct v4l2_subdev *sd, u32 segment) in edid_verify_header() argument
1337 struct adv7511_state *state = get_adv7511_state(sd); in edid_verify_header()
1345 static bool adv7511_check_edid_status(struct v4l2_subdev *sd) in adv7511_check_edid_status() argument
1347 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_check_edid_status()
1348 u8 edidRdy = adv7511_rd(sd, 0xc5); in adv7511_check_edid_status()
1350 v4l2_dbg(1, debug, sd, "%s: edid ready (retries: %d)\n", in adv7511_check_edid_status()
1357 int segment = adv7511_rd(sd, 0xc4); in adv7511_check_edid_status()
1361 v4l2_err(sd, "edid segment number too big\n"); in adv7511_check_edid_status()
1364 v4l2_dbg(1, debug, sd, "%s: got segment %d\n", __func__, segment); in adv7511_check_edid_status()
1365 adv7511_edid_rd(sd, 256, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1366 adv7511_dbg_dump_edid(2, debug, sd, segment, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1369 v4l2_dbg(1, debug, sd, "%s: %d blocks in total\n", __func__, state->edid.blocks); in adv7511_check_edid_status()
1371 if (!edid_verify_crc(sd, segment) || in adv7511_check_edid_status()
1372 !edid_verify_header(sd, segment)) { in adv7511_check_edid_status()
1374 v4l2_err(sd, "%s: edid crc or header error\n", __func__); in adv7511_check_edid_status()
1376 adv7511_s_power(sd, false); in adv7511_check_edid_status()
1377 adv7511_s_power(sd, true); in adv7511_check_edid_status()
1385 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1386 adv7511_wr(sd, 0xc9, 0xf); in adv7511_check_edid_status()
1387 adv7511_wr(sd, 0xc4, state->edid.segments); in adv7511_check_edid_status()
1393 v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1402 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed); in adv7511_check_edid_status()
1411 static void adv7511_init_setup(struct v4l2_subdev *sd) in adv7511_init_setup() argument
1413 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_init_setup()
1416 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_init_setup()
1419 adv7511_wr(sd, 0x96, 0xff); in adv7511_init_setup()
1425 adv7511_wr_and_or(sd, 0xd6, 0x3f, 0xc0); in adv7511_init_setup()
1428 adv7511_set_isr(sd, false); in adv7511_init_setup()
1429 adv7511_s_stream(sd, false); in adv7511_init_setup()
1430 adv7511_s_audio_stream(sd, false); in adv7511_init_setup()
1438 struct v4l2_subdev *sd; in adv7511_probe() local
1459 sd = &state->sd; in adv7511_probe()
1461 v4l2_dbg(1, debug, sd, "detecting adv7511 client on address 0x%x\n", in adv7511_probe()
1464 v4l2_i2c_subdev_init(sd, client, &adv7511_ops); in adv7511_probe()
1482 sd->ctrl_handler = hdl; in adv7511_probe()
1494 err = media_entity_init(&sd->entity, 1, &state->pad, 0); in adv7511_probe()
1503 state->chip_revision = adv7511_rd(sd, 0x0); in adv7511_probe()
1504 chip_id[0] = adv7511_rd(sd, 0xf5); in adv7511_probe()
1505 chip_id[1] = adv7511_rd(sd, 0xf6); in adv7511_probe()
1507 v4l2_err(sd, "chip_id != 0x7511, read 0x%02x%02x\n", chip_id[0], chip_id[1]); in adv7511_probe()
1514 v4l2_err(sd, "failed to register edid i2c client\n"); in adv7511_probe()
1521 v4l2_err(sd, "failed to register pktmem i2c client\n"); in adv7511_probe()
1526 adv7511_wr(sd, 0xe2, 0x01); /* power down cec section */ in adv7511_probe()
1527 state->work_queue = create_singlethread_workqueue(sd->name); in adv7511_probe()
1529 v4l2_err(sd, "could not create workqueue\n"); in adv7511_probe()
1536 adv7511_init_setup(sd); in adv7511_probe()
1537 adv7511_set_isr(sd, true); in adv7511_probe()
1538 adv7511_check_monitor_present_status(sd); in adv7511_probe()
1540 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in adv7511_probe()
1549 media_entity_cleanup(&sd->entity); in adv7511_probe()
1559 struct v4l2_subdev *sd = i2c_get_clientdata(client); in adv7511_remove() local
1560 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_remove()
1564 v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, in adv7511_remove()
1567 adv7511_init_setup(sd); in adv7511_remove()
1572 v4l2_device_unregister_subdev(sd); in adv7511_remove()
1573 media_entity_cleanup(&sd->entity); in adv7511_remove()
1574 v4l2_ctrl_handler_free(sd->ctrl_handler); in adv7511_remove()