Lines Matching refs:adv7181
54 struct adv7181 { struct
70 #define to_adv7181(sd) container_of(sd, struct adv7181, subdev) argument
162 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_set_fmt() local
166 adv7181_fill_fmt(adv7181->cur_mode, mbus_fmt); in adv7181_set_fmt()
175 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_get_fmt() local
178 adv7181_fill_fmt(adv7181->cur_mode, mbus_fmt); in adv7181_get_fmt()
216 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_g_skip_top_lines() local
218 *lines = adv7181->skip_top; in adv7181_g_skip_top_lines()
231 static int __adv7181_power_on(struct adv7181 *adv7181) in __adv7181_power_on() argument
234 struct device *dev = &adv7181->client->dev; in __adv7181_power_on()
236 if (!IS_ERR(adv7181->xvclk)) { in __adv7181_power_on()
237 ret = clk_prepare_enable(adv7181->xvclk); in __adv7181_power_on()
244 gpiod_set_value_cansleep(adv7181->reset_gpio, 1); in __adv7181_power_on()
246 ret = regulator_bulk_enable(ADV7181_NUM_SUPPLIES, adv7181->supplies); in __adv7181_power_on()
252 gpiod_set_value_cansleep(adv7181->reset_gpio, 0); in __adv7181_power_on()
257 if (!IS_ERR(adv7181->xvclk)) in __adv7181_power_on()
258 clk_disable_unprepare(adv7181->xvclk); in __adv7181_power_on()
263 static void __adv7181_power_off(struct adv7181 *adv7181) in __adv7181_power_off() argument
265 if (!IS_ERR(adv7181->xvclk)) in __adv7181_power_off()
266 clk_disable_unprepare(adv7181->xvclk); in __adv7181_power_off()
267 gpiod_set_value_cansleep(adv7181->reset_gpio, 1); in __adv7181_power_off()
268 regulator_bulk_disable(ADV7181_NUM_SUPPLIES, adv7181->supplies); in __adv7181_power_off()
273 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_s_stream() local
274 struct i2c_client *client = adv7181->client; in adv7181_s_stream()
277 mutex_lock(&adv7181->mutex); in adv7181_s_stream()
280 if (on == adv7181->streaming) in adv7181_s_stream()
284 ret = pm_runtime_get_sync(&adv7181->client->dev); in adv7181_s_stream()
290 ret = adv7181_write_array(adv7181->client, in adv7181_s_stream()
291 adv7181->cur_mode->reg_list); in adv7181_s_stream()
309 adv7181->streaming = on; in adv7181_s_stream()
312 mutex_unlock(&adv7181->mutex); in adv7181_s_stream()
320 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_open() local
323 mutex_lock(&adv7181->mutex); in adv7181_open()
329 mutex_unlock(&adv7181->mutex); in adv7181_open()
339 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_runtime_resume() local
341 return __adv7181_power_on(adv7181); in adv7181_runtime_resume()
348 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_runtime_suspend() local
350 __adv7181_power_off(adv7181); in adv7181_runtime_suspend()
388 static int adv7181_check_sensor_id(struct adv7181 *adv7181, in adv7181_check_sensor_id() argument
391 struct device *dev = &adv7181->client->dev; in adv7181_check_sensor_id()
406 static int adv7181_configure_regulators(struct adv7181 *adv7181) in adv7181_configure_regulators() argument
411 adv7181->supplies[i].supply = adv7181_supply_names[i]; in adv7181_configure_regulators()
413 return devm_regulator_bulk_get(&adv7181->client->dev, in adv7181_configure_regulators()
415 adv7181->supplies); in adv7181_configure_regulators()
422 struct adv7181 *adv7181; in adv7181_probe() local
425 adv7181 = devm_kzalloc(dev, sizeof(*adv7181), GFP_KERNEL); in adv7181_probe()
426 if (!adv7181) in adv7181_probe()
429 adv7181->skip_top = ADV7181_SKIP_TOP; in adv7181_probe()
431 adv7181->client = client; in adv7181_probe()
432 adv7181->cur_mode = &supported_modes[0]; in adv7181_probe()
434 adv7181->xvclk = devm_clk_get(dev, "xvclk"); in adv7181_probe()
435 if (!IS_ERR(adv7181->xvclk)) { in adv7181_probe()
436 ret = clk_set_rate(adv7181->xvclk, ADV7181_XVCLK_FREQ); in adv7181_probe()
441 if (clk_get_rate(adv7181->xvclk) != ADV7181_XVCLK_FREQ) in adv7181_probe()
445 adv7181->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in adv7181_probe()
446 if (IS_ERR(adv7181->reset_gpio)) { in adv7181_probe()
451 ret = adv7181_configure_regulators(adv7181); in adv7181_probe()
457 mutex_init(&adv7181->mutex); in adv7181_probe()
458 v4l2_i2c_subdev_init(&adv7181->subdev, client, &adv7181_subdev_ops); in adv7181_probe()
460 ret = __adv7181_power_on(adv7181); in adv7181_probe()
464 ret = adv7181_check_sensor_id(adv7181, client); in adv7181_probe()
469 adv7181->subdev.internal_ops = &adv7181_internal_ops; in adv7181_probe()
470 adv7181->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adv7181_probe()
473 adv7181->pad.flags = MEDIA_PAD_FL_SOURCE; in adv7181_probe()
474 adv7181->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; in adv7181_probe()
475 ret = media_entity_init(&adv7181->subdev.entity, 1, &adv7181->pad, 0); in adv7181_probe()
480 ret = v4l2_async_register_subdev(&adv7181->subdev); in adv7181_probe()
494 media_entity_cleanup(&adv7181->subdev.entity); in adv7181_probe()
497 __adv7181_power_off(adv7181); in adv7181_probe()
499 mutex_destroy(&adv7181->mutex); in adv7181_probe()
507 struct adv7181 *adv7181 = to_adv7181(sd); in adv7181_remove() local
513 mutex_destroy(&adv7181->mutex); in adv7181_remove()
517 __adv7181_power_off(adv7181); in adv7181_remove()