Lines Matching full:sensor

809 	/* Sensor */
886 /* Sensor */
1219 /* Sensor */
1348 static int ov8865_read(struct ov8865_sensor *sensor, u16 address, u8 *value) in ov8865_read() argument
1351 struct i2c_client *client = sensor->i2c_client; in ov8865_read()
1371 static int ov8865_write(struct ov8865_sensor *sensor, u16 address, u8 value) in ov8865_write() argument
1374 struct i2c_client *client = sensor->i2c_client; in ov8865_write()
1387 static int ov8865_write_sequence(struct ov8865_sensor *sensor, in ov8865_write_sequence() argument
1395 ret = ov8865_write(sensor, sequence[i].address, in ov8865_write_sequence()
1407 static int ov8865_update_bits(struct ov8865_sensor *sensor, u16 address, in ov8865_update_bits() argument
1413 ret = ov8865_read(sensor, address, &value); in ov8865_update_bits()
1420 return ov8865_write(sensor, address, value); in ov8865_update_bits()
1423 /* Sensor */
1425 static int ov8865_sw_reset(struct ov8865_sensor *sensor) in ov8865_sw_reset() argument
1427 return ov8865_write(sensor, OV8865_SW_RESET_REG, OV8865_SW_RESET_RESET); in ov8865_sw_reset()
1430 static int ov8865_sw_standby(struct ov8865_sensor *sensor, int standby) in ov8865_sw_standby() argument
1437 return ov8865_write(sensor, OV8865_SW_STANDBY_REG, value); in ov8865_sw_standby()
1440 static int ov8865_chip_id_check(struct ov8865_sensor *sensor) in ov8865_chip_id_check() argument
1451 ret = ov8865_read(sensor, regs[i], &value); in ov8865_chip_id_check()
1456 dev_err(sensor->dev, in ov8865_chip_id_check()
1466 static int ov8865_charge_pump_configure(struct ov8865_sensor *sensor) in ov8865_charge_pump_configure() argument
1468 return ov8865_write(sensor, OV8865_PUMP_CLK_DIV_REG, in ov8865_charge_pump_configure()
1472 static int ov8865_mipi_configure(struct ov8865_sensor *sensor) in ov8865_mipi_configure() argument
1475 &sensor->endpoint.bus.mipi_csi2; in ov8865_mipi_configure()
1479 ret = ov8865_write(sensor, OV8865_MIPI_SC_CTRL0_REG, in ov8865_mipi_configure()
1486 ret = ov8865_write(sensor, OV8865_MIPI_SC_CTRL2_REG, in ov8865_mipi_configure()
1492 ret = ov8865_write(sensor, OV8865_MIPI_LANE_SEL01_REG, in ov8865_mipi_configure()
1500 ret = ov8865_write(sensor, OV8865_MIPI_LANE_SEL23_REG, in ov8865_mipi_configure()
1507 ret = ov8865_update_bits(sensor, OV8865_CLK_SEL1_REG, in ov8865_mipi_configure()
1518 return ov8865_write(sensor, OV8865_MIPI_PCLK_PERIOD_REG, 0x16); in ov8865_mipi_configure()
1521 static int ov8865_black_level_configure(struct ov8865_sensor *sensor) in ov8865_black_level_configure() argument
1526 ret = ov8865_write(sensor, OV8865_BLC_CTRL0_REG, in ov8865_black_level_configure()
1536 ret = ov8865_write(sensor, OV8865_BLC_CTRLD_REG, in ov8865_black_level_configure()
1541 ret = ov8865_write(sensor, OV8865_BLC_CTRL1F_REG, 0); in ov8865_black_level_configure()
1546 return ov8865_write(sensor, OV8865_BLC_OFFSET_LIMIT_REG, in ov8865_black_level_configure()
1550 static int ov8865_isp_configure(struct ov8865_sensor *sensor) in ov8865_isp_configure() argument
1555 ret = ov8865_write(sensor, OV8865_ISP_CTRL0_REG, in ov8865_isp_configure()
1562 return ov8865_write(sensor, OV8865_ISP_CTRL1_REG, in ov8865_isp_configure()
1566 static unsigned long ov8865_mode_pll1_rate(struct ov8865_sensor *sensor, in ov8865_mode_pll1_rate() argument
1572 config = sensor->pll_configs->pll1_config; in ov8865_mode_pll1_rate()
1573 pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half; in ov8865_mode_pll1_rate()
1603 static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, in ov8865_mode_pll1_configure() argument
1611 config = sensor->pll_configs->pll1_config; in ov8865_mode_pll1_configure()
1621 ret = ov8865_write(sensor, OV8865_MIPI_BIT_SEL_REG, value); in ov8865_mode_pll1_configure()
1625 ret = ov8865_write(sensor, OV8865_PLL_CTRLA_REG, in ov8865_mode_pll1_configure()
1630 ret = ov8865_write(sensor, OV8865_PLL_CTRL0_REG, in ov8865_mode_pll1_configure()
1635 ret = ov8865_write(sensor, OV8865_PLL_CTRL1_REG, in ov8865_mode_pll1_configure()
1640 ret = ov8865_write(sensor, OV8865_PLL_CTRL2_REG, in ov8865_mode_pll1_configure()
1645 ret = ov8865_write(sensor, OV8865_PLL_CTRL3_REG, in ov8865_mode_pll1_configure()
1650 ret = ov8865_write(sensor, OV8865_PLL_CTRL4_REG, in ov8865_mode_pll1_configure()
1655 ret = ov8865_update_bits(sensor, OV8865_PCLK_SEL_REG, in ov8865_mode_pll1_configure()
1661 ret = ov8865_write(sensor, OV8865_PLL_CTRL5_REG, in ov8865_mode_pll1_configure()
1666 ret = ov8865_write(sensor, OV8865_PLL_CTRL6_REG, in ov8865_mode_pll1_configure()
1671 return ov8865_update_bits(sensor, OV8865_PLL_CTRL1E_REG, in ov8865_mode_pll1_configure()
1676 static int ov8865_mode_pll2_configure(struct ov8865_sensor *sensor, in ov8865_mode_pll2_configure() argument
1682 config = mode->pll2_binning ? sensor->pll_configs->pll2_config_binning : in ov8865_mode_pll2_configure()
1683 sensor->pll_configs->pll2_config_native; in ov8865_mode_pll2_configure()
1685 ret = ov8865_write(sensor, OV8865_PLL_CTRL12_REG, in ov8865_mode_pll2_configure()
1691 ret = ov8865_write(sensor, OV8865_PLL_CTRLB_REG, in ov8865_mode_pll2_configure()
1696 ret = ov8865_write(sensor, OV8865_PLL_CTRLC_REG, in ov8865_mode_pll2_configure()
1701 ret = ov8865_write(sensor, OV8865_PLL_CTRLD_REG, in ov8865_mode_pll2_configure()
1706 ret = ov8865_write(sensor, OV8865_PLL_CTRLF_REG, in ov8865_mode_pll2_configure()
1711 return ov8865_write(sensor, OV8865_PLL_CTRLE_REG, in ov8865_mode_pll2_configure()
1715 static int ov8865_mode_sclk_configure(struct ov8865_sensor *sensor, in ov8865_mode_sclk_configure() argument
1721 ret = ov8865_write(sensor, OV8865_CLK_SEL0_REG, in ov8865_mode_sclk_configure()
1726 ret = ov8865_update_bits(sensor, OV8865_CLK_SEL1_REG, in ov8865_mode_sclk_configure()
1732 return ov8865_write(sensor, OV8865_SCLK_CTRL_REG, in ov8865_mode_sclk_configure()
1738 static int ov8865_mode_binning_configure(struct ov8865_sensor *sensor, in ov8865_mode_binning_configure() argument
1745 ret = ov8865_write(sensor, OV8865_FORMAT1_REG, 0); in ov8865_mode_binning_configure()
1763 ret = ov8865_write(sensor, OV8865_FORMAT2_REG, value); in ov8865_mode_binning_configure()
1767 ret = ov8865_update_bits(sensor, OV8865_ISP_CTRL2_REG, in ov8865_mode_binning_configure()
1783 ret = ov8865_write(sensor, OV8865_VAP_CTRL1_REG, in ov8865_mode_binning_configure()
1789 ret = ov8865_write(sensor, OV8865_INC_X_ODD_REG, in ov8865_mode_binning_configure()
1794 ret = ov8865_write(sensor, OV8865_INC_X_EVEN_REG, in ov8865_mode_binning_configure()
1799 ret = ov8865_write(sensor, OV8865_INC_Y_ODD_REG, in ov8865_mode_binning_configure()
1804 return ov8865_write(sensor, OV8865_INC_Y_EVEN_REG, in ov8865_mode_binning_configure()
1808 static int ov8865_mode_black_level_configure(struct ov8865_sensor *sensor, in ov8865_mode_black_level_configure() argument
1814 ret = ov8865_write(sensor, OV8865_BLC_CTRL1_REG, in ov8865_mode_black_level_configure()
1822 ret = ov8865_write(sensor, OV8865_BLC_TOP_ZLINE_START_REG, in ov8865_mode_black_level_configure()
1827 ret = ov8865_write(sensor, OV8865_BLC_TOP_ZLINE_NUM_REG, in ov8865_mode_black_level_configure()
1834 ret = ov8865_write(sensor, OV8865_BLC_TOP_BLKLINE_START_REG, in ov8865_mode_black_level_configure()
1839 ret = ov8865_write(sensor, OV8865_BLC_TOP_BLKLINE_NUM_REG, in ov8865_mode_black_level_configure()
1846 ret = ov8865_write(sensor, OV8865_BLC_BOT_ZLINE_START_REG, in ov8865_mode_black_level_configure()
1851 ret = ov8865_write(sensor, OV8865_BLC_BOT_ZLINE_NUM_REG, in ov8865_mode_black_level_configure()
1858 ret = ov8865_write(sensor, OV8865_BLC_BOT_BLKLINE_START_REG, in ov8865_mode_black_level_configure()
1863 ret = ov8865_write(sensor, OV8865_BLC_BOT_BLKLINE_NUM_REG, in ov8865_mode_black_level_configure()
1870 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_LEFT_START_H_REG, in ov8865_mode_black_level_configure()
1875 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_LEFT_START_L_REG, in ov8865_mode_black_level_configure()
1880 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_LEFT_END_H_REG, in ov8865_mode_black_level_configure()
1885 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_LEFT_END_L_REG, in ov8865_mode_black_level_configure()
1890 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_RIGHT_START_H_REG, in ov8865_mode_black_level_configure()
1895 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_RIGHT_START_L_REG, in ov8865_mode_black_level_configure()
1900 ret = ov8865_write(sensor, OV8865_BLC_ANCHOR_RIGHT_END_H_REG, in ov8865_mode_black_level_configure()
1905 return ov8865_write(sensor, OV8865_BLC_ANCHOR_RIGHT_END_L_REG, in ov8865_mode_black_level_configure()
1909 static int ov8865_mode_configure(struct ov8865_sensor *sensor, in ov8865_mode_configure() argument
1916 ret = ov8865_write(sensor, OV8865_OUTPUT_SIZE_X_H_REG, in ov8865_mode_configure()
1921 ret = ov8865_write(sensor, OV8865_OUTPUT_SIZE_X_L_REG, in ov8865_mode_configure()
1928 ret = ov8865_write(sensor, OV8865_HTS_H_REG, OV8865_HTS_H(mode->hts)); in ov8865_mode_configure()
1932 ret = ov8865_write(sensor, OV8865_HTS_L_REG, OV8865_HTS_L(mode->hts)); in ov8865_mode_configure()
1938 ret = ov8865_write(sensor, OV8865_OUTPUT_SIZE_Y_H_REG, in ov8865_mode_configure()
1943 ret = ov8865_write(sensor, OV8865_OUTPUT_SIZE_Y_L_REG, in ov8865_mode_configure()
1950 ret = ov8865_write(sensor, OV8865_VTS_H_REG, OV8865_VTS_H(mode->vts)); in ov8865_mode_configure()
1954 ret = ov8865_write(sensor, OV8865_VTS_L_REG, OV8865_VTS_L(mode->vts)); in ov8865_mode_configure()
1961 ret = ov8865_write(sensor, OV8865_AUTO_SIZE_CTRL_REG, in ov8865_mode_configure()
1971 ret = ov8865_write(sensor, OV8865_AUTO_SIZE_BOUNDARIES_REG, in ov8865_mode_configure()
1979 ret = ov8865_write(sensor, OV8865_CROP_START_X_H_REG, in ov8865_mode_configure()
1984 ret = ov8865_write(sensor, OV8865_CROP_START_X_L_REG, in ov8865_mode_configure()
1991 ret = ov8865_write(sensor, OV8865_OFFSET_X_H_REG, in ov8865_mode_configure()
1996 ret = ov8865_write(sensor, OV8865_OFFSET_X_L_REG, in ov8865_mode_configure()
2003 ret = ov8865_write(sensor, OV8865_CROP_END_X_H_REG, in ov8865_mode_configure()
2008 ret = ov8865_write(sensor, OV8865_CROP_END_X_L_REG, in ov8865_mode_configure()
2015 ret = ov8865_write(sensor, OV8865_CROP_START_Y_H_REG, in ov8865_mode_configure()
2020 ret = ov8865_write(sensor, OV8865_CROP_START_Y_L_REG, in ov8865_mode_configure()
2027 ret = ov8865_write(sensor, OV8865_OFFSET_Y_H_REG, in ov8865_mode_configure()
2032 ret = ov8865_write(sensor, OV8865_OFFSET_Y_L_REG, in ov8865_mode_configure()
2039 ret = ov8865_write(sensor, OV8865_CROP_END_Y_H_REG, in ov8865_mode_configure()
2044 ret = ov8865_write(sensor, OV8865_CROP_END_Y_L_REG, in ov8865_mode_configure()
2052 ret = ov8865_write(sensor, OV8865_VFIFO_READ_START_H_REG, in ov8865_mode_configure()
2057 ret = ov8865_write(sensor, OV8865_VFIFO_READ_START_L_REG, in ov8865_mode_configure()
2062 ret = ov8865_write(sensor, OV8865_ABLC_NUM_REG, in ov8865_mode_configure()
2067 ret = ov8865_write(sensor, OV8865_ZLINE_NUM_REG, in ov8865_mode_configure()
2074 ret = ov8865_mode_binning_configure(sensor, mode); in ov8865_mode_configure()
2080 ret = ov8865_mode_black_level_configure(sensor, mode); in ov8865_mode_configure()
2086 ret = ov8865_mode_pll1_configure(sensor, mode, mbus_code); in ov8865_mode_configure()
2090 ret = ov8865_mode_pll2_configure(sensor, mode); in ov8865_mode_configure()
2094 ret = ov8865_mode_sclk_configure(sensor, mode); in ov8865_mode_configure()
2101 ret = ov8865_write_sequence(sensor, mode->register_values, in ov8865_mode_configure()
2110 static unsigned long ov8865_mode_mipi_clk_rate(struct ov8865_sensor *sensor, in ov8865_mode_mipi_clk_rate() argument
2116 config = sensor->pll_configs->pll1_config; in ov8865_mode_mipi_clk_rate()
2118 pll1_rate = ov8865_mode_pll1_rate(sensor, mode); in ov8865_mode_mipi_clk_rate()
2125 static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure) in ov8865_exposure_configure() argument
2129 /* The sensor stores exposure in units of 1/16th of a line */ in ov8865_exposure_configure()
2132 ret = ov8865_write(sensor, OV8865_EXPOSURE_CTRL_HH_REG, in ov8865_exposure_configure()
2137 ret = ov8865_write(sensor, OV8865_EXPOSURE_CTRL_H_REG, in ov8865_exposure_configure()
2142 return ov8865_write(sensor, OV8865_EXPOSURE_CTRL_L_REG, in ov8865_exposure_configure()
2148 static int ov8865_analog_gain_configure(struct ov8865_sensor *sensor, u32 gain) in ov8865_analog_gain_configure() argument
2152 ret = ov8865_write(sensor, OV8865_GAIN_CTRL_H_REG, in ov8865_analog_gain_configure()
2157 return ov8865_write(sensor, OV8865_GAIN_CTRL_L_REG, in ov8865_analog_gain_configure()
2163 static int ov8865_red_balance_configure(struct ov8865_sensor *sensor, in ov8865_red_balance_configure() argument
2168 ret = ov8865_write(sensor, OV8865_ISP_GAIN_RED_H_REG, in ov8865_red_balance_configure()
2173 return ov8865_write(sensor, OV8865_ISP_GAIN_RED_L_REG, in ov8865_red_balance_configure()
2177 static int ov8865_blue_balance_configure(struct ov8865_sensor *sensor, in ov8865_blue_balance_configure() argument
2182 ret = ov8865_write(sensor, OV8865_ISP_GAIN_BLUE_H_REG, in ov8865_blue_balance_configure()
2187 return ov8865_write(sensor, OV8865_ISP_GAIN_BLUE_L_REG, in ov8865_blue_balance_configure()
2193 static int ov8865_flip_vert_configure(struct ov8865_sensor *sensor, bool enable) in ov8865_flip_vert_configure() argument
2198 return ov8865_update_bits(sensor, OV8865_FORMAT1_REG, bits, in ov8865_flip_vert_configure()
2202 static int ov8865_flip_horz_configure(struct ov8865_sensor *sensor, bool enable) in ov8865_flip_horz_configure() argument
2207 return ov8865_update_bits(sensor, OV8865_FORMAT2_REG, bits, in ov8865_flip_horz_configure()
2213 static int ov8865_test_pattern_configure(struct ov8865_sensor *sensor, in ov8865_test_pattern_configure() argument
2219 return ov8865_write(sensor, OV8865_PRE_CTRL0_REG, in ov8865_test_pattern_configure()
2225 static int ov8865_vts_configure(struct ov8865_sensor *sensor, u32 vblank) in ov8865_vts_configure() argument
2227 u16 vts = sensor->state.mode->output_size_y + vblank; in ov8865_vts_configure()
2230 ret = ov8865_write(sensor, OV8865_VTS_H_REG, OV8865_VTS_H(vts)); in ov8865_vts_configure()
2234 return ov8865_write(sensor, OV8865_VTS_L_REG, OV8865_VTS_L(vts)); in ov8865_vts_configure()
2239 static int ov8865_state_mipi_configure(struct ov8865_sensor *sensor, in ov8865_state_mipi_configure() argument
2243 struct ov8865_ctrls *ctrls = &sensor->ctrls; in ov8865_state_mipi_configure()
2245 &sensor->endpoint.bus.mipi_csi2; in ov8865_state_mipi_configure()
2252 mipi_clk_rate = ov8865_mode_mipi_clk_rate(sensor, mode); in ov8865_state_mipi_configure()
2263 for (j = 0; j < sensor->endpoint.nr_of_link_frequencies; j++) { in ov8865_state_mipi_configure()
2264 u64 freq = sensor->endpoint.link_frequencies[j]; in ov8865_state_mipi_configure()
2271 dev_err(sensor->dev, in ov8865_state_mipi_configure()
2274 } else if (j == sensor->endpoint.nr_of_link_frequencies) { in ov8865_state_mipi_configure()
2275 dev_err(sensor->dev, in ov8865_state_mipi_configure()
2298 static int ov8865_state_configure(struct ov8865_sensor *sensor, in ov8865_state_configure() argument
2304 if (sensor->state.streaming) in ov8865_state_configure()
2308 if (pm_runtime_enabled(sensor->dev) && in ov8865_state_configure()
2309 !pm_runtime_suspended(sensor->dev)) { in ov8865_state_configure()
2310 ret = ov8865_mode_configure(sensor, mode, mbus_code); in ov8865_state_configure()
2315 ret = ov8865_state_mipi_configure(sensor, mode, mbus_code); in ov8865_state_configure()
2319 sensor->state.mode = mode; in ov8865_state_configure()
2320 sensor->state.mbus_code = mbus_code; in ov8865_state_configure()
2325 static int ov8865_state_init(struct ov8865_sensor *sensor) in ov8865_state_init() argument
2327 return ov8865_state_configure(sensor, &ov8865_modes[0], in ov8865_state_init()
2331 /* Sensor Base */
2333 static int ov8865_sensor_init(struct ov8865_sensor *sensor) in ov8865_sensor_init() argument
2337 ret = ov8865_sw_reset(sensor); in ov8865_sensor_init()
2339 dev_err(sensor->dev, "failed to perform sw reset\n"); in ov8865_sensor_init()
2343 ret = ov8865_sw_standby(sensor, 1); in ov8865_sensor_init()
2345 dev_err(sensor->dev, "failed to set sensor standby\n"); in ov8865_sensor_init()
2349 ret = ov8865_chip_id_check(sensor); in ov8865_sensor_init()
2351 dev_err(sensor->dev, "failed to check sensor chip id\n"); in ov8865_sensor_init()
2355 ret = ov8865_write_sequence(sensor, ov8865_init_sequence, in ov8865_sensor_init()
2358 dev_err(sensor->dev, "failed to write init sequence\n"); in ov8865_sensor_init()
2362 ret = ov8865_charge_pump_configure(sensor); in ov8865_sensor_init()
2364 dev_err(sensor->dev, "failed to configure pad\n"); in ov8865_sensor_init()
2368 ret = ov8865_mipi_configure(sensor); in ov8865_sensor_init()
2370 dev_err(sensor->dev, "failed to configure MIPI\n"); in ov8865_sensor_init()
2374 ret = ov8865_isp_configure(sensor); in ov8865_sensor_init()
2376 dev_err(sensor->dev, "failed to configure ISP\n"); in ov8865_sensor_init()
2380 ret = ov8865_black_level_configure(sensor); in ov8865_sensor_init()
2382 dev_err(sensor->dev, "failed to configure black level\n"); in ov8865_sensor_init()
2387 ret = ov8865_state_configure(sensor, sensor->state.mode, in ov8865_sensor_init()
2388 sensor->state.mbus_code); in ov8865_sensor_init()
2390 dev_err(sensor->dev, "failed to configure state\n"); in ov8865_sensor_init()
2397 static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on) in ov8865_sensor_power() argument
2403 gpiod_set_value_cansleep(sensor->reset, 1); in ov8865_sensor_power()
2404 gpiod_set_value_cansleep(sensor->powerdown, 1); in ov8865_sensor_power()
2406 ret = regulator_enable(sensor->dovdd); in ov8865_sensor_power()
2408 dev_err(sensor->dev, in ov8865_sensor_power()
2413 ret = regulator_enable(sensor->avdd); in ov8865_sensor_power()
2415 dev_err(sensor->dev, in ov8865_sensor_power()
2420 ret = regulator_enable(sensor->dvdd); in ov8865_sensor_power()
2422 dev_err(sensor->dev, in ov8865_sensor_power()
2427 ret = clk_prepare_enable(sensor->extclk); in ov8865_sensor_power()
2429 dev_err(sensor->dev, "failed to enable EXTCLK clock\n"); in ov8865_sensor_power()
2433 gpiod_set_value_cansleep(sensor->reset, 0); in ov8865_sensor_power()
2434 gpiod_set_value_cansleep(sensor->powerdown, 0); in ov8865_sensor_power()
2439 gpiod_set_value_cansleep(sensor->powerdown, 1); in ov8865_sensor_power()
2440 gpiod_set_value_cansleep(sensor->reset, 1); in ov8865_sensor_power()
2442 clk_disable_unprepare(sensor->extclk); in ov8865_sensor_power()
2445 regulator_disable(sensor->dvdd); in ov8865_sensor_power()
2447 regulator_disable(sensor->avdd); in ov8865_sensor_power()
2449 regulator_disable(sensor->dovdd); in ov8865_sensor_power()
2460 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_s_ctrl() local
2468 exposure_max = sensor->state.mode->output_size_y + ctrl->val - in ov8865_s_ctrl()
2470 __v4l2_ctrl_modify_range(sensor->ctrls.exposure, in ov8865_s_ctrl()
2471 sensor->ctrls.exposure->minimum, in ov8865_s_ctrl()
2473 sensor->ctrls.exposure->step, in ov8865_s_ctrl()
2474 min(sensor->ctrls.exposure->val, in ov8865_s_ctrl()
2478 /* Wait for the sensor to be on before setting controls. */ in ov8865_s_ctrl()
2479 if (pm_runtime_suspended(sensor->dev)) in ov8865_s_ctrl()
2484 ret = ov8865_exposure_configure(sensor, ctrl->val); in ov8865_s_ctrl()
2489 ret = ov8865_analog_gain_configure(sensor, ctrl->val); in ov8865_s_ctrl()
2494 return ov8865_red_balance_configure(sensor, ctrl->val); in ov8865_s_ctrl()
2496 return ov8865_blue_balance_configure(sensor, ctrl->val); in ov8865_s_ctrl()
2498 return ov8865_flip_horz_configure(sensor, !!ctrl->val); in ov8865_s_ctrl()
2500 return ov8865_flip_vert_configure(sensor, !!ctrl->val); in ov8865_s_ctrl()
2503 return ov8865_test_pattern_configure(sensor, index); in ov8865_s_ctrl()
2505 return ov8865_vts_configure(sensor, ctrl->val); in ov8865_s_ctrl()
2517 static int ov8865_ctrls_init(struct ov8865_sensor *sensor) in ov8865_ctrls_init() argument
2519 struct ov8865_ctrls *ctrls = &sensor->ctrls; in ov8865_ctrls_init()
2531 handler->lock = &sensor->mutex; in ov8865_ctrls_init()
2588 ret = v4l2_fwnode_device_parse(sensor->dev, &props); in ov8865_ctrls_init()
2604 sensor->subdev.ctrl_handler = handler; in ov8865_ctrls_init()
2618 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_s_stream() local
2619 struct ov8865_state *state = &sensor->state; in ov8865_s_stream()
2623 ret = pm_runtime_resume_and_get(sensor->dev); in ov8865_s_stream()
2628 mutex_lock(&sensor->mutex); in ov8865_s_stream()
2629 ret = ov8865_sw_standby(sensor, !enable); in ov8865_s_stream()
2630 mutex_unlock(&sensor->mutex); in ov8865_s_stream()
2638 pm_runtime_put(sensor->dev); in ov8865_s_stream()
2682 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_get_fmt() local
2685 mutex_lock(&sensor->mutex); in ov8865_get_fmt()
2691 ov8865_mbus_format_fill(mbus_format, sensor->state.mbus_code, in ov8865_get_fmt()
2692 sensor->state.mode); in ov8865_get_fmt()
2694 mutex_unlock(&sensor->mutex); in ov8865_get_fmt()
2703 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_set_fmt() local
2712 mutex_lock(&sensor->mutex); in ov8865_set_fmt()
2714 if (sensor->state.streaming) { in ov8865_set_fmt()
2745 else if (sensor->state.mode != mode || in ov8865_set_fmt()
2746 sensor->state.mbus_code != mbus_code) in ov8865_set_fmt()
2747 ret = ov8865_state_configure(sensor, mode, mbus_code); in ov8865_set_fmt()
2749 __v4l2_ctrl_modify_range(sensor->ctrls.vblank, OV8865_TIMING_MIN_VTS, in ov8865_set_fmt()
2754 __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, in ov8865_set_fmt()
2758 __v4l2_ctrl_modify_range(sensor->ctrls.exposure, in ov8865_set_fmt()
2759 sensor->ctrls.exposure->minimum, exposure_max, in ov8865_set_fmt()
2760 sensor->ctrls.exposure->step, in ov8865_set_fmt()
2761 min(sensor->ctrls.exposure->val, in ov8865_set_fmt()
2765 mutex_unlock(&sensor->mutex); in ov8865_set_fmt()
2788 __ov8865_get_pad_crop(struct ov8865_sensor *sensor, in __ov8865_get_pad_crop() argument
2792 const struct ov8865_mode *mode = sensor->state.mode; in __ov8865_get_pad_crop()
2811 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_get_selection() local
2815 mutex_lock(&sensor->mutex); in ov8865_get_selection()
2816 __ov8865_get_pad_crop(sensor, state, sel->pad, in ov8865_get_selection()
2818 mutex_unlock(&sensor->mutex); in ov8865_get_selection()
2844 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_get_frame_interval() local
2856 mutex_lock(&sensor->mutex); in ov8865_get_frame_interval()
2858 mode = sensor->state.mode; in ov8865_get_frame_interval()
2860 sensor->ctrls.vblank->val); in ov8865_get_frame_interval()
2861 fps = DIV_ROUND_CLOSEST(sensor->ctrls.pixel_rate->val, framesize); in ov8865_get_frame_interval()
2866 mutex_unlock(&sensor->mutex); in ov8865_get_frame_interval()
2891 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_suspend() local
2892 struct ov8865_state *state = &sensor->state; in ov8865_suspend()
2895 mutex_lock(&sensor->mutex); in ov8865_suspend()
2898 ret = ov8865_sw_standby(sensor, true); in ov8865_suspend()
2903 ret = ov8865_sensor_power(sensor, false); in ov8865_suspend()
2905 ov8865_sw_standby(sensor, false); in ov8865_suspend()
2908 mutex_unlock(&sensor->mutex); in ov8865_suspend()
2917 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_resume() local
2918 struct ov8865_state *state = &sensor->state; in ov8865_resume()
2921 mutex_lock(&sensor->mutex); in ov8865_resume()
2923 ret = ov8865_sensor_power(sensor, true); in ov8865_resume()
2927 ret = ov8865_sensor_init(sensor); in ov8865_resume()
2931 ret = __v4l2_ctrl_handler_setup(&sensor->ctrls.handler); in ov8865_resume()
2936 ret = ov8865_sw_standby(sensor, false); in ov8865_resume()
2944 ov8865_sensor_power(sensor, false); in ov8865_resume()
2947 mutex_unlock(&sensor->mutex); in ov8865_resume()
2956 struct ov8865_sensor *sensor; in ov8865_probe() local
2963 sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); in ov8865_probe()
2964 if (!sensor) in ov8865_probe()
2967 sensor->dev = dev; in ov8865_probe()
2968 sensor->i2c_client = client; in ov8865_probe()
2973 sensor->dvdd = devm_regulator_get(dev, "dvdd"); in ov8865_probe()
2974 if (IS_ERR(sensor->dvdd)) in ov8865_probe()
2975 return dev_err_probe(dev, PTR_ERR(sensor->dvdd), in ov8865_probe()
2979 sensor->dovdd = devm_regulator_get(dev, "dovdd"); in ov8865_probe()
2980 if (IS_ERR(sensor->dovdd)) in ov8865_probe()
2981 return dev_err_probe(dev, PTR_ERR(sensor->dovdd), in ov8865_probe()
2985 sensor->avdd = devm_regulator_get(dev, "avdd"); in ov8865_probe()
2986 if (IS_ERR(sensor->avdd)) in ov8865_probe()
2987 return dev_err_probe(dev, PTR_ERR(sensor->avdd), in ov8865_probe()
2996 sensor->endpoint.bus_type = V4L2_MBUS_CSI2_DPHY; in ov8865_probe()
2998 ret = v4l2_fwnode_endpoint_alloc_parse(handle, &sensor->endpoint); in ov8865_probe()
3007 sensor->powerdown = devm_gpiod_get_optional(dev, "powerdown", in ov8865_probe()
3009 if (IS_ERR(sensor->powerdown)) { in ov8865_probe()
3010 ret = PTR_ERR(sensor->powerdown); in ov8865_probe()
3014 sensor->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in ov8865_probe()
3015 if (IS_ERR(sensor->reset)) { in ov8865_probe()
3016 ret = PTR_ERR(sensor->reset); in ov8865_probe()
3022 sensor->extclk = devm_clk_get(dev, NULL); in ov8865_probe()
3023 if (PTR_ERR(sensor->extclk) == -ENOENT) { in ov8865_probe()
3025 sensor->extclk = NULL; in ov8865_probe()
3026 } else if (IS_ERR(sensor->extclk)) { in ov8865_probe()
3028 ret = PTR_ERR(sensor->extclk); in ov8865_probe()
3043 if (!ret && sensor->extclk) { in ov8865_probe()
3044 ret = clk_set_rate(sensor->extclk, rate); in ov8865_probe()
3049 } else if (ret && !sensor->extclk) { in ov8865_probe()
3054 sensor->extclk_rate = rate ? rate : clk_get_rate(sensor->extclk); in ov8865_probe()
3057 if (sensor->extclk_rate == supported_extclk_rates[i]) in ov8865_probe()
3063 sensor->extclk_rate); in ov8865_probe()
3068 sensor->pll_configs = ov8865_pll_configs[i]; in ov8865_probe()
3072 subdev = &sensor->subdev; in ov8865_probe()
3078 pad = &sensor->pad; in ov8865_probe()
3087 mutex_init(&sensor->mutex); in ov8865_probe()
3089 /* Sensor */ in ov8865_probe()
3091 ret = ov8865_ctrls_init(sensor); in ov8865_probe()
3095 mutex_lock(&sensor->mutex); in ov8865_probe()
3096 ret = ov8865_state_init(sensor); in ov8865_probe()
3097 mutex_unlock(&sensor->mutex); in ov8865_probe()
3103 pm_runtime_set_suspended(sensor->dev); in ov8865_probe()
3104 pm_runtime_enable(sensor->dev); in ov8865_probe()
3115 pm_runtime_disable(sensor->dev); in ov8865_probe()
3118 v4l2_ctrl_handler_free(&sensor->ctrls.handler); in ov8865_probe()
3121 mutex_destroy(&sensor->mutex); in ov8865_probe()
3124 media_entity_cleanup(&sensor->subdev.entity); in ov8865_probe()
3127 v4l2_fwnode_endpoint_free(&sensor->endpoint); in ov8865_probe()
3135 struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); in ov8865_remove() local
3138 pm_runtime_disable(sensor->dev); in ov8865_remove()
3139 v4l2_ctrl_handler_free(&sensor->ctrls.handler); in ov8865_remove()
3140 mutex_destroy(&sensor->mutex); in ov8865_remove()
3143 v4l2_fwnode_endpoint_free(&sensor->endpoint); in ov8865_remove()
3176 MODULE_DESCRIPTION("V4L2 driver for the OmniVision OV8865 image sensor");