Symbol: mt9p031
drivers/media/i2c/mt9p031.c
1007
mt9p031_power_off(mt9p031);
drivers/media/i2c/mt9p031.c
1065
static int mt9p031_parse_properties(struct mt9p031 *mt9p031, struct device *dev)
drivers/media/i2c/mt9p031.c
1083
&mt9p031->ext_freq);
drivers/media/i2c/mt9p031.c
1085
&mt9p031->target_freq);
drivers/media/i2c/mt9p031.c
1087
mt9p031->pixclk_pol = !!(endpoint.bus.parallel.flags &
drivers/media/i2c/mt9p031.c
1097
struct mt9p031 *mt9p031;
drivers/media/i2c/mt9p031.c
1107
mt9p031 = devm_kzalloc(&client->dev, sizeof(*mt9p031), GFP_KERNEL);
drivers/media/i2c/mt9p031.c
1108
if (mt9p031 == NULL)
drivers/media/i2c/mt9p031.c
1111
ret = mt9p031_parse_properties(mt9p031, &client->dev);
drivers/media/i2c/mt9p031.c
1115
mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF;
drivers/media/i2c/mt9p031.c
1116
mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC;
drivers/media/i2c/mt9p031.c
1118
mt9p031->code = info->code;
drivers/media/i2c/mt9p031.c
1120
mt9p031->regulators[0].supply = "vdd";
drivers/media/i2c/mt9p031.c
1121
mt9p031->regulators[1].supply = "vdd_io";
drivers/media/i2c/mt9p031.c
1122
mt9p031->regulators[2].supply = "vaa";
drivers/media/i2c/mt9p031.c
1124
ret = devm_regulator_bulk_get(&client->dev, 3, mt9p031->regulators);
drivers/media/i2c/mt9p031.c
1130
mutex_init(&mt9p031->power_lock);
drivers/media/i2c/mt9p031.c
1132
v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 6);
drivers/media/i2c/mt9p031.c
1134
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1138
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1141
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1143
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1145
v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1146
V4L2_CID_PIXEL_RATE, mt9p031->target_freq,
drivers/media/i2c/mt9p031.c
1147
mt9p031->target_freq, 1, mt9p031->target_freq);
drivers/media/i2c/mt9p031.c
1148
v4l2_ctrl_new_std_menu_items(&mt9p031->ctrls, &mt9p031_ctrl_ops,
drivers/media/i2c/mt9p031.c
1154
v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL);
drivers/media/i2c/mt9p031.c
1156
mt9p031->subdev.ctrl_handler = &mt9p031->ctrls;
drivers/media/i2c/mt9p031.c
1158
if (mt9p031->ctrls.error) {
drivers/media/i2c/mt9p031.c
1160
__func__, mt9p031->ctrls.error);
drivers/media/i2c/mt9p031.c
1161
ret = mt9p031->ctrls.error;
drivers/media/i2c/mt9p031.c
1165
mt9p031->blc_auto = v4l2_ctrl_find(&mt9p031->ctrls, V4L2_CID_BLC_AUTO);
drivers/media/i2c/mt9p031.c
1166
mt9p031->blc_offset = v4l2_ctrl_find(&mt9p031->ctrls,
drivers/media/i2c/mt9p031.c
1169
v4l2_i2c_subdev_init(&mt9p031->subdev, client, &mt9p031_subdev_ops);
drivers/media/i2c/mt9p031.c
1170
mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops;
drivers/media/i2c/mt9p031.c
1172
mt9p031->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
drivers/media/i2c/mt9p031.c
1173
mt9p031->pad.flags = MEDIA_PAD_FL_SOURCE;
drivers/media/i2c/mt9p031.c
1174
ret = media_entity_pads_init(&mt9p031->subdev.entity, 1, &mt9p031->pad);
drivers/media/i2c/mt9p031.c
1178
mt9p031->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
drivers/media/i2c/mt9p031.c
1180
ret = mt9p031_init_state(&mt9p031->subdev, NULL);
drivers/media/i2c/mt9p031.c
1184
mt9p031->reset = devm_gpiod_get_optional(&client->dev, "reset",
drivers/media/i2c/mt9p031.c
1187
ret = mt9p031_clk_setup(mt9p031);
drivers/media/i2c/mt9p031.c
1191
ret = v4l2_async_register_subdev(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
1195
v4l2_ctrl_handler_free(&mt9p031->ctrls);
drivers/media/i2c/mt9p031.c
1196
media_entity_cleanup(&mt9p031->subdev.entity);
drivers/media/i2c/mt9p031.c
1197
mutex_destroy(&mt9p031->power_lock);
drivers/media/i2c/mt9p031.c
1206
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
1208
v4l2_ctrl_handler_free(&mt9p031->ctrls);
drivers/media/i2c/mt9p031.c
1211
mutex_destroy(&mt9p031->power_lock);
drivers/media/i2c/mt9p031.c
148
static struct mt9p031 *to_mt9p031(struct v4l2_subdev *sd)
drivers/media/i2c/mt9p031.c
150
return container_of(sd, struct mt9p031, subdev);
drivers/media/i2c/mt9p031.c
163
static int mt9p031_set_output_control(struct mt9p031 *mt9p031, u16 clear,
drivers/media/i2c/mt9p031.c
166
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
167
u16 value = (mt9p031->output_control & ~clear) | set;
drivers/media/i2c/mt9p031.c
174
mt9p031->output_control = value;
drivers/media/i2c/mt9p031.c
178
static int mt9p031_set_mode2(struct mt9p031 *mt9p031, u16 clear, u16 set)
drivers/media/i2c/mt9p031.c
180
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
181
u16 value = (mt9p031->mode2 & ~clear) | set;
drivers/media/i2c/mt9p031.c
188
mt9p031->mode2 = value;
drivers/media/i2c/mt9p031.c
192
static int mt9p031_reset(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
194
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
206
MT9P031_PIXEL_CLOCK_DIVIDE(mt9p031->clk_div));
drivers/media/i2c/mt9p031.c
210
return mt9p031_set_output_control(mt9p031, MT9P031_OUTPUT_CONTROL_CEN,
drivers/media/i2c/mt9p031.c
214
static int mt9p031_clk_setup(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
232
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
236
mt9p031->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
drivers/media/i2c/mt9p031.c
237
if (IS_ERR(mt9p031->clk))
drivers/media/i2c/mt9p031.c
238
return dev_err_probe(&client->dev, PTR_ERR(mt9p031->clk),
drivers/media/i2c/mt9p031.c
241
ret = clk_set_rate(mt9p031->clk, mt9p031->ext_freq);
drivers/media/i2c/mt9p031.c
245
ext_freq = clk_get_rate(mt9p031->clk);
drivers/media/i2c/mt9p031.c
253
div = DIV_ROUND_UP(ext_freq, mt9p031->target_freq);
drivers/media/i2c/mt9p031.c
256
mt9p031->clk_div = min_t(unsigned int, div, 64);
drivers/media/i2c/mt9p031.c
257
mt9p031->use_pll = false;
drivers/media/i2c/mt9p031.c
262
mt9p031->pll.ext_clock = ext_freq;
drivers/media/i2c/mt9p031.c
263
mt9p031->pll.pix_clock = mt9p031->target_freq;
drivers/media/i2c/mt9p031.c
264
mt9p031->use_pll = true;
drivers/media/i2c/mt9p031.c
266
return aptina_pll_calculate(&client->dev, &limits, &mt9p031->pll);
drivers/media/i2c/mt9p031.c
269
static int mt9p031_pll_enable(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
271
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
274
if (!mt9p031->use_pll)
drivers/media/i2c/mt9p031.c
283
(mt9p031->pll.m << 8) | (mt9p031->pll.n - 1));
drivers/media/i2c/mt9p031.c
287
ret = mt9p031_write(client, MT9P031_PLL_CONFIG_2, mt9p031->pll.p1 - 1);
drivers/media/i2c/mt9p031.c
298
static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
300
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
302
if (!mt9p031->use_pll)
drivers/media/i2c/mt9p031.c
309
static int mt9p031_power_on(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
315
if (mt9p031->reset) {
drivers/media/i2c/mt9p031.c
316
gpiod_set_value(mt9p031->reset, 1);
drivers/media/i2c/mt9p031.c
321
ret = regulator_bulk_enable(ARRAY_SIZE(mt9p031->regulators),
drivers/media/i2c/mt9p031.c
322
mt9p031->regulators);
drivers/media/i2c/mt9p031.c
327
if (mt9p031->clk) {
drivers/media/i2c/mt9p031.c
328
ret = clk_prepare_enable(mt9p031->clk);
drivers/media/i2c/mt9p031.c
330
regulator_bulk_disable(ARRAY_SIZE(mt9p031->regulators),
drivers/media/i2c/mt9p031.c
331
mt9p031->regulators);
drivers/media/i2c/mt9p031.c
337
if (mt9p031->reset) {
drivers/media/i2c/mt9p031.c
338
gpiod_set_value(mt9p031->reset, 0);
drivers/media/i2c/mt9p031.c
340
rate = clk_get_rate(mt9p031->clk);
drivers/media/i2c/mt9p031.c
350
static void mt9p031_power_off(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
352
if (mt9p031->reset) {
drivers/media/i2c/mt9p031.c
353
gpiod_set_value(mt9p031->reset, 1);
drivers/media/i2c/mt9p031.c
357
regulator_bulk_disable(ARRAY_SIZE(mt9p031->regulators),
drivers/media/i2c/mt9p031.c
358
mt9p031->regulators);
drivers/media/i2c/mt9p031.c
360
clk_disable_unprepare(mt9p031->clk);
drivers/media/i2c/mt9p031.c
363
static int __mt9p031_set_power(struct mt9p031 *mt9p031, bool on)
drivers/media/i2c/mt9p031.c
365
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
369
mt9p031_power_off(mt9p031);
drivers/media/i2c/mt9p031.c
373
ret = mt9p031_power_on(mt9p031);
drivers/media/i2c/mt9p031.c
377
ret = mt9p031_reset(mt9p031);
drivers/media/i2c/mt9p031.c
384
if (mt9p031->pixclk_pol) {
drivers/media/i2c/mt9p031.c
391
return v4l2_ctrl_handler_setup(&mt9p031->ctrls);
drivers/media/i2c/mt9p031.c
398
static int mt9p031_set_params(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
400
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
401
struct v4l2_mbus_framefmt *format = &mt9p031->format;
drivers/media/i2c/mt9p031.c
402
const struct v4l2_rect *crop = &mt9p031->crop;
drivers/media/i2c/mt9p031.c
465
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
484
ret = mt9p031_set_output_control(mt9p031,
drivers/media/i2c/mt9p031.c
489
return mt9p031_pll_disable(mt9p031);
drivers/media/i2c/mt9p031.c
492
ret = mt9p031_set_params(mt9p031);
drivers/media/i2c/mt9p031.c
497
ret = mt9p031_set_output_control(mt9p031, 0,
drivers/media/i2c/mt9p031.c
512
return mt9p031_pll_enable(mt9p031);
drivers/media/i2c/mt9p031.c
519
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
524
code->code = mt9p031->format.code;
drivers/media/i2c/mt9p031.c
532
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
534
if (fse->index >= 8 || fse->code != mt9p031->format.code)
drivers/media/i2c/mt9p031.c
547
__mt9p031_get_pad_format(struct mt9p031 *mt9p031,
drivers/media/i2c/mt9p031.c
555
return &mt9p031->format;
drivers/media/i2c/mt9p031.c
562
__mt9p031_get_pad_crop(struct mt9p031 *mt9p031,
drivers/media/i2c/mt9p031.c
570
return &mt9p031->crop;
drivers/media/i2c/mt9p031.c
580
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
582
fmt->format = *__mt9p031_get_pad_format(mt9p031, sd_state, fmt->pad,
drivers/media/i2c/mt9p031.c
591
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
599
__crop = __mt9p031_get_pad_crop(mt9p031, sd_state, format->pad,
drivers/media/i2c/mt9p031.c
615
__format = __mt9p031_get_pad_format(mt9p031, sd_state, format->pad,
drivers/media/i2c/mt9p031.c
629
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
640
sel->r = *__mt9p031_get_pad_crop(mt9p031, sd_state,
drivers/media/i2c/mt9p031.c
653
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
680
__crop = __mt9p031_get_pad_crop(mt9p031, sd_state, sel->pad,
drivers/media/i2c/mt9p031.c
687
__format = __mt9p031_get_pad_format(mt9p031, sd_state,
drivers/media/i2c/mt9p031.c
703
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
709
crop = __mt9p031_get_pad_crop(mt9p031, sd_state, 0, which);
drivers/media/i2c/mt9p031.c
715
format = __mt9p031_get_pad_format(mt9p031, sd_state, 0, which);
drivers/media/i2c/mt9p031.c
716
format->code = mt9p031->code;
drivers/media/i2c/mt9p031.c
734
static int mt9p031_restore_blc(struct mt9p031 *mt9p031)
drivers/media/i2c/mt9p031.c
736
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
739
if (mt9p031->blc_auto->cur.val != 0) {
drivers/media/i2c/mt9p031.c
740
ret = mt9p031_set_mode2(mt9p031, 0,
drivers/media/i2c/mt9p031.c
746
if (mt9p031->blc_offset->cur.val != 0) {
drivers/media/i2c/mt9p031.c
748
mt9p031->blc_offset->cur.val);
drivers/media/i2c/mt9p031.c
758
struct mt9p031 *mt9p031 =
drivers/media/i2c/mt9p031.c
759
container_of(ctrl->handler, struct mt9p031, ctrls);
drivers/media/i2c/mt9p031.c
760
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
drivers/media/i2c/mt9p031.c
806
return mt9p031_set_mode2(mt9p031,
drivers/media/i2c/mt9p031.c
809
return mt9p031_set_mode2(mt9p031,
drivers/media/i2c/mt9p031.c
814
return mt9p031_set_mode2(mt9p031,
drivers/media/i2c/mt9p031.c
817
return mt9p031_set_mode2(mt9p031,
drivers/media/i2c/mt9p031.c
826
v4l2_ctrl_activate(mt9p031->blc_auto, ctrl->val == 0);
drivers/media/i2c/mt9p031.c
827
v4l2_ctrl_activate(mt9p031->blc_offset, ctrl->val == 0);
drivers/media/i2c/mt9p031.c
831
ret = mt9p031_restore_blc(mt9p031);
drivers/media/i2c/mt9p031.c
849
ret = mt9p031_set_mode2(mt9p031, MT9P031_READ_MODE_2_ROW_BLC,
drivers/media/i2c/mt9p031.c
863
ret = mt9p031_set_mode2(mt9p031,
drivers/media/i2c/mt9p031.c
965
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
968
mutex_lock(&mt9p031->power_lock);
drivers/media/i2c/mt9p031.c
973
if (mt9p031->power_count == !on) {
drivers/media/i2c/mt9p031.c
974
ret = __mt9p031_set_power(mt9p031, !!on);
drivers/media/i2c/mt9p031.c
980
mt9p031->power_count += on ? 1 : -1;
drivers/media/i2c/mt9p031.c
981
WARN_ON(mt9p031->power_count < 0);
drivers/media/i2c/mt9p031.c
984
mutex_unlock(&mt9p031->power_lock);
drivers/media/i2c/mt9p031.c
995
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
drivers/media/i2c/mt9p031.c
999
ret = mt9p031_power_on(mt9p031);