Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0-only
9 * This file is named adv7511-v4l2.c so it doesn't conflict with the Analog
22 #include <linux/v4l2-dv-timings.h>
23 #include <media/v4l2-device.h>
24 #include <media/v4l2-common.h>
25 #include <media/v4l2-ctrls.h>
26 #include <media/v4l2-dv-timings.h>
32 MODULE_PARM_DESC(debug, "debug level (0-2)");
94 /* Did we receive hotplug and rx-sense signals? */
150 return &container_of(ctrl->handler, struct adv7511_state, hdl)->sd; in to_sd()
153 /* ------------------------ I2C ----------------------------------------------- */
160 if (!i2c_smbus_xfer(client->adapter, client->addr, client->flags, in adv_smbus_read_byte_data_check()
166 client->addr, command); in adv_smbus_read_byte_data_check()
167 return -1; in adv_smbus_read_byte_data_check()
182 return -1; in adv_smbus_read_byte_data()
207 /* To set specific bits in the register, a clear-mask is given (to be AND-ed),
208 and then the value-mask (to be OR-ed). */
224 ret = i2c_smbus_read_i2c_block_data(state->i2c_edid, i, in adv7511_edid_rd()
239 return i2c_smbus_read_byte_data(state->i2c_cec, reg); in adv7511_cec_read()
249 ret = i2c_smbus_write_byte_data(state->i2c_cec, reg, val); in adv7511_cec_write()
267 return adv_smbus_read_byte_data(state->i2c_pktmem, reg); in adv7511_pktmem_rd()
327 4096-564, 0, 0, 256, in adv7511_csc_rgb_full2limit()
328 0, 4096-564, 0, 256, in adv7511_csc_rgb_full2limit()
329 0, 0, 4096-564, 256); in adv7511_csc_rgb_full2limit()
332 /* AVI infoframe: Limited range RGB (16-235) */ in adv7511_csc_rgb_full2limit()
337 /* AVI infoframe: Full range RGB (0-255) */ in adv7511_csc_rgb_full2limit()
346 /* Only makes sense for RGB formats */ in adv7511_set_rgb_quantization_mode()
347 if (state->fmt_code != MEDIA_BUS_FMT_RGB888_1X24) { in adv7511_set_rgb_quantization_mode()
353 switch (ctrl->val) { in adv7511_set_rgb_quantization_mode()
356 if (state->dv_timings.bt.flags & V4L2_DV_FL_IS_CE_VIDEO) { in adv7511_set_rgb_quantization_mode()
357 /* CE format, RGB limited range (16-235) */ in adv7511_set_rgb_quantization_mode()
360 /* not CE format, RGB full range (0-255) */ in adv7511_set_rgb_quantization_mode()
365 /* RGB limited range (16-235) */ in adv7511_set_rgb_quantization_mode()
369 /* RGB full range (0-255) */ in adv7511_set_rgb_quantization_mode()
375 /* ------------------------------ CTRL OPS ------------------------------ */
382 v4l2_dbg(1, debug, sd, "%s: ctrl id: %d, ctrl->val %d\n", __func__, ctrl->id, ctrl->val); in adv7511_s_ctrl()
384 if (state->hdmi_mode_ctrl == ctrl) { in adv7511_s_ctrl()
385 /* Set HDMI or DVI-D */ in adv7511_s_ctrl()
386 adv7511_wr_and_or(sd, 0xaf, 0xfd, ctrl->val == V4L2_DV_TX_MODE_HDMI ? 0x02 : 0x00); in adv7511_s_ctrl()
389 if (state->rgb_quantization_range_ctrl == ctrl) { in adv7511_s_ctrl()
393 if (state->content_type_ctrl == ctrl) { in adv7511_s_ctrl()
396 state->content_type = ctrl->val; in adv7511_s_ctrl()
397 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC; in adv7511_s_ctrl()
398 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS; in adv7511_s_ctrl()
404 return -EINVAL; in adv7511_s_ctrl()
411 /* ---------------------------- CORE OPS ------------------------------------------- */
418 v4l2_info(sd, "0x000-0x0ff: Main Map\n"); in adv7511_inv_register()
419 if (state->i2c_cec) in adv7511_inv_register()
420 v4l2_info(sd, "0x100-0x1ff: CEC Map\n"); in adv7511_inv_register()
427 reg->size = 1; in adv7511_g_register()
428 switch (reg->reg >> 8) { in adv7511_g_register()
430 reg->val = adv7511_rd(sd, reg->reg & 0xff); in adv7511_g_register()
433 if (state->i2c_cec) { in adv7511_g_register()
434 reg->val = adv7511_cec_read(sd, reg->reg & 0xff); in adv7511_g_register()
439 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_g_register()
450 switch (reg->reg >> 8) { in adv7511_s_register()
452 adv7511_wr(sd, reg->reg & 0xff, reg->val & 0xff); in adv7511_s_register()
455 if (state->i2c_cec) { in adv7511_s_register()
456 adv7511_cec_write(sd, reg->reg & 0xff, reg->val & 0xff); in adv7511_s_register()
461 v4l2_info(sd, "Register %03llx not supported\n", reg->reg); in adv7511_s_register()
486 return 256 - csum; in hdmi_infoframe_checksum()
496 if (!(adv7511_rd(sd, cri->present_reg) & cri->present_mask)) { in read_infoframe()
497 v4l2_info(sd, "%s infoframe not transmitted\n", cri->desc); in read_infoframe()
501 memcpy(buffer, cri->header, sizeof(cri->header)); in read_infoframe()
506 v4l2_err(sd, "%s: invalid %s infoframe length %d\n", __func__, cri->desc, len); in read_infoframe()
510 if (cri->payload_addr >= 0x100) { in read_infoframe()
512 buffer[i + 4] = adv7511_pktmem_rd(sd, cri->payload_addr + i - 0x100); in read_infoframe()
515 buffer[i + 4] = adv7511_rd(sd, cri->payload_addr + i); in read_infoframe()
528 struct device *dev = &client->dev; in log_infoframe()
537 __func__, cri->desc); in log_infoframe()
561 struct adv7511_state_edid *edid = &state->edid; in adv7511_log_status()
586 v4l2_info(sd, "power %s\n", state->power_on ? "on" : "off"); in adv7511_log_status()
587 v4l2_info(sd, "%s hotplug, %s Rx Sense, %s EDID (%d block(s))\n", in adv7511_log_status()
590 edid->segments ? "found" : "no", in adv7511_log_status()
591 edid->blocks); in adv7511_log_status()
594 "HDMI" : "DVI-D", in adv7511_log_status()
599 errors[adv7511_rd(sd, 0xc8) >> 4], state->edid_detect_counter, in adv7511_log_status()
626 if (state->dv_timings.type == V4L2_DV_BT_656_1120) in adv7511_log_status()
627 v4l2_print_dv_timings(sd->name, "timings: ", in adv7511_log_status()
628 &state->dv_timings, false); in adv7511_log_status()
631 v4l2_info(sd, "i2c edid addr: 0x%x\n", state->i2c_edid_addr); in adv7511_log_status()
633 if (state->i2c_cec == NULL) in adv7511_log_status()
636 v4l2_info(sd, "i2c cec addr: 0x%x\n", state->i2c_cec_addr); in adv7511_log_status()
638 v4l2_info(sd, "CEC: %s\n", state->cec_enabled_adap ? in adv7511_log_status()
640 if (state->cec_enabled_adap) { in adv7511_log_status()
642 bool is_valid = state->cec_valid_addrs & (1 << i); in adv7511_log_status()
646 state->cec_addr[i]); in adv7511_log_status()
649 v4l2_info(sd, "i2c pktmem addr: 0x%x\n", state->i2c_pktmem_addr); in adv7511_log_status()
662 state->power_on = on; in adv7511_s_power()
698 adv7511_wr(sd, 0x43, state->i2c_edid_addr); in adv7511_s_power()
699 adv7511_wr(sd, 0x45, state->i2c_pktmem_addr); in adv7511_s_power()
710 struct v4l2_subdev *sd = &state->sd; in adv7511_cec_adap_enable()
712 if (state->i2c_cec == NULL) in adv7511_cec_adap_enable()
713 return -EIO; in adv7511_cec_adap_enable()
715 if (!state->cec_enabled_adap && enable) { in adv7511_cec_adap_enable()
727 if (state->enabled_irq) in adv7511_cec_adap_enable()
729 } else if (state->cec_enabled_adap && !enable) { in adv7511_cec_adap_enable()
730 if (state->enabled_irq) in adv7511_cec_adap_enable()
732 /* disable address mask 1-3 */ in adv7511_cec_adap_enable()
736 state->cec_valid_addrs = 0; in adv7511_cec_adap_enable()
738 state->cec_enabled_adap = enable; in adv7511_cec_adap_enable()
745 struct v4l2_subdev *sd = &state->sd; in adv7511_cec_adap_log_addr()
748 if (!state->cec_enabled_adap) in adv7511_cec_adap_log_addr()
749 return addr == CEC_LOG_ADDR_INVALID ? 0 : -EIO; in adv7511_cec_adap_log_addr()
753 state->cec_valid_addrs = 0; in adv7511_cec_adap_log_addr()
758 bool is_valid = state->cec_valid_addrs & (1 << i); in adv7511_cec_adap_log_addr()
762 if (is_valid && state->cec_addr[i] == addr) in adv7511_cec_adap_log_addr()
768 return -ENXIO; in adv7511_cec_adap_log_addr()
770 state->cec_addr[i] = addr; in adv7511_cec_adap_log_addr()
771 state->cec_valid_addrs |= 1 << i; in adv7511_cec_adap_log_addr()
800 struct v4l2_subdev *sd = &state->sd; in adv7511_cec_adap_transmit()
801 u8 len = msg->len; in adv7511_cec_adap_transmit()
808 return -EINVAL; in adv7511_cec_adap_transmit()
812 * The number of retries is the number of attempts - 1, but retry in adv7511_cec_adap_transmit()
816 adv7511_cec_write_and_or(sd, 0x12, ~0x70, max(1, attempts - 1) << 4); in adv7511_cec_adap_transmit()
823 adv7511_cec_write(sd, i, msg->msg[i]); in adv7511_cec_adap_transmit()
844 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_ARB_LOST, in adv_cec_tx_raw_status()
865 cec_transmit_done(state->cec_adap, status, in adv_cec_tx_raw_status()
871 cec_transmit_done(state->cec_adap, CEC_TX_STATUS_OK, 0, 0, 0, 0); in adv_cec_tx_raw_status()
893 if (state->enabled_irq == enable) in adv7511_set_isr()
895 state->enabled_irq = enable; in adv7511_set_isr()
915 } while (retries-- && irqs_rd != irqs); in adv7511_set_isr()
921 (state->cec_enabled_adap && enable) ? 0x39 : 0x00); in adv7511_set_isr()
938 v4l2_dbg(1, debug, sd, "%s: irq 0x%x, cec-irq 0x%x\n", __func__, in adv7511_isr()
968 adv7511_cec_write(sd, 0x4a, 0); /* toggle to re-enable rx 1 */ in adv7511_isr()
970 cec_received_msg(state->cec_adap, &msg); in adv7511_isr()
993 /* ------------------------------ VIDEO OPS ------------------------------ */
1006 state->have_monitor = false; in adv7511_s_stream()
1015 struct v4l2_bt_timings *bt = &timings->bt; in adv7511_s_dv_timings()
1021 return -EINVAL; in adv7511_s_dv_timings()
1025 return -EINVAL; in adv7511_s_dv_timings()
1032 state->dv_timings = *timings; in adv7511_s_dv_timings()
1036 ((bt->polarities & V4L2_DV_VSYNC_POS_POL) ? 0 : 0x40) | in adv7511_s_dv_timings()
1037 ((bt->polarities & V4L2_DV_HSYNC_POS_POL) ? 0 : 0x20)); in adv7511_s_dv_timings()
1039 fps = (u32)bt->pixelclock / (V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt)); in adv7511_s_dv_timings()
1056 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in adv7511_s_dv_timings()
1069 return -EINVAL; in adv7511_g_dv_timings()
1072 return -EINVAL; in adv7511_g_dv_timings()
1074 *timings = state->dv_timings; in adv7511_g_dv_timings()
1082 if (timings->pad != 0) in adv7511_enum_dv_timings()
1083 return -EINVAL; in adv7511_enum_dv_timings()
1091 if (cap->pad != 0) in adv7511_dv_timings_cap()
1092 return -EINVAL; in adv7511_dv_timings_cap()
1102 /* ------------------------------ AUDIO OPS ------------------------------ */
1128 return -EINVAL; in adv7511_s_clock_freq()
1152 return -EINVAL; in adv7511_s_i2s_clock_freq()
1181 /* ---------------------------- PAD OPS ------------------------------------- */
1187 memset(edid->reserved, 0, sizeof(edid->reserved)); in adv7511_get_edid()
1189 if (edid->pad != 0) in adv7511_get_edid()
1190 return -EINVAL; in adv7511_get_edid()
1192 if (edid->start_block == 0 && edid->blocks == 0) { in adv7511_get_edid()
1193 edid->blocks = state->edid.blocks; in adv7511_get_edid()
1197 if (state->edid.blocks == 0) in adv7511_get_edid()
1198 return -ENODATA; in adv7511_get_edid()
1200 if (edid->start_block >= state->edid.blocks) in adv7511_get_edid()
1201 return -EINVAL; in adv7511_get_edid()
1203 if (edid->start_block + edid->blocks > state->edid.blocks) in adv7511_get_edid()
1204 edid->blocks = state->edid.blocks - edid->start_block; in adv7511_get_edid()
1206 memcpy(edid->edid, &state->edid.data[edid->start_block * 128], in adv7511_get_edid()
1207 128 * edid->blocks); in adv7511_get_edid()
1216 if (code->pad != 0) in adv7511_enum_mbus_code()
1217 return -EINVAL; in adv7511_enum_mbus_code()
1219 switch (code->index) { in adv7511_enum_mbus_code()
1221 code->code = MEDIA_BUS_FMT_RGB888_1X24; in adv7511_enum_mbus_code()
1224 code->code = MEDIA_BUS_FMT_YUYV8_1X16; in adv7511_enum_mbus_code()
1227 code->code = MEDIA_BUS_FMT_UYVY8_1X16; in adv7511_enum_mbus_code()
1230 return -EINVAL; in adv7511_enum_mbus_code()
1238 format->width = state->dv_timings.bt.width; in adv7511_fill_format()
1239 format->height = state->dv_timings.bt.height; in adv7511_fill_format()
1240 format->field = V4L2_FIELD_NONE; in adv7511_fill_format()
1249 if (format->pad != 0) in adv7511_get_fmt()
1250 return -EINVAL; in adv7511_get_fmt()
1252 memset(&format->format, 0, sizeof(format->format)); in adv7511_get_fmt()
1253 adv7511_fill_format(state, &format->format); in adv7511_get_fmt()
1255 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in adv7511_get_fmt()
1258 fmt = v4l2_subdev_state_get_format(sd_state, format->pad); in adv7511_get_fmt()
1259 format->format.code = fmt->code; in adv7511_get_fmt()
1260 format->format.colorspace = fmt->colorspace; in adv7511_get_fmt()
1261 format->format.ycbcr_enc = fmt->ycbcr_enc; in adv7511_get_fmt()
1262 format->format.quantization = fmt->quantization; in adv7511_get_fmt()
1263 format->format.xfer_func = fmt->xfer_func; in adv7511_get_fmt()
1265 format->format.code = state->fmt_code; in adv7511_get_fmt()
1266 format->format.colorspace = state->colorspace; in adv7511_get_fmt()
1267 format->format.ycbcr_enc = state->ycbcr_enc; in adv7511_get_fmt()
1268 format->format.quantization = state->quantization; in adv7511_get_fmt()
1269 format->format.xfer_func = state->xfer_func; in adv7511_get_fmt()
1281 * Bitfield namings come the CEA-861-F standard, table 8 "Auxiliary in adv7511_set_fmt()
1295 u8 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC; in adv7511_set_fmt()
1296 u8 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS; in adv7511_set_fmt()
1298 if (format->pad != 0) in adv7511_set_fmt()
1299 return -EINVAL; in adv7511_set_fmt()
1300 switch (format->format.code) { in adv7511_set_fmt()
1306 return -EINVAL; in adv7511_set_fmt()
1309 adv7511_fill_format(state, &format->format); in adv7511_set_fmt()
1310 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in adv7511_set_fmt()
1313 fmt = v4l2_subdev_state_get_format(sd_state, format->pad); in adv7511_set_fmt()
1314 fmt->code = format->format.code; in adv7511_set_fmt()
1315 fmt->colorspace = format->format.colorspace; in adv7511_set_fmt()
1316 fmt->ycbcr_enc = format->format.ycbcr_enc; in adv7511_set_fmt()
1317 fmt->quantization = format->format.quantization; in adv7511_set_fmt()
1318 fmt->xfer_func = format->format.xfer_func; in adv7511_set_fmt()
1322 switch (format->format.code) { in adv7511_set_fmt()
1339 state->fmt_code = format->format.code; in adv7511_set_fmt()
1340 state->colorspace = format->format.colorspace; in adv7511_set_fmt()
1341 state->ycbcr_enc = format->format.ycbcr_enc; in adv7511_set_fmt()
1342 state->quantization = format->format.quantization; in adv7511_set_fmt()
1343 state->xfer_func = format->format.xfer_func; in adv7511_set_fmt()
1345 switch (format->format.colorspace) { in adv7511_set_fmt()
1353 if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_XV601) { in adv7511_set_fmt()
1360 if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_XV709) { in adv7511_set_fmt()
1372 if (y && format->format.ycbcr_enc == V4L2_YCBCR_ENC_BT2020_CONST_LUM) in adv7511_set_fmt()
1382 * CEA-861-F says that for RGB formats the YCC range must match the in adv7511_set_fmt()
1385 * The RGB quantization range shouldn't be non-zero if the EDID doesn't in adv7511_set_fmt()
1390 * The same is true for the YCC quantization range: non-standard YCC in adv7511_set_fmt()
1394 switch (format->format.quantization) { in adv7511_set_fmt()
1398 yq = q ? q - 1 : HDMI_YCC_QUANTIZATION_RANGE_FULL; in adv7511_set_fmt()
1403 yq = q ? q - 1 : HDMI_YCC_QUANTIZATION_RANGE_LIMITED; in adv7511_set_fmt()
1413 adv7511_set_rgb_quantization_mode(sd, state->rgb_quantization_range_ctrl); in adv7511_set_fmt()
1429 /* --------------------- SUBDEV OPS --------------------------------------- */
1438 /* ----------------------------------------------------------------------- */
1468 cec_s_phys_addr(state->cec_adap, ed.phys_addr, false); in adv7511_notify_no_edid()
1470 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x0); in adv7511_notify_no_edid()
1477 struct v4l2_subdev *sd = &state->sd; in adv7511_edid_handler()
1490 if (state->edid.read_retries) { in adv7511_edid_handler()
1491 state->edid.read_retries--; in adv7511_edid_handler()
1493 state->have_monitor = false; in adv7511_edid_handler()
1496 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY); in adv7511_edid_handler()
1525 /* 1st order interpolation 4:2:2 -> 4:4:4 up conversion, Aspect ratio: 16:9 */ in adv7511_setup()
1546 v4l2_ctrl_handler_setup(&state->hdl); in adv7511_setup()
1554 mdt.present = state->have_monitor; in adv7511_notify_monitor_detect()
1561 /* read hotplug and rx-sense state */ in adv7511_check_monitor_present_status()
1568 status & MASK_ADV7511_MSEN_DETECT ? ", rx-sense" : ""); in adv7511_check_monitor_present_status()
1571 v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1572 v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0); in adv7511_check_monitor_present_status()
1574 …if ((status & MASK_ADV7511_HPD_DETECT) && ((status & MASK_ADV7511_MSEN_DETECT) || state->edid.segm… in adv7511_check_monitor_present_status()
1575 v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__); in adv7511_check_monitor_present_status()
1576 if (!state->have_monitor) { in adv7511_check_monitor_present_status()
1578 state->have_monitor = true; in adv7511_check_monitor_present_status()
1586 state->edid.read_retries = EDID_MAX_RETRIES; in adv7511_check_monitor_present_status()
1587 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY); in adv7511_check_monitor_present_status()
1591 state->edid.read_retries = EDID_MAX_RETRIES; in adv7511_check_monitor_present_status()
1592 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY); in adv7511_check_monitor_present_status()
1595 if (state->have_monitor) { in adv7511_check_monitor_present_status()
1597 state->have_monitor = false; in adv7511_check_monitor_present_status()
1601 memset(&state->edid, 0, sizeof(struct adv7511_state_edid)); in adv7511_check_monitor_present_status()
1619 u32 blocks = state->edid.blocks; in edid_verify_crc()
1620 u8 *data = state->edid.data; in edid_verify_crc()
1635 u8 *data = state->edid.data; in edid_verify_header()
1648 __func__, EDID_MAX_RETRIES - state->edid.read_retries); in adv7511_check_edid_status()
1650 if (state->edid.complete) in adv7511_check_edid_status()
1663 err = adv7511_edid_rd(sd, 256, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1665 adv7511_dbg_dump_edid(2, debug, sd, segment, &state->edid.data[segment * 256]); in adv7511_check_edid_status()
1667 state->edid.blocks = in adv7511_check_edid_status()
1668 v4l2_num_edid_blocks(state->edid.data, in adv7511_check_edid_status()
1671 __func__, state->edid.blocks); in adv7511_check_edid_status()
1679 state->have_monitor = false; in adv7511_check_edid_status()
1685 state->edid.segments = segment + 1; in adv7511_check_edid_status()
1686 v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x1); in adv7511_check_edid_status()
1687 if (state->edid.blocks > state->edid.segments * 2) { in adv7511_check_edid_status()
1689 v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1691 adv7511_wr(sd, 0xc4, state->edid.segments); in adv7511_check_edid_status()
1692 state->edid.read_retries = EDID_MAX_RETRIES; in adv7511_check_edid_status()
1693 queue_delayed_work(state->work_queue, &state->edid_handler, EDID_DELAY); in adv7511_check_edid_status()
1697 v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments); in adv7511_check_edid_status()
1698 state->edid.complete = true; in adv7511_check_edid_status()
1699 ed.phys_addr = cec_get_edid_phys_addr(state->edid.data, in adv7511_check_edid_status()
1700 state->edid.segments * 256, in adv7511_check_edid_status()
1707 state->edid_detect_counter++; in adv7511_check_edid_status()
1708 cec_s_phys_addr(state->cec_adap, ed.phys_addr, false); in adv7511_check_edid_status()
1750 err = cec_register_adapter(state->cec_adap, &client->dev); in adv7511_registered()
1752 cec_delete_adapter(state->cec_adap); in adv7511_registered()
1756 state->debugfs_dir = debugfs_create_dir(sd->name, v4l2_debugfs_root()); in adv7511_registered()
1757 state->infoframes = v4l2_debugfs_if_alloc(state->debugfs_dir, in adv7511_registered()
1767 cec_unregister_adapter(state->cec_adap); in adv7511_unregistered()
1768 v4l2_debugfs_if_free(state->infoframes); in adv7511_unregistered()
1769 state->infoframes = NULL; in adv7511_unregistered()
1770 debugfs_remove_recursive(state->debugfs_dir); in adv7511_unregistered()
1771 state->debugfs_dir = NULL; in adv7511_unregistered()
1779 /* ----------------------------------------------------------------------- */
1784 struct adv7511_state_edid *edid = &state->edid; in adv7511_init_setup()
1785 u32 cec_clk = state->pdata.cec_clk; in adv7511_init_setup()
1795 * It might leave the chip in a partly un-initialized state, in adv7511_init_setup()
1800 state->have_monitor = false; in adv7511_init_setup()
1805 if (state->i2c_cec == NULL) in adv7511_init_setup()
1822 ratio = (cec_clk / 750000) - 1; in adv7511_init_setup()
1829 struct adv7511_platform_data *pdata = client->dev.platform_data; in adv7511_probe()
1833 int err = -EIO; in adv7511_probe()
1836 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in adv7511_probe()
1837 return -EIO; in adv7511_probe()
1839 state = devm_kzalloc(&client->dev, sizeof(struct adv7511_state), GFP_KERNEL); in adv7511_probe()
1841 return -ENOMEM; in adv7511_probe()
1846 return -ENODEV; in adv7511_probe()
1848 memcpy(&state->pdata, pdata, sizeof(state->pdata)); in adv7511_probe()
1849 state->fmt_code = MEDIA_BUS_FMT_RGB888_1X24; in adv7511_probe()
1850 state->colorspace = V4L2_COLORSPACE_SRGB; in adv7511_probe()
1852 sd = &state->sd; in adv7511_probe()
1855 client->addr << 1); in adv7511_probe()
1858 sd->internal_ops = &adv7511_int_ops; in adv7511_probe()
1860 hdl = &state->hdl; in adv7511_probe()
1863 state->hdmi_mode_ctrl = v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops, in adv7511_probe()
1866 state->hotplug_ctrl = v4l2_ctrl_new_std(hdl, NULL, in adv7511_probe()
1868 state->rx_sense_ctrl = v4l2_ctrl_new_std(hdl, NULL, in adv7511_probe()
1870 state->have_edid0_ctrl = v4l2_ctrl_new_std(hdl, NULL, in adv7511_probe()
1872 state->rgb_quantization_range_ctrl = in adv7511_probe()
1876 state->content_type_ctrl = in adv7511_probe()
1880 sd->ctrl_handler = hdl; in adv7511_probe()
1881 if (hdl->error) { in adv7511_probe()
1882 err = hdl->error; in adv7511_probe()
1885 state->pad.flags = MEDIA_PAD_FL_SINK; in adv7511_probe()
1886 sd->entity.function = MEDIA_ENT_F_DV_ENCODER; in adv7511_probe()
1887 err = media_entity_pads_init(&sd->entity, 1, &state->pad); in adv7511_probe()
1892 state->i2c_edid_addr = state->pdata.i2c_edid << 1; in adv7511_probe()
1893 state->i2c_cec_addr = state->pdata.i2c_cec << 1; in adv7511_probe()
1894 state->i2c_pktmem_addr = state->pdata.i2c_pktmem << 1; in adv7511_probe()
1896 state->chip_revision = adv7511_rd(sd, 0x0); in adv7511_probe()
1902 err = -EIO; in adv7511_probe()
1906 state->i2c_edid = i2c_new_dummy_device(client->adapter, in adv7511_probe()
1907 state->i2c_edid_addr >> 1); in adv7511_probe()
1908 if (IS_ERR(state->i2c_edid)) { in adv7511_probe()
1910 err = PTR_ERR(state->i2c_edid); in adv7511_probe()
1914 adv7511_wr(sd, 0xe1, state->i2c_cec_addr); in adv7511_probe()
1915 if (state->pdata.cec_clk < 3000000 || in adv7511_probe()
1916 state->pdata.cec_clk > 100000000) { in adv7511_probe()
1918 __func__, state->pdata.cec_clk); in adv7511_probe()
1919 state->pdata.cec_clk = 0; in adv7511_probe()
1922 if (state->pdata.cec_clk) { in adv7511_probe()
1923 state->i2c_cec = i2c_new_dummy_device(client->adapter, in adv7511_probe()
1924 state->i2c_cec_addr >> 1); in adv7511_probe()
1925 if (IS_ERR(state->i2c_cec)) { in adv7511_probe()
1927 err = PTR_ERR(state->i2c_cec); in adv7511_probe()
1935 state->i2c_pktmem = i2c_new_dummy_device(client->adapter, state->i2c_pktmem_addr >> 1); in adv7511_probe()
1936 if (IS_ERR(state->i2c_pktmem)) { in adv7511_probe()
1938 err = PTR_ERR(state->i2c_pktmem); in adv7511_probe()
1942 state->work_queue = create_singlethread_workqueue(sd->name); in adv7511_probe()
1943 if (state->work_queue == NULL) { in adv7511_probe()
1945 err = -ENOMEM; in adv7511_probe()
1949 INIT_DELAYED_WORK(&state->edid_handler, adv7511_edid_handler); in adv7511_probe()
1954 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops, in adv7511_probe()
1955 state, dev_name(&client->dev), CEC_CAP_DEFAULTS, in adv7511_probe()
1957 err = PTR_ERR_OR_ZERO(state->cec_adap); in adv7511_probe()
1959 destroy_workqueue(state->work_queue); in adv7511_probe()
1967 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in adv7511_probe()
1968 client->addr << 1, client->adapter->name); in adv7511_probe()
1972 i2c_unregister_device(state->i2c_pktmem); in adv7511_probe()
1974 i2c_unregister_device(state->i2c_cec); in adv7511_probe()
1976 i2c_unregister_device(state->i2c_edid); in adv7511_probe()
1978 media_entity_cleanup(&sd->entity); in adv7511_probe()
1980 v4l2_ctrl_handler_free(&state->hdl); in adv7511_probe()
1984 /* ----------------------------------------------------------------------- */
1991 state->chip_revision = -1; in adv7511_remove()
1993 v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name, in adv7511_remove()
1994 client->addr << 1, client->adapter->name); in adv7511_remove()
1998 cancel_delayed_work_sync(&state->edid_handler); in adv7511_remove()
1999 i2c_unregister_device(state->i2c_edid); in adv7511_remove()
2000 i2c_unregister_device(state->i2c_cec); in adv7511_remove()
2001 i2c_unregister_device(state->i2c_pktmem); in adv7511_remove()
2002 destroy_workqueue(state->work_queue); in adv7511_remove()
2004 media_entity_cleanup(&sd->entity); in adv7511_remove()
2005 v4l2_ctrl_handler_free(sd->ctrl_handler); in adv7511_remove()
2008 /* ----------------------------------------------------------------------- */
2011 { "adv7511-v4l2" },
2018 .name = "adv7511-v4l2",