Lines Matching refs:techpoint
41 static struct techpoint *g_techpoints[MAX_CHIPS];
51 #define to_techpoint(sd) container_of(sd, struct techpoint, subdev)
53 static int techpoint_get_regulators(struct techpoint *techpoint) in techpoint_get_regulators() argument
56 struct i2c_client *client = techpoint->client; in techpoint_get_regulators()
57 struct device *dev = &techpoint->client->dev; in techpoint_get_regulators()
59 if (!techpoint->supplies) in techpoint_get_regulators()
60 techpoint->supplies = devm_kzalloc(dev, in techpoint_get_regulators()
67 techpoint->supplies[i].supply = techpoint_supply_names[i]; in techpoint_get_regulators()
70 techpoint->supplies); in techpoint_get_regulators()
73 static int techpoint_analyze_dts(struct techpoint *techpoint) in techpoint_analyze_dts() argument
76 struct i2c_client *client = techpoint->client; in techpoint_analyze_dts()
84 &techpoint->module_index); in techpoint_analyze_dts()
86 &techpoint->module_facing); in techpoint_analyze_dts()
88 &techpoint->module_name); in techpoint_analyze_dts()
90 &techpoint->len_name); in techpoint_analyze_dts()
97 &techpoint->xvclk_freq_value); in techpoint_analyze_dts()
99 techpoint->xvclk_freq_value = 27000000; in techpoint_analyze_dts()
112 techpoint->data_lanes = rval; in techpoint_analyze_dts()
114 techpoint->xvclk = devm_clk_get(dev, "xvclk"); in techpoint_analyze_dts()
115 if (IS_ERR(techpoint->xvclk)) { in techpoint_analyze_dts()
120 techpoint->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH); in techpoint_analyze_dts()
121 if (IS_ERR(techpoint->power_gpio)) in techpoint_analyze_dts()
124 gpiod_set_value_cansleep(techpoint->power_gpio, 1); in techpoint_analyze_dts()
126 techpoint_get_regulators(techpoint); in techpoint_analyze_dts()
128 regulator_bulk_enable(TECHPOINT_NUM_SUPPLIES, techpoint->supplies); in techpoint_analyze_dts()
132 techpoint->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in techpoint_analyze_dts()
133 if (IS_ERR(techpoint->reset_gpio)) in techpoint_analyze_dts()
136 gpiod_set_value_cansleep(techpoint->reset_gpio, 0); in techpoint_analyze_dts()
138 techpoint->pinctrl = devm_pinctrl_get(dev); in techpoint_analyze_dts()
139 if (!IS_ERR(techpoint->pinctrl)) { in techpoint_analyze_dts()
140 techpoint->pins_default = in techpoint_analyze_dts()
141 pinctrl_lookup_state(techpoint->pinctrl, in techpoint_analyze_dts()
143 if (IS_ERR(techpoint->pins_default)) in techpoint_analyze_dts()
146 techpoint->pins_sleep = in techpoint_analyze_dts()
147 pinctrl_lookup_state(techpoint->pinctrl, in techpoint_analyze_dts()
149 if (IS_ERR(techpoint->pins_sleep)) in techpoint_analyze_dts()
158 static int techpoint_initialize_controls(struct techpoint *techpoint) in techpoint_initialize_controls() argument
164 struct device *dev = &techpoint->client->dev; in techpoint_initialize_controls()
166 handler = &techpoint->ctrl_handler; in techpoint_initialize_controls()
167 mode = techpoint->cur_video_mode; in techpoint_initialize_controls()
169 if (techpoint->input_type == TECHPOINT_DVP_BT1120) { in techpoint_initialize_controls()
173 handler->lock = &techpoint->mutex; in techpoint_initialize_controls()
175 techpoint->pixel_rate_ctrl = v4l2_ctrl_new_std(handler, NULL, in techpoint_initialize_controls()
180 } else if (techpoint->input_type == TECHPOINT_MIPI) { in techpoint_initialize_controls()
184 handler->lock = &techpoint->mutex; in techpoint_initialize_controls()
185 techpoint->link_freq_ctrl = in techpoint_initialize_controls()
188 __v4l2_ctrl_s_ctrl(techpoint->link_freq_ctrl, 0); in techpoint_initialize_controls()
194 techpoint->pixel_rate_ctrl = in techpoint_initialize_controls()
206 techpoint->subdev.ctrl_handler = handler; in techpoint_initialize_controls()
216 static int __techpoint_power_on(struct techpoint *techpoint) in __techpoint_power_on() argument
219 struct device *dev = &techpoint->client->dev; in __techpoint_power_on()
221 if (!IS_ERR_OR_NULL(techpoint->pins_default)) { in __techpoint_power_on()
222 ret = pinctrl_select_state(techpoint->pinctrl, in __techpoint_power_on()
223 techpoint->pins_default); in __techpoint_power_on()
228 if (!IS_ERR(techpoint->power_gpio)) { in __techpoint_power_on()
229 gpiod_set_value_cansleep(techpoint->power_gpio, 1); in __techpoint_power_on()
235 if (!IS_ERR(techpoint->xvclk)) { in __techpoint_power_on()
237 clk_set_rate(techpoint->xvclk, techpoint->xvclk_freq_value); in __techpoint_power_on()
240 if (clk_get_rate(techpoint->xvclk) != in __techpoint_power_on()
241 techpoint->xvclk_freq_value) in __techpoint_power_on()
243 ret = clk_prepare_enable(techpoint->xvclk); in __techpoint_power_on()
250 if (!IS_ERR(techpoint->reset_gpio)) { in __techpoint_power_on()
251 gpiod_set_value_cansleep(techpoint->reset_gpio, 0); in __techpoint_power_on()
253 gpiod_set_value_cansleep(techpoint->reset_gpio, 1); in __techpoint_power_on()
255 gpiod_set_value_cansleep(techpoint->reset_gpio, 0); in __techpoint_power_on()
263 if (!IS_ERR(techpoint->reset_gpio)) in __techpoint_power_on()
264 gpiod_set_value_cansleep(techpoint->reset_gpio, 0); in __techpoint_power_on()
266 if (!IS_ERR_OR_NULL(techpoint->pins_sleep)) in __techpoint_power_on()
267 pinctrl_select_state(techpoint->pinctrl, techpoint->pins_sleep); in __techpoint_power_on()
269 if (!IS_ERR(techpoint->power_gpio)) in __techpoint_power_on()
270 gpiod_set_value_cansleep(techpoint->power_gpio, 0); in __techpoint_power_on()
275 static void __techpoint_power_off(struct techpoint *techpoint) in __techpoint_power_off() argument
283 if (!IS_ERR(techpoint->reset_gpio)) in __techpoint_power_off()
284 gpiod_set_value_cansleep(techpoint->reset_gpio, 1); in __techpoint_power_off()
286 if (IS_ERR(techpoint->xvclk)) in __techpoint_power_off()
287 clk_disable_unprepare(techpoint->xvclk); in __techpoint_power_off()
289 if (!IS_ERR_OR_NULL(techpoint->pins_sleep)) { in __techpoint_power_off()
290 ret = pinctrl_select_state(techpoint->pinctrl, in __techpoint_power_off()
291 techpoint->pins_sleep); in __techpoint_power_off()
293 dev_err(&techpoint->client->dev, "could not set pins\n"); in __techpoint_power_off()
296 if (!IS_ERR(techpoint->power_gpio)) in __techpoint_power_off()
297 gpiod_set_value_cansleep(techpoint->power_gpio, 0); in __techpoint_power_off()
304 struct techpoint *techpoint = to_techpoint(sd); in techpoint_runtime_resume() local
306 return __techpoint_power_on(techpoint); in techpoint_runtime_resume()
313 struct techpoint *techpoint = to_techpoint(sd); in techpoint_runtime_suspend() local
315 __techpoint_power_off(techpoint); in techpoint_runtime_suspend()
322 struct techpoint *techpoint = to_techpoint(sd); in techpoint_power() local
323 struct i2c_client *client = techpoint->client; in techpoint_power()
326 mutex_lock(&techpoint->mutex); in techpoint_power()
329 if (techpoint->power_on == !!on) in techpoint_power()
340 techpoint->power_on = true; in techpoint_power()
343 techpoint->power_on = false; in techpoint_power()
347 mutex_unlock(&techpoint->mutex); in techpoint_power()
360 techpoint_find_best_fit(struct techpoint *techpoint, in techpoint_find_best_fit() argument
369 for (i = 0; i < techpoint->video_modes_num; i++) { in techpoint_find_best_fit()
371 techpoint_get_reso_dist(&techpoint->video_modes[i], in techpoint_find_best_fit()
374 techpoint->video_modes[i].bus_fmt == framefmt->code) { in techpoint_find_best_fit()
380 return &techpoint->video_modes[cur_best_fit]; in techpoint_find_best_fit()
387 struct techpoint *techpoint = to_techpoint(sd); in techpoint_set_fmt() local
390 mutex_lock(&techpoint->mutex); in techpoint_set_fmt()
392 mode = techpoint_find_best_fit(techpoint, fmt); in techpoint_set_fmt()
393 techpoint->cur_video_mode = mode; in techpoint_set_fmt()
404 mutex_unlock(&techpoint->mutex); in techpoint_set_fmt()
408 if (techpoint->streaming) { in techpoint_set_fmt()
409 mutex_unlock(&techpoint->mutex); in techpoint_set_fmt()
414 mutex_unlock(&techpoint->mutex); in techpoint_set_fmt()
422 struct techpoint *techpoint = to_techpoint(sd); in techpoint_get_fmt() local
423 struct i2c_client *client = techpoint->client; in techpoint_get_fmt()
424 const struct techpoint_video_modes *mode = techpoint->cur_video_mode; in techpoint_get_fmt()
426 mutex_lock(&techpoint->mutex); in techpoint_get_fmt()
431 mutex_unlock(&techpoint->mutex); in techpoint_get_fmt()
445 mutex_unlock(&techpoint->mutex); in techpoint_get_fmt()
458 struct techpoint *techpoint = to_techpoint(sd); in techpoint_enum_mbus_code() local
462 code->code = techpoint->cur_video_mode->bus_fmt; in techpoint_enum_mbus_code()
471 struct techpoint *techpoint = to_techpoint(sd); in techpoint_enum_frame_sizes() local
473 if (fse->index >= techpoint->video_modes_num) in techpoint_enum_frame_sizes()
476 if (fse->code != techpoint->video_modes[fse->index].bus_fmt) in techpoint_enum_frame_sizes()
479 fse->min_width = techpoint->video_modes[fse->index].width; in techpoint_enum_frame_sizes()
480 fse->max_width = techpoint->video_modes[fse->index].width; in techpoint_enum_frame_sizes()
481 fse->max_height = techpoint->video_modes[fse->index].height; in techpoint_enum_frame_sizes()
482 fse->min_height = techpoint->video_modes[fse->index].height; in techpoint_enum_frame_sizes()
490 struct techpoint *techpoint = to_techpoint(sd); in techpoint_g_frame_interval() local
492 mutex_lock(&techpoint->mutex); in techpoint_g_frame_interval()
493 fi->interval = techpoint->cur_video_mode->max_fps; in techpoint_g_frame_interval()
494 mutex_unlock(&techpoint->mutex); in techpoint_g_frame_interval()
503 struct techpoint *techpoint = to_techpoint(sd); in techpoint_g_mbus_config() local
505 if (techpoint->input_type == TECHPOINT_DVP_BT1120) { in techpoint_g_mbus_config()
510 } else if (techpoint->input_type == TECHPOINT_MIPI) { in techpoint_g_mbus_config()
512 if (techpoint->data_lanes == 4) { in techpoint_g_mbus_config()
514 } else if (techpoint->data_lanes == 2) { in techpoint_g_mbus_config()
526 struct techpoint *techpoint = to_techpoint(sd); in techpoint_querystd() local
528 if (techpoint->input_type == TECHPOINT_DVP_BT1120) in techpoint_querystd()
534 static __maybe_unused void techpoint_get_module_inf(struct techpoint *techpoint, in techpoint_get_module_inf() argument
539 strscpy(inf->base.module, techpoint->module_name, in techpoint_get_module_inf()
541 strscpy(inf->base.lens, techpoint->len_name, sizeof(inf->base.lens)); in techpoint_get_module_inf()
545 techpoint_get_bt656_module_inf(struct techpoint *techpoint, in techpoint_get_bt656_module_inf() argument
549 if (techpoint->input_type == TECHPOINT_DVP_BT1120) { in techpoint_get_bt656_module_inf()
556 static void techpoint_get_vicap_rst_inf(struct techpoint *techpoint, in techpoint_get_vicap_rst_inf() argument
559 rst_info->is_reset = techpoint->do_reset; in techpoint_get_vicap_rst_inf()
563 static void techpoint_set_vicap_rst_inf(struct techpoint *techpoint, in techpoint_set_vicap_rst_inf() argument
566 techpoint->do_reset = rst_info->is_reset; in techpoint_set_vicap_rst_inf()
571 struct techpoint *techpoint = to_techpoint(sd); in techpoint_ioctl() local
576 techpoint_get_module_inf(techpoint, (struct rkmodule_inf *)arg); in techpoint_ioctl()
579 techpoint_get_bt656_module_inf(techpoint, in techpoint_ioctl()
584 if (!techpoint->streaming) in techpoint_ioctl()
585 techpoint_get_vc_fmt_inf(techpoint, in techpoint_ioctl()
589 __techpoint_get_vc_fmt_inf(techpoint, in techpoint_ioctl()
594 techpoint_get_vc_hotplug_inf(techpoint, in techpoint_ioctl()
602 techpoint_get_vicap_rst_inf(techpoint, in techpoint_ioctl()
607 techpoint_set_vicap_rst_inf(techpoint, in techpoint_ioctl()
612 techpoint_set_quick_stream(techpoint, *((u32 *)arg)); in techpoint_ioctl()
773 static __maybe_unused int __techpoint_start_stream(struct techpoint *techpoint) in __techpoint_start_stream() argument
775 techpoint_start_video_stream(techpoint); in __techpoint_start_stream()
779 static __maybe_unused int __techpoint_stop_stream(struct techpoint *techpoint) in __techpoint_stop_stream() argument
781 techpoint_stop_video_stream(techpoint); in __techpoint_stop_stream()
787 struct techpoint *techpoint = to_techpoint(sd); in techpoint_stream() local
788 struct i2c_client *client = techpoint->client; in techpoint_stream()
791 techpoint->cur_video_mode->width, in techpoint_stream()
792 techpoint->cur_video_mode->height); in techpoint_stream()
794 mutex_lock(&techpoint->mutex); in techpoint_stream()
796 if (techpoint->streaming == on) in techpoint_stream()
800 __techpoint_start_stream(techpoint); in techpoint_stream()
802 __techpoint_stop_stream(techpoint); in techpoint_stream()
804 techpoint->streaming = on; in techpoint_stream()
807 mutex_unlock(&techpoint->mutex); in techpoint_stream()
874 static int techpoint_9930_audio_init(struct techpoint *techpoint);
898 struct techpoint *techpoint = in i2c_rdwr_store() local
899 container_of(dev, struct techpoint, dev); in i2c_rdwr_store()
906 dev_err(&techpoint->client->dev, "%s sscanf failed: %d\n", in i2c_rdwr_store()
912 techpoint_read_reg(techpoint->client, reg, (unsigned char *)&v); in i2c_rdwr_store()
914 techpoint_write_reg(techpoint->client, reg, v); in i2c_rdwr_store()
916 techpoint_9930_audio_init(techpoint); in i2c_rdwr_store()
1055 static int techpoint_2855_audio_init(struct techpoint *techpoint) in techpoint_2855_audio_init() argument
1057 struct i2c_client *client = techpoint->client; in techpoint_2855_audio_init()
1099 static int techpoint_9930_audio_init(struct techpoint *techpoint) in techpoint_9930_audio_init() argument
1101 struct i2c_client *client = techpoint->client; in techpoint_9930_audio_init()
1143 static int techpoint_audio_init(struct techpoint *techpoint) in techpoint_audio_init() argument
1145 if (techpoint) in techpoint_audio_init()
1146 techpoint_2855_audio_init(techpoint); in techpoint_audio_init()
1148 if (techpoint && techpoint->audio_in) in techpoint_audio_init()
1149 techpoint_9930_audio_init(techpoint->audio_in->slave_tp[0]); in techpoint_audio_init()
1154 static int techpoint_audio_dt_parse(struct techpoint *techpoint) in techpoint_audio_dt_parse() argument
1156 struct device *dev = &techpoint->client->dev; in techpoint_audio_dt_parse()
1162 techpoint->audio_in = NULL; in techpoint_audio_dt_parse()
1166 techpoint->audio_in = devm_kzalloc(dev, sizeof(struct techpoint_audio), in techpoint_audio_dt_parse()
1168 if (!techpoint->audio_in) in techpoint_audio_dt_parse()
1171 audio_stream = techpoint->audio_in; in techpoint_audio_dt_parse()
1222 struct techpoint *tp = g_techpoints[i]; in techpoint_audio_dt_parse()
1224 if (tp->i2c_idx != techpoint->i2c_idx) { in techpoint_audio_dt_parse()
1232 techpoint->audio_out = NULL; in techpoint_audio_dt_parse()
1236 techpoint->audio_out = devm_kzalloc(dev, sizeof(struct techpoint_audio), in techpoint_audio_dt_parse()
1238 if (!techpoint->audio_out) in techpoint_audio_dt_parse()
1241 audio_stream = techpoint->audio_out; in techpoint_audio_dt_parse()
1276 if (!techpoint->audio_in && !techpoint->audio_out) in techpoint_audio_dt_parse()
1282 static int techpoint_audio_probe(struct techpoint *techpoint) in techpoint_audio_probe() argument
1284 struct device *dev = &techpoint->client->dev; in techpoint_audio_probe()
1288 switch (techpoint->chip_id) { in techpoint_audio_probe()
1290 techpoint_9930_audio_init(techpoint); in techpoint_audio_probe()
1293 techpoint_2855_audio_init(techpoint); in techpoint_audio_probe()
1299 if (techpoint->chip_id == CHIP_TP9930) { in techpoint_audio_probe()
1301 techpoint_write_reg(techpoint->client, 0x40, 0x00); in techpoint_audio_probe()
1303 techpoint_write_reg(techpoint->client, i, 0xbb); in techpoint_audio_probe()
1306 ret = techpoint_audio_dt_parse(techpoint); in techpoint_audio_probe()
1312 ret = techpoint_audio_init(techpoint); in techpoint_audio_probe()
1337 struct techpoint *techpoint) in techpoint_sysfs_init() argument
1339 struct device *dev = &techpoint->dev; in techpoint_sysfs_init()
1370 struct techpoint *techpoint; in techpoint_probe() local
1379 techpoint = devm_kzalloc(dev, sizeof(*techpoint), GFP_KERNEL); in techpoint_probe()
1380 if (!techpoint) in techpoint_probe()
1383 techpoint->client = client; in techpoint_probe()
1384 techpoint->supplies = NULL; in techpoint_probe()
1386 techpoint_sysfs_init(client, techpoint); in techpoint_probe()
1388 mutex_init(&techpoint->mutex); in techpoint_probe()
1390 sd = &techpoint->subdev; in techpoint_probe()
1393 techpoint_analyze_dts(techpoint); in techpoint_probe()
1395 ret = __techpoint_power_on(techpoint); in techpoint_probe()
1401 ret = techpoint_initialize_devices(techpoint); in techpoint_probe()
1407 ret = techpoint_initialize_controls(techpoint); in techpoint_probe()
1419 techpoint->pad[index].flags = MEDIA_PAD_FL_SOURCE; in techpoint_probe()
1421 ret = media_entity_pads_init(&sd->entity, PAD_MAX, techpoint->pad); in techpoint_probe()
1427 if (strcmp(techpoint->module_facing, "back") == 0) in techpoint_probe()
1433 techpoint->module_index, facing, in techpoint_probe()
1442 techpoint->i2c_idx = g_idx; in techpoint_probe()
1443 g_techpoints[g_idx++] = techpoint; in techpoint_probe()
1445 ret = techpoint_audio_probe(techpoint); in techpoint_probe()
1462 v4l2_ctrl_handler_free(&techpoint->ctrl_handler); in techpoint_probe()
1464 __techpoint_power_off(techpoint); in techpoint_probe()
1466 mutex_destroy(&techpoint->mutex); in techpoint_probe()
1474 struct techpoint *techpoint = to_techpoint(sd); in techpoint_remove() local
1480 v4l2_ctrl_handler_free(&techpoint->ctrl_handler); in techpoint_remove()
1481 mutex_destroy(&techpoint->mutex); in techpoint_remove()
1485 __techpoint_power_off(techpoint); in techpoint_remove()