Lines Matching refs:gc08a3
121 struct gc08a3 { struct
156 #define to_gc08a3(sd) container_of(sd, struct gc08a3, subdev) argument
1181 gc08a3_find_best_fit(struct gc08a3 *gc08a3, in gc08a3_find_best_fit() argument
1190 for (i = 0; i < gc08a3->cfg_num; i++) { in gc08a3_find_best_fit()
1191 dist = gc08a3_get_reso_dist(&gc08a3->support_modes[i], framefmt); in gc08a3_find_best_fit()
1198 return &gc08a3->support_modes[cur_best_fit]; in gc08a3_find_best_fit()
1205 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_set_fmt() local
1209 mutex_lock(&gc08a3->mutex); in gc08a3_set_fmt()
1211 mode = gc08a3_find_best_fit(gc08a3, fmt); in gc08a3_set_fmt()
1220 mutex_unlock(&gc08a3->mutex); in gc08a3_set_fmt()
1224 gc08a3->cur_mode = mode; in gc08a3_set_fmt()
1226 __v4l2_ctrl_modify_range(gc08a3->hblank, h_blank, in gc08a3_set_fmt()
1229 __v4l2_ctrl_modify_range(gc08a3->vblank, vblank_def, in gc08a3_set_fmt()
1232 __v4l2_ctrl_s_ctrl(gc08a3->link_freq, in gc08a3_set_fmt()
1235 dev_info(&gc08a3->client->dev, "%s: mode->mipi_freq_idx(%d)", in gc08a3_set_fmt()
1238 mutex_unlock(&gc08a3->mutex); in gc08a3_set_fmt()
1247 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_get_fmt() local
1248 const struct gc08a3_mode *mode = gc08a3->cur_mode; in gc08a3_get_fmt()
1250 mutex_lock(&gc08a3->mutex); in gc08a3_get_fmt()
1255 mutex_unlock(&gc08a3->mutex); in gc08a3_get_fmt()
1264 mutex_unlock(&gc08a3->mutex); in gc08a3_get_fmt()
1284 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_enum_frame_sizes() local
1286 if (fse->index >= gc08a3->cfg_num) in gc08a3_enum_frame_sizes()
1292 fse->min_width = gc08a3->support_modes[fse->index].width; in gc08a3_enum_frame_sizes()
1293 fse->max_width = gc08a3->support_modes[fse->index].width; in gc08a3_enum_frame_sizes()
1294 fse->max_height = gc08a3->support_modes[fse->index].height; in gc08a3_enum_frame_sizes()
1295 fse->min_height = gc08a3->support_modes[fse->index].height; in gc08a3_enum_frame_sizes()
1303 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_g_frame_interval() local
1304 const struct gc08a3_mode *mode = gc08a3->cur_mode; in gc08a3_g_frame_interval()
1311 static void gc08a3_get_module_inf(struct gc08a3 *gc08a3, in gc08a3_get_module_inf() argument
1318 gc08a3->module_name, in gc08a3_get_module_inf()
1321 gc08a3->len_name, in gc08a3_get_module_inf()
1325 static void gc08a3_set_module_inf(struct gc08a3 *gc08a3, in gc08a3_set_module_inf() argument
1328 mutex_lock(&gc08a3->mutex); in gc08a3_set_module_inf()
1329 memcpy(&gc08a3->awb_cfg, cfg, sizeof(*cfg)); in gc08a3_set_module_inf()
1330 mutex_unlock(&gc08a3->mutex); in gc08a3_set_module_inf()
1333 static int gc08a3_get_channel_info(struct gc08a3 *gc08a3, struct rkmodule_channel_info *ch_info) in gc08a3_get_channel_info() argument
1337 ch_info->vc = gc08a3->cur_mode->vc[ch_info->index]; in gc08a3_get_channel_info()
1338 ch_info->width = gc08a3->cur_mode->width; in gc08a3_get_channel_info()
1339 ch_info->height = gc08a3->cur_mode->height; in gc08a3_get_channel_info()
1346 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_ioctl() local
1353 gc08a3_get_module_inf(gc08a3, (struct rkmodule_inf *)arg); in gc08a3_ioctl()
1356 gc08a3_set_module_inf(gc08a3, (struct rkmodule_awb_cfg *)arg); in gc08a3_ioctl()
1363 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_ioctl()
1367 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_ioctl()
1374 ret = gc08a3_get_channel_info(gc08a3, ch_info); in gc08a3_ioctl()
1456 static int __gc08a3_start_stream(struct gc08a3 *gc08a3) in __gc08a3_start_stream() argument
1460 ret = gc08a3_write_array(gc08a3->client, gc08a3->cur_mode->reg_list); in __gc08a3_start_stream()
1465 mutex_unlock(&gc08a3->mutex); in __gc08a3_start_stream()
1466 ret = v4l2_ctrl_handler_setup(&gc08a3->ctrl_handler); in __gc08a3_start_stream()
1467 mutex_lock(&gc08a3->mutex); in __gc08a3_start_stream()
1468 ret |= gc08a3_write_reg(gc08a3->client, in __gc08a3_start_stream()
1474 static int __gc08a3_stop_stream(struct gc08a3 *gc08a3) in __gc08a3_stop_stream() argument
1478 ret = gc08a3_write_reg(gc08a3->client, in __gc08a3_stop_stream()
1487 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_s_stream() local
1488 struct i2c_client *client = gc08a3->client; in gc08a3_s_stream()
1492 gc08a3->cur_mode->width, in gc08a3_s_stream()
1493 gc08a3->cur_mode->height, in gc08a3_s_stream()
1494 DIV_ROUND_CLOSEST(gc08a3->cur_mode->max_fps.denominator, in gc08a3_s_stream()
1495 gc08a3->cur_mode->max_fps.numerator)); in gc08a3_s_stream()
1497 mutex_lock(&gc08a3->mutex); in gc08a3_s_stream()
1499 if (on == gc08a3->streaming) in gc08a3_s_stream()
1509 ret = __gc08a3_start_stream(gc08a3); in gc08a3_s_stream()
1516 __gc08a3_stop_stream(gc08a3); in gc08a3_s_stream()
1520 gc08a3->streaming = on; in gc08a3_s_stream()
1523 mutex_unlock(&gc08a3->mutex); in gc08a3_s_stream()
1530 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_s_power() local
1531 struct i2c_client *client = gc08a3->client; in gc08a3_s_power()
1535 mutex_lock(&gc08a3->mutex); in gc08a3_s_power()
1538 if (gc08a3->power_on == !!on) in gc08a3_s_power()
1548 ret = gc08a3_write_array(gc08a3->client, gc08a3->cur_mode->global_reg_list); in gc08a3_s_power()
1555 gc08a3->power_on = true; in gc08a3_s_power()
1558 gc08a3->power_on = false; in gc08a3_s_power()
1562 mutex_unlock(&gc08a3->mutex); in gc08a3_s_power()
1573 static int __gc08a3_power_on(struct gc08a3 *gc08a3) in __gc08a3_power_on() argument
1577 struct device *dev = &gc08a3->client->dev; in __gc08a3_power_on()
1579 if (!IS_ERR(gc08a3->power_gpio)) in __gc08a3_power_on()
1580 gpiod_set_value_cansleep(gc08a3->power_gpio, 1); in __gc08a3_power_on()
1584 if (!IS_ERR_OR_NULL(gc08a3->pins_default)) { in __gc08a3_power_on()
1585 ret = pinctrl_select_state(gc08a3->pinctrl, in __gc08a3_power_on()
1586 gc08a3->pins_default); in __gc08a3_power_on()
1590 ret = clk_set_rate(gc08a3->xvclk, GC08A3_XVCLK_FREQ); in __gc08a3_power_on()
1593 if (clk_get_rate(gc08a3->xvclk) != GC08A3_XVCLK_FREQ) in __gc08a3_power_on()
1595 ret = clk_prepare_enable(gc08a3->xvclk); in __gc08a3_power_on()
1600 if (!IS_ERR(gc08a3->reset_gpio)) in __gc08a3_power_on()
1601 gpiod_set_value_cansleep(gc08a3->reset_gpio, 0); in __gc08a3_power_on()
1603 ret = regulator_bulk_enable(GC08A3_NUM_SUPPLIES, gc08a3->supplies); in __gc08a3_power_on()
1610 if (!IS_ERR(gc08a3->reset_gpio)) in __gc08a3_power_on()
1611 gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); in __gc08a3_power_on()
1614 if (!IS_ERR(gc08a3->pwdn_gpio)) in __gc08a3_power_on()
1615 gpiod_set_value_cansleep(gc08a3->pwdn_gpio, 1); in __gc08a3_power_on()
1624 clk_disable_unprepare(gc08a3->xvclk); in __gc08a3_power_on()
1629 static void __gc08a3_power_off(struct gc08a3 *gc08a3) in __gc08a3_power_off() argument
1633 if (!IS_ERR(gc08a3->pwdn_gpio)) in __gc08a3_power_off()
1634 gpiod_set_value_cansleep(gc08a3->pwdn_gpio, 0); in __gc08a3_power_off()
1635 clk_disable_unprepare(gc08a3->xvclk); in __gc08a3_power_off()
1636 if (!IS_ERR(gc08a3->reset_gpio)) in __gc08a3_power_off()
1637 gpiod_set_value_cansleep(gc08a3->reset_gpio, 0); in __gc08a3_power_off()
1638 if (!IS_ERR_OR_NULL(gc08a3->pins_sleep)) { in __gc08a3_power_off()
1639 ret = pinctrl_select_state(gc08a3->pinctrl, in __gc08a3_power_off()
1640 gc08a3->pins_sleep); in __gc08a3_power_off()
1642 dev_dbg(&gc08a3->client->dev, "could not set pins\n"); in __gc08a3_power_off()
1644 if (!IS_ERR(gc08a3->power_gpio)) in __gc08a3_power_off()
1645 gpiod_set_value_cansleep(gc08a3->power_gpio, 0); in __gc08a3_power_off()
1647 regulator_bulk_disable(GC08A3_NUM_SUPPLIES, gc08a3->supplies); in __gc08a3_power_off()
1654 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_runtime_resume() local
1656 return __gc08a3_power_on(gc08a3); in gc08a3_runtime_resume()
1663 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_runtime_suspend() local
1665 __gc08a3_power_off(gc08a3); in gc08a3_runtime_suspend()
1673 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_open() local
1676 const struct gc08a3_mode *def_mode = &gc08a3->support_modes[0]; in gc08a3_open()
1678 mutex_lock(&gc08a3->mutex); in gc08a3_open()
1685 mutex_unlock(&gc08a3->mutex); in gc08a3_open()
1696 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_enum_frame_interval() local
1698 if (fie->index >= gc08a3->cfg_num) in gc08a3_enum_frame_interval()
1702 fie->width = gc08a3->support_modes[fie->index].width; in gc08a3_enum_frame_interval()
1703 fie->height = gc08a3->support_modes[fie->index].height; in gc08a3_enum_frame_interval()
1704 fie->interval = gc08a3->support_modes[fie->index].max_fps; in gc08a3_enum_frame_interval()
1711 struct gc08a3 *sensor = to_gc08a3(sd); in gc08a3_g_mbus_config()
1772 static int gc08a3_set_exposure_reg(struct gc08a3 *gc08a3, u32 exposure) in gc08a3_set_exposure_reg() argument
1780 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_set_exposure_reg()
1783 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_set_exposure_reg()
1789 static int gc08a3_set_gain_reg(struct gc08a3 *gc08a3, u32 a_gain) in gc08a3_set_gain_reg() argument
1801 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_set_gain_reg()
1805 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_set_gain_reg()
1814 struct gc08a3 *gc08a3 = container_of(ctrl->handler, in gc08a3_set_ctrl() local
1815 struct gc08a3, ctrl_handler); in gc08a3_set_ctrl()
1816 struct i2c_client *client = gc08a3->client; in gc08a3_set_ctrl()
1824 max = gc08a3->cur_mode->height + ctrl->val - 16; in gc08a3_set_ctrl()
1825 __v4l2_ctrl_modify_range(gc08a3->exposure, in gc08a3_set_ctrl()
1826 gc08a3->exposure->minimum, max, in gc08a3_set_ctrl()
1827 gc08a3->exposure->step, in gc08a3_set_ctrl()
1828 gc08a3->exposure->default_value); in gc08a3_set_ctrl()
1839 ret = gc08a3_set_exposure_reg(gc08a3, ctrl->val); in gc08a3_set_ctrl()
1843 ret = gc08a3_set_gain_reg(gc08a3, ctrl->val); in gc08a3_set_ctrl()
1847 ret = gc08a3_write_reg(gc08a3->client, in gc08a3_set_ctrl()
1849 (ctrl->val + gc08a3->cur_mode->height) in gc08a3_set_ctrl()
1851 ret |= gc08a3_write_reg(gc08a3->client, in gc08a3_set_ctrl()
1853 (ctrl->val + gc08a3->cur_mode->height) in gc08a3_set_ctrl()
1871 static int gc08a3_initialize_controls(struct gc08a3 *gc08a3) in gc08a3_initialize_controls() argument
1879 handler = &gc08a3->ctrl_handler; in gc08a3_initialize_controls()
1880 mode = gc08a3->cur_mode; in gc08a3_initialize_controls()
1884 handler->lock = &gc08a3->mutex; in gc08a3_initialize_controls()
1886 gc08a3->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, in gc08a3_initialize_controls()
1891 0, gc08a3->pixel_rate, 1, gc08a3->pixel_rate); in gc08a3_initialize_controls()
1893 __v4l2_ctrl_s_ctrl(gc08a3->link_freq, in gc08a3_initialize_controls()
1897 gc08a3->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in gc08a3_initialize_controls()
1899 if (gc08a3->hblank) in gc08a3_initialize_controls()
1900 gc08a3->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in gc08a3_initialize_controls()
1903 gc08a3->vblank = v4l2_ctrl_new_std(handler, &gc08a3_ctrl_ops, in gc08a3_initialize_controls()
1909 gc08a3->exposure = v4l2_ctrl_new_std(handler, &gc08a3_ctrl_ops, in gc08a3_initialize_controls()
1914 gc08a3->anal_gain = v4l2_ctrl_new_std(handler, &gc08a3_ctrl_ops, in gc08a3_initialize_controls()
1921 dev_err(&gc08a3->client->dev, in gc08a3_initialize_controls()
1926 gc08a3->subdev.ctrl_handler = handler; in gc08a3_initialize_controls()
1936 static int gc08a3_check_sensor_id(struct gc08a3 *gc08a3, in gc08a3_check_sensor_id() argument
1939 struct device *dev = &gc08a3->client->dev; in gc08a3_check_sensor_id()
1956 static int gc08a3_configure_regulators(struct gc08a3 *gc08a3) in gc08a3_configure_regulators() argument
1961 gc08a3->supplies[i].supply = gc08a3_supply_names[i]; in gc08a3_configure_regulators()
1963 return devm_regulator_bulk_get(&gc08a3->client->dev, in gc08a3_configure_regulators()
1965 gc08a3->supplies); in gc08a3_configure_regulators()
1968 static int gc08a3_parse_of(struct gc08a3 *gc08a3) in gc08a3_parse_of() argument
1970 struct device *dev = &gc08a3->client->dev; in gc08a3_parse_of()
1988 gc08a3->lane_num = rval; in gc08a3_parse_of()
1989 if (4 == gc08a3->lane_num) { in gc08a3_parse_of()
1990 gc08a3->cur_mode = &supported_modes_4lane[0]; in gc08a3_parse_of()
1991 gc08a3->support_modes = supported_modes_4lane; in gc08a3_parse_of()
1992 gc08a3->cfg_num = ARRAY_SIZE(supported_modes_4lane); in gc08a3_parse_of()
1994 fps = DIV_ROUND_CLOSEST(gc08a3->cur_mode->max_fps.denominator, in gc08a3_parse_of()
1995 gc08a3->cur_mode->max_fps.numerator); in gc08a3_parse_of()
1996 gc08a3->pixel_rate = gc08a3->cur_mode->vts_def * in gc08a3_parse_of()
1997 gc08a3->cur_mode->hts_def * fps; in gc08a3_parse_of()
2000 gc08a3->lane_num, gc08a3->pixel_rate); in gc08a3_parse_of()
2001 } else if (2 == gc08a3->lane_num) { in gc08a3_parse_of()
2003 dev_err(dev, "unsupported lane_num(%d)\n", gc08a3->lane_num); in gc08a3_parse_of()
2015 struct gc08a3 *gc08a3; in gc08a3_probe() local
2025 gc08a3 = devm_kzalloc(dev, sizeof(*gc08a3), GFP_KERNEL); in gc08a3_probe()
2026 if (!gc08a3) in gc08a3_probe()
2030 &gc08a3->module_index); in gc08a3_probe()
2032 &gc08a3->module_facing); in gc08a3_probe()
2034 &gc08a3->module_name); in gc08a3_probe()
2036 &gc08a3->len_name); in gc08a3_probe()
2041 gc08a3->client = client; in gc08a3_probe()
2043 gc08a3->xvclk = devm_clk_get(dev, "xvclk"); in gc08a3_probe()
2044 if (IS_ERR(gc08a3->xvclk)) { in gc08a3_probe()
2049 gc08a3->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in gc08a3_probe()
2050 if (IS_ERR(gc08a3->power_gpio)) in gc08a3_probe()
2052 gc08a3->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in gc08a3_probe()
2053 if (IS_ERR(gc08a3->reset_gpio)) in gc08a3_probe()
2056 gc08a3->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc08a3_probe()
2057 if (IS_ERR(gc08a3->pwdn_gpio)) in gc08a3_probe()
2060 ret = gc08a3_configure_regulators(gc08a3); in gc08a3_probe()
2066 ret = gc08a3_parse_of(gc08a3); in gc08a3_probe()
2070 gc08a3->pinctrl = devm_pinctrl_get(dev); in gc08a3_probe()
2071 if (!IS_ERR(gc08a3->pinctrl)) { in gc08a3_probe()
2072 gc08a3->pins_default = in gc08a3_probe()
2073 pinctrl_lookup_state(gc08a3->pinctrl, in gc08a3_probe()
2075 if (IS_ERR(gc08a3->pins_default)) in gc08a3_probe()
2078 gc08a3->pins_sleep = in gc08a3_probe()
2079 pinctrl_lookup_state(gc08a3->pinctrl, in gc08a3_probe()
2081 if (IS_ERR(gc08a3->pins_sleep)) in gc08a3_probe()
2085 mutex_init(&gc08a3->mutex); in gc08a3_probe()
2087 sd = &gc08a3->subdev; in gc08a3_probe()
2089 ret = gc08a3_initialize_controls(gc08a3); in gc08a3_probe()
2093 ret = __gc08a3_power_on(gc08a3); in gc08a3_probe()
2097 ret = gc08a3_check_sensor_id(gc08a3, client); in gc08a3_probe()
2107 gc08a3->pad.flags = MEDIA_PAD_FL_SOURCE; in gc08a3_probe()
2109 ret = media_entity_pads_init(&sd->entity, 1, &gc08a3->pad); in gc08a3_probe()
2115 if (strcmp(gc08a3->module_facing, "back") == 0) in gc08a3_probe()
2121 gc08a3->module_index, facing, in gc08a3_probe()
2140 __gc08a3_power_off(gc08a3); in gc08a3_probe()
2142 v4l2_ctrl_handler_free(&gc08a3->ctrl_handler); in gc08a3_probe()
2144 mutex_destroy(&gc08a3->mutex); in gc08a3_probe()
2152 struct gc08a3 *gc08a3 = to_gc08a3(sd); in gc08a3_remove() local
2158 v4l2_ctrl_handler_free(&gc08a3->ctrl_handler); in gc08a3_remove()
2159 mutex_destroy(&gc08a3->mutex); in gc08a3_remove()
2163 __gc08a3_power_off(gc08a3); in gc08a3_remove()