Lines Matching +full:sense +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0-only
10 * REF_01 - Analog Devices, Programming Guide, AD9889B/AD9389B,
21 #include <linux/v4l2-dv-timings.h>
22 #include <media/v4l2-device.h>
23 #include <media/v4l2-common.h>
24 #include <media/v4l2-dv-timings.h>
25 #include <media/v4l2-ctrls.h>
30 MODULE_PARM_DESC(debug, "debug level (0-2)");
75 /* Did we receive hotplug and rx-sense signals? */
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);
105 return &container_of(ctrl->handler, struct ad9389b_state, hdl)->sd; in to_sd()
108 /* ------------------------ I2C ----------------------------------------------- */
132 /* To set specific bits in the register, a clear-mask is given (to be AND-ed),
133 and then the value-mask (to be OR-ed). */
148 buf[i] = i2c_smbus_read_byte_data(state->edid_i2c_client, i); in ad9389b_edid_rd()
210 4096-564, 0, 0, 256, in ad9389b_csc_rgb_full2limit()
211 0, 4096-564, 0, 256, in ad9389b_csc_rgb_full2limit()
212 0, 0, 4096-564, 256); in ad9389b_csc_rgb_full2limit()
215 /* AVI infoframe: Limited range RGB (16-235) */ in ad9389b_csc_rgb_full2limit()
220 /* AVI infoframe: Full range RGB (0-255) */ in ad9389b_csc_rgb_full2limit()
229 if (state->dv_timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) { in ad9389b_set_IT_content_AVI_InfoFrame()
242 switch (ctrl->val) { in ad9389b_set_rgb_quantization_mode()
245 if (state->dv_timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) { in ad9389b_set_rgb_quantization_mode()
246 /* CE format, RGB limited range (16-235) */ in ad9389b_set_rgb_quantization_mode()
249 /* not CE format, RGB full range (0-255) */ in ad9389b_set_rgb_quantization_mode()
254 /* RGB limited range (16-235) */ in ad9389b_set_rgb_quantization_mode()
258 /* RGB full range (0-255) */ in ad9389b_set_rgb_quantization_mode()
262 return -EINVAL; in ad9389b_set_rgb_quantization_mode()
298 /* ------------------------------ CTRL OPS ------------------------------ */
306 "%s: ctrl id: %d, ctrl->val %d\n", __func__, ctrl->id, ctrl->val); in ad9389b_s_ctrl()
308 if (state->hdmi_mode_ctrl == ctrl) { in ad9389b_s_ctrl()
309 /* Set HDMI or DVI-D */ in ad9389b_s_ctrl()
311 ctrl->val == V4L2_DV_TX_MODE_HDMI ? 0x02 : 0x00); in ad9389b_s_ctrl()
314 if (state->rgb_quantization_range_ctrl == ctrl) in ad9389b_s_ctrl()
316 return -EINVAL; in ad9389b_s_ctrl()
323 /* ---------------------------- CORE OPS ------------------------------------------- */
328 reg->val = ad9389b_rd(sd, reg->reg & 0xff); in ad9389b_g_register()
329 reg->size = 1; in ad9389b_g_register()
335 ad9389b_wr(sd, reg->reg & 0xff, reg->val & 0xff); in ad9389b_s_register()
343 struct ad9389b_state_edid *edid = &state->edid; 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()
376 edid->segments ? "found" : "no", edid->blocks); in ad9389b_log_status()
379 "HDMI" : "DVI-D", in ad9389b_log_status()
387 state->edid_detect_counter, in ad9389b_log_status()
424 if (state->dv_timings.type == V4L2_DV_BT_656_1120) in ad9389b_log_status()
425 v4l2_print_dv_timings(sd->name, "timings: ", in ad9389b_log_status()
426 &state->dv_timings, false); in ad9389b_log_status()
436 struct ad9389b_platform_data *pdata = &state->pdata; in ad9389b_s_power()
442 state->power_on = on; in ad9389b_s_power()
478 if (pdata->diff_data_drive_strength > 0) in ad9389b_s_power()
479 ad9389b_wr(sd, 0xa2, pdata->diff_data_drive_strength); in ad9389b_s_power()
483 if (pdata->diff_clk_drive_strength > 0) in ad9389b_s_power()
484 ad9389b_wr(sd, 0xa3, pdata->diff_clk_drive_strength); in ad9389b_s_power()
521 } while (retries-- && irqs_rd != irqs); in ad9389b_set_isr()
561 /* ------------------------------ VIDEO OPS ------------------------------ */
597 return -EINVAL; in ad9389b_s_dv_timings()
603 timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS; in ad9389b_s_dv_timings()
606 state->dv_timings = *timings; in ad9389b_s_dv_timings()
609 ad9389b_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in ad9389b_s_dv_timings()
612 if (state->pdata.tmds_pll_gear == AD9389B_TMDS_PLL_GEAR_SEMI_AUTOMATIC) in ad9389b_s_dv_timings()
613 ad9389b_set_manual_pll_gear(sd, (u32)timings->bt.pixelclock); in ad9389b_s_dv_timings()
629 return -EINVAL; in ad9389b_g_dv_timings()
631 *timings = state->dv_timings; in ad9389b_g_dv_timings()
639 if (timings->pad != 0) in ad9389b_enum_dv_timings()
640 return -EINVAL; in ad9389b_enum_dv_timings()
649 if (cap->pad != 0) in ad9389b_dv_timings_cap()
650 return -EINVAL; in ad9389b_dv_timings_cap()
662 /* ------------------------------ PAD OPS ------------------------------ */
668 if (edid->pad != 0) in ad9389b_get_edid()
669 return -EINVAL; in ad9389b_get_edid()
670 if (edid->blocks == 0 || edid->blocks > 256) in ad9389b_get_edid()
671 return -EINVAL; in ad9389b_get_edid()
672 if (!state->edid.segments) { in ad9389b_get_edid()
674 return -ENODATA; in ad9389b_get_edid()
676 if (edid->start_block >= state->edid.segments * 2) in ad9389b_get_edid()
677 return -E2BIG; in ad9389b_get_edid()
678 if (edid->blocks + edid->start_block >= state->edid.segments * 2) in ad9389b_get_edid()
679 edid->blocks = state->edid.segments * 2 - edid->start_block; in ad9389b_get_edid()
680 memcpy(edid->edid, &state->edid.data[edid->start_block * 128], in ad9389b_get_edid()
681 128 * edid->blocks); in ad9389b_get_edid()
691 /* ------------------------------ AUDIO OPS ------------------------------ */
705 static int ad9389b_s_clock_freq(struct v4l2_subdev *sd, u32 freq) in ad9389b_s_clock_freq() argument
709 switch (freq) { in ad9389b_s_clock_freq()
718 return -EINVAL; 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
733 switch (freq) { in ad9389b_s_i2s_clock_freq()
742 return -EINVAL; in ad9389b_s_i2s_clock_freq()
754 /* TODO See datasheet "Programmers guide" p. 39-40 */ in ad9389b_s_routing()
775 /* --------------------- SUBDEV OPS --------------------------------------- */
784 /* ----------------------------------------------------------------------- */
814 struct v4l2_subdev *sd = &state->sd; in ad9389b_edid_handler()
828 if (state->edid.read_retries) { in ad9389b_edid_handler()
829 state->edid.read_retries--; in ad9389b_edid_handler()
833 schedule_delayed_work(&state->edid_handler, EDID_DELAY); in ad9389b_edid_handler()
867 /* 1st order interpolation 4:2:2 -> 4:4:4 up conversion, in ad9389b_setup()
885 v4l2_ctrl_handler_setup(&state->hdl); in ad9389b_setup()
895 mdt.present = state->have_monitor; in ad9389b_notify_monitor_detect()
902 /* read hotplug and rx-sense state */ in ad9389b_update_monitor_present_status()
909 status & MASK_AD9389B_MSEN_DETECT ? ", rx-sense" : ""); in ad9389b_update_monitor_present_status()
913 state->have_monitor = true; in ad9389b_update_monitor_present_status()
921 state->edid.read_retries = EDID_MAX_RETRIES; in ad9389b_update_monitor_present_status()
922 schedule_delayed_work(&state->edid_handler, EDID_DELAY); in ad9389b_update_monitor_present_status()
925 state->have_monitor = false; in ad9389b_update_monitor_present_status()
928 memset(&state->edid, 0, sizeof(struct ad9389b_state_edid)); 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()
934 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0); in ad9389b_update_monitor_present_status()
937 ad9389b_s_ctrl(state->rgb_quantization_range_ctrl); in ad9389b_update_monitor_present_status()
938 ad9389b_s_ctrl(state->hdmi_mode_ctrl); in ad9389b_update_monitor_present_status()
952 while (state->power_on && (ad9389b_rd(sd, 0x41) & 0x40)) { 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()
959 cancel_delayed_work_sync(&state->edid_handler); in ad9389b_check_monitor_present_status()
960 memset(&state->edid, 0, sizeof(struct ad9389b_state_edid)); in ad9389b_check_monitor_present_status()
979 u32 blocks = state->edid.blocks; in edid_verify_crc()
980 u8 *data = state->edid.data; in edid_verify_crc()
996 u8 *data = state->edid.data; in edid_verify_header()
1017 __func__, EDID_MAX_RETRIES - state->edid.read_retries); in ad9389b_check_edid_status()
1028 ad9389b_edid_rd(sd, 256, &state->edid.data[segment * 256]); in ad9389b_check_edid_status()
1030 &state->edid.data[segment * 256]); in ad9389b_check_edid_status()
1032 state->edid.blocks = state->edid.data[0x7e] + 1; in ad9389b_check_edid_status()
1034 __func__, state->edid.blocks); in ad9389b_check_edid_status()
1045 state->edid.segments = segment + 1; in ad9389b_check_edid_status()
1046 if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) { in ad9389b_check_edid_status()
1049 __func__, state->edid.segments); in ad9389b_check_edid_status()
1051 ad9389b_wr(sd, 0xc4, state->edid.segments); in ad9389b_check_edid_status()
1052 state->edid.read_retries = EDID_MAX_RETRIES; in ad9389b_check_edid_status()
1053 schedule_delayed_work(&state->edid_handler, EDID_DELAY); in ad9389b_check_edid_status()
1061 state->edid_detect_counter++; in ad9389b_check_edid_status()
1062 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0); in ad9389b_check_edid_status()
1066 /* ----------------------------------------------------------------------- */
1071 struct ad9389b_state_edid *edid = &state->edid; in ad9389b_init_setup()
1079 state->have_monitor = false; in ad9389b_init_setup()
1087 struct ad9389b_platform_data *pdata = client->dev.platform_data; in ad9389b_probe()
1090 int err = -EIO; in ad9389b_probe()
1093 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in ad9389b_probe()
1094 return -EIO; in ad9389b_probe()
1097 client->addr << 1); in ad9389b_probe()
1099 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); in ad9389b_probe()
1101 return -ENOMEM; in ad9389b_probe()
1106 return -ENODEV; in ad9389b_probe()
1108 memcpy(&state->pdata, pdata, sizeof(state->pdata)); in ad9389b_probe()
1110 sd = &state->sd; in ad9389b_probe()
1112 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in ad9389b_probe()
1114 hdl = &state->hdl; in ad9389b_probe()
1117 state->hdmi_mode_ctrl = v4l2_ctrl_new_std_menu(hdl, &ad9389b_ctrl_ops, in ad9389b_probe()
1120 state->hotplug_ctrl = v4l2_ctrl_new_std(hdl, NULL, in ad9389b_probe()
1122 state->rx_sense_ctrl = v4l2_ctrl_new_std(hdl, NULL, in ad9389b_probe()
1124 state->have_edid0_ctrl = v4l2_ctrl_new_std(hdl, NULL, in ad9389b_probe()
1126 state->rgb_quantization_range_ctrl = in ad9389b_probe()
1130 sd->ctrl_handler = hdl; in ad9389b_probe()
1131 if (hdl->error) { in ad9389b_probe()
1132 err = hdl->error; in ad9389b_probe()
1136 state->pad.flags = MEDIA_PAD_FL_SINK; 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()
1143 if (state->chip_revision != 2) { in ad9389b_probe()
1144 v4l2_err(sd, "chip_revision %d != 2\n", state->chip_revision); in ad9389b_probe()
1145 err = -EIO; in ad9389b_probe()
1149 ad9389b_rd(sd, 0x41), state->chip_revision); in ad9389b_probe()
1151 state->edid_i2c_client = i2c_new_dummy_device(client->adapter, (0x7e >> 1)); in ad9389b_probe()
1152 if (IS_ERR(state->edid_i2c_client)) { in ad9389b_probe()
1154 err = PTR_ERR(state->edid_i2c_client); in ad9389b_probe()
1158 INIT_DELAYED_WORK(&state->edid_handler, ad9389b_edid_handler); in ad9389b_probe()
1159 state->dv_timings = dv1080p60; in ad9389b_probe()
1164 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in ad9389b_probe()
1165 client->addr << 1, client->adapter->name); in ad9389b_probe()
1169 media_entity_cleanup(&sd->entity); in ad9389b_probe()
1171 v4l2_ctrl_handler_free(&state->hdl); in ad9389b_probe()
1175 /* ----------------------------------------------------------------------- */
1182 state->chip_revision = -1; in ad9389b_remove()
1184 v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, in ad9389b_remove()
1185 client->addr << 1, client->adapter->name); in ad9389b_remove()
1190 cancel_delayed_work_sync(&state->edid_handler); in ad9389b_remove()
1191 i2c_unregister_device(state->edid_i2c_client); in ad9389b_remove()
1193 media_entity_cleanup(&sd->entity); in ad9389b_remove()
1194 v4l2_ctrl_handler_free(sd->ctrl_handler); in ad9389b_remove()
1198 /* ----------------------------------------------------------------------- */