1 // SPDX-License-Identifier: GPL-2.0
3 * Support for OmniVision OV2722 1080p HD camera sensor.
5 * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/kernel.h>
22 #include <linux/string.h>
23 #include <linux/errno.h>
24 #include <linux/init.h>
25 #include <linux/kmod.h>
26 #include <linux/device.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/i2c.h>
30 #include <linux/moduleparam.h>
31 #include <media/v4l2-device.h>
32 #include "../include/linux/atomisp_gmin_platform.h"
33 #include <linux/acpi.h>
38 /* i2c read/write stuff */
39 static int ov2722_read_reg(struct i2c_client *client,
40 u16 data_length, u16 reg, u16 *val)
43 struct i2c_msg msg[2];
44 unsigned char data[6];
46 if (!client->adapter) {
47 dev_err(&client->dev, "%s error, no client->adapter\n",
52 if (data_length != OV2722_8BIT && data_length != OV2722_16BIT &&
53 data_length != OV2722_32BIT) {
54 dev_err(&client->dev, "%s error, invalid data length\n",
59 memset(msg, 0, sizeof(msg));
61 msg[0].addr = client->addr;
63 msg[0].len = I2C_MSG_LENGTH;
66 /* high byte goes out first */
67 data[0] = (u8)(reg >> 8);
68 data[1] = (u8)(reg & 0xff);
70 msg[1].addr = client->addr;
71 msg[1].len = data_length;
72 msg[1].flags = I2C_M_RD;
75 err = i2c_transfer(client->adapter, msg, 2);
80 "read from offset 0x%x error %d", reg, err);
85 /* high byte comes first */
86 if (data_length == OV2722_8BIT)
88 else if (data_length == OV2722_16BIT)
89 *val = be16_to_cpu(*(__be16 *)&data[0]);
91 *val = be32_to_cpu(*(__be32 *)&data[0]);
96 static int ov2722_i2c_write(struct i2c_client *client, u16 len, u8 *data)
99 const int num_msg = 1;
102 msg.addr = client->addr;
106 ret = i2c_transfer(client->adapter, &msg, 1);
108 return ret == num_msg ? 0 : -EIO;
111 static int ov2722_write_reg(struct i2c_client *client, u16 data_length,
115 unsigned char data[4] = {0};
116 __be16 *wreg = (__be16 *)data;
117 const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
119 if (data_length != OV2722_8BIT && data_length != OV2722_16BIT) {
120 dev_err(&client->dev,
121 "%s error, invalid data_length\n", __func__);
125 /* high byte goes out first */
126 *wreg = cpu_to_be16(reg);
128 if (data_length == OV2722_8BIT) {
132 __be16 *wdata = (__be16 *)&data[2];
134 *wdata = cpu_to_be16(val);
137 ret = ov2722_i2c_write(client, len, data);
139 dev_err(&client->dev,
140 "write error: wrote 0x%x to offset 0x%x error %d",
147 * ov2722_write_reg_array - Initializes a list of OV2722 registers
148 * @client: i2c driver client structure
149 * @reglist: list of registers to be written
151 * This function initializes a list of registers. When consecutive addresses
152 * are found in a row on the list, this function creates a buffer and sends
153 * consecutive data in a single i2c_transfer().
155 * __ov2722_flush_reg_array, __ov2722_buf_reg_array() and
156 * __ov2722_write_reg_is_consecutive() are internal functions to
157 * ov2722_write_reg_array_fast() and should be not used anywhere else.
161 static int __ov2722_flush_reg_array(struct i2c_client *client,
162 struct ov2722_write_ctrl *ctrl)
165 __be16 *data16 = (void *)&ctrl->buffer.addr;
167 if (ctrl->index == 0)
170 size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
171 *data16 = cpu_to_be16(ctrl->buffer.addr);
174 return ov2722_i2c_write(client, size, (u8 *)&ctrl->buffer);
177 static int __ov2722_buf_reg_array(struct i2c_client *client,
178 struct ov2722_write_ctrl *ctrl,
179 const struct ov2722_reg *next)
184 switch (next->type) {
187 ctrl->buffer.data[ctrl->index] = (u8)next->val;
191 data16 = (void *)&ctrl->buffer.data[ctrl->index];
192 *data16 = cpu_to_be16((u16)next->val);
198 /* When first item is added, we need to store its starting address */
199 if (ctrl->index == 0)
200 ctrl->buffer.addr = next->reg;
205 * Buffer cannot guarantee free space for u32? Better flush it to avoid
206 * possible lack of memory for next item.
208 if (ctrl->index + sizeof(u16) >= OV2722_MAX_WRITE_BUF_SIZE)
209 return __ov2722_flush_reg_array(client, ctrl);
214 static int __ov2722_write_reg_is_consecutive(struct i2c_client *client,
215 struct ov2722_write_ctrl *ctrl,
216 const struct ov2722_reg *next)
218 if (ctrl->index == 0)
221 return ctrl->buffer.addr + ctrl->index == next->reg;
224 static int ov2722_write_reg_array(struct i2c_client *client,
225 const struct ov2722_reg *reglist)
227 const struct ov2722_reg *next = reglist;
228 struct ov2722_write_ctrl ctrl;
232 for (; next->type != OV2722_TOK_TERM; next++) {
233 switch (next->type & OV2722_TOK_MASK) {
234 case OV2722_TOK_DELAY:
235 err = __ov2722_flush_reg_array(client, &ctrl);
242 * If next address is not consecutive, data needs to be
243 * flushed before proceed.
245 if (!__ov2722_write_reg_is_consecutive(client, &ctrl,
247 err = __ov2722_flush_reg_array(client, &ctrl);
251 err = __ov2722_buf_reg_array(client, &ctrl, next);
253 dev_err(&client->dev, "%s: write error, aborted\n",
261 return __ov2722_flush_reg_array(client, &ctrl);
264 static long __ov2722_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
265 int gain, int digitgain)
268 struct i2c_client *client = v4l2_get_subdevdata(sd);
269 struct ov2722_device *dev = to_ov2722_sensor(sd);
273 dev_dbg(&client->dev, "set_exposure without group hold\n");
275 /* clear VTS_DIFF on manual mode */
276 ret = ov2722_write_reg(client, OV2722_16BIT, OV2722_VTS_DIFF_H, 0);
280 hts = dev->pixels_per_line;
281 vts = dev->lines_per_frame;
283 if ((coarse_itg + OV2722_COARSE_INTG_TIME_MAX_MARGIN) > vts)
284 vts = coarse_itg + OV2722_COARSE_INTG_TIME_MAX_MARGIN;
289 ret = ov2722_write_reg(client, OV2722_16BIT,
294 ret = ov2722_write_reg(client, OV2722_16BIT,
300 ret = ov2722_write_reg(client, OV2722_8BIT,
301 OV2722_AEC_PK_EXPO_L,
306 ret = ov2722_write_reg(client, OV2722_16BIT,
307 OV2722_AEC_PK_EXPO_H,
308 (coarse_itg >> 8) & 0xfff);
312 /* set analog gain */
313 ret = ov2722_write_reg(client, OV2722_16BIT,
314 OV2722_AGC_ADJ_H, gain);
318 /* set digital gain */
319 ret = ov2722_write_reg(client, OV2722_16BIT,
320 OV2722_MWB_GAIN_R_H, digitgain);
324 ret = ov2722_write_reg(client, OV2722_16BIT,
325 OV2722_MWB_GAIN_G_H, digitgain);
329 ret = ov2722_write_reg(client, OV2722_16BIT,
330 OV2722_MWB_GAIN_B_H, digitgain);
335 static int ov2722_set_exposure(struct v4l2_subdev *sd, int exposure,
336 int gain, int digitgain)
338 struct ov2722_device *dev = to_ov2722_sensor(sd);
341 mutex_lock(&dev->input_lock);
342 ret = __ov2722_set_exposure(sd, exposure, gain, digitgain);
343 mutex_unlock(&dev->input_lock);
348 static long ov2722_s_exposure(struct v4l2_subdev *sd,
349 struct atomisp_exposure *exposure)
351 int exp = exposure->integration_time[0];
352 int gain = exposure->gain[0];
353 int digitgain = exposure->gain[1];
355 /* we should not accept the invalid value below. */
357 struct i2c_client *client = v4l2_get_subdevdata(sd);
359 v4l2_err(client, "%s: invalid value\n", __func__);
363 return ov2722_set_exposure(sd, exp, gain, digitgain);
366 static long ov2722_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
369 case ATOMISP_IOC_S_EXPOSURE:
370 return ov2722_s_exposure(sd, arg);
377 /* This returns the exposure time being used. This should only be used
378 * for filling in EXIF data, not for actual image processing.
380 static int ov2722_q_exposure(struct v4l2_subdev *sd, s32 *value)
382 struct i2c_client *client = v4l2_get_subdevdata(sd);
387 ret = ov2722_read_reg(client, OV2722_8BIT,
388 OV2722_AEC_PK_EXPO_L,
393 ret = ov2722_read_reg(client, OV2722_8BIT,
394 OV2722_AEC_PK_EXPO_M,
399 reg_v += reg_v2 << 8;
400 ret = ov2722_read_reg(client, OV2722_8BIT,
401 OV2722_AEC_PK_EXPO_H,
406 *value = reg_v + (((u32)reg_v2 << 16));
411 static int ov2722_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
413 struct ov2722_device *dev =
414 container_of(ctrl->handler, struct ov2722_device, ctrl_handler);
419 case V4L2_CID_EXPOSURE_ABSOLUTE:
420 ret = ov2722_q_exposure(&dev->sd, &ctrl->val);
422 case V4L2_CID_LINK_FREQ:
423 val = dev->res->mipi_freq;
427 ctrl->val = val * 1000; /* To Hz */
436 static const struct v4l2_ctrl_ops ctrl_ops = {
437 .g_volatile_ctrl = ov2722_g_volatile_ctrl
440 static const struct v4l2_ctrl_config ov2722_controls[] = {
443 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
444 .type = V4L2_CTRL_TYPE_INTEGER,
454 .id = V4L2_CID_LINK_FREQ,
455 .name = "Link Frequency",
456 .type = V4L2_CTRL_TYPE_INTEGER,
458 .max = 1500000 * 1000,
461 .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY,
465 static int ov2722_init(struct v4l2_subdev *sd)
467 struct ov2722_device *dev = to_ov2722_sensor(sd);
469 mutex_lock(&dev->input_lock);
471 /* restore settings */
472 ov2722_res = ov2722_res_preview;
473 N_RES = N_RES_PREVIEW;
475 mutex_unlock(&dev->input_lock);
480 static int power_ctrl(struct v4l2_subdev *sd, bool flag)
483 struct ov2722_device *dev = to_ov2722_sensor(sd);
485 if (!dev || !dev->platform_data)
489 ret = dev->platform_data->v1p8_ctrl(sd, 1);
491 ret = dev->platform_data->v2p8_ctrl(sd, 1);
493 dev->platform_data->v1p8_ctrl(sd, 0);
496 ret = dev->platform_data->v1p8_ctrl(sd, 0);
497 ret |= dev->platform_data->v2p8_ctrl(sd, 0);
503 static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
505 struct ov2722_device *dev = to_ov2722_sensor(sd);
508 if (!dev || !dev->platform_data)
511 /* Note: the GPIO order is asymmetric: always RESET#
512 * before PWDN# when turning it on or off.
514 ret = dev->platform_data->gpio0_ctrl(sd, flag);
515 ret |= dev->platform_data->gpio1_ctrl(sd, flag);
519 static int power_up(struct v4l2_subdev *sd)
521 struct ov2722_device *dev = to_ov2722_sensor(sd);
522 struct i2c_client *client = v4l2_get_subdevdata(sd);
525 if (!dev->platform_data) {
526 dev_err(&client->dev,
527 "no camera_sensor_platform_data");
532 ret = power_ctrl(sd, 1);
536 /* according to DS, at least 5ms is needed between DOVDD and PWDN */
537 usleep_range(5000, 6000);
540 ret = gpio_ctrl(sd, 1);
542 ret = gpio_ctrl(sd, 0);
547 /* flis clock control */
548 ret = dev->platform_data->flisclk_ctrl(sd, 1);
552 /* according to DS, 20ms is needed between PWDN and i2c access */
561 dev_err(&client->dev, "sensor power-up failed\n");
566 static int power_down(struct v4l2_subdev *sd)
568 struct ov2722_device *dev = to_ov2722_sensor(sd);
569 struct i2c_client *client = v4l2_get_subdevdata(sd);
572 if (!dev->platform_data) {
573 dev_err(&client->dev,
574 "no camera_sensor_platform_data");
578 ret = dev->platform_data->flisclk_ctrl(sd, 0);
580 dev_err(&client->dev, "flisclk failed\n");
583 ret = gpio_ctrl(sd, 0);
585 ret = gpio_ctrl(sd, 0);
587 dev_err(&client->dev, "gpio failed 2\n");
591 ret = power_ctrl(sd, 0);
593 dev_err(&client->dev, "vprog failed.\n");
598 static int ov2722_s_power(struct v4l2_subdev *sd, int on)
603 return power_down(sd);
607 return ov2722_init(sd);
612 /* TODO: remove it. */
613 static int startup(struct v4l2_subdev *sd)
615 struct ov2722_device *dev = to_ov2722_sensor(sd);
616 struct i2c_client *client = v4l2_get_subdevdata(sd);
619 ret = ov2722_write_reg(client, OV2722_8BIT,
620 OV2722_SW_RESET, 0x01);
622 dev_err(&client->dev, "ov2722 reset err.\n");
626 ret = ov2722_write_reg_array(client, dev->res->regs);
628 dev_err(&client->dev, "ov2722 write register err.\n");
635 static int ov2722_set_fmt(struct v4l2_subdev *sd,
636 struct v4l2_subdev_state *sd_state,
637 struct v4l2_subdev_format *format)
639 struct v4l2_mbus_framefmt *fmt = &format->format;
640 struct ov2722_device *dev = to_ov2722_sensor(sd);
641 struct i2c_client *client = v4l2_get_subdevdata(sd);
642 struct ov2722_resolution *res;
643 struct camera_mipi_info *ov2722_info = NULL;
650 ov2722_info = v4l2_get_subdev_hostdata(sd);
654 res = v4l2_find_nearest_size(ov2722_res_preview,
655 ARRAY_SIZE(ov2722_res_preview), width,
656 height, fmt->width, fmt->height);
658 res = &ov2722_res_preview[N_RES - 1];
660 fmt->width = res->width;
661 fmt->height = res->height;
664 fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
665 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
666 sd_state->pads->try_fmt = *fmt;
670 mutex_lock(&dev->input_lock);
672 dev->pixels_per_line = dev->res->pixels_per_line;
673 dev->lines_per_frame = dev->res->lines_per_frame;
679 dev_err(&client->dev, "ov2722 startup err, retry to power up\n");
680 for (i = 0; i < OV2722_POWER_UP_RETRY_NUM; i++) {
681 dev_err(&client->dev,
682 "ov2722 retry to power up %d/%d times, result: ",
683 i + 1, OV2722_POWER_UP_RETRY_NUM);
687 dev_err(&client->dev, "power up failed, continue\n");
692 dev_err(&client->dev, " startup FAILED!\n");
694 dev_err(&client->dev, " startup SUCCESS!\n");
699 dev_err(&client->dev, "ov2722 startup err\n");
705 mutex_unlock(&dev->input_lock);
709 static int ov2722_get_fmt(struct v4l2_subdev *sd,
710 struct v4l2_subdev_state *sd_state,
711 struct v4l2_subdev_format *format)
713 struct v4l2_mbus_framefmt *fmt = &format->format;
714 struct ov2722_device *dev = to_ov2722_sensor(sd);
721 fmt->width = dev->res->width;
722 fmt->height = dev->res->height;
723 fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
728 static int ov2722_detect(struct i2c_client *client)
730 struct i2c_adapter *adapter = client->adapter;
731 u16 high = 0, low = 0;
735 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
738 ov2722_read_reg(client, OV2722_8BIT,
739 OV2722_SC_CMMN_CHIP_ID_H, &high);
740 ov2722_read_reg(client, OV2722_8BIT,
741 OV2722_SC_CMMN_CHIP_ID_L, &low);
742 id = (high << 8) | low;
744 if ((id != OV2722_ID) && (id != OV2720_ID)) {
745 dev_err(&client->dev, "sensor ID error\n");
750 ov2722_read_reg(client, OV2722_8BIT,
751 OV2722_SC_CMMN_SUB_ID, &high);
752 revision = (u8)high & 0x0f;
754 dev_dbg(&client->dev, "sensor_revision = 0x%x\n", revision);
755 dev_dbg(&client->dev, "detect ov2722 success\n");
759 static int ov2722_s_stream(struct v4l2_subdev *sd, int enable)
761 struct ov2722_device *dev = to_ov2722_sensor(sd);
762 struct i2c_client *client = v4l2_get_subdevdata(sd);
765 mutex_lock(&dev->input_lock);
767 ret = ov2722_write_reg(client, OV2722_8BIT, OV2722_SW_STREAM,
768 enable ? OV2722_START_STREAMING :
769 OV2722_STOP_STREAMING);
771 mutex_unlock(&dev->input_lock);
775 static int ov2722_s_config(struct v4l2_subdev *sd,
776 int irq, void *platform_data)
778 struct ov2722_device *dev = to_ov2722_sensor(sd);
779 struct i2c_client *client = v4l2_get_subdevdata(sd);
786 (struct camera_sensor_platform_data *)platform_data;
788 mutex_lock(&dev->input_lock);
790 /* power off the module, then power on it in future
791 * as first power on by board may not fulfill the
792 * power on sequqence needed by the module
794 ret = power_down(sd);
796 dev_err(&client->dev, "ov2722 power-off err.\n");
802 dev_err(&client->dev, "ov2722 power-up err.\n");
806 ret = dev->platform_data->csi_cfg(sd, 1);
810 /* config & detect sensor */
811 ret = ov2722_detect(client);
813 dev_err(&client->dev, "ov2722_detect err s_config.\n");
817 /* turn off sensor, after probed */
818 ret = power_down(sd);
820 dev_err(&client->dev, "ov2722 power-off err.\n");
823 mutex_unlock(&dev->input_lock);
828 dev->platform_data->csi_cfg(sd, 0);
831 dev_err(&client->dev, "sensor power-gating failed\n");
833 mutex_unlock(&dev->input_lock);
837 static int ov2722_g_frame_interval(struct v4l2_subdev *sd,
838 struct v4l2_subdev_frame_interval *interval)
840 struct ov2722_device *dev = to_ov2722_sensor(sd);
842 interval->interval.numerator = 1;
843 interval->interval.denominator = dev->res->fps;
848 static int ov2722_enum_mbus_code(struct v4l2_subdev *sd,
849 struct v4l2_subdev_state *sd_state,
850 struct v4l2_subdev_mbus_code_enum *code)
852 if (code->index >= MAX_FMTS)
855 code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
859 static int ov2722_enum_frame_size(struct v4l2_subdev *sd,
860 struct v4l2_subdev_state *sd_state,
861 struct v4l2_subdev_frame_size_enum *fse)
863 int index = fse->index;
868 fse->min_width = ov2722_res[index].width;
869 fse->min_height = ov2722_res[index].height;
870 fse->max_width = ov2722_res[index].width;
871 fse->max_height = ov2722_res[index].height;
876 static int ov2722_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
878 struct ov2722_device *dev = to_ov2722_sensor(sd);
880 mutex_lock(&dev->input_lock);
881 *frames = dev->res->skip_frames;
882 mutex_unlock(&dev->input_lock);
887 static const struct v4l2_subdev_sensor_ops ov2722_sensor_ops = {
888 .g_skip_frames = ov2722_g_skip_frames,
891 static const struct v4l2_subdev_video_ops ov2722_video_ops = {
892 .s_stream = ov2722_s_stream,
893 .g_frame_interval = ov2722_g_frame_interval,
896 static const struct v4l2_subdev_core_ops ov2722_core_ops = {
897 .s_power = ov2722_s_power,
898 .ioctl = ov2722_ioctl,
901 static const struct v4l2_subdev_pad_ops ov2722_pad_ops = {
902 .enum_mbus_code = ov2722_enum_mbus_code,
903 .enum_frame_size = ov2722_enum_frame_size,
904 .get_fmt = ov2722_get_fmt,
905 .set_fmt = ov2722_set_fmt,
908 static const struct v4l2_subdev_ops ov2722_ops = {
909 .core = &ov2722_core_ops,
910 .video = &ov2722_video_ops,
911 .pad = &ov2722_pad_ops,
912 .sensor = &ov2722_sensor_ops,
915 static void ov2722_remove(struct i2c_client *client)
917 struct v4l2_subdev *sd = i2c_get_clientdata(client);
918 struct ov2722_device *dev = to_ov2722_sensor(sd);
920 dev->platform_data->csi_cfg(sd, 0);
921 v4l2_ctrl_handler_free(&dev->ctrl_handler);
922 v4l2_device_unregister_subdev(sd);
924 atomisp_gmin_remove_subdev(sd);
926 media_entity_cleanup(&dev->sd.entity);
930 static int __ov2722_init_ctrl_handler(struct ov2722_device *dev)
932 struct v4l2_ctrl_handler *hdl;
935 hdl = &dev->ctrl_handler;
936 v4l2_ctrl_handler_init(&dev->ctrl_handler, ARRAY_SIZE(ov2722_controls));
937 for (i = 0; i < ARRAY_SIZE(ov2722_controls); i++)
938 v4l2_ctrl_new_custom(&dev->ctrl_handler, &ov2722_controls[i],
941 dev->link_freq = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_LINK_FREQ);
943 if (dev->ctrl_handler.error || !dev->link_freq)
944 return dev->ctrl_handler.error;
946 dev->sd.ctrl_handler = hdl;
951 static int ov2722_probe(struct i2c_client *client)
953 struct ov2722_device *dev;
957 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
961 mutex_init(&dev->input_lock);
963 dev->res = &ov2722_res_preview[0];
964 v4l2_i2c_subdev_init(&dev->sd, client, &ov2722_ops);
966 ovpdev = gmin_camera_platform_data(&dev->sd,
967 ATOMISP_INPUT_FORMAT_RAW_10,
968 atomisp_bayer_order_grbg);
970 ret = ov2722_s_config(&dev->sd, client->irq, ovpdev);
974 ret = __ov2722_init_ctrl_handler(dev);
976 goto out_ctrl_handler_free;
978 dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
979 dev->pad.flags = MEDIA_PAD_FL_SOURCE;
980 dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
981 dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
983 ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
985 ov2722_remove(client);
987 return atomisp_register_i2c_module(&dev->sd, ovpdev, RAW_CAMERA);
989 out_ctrl_handler_free:
990 v4l2_ctrl_handler_free(&dev->ctrl_handler);
993 atomisp_gmin_remove_subdev(&dev->sd);
994 v4l2_device_unregister_subdev(&dev->sd);
999 static const struct acpi_device_id ov2722_acpi_match[] = {
1003 MODULE_DEVICE_TABLE(acpi, ov2722_acpi_match);
1005 static struct i2c_driver ov2722_driver = {
1008 .acpi_match_table = ov2722_acpi_match,
1010 .probe_new = ov2722_probe,
1011 .remove = ov2722_remove,
1013 module_i2c_driver(ov2722_driver);
1015 MODULE_AUTHOR("Wei Liu <wei.liu@intel.com>");
1016 MODULE_DESCRIPTION("A low-level driver for OmniVision 2722 sensors");
1017 MODULE_LICENSE("GPL");