Lines Matching +full:4 +full:- +full:inch
1 // SPDX-License-Identifier: GPL-2.0
3 // mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor
13 #include <media/v4l2-device.h>
14 #include <media/v4l2-ctrls.h>
23 MODULE_PARM_DESC(debug, "Debug level (0-2)");
164 analoginit = lineargain / 4; in calc_mt9v011_gain()
182 exposure = core->exposure; in set_balance()
184 green_gain = calc_mt9v011_gain(core->global_gain); in set_balance()
186 bal = core->global_gain; in set_balance()
187 bal += (core->blue_bal * core->global_gain / (1 << 7)); in set_balance()
190 bal = core->global_gain; in set_balance()
191 bal += (core->red_bal * core->global_gain / (1 << 7)); in set_balance()
218 frames_per_ms = core->xtal * 1000l; in calc_fps()
250 t_time = core->xtal * ((u64)numerator); in calc_speed()
262 speed -= 2; in calc_speed()
283 * width-1. However, this doesn't work, since one pixel per line will in set_res()
287 hstart = 20 + (640 - core->width) / 2; in set_res()
289 mt9v011_write(sd, R04_MT9V011_WIDTH, core->width); in set_res()
290 mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width); in set_res()
292 vstart = 8 + (480 - core->height) / 2; in set_res()
294 mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height); in set_res()
295 mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height); in set_res()
305 if (core->hflip) in set_read_mode()
308 if (core->vflip) in set_read_mode()
333 if (code->pad || code->index > 0) in mt9v011_enum_mbus_code()
334 return -EINVAL; in mt9v011_enum_mbus_code()
336 code->code = MEDIA_BUS_FMT_SGRBG8_1X8; in mt9v011_enum_mbus_code()
344 struct v4l2_mbus_framefmt *fmt = &format->format; in mt9v011_set_fmt()
347 if (format->pad || fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8) in mt9v011_set_fmt()
348 return -EINVAL; in mt9v011_set_fmt()
350 v4l_bound_align_image(&fmt->width, 48, 639, 1, in mt9v011_set_fmt()
351 &fmt->height, 32, 480, 1, 0); in mt9v011_set_fmt()
352 fmt->field = V4L2_FIELD_NONE; in mt9v011_set_fmt()
353 fmt->colorspace = V4L2_COLORSPACE_SRGB; in mt9v011_set_fmt()
355 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { in mt9v011_set_fmt()
356 core->width = fmt->width; in mt9v011_set_fmt()
357 core->height = fmt->height; in mt9v011_set_fmt()
361 sd_state->pads->try_fmt = *fmt; in mt9v011_set_fmt()
371 &ival->interval.numerator, in mt9v011_g_frame_interval()
372 &ival->interval.denominator); in mt9v011_g_frame_interval()
380 struct v4l2_fract *tpf = &ival->interval; in mt9v011_s_frame_interval()
383 speed = calc_speed(sd, tpf->numerator, tpf->denominator); in mt9v011_s_frame_interval()
389 calc_fps(sd, &tpf->numerator, &tpf->denominator); in mt9v011_s_frame_interval()
398 reg->val = mt9v011_read(sd, reg->reg & 0xff); in mt9v011_g_register()
399 reg->size = 2; in mt9v011_g_register()
407 mt9v011_write(sd, reg->reg & 0xff, reg->val & 0xffff); in mt9v011_s_register()
416 container_of(ctrl->handler, struct mt9v011, ctrls); in mt9v011_s_ctrl()
417 struct v4l2_subdev *sd = &core->sd; in mt9v011_s_ctrl()
419 switch (ctrl->id) { in mt9v011_s_ctrl()
421 core->global_gain = ctrl->val; in mt9v011_s_ctrl()
424 core->exposure = ctrl->val; in mt9v011_s_ctrl()
427 core->red_bal = ctrl->val; in mt9v011_s_ctrl()
430 core->blue_bal = ctrl->val; in mt9v011_s_ctrl()
433 core->hflip = ctrl->val; in mt9v011_s_ctrl()
437 core->vflip = ctrl->val; in mt9v011_s_ctrl()
441 return -EINVAL; in mt9v011_s_ctrl()
492 if (!i2c_check_functionality(c->adapter, in mt9v011_probe()
494 return -EIO; in mt9v011_probe()
496 core = devm_kzalloc(&c->dev, sizeof(struct mt9v011), GFP_KERNEL); in mt9v011_probe()
498 return -ENOMEM; in mt9v011_probe()
500 sd = &core->sd; in mt9v011_probe()
504 core->pad.flags = MEDIA_PAD_FL_SOURCE; in mt9v011_probe()
505 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in mt9v011_probe()
507 ret = media_entity_pads_init(&sd->entity, 1, &core->pad); in mt9v011_probe()
518 return -EINVAL; in mt9v011_probe()
521 v4l2_ctrl_handler_init(&core->ctrls, 5); in mt9v011_probe()
522 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
523 V4L2_CID_GAIN, 0, (1 << 12) - 1 - 0x20, 1, 0x20); in mt9v011_probe()
524 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
526 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
527 V4L2_CID_RED_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); in mt9v011_probe()
528 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
529 V4L2_CID_BLUE_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); in mt9v011_probe()
530 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
532 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
535 if (core->ctrls.error) { in mt9v011_probe()
536 int ret = core->ctrls.error; in mt9v011_probe()
539 v4l2_ctrl_handler_free(&core->ctrls); in mt9v011_probe()
542 core->sd.ctrl_handler = &core->ctrls; in mt9v011_probe()
544 core->global_gain = 0x0024; in mt9v011_probe()
545 core->exposure = 0x01fc; in mt9v011_probe()
546 core->width = 640; in mt9v011_probe()
547 core->height = 480; in mt9v011_probe()
548 core->xtal = 27000000; /* Hz */ in mt9v011_probe()
550 if (c->dev.platform_data) { in mt9v011_probe()
551 struct mt9v011_platform_data *pdata = c->dev.platform_data; in mt9v011_probe()
553 core->xtal = pdata->xtal; in mt9v011_probe()
555 core->xtal / 1000000, (core->xtal / 1000) % 1000); in mt9v011_probe()
558 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", in mt9v011_probe()
559 c->addr << 1, c->adapter->name, version); in mt9v011_probe()
571 c->addr << 1); in mt9v011_remove()
574 v4l2_ctrl_handler_free(&core->ctrls); in mt9v011_remove()
577 /* ----------------------------------------------------------------------- */