Lines Matching +full:9 +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)");
169 return analoginit + (analogmult << 7) + (digitalgain << 9); in calc_mt9v011_gain()
180 exposure = core->exposure; in set_balance()
182 green_gain = calc_mt9v011_gain(core->global_gain); in set_balance()
184 bal = core->global_gain; in set_balance()
185 bal += (core->blue_bal * core->global_gain / (1 << 7)); in set_balance()
188 bal = core->global_gain; in set_balance()
189 bal += (core->red_bal * core->global_gain / (1 << 7)); in set_balance()
216 frames_per_ms = core->xtal * 1000l; in calc_fps()
248 t_time = core->xtal * ((u64)numerator); in calc_speed()
260 speed -= 2; in calc_speed()
281 * width-1. However, this doesn't work, since one pixel per line will in set_res()
285 hstart = 20 + (640 - core->width) / 2; in set_res()
287 mt9v011_write(sd, R04_MT9V011_WIDTH, core->width); in set_res()
288 mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width); in set_res()
290 vstart = 8 + (480 - core->height) / 2; in set_res()
292 mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height); in set_res()
293 mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height); in set_res()
303 if (core->hflip) in set_read_mode()
306 if (core->vflip) in set_read_mode()
331 if (code->pad || code->index > 0) in mt9v011_enum_mbus_code()
332 return -EINVAL; in mt9v011_enum_mbus_code()
334 code->code = MEDIA_BUS_FMT_SGRBG8_1X8; in mt9v011_enum_mbus_code()
342 struct v4l2_mbus_framefmt *fmt = &format->format; in mt9v011_set_fmt()
345 if (format->pad || fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8) in mt9v011_set_fmt()
346 return -EINVAL; in mt9v011_set_fmt()
348 v4l_bound_align_image(&fmt->width, 48, 639, 1, in mt9v011_set_fmt()
349 &fmt->height, 32, 480, 1, 0); in mt9v011_set_fmt()
350 fmt->field = V4L2_FIELD_NONE; in mt9v011_set_fmt()
351 fmt->colorspace = V4L2_COLORSPACE_SRGB; in mt9v011_set_fmt()
353 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { in mt9v011_set_fmt()
354 core->width = fmt->width; in mt9v011_set_fmt()
355 core->height = fmt->height; in mt9v011_set_fmt()
373 if (ival->which != V4L2_SUBDEV_FORMAT_ACTIVE) in mt9v011_get_frame_interval()
374 return -EINVAL; in mt9v011_get_frame_interval()
377 &ival->interval.numerator, in mt9v011_get_frame_interval()
378 &ival->interval.denominator); in mt9v011_get_frame_interval()
387 struct v4l2_fract *tpf = &ival->interval; in mt9v011_set_frame_interval()
394 if (ival->which != V4L2_SUBDEV_FORMAT_ACTIVE) in mt9v011_set_frame_interval()
395 return -EINVAL; in mt9v011_set_frame_interval()
397 speed = calc_speed(sd, tpf->numerator, tpf->denominator); in mt9v011_set_frame_interval()
403 calc_fps(sd, &tpf->numerator, &tpf->denominator); in mt9v011_set_frame_interval()
412 reg->val = mt9v011_read(sd, reg->reg & 0xff); in mt9v011_g_register()
413 reg->size = 2; in mt9v011_g_register()
421 mt9v011_write(sd, reg->reg & 0xff, reg->val & 0xffff); in mt9v011_s_register()
430 container_of(ctrl->handler, struct mt9v011, ctrls); in mt9v011_s_ctrl()
431 struct v4l2_subdev *sd = &core->sd; in mt9v011_s_ctrl()
433 switch (ctrl->id) { in mt9v011_s_ctrl()
435 core->global_gain = ctrl->val; in mt9v011_s_ctrl()
438 core->exposure = ctrl->val; in mt9v011_s_ctrl()
441 core->red_bal = ctrl->val; in mt9v011_s_ctrl()
444 core->blue_bal = ctrl->val; in mt9v011_s_ctrl()
447 core->hflip = ctrl->val; in mt9v011_s_ctrl()
451 core->vflip = ctrl->val; in mt9v011_s_ctrl()
455 return -EINVAL; in mt9v011_s_ctrl()
499 if (!i2c_check_functionality(c->adapter, in mt9v011_probe()
501 return -EIO; in mt9v011_probe()
503 core = devm_kzalloc(&c->dev, sizeof(struct mt9v011), GFP_KERNEL); in mt9v011_probe()
505 return -ENOMEM; in mt9v011_probe()
507 sd = &core->sd; in mt9v011_probe()
510 core->pad.flags = MEDIA_PAD_FL_SOURCE; in mt9v011_probe()
511 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; in mt9v011_probe()
513 ret = media_entity_pads_init(&sd->entity, 1, &core->pad); in mt9v011_probe()
523 return -EINVAL; in mt9v011_probe()
526 v4l2_ctrl_handler_init(&core->ctrls, 5); in mt9v011_probe()
527 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
528 V4L2_CID_GAIN, 0, (1 << 12) - 1 - 0x20, 1, 0x20); in mt9v011_probe()
529 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
531 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
532 V4L2_CID_RED_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); in mt9v011_probe()
533 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
534 V4L2_CID_BLUE_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); in mt9v011_probe()
535 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
537 v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, in mt9v011_probe()
540 if (core->ctrls.error) { in mt9v011_probe()
541 int ret = core->ctrls.error; in mt9v011_probe()
544 v4l2_ctrl_handler_free(&core->ctrls); in mt9v011_probe()
547 core->sd.ctrl_handler = &core->ctrls; in mt9v011_probe()
549 core->global_gain = 0x0024; in mt9v011_probe()
550 core->exposure = 0x01fc; in mt9v011_probe()
551 core->width = 640; in mt9v011_probe()
552 core->height = 480; in mt9v011_probe()
553 core->xtal = 27000000; /* Hz */ in mt9v011_probe()
555 if (c->dev.platform_data) { in mt9v011_probe()
556 struct mt9v011_platform_data *pdata = c->dev.platform_data; in mt9v011_probe()
558 core->xtal = pdata->xtal; in mt9v011_probe()
560 core->xtal / 1000000, (core->xtal / 1000) % 1000); in mt9v011_probe()
563 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", in mt9v011_probe()
564 c->addr << 1, c->adapter->name, version); in mt9v011_probe()
576 c->addr << 1); in mt9v011_remove()
579 v4l2_ctrl_handler_free(&core->ctrls); in mt9v011_remove()
582 /* ----------------------------------------------------------------------- */