Lines Matching refs:lt6911uxe

162 struct lt6911uxe {  struct
549 static inline struct lt6911uxe *to_lt6911uxe(struct v4l2_subdev *sd) in to_lt6911uxe()
551 return container_of(sd, struct lt6911uxe, sd); in to_lt6911uxe()
556 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in i2c_rd() local
557 struct i2c_client *client = lt6911uxe->i2c_client; in i2c_rd()
608 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in i2c_wr() local
609 struct i2c_client *client = lt6911uxe->i2c_client; in i2c_wr()
700 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in tx_5v_power_present() local
703 if (!lt6911uxe->plugin_det_gpio) in tx_5v_power_present()
708 val = gpiod_get_value(lt6911uxe->plugin_det_gpio); in tx_5v_power_present()
722 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in no_signal() local
725 lt6911uxe->nosignal); in no_signal()
727 return lt6911uxe->nosignal; in no_signal()
732 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in audio_present() local
734 return lt6911uxe->is_audio_present; in audio_present()
762 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_rcv_supported_res() local
765 for (i = 0; i < lt6911uxe->cfg_num; i++) { in lt6911uxe_rcv_supported_res()
766 if ((lt6911uxe->support_modes[i].width == width) && in lt6911uxe_rcv_supported_res()
767 (lt6911uxe->support_modes[i].height == height)) { in lt6911uxe_rcv_supported_res()
772 if (i == lt6911uxe->cfg_num) { in lt6911uxe_rcv_supported_res()
784 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_get_detected_timings() local
840 lt6911uxe->nosignal = false; in lt6911uxe_get_detected_timings()
841 lt6911uxe->is_audio_present = true; in lt6911uxe_get_detected_timings()
866 lt6911uxe->nosignal = true; in lt6911uxe_get_detected_timings()
885 struct lt6911uxe *lt6911uxe = container_of(dwork, in lt6911uxe_delayed_work_hotplug() local
886 struct lt6911uxe, delayed_work_hotplug); in lt6911uxe_delayed_work_hotplug()
887 struct v4l2_subdev *sd = &lt6911uxe->sd; in lt6911uxe_delayed_work_hotplug()
895 struct lt6911uxe *lt6911uxe = container_of(dwork, in lt6911uxe_delayed_work_res_change() local
896 struct lt6911uxe, delayed_work_res_change); in lt6911uxe_delayed_work_res_change()
897 struct v4l2_subdev *sd = &lt6911uxe->sd; in lt6911uxe_delayed_work_res_change()
904 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_ctrl_detect_tx_5v() local
906 return v4l2_ctrl_s_ctrl(lt6911uxe->detect_tx_5v_ctrl, in lt6911uxe_s_ctrl_detect_tx_5v()
912 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_ctrl_audio_sampling_rate() local
914 return v4l2_ctrl_s_ctrl(lt6911uxe->audio_sampling_rate_ctrl, in lt6911uxe_s_ctrl_audio_sampling_rate()
920 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_ctrl_audio_present() local
922 return v4l2_ctrl_s_ctrl(lt6911uxe->audio_present_ctrl, in lt6911uxe_s_ctrl_audio_present()
964 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in enable_stream() local
970 i2c_wr8(&lt6911uxe->sd, STREAM_CTL, ENABLE_STREAM); in enable_stream()
972 i2c_wr8(&lt6911uxe->sd, STREAM_CTL, DISABLE_STREAM); in enable_stream()
983 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_format_change() local
995 if (!v4l2_match_dv_timings(&lt6911uxe->timings, &timings, 0, false)) { in lt6911uxe_format_change()
1002 if (sd->devnode && !lt6911uxe->i2c_client->irq) in lt6911uxe_format_change()
1005 if (sd->devnode && lt6911uxe->i2c_client->irq) in lt6911uxe_format_change()
1011 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_isr() local
1013 schedule_delayed_work(&lt6911uxe->delayed_work_res_change, HZ / 20); in lt6911uxe_isr()
1021 struct lt6911uxe *lt6911uxe = dev_id; in lt6911uxe_res_change_irq_handler() local
1024 lt6911uxe_isr(&lt6911uxe->sd, 0, &handled); in lt6911uxe_res_change_irq_handler()
1031 struct lt6911uxe *lt6911uxe = dev_id; in plugin_detect_irq_handler() local
1034 schedule_delayed_work(&lt6911uxe->delayed_work_hotplug, in plugin_detect_irq_handler()
1042 struct lt6911uxe *lt6911uxe = from_timer(lt6911uxe, t, timer); in lt6911uxe_irq_poll_timer() local
1044 schedule_work(&lt6911uxe->work_i2c_poll); in lt6911uxe_irq_poll_timer()
1045 mod_timer(&lt6911uxe->timer, jiffies + msecs_to_jiffies(POLL_INTERVAL_MS)); in lt6911uxe_irq_poll_timer()
1050 struct lt6911uxe *lt6911uxe = container_of(work, in lt6911uxe_work_i2c_poll() local
1051 struct lt6911uxe, work_i2c_poll); in lt6911uxe_work_i2c_poll()
1052 struct v4l2_subdev *sd = &lt6911uxe->sd; in lt6911uxe_work_i2c_poll()
1083 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_dv_timings() local
1092 if (v4l2_match_dv_timings(&lt6911uxe->timings, timings, 0, false)) { in lt6911uxe_s_dv_timings()
1103 lt6911uxe->timings = *timings; in lt6911uxe_s_dv_timings()
1113 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_g_dv_timings() local
1115 *timings = lt6911uxe->timings; in lt6911uxe_g_dv_timings()
1133 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_query_dv_timings() local
1135 *timings = lt6911uxe->timings; in lt6911uxe_query_dv_timings()
1165 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_g_mbus_config() local
1166 u32 lane_num = lt6911uxe->bus_cfg.bus.mipi_csi2.num_data_lanes; in lt6911uxe_g_mbus_config()
1173 cfg->type = lt6911uxe->bus_cfg.bus_type; in lt6911uxe_g_mbus_config()
1181 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_stream() local
1182 struct i2c_client *client = lt6911uxe->i2c_client; in lt6911uxe_s_stream()
1185 lt6911uxe->cur_mode->width, in lt6911uxe_s_stream()
1186 lt6911uxe->cur_mode->height, in lt6911uxe_s_stream()
1187 lt6911uxe->cur_mode->interlace ? "I" : "P", in lt6911uxe_s_stream()
1188 DIV_ROUND_CLOSEST(lt6911uxe->cur_mode->max_fps.denominator, in lt6911uxe_s_stream()
1189 lt6911uxe->cur_mode->max_fps.numerator)); in lt6911uxe_s_stream()
1215 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_enum_frame_sizes() local
1217 if (fse->index >= lt6911uxe->cfg_num) in lt6911uxe_enum_frame_sizes()
1223 fse->min_width = lt6911uxe->support_modes[fse->index].width; in lt6911uxe_enum_frame_sizes()
1224 fse->max_width = lt6911uxe->support_modes[fse->index].width; in lt6911uxe_enum_frame_sizes()
1225 fse->max_height = lt6911uxe->support_modes[fse->index].height; in lt6911uxe_enum_frame_sizes()
1226 fse->min_height = lt6911uxe->support_modes[fse->index].height; in lt6911uxe_enum_frame_sizes()
1235 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_enum_frame_interval() local
1237 if (fie->index >= lt6911uxe->cfg_num) in lt6911uxe_enum_frame_interval()
1242 fie->width = lt6911uxe->support_modes[fie->index].width; in lt6911uxe_enum_frame_interval()
1243 fie->height = lt6911uxe->support_modes[fie->index].height; in lt6911uxe_enum_frame_interval()
1244 fie->interval = lt6911uxe->support_modes[fie->index].max_fps; in lt6911uxe_enum_frame_interval()
1263 lt6911uxe_find_best_fit(struct lt6911uxe *lt6911uxe) in lt6911uxe_find_best_fit() argument
1270 for (i = 0; i < lt6911uxe->cfg_num; i++) { in lt6911uxe_find_best_fit()
1271 if (lt6911uxe->support_modes[i].interlace == lt6911uxe->timings.bt.interlaced) { in lt6911uxe_find_best_fit()
1272 dist = lt6911uxe_get_reso_dist(&lt6911uxe->support_modes[i], in lt6911uxe_find_best_fit()
1273 &lt6911uxe->timings); in lt6911uxe_find_best_fit()
1280 dev_info(&lt6911uxe->i2c_client->dev, in lt6911uxe_find_best_fit()
1282 cur_best_fit, lt6911uxe->support_modes[cur_best_fit].width, in lt6911uxe_find_best_fit()
1283 lt6911uxe->support_modes[cur_best_fit].height, in lt6911uxe_find_best_fit()
1284 lt6911uxe->support_modes[cur_best_fit].interlace ? "I" : "P", in lt6911uxe_find_best_fit()
1285 DIV_ROUND_CLOSEST(lt6911uxe->support_modes[cur_best_fit].max_fps.denominator, in lt6911uxe_find_best_fit()
1286 lt6911uxe->support_modes[cur_best_fit].max_fps.numerator)); in lt6911uxe_find_best_fit()
1288 return &lt6911uxe->support_modes[cur_best_fit]; in lt6911uxe_find_best_fit()
1295 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_get_fmt() local
1298 mutex_lock(&lt6911uxe->confctl_mutex); in lt6911uxe_get_fmt()
1299 format->format.code = lt6911uxe->mbus_fmt_code; in lt6911uxe_get_fmt()
1300 format->format.width = lt6911uxe->timings.bt.width; in lt6911uxe_get_fmt()
1301 format->format.height = lt6911uxe->timings.bt.height; in lt6911uxe_get_fmt()
1303 lt6911uxe->timings.bt.interlaced ? in lt6911uxe_get_fmt()
1306 mutex_unlock(&lt6911uxe->confctl_mutex); in lt6911uxe_get_fmt()
1308 mode = lt6911uxe_find_best_fit(lt6911uxe); in lt6911uxe_get_fmt()
1309 lt6911uxe->cur_mode = mode; in lt6911uxe_get_fmt()
1311 __v4l2_ctrl_s_ctrl_int64(lt6911uxe->pixel_rate, in lt6911uxe_get_fmt()
1313 __v4l2_ctrl_s_ctrl(lt6911uxe->link_freq, in lt6911uxe_get_fmt()
1329 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_set_fmt() local
1352 lt6911uxe->mbus_fmt_code = format->format.code; in lt6911uxe_set_fmt()
1353 mode = lt6911uxe_find_best_fit(lt6911uxe); in lt6911uxe_set_fmt()
1354 lt6911uxe->cur_mode = mode; in lt6911uxe_set_fmt()
1364 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_g_frame_interval() local
1365 const struct lt6911uxe_mode *mode = lt6911uxe->cur_mode; in lt6911uxe_g_frame_interval()
1367 mutex_lock(&lt6911uxe->confctl_mutex); in lt6911uxe_g_frame_interval()
1369 mutex_unlock(&lt6911uxe->confctl_mutex); in lt6911uxe_g_frame_interval()
1374 static void lt6911uxe_get_module_inf(struct lt6911uxe *lt6911uxe, in lt6911uxe_get_module_inf() argument
1379 strscpy(inf->base.module, lt6911uxe->module_name, sizeof(inf->base.module)); in lt6911uxe_get_module_inf()
1380 strscpy(inf->base.lens, lt6911uxe->len_name, sizeof(inf->base.lens)); in lt6911uxe_get_module_inf()
1385 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_ioctl() local
1391 lt6911uxe_get_module_inf(lt6911uxe, (struct rkmodule_inf *)arg); in lt6911uxe_ioctl()
1400 dev_dbg(&lt6911uxe->i2c_client->dev, in lt6911uxe_ioctl()
1407 dev_dbg(&lt6911uxe->i2c_client->dev, in lt6911uxe_ioctl()
1420 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_s_power() local
1423 mutex_lock(&lt6911uxe->confctl_mutex); in lt6911uxe_s_power()
1425 if (lt6911uxe->power_on == !!on) in lt6911uxe_s_power()
1429 lt6911uxe->power_on = true; in lt6911uxe_s_power()
1431 lt6911uxe->power_on = false; in lt6911uxe_s_power()
1434 mutex_unlock(&lt6911uxe->confctl_mutex); in lt6911uxe_s_power()
1521 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_open() local
1524 const struct lt6911uxe_mode *def_mode = &lt6911uxe->support_modes[0]; in lt6911uxe_open()
1526 mutex_lock(&lt6911uxe->confctl_mutex); in lt6911uxe_open()
1532 mutex_unlock(&lt6911uxe->confctl_mutex); in lt6911uxe_open()
1603 static void lt6911uxe_reset(struct lt6911uxe *lt6911uxe) in lt6911uxe_reset() argument
1605 gpiod_set_value(lt6911uxe->reset_gpio, 0); in lt6911uxe_reset()
1607 gpiod_set_value(lt6911uxe->reset_gpio, 1); in lt6911uxe_reset()
1609 gpiod_set_value(lt6911uxe->reset_gpio, 0); in lt6911uxe_reset()
1613 static int lt6911uxe_init_v4l2_ctrls(struct lt6911uxe *lt6911uxe) in lt6911uxe_init_v4l2_ctrls() argument
1619 mode = lt6911uxe->cur_mode; in lt6911uxe_init_v4l2_ctrls()
1620 sd = &lt6911uxe->sd; in lt6911uxe_init_v4l2_ctrls()
1621 ret = v4l2_ctrl_handler_init(&lt6911uxe->hdl, 5); in lt6911uxe_init_v4l2_ctrls()
1625 lt6911uxe->link_freq = v4l2_ctrl_new_int_menu(&lt6911uxe->hdl, NULL, in lt6911uxe_init_v4l2_ctrls()
1629 lt6911uxe->pixel_rate = v4l2_ctrl_new_std(&lt6911uxe->hdl, NULL, in lt6911uxe_init_v4l2_ctrls()
1633 lt6911uxe->detect_tx_5v_ctrl = v4l2_ctrl_new_std(&lt6911uxe->hdl, in lt6911uxe_init_v4l2_ctrls()
1637 lt6911uxe->audio_sampling_rate_ctrl = in lt6911uxe_init_v4l2_ctrls()
1638 v4l2_ctrl_new_custom(&lt6911uxe->hdl, in lt6911uxe_init_v4l2_ctrls()
1640 lt6911uxe->audio_present_ctrl = v4l2_ctrl_new_custom(&lt6911uxe->hdl, in lt6911uxe_init_v4l2_ctrls()
1643 sd->ctrl_handler = &lt6911uxe->hdl; in lt6911uxe_init_v4l2_ctrls()
1644 if (lt6911uxe->hdl.error) { in lt6911uxe_init_v4l2_ctrls()
1645 ret = lt6911uxe->hdl.error; in lt6911uxe_init_v4l2_ctrls()
1650 __v4l2_ctrl_s_ctrl(lt6911uxe->link_freq, mode->mipi_freq_idx); in lt6911uxe_init_v4l2_ctrls()
1651 __v4l2_ctrl_s_ctrl_int64(lt6911uxe->pixel_rate, LT6911UXE_PIXEL_RATE); in lt6911uxe_init_v4l2_ctrls()
1663 static int lt6911uxe_probe_of(struct lt6911uxe *lt6911uxe) in lt6911uxe_probe_of() argument
1665 struct device *dev = &lt6911uxe->i2c_client->dev; in lt6911uxe_probe_of()
1671 &lt6911uxe->module_index); in lt6911uxe_probe_of()
1673 &lt6911uxe->module_facing); in lt6911uxe_probe_of()
1675 &lt6911uxe->module_name); in lt6911uxe_probe_of()
1677 &lt6911uxe->len_name); in lt6911uxe_probe_of()
1683 lt6911uxe->power_gpio = devm_gpiod_get_optional(dev, "power", in lt6911uxe_probe_of()
1685 if (IS_ERR(lt6911uxe->power_gpio)) { in lt6911uxe_probe_of()
1687 ret = PTR_ERR(lt6911uxe->power_gpio); in lt6911uxe_probe_of()
1691 lt6911uxe->reset_gpio = devm_gpiod_get_optional(dev, "reset", in lt6911uxe_probe_of()
1693 if (IS_ERR(lt6911uxe->reset_gpio)) { in lt6911uxe_probe_of()
1695 ret = PTR_ERR(lt6911uxe->reset_gpio); in lt6911uxe_probe_of()
1699 lt6911uxe->plugin_det_gpio = devm_gpiod_get_optional(dev, "plugin-det", in lt6911uxe_probe_of()
1701 if (IS_ERR(lt6911uxe->plugin_det_gpio)) { in lt6911uxe_probe_of()
1703 ret = PTR_ERR(lt6911uxe->plugin_det_gpio); in lt6911uxe_probe_of()
1714 &lt6911uxe->bus_cfg); in lt6911uxe_probe_of()
1720 lt6911uxe->support_modes = supported_modes_dphy; in lt6911uxe_probe_of()
1721 lt6911uxe->cfg_num = ARRAY_SIZE(supported_modes_dphy); in lt6911uxe_probe_of()
1723 lt6911uxe->xvclk = devm_clk_get(dev, "xvclk"); in lt6911uxe_probe_of()
1724 if (IS_ERR(lt6911uxe->xvclk)) { in lt6911uxe_probe_of()
1730 ret = clk_prepare_enable(lt6911uxe->xvclk); in lt6911uxe_probe_of()
1736 lt6911uxe->enable_hdcp = false; in lt6911uxe_probe_of()
1738 gpiod_set_value(lt6911uxe->power_gpio, 1); in lt6911uxe_probe_of()
1739 lt6911uxe_reset(lt6911uxe); in lt6911uxe_probe_of()
1748 static inline int lt6911uxe_probe_of(struct lt6911uxe *state) in lt6911uxe_probe_of()
1753 static int lt6911uxe_check_chip_id(struct lt6911uxe *lt6911uxe) in lt6911uxe_check_chip_id() argument
1755 struct device *dev = &lt6911uxe->i2c_client->dev; in lt6911uxe_check_chip_id()
1756 struct v4l2_subdev *sd = &lt6911uxe->sd; in lt6911uxe_check_chip_id()
1782 struct lt6911uxe *lt6911uxe; in lt6911uxe_probe() local
1793 lt6911uxe = devm_kzalloc(dev, sizeof(struct lt6911uxe), GFP_KERNEL); in lt6911uxe_probe()
1794 if (!lt6911uxe) in lt6911uxe_probe()
1797 sd = &lt6911uxe->sd; in lt6911uxe_probe()
1798 lt6911uxe->i2c_client = client; in lt6911uxe_probe()
1799 lt6911uxe->mbus_fmt_code = LT6911UXE_MEDIA_BUS_FMT; in lt6911uxe_probe()
1801 err = lt6911uxe_probe_of(lt6911uxe); in lt6911uxe_probe()
1807 lt6911uxe->timings = default_timing; in lt6911uxe_probe()
1808 lt6911uxe->cur_mode = &lt6911uxe->support_modes[0]; in lt6911uxe_probe()
1809 err = lt6911uxe_check_chip_id(lt6911uxe); in lt6911uxe_probe()
1813 mutex_init(&lt6911uxe->confctl_mutex); in lt6911uxe_probe()
1814 err = lt6911uxe_init_v4l2_ctrls(lt6911uxe); in lt6911uxe_probe()
1826 lt6911uxe->pad.flags = MEDIA_PAD_FL_SOURCE; in lt6911uxe_probe()
1828 err = media_entity_pads_init(&sd->entity, 1, &lt6911uxe->pad); in lt6911uxe_probe()
1835 if (strcmp(lt6911uxe->module_facing, "back") == 0) in lt6911uxe_probe()
1841 lt6911uxe->module_index, facing, in lt6911uxe_probe()
1849 INIT_DELAYED_WORK(&lt6911uxe->delayed_work_hotplug, in lt6911uxe_probe()
1851 INIT_DELAYED_WORK(&lt6911uxe->delayed_work_res_change, in lt6911uxe_probe()
1854 if (lt6911uxe->i2c_client->irq) { in lt6911uxe_probe()
1857 lt6911uxe->i2c_client->irq, in lt6911uxe_probe()
1860 "lt6911uxe", lt6911uxe); in lt6911uxe_probe()
1867 INIT_WORK(&lt6911uxe->work_i2c_poll, lt6911uxe_work_i2c_poll); in lt6911uxe_probe()
1868 timer_setup(&lt6911uxe->timer, lt6911uxe_irq_poll_timer, 0); in lt6911uxe_probe()
1869 lt6911uxe->timer.expires = jiffies + in lt6911uxe_probe()
1871 add_timer(&lt6911uxe->timer); in lt6911uxe_probe()
1874 lt6911uxe->plugin_irq = gpiod_to_irq(lt6911uxe->plugin_det_gpio); in lt6911uxe_probe()
1875 if (lt6911uxe->plugin_irq < 0) in lt6911uxe_probe()
1878 err = devm_request_threaded_irq(dev, lt6911uxe->plugin_irq, NULL, in lt6911uxe_probe()
1881 lt6911uxe); in lt6911uxe_probe()
1897 if (!lt6911uxe->i2c_client->irq) in lt6911uxe_probe()
1898 flush_work(&lt6911uxe->work_i2c_poll); in lt6911uxe_probe()
1899 cancel_delayed_work(&lt6911uxe->delayed_work_hotplug); in lt6911uxe_probe()
1900 cancel_delayed_work(&lt6911uxe->delayed_work_res_change); in lt6911uxe_probe()
1906 v4l2_ctrl_handler_free(&lt6911uxe->hdl); in lt6911uxe_probe()
1907 mutex_destroy(&lt6911uxe->confctl_mutex); in lt6911uxe_probe()
1914 struct lt6911uxe *lt6911uxe = to_lt6911uxe(sd); in lt6911uxe_remove() local
1916 if (!lt6911uxe->i2c_client->irq) { in lt6911uxe_remove()
1917 del_timer_sync(&lt6911uxe->timer); in lt6911uxe_remove()
1918 flush_work(&lt6911uxe->work_i2c_poll); in lt6911uxe_remove()
1920 cancel_delayed_work_sync(&lt6911uxe->delayed_work_hotplug); in lt6911uxe_remove()
1921 cancel_delayed_work_sync(&lt6911uxe->delayed_work_res_change); in lt6911uxe_remove()
1927 v4l2_ctrl_handler_free(&lt6911uxe->hdl); in lt6911uxe_remove()
1928 mutex_destroy(&lt6911uxe->confctl_mutex); in lt6911uxe_remove()
1929 clk_disable_unprepare(lt6911uxe->xvclk); in lt6911uxe_remove()