Lines Matching +full:rclk +full:-
1 // SPDX-License-Identifier: GPL-2.0
5 * it6616 HDMI to MIPI CSI-2 bridge driver.
7 * Author: Jau-Chih.Tseng@ite.com.tw
8 * Jianwei Fan <jianwei.fan@rock-chips.com>
22 #include <linux/rk-camera-module.h>
25 #include <linux/v4l2-dv-timings.h>
31 #include <media/v4l2-controls_rockchip.h>
32 #include <media/v4l2-ctrls.h>
33 #include <media/v4l2-device.h>
34 #include <media/v4l2-dv-timings.h>
35 #include <media/v4l2-event.h>
36 #include <media/v4l2-fwnode.h>
43 MODULE_PARM_DESC(debug, "debug level (0-3)");
526 u32 rclk; member
1002 while (tdata->ucAddr != 0xff) { in it6616_hdim_write_table()
1003 if (tdata->andmask == 0xff) in it6616_hdim_write_table()
1004 it6616_hdmi_write(regmap, tdata->ucAddr, tdata->ucValue); in it6616_hdim_write_table()
1006 it6616_hdmi_set(regmap, tdata->ucAddr, tdata->andmask, tdata->ucValue); in it6616_hdim_write_table()
1013 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_get_video_stable()
1023 struct bus_para *bus_para = &it6616->mipi.bus_para_config; in it6616_mipitx_init_bus_para()
1026 bus_para->swap_pn = MIPI_TX_PN_SWAP; in it6616_mipitx_init_bus_para()
1027 bus_para->swap_lan = MIPI_TX_LANE_SWAP; in it6616_mipitx_init_bus_para()
1028 bus_para->pclk_inv = MIPI_TX_ENABLE_PCLK_INV; in it6616_mipitx_init_bus_para()
1029 bus_para->mclk_inv = MIPI_TX_ENABLE_MCLK_INV; in it6616_mipitx_init_bus_para()
1030 bus_para->lpx_num = in it6616_mipitx_init_bus_para()
1031 it6616->mipi_tx_enable_manual_adjusted_d_phy ? MIPI_TX_LPX : lpx; in it6616_mipitx_init_bus_para()
1032 bus_para->mipi_tx_hs_prepare = in it6616_mipitx_init_bus_para()
1033 it6616->mipi_tx_enable_manual_adjusted_d_phy ? in it6616_mipitx_init_bus_para()
1035 bus_para->tx_sel_line_start = true; in it6616_mipitx_init_bus_para()
1036 bus_para->tx_bypass = MIPI_TX_ENABLE_BY_PASS; in it6616_mipitx_init_bus_para()
1037 bus_para->tx_enable_hs_pre_1T = MIPI_TX_ENABLE_HS_PRE_1T; in it6616_mipitx_init_bus_para()
1038 bus_para->tx_vlpm_length = MIPI_TX_V_LPM_LENGTH; in it6616_mipitx_init_bus_para()
1039 bus_para->tx_hlpm_length = MIPI_TX_H_LPM_LENGTH; in it6616_mipitx_init_bus_para()
1040 bus_para->tx_enable_h_enter_lpm = MIPI_TX_ENABLE_H_ENTER_LPM; in it6616_mipitx_init_bus_para()
1148 for (i = 0; i <= bytenum - 1; i++) in it6616_get_dcs_crc()
1159 pheader->word_count_h = word_count >> 8; in it6616_mipi_tx_setup_long_packet_header()
1160 pheader->word_count_l = (u8)word_count; in it6616_mipi_tx_setup_long_packet_header()
1161 header = pheader->data_id | pheader->word_count_h << 16 | pheader->word_count_l << 8; in it6616_mipi_tx_setup_long_packet_header()
1162 pheader->ecc = it6616_get_dcs_ecc(header); in it6616_mipi_tx_setup_long_packet_header()
1169 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_get_packet_size()
1193 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_get_packet_fire_state()
1194 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_get_packet_fire_state()
1214 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_setup_packet()
1218 pheader->data_id = dcs_setting_table[cmd_name].data_id; in it6616_mipi_tx_setup_packet()
1227 pheader->word_count_l = dcs_setting_table[cmd_name].para_list[0]; in it6616_mipi_tx_setup_packet()
1228 pheader->word_count_h = dcs_setting_table[cmd_name].para_list[1]; in it6616_mipi_tx_setup_packet()
1229 short_cmd = pheader->data_id | pheader->word_count_l << 8 | in it6616_mipi_tx_setup_packet()
1230 pheader->word_count_h << 16; in it6616_mipi_tx_setup_packet()
1231 pheader->ecc = it6616_get_dcs_ecc(short_cmd); in it6616_mipi_tx_setup_packet()
1242 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_fire_packet()
1252 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_setup_packet_process()
1253 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_setup_packet_process()
1254 struct v4l2_subdev *sd = &it6616->sd; in it6616_mipi_tx_setup_packet_process()
1309 it6616_mipi_tx_write(mipi, 0x74, (it6616->mipi_tx_enable_h_fire_packet << 7) | data_count); in it6616_mipi_tx_setup_packet_process()
1317 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_write_lp_cmds()
1318 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_write_lp_cmds()
1380 struct regmap *mipi = it6616->mipi_regmap; in it6616_enter_bus_turn_around()
1389 it6616_mipi_tx_write(mipi, 0x74, it6616->mipi_tx_enable_h_fire_packet << 7); in it6616_enter_bus_turn_around()
1400 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_read_panel()
1415 struct mipi_bus *bus = &it6616->mipi; in it6616_mipitx_get_bus_config()
1417 struct bus_config *cfg = &bus->bus_para_config.cfg; in it6616_mipitx_get_bus_config()
1418 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_get_bus_config()
1421 bus_config_table = (bus->bus_type == MIPI_CSI) ? in it6616_mipitx_get_bus_config()
1425 if (bus_config_table[i].lane == bus->lane_cnt && in it6616_mipitx_get_bus_config()
1426 bus_config_table[i].type == bus->data_type) { in it6616_mipitx_get_bus_config()
1428 bus->bus_para_config.cfg = bus_config_table[i]; in it6616_mipitx_get_bus_config()
1430 i, (bus->bus_type == MIPI_CSI) ? "MIPI_CSI" : "MIPI_DSI"); in it6616_mipitx_get_bus_config()
1432 cfg->lane, in it6616_mipitx_get_bus_config()
1433 cfg->type, in it6616_mipitx_get_bus_config()
1434 cfg->reg23_p2m, in it6616_mipitx_get_bus_config()
1435 cfg->regb0_div[0], in it6616_mipitx_get_bus_config()
1436 cfg->regb0_div[1], in it6616_mipitx_get_bus_config()
1437 cfg->regb0_div[2]); in it6616_mipitx_get_bus_config()
1444 return -EINVAL; in it6616_mipitx_get_bus_config()
1449 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_setup_dsi()
1450 struct bus_para *bus = &it6616->mipi.bus_para_config; in it6616_mipitx_setup_dsi()
1451 struct bus_config *cfg = &bus->cfg; in it6616_mipitx_setup_dsi()
1452 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_setup_dsi()
1453 u8 mp_lane_num = cfg->lane - 1; in it6616_mipitx_setup_dsi()
1458 u8 mp_vid_type = cfg->type; in it6616_mipitx_setup_dsi()
1459 u32 mclk_ps = it6616->tx_mclk_ps, tx_mclk_mhz = it6616->tx_mclk / 1000; in it6616_mipitx_setup_dsi()
1460 u32 mipi_tx_calc_hs_end_time = (6 * mclk_ps - 20 * 1000) / mclk_ps; in it6616_mipitx_setup_dsi()
1463 reg23 = cfg->reg23_p2m; in it6616_mipitx_setup_dsi()
1468 it6616_mipi_tx_set_bits(mipi, 0x28, 0x20, bus->tx_sel_line_start << 5); in it6616_mipitx_setup_dsi()
1470 if (!it6616->mipi_tx_enable_manual_adjusted_d_phy) { in it6616_mipitx_setup_dsi()
1472 mp_hs_pretime = (((145 + ((4 + bus->lpx_num) * 20)) * 1000 - in it6616_mipitx_setup_dsi()
1476 mp_hs_pretime = ((((145 + ((4 + bus->lpx_num) * 20)) * 1000 - in it6616_mipitx_setup_dsi()
1480 mp_hs_pretime = ((((145 + ((4 + bus->lpx_num) * 20)) * 1000 - in it6616_mipitx_setup_dsi()
1504 it6616_mipi_tx_set_bits(mipi, 0x5e, 0x03, (bus->tx_vlpm_length >> 8) & 0x03); in it6616_mipitx_setup_dsi()
1505 it6616_mipi_tx_set_bits(mipi, 0x5d, 0xff, bus->tx_vlpm_length & 0xFF); in it6616_mipitx_setup_dsi()
1506 it6616_mipi_tx_set_bits(mipi, 0x5e, 0x0c, (bus->tx_hlpm_length & 0x300) >> 6); in it6616_mipitx_setup_dsi()
1507 it6616_mipi_tx_set_bits(mipi, 0x5f, 0xff, bus->tx_hlpm_length & 0xFF); in it6616_mipitx_setup_dsi()
1508 it6616_mipi_tx_set_bits(mipi, 0x5e, 0x10, bus->tx_enable_h_enter_lpm << 4); in it6616_mipitx_setup_dsi()
1509 it6616_mipi_tx_set_bits(mipi, 0x6a, 0xff, bus->p2m_delay.tx_dsi_vsync_delay); in it6616_mipitx_setup_dsi()
1522 mp_hs_pretime, mp_hs_endtime, bus->p2m_delay.tx_dsi_vsync_delay); in it6616_mipitx_setup_dsi()
1527 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_mipitx_setup_csi()
1528 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_setup_csi()
1529 struct bus_para *bus = &it6616->mipi.bus_para_config; in it6616_mipitx_setup_csi()
1530 struct bus_config *cfg = &bus->cfg; in it6616_mipitx_setup_csi()
1531 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_setup_csi()
1534 u8 mp_vid_type = cfg->type; in it6616_mipitx_setup_csi()
1535 u32 mclk_ps = it6616->tx_mclk_ps, tx_mclk_mhz = it6616->tx_mclk / 1000; in it6616_mipitx_setup_csi()
1536 u32 mipi_tx_calc_hs_end_time = (6 * mclk_ps - 20 * 1000) / mclk_ps; in it6616_mipitx_setup_csi()
1539 reg23 = cfg->reg23_p2m; in it6616_mipitx_setup_csi()
1546 if (!it6616->mipi_tx_enable_manual_adjusted_d_phy) { in it6616_mipitx_setup_csi()
1547 mp_hs_pretime = (((145 + ((4 + bus->lpx_num) * 20)) * 1000 - in it6616_mipitx_setup_csi()
1572 it6616_mipi_tx_write(mipi, 0x25, bus->p2m_delay.tx_csi_p2m_delay); in it6616_mipitx_setup_csi()
1581 mp_hs_pretime, mp_hs_endtime, bus->p2m_delay.tx_csi_p2m_delay); in it6616_mipitx_setup_csi()
1586 u8 i, csi_dsi_index = (it6616->mipi.bus_type == MIPI_CSI) ? 0 : 1; in it6616_mipi_tx_find_color_space_name_index()
1589 if (it6616->mipi.data_type == mipi_color_space[csi_dsi_index][i]) in it6616_mipi_tx_find_color_space_name_index()
1598 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_output_disable()
1605 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_output_enable()
1613 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_non_continuous_clock_setup()
1614 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_non_continuous_clock_setup()
1624 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_output_setup()
1625 struct bus_para *bus = &it6616->mipi.bus_para_config; in it6616_mipitx_output_setup()
1626 struct bus_config *cfg = &bus->cfg; in it6616_mipitx_output_setup()
1627 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_output_setup()
1629 u8 bus_type_index = ((it6616->mipi.bus_type == MIPI_CSI) ? 0 : 1); in it6616_mipitx_output_setup()
1632 u32 pclk = it6616->vinfo.pclk / 1000; in it6616_mipitx_output_setup()
1634 if (it6616->mipi_tx_enable_auto_adjust_lane_count) in it6616_mipitx_output_setup()
1635 it6616->mipi.lane_cnt = it6616->csi_lanes_in_use; in it6616_mipitx_output_setup()
1641 dev_info(dev, "lan_num: %d, swap_pn: %d", it6616->mipi.lane_cnt, bus->swap_pn); in it6616_mipitx_output_setup()
1642 dev_info(dev, "swap_lan: %d, pclk_inv: %d", bus->swap_lan, bus->pclk_inv); in it6616_mipitx_output_setup()
1643 dev_info(dev, "mclk_inv: %d, lpx_num: %d", bus->mclk_inv, bus->lpx_num); in it6616_mipitx_output_setup()
1648 regb0 = cfg->regb0_div[0]; in it6616_mipitx_output_setup()
1650 regb0 = cfg->regb0_div[1]; in it6616_mipitx_output_setup()
1652 regb0 = cfg->regb0_div[2]; in it6616_mipitx_output_setup()
1661 it6616->tx_mclk = mclk_MHz * 1000; in it6616_mipitx_output_setup()
1662 it6616->tx_mclk_ps = (2000 * (mprediv + 1) * 1000) / ((pclk) * (mplldiv + 1)); in it6616_mipitx_output_setup()
1665 it6616->tx_mclk_ps / 1000, it6616->tx_mclk_ps % 1000, in it6616_mipitx_output_setup()
1666 it6616->tx_mclk / 1000, pclk); in it6616_mipitx_output_setup()
1668 if (it6616->mipi_tx_enable_auto_adjust_lane_count) { in it6616_mipitx_output_setup()
1670 it6616->mipi.lane_cnt = (it6616->mipi.lane_cnt == 4) ? 2 : 1; in it6616_mipitx_output_setup()
1672 MIPI_TX_LANE_ADJUST_THRESHOLD, it6616->mipi.lane_cnt); in it6616_mipitx_output_setup()
1677 if (it6616->tx_mclk > 310000) in it6616_mipitx_output_setup()
1678 bus->mclk_inv = 0; in it6616_mipitx_output_setup()
1680 it6616_mipi_tx_set_bits(mipi, 0x28, 0x0c, (bus->swap_pn << 3) | (bus->swap_lan << 2)); in it6616_mipitx_output_setup()
1681 it6616_mipi_tx_set_bits(mipi, 0x10, BIT(2), bus->pclk_inv << 2); in it6616_mipitx_output_setup()
1685 it6616_mipi_tx_set_bits(mipi, 0x10, BIT(1), bus->mclk_inv << 1); in it6616_mipitx_output_setup()
1688 it6616_mipi_tx_set_bits(mipi, 0x11, BIT(3), bus->mclk_inv << 3); in it6616_mipitx_output_setup()
1692 it6616_mipi_tx_set_bits(mipi, 0x47, 0xf0, bus->mipi_tx_hs_prepare << 4); in it6616_mipitx_output_setup()
1693 it6616_mipi_tx_set_bits(mipi, 0x44, 0x04, bus->tx_enable_hs_pre_1T << 2); in it6616_mipitx_output_setup()
1694 it6616_mipi_tx_set_bits(mipi, 0x21, 0x30, (it6616->mipi.lane_cnt - 1) << 4); in it6616_mipitx_output_setup()
1697 bus->mipi_tx_hs_prepare, bus->lpx_num); in it6616_mipitx_output_setup()
1703 if (it6616->mipi.bus_type == MIPI_CSI) { in it6616_mipitx_output_setup()
1705 bus->p2m_delay.tx_csi_p2m_delay = 0x02; in it6616_mipitx_output_setup()
1707 bus->p2m_delay.tx_csi_p2m_delay = 0x04; in it6616_mipitx_output_setup()
1709 bus->p2m_delay.tx_csi_p2m_delay = 0x0a; in it6616_mipitx_output_setup()
1711 bus->p2m_delay.tx_csi_p2m_delay = 0x08; in it6616_mipitx_output_setup()
1713 bus->p2m_delay.tx_csi_p2m_delay = 0x04; in it6616_mipitx_output_setup()
1717 bus->p2m_delay.tx_dsi_vsync_delay = 0x02; in it6616_mipitx_output_setup()
1719 bus->p2m_delay.tx_dsi_vsync_delay = 0x04; in it6616_mipitx_output_setup()
1721 bus->p2m_delay.tx_dsi_vsync_delay = 0x0a; in it6616_mipitx_output_setup()
1723 bus->p2m_delay.tx_dsi_vsync_delay = 0x08; in it6616_mipitx_output_setup()
1725 bus->p2m_delay.tx_dsi_vsync_delay = 0x04; in it6616_mipitx_output_setup()
1729 if (!it6616->mipi_tx_enable_continuous_clock) in it6616_mipitx_output_setup()
1732 /* setup mipi-tx-afe */ in it6616_mipitx_output_setup()
1742 it6616->mipi_tx_enable_mipi_output = 1; in it6616_enable_mipi()
1748 it6616->mipi_tx_enable_mipi_output = 0; in it6616_disable_mipi()
1753 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_get_support_format()
1754 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_get_support_format()
1755 u8 mipi_intput_color = it6616->mipi.data_type; in it6616_mipi_tx_get_support_format()
1757 u8 bus_type_index = ((it6616->mipi.bus_type == MIPI_CSI) ? 0 : 1); in it6616_mipi_tx_get_support_format()
1759 if (it6616->mipi.bus_type == MIPI_CSI) { in it6616_mipi_tx_get_support_format()
1763 it6616->mipi.data_type = CSI_RGB888; in it6616_mipi_tx_get_support_format()
1768 it6616->mipi.data_type = CSI_YCbCr4228b; in it6616_mipi_tx_get_support_format()
1788 mipi_intput_color = it6616->mipi.data_type = DSI_RGB_24b; in it6616_mipi_tx_get_support_format()
1802 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_rk_fix_first_bit_issue()
1814 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_initial()
1815 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_initial()
1816 struct bus_para *bus = &it6616->mipi.bus_para_config; in it6616_mipitx_initial()
1823 it6616_mipi_tx_set_bits(mipi, 0x6b, 0x01, it6616->mipi.bus_type); in it6616_mipitx_initial()
1824 it6616_mipi_tx_set_bits(mipi, 0x10, 0x80, bus->tx_bypass << 7); in it6616_mipitx_initial()
1827 it6616_mipi_tx_set_bits(mipi, 0x45, 0x0f, bus->lpx_num); in it6616_mipitx_initial()
1829 if (it6616->mipi_tx_enable_initial_fire_lp_cmd) { in it6616_mipitx_initial()
1840 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_is_5v_on()
1850 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_is_clock_stable()
1860 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_is_symbol_locked()
1872 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_is_scdt_on()
1883 u8 mipi_intput_color = it6616->mipi.data_type; in it6616_hdmi_get_output_color_space()
1885 if (it6616->mipi.bus_type == MIPI_CSI) { in it6616_hdmi_get_output_color_space()
1920 it6616->output_colorspace = hdmi_output_color; in it6616_hdmi_get_output_color_space()
1927 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_edid_ram_get()
1928 struct regmap *edid = it6616->edid_regmap; in it6616_hdmi_edid_ram_get()
1937 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_edid_ram_update_chksum()
1945 sum += it6616->edid_data[i]; in it6616_hdmi_edid_ram_update_chksum()
1946 sum = (0x100 - sum) & 0xFF; in it6616_hdmi_edid_ram_update_chksum()
1954 sum += it6616->edid_data[i]; in it6616_hdmi_edid_ram_update_chksum()
1956 sum -= it6616->edid_data[offset]; in it6616_hdmi_edid_ram_update_chksum()
1957 sum -= it6616->edid_data[offset + 1]; in it6616_hdmi_edid_ram_update_chksum()
1960 sum = (0x100 - sum) & 0xFF; in it6616_hdmi_edid_ram_update_chksum()
1967 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_edid_ram_init()
1968 struct regmap *edid = it6616->edid_regmap; in it6616_hdmi_edid_ram_init()
1974 it6616_hdmi_edid_write(edid, it6616->edid_data, 0, it6616->edid_len); in it6616_hdmi_edid_ram_init()
1978 addr = cec_get_edid_phys_addr(it6616->edid_data, it6616->edid_len, &phy_addr_off); in it6616_hdmi_edid_ram_init()
1995 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_video_reset()
2006 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_edid_ram_enable()
2016 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_get_video_info()
2017 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_rx_get_video_info()
2038 it6616->vinfo.h_active = h_active; in it6616_hdmi_rx_get_video_info()
2039 it6616->vinfo.h_total = h_total; in it6616_hdmi_rx_get_video_info()
2040 it6616->vinfo.h_front_porch = h_front_porch; in it6616_hdmi_rx_get_video_info()
2041 it6616->vinfo.h_sync_w = h_sync_w; in it6616_hdmi_rx_get_video_info()
2042 it6616->vinfo.h_back_porch = (h_total - h_active - h_front_porch - h_sync_w); in it6616_hdmi_rx_get_video_info()
2043 it6616->vinfo.v_active = v_active; in it6616_hdmi_rx_get_video_info()
2044 it6616->vinfo.v_total = v_total; in it6616_hdmi_rx_get_video_info()
2045 it6616->vinfo.v_front_porch = v_front_porch; in it6616_hdmi_rx_get_video_info()
2046 it6616->vinfo.v_sync_w = v_sync_w; in it6616_hdmi_rx_get_video_info()
2047 it6616->vinfo.v_back_porch = v_total - v_active - v_front_porch - v_sync_w; in it6616_hdmi_rx_get_video_info()
2048 it6616->vinfo.interlaced = (interlaced) & 0x01; in it6616_hdmi_rx_get_video_info()
2049 it6616->vinfo.v_sync_pol = (v_sync_pol) & 0x01; in it6616_hdmi_rx_get_video_info()
2050 it6616->vinfo.h_sync_pol = (h_sync_pol) & 0x01; in it6616_hdmi_rx_get_video_info()
2052 frame_rate = (u32)(it6616->vinfo.pclk) * 1000; in it6616_hdmi_rx_get_video_info()
2053 frame_rate /= it6616->vinfo.h_total; in it6616_hdmi_rx_get_video_info()
2054 frame_rate /= it6616->vinfo.v_total; in it6616_hdmi_rx_get_video_info()
2055 it6616->vinfo.frame_rate = frame_rate; in it6616_hdmi_rx_get_video_info()
2057 if (it6616->avi_if.colorspace == HDMI_COLORSPACE_YUV420) { in it6616_hdmi_rx_get_video_info()
2058 dev_dbg(dev, "HActive = %d\n", it6616->vinfo.h_active*2); in it6616_hdmi_rx_get_video_info()
2059 dev_dbg(dev, "HTotal = %d\n", it6616->vinfo.h_total*2); in it6616_hdmi_rx_get_video_info()
2061 dev_dbg(dev, "HActive = %d\n", it6616->vinfo.h_active); in it6616_hdmi_rx_get_video_info()
2062 dev_dbg(dev, "HTotal = %d\n", it6616->vinfo.h_total); in it6616_hdmi_rx_get_video_info()
2065 dev_dbg(dev, "VActive = %d\n", it6616->vinfo.v_active); in it6616_hdmi_rx_get_video_info()
2066 dev_dbg(dev, "VTotal = %d\n", it6616->vinfo.v_total); in it6616_hdmi_rx_get_video_info()
2068 if (it6616->avi_if.colorspace == HDMI_COLORSPACE_YUV420) { in it6616_hdmi_rx_get_video_info()
2069 dev_dbg(dev, "HFrontPorch = %d\n", it6616->vinfo.h_front_porch*2); in it6616_hdmi_rx_get_video_info()
2070 dev_dbg(dev, "HSyncWidth = %d\n", it6616->vinfo.h_sync_w*2); in it6616_hdmi_rx_get_video_info()
2071 dev_dbg(dev, "HBackPorch = %d\n", it6616->vinfo.h_back_porch*2); in it6616_hdmi_rx_get_video_info()
2073 dev_dbg(dev, "HFrontPorch = %d\n", it6616->vinfo.h_front_porch); in it6616_hdmi_rx_get_video_info()
2074 dev_dbg(dev, "HSyncWidth = %d\n", it6616->vinfo.h_sync_w); in it6616_hdmi_rx_get_video_info()
2075 dev_dbg(dev, "HBackPorch = %d\n", it6616->vinfo.h_back_porch); in it6616_hdmi_rx_get_video_info()
2078 dev_dbg(dev, "VFrontPorch = %d\n", it6616->vinfo.v_front_porch); in it6616_hdmi_rx_get_video_info()
2079 dev_dbg(dev, "VSyncWidth = %d\n", it6616->vinfo.v_sync_w); in it6616_hdmi_rx_get_video_info()
2080 dev_dbg(dev, "VBackPorch = %d\n", it6616->vinfo.v_back_porch); in it6616_hdmi_rx_get_video_info()
2081 dev_dbg(dev, "FrameRate = %u\n", it6616->vinfo.frame_rate); in it6616_hdmi_rx_get_video_info()
2083 if (it6616->vinfo.interlaced) in it6616_hdmi_rx_get_video_info()
2088 if (it6616->vinfo.v_sync_pol) in it6616_hdmi_rx_get_video_info()
2093 if (it6616->vinfo.h_sync_pol) in it6616_hdmi_rx_get_video_info()
2101 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_hpd_output()
2115 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_hdcp_reset()
2123 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_get_hdcp_status()
2139 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_get_av_mute_state()
2150 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_set_av_mute()
2158 if (!it6616->mipi_tx_enable_mipi_output) { in it6616_hdmi_rx_set_av_mute()
2175 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_update_rs()
2188 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_calc_rclk()
2189 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_calc_rclk()
2194 it6616_mipi_tx_set_bits(mipi, 0xE0, 0x80, 0x80); // Enable RCLK 100ms count in it6616_mipi_tx_calc_rclk()
2196 it6616_mipi_tx_set_bits(mipi, 0xE0, 0x80, 0x00); // Disable RCLK 100ms count in it6616_mipi_tx_calc_rclk()
2206 it6616->tx_rclk = sum / TIMER_100MS; in it6616_mipi_tx_calc_rclk()
2207 dev_dbg(dev, "mipi rclk = %d.%d MHz", it6616->tx_rclk / 1000, in it6616_mipi_tx_calc_rclk()
2208 it6616->tx_rclk % 1000); in it6616_mipi_tx_calc_rclk()
2213 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_calc_mclk()
2214 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_calc_mclk()
2233 tx_mclk = it6616->tx_rclk * 2048 / sum; in it6616_mipi_tx_calc_mclk()
2239 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipi_tx_calc_pclk()
2240 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipi_tx_calc_pclk()
2259 it6616->tx_pclk = it6616->tx_rclk * 2048 / sum; in it6616_mipi_tx_calc_pclk()
2260 dev_dbg(dev, "mipi pclk = %u.%u MHz", it6616->tx_pclk / 1000, in it6616_mipi_tx_calc_pclk()
2261 it6616->tx_pclk % 1000); in it6616_mipi_tx_calc_pclk()
2266 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_calc_rclk()
2267 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_rx_calc_rclk()
2268 u32 rddata, rclk, sum = 0; in it6616_hdmi_rx_calc_rclk() local
2286 rclk = sum / TIMER_100MS; in it6616_hdmi_rx_calc_rclk()
2288 dev_dbg(dev, "RCLK=%u KHz\n", rclk); in it6616_hdmi_rx_calc_rclk()
2290 t1usint = rclk / 1000; in it6616_hdmi_rx_calc_rclk()
2291 t1usflt = (rclk / 1000 - t1usint) * 256; in it6616_hdmi_rx_calc_rclk()
2295 it6616->rclk = rclk; in it6616_hdmi_rx_calc_rclk()
2297 return rclk; in it6616_hdmi_rx_calc_rclk()
2302 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_calc_pclk()
2303 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_rx_calc_pclk()
2320 pclk = it6616->rclk * 512 / sump; // 512=2*256 because of 1T 2 pixel in it6616_hdmi_rx_calc_pclk()
2322 it6616->vinfo.pclk = pclk; in it6616_hdmi_rx_calc_pclk()
2333 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_calc_tmds_clk()
2334 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_rx_calc_tmds_clk()
2348 it6616->vinfo.TMDSCLK = (it6616->rclk * (u32)1024 * i) / sumt; in it6616_hdmi_rx_calc_tmds_clk()
2350 it6616->vinfo.TMDSCLK = (it6616->rclk * (u32)512 * i) / sumt; in it6616_hdmi_rx_calc_tmds_clk()
2352 it6616->vinfo.TMDSCLK = (it6616->rclk * (u32)256 * i) / sumt; in it6616_hdmi_rx_calc_tmds_clk()
2354 it6616->vinfo.TMDSCLK = (it6616->rclk * (u32)128 * i) / sumt; in it6616_hdmi_rx_calc_tmds_clk()
2357 it6616->vinfo.TMDSCLK / 1000, it6616->vinfo.TMDSCLK % 1000); in it6616_hdmi_rx_calc_tmds_clk()
2359 dev_err(dev, "%s - sumt==0\n", __func__); in it6616_hdmi_rx_calc_tmds_clk()
2365 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_receive_avi_infoframe_log()
2375 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_update_avi_infoframe()
2376 struct hdmi_avi_infoframe *frame = &it6616->avi_if; in it6616_hdmi_update_avi_infoframe()
2393 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_setup_csc()
2394 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_rx_setup_csc()
2408 color_in = it6616->avi_if.colorspace; in it6616_hdmi_rx_setup_csc()
2421 if (it6616->avi_if.colorimetry == HDMI_COLORIMETRY_ITU_709) { in it6616_hdmi_rx_setup_csc()
2422 if (it6616->avi_if.quantization_range == HDMI_QUANTIZATION_RANGE_LIMITED) in it6616_hdmi_rx_setup_csc()
2427 if (it6616->avi_if.quantization_range == HDMI_QUANTIZATION_RANGE_LIMITED) in it6616_hdmi_rx_setup_csc()
2437 if (it6616->avi_if.colorimetry == HDMI_COLORIMETRY_ITU_709) in it6616_hdmi_rx_setup_csc()
2440 else if (it6616->avi_if.colorimetry == HDMI_COLORIMETRY_EXTENDED && in it6616_hdmi_rx_setup_csc()
2441 (it6616->avi_if.extended_colorimetry == 0x05 || in it6616_hdmi_rx_setup_csc()
2442 it6616->avi_if.extended_colorimetry == 0x06)) in it6616_hdmi_rx_setup_csc()
2500 if (it6616->mipi.bus_type == MIPI_CSI) { in it6616_hdmi_rx_setup_csc()
2501 switch (it6616->mipi.data_type) { in it6616_hdmi_rx_setup_csc()
2507 switch (it6616->mipi.data_type) { in it6616_hdmi_rx_setup_csc()
2522 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_reset_audio_logic()
2539 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_rx_audio_setup_i2s_justified()
2542 it6616->audio_i2s_justified : i2s_justified; in it6616_hdmi_rx_audio_setup_i2s_justified()
2549 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_tx_audio_setup()
2550 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_tx_audio_setup()
2559 it6616->ainfo.n = ((u32)it6616_hdmi_read(hdmi, 0xBE) << 12) + in it6616_hdmi_tx_audio_setup()
2562 it6616->ainfo.cts = it6616_hdmi_read(hdmi, 0xC0) >> 4; in it6616_hdmi_tx_audio_setup()
2563 it6616->ainfo.cts |= ((u32)it6616_hdmi_read(hdmi, 0xC1)) << 12; in it6616_hdmi_tx_audio_setup()
2564 it6616->ainfo.cts |= ((u32)it6616_hdmi_read(hdmi, 0xC2)) << 4; in it6616_hdmi_tx_audio_setup()
2567 if (it6616->ainfo.cts == 0) { in it6616_hdmi_tx_audio_setup()
2568 dev_info(dev, "WARNING:cts = %u", it6616->ainfo.cts); in it6616_hdmi_tx_audio_setup()
2575 it6616->ainfo.channel_status = ((it6616_hdmi_read(hdmi, 0xB5) & 0xC0) >> 2) + in it6616_hdmi_tx_audio_setup()
2577 cts_128 = 128 * it6616->ainfo.cts; in it6616_hdmi_tx_audio_setup()
2578 sum = it6616->ainfo.n * it6616->vinfo.TMDSCLK; in it6616_hdmi_tx_audio_setup()
2579 it6616->ainfo.sample_freq = sum / cts_128; in it6616_hdmi_tx_audio_setup()
2581 dev_info(dev, "n = %u cts = %u\n", it6616->ainfo.n, it6616->ainfo.cts); in it6616_hdmi_tx_audio_setup()
2582 dev_info(dev, "tmds clock = %d kHz\n", it6616->vinfo.TMDSCLK); in it6616_hdmi_tx_audio_setup()
2583 dev_info(dev, "Audio_CH_Status[24:27 - 30:31][bit0~bit5] = 0x%02x\n", in it6616_hdmi_tx_audio_setup()
2584 it6616->ainfo.channel_status); in it6616_hdmi_tx_audio_setup()
2586 it6616->ainfo.sample_freq, (sum % cts_128) * 100 / cts_128); in it6616_hdmi_tx_audio_setup()
2588 if (it6616->ainfo.sample_freq > 25 && it6616->ainfo.sample_freq <= 38) in it6616_hdmi_tx_audio_setup()
2589 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_32K; in it6616_hdmi_tx_audio_setup()
2590 else if (it6616->ainfo.sample_freq > 38 && it6616->ainfo.sample_freq <= 45) in it6616_hdmi_tx_audio_setup()
2591 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_44P1K; in it6616_hdmi_tx_audio_setup()
2592 else if (it6616->ainfo.sample_freq > 45 && it6616->ainfo.sample_freq <= 58) in it6616_hdmi_tx_audio_setup()
2593 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_48K; in it6616_hdmi_tx_audio_setup()
2594 else if (it6616->ainfo.sample_freq > 58 && it6616->ainfo.sample_freq <= 78) in it6616_hdmi_tx_audio_setup()
2595 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_64K; in it6616_hdmi_tx_audio_setup()
2596 else if (it6616->ainfo.sample_freq > 78 && it6616->ainfo.sample_freq <= 91) in it6616_hdmi_tx_audio_setup()
2597 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_88P2K; in it6616_hdmi_tx_audio_setup()
2598 else if (it6616->ainfo.sample_freq > 91 && it6616->ainfo.sample_freq <= 106) in it6616_hdmi_tx_audio_setup()
2599 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_96K; in it6616_hdmi_tx_audio_setup()
2600 else if (it6616->ainfo.sample_freq > 106 && it6616->ainfo.sample_freq <= 166) in it6616_hdmi_tx_audio_setup()
2601 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_128K; in it6616_hdmi_tx_audio_setup()
2602 else if (it6616->ainfo.sample_freq > 166 && it6616->ainfo.sample_freq <= 182) in it6616_hdmi_tx_audio_setup()
2603 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_176P4K; in it6616_hdmi_tx_audio_setup()
2604 else if (it6616->ainfo.sample_freq > 182 && it6616->ainfo.sample_freq <= 202) in it6616_hdmi_tx_audio_setup()
2605 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_192K; in it6616_hdmi_tx_audio_setup()
2606 else if (it6616->ainfo.sample_freq > 224 && it6616->ainfo.sample_freq <= 320) in it6616_hdmi_tx_audio_setup()
2607 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_256K; in it6616_hdmi_tx_audio_setup()
2608 else if (it6616->ainfo.sample_freq > 320 && it6616->ainfo.sample_freq <= 448) in it6616_hdmi_tx_audio_setup()
2609 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_384K; in it6616_hdmi_tx_audio_setup()
2610 else if (it6616->ainfo.sample_freq > 448 && it6616->ainfo.sample_freq <= 638) in it6616_hdmi_tx_audio_setup()
2611 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_512K; in it6616_hdmi_tx_audio_setup()
2612 else if (it6616->ainfo.sample_freq > 638 && it6616->ainfo.sample_freq <= 894) in it6616_hdmi_tx_audio_setup()
2613 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_768K; in it6616_hdmi_tx_audio_setup()
2614 else if (it6616->ainfo.sample_freq > 894 && it6616->ainfo.sample_freq <= 1324) in it6616_hdmi_tx_audio_setup()
2615 it6616->ainfo.force_sample_freq = AUDIO_SAMPLING_1024K; in it6616_hdmi_tx_audio_setup()
2617 dev_info(dev, "Sampling_Frequency value 0x%02x", it6616->ainfo.force_sample_freq); in it6616_hdmi_tx_audio_setup()
2619 if (it6616->ainfo.channel_status == it6616->ainfo.force_sample_freq) { in it6616_hdmi_tx_audio_setup()
2626 it6616->audio_sampling_freq_error_count = 0; in it6616_hdmi_tx_audio_setup()
2630 it6616->audio_sampling_freq_error_count++; in it6616_hdmi_tx_audio_setup()
2631 dev_dbg(dev, "it6616->audio_sampling_freq_error_count=%d\n", in it6616_hdmi_tx_audio_setup()
2632 (int) it6616->audio_sampling_freq_error_count); in it6616_hdmi_tx_audio_setup()
2635 if (it6616->audio_sampling_freq_error_count > MAX_AUDIO_SAMPLING_FREQ_ERROR_COUNT) { in it6616_hdmi_tx_audio_setup()
2638 it6616_hdmi_set(hdmi, 0x8A, 0x3F, it6616->ainfo.force_sample_freq); in it6616_hdmi_tx_audio_setup()
2641 if (it6616->ainfo.sample_freq <= 182) { in it6616_hdmi_tx_audio_setup()
2649 it6616->audio_sampling_freq_error_count = 0; in it6616_hdmi_tx_audio_setup()
2656 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_tx_audio_output_enable()
2657 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_tx_audio_output_enable()
2664 it6616_hdmi_write(hdmi, 0xC7, 0x7F); // SPDIF/I2S tri-state on in it6616_hdmi_tx_audio_output_enable()
2670 it6616_hdmi_write(hdmi, 0xC7, 0x00); // SPDIF/I2S tri-state off in it6616_hdmi_tx_audio_output_enable()
2679 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_audio_mute_clear()
2692 it6616_hdmi_tx_audio_output_enable(it6616, it6616->audio_interface); in it6616_hdmi_rx_audio_process()
2697 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_initial()
2698 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_initial()
2704 it6616_hdmi_set(hdmi, 0x67, BIT(7), it6616->hdmi_rx_disable_pixel_repeat << 7); in it6616_hdmi_initial()
2706 it6616->hdmi_rx_video_stable_condition << 5); in it6616_hdmi_initial()
2714 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_irq_color_depth()
2715 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_irq_color_depth()
2728 avi_new = &it6616->avi_if; in it6616_hdmi_irq_new_avi_infoframe()
2729 avi_prev = &it6616->avi_if_prev; in it6616_hdmi_irq_new_avi_infoframe()
2730 hdmi_infoframe_log(KERN_INFO, &it6616->hdmi_i2c->dev, in it6616_hdmi_irq_new_avi_infoframe()
2733 if (avi_prev->video_code != avi_new->video_code) in it6616_hdmi_irq_new_avi_infoframe()
2734 avi_prev->video_code = avi_new->video_code; in it6616_hdmi_irq_new_avi_infoframe()
2735 if (avi_prev->colorspace != avi_new->colorspace) in it6616_hdmi_irq_new_avi_infoframe()
2736 avi_prev->colorspace = avi_new->colorspace; in it6616_hdmi_irq_new_avi_infoframe()
2756 struct regmap *mipi = it6616->mipi_regmap; in it6616_mipitx_irq()
2757 struct device *dev = &it6616->mipi_i2c->dev; in it6616_mipitx_irq()
2768 it6616->mipi_tx_video_stable = it6616_mipi_tx_get_video_stable(it6616); in it6616_mipitx_irq()
2771 reg09h, it6616->mipi_tx_video_stable ? "" : "un"); in it6616_mipitx_irq()
2773 if (it6616->mipi_tx_video_stable) { in it6616_mipitx_irq()
2790 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_hdmi_irq()
2791 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_hdmi_irq()
2862 dev_err(dev, "# CH2 CDR FIFO Aut0-Rst #\n"); in it6616_hdmi_irq()
2864 dev_err(dev, "# CH1 CDR FIFO Aut0-Rst #\n"); in it6616_hdmi_irq()
2866 dev_err(dev, "# CH0 CDR FIFO Aut0-Rst #\n"); in it6616_hdmi_irq()
2876 it6616->hdmi_rx_hdcp_state = true; in it6616_hdmi_irq()
2879 it6616->hdmi_rx_hdcp_state = it6616_get_hdcp_status(it6616); in it6616_hdmi_irq()
2882 it6616->hdmi_rx_hdcp_state ? "ON" : "OFF"); in it6616_hdmi_irq()
2886 it6616->hdmi_rx_hdcp_state = false; in it6616_hdmi_irq()
2945 it6616->hdmi_rx_video_stable = it6616_hdmi_is_scdt_on(it6616); in it6616_hdmi_irq()
2946 dev_info(dev, "SCDT %s", it6616->hdmi_rx_video_stable ? "ON" : "OFF"); in it6616_hdmi_irq()
2948 if (it6616->hdmi_rx_video_stable) { in it6616_hdmi_irq()
3003 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_get_chip_id()
3004 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_get_chip_id()
3013 return -ENODEV; in it6616_get_chip_id()
3022 struct regmap *hdmi = it6616->hdmi_regmap; in it6616_poll_threaded_handler()
3036 mutex_lock(&it6616->confctl_mutex); in it6616_intp_threaded_handler()
3041 mutex_unlock(&it6616->confctl_mutex); in it6616_intp_threaded_handler()
3048 struct device *dev = &it6616->hdmi_i2c->dev; in it6616_initial()
3050 mutex_lock(&it6616->confctl_mutex); in it6616_initial()
3055 return -ENODEV; in it6616_initial()
3059 it6616->edid_len = sizeof(default_edid); in it6616_initial()
3060 memcpy(it6616->edid_data, default_edid, it6616->edid_len); in it6616_initial()
3063 it6616->mipi.bus_type = MIPI_TX_INTERFACE; in it6616_initial()
3064 it6616->mipi.lane_cnt = it6616->csi_lanes_in_use; in it6616_initial()
3065 it6616->mipi.data_type = MIPI_TX_DATA_TYPE; in it6616_initial()
3067 it6616->mipi_tx_enable_auto_adjust_lane_count = in it6616_initial()
3069 it6616->mipi_tx_enable_h_fire_packet = in it6616_initial()
3071 it6616->mipi_tx_enable_initial_fire_lp_cmd = in it6616_initial()
3074 it6616->rs_level = DEFAULT_RS_LEVEL; in it6616_initial()
3075 it6616->audio_interface = AUDIO_I2S; in it6616_initial()
3076 it6616->audio_i2s_justified = AUDIO_I2S_JUSTIFIED; in it6616_initial()
3077 it6616->hdmi_rx_disable_pixel_repeat = in it6616_initial()
3079 it6616->hdmi_rx_video_stable_condition = in it6616_initial()
3081 it6616->mipi_tx_enable_continuous_clock = in it6616_initial()
3083 it6616->mipi_tx_enable_manual_adjusted_d_phy = in it6616_initial()
3085 it6616->hdmi_rx_video_stable = false; in it6616_initial()
3086 it6616->mipi_tx_video_stable = false; in it6616_initial()
3087 it6616->hdmi_rx_hdcp_state = false; in it6616_initial()
3088 it6616->mipi_tx_enable_mipi_output = false; in it6616_initial()
3097 mutex_unlock(&it6616->confctl_mutex); in it6616_initial()
3104 mutex_lock(&it6616->confctl_mutex); in it6616_set_hpd()
3111 mutex_unlock(&it6616->confctl_mutex); in it6616_set_hpd()
3116 mutex_lock(&it6616->confctl_mutex); in it6616_update_edid_data()
3118 memcpy(it6616->edid_data, edid, it6616->edid_len); in it6616_update_edid_data()
3119 it6616->edid_len = edid_len; in it6616_update_edid_data()
3122 mutex_unlock(&it6616->confctl_mutex); in it6616_update_edid_data()
3178 str += scnprintf(str, end - str, in attr_buffer_put()
3180 str += scnprintf(str, end - str, in attr_buffer_put()
3182 str += scnprintf(str, end - str, in attr_buffer_put()
3184 str += scnprintf(str, end - str, in attr_buffer_put()
3189 str += scnprintf(str, end - str, "\n[%02X] ", i & 0xF0); in attr_buffer_put()
3190 str += scnprintf(str, end - str, "0x%02X ", reg_buf[i]); in attr_buffer_put()
3192 str += scnprintf(str, end - str, "\n"); in attr_buffer_put()
3194 return end - str; in attr_buffer_put()
3203 dev_info(dev, "%s(%x)\n", __func__, it6616->attr_hdmi_reg_bank); in edid_ram_show()
3205 mutex_lock(&it6616->confctl_mutex); in edid_ram_show()
3207 mutex_unlock(&it6616->confctl_mutex); in edid_ram_show()
3219 return -EINVAL; in hdmi_reg_store()
3221 it6616->attr_hdmi_reg_bank = (u8) reg_bank; in hdmi_reg_store()
3224 __func__, reg_bank, it6616->attr_hdmi_reg_bank); in hdmi_reg_store()
3234 struct regmap *hdmi = it6616->hdmi_regmap; in hdmi_reg_show()
3238 dev_info(dev, "%s(%x)\n", __func__, it6616->attr_hdmi_reg_bank); in hdmi_reg_show()
3240 mutex_lock(&it6616->confctl_mutex); in hdmi_reg_show()
3241 it6616_hdmi_chgbank(hdmi, it6616->attr_hdmi_reg_bank); in hdmi_reg_show()
3246 mutex_unlock(&it6616->confctl_mutex); in hdmi_reg_show()
3255 struct regmap *mipi = it6616->mipi_regmap; in mipi_reg_show()
3259 mutex_lock(&it6616->confctl_mutex); in mipi_reg_show()
3263 mutex_unlock(&it6616->confctl_mutex); in mipi_reg_show()
3272 struct regmap *mipi = it6616->mipi_regmap; in mipi_reg_store()
3312 it6616->nosignal); in no_signal()
3314 return it6616->nosignal; in no_signal()
3321 return it6616->is_audio_present; in audio_present()
3331 return code_to_rate_table[it6616->ainfo.force_sample_freq]; in get_audio_sampling_rate()
3339 return DIV_ROUND_CLOSEST((unsigned int)t->pixelclock, in fps_calc()
3368 struct v4l2_bt_timings *bt = &timings->bt; in it6616_get_detected_timings()
3374 it6616->nosignal = false; in it6616_get_detected_timings()
3375 it6616->is_audio_present = tx_5v_power_present(sd) ? true : false; in it6616_get_detected_timings()
3376 timings->type = V4L2_DV_BT_656_1120; in it6616_get_detected_timings()
3377 bt->interlaced = it6616->vinfo.interlaced; in it6616_get_detected_timings()
3378 bt->width = it6616->vinfo.h_active; in it6616_get_detected_timings()
3379 bt->height = it6616->vinfo.v_active; in it6616_get_detected_timings()
3380 bt->vsync = it6616->vinfo.v_sync_w; in it6616_get_detected_timings()
3381 bt->hsync = it6616->vinfo.h_sync_w; in it6616_get_detected_timings()
3382 bt->pixelclock = it6616->vinfo.pclk * 1000; in it6616_get_detected_timings()
3383 bt->hfrontporch = it6616->vinfo.h_front_porch; in it6616_get_detected_timings()
3384 bt->vfrontporch = it6616->vinfo.v_front_porch; in it6616_get_detected_timings()
3385 bt->hbackporch = it6616->vinfo.h_back_porch; in it6616_get_detected_timings()
3386 bt->vbackporch = it6616->vinfo.v_back_porch; in it6616_get_detected_timings()
3387 htotal = it6616->vinfo.h_total; in it6616_get_detected_timings()
3388 vtotal = it6616->vinfo.v_total; in it6616_get_detected_timings()
3390 if (it6616->avi_if.colorspace == HDMI_COLORSPACE_YUV420) { in it6616_get_detected_timings()
3391 bt->width = it6616->vinfo.h_active * 2; in it6616_get_detected_timings()
3392 bt->hfrontporch = it6616->vinfo.h_front_porch * 2; in it6616_get_detected_timings()
3393 bt->hbackporch = it6616->vinfo.h_back_porch * 2; in it6616_get_detected_timings()
3394 bt->hsync = it6616->vinfo.h_sync_w * 2; in it6616_get_detected_timings()
3395 htotal = it6616->vinfo.h_total * 2; in it6616_get_detected_timings()
3400 if (!it6616_rcv_supported_res(sd, bt->width, bt->height)) { in it6616_get_detected_timings()
3401 it6616->nosignal = true; in it6616_get_detected_timings()
3403 return -EINVAL; in it6616_get_detected_timings()
3407 if (bt->interlaced) { in it6616_get_detected_timings()
3408 bt->height *= 2; in it6616_get_detected_timings()
3409 bt->il_vsync = bt->vsync + 1; in it6616_get_detected_timings()
3413 bt->width, bt->height, htotal, vtotal, bt->pixelclock, fps); in it6616_get_detected_timings()
3415 bt->hfrontporch, bt->hsync, bt->hbackporch, in it6616_get_detected_timings()
3416 bt->vfrontporch, bt->vsync, bt->vbackporch); in it6616_get_detected_timings()
3417 v4l2_dbg(1, debug, sd, "inerlaced:%d,\n", bt->interlaced); in it6616_get_detected_timings()
3426 return v4l2_ctrl_s_ctrl(it6616->detect_tx_5v_ctrl, in it6616_s_ctrl_detect_tx_5v()
3434 return v4l2_ctrl_s_ctrl(it6616->audio_sampling_rate_ctrl, in it6616_s_ctrl_audio_sampling_rate()
3442 return v4l2_ctrl_s_ctrl(it6616->audio_present_ctrl, in it6616_s_ctrl_audio_present()
3460 if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120) in it6616_match_dv_timings()
3462 if (t1->bt.width == t2->bt.width && in it6616_match_dv_timings()
3463 t1->bt.height == t2->bt.height && in it6616_match_dv_timings()
3464 t1->bt.interlaced == t2->bt.interlaced && in it6616_match_dv_timings()
3465 t1->bt.hfrontporch == t2->bt.hfrontporch && in it6616_match_dv_timings()
3466 t1->bt.hsync == t2->bt.hsync && in it6616_match_dv_timings()
3467 t1->bt.hbackporch == t2->bt.hbackporch && in it6616_match_dv_timings()
3468 t1->bt.vfrontporch == t2->bt.vfrontporch && in it6616_match_dv_timings()
3469 t1->bt.vsync == t2->bt.vsync && in it6616_match_dv_timings()
3470 t1->bt.vbackporch == t2->bt.vbackporch && in it6616_match_dv_timings()
3471 (!t1->bt.interlaced || in it6616_match_dv_timings()
3472 (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch && in it6616_match_dv_timings()
3473 t1->bt.il_vsync == t2->bt.il_vsync && in it6616_match_dv_timings()
3474 t1->bt.il_vbackporch == t2->bt.il_vbackporch))) in it6616_match_dv_timings()
3490 if (!it6616_match_dv_timings(&it6616->timings, &timings)) { in it6616_format_change()
3493 v4l2_print_dv_timings(sd->name, in it6616_format_change()
3496 if (sd->devnode) in it6616_format_change()
3513 it6616->nosignal = true; in it6616_isr()
3526 if (it6616->mipi_tx_video_stable && it6616_hdmi_is_5v_on(it6616)) in it6616_detect_hot_plug()
3527 v4l2_ctrl_s_ctrl(it6616->detect_tx_5v_ctrl, 1); in it6616_detect_hot_plug()
3529 v4l2_ctrl_s_ctrl(it6616->detect_tx_5v_ctrl, 0); in it6616_detect_hot_plug()
3539 it6616_isr(&it6616->sd, 0, &handled); in it6616_work_i2c_poll()
3540 it6616_detect_hot_plug(&it6616->sd); in it6616_work_i2c_poll()
3541 schedule_delayed_work(&it6616->work_i2c_poll, in it6616_work_i2c_poll()
3548 switch (sub->type) { in it6616_subscribe_event()
3554 return -EINVAL; in it6616_subscribe_event()
3574 return -EINVAL; in it6616_s_dv_timings()
3577 v4l2_print_dv_timings(sd->name, "s_dv_timings: ", in it6616_s_dv_timings()
3580 if (v4l2_match_dv_timings(&it6616->timings, timings, 0, false)) { in it6616_s_dv_timings()
3588 return -ERANGE; in it6616_s_dv_timings()
3591 it6616->timings = *timings; in it6616_s_dv_timings()
3601 *timings = it6616->timings; in it6616_g_dv_timings()
3609 if (timings->pad != 0) in it6616_enum_dv_timings()
3610 return -EINVAL; in it6616_enum_dv_timings()
3621 *timings = it6616->timings; in it6616_query_dv_timings()
3623 v4l2_print_dv_timings(sd->name, in it6616_query_dv_timings()
3631 return -ERANGE; in it6616_query_dv_timings()
3640 if (cap->pad != 0) in it6616_dv_timings_cap()
3641 return -EINVAL; in it6616_dv_timings_cap()
3653 cfg->type = V4L2_MBUS_CSI2_DPHY; in it6616_g_mbus_config()
3654 cfg->flags = V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK | in it6616_g_mbus_config()
3657 switch (it6616->csi_lanes_in_use) { in it6616_g_mbus_config()
3659 cfg->flags |= V4L2_MBUS_CSI2_1_LANE; in it6616_g_mbus_config()
3662 cfg->flags |= V4L2_MBUS_CSI2_2_LANE; in it6616_g_mbus_config()
3665 cfg->flags |= V4L2_MBUS_CSI2_3_LANE; in it6616_g_mbus_config()
3668 cfg->flags |= V4L2_MBUS_CSI2_4_LANE; in it6616_g_mbus_config()
3672 return -EINVAL; in it6616_g_mbus_config()
3697 struct i2c_client *client = it6616->i2c_client; in it6616_s_stream()
3700 dev_info(&client->dev, "%s: on: %d, %dx%d@%d\n", __func__, on, in it6616_s_stream()
3701 it6616->cur_mode->width, in it6616_s_stream()
3702 it6616->cur_mode->height, in it6616_s_stream()
3703 DIV_ROUND_CLOSEST(it6616->cur_mode->max_fps.denominator, in it6616_s_stream()
3704 it6616->cur_mode->max_fps.numerator)); in it6616_s_stream()
3706 mutex_lock(&it6616->confctl_mutex); in it6616_s_stream()
3712 dev_err(it6616->dev, "Failed to start it6616 stream\n"); in it6616_s_stream()
3721 mutex_unlock(&it6616->confctl_mutex); in it6616_s_stream()
3729 switch (code->index) { in it6616_enum_mbus_code()
3731 code->code = IT6616_MEDIA_BUS_FMT; in it6616_enum_mbus_code()
3735 return -EINVAL; in it6616_enum_mbus_code()
3745 if (fse->index >= ARRAY_SIZE(supported_modes)) in it6616_enum_frame_sizes()
3746 return -EINVAL; in it6616_enum_frame_sizes()
3748 if (fse->code != IT6616_MEDIA_BUS_FMT) in it6616_enum_frame_sizes()
3749 return -EINVAL; in it6616_enum_frame_sizes()
3751 fse->min_width = supported_modes[fse->index].width; in it6616_enum_frame_sizes()
3752 fse->max_width = supported_modes[fse->index].width; in it6616_enum_frame_sizes()
3753 fse->max_height = supported_modes[fse->index].height; in it6616_enum_frame_sizes()
3754 fse->min_height = supported_modes[fse->index].height; in it6616_enum_frame_sizes()
3765 mutex_lock(&it6616->confctl_mutex); in it6616_get_fmt()
3766 format->format.code = it6616->mbus_fmt_code; in it6616_get_fmt()
3767 format->format.width = it6616->timings.bt.width; in it6616_get_fmt()
3768 format->format.height = it6616->timings.bt.height; in it6616_get_fmt()
3769 format->format.field = in it6616_get_fmt()
3770 it6616->timings.bt.interlaced ? in it6616_get_fmt()
3772 format->format.colorspace = V4L2_COLORSPACE_SRGB; in it6616_get_fmt()
3773 mutex_unlock(&it6616->confctl_mutex); in it6616_get_fmt()
3776 __func__, format->format.code, format->format.width, in it6616_get_fmt()
3777 format->format.height, format->format.field); in it6616_get_fmt()
3786 if (fie->index >= ARRAY_SIZE(supported_modes)) in it6616_enum_frame_interval()
3787 return -EINVAL; in it6616_enum_frame_interval()
3789 fie->code = IT6616_MEDIA_BUS_FMT; in it6616_enum_frame_interval()
3791 fie->width = supported_modes[fie->index].width; in it6616_enum_frame_interval()
3792 fie->height = supported_modes[fie->index].height; in it6616_enum_frame_interval()
3793 fie->interval = supported_modes[fie->index].max_fps; in it6616_enum_frame_interval()
3801 return abs(mode->width - framefmt->width) + in it6616_get_reso_dist()
3802 abs(mode->height - framefmt->height); in it6616_get_reso_dist()
3808 struct v4l2_mbus_framefmt *framefmt = &fmt->format; in it6616_find_best_fit()
3811 int cur_best_fit_dist = -1; in it6616_find_best_fit()
3816 if (cur_best_fit_dist == -1 || dist < cur_best_fit_dist) { in it6616_find_best_fit()
3833 u32 code = format->format.code; in it6616_set_fmt()
3836 format->format.code = code; in it6616_set_fmt()
3846 return -EINVAL; in it6616_set_fmt()
3849 if (format->which == V4L2_SUBDEV_FORMAT_TRY) in it6616_set_fmt()
3852 it6616->mbus_fmt_code = format->format.code; in it6616_set_fmt()
3854 it6616->cur_mode = mode; in it6616_set_fmt()
3863 const struct it6616_mode *mode = it6616->cur_mode; in it6616_g_frame_interval()
3865 mutex_lock(&it6616->confctl_mutex); in it6616_g_frame_interval()
3866 fi->interval = mode->max_fps; in it6616_g_frame_interval()
3867 mutex_unlock(&it6616->confctl_mutex); in it6616_g_frame_interval()
3876 strscpy(inf->base.sensor, IT6616_NAME, sizeof(inf->base.sensor)); in it6616_get_module_inf()
3877 strscpy(inf->base.module, it6616->module_name, sizeof(inf->base.module)); in it6616_get_module_inf()
3878 strscpy(inf->base.lens, it6616->len_name, sizeof(inf->base.lens)); in it6616_get_module_inf()
3894 ret = -ENOIOCTLCMD; in it6616_ioctl()
3906 mutex_lock(&it6616->confctl_mutex); in it6616_s_power()
3908 if (it6616->power_on == !!on) in it6616_s_power()
3912 it6616->power_on = true; in it6616_s_power()
3914 it6616->power_on = false; in it6616_s_power()
3917 mutex_unlock(&it6616->confctl_mutex); in it6616_s_power()
3935 ret = -ENOMEM; in it6616_compat_ioctl32()
3943 ret = -EFAULT; in it6616_compat_ioctl32()
3950 ret = -ENOMEM; in it6616_compat_ioctl32()
3958 ret = -EFAULT; in it6616_compat_ioctl32()
3963 ret = -ENOIOCTLCMD; in it6616_compat_ioctl32()
3976 v4l2_subdev_get_try_format(sd, fh->pad, 0); in it6616_open()
3979 mutex_lock(&it6616->confctl_mutex); in it6616_open()
3981 try_fmt->width = def_mode->width; in it6616_open()
3982 try_fmt->height = def_mode->height; in it6616_open()
3983 try_fmt->code = IT6616_MEDIA_BUS_FMT; in it6616_open()
3984 try_fmt->field = V4L2_FIELD_NONE; in it6616_open()
3985 mutex_unlock(&it6616->confctl_mutex); in it6616_open()
4058 gpiod_set_value(it6616->reset_gpio, 0); in it6616_reset()
4060 gpiod_set_value(it6616->reset_gpio, 1); in it6616_reset()
4062 gpiod_set_value(it6616->reset_gpio, 0); in it6616_reset()
4071 sd = &it6616->sd; in it6616_init_v4l2_ctrls()
4072 ret = v4l2_ctrl_handler_init(&it6616->hdl, 5); in it6616_init_v4l2_ctrls()
4076 it6616->link_freq = v4l2_ctrl_new_int_menu(&it6616->hdl, NULL, in it6616_init_v4l2_ctrls()
4078 ARRAY_SIZE(link_freq_menu_items) - 1, 0, in it6616_init_v4l2_ctrls()
4080 it6616->pixel_rate = v4l2_ctrl_new_std(&it6616->hdl, NULL, in it6616_init_v4l2_ctrls()
4084 it6616->detect_tx_5v_ctrl = v4l2_ctrl_new_std(&it6616->hdl, in it6616_init_v4l2_ctrls()
4088 it6616->audio_sampling_rate_ctrl = in it6616_init_v4l2_ctrls()
4089 v4l2_ctrl_new_custom(&it6616->hdl, in it6616_init_v4l2_ctrls()
4091 it6616->audio_present_ctrl = v4l2_ctrl_new_custom(&it6616->hdl, in it6616_init_v4l2_ctrls()
4094 sd->ctrl_handler = &it6616->hdl; in it6616_init_v4l2_ctrls()
4095 if (it6616->hdl.error) { in it6616_init_v4l2_ctrls()
4096 ret = it6616->hdl.error; in it6616_init_v4l2_ctrls()
4101 __v4l2_ctrl_s_ctrl(it6616->link_freq, link_freq_menu_items[0]); in it6616_init_v4l2_ctrls()
4102 __v4l2_ctrl_s_ctrl_int64(it6616->pixel_rate, IT6616_PIXEL_RATE); in it6616_init_v4l2_ctrls()
4105 ret = -ENODEV; in it6616_init_v4l2_ctrls()
4116 struct device *dev = &it6616->i2c_client->dev; in it6616_probe_of()
4117 struct device_node *node = dev->of_node; in it6616_probe_of()
4123 &it6616->module_index); in it6616_probe_of()
4125 &it6616->module_facing); in it6616_probe_of()
4127 &it6616->module_name); in it6616_probe_of()
4129 &it6616->len_name); in it6616_probe_of()
4132 return -EINVAL; in it6616_probe_of()
4135 it6616->power_gpio = devm_gpiod_get_optional(dev, "power", in it6616_probe_of()
4137 if (IS_ERR(it6616->power_gpio)) { in it6616_probe_of()
4139 ret = PTR_ERR(it6616->power_gpio); in it6616_probe_of()
4143 it6616->reset_gpio = devm_gpiod_get_optional(dev, "reset", in it6616_probe_of()
4145 if (IS_ERR(it6616->reset_gpio)) { in it6616_probe_of()
4147 ret = PTR_ERR(it6616->reset_gpio); in it6616_probe_of()
4151 ep = of_graph_get_next_endpoint(dev->of_node, NULL); in it6616_probe_of()
4154 return -EINVAL; in it6616_probe_of()
4165 dev_err(dev, "missing CSI-2 properties in endpoint\n"); in it6616_probe_of()
4166 ret = -EINVAL; in it6616_probe_of()
4170 it6616->xvclk = devm_clk_get(dev, "xvclk"); in it6616_probe_of()
4171 if (IS_ERR(it6616->xvclk)) { in it6616_probe_of()
4173 ret = -EINVAL; in it6616_probe_of()
4177 ret = clk_prepare_enable(it6616->xvclk); in it6616_probe_of()
4183 it6616->csi_lanes_in_use = endpoint.bus.mipi_csi2.num_data_lanes; in it6616_probe_of()
4184 it6616->bus = endpoint.bus.mipi_csi2; in it6616_probe_of()
4186 gpiod_set_value(it6616->power_gpio, 1); in it6616_probe_of()
4200 return -ENODEV; in it6616_probe_of()
4210 tx_5v_power_present(&it6616->sd) ? 1 : 0); in audio_present_show()
4219 code_to_rate_table[it6616->ainfo.force_sample_freq]); in audio_rate_show()
4229 it6616->hdmirx_class = class_create(THIS_MODULE, "hdmirx_it6616"); in it6616_create_class_attr()
4230 if (IS_ERR(it6616->hdmirx_class)) { in it6616_create_class_attr()
4231 ret = -ENOMEM; in it6616_create_class_attr()
4232 dev_err(it6616->dev, "failed to create hdmirx_it6616 class!\n"); in it6616_create_class_attr()
4236 it6616->classdev = device_create(it6616->hdmirx_class, NULL, in it6616_create_class_attr()
4238 if (IS_ERR(it6616->classdev)) { in it6616_create_class_attr()
4239 ret = PTR_ERR(it6616->classdev); in it6616_create_class_attr()
4240 dev_err(it6616->dev, "Failed to create device\n"); in it6616_create_class_attr()
4244 ret = device_create_file(it6616->classdev, in it6616_create_class_attr()
4247 dev_err(it6616->dev, "failed to create attr audio_present!\n"); in it6616_create_class_attr()
4251 ret = device_create_file(it6616->classdev, in it6616_create_class_attr()
4254 dev_err(it6616->dev, in it6616_create_class_attr()
4262 device_remove_file(it6616->classdev, &dev_attr_audio_present); in it6616_create_class_attr()
4264 class_destroy(it6616->hdmirx_class); in it6616_create_class_attr()
4270 device_remove_file(it6616->classdev, &dev_attr_audio_rate); in it6616_remove_class_attr()
4271 device_remove_file(it6616->classdev, &dev_attr_audio_present); in it6616_remove_class_attr()
4272 class_destroy(it6616->hdmirx_class); in it6616_remove_class_attr()
4280 struct device *dev = &client->dev; in it6616_probe()
4291 return -ENOMEM; in it6616_probe()
4293 sd = &it6616->sd; in it6616_probe()
4294 it6616->hdmi_i2c = client; in it6616_probe()
4295 it6616->mipi_i2c = i2c_new_dummy_device(client->adapter, in it6616_probe()
4298 if (!it6616->mipi_i2c) in it6616_probe()
4299 return -EIO; in it6616_probe()
4301 it6616->edid_i2c = i2c_new_dummy_device(client->adapter, in it6616_probe()
4304 if (!it6616->edid_i2c) in it6616_probe()
4307 it6616->hdmi_regmap = devm_regmap_init_i2c(client, in it6616_probe()
4309 if (IS_ERR(it6616->hdmi_i2c)) { in it6616_probe()
4310 err = PTR_ERR(it6616->hdmi_i2c); in it6616_probe()
4314 it6616->mipi_regmap = devm_regmap_init_i2c(it6616->mipi_i2c, in it6616_probe()
4316 if (IS_ERR(it6616->mipi_regmap)) { in it6616_probe()
4317 err = PTR_ERR(it6616->mipi_regmap); in it6616_probe()
4321 it6616->edid_regmap = devm_regmap_init_i2c(it6616->edid_i2c, in it6616_probe()
4323 if (IS_ERR(it6616->edid_regmap)) { in it6616_probe()
4324 err = PTR_ERR(it6616->edid_regmap); in it6616_probe()
4328 it6616->dev = dev; in it6616_probe()
4329 it6616->cur_mode = &supported_modes[0]; in it6616_probe()
4330 it6616->i2c_client = client; in it6616_probe()
4331 it6616->mbus_fmt_code = IT6616_MEDIA_BUS_FMT; in it6616_probe()
4339 mutex_init(&it6616->confctl_mutex); in it6616_probe()
4344 err = -ENODEV; in it6616_probe()
4348 err = sysfs_create_files(&client->dev.kobj, it6616_attrs); in it6616_probe()
4361 client->flags |= I2C_CLIENT_SCCB; in it6616_probe()
4364 sd->internal_ops = &it6616_internal_ops; in it6616_probe()
4365 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in it6616_probe()
4369 it6616->pad.flags = MEDIA_PAD_FL_SOURCE; in it6616_probe()
4370 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in it6616_probe()
4371 err = media_entity_pads_init(&sd->entity, 1, &it6616->pad); in it6616_probe()
4378 if (strcmp(it6616->module_facing, "back") == 0) in it6616_probe()
4383 snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", in it6616_probe()
4384 it6616->module_index, facing, in it6616_probe()
4385 IT6616_NAME, dev_name(sd->dev)); in it6616_probe()
4394 dev_err(it6616->dev, "create class attr failed! err:%d\n", err); in it6616_probe()
4395 return -ENODEV; in it6616_probe()
4398 INIT_DELAYED_WORK(&it6616->work_i2c_poll, it6616_work_i2c_poll); in it6616_probe()
4399 schedule_delayed_work(&it6616->work_i2c_poll, msecs_to_jiffies(500)); in it6616_probe()
4400 err = v4l2_ctrl_handler_setup(sd->ctrl_handler); in it6616_probe()
4406 v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name, in it6616_probe()
4407 client->addr << 1, client->adapter->name); in it6616_probe()
4413 cancel_delayed_work_sync(&it6616->work_i2c_poll); in it6616_probe()
4416 media_entity_cleanup(&sd->entity); in it6616_probe()
4419 v4l2_ctrl_handler_free(&it6616->hdl); in it6616_probe()
4420 mutex_destroy(&it6616->confctl_mutex); in it6616_probe()
4422 i2c_unregister_device(it6616->edid_i2c); in it6616_probe()
4424 i2c_unregister_device(it6616->mipi_i2c); in it6616_probe()
4434 cancel_delayed_work_sync(&it6616->work_i2c_poll); in it6616_remove()
4439 media_entity_cleanup(&sd->entity); in it6616_remove()
4441 v4l2_ctrl_handler_free(&it6616->hdl); in it6616_remove()
4442 sysfs_remove_files(&client->dev.kobj, it6616_attrs); in it6616_remove()
4443 mutex_destroy(&it6616->confctl_mutex); in it6616_remove()
4445 i2c_unregister_device(it6616->mipi_i2c); in it6616_remove()
4446 i2c_unregister_device(it6616->edid_i2c); in it6616_remove()
4447 clk_disable_unprepare(it6616->xvclk); in it6616_remove()
4482 MODULE_DESCRIPTION("ITE it6616 HDMI to CSI-2 bridge driver");
4483 MODULE_AUTHOR("Jianwei Fan <jianwei.fan@rock-chips.com>");