Lines Matching +full:10 +full:- +full:inch
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for SiliconFile SR030PC30 VGA (1/10-Inch) Image Sensor with ISP
19 #include <media/v4l2-device.h>
20 #include <media/v4l2-subdev.h>
21 #include <media/v4l2-mediabus.h>
22 #include <media/v4l2-ctrls.h>
32 * b15..b8 - page id, b7..b0 - register address
57 /* page 10 */
79 /* page 14 - Lens Shading Compensation */
86 /* page 15 - Color correction */
95 /* page 16 - Gamma correction */
99 /* page 20 - Auto Exposure */
112 /* page 22 - Auto White Balance */
253 { GMA_COEF_REG(9), 0xBD }, { GMA_COEF_REG(10), 0xCA },
256 /* Noise reduction, Z-LPF, YC-LPF and BLPF filters setup */
291 if (info->i2c_reg_page != page && (reg & 0xFF) != 0x03) { in set_i2c_page()
294 info->i2c_reg_page = page; in set_i2c_page()
325 while (msg->addr != REG_TERM) { in sr030pc30_bulk_write_reg()
326 int ret = cam_i2c_write(sd, msg->addr, msg->val); in sr030pc30_bulk_write_reg()
347 info->sleep = sleep; in sr030pc30_pwr_ctrl()
349 info->i2c_reg_page = -1; in sr030pc30_pwr_ctrl()
364 if (info->hflip) in sr030pc30_set_flip()
366 if (info->vflip) in sr030pc30_set_flip()
377 if (!info->curr_win) in sr030pc30_set_params()
378 return -EINVAL; in sr030pc30_set_params()
382 info->curr_win->vid_ctl1); in sr030pc30_set_params()
384 if (!ret && info->curr_fmt) in sr030pc30_set_params()
386 info->curr_fmt->ispctl1_reg); in sr030pc30_set_params()
400 while (i--) { in sr030pc30_try_frame_size()
401 int err = abs(fsize->width - mf->width) in sr030pc30_try_frame_size()
402 + abs(fsize->height - mf->height); in sr030pc30_try_frame_size()
410 mf->width = match->width; in sr030pc30_try_frame_size()
411 mf->height = match->height; in sr030pc30_try_frame_size()
414 return -EINVAL; in sr030pc30_try_frame_size()
420 container_of(ctrl->handler, struct sr030pc30_info, hdl); in sr030pc30_s_ctrl()
421 struct v4l2_subdev *sd = &info->sd; in sr030pc30_s_ctrl()
425 __func__, ctrl->id, ctrl->val); in sr030pc30_s_ctrl()
427 switch (ctrl->id) { in sr030pc30_s_ctrl()
429 if (ctrl->is_new) { in sr030pc30_s_ctrl()
431 ctrl->val ? 0x2E : 0x2F); in sr030pc30_s_ctrl()
434 ctrl->val ? 0xFB : 0x7B); in sr030pc30_s_ctrl()
436 if (!ret && info->blue->is_new) in sr030pc30_s_ctrl()
437 ret = cam_i2c_write(sd, MWB_BGAIN_REG, info->blue->val); in sr030pc30_s_ctrl()
438 if (!ret && info->red->is_new) in sr030pc30_s_ctrl()
439 ret = cam_i2c_write(sd, MWB_RGAIN_REG, info->red->val); in sr030pc30_s_ctrl()
443 /* auto anti-flicker is also enabled here */ in sr030pc30_s_ctrl()
444 if (ctrl->is_new) in sr030pc30_s_ctrl()
446 ctrl->val == V4L2_EXPOSURE_AUTO ? 0xDC : 0x0C); in sr030pc30_s_ctrl()
447 if (info->exp->is_new) { in sr030pc30_s_ctrl()
448 unsigned long expos = info->exp->val; in sr030pc30_s_ctrl()
450 expos = expos * info->pdata->clk_rate / (8 * 1000); in sr030pc30_s_ctrl()
464 return -EINVAL; in sr030pc30_s_ctrl()
474 if (!code || code->pad || in sr030pc30_enum_mbus_code()
475 code->index >= ARRAY_SIZE(sr030pc30_formats)) in sr030pc30_enum_mbus_code()
476 return -EINVAL; in sr030pc30_enum_mbus_code()
478 code->code = sr030pc30_formats[code->index].code; in sr030pc30_enum_mbus_code()
489 if (!format || format->pad) in sr030pc30_get_fmt()
490 return -EINVAL; in sr030pc30_get_fmt()
492 mf = &format->format; in sr030pc30_get_fmt()
494 if (!info->curr_win || !info->curr_fmt) in sr030pc30_get_fmt()
495 return -EINVAL; in sr030pc30_get_fmt()
497 mf->width = info->curr_win->width; in sr030pc30_get_fmt()
498 mf->height = info->curr_win->height; in sr030pc30_get_fmt()
499 mf->code = info->curr_fmt->code; in sr030pc30_get_fmt()
500 mf->colorspace = info->curr_fmt->colorspace; in sr030pc30_get_fmt()
501 mf->field = V4L2_FIELD_NONE; in sr030pc30_get_fmt()
515 if (mf->code == sr030pc30_formats[i].code) in try_fmt()
521 mf->code = sr030pc30_formats[i].code; in try_fmt()
536 return -EINVAL; in sr030pc30_set_fmt()
538 mf = &format->format; in sr030pc30_set_fmt()
539 if (format->pad) in sr030pc30_set_fmt()
540 return -EINVAL; in sr030pc30_set_fmt()
543 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { in sr030pc30_set_fmt()
544 sd_state->pads->try_fmt = *mf; in sr030pc30_set_fmt()
548 info->curr_fmt = fmt; in sr030pc30_set_fmt()
561 info->curr_fmt = &sr030pc30_formats[0]; in sr030pc30_base_config()
562 info->curr_win = &sr030pc30_sizes[0]; in sr030pc30_base_config()
571 expmin = EXPOS_MIN_MS * info->pdata->clk_rate / (8 * 1000); in sr030pc30_base_config()
572 expmax = EXPOS_MAX_MS * info->pdata->clk_rate / (8 * 1000); in sr030pc30_base_config()
595 const struct sr030pc30_platform_data *pdata = info->pdata; in sr030pc30_s_power()
600 return -EINVAL; in sr030pc30_s_power()
611 if (pdata->set_power) { in sr030pc30_s_power()
612 ret = pdata->set_power(&client->dev, on); in sr030pc30_s_power()
621 info->curr_win = NULL; in sr030pc30_s_power()
622 info->curr_fmt = NULL; in sr030pc30_s_power()
649 * or -ENODEV otherwise.
654 = client->dev.platform_data; in sr030pc30_detect()
658 if (pdata->set_power) { in sr030pc30_detect()
659 ret = pdata->set_power(&client->dev, 1); in sr030pc30_detect()
666 if (pdata->set_power) in sr030pc30_detect()
667 pdata->set_power(&client->dev, 0); in sr030pc30_detect()
670 dev_err(&client->dev, "%s: I2C read failed\n", __func__); in sr030pc30_detect()
674 return ret == SR030PC30_ID ? 0 : -ENODEV; in sr030pc30_detect()
685 = client->dev.platform_data; in sr030pc30_probe()
689 dev_err(&client->dev, "No platform data!"); in sr030pc30_probe()
690 return -EIO; in sr030pc30_probe()
697 info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); in sr030pc30_probe()
699 return -ENOMEM; in sr030pc30_probe()
701 sd = &info->sd; in sr030pc30_probe()
702 info->pdata = client->dev.platform_data; in sr030pc30_probe()
706 hdl = &info->hdl; in sr030pc30_probe()
708 info->awb = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, in sr030pc30_probe()
710 info->red = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, in sr030pc30_probe()
712 info->blue = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, in sr030pc30_probe()
714 info->autoexp = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, in sr030pc30_probe()
716 info->exp = v4l2_ctrl_new_std(hdl, &sr030pc30_ctrl_ops, in sr030pc30_probe()
718 sd->ctrl_handler = hdl; in sr030pc30_probe()
719 if (hdl->error) { in sr030pc30_probe()
720 int err = hdl->error; in sr030pc30_probe()
725 v4l2_ctrl_auto_cluster(3, &info->awb, 0, false); in sr030pc30_probe()
726 v4l2_ctrl_auto_cluster(2, &info->autoexp, V4L2_EXPOSURE_MANUAL, false); in sr030pc30_probe()
729 info->i2c_reg_page = -1; in sr030pc30_probe()
730 info->hflip = 1; in sr030pc30_probe()
740 v4l2_ctrl_handler_free(sd->ctrl_handler); in sr030pc30_remove()