Lines Matching refs:sd

88 	struct v4l2_subdev sd;  member
118 static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd);
119 static bool adv7511_check_edid_status(struct v4l2_subdev *sd);
120 static void adv7511_setup(struct v4l2_subdev *sd);
121 static int adv7511_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq);
122 static int adv7511_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
137 static inline struct adv7511_state *get_adv7511_state(struct v4l2_subdev *sd) in get_adv7511_state() argument
139 return container_of(sd, struct adv7511_state, sd); in get_adv7511_state()
144 return &container_of(ctrl->handler, struct adv7511_state, hdl)->sd; in to_sd()
179 static int adv7511_rd(struct v4l2_subdev *sd, u8 reg) in adv7511_rd() argument
181 struct i2c_client *client = v4l2_get_subdevdata(sd); in adv7511_rd()
186 static int adv7511_wr(struct v4l2_subdev *sd, u8 reg, u8 val) in adv7511_wr() argument
188 struct i2c_client *client = v4l2_get_subdevdata(sd); in adv7511_wr()
197 v4l2_err(sd, "%s: i2c write error\n", __func__); in adv7511_wr()
203 static inline void adv7511_wr_and_or(struct v4l2_subdev *sd, u8 reg, uint8_t clr_mask, uint8_t val_… in adv7511_wr_and_or() argument
205 adv7511_wr(sd, reg, (adv7511_rd(sd, reg) & clr_mask) | val_mask); in adv7511_wr_and_or()
225 static inline void adv7511_edid_rd(struct v4l2_subdev *sd, uint16_t len, uint8_t *buf) in adv7511_edid_rd() argument
227 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_edid_rd()
231 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_edid_rd()
237 v4l2_err(sd, "%s: i2c read error\n", __func__); in adv7511_edid_rd()
240 static inline bool adv7511_have_hotplug(struct v4l2_subdev *sd) in adv7511_have_hotplug() argument
242 return adv7511_rd(sd, 0x42) & MASK_ADV7511_HPD_DETECT; in adv7511_have_hotplug()
245 static inline bool adv7511_have_rx_sense(struct v4l2_subdev *sd) in adv7511_have_rx_sense() argument
247 return adv7511_rd(sd, 0x42) & MASK_ADV7511_MSEN_DETECT; in adv7511_have_rx_sense()
250 static void adv7511_csc_conversion_mode(struct v4l2_subdev *sd, uint8_t mode) in adv7511_csc_conversion_mode() argument
252 adv7511_wr_and_or(sd, 0x18, 0x9f, (mode & 0x3)<<5); in adv7511_csc_conversion_mode()
255 static void adv7511_csc_coeff(struct v4l2_subdev *sd, in adv7511_csc_coeff() argument
261 adv7511_wr_and_or(sd, 0x18, 0xe0, A1>>8); in adv7511_csc_coeff()
262 adv7511_wr(sd, 0x19, A1); in adv7511_csc_coeff()
263 adv7511_wr_and_or(sd, 0x1A, 0xe0, A2>>8); in adv7511_csc_coeff()
264 adv7511_wr(sd, 0x1B, A2); in adv7511_csc_coeff()
265 adv7511_wr_and_or(sd, 0x1c, 0xe0, A3>>8); in adv7511_csc_coeff()
266 adv7511_wr(sd, 0x1d, A3); in adv7511_csc_coeff()
267 adv7511_wr_and_or(sd, 0x1e, 0xe0, A4>>8); in adv7511_csc_coeff()
268 adv7511_wr(sd, 0x1f, A4); in adv7511_csc_coeff()
271 adv7511_wr_and_or(sd, 0x20, 0xe0, B1>>8); in adv7511_csc_coeff()
272 adv7511_wr(sd, 0x21, B1); in adv7511_csc_coeff()
273 adv7511_wr_and_or(sd, 0x22, 0xe0, B2>>8); in adv7511_csc_coeff()
274 adv7511_wr(sd, 0x23, B2); in adv7511_csc_coeff()
275 adv7511_wr_and_or(sd, 0x24, 0xe0, B3>>8); in adv7511_csc_coeff()
276 adv7511_wr(sd, 0x25, B3); in adv7511_csc_coeff()
277 adv7511_wr_and_or(sd, 0x26, 0xe0, B4>>8); in adv7511_csc_coeff()
278 adv7511_wr(sd, 0x27, B4); in adv7511_csc_coeff()
281 adv7511_wr_and_or(sd, 0x28, 0xe0, C1>>8); in adv7511_csc_coeff()
282 adv7511_wr(sd, 0x29, C1); in adv7511_csc_coeff()
283 adv7511_wr_and_or(sd, 0x2A, 0xe0, C2>>8); in adv7511_csc_coeff()
284 adv7511_wr(sd, 0x2B, C2); in adv7511_csc_coeff()
285 adv7511_wr_and_or(sd, 0x2C, 0xe0, C3>>8); in adv7511_csc_coeff()
286 adv7511_wr(sd, 0x2D, C3); in adv7511_csc_coeff()
287 adv7511_wr_and_or(sd, 0x2E, 0xe0, C4>>8); in adv7511_csc_coeff()
288 adv7511_wr(sd, 0x2F, C4); in adv7511_csc_coeff()
291 static void adv7511_csc_rgb_full2limit(struct v4l2_subdev *sd, bool enable) in adv7511_csc_rgb_full2limit() argument
295 adv7511_csc_conversion_mode(sd, csc_mode); in adv7511_csc_rgb_full2limit()
296 adv7511_csc_coeff(sd, in adv7511_csc_rgb_full2limit()
301 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x80); in adv7511_csc_rgb_full2limit()
303 adv7511_wr_and_or(sd, 0x57, 0xf3, 0x04); in adv7511_csc_rgb_full2limit()
306 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x0); in adv7511_csc_rgb_full2limit()
308 adv7511_wr_and_or(sd, 0x57, 0xf3, 0x08); in adv7511_csc_rgb_full2limit()
312 static void adv7511_set_IT_content_AVI_InfoFrame(struct v4l2_subdev *sd) in adv7511_set_IT_content_AVI_InfoFrame() argument
314 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_IT_content_AVI_InfoFrame()
317 adv7511_wr_and_or(sd, 0x57, 0x7f, 0x00); in adv7511_set_IT_content_AVI_InfoFrame()
320 adv7511_wr_and_or(sd, 0x57, 0x7f, 0x80); in adv7511_set_IT_content_AVI_InfoFrame()
324 static int adv7511_set_rgb_quantization_mode(struct v4l2_subdev *sd, struct v4l2_ctrl *ctrl) in adv7511_set_rgb_quantization_mode() argument
332 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_rgb_quantization_mode()
336 adv7511_csc_rgb_full2limit(sd, true); in adv7511_set_rgb_quantization_mode()
339 adv7511_csc_rgb_full2limit(sd, false); in adv7511_set_rgb_quantization_mode()
345 adv7511_csc_rgb_full2limit(sd, true); in adv7511_set_rgb_quantization_mode()
349 adv7511_csc_rgb_full2limit(sd, false); in adv7511_set_rgb_quantization_mode()
359 struct v4l2_subdev *sd = to_sd(ctrl); in adv7511_s_ctrl() local
360 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_ctrl()
362 v4l2_dbg(1, debug, sd, "%s: ctrl id: %d, ctrl->val %d\n", __func__, ctrl->id, ctrl->val); in adv7511_s_ctrl()
366 adv7511_wr_and_or(sd, 0xaf, 0xfd, ctrl->val == V4L2_DV_TX_MODE_HDMI ? 0x02 : 0x00); in adv7511_s_ctrl()
370 return adv7511_set_rgb_quantization_mode(sd, ctrl); in adv7511_s_ctrl()
382 static void adv7511_inv_register(struct v4l2_subdev *sd) in adv7511_inv_register() argument
384 v4l2_info(sd, "0x000-0x0ff: Main Map\n"); in adv7511_inv_register()
387 static int adv7511_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in adv7511_g_register() argument
392 reg->val = adv7511_rd(sd, reg->reg & 0xff); in adv7511_g_register()
395 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_g_register()
396 adv7511_inv_register(sd); in adv7511_g_register()
402 static int adv7511_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in adv7511_s_register() argument
406 adv7511_wr(sd, reg->reg & 0xff, reg->val & 0xff); in adv7511_s_register()
409 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_s_register()
410 adv7511_inv_register(sd); in adv7511_s_register()
417 static int adv7511_log_status(struct v4l2_subdev *sd) in adv7511_log_status() argument
419 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_log_status()
444 v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off"); in adv7511_log_status()
445 v4l2_info(sd, "%s hotplug, %s Rx Sense, %s EDID (%d block(s))\n", in adv7511_log_status()
446 (adv7511_rd(sd, 0x42) & MASK_ADV7511_HPD_DETECT) ? "detected" : "no", in adv7511_log_status()
447 (adv7511_rd(sd, 0x42) & MASK_ADV7511_MSEN_DETECT) ? "detected" : "no", in adv7511_log_status()
450 v4l2_info(sd, "%s output %s\n", in adv7511_log_status()
451 (adv7511_rd(sd, 0xaf) & 0x02) ? in adv7511_log_status()
453 (adv7511_rd(sd, 0xa1) & 0x3c) ? in adv7511_log_status()
455 v4l2_info(sd, "state: %s, error: %s, detect count: %u, msk/irq: %02x/%02x\n", in adv7511_log_status()
456 states[adv7511_rd(sd, 0xc8) & 0xf], in adv7511_log_status()
457 errors[adv7511_rd(sd, 0xc8) >> 4], state->edid_detect_counter, in adv7511_log_status()
458 adv7511_rd(sd, 0x94), adv7511_rd(sd, 0x96)); in adv7511_log_status()
459 v4l2_info(sd, "RGB quantization: %s range\n", adv7511_rd(sd, 0x18) & 0x80 ? "limited" : "full"); in adv7511_log_status()
460 if (adv7511_rd(sd, 0xaf) & 0x02) { in adv7511_log_status()
462 u8 manual_cts = adv7511_rd(sd, 0x0a) & 0x80; in adv7511_log_status()
463 u32 N = (adv7511_rd(sd, 0x01) & 0xf) << 16 | in adv7511_log_status()
464 adv7511_rd(sd, 0x02) << 8 | in adv7511_log_status()
465 adv7511_rd(sd, 0x03); in adv7511_log_status()
466 u8 vic_detect = adv7511_rd(sd, 0x3e) >> 2; in adv7511_log_status()
467 u8 vic_sent = adv7511_rd(sd, 0x3d) & 0x3f; in adv7511_log_status()
471 CTS = (adv7511_rd(sd, 0x07) & 0xf) << 16 | in adv7511_log_status()
472 adv7511_rd(sd, 0x08) << 8 | in adv7511_log_status()
473 adv7511_rd(sd, 0x09); in adv7511_log_status()
475 CTS = (adv7511_rd(sd, 0x04) & 0xf) << 16 | in adv7511_log_status()
476 adv7511_rd(sd, 0x05) << 8 | in adv7511_log_status()
477 adv7511_rd(sd, 0x06); in adv7511_log_status()
478 v4l2_info(sd, "CTS %s mode: N %d, CTS %d\n", in adv7511_log_status()
480 v4l2_info(sd, "VIC: detected %d, sent %d\n", in adv7511_log_status()
484 v4l2_print_dv_timings(sd->name, "timings: ", in adv7511_log_status()
487 v4l2_info(sd, "no timings set\n"); in adv7511_log_status()
488 v4l2_info(sd, "i2c edid addr: 0x%x\n", state->i2c_edid_addr); in adv7511_log_status()
489 v4l2_info(sd, "i2c cec addr: 0x%x\n", state->i2c_cec_addr); in adv7511_log_status()
494 static int adv7511_s_power(struct v4l2_subdev *sd, int on) in adv7511_s_power() argument
496 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_power()
500 v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off"); in adv7511_s_power()
506 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x40); in adv7511_s_power()
514 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x0); in adv7511_s_power()
515 if ((adv7511_rd(sd, 0x41) & 0x40) == 0) in adv7511_s_power()
517 adv7511_wr_and_or(sd, 0x41, 0xbf, 0x40); in adv7511_s_power()
521 v4l2_dbg(1, debug, sd, "%s: failed to powerup the adv7511!\n", __func__); in adv7511_s_power()
522 adv7511_s_power(sd, 0); in adv7511_s_power()
526 v4l2_dbg(1, debug, sd, "%s: needed %d retries to powerup the adv7511\n", __func__, i); in adv7511_s_power()
529 adv7511_wr(sd, 0x98, 0x03); in adv7511_s_power()
530 adv7511_wr_and_or(sd, 0x9a, 0xfe, 0x70); in adv7511_s_power()
531 adv7511_wr(sd, 0x9c, 0x30); in adv7511_s_power()
532 adv7511_wr_and_or(sd, 0x9d, 0xfc, 0x01); in adv7511_s_power()
533 adv7511_wr(sd, 0xa2, 0xa4); in adv7511_s_power()
534 adv7511_wr(sd, 0xa3, 0xa4); in adv7511_s_power()
535 adv7511_wr(sd, 0xe0, 0xd0); in adv7511_s_power()
536 adv7511_wr(sd, 0xf9, 0x00); in adv7511_s_power()
538 adv7511_wr(sd, 0x43, state->i2c_edid_addr); in adv7511_s_power()
541 adv7511_wr(sd, 0xc9, 0xf); in adv7511_s_power()
546 static void adv7511_set_isr(struct v4l2_subdev *sd, bool enable) in adv7511_set_isr() argument
552 v4l2_dbg(2, debug, sd, "%s: %s\n", __func__, enable ? "enable" : "disable"); in adv7511_set_isr()
558 else if (adv7511_have_hotplug(sd)) in adv7511_set_isr()
570 adv7511_wr(sd, 0x94, irqs); in adv7511_set_isr()
571 irqs_rd = adv7511_rd(sd, 0x94); in adv7511_set_isr()
576 v4l2_err(sd, "Could not set interrupts: hw failure?\n"); in adv7511_set_isr()
580 static int adv7511_isr(struct v4l2_subdev *sd, u32 status, bool *handled) in adv7511_isr() argument
585 adv7511_set_isr(sd, false); in adv7511_isr()
586 irq_status = adv7511_rd(sd, 0x96); in adv7511_isr()
588 adv7511_wr(sd, 0x96, irq_status); in adv7511_isr()
590 v4l2_dbg(1, debug, sd, "%s: irq 0x%x\n", __func__, irq_status); in adv7511_isr()
593 adv7511_check_monitor_present_status(sd); in adv7511_isr()
595 adv7511_check_edid_status(sd); in adv7511_isr()
598 adv7511_set_isr(sd, true); in adv7511_isr()
618 static int adv7511_s_stream(struct v4l2_subdev *sd, int enable) in adv7511_s_stream() argument
620 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_stream()
622 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in adv7511_s_stream()
623 adv7511_wr_and_or(sd, 0xa1, ~0x3c, (enable ? 0 : 0x3c)); in adv7511_s_stream()
625 adv7511_check_monitor_present_status(sd); in adv7511_s_stream()
627 adv7511_s_power(sd, 0); in adv7511_s_stream()
633 static int adv7511_s_dv_timings(struct v4l2_subdev *sd, in adv7511_s_dv_timings() argument
636 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_s_dv_timings()
638 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_s_dv_timings()
654 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in adv7511_s_dv_timings()
657 adv7511_set_IT_content_AVI_InfoFrame(sd); in adv7511_s_dv_timings()
662 static int adv7511_g_dv_timings(struct v4l2_subdev *sd, in adv7511_g_dv_timings() argument
665 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_g_dv_timings()
667 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_g_dv_timings()
677 static int adv7511_enum_dv_timings(struct v4l2_subdev *sd, in adv7511_enum_dv_timings() argument
686 static int adv7511_dv_timings_cap(struct v4l2_subdev *sd, in adv7511_dv_timings_cap() argument
703 static int adv7511_s_audio_stream(struct v4l2_subdev *sd, int enable) in adv7511_s_audio_stream() argument
705 v4l2_dbg(1, debug, sd, "%s: %sable\n", __func__, (enable ? "en" : "dis")); in adv7511_s_audio_stream()
708 adv7511_wr_and_or(sd, 0x4b, 0x3f, 0x80); in adv7511_s_audio_stream()
710 adv7511_wr_and_or(sd, 0x4b, 0x3f, 0x40); in adv7511_s_audio_stream()
715 static int adv7511_s_clock_freq(struct v4l2_subdev *sd, u32 freq) in adv7511_s_clock_freq() argument
732 adv7511_wr(sd, 0x01, (N >> 16) & 0xf); in adv7511_s_clock_freq()
733 adv7511_wr(sd, 0x02, (N >> 8) & 0xff); in adv7511_s_clock_freq()
734 adv7511_wr(sd, 0x03, N & 0xff); in adv7511_s_clock_freq()
739 static int adv7511_s_i2s_clock_freq(struct v4l2_subdev *sd, u32 freq) in adv7511_s_i2s_clock_freq() argument
756 adv7511_wr_and_or(sd, 0x15, 0xf, i2s_sf); in adv7511_s_i2s_clock_freq()
761 static int adv7511_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) in adv7511_s_routing() argument
764 adv7511_wr_and_or(sd, 0x73, 0xf8, 0x1); in adv7511_s_routing()
766 adv7511_wr(sd, 0x76, 0x00); in adv7511_s_routing()
769 adv7511_wr_and_or(sd, 0x14, 0xf0, 0x02); in adv7511_s_routing()
783 static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) in adv7511_get_edid() argument
785 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_get_edid()
812 static int adv7511_enum_mbus_code(struct v4l2_subdev *sd, in adv7511_enum_mbus_code() argument
845 static int adv7511_get_fmt(struct v4l2_subdev *sd, in adv7511_get_fmt() argument
849 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_get_fmt()
859 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in adv7511_get_fmt()
874 static int adv7511_set_fmt(struct v4l2_subdev *sd, in adv7511_set_fmt() argument
878 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_set_fmt()
910 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); in adv7511_set_fmt()
920 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); in adv7511_set_fmt()
921 adv7511_wr_and_or(sd, 0x16, 0x03, 0xb8); in adv7511_set_fmt()
925 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x01); in adv7511_set_fmt()
926 adv7511_wr_and_or(sd, 0x16, 0x03, 0xbc); in adv7511_set_fmt()
931 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x00); in adv7511_set_fmt()
932 adv7511_wr_and_or(sd, 0x16, 0x03, 0x00); in adv7511_set_fmt()
1002 adv7511_wr_and_or(sd, 0x4a, 0xbf, 0); in adv7511_set_fmt()
1003 adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5); in adv7511_set_fmt()
1004 adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6); in adv7511_set_fmt()
1005 adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2)); in adv7511_set_fmt()
1006 adv7511_wr_and_or(sd, 0x59, 0x0f, yq << 4); in adv7511_set_fmt()
1007 adv7511_wr_and_or(sd, 0x4a, 0xff, 1); in adv7511_set_fmt()
1031 static void adv7511_dbg_dump_edid(int lvl, int debug, struct v4l2_subdev *sd, int segment, uint8_t … in adv7511_dbg_dump_edid() argument
1035 v4l2_dbg(lvl, debug, sd, "edid segment %d\n", segment); in adv7511_dbg_dump_edid()
1040 v4l2_dbg(lvl, debug, sd, "\n"); in adv7511_dbg_dump_edid()
1046 v4l2_dbg(lvl, debug, sd, "%s\n", b); in adv7511_dbg_dump_edid()
1051 static void adv7511_notify_no_edid(struct v4l2_subdev *sd) in adv7511_notify_no_edid() argument
1053 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_notify_no_edid()
1058 ed.segment = adv7511_rd(sd, 0xc4); in adv7511_notify_no_edid()
1059 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed); in adv7511_notify_no_edid()
1067 struct v4l2_subdev *sd = &state->sd; in adv7511_edid_handler() local
1069 v4l2_dbg(1, debug, sd, "%s:\n", __func__); in adv7511_edid_handler()
1071 if (adv7511_check_edid_status(sd)) { in adv7511_edid_handler()
1076 if (adv7511_have_hotplug(sd)) { in adv7511_edid_handler()
1082 v4l2_dbg(1, debug, sd, "%s: edid read failed\n", __func__); in adv7511_edid_handler()
1084 adv7511_s_power(sd, false); in adv7511_edid_handler()
1085 adv7511_s_power(sd, true); in adv7511_edid_handler()
1092 adv7511_notify_no_edid(sd); in adv7511_edid_handler()
1093 v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__); in adv7511_edid_handler()
1096 static void adv7511_audio_setup(struct v4l2_subdev *sd) in adv7511_audio_setup() argument
1098 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_audio_setup()
1100 adv7511_s_i2s_clock_freq(sd, 48000); in adv7511_audio_setup()
1101 adv7511_s_clock_freq(sd, 48000); in adv7511_audio_setup()
1102 adv7511_s_routing(sd, 0, 0, 0); in adv7511_audio_setup()
1106 static void adv7511_setup(struct v4l2_subdev *sd) in adv7511_setup() argument
1108 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_setup()
1109 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_setup()
1112 adv7511_wr_and_or(sd, 0x15, 0xf0, 0x0); in adv7511_setup()
1114 adv7511_wr_and_or(sd, 0x16, 0x7f, 0x0); in adv7511_setup()
1116 adv7511_wr_and_or(sd, 0x17, 0xf9, 0x06); in adv7511_setup()
1118 adv7511_wr_and_or(sd, 0x3b, 0x9f, 0x0); in adv7511_setup()
1120 adv7511_wr_and_or(sd, 0x18, 0x7f, 0x0); in adv7511_setup()
1123 adv7511_wr_and_or(sd, 0x55, 0x9c, 0x12); in adv7511_setup()
1125 adv7511_wr_and_or(sd, 0x44, 0xe7, 0x10); in adv7511_setup()
1127 adv7511_wr(sd, 0x56, 0xa8); in adv7511_setup()
1129 adv7511_wr_and_or(sd, 0xaf, 0xed, 0x0); in adv7511_setup()
1132 adv7511_wr_and_or(sd, 0xba, 0x1f, 0x60); in adv7511_setup()
1134 adv7511_audio_setup(sd); in adv7511_setup()
1139 static void adv7511_notify_monitor_detect(struct v4l2_subdev *sd) in adv7511_notify_monitor_detect() argument
1142 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_notify_monitor_detect()
1145 v4l2_subdev_notify(sd, ADV7511_MONITOR_DETECT, (void *)&mdt); in adv7511_notify_monitor_detect()
1148 static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd) in adv7511_check_monitor_present_status() argument
1150 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_check_monitor_present_status()
1152 uint8_t status = adv7511_rd(sd, 0x42); in adv7511_check_monitor_present_status()
1154 v4l2_dbg(1, debug, sd, "%s: status: 0x%x%s%s\n", in adv7511_check_monitor_present_status()
1161 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1162 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1165 v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__); in adv7511_check_monitor_present_status()
1167 v4l2_dbg(1, debug, sd, "%s: monitor detected\n", __func__); in adv7511_check_monitor_present_status()
1169 adv7511_set_isr(sd, true); in adv7511_check_monitor_present_status()
1170 if (!adv7511_s_power(sd, true)) { in adv7511_check_monitor_present_status()
1171 v4l2_dbg(1, debug, sd, "%s: monitor detected, powerup failed\n", __func__); in adv7511_check_monitor_present_status()
1174 adv7511_setup(sd); in adv7511_check_monitor_present_status()
1175 adv7511_notify_monitor_detect(sd); in adv7511_check_monitor_present_status()
1180 v4l2_dbg(1, debug, sd, "%s: hotplug detected\n", __func__); in adv7511_check_monitor_present_status()
1184 v4l2_dbg(1, debug, sd, "%s: hotplug not detected\n", __func__); in adv7511_check_monitor_present_status()
1186 v4l2_dbg(1, debug, sd, "%s: monitor not detected\n", __func__); in adv7511_check_monitor_present_status()
1188 adv7511_notify_monitor_detect(sd); in adv7511_check_monitor_present_status()
1190 adv7511_s_power(sd, false); in adv7511_check_monitor_present_status()
1192 adv7511_notify_no_edid(sd); in adv7511_check_monitor_present_status()
1206 static bool edid_verify_crc(struct v4l2_subdev *sd, u32 segment) in edid_verify_crc() argument
1208 struct adv7511_state *state = get_adv7511_state(sd); in edid_verify_crc()
1219 static bool edid_verify_header(struct v4l2_subdev *sd, u32 segment) in edid_verify_header() argument
1224 struct adv7511_state *state = get_adv7511_state(sd); in edid_verify_header()
1232 static bool adv7511_check_edid_status(struct v4l2_subdev *sd) in adv7511_check_edid_status() argument
1234 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_check_edid_status()
1235 uint8_t edidRdy = adv7511_rd(sd, 0xc5); in adv7511_check_edid_status()
1237 v4l2_dbg(1, debug, sd, "%s: edid ready (retries: %d)\n", in adv7511_check_edid_status()
1244 int segment = adv7511_rd(sd, 0xc4); in adv7511_check_edid_status()
1248 v4l2_err(sd, "edid segment number too big\n"); in adv7511_check_edid_status()
1251 v4l2_dbg(1, debug, sd, "%s: got segment %d\n", __func__, segment); in adv7511_check_edid_status()
1252 adv7511_edid_rd(sd, 256, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1253 adv7511_dbg_dump_edid(2, debug, sd, segment, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1256 v4l2_dbg(1, debug, sd, "%s: %d blocks in total\n", __func__, state->edid.blocks); in adv7511_check_edid_status()
1258 if (!edid_verify_crc(sd, segment) || in adv7511_check_edid_status()
1259 !edid_verify_header(sd, segment)) { in adv7511_check_edid_status()
1261 v4l2_err(sd, "%s: edid crc or header error\n", __func__); in adv7511_check_edid_status()
1263 adv7511_s_power(sd, false); in adv7511_check_edid_status()
1264 adv7511_s_power(sd, true); in adv7511_check_edid_status()
1272 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1273 adv7511_wr(sd, 0xc9, 0xf); in adv7511_check_edid_status()
1274 adv7511_wr(sd, 0xc4, state->edid.segments); in adv7511_check_edid_status()
1280 v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1289 v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed); in adv7511_check_edid_status()
1298 static void adv7511_init_setup(struct v4l2_subdev *sd) in adv7511_init_setup() argument
1300 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_init_setup()
1303 v4l2_dbg(1, debug, sd, "%s\n", __func__); in adv7511_init_setup()
1306 adv7511_wr(sd, 0x96, 0xff); in adv7511_init_setup()
1312 adv7511_wr_and_or(sd, 0xd6, 0x3f, 0xc0); in adv7511_init_setup()
1315 adv7511_set_isr(sd, false); in adv7511_init_setup()
1316 adv7511_s_stream(sd, false); in adv7511_init_setup()
1317 adv7511_s_audio_stream(sd, false); in adv7511_init_setup()
1325 struct v4l2_subdev *sd; in adv7511_probe() local
1346 sd = &state->sd; in adv7511_probe()
1348 v4l2_dbg(1, debug, sd, "detecting adv7511 client on address 0x%x\n", in adv7511_probe()
1351 v4l2_i2c_subdev_init(sd, client, &adv7511_ops); in adv7511_probe()
1369 sd->ctrl_handler = hdl; in adv7511_probe()
1381 err = media_entity_init(&sd->entity, 1, &state->pad, 0); in adv7511_probe()
1389 state->chip_revision = adv7511_rd(sd, 0x0); in adv7511_probe()
1390 chip_id[0] = adv7511_rd(sd, 0xf5); in adv7511_probe()
1391 chip_id[1] = adv7511_rd(sd, 0xf6); in adv7511_probe()
1393 v4l2_err(sd, "chip_id != 0x7511, read 0x%02x%02x\n", chip_id[0], chip_id[1]); in adv7511_probe()
1400 v4l2_err(sd, "failed to register edid i2c client\n"); in adv7511_probe()
1405 adv7511_wr(sd, 0xe2, 0x01); /* power down cec section */ in adv7511_probe()
1406 state->work_queue = create_singlethread_workqueue(sd->name); in adv7511_probe()
1408 v4l2_err(sd, "could not create workqueue\n"); in adv7511_probe()
1415 adv7511_init_setup(sd); in adv7511_probe()
1416 adv7511_set_isr(sd, true); in adv7511_probe()
1417 adv7511_check_monitor_present_status(sd); in adv7511_probe()
1419 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in adv7511_probe()
1426 media_entity_cleanup(&sd->entity); in adv7511_probe()
1436 struct v4l2_subdev *sd = i2c_get_clientdata(client); in adv7511_remove() local
1437 struct adv7511_state *state = get_adv7511_state(sd); in adv7511_remove()
1441 v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, in adv7511_remove()
1444 adv7511_init_setup(sd); in adv7511_remove()
1448 v4l2_device_unregister_subdev(sd); in adv7511_remove()
1449 media_entity_cleanup(&sd->entity); in adv7511_remove()
1450 v4l2_ctrl_handler_free(sd->ctrl_handler); in adv7511_remove()