Lines Matching full:sensor
3 * Samsung S5K6A3 image sensor driver
45 * struct s5k6a3 - fimc-is sensor data structure
47 * @subdev: the image sensor's v4l2 subdev
49 * @supplies: image sensor's voltage regulator supplies
50 * @gpio_reset: GPIO connected to the sensor's reset pin
52 * @format: media bus format at the sensor's source pad
126 struct s5k6a3 *sensor, struct v4l2_subdev_state *sd_state, in __s5k6a3_get_format() argument
132 return &sensor->format; in __s5k6a3_get_format()
139 struct s5k6a3 *sensor = sd_to_s5k6a3(sd); in s5k6a3_set_fmt() local
144 mf = __s5k6a3_get_format(sensor, sd_state, fmt->pad, fmt->which); in s5k6a3_set_fmt()
146 mutex_lock(&sensor->lock); in s5k6a3_set_fmt()
148 mutex_unlock(&sensor->lock); in s5k6a3_set_fmt()
157 struct s5k6a3 *sensor = sd_to_s5k6a3(sd); in s5k6a3_get_fmt() local
160 mf = __s5k6a3_get_format(sensor, sd_state, fmt->pad, fmt->which); in s5k6a3_get_fmt()
162 mutex_lock(&sensor->lock); in s5k6a3_get_fmt()
164 mutex_unlock(&sensor->lock); in s5k6a3_get_fmt()
190 static int __s5k6a3_power_on(struct s5k6a3 *sensor) in __s5k6a3_power_on() argument
195 ret = clk_set_rate(sensor->clock, sensor->clock_frequency); in __s5k6a3_power_on()
199 ret = pm_runtime_get(sensor->dev); in __s5k6a3_power_on()
203 ret = regulator_enable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
207 ret = clk_prepare_enable(sensor->clock); in __s5k6a3_power_on()
212 ret = regulator_enable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
217 gpiod_set_value_cansleep(sensor->gpio_reset, 0); in __s5k6a3_power_on()
219 gpiod_set_value_cansleep(sensor->gpio_reset, 1); in __s5k6a3_power_on()
221 gpiod_set_value_cansleep(sensor->gpio_reset, 0); in __s5k6a3_power_on()
223 /* Delay needed for the sensor initialization */ in __s5k6a3_power_on()
228 clk_disable_unprepare(sensor->clock); in __s5k6a3_power_on()
231 regulator_disable(sensor->supplies[i].consumer); in __s5k6a3_power_on()
233 pm_runtime_put(sensor->dev); in __s5k6a3_power_on()
237 static int __s5k6a3_power_off(struct s5k6a3 *sensor) in __s5k6a3_power_off() argument
241 gpiod_set_value_cansleep(sensor->gpio_reset, 1); in __s5k6a3_power_off()
244 regulator_disable(sensor->supplies[i].consumer); in __s5k6a3_power_off()
246 clk_disable_unprepare(sensor->clock); in __s5k6a3_power_off()
247 pm_runtime_put(sensor->dev); in __s5k6a3_power_off()
253 struct s5k6a3 *sensor = sd_to_s5k6a3(sd); in s5k6a3_s_power() local
256 mutex_lock(&sensor->lock); in s5k6a3_s_power()
258 if (sensor->power_count == !on) { in s5k6a3_s_power()
260 ret = __s5k6a3_power_on(sensor); in s5k6a3_s_power()
262 ret = __s5k6a3_power_off(sensor); in s5k6a3_s_power()
265 sensor->power_count += on ? 1 : -1; in s5k6a3_s_power()
268 mutex_unlock(&sensor->lock); in s5k6a3_s_power()
284 struct s5k6a3 *sensor; in s5k6a3_probe() local
288 sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); in s5k6a3_probe()
289 if (!sensor) in s5k6a3_probe()
292 mutex_init(&sensor->lock); in s5k6a3_probe()
293 sensor->dev = dev; in s5k6a3_probe()
295 sensor->clock = devm_clk_get(sensor->dev, S5K6A3_CLK_NAME); in s5k6a3_probe()
296 if (IS_ERR(sensor->clock)) in s5k6a3_probe()
297 return PTR_ERR(sensor->clock); in s5k6a3_probe()
299 sensor->gpio_reset = devm_gpiod_get(dev, NULL, GPIOD_OUT_HIGH); in s5k6a3_probe()
300 ret = PTR_ERR_OR_ZERO(sensor->gpio_reset); in s5k6a3_probe()
305 &sensor->clock_frequency)) { in s5k6a3_probe()
306 sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ; in s5k6a3_probe()
308 sensor->clock_frequency); in s5k6a3_probe()
312 sensor->supplies[i].supply = s5k6a3_supply_names[i]; in s5k6a3_probe()
315 sensor->supplies); in s5k6a3_probe()
319 sd = &sensor->subdev; in s5k6a3_probe()
321 sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in s5k6a3_probe()
324 sensor->format.code = s5k6a3_formats[0].code; in s5k6a3_probe()
325 sensor->format.width = S5K6A3_DEFAULT_WIDTH; in s5k6a3_probe()
326 sensor->format.height = S5K6A3_DEFAULT_HEIGHT; in s5k6a3_probe()
329 sensor->pad.flags = MEDIA_PAD_FL_SOURCE; in s5k6a3_probe()
330 ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad); in s5k6a3_probe()
381 MODULE_DESCRIPTION("S5K6A3 image sensor subdev driver");