2 * Driver for SiliconFile NOON010PC30 CIF (1/11") Image Sensor with ISP
4 * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd.
5 * Contact: Sylwester Nawrocki, <s.nawrocki@samsung.com>
7 * Initial register configuration based on a driver authored by
8 * HeungJun Kim <riverful.kim@samsung.com>.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
16 #include <linux/delay.h>
17 #include <linux/gpio.h>
18 #include <linux/i2c.h>
19 #include <linux/slab.h>
20 #include <linux/regulator/consumer.h>
21 #include <media/noon010pc30.h>
22 #include <media/v4l2-chip-ident.h>
23 #include <linux/videodev2.h>
24 #include <media/v4l2-ctrls.h>
25 #include <media/v4l2-device.h>
26 #include <media/v4l2-mediabus.h>
27 #include <media/v4l2-subdev.h>
30 module_param(debug, int, 0644);
31 MODULE_PARM_DESC(debug, "Enable module debug trace. Set to 1 to enable.");
33 #define MODULE_NAME "NOON010PC30"
36 * Register offsets within a page
37 * b15..b8 - page id, b7..b0 - register address
39 #define POWER_CTRL_REG 0x0001
40 #define PAGEMODE_REG 0x03
41 #define DEVICE_ID_REG 0x0004
42 #define NOON010PC30_ID 0x86
43 #define VDO_CTL_REG(n) (0x0010 + (n))
44 #define SYNC_CTL_REG 0x0012
45 /* Window size and position */
46 #define WIN_ROWH_REG 0x0013
47 #define WIN_ROWL_REG 0x0014
48 #define WIN_COLH_REG 0x0015
49 #define WIN_COLL_REG 0x0016
50 #define WIN_HEIGHTH_REG 0x0017
51 #define WIN_HEIGHTL_REG 0x0018
52 #define WIN_WIDTHH_REG 0x0019
53 #define WIN_WIDTHL_REG 0x001A
54 #define HBLANKH_REG 0x001B
55 #define HBLANKL_REG 0x001C
56 #define VSYNCH_REG 0x001D
57 #define VSYNCL_REG 0x001E
59 #define VS_CTL_REG(n) (0x00A1 + (n))
61 #define ISP_CTL_REG(n) (0x0110 + (n))
62 #define YOFS_REG 0x0119
63 #define DARK_YOFS_REG 0x011A
64 #define SAT_CTL_REG 0x0120
65 #define BSAT_REG 0x0121
66 #define RSAT_REG 0x0122
67 /* Color correction */
68 #define CMC_CTL_REG 0x0130
69 #define CMC_OFSGH_REG 0x0133
70 #define CMC_OFSGL_REG 0x0135
71 #define CMC_SIGN_REG 0x0136
72 #define CMC_GOFS_REG 0x0137
73 #define CMC_COEF_REG(n) (0x0138 + (n))
74 #define CMC_OFS_REG(n) (0x0141 + (n))
75 /* Gamma correction */
76 #define GMA_CTL_REG 0x0160
77 #define GMA_COEF_REG(n) (0x0161 + (n))
79 #define LENS_CTRL_REG 0x01D0
80 #define LENS_XCEN_REG 0x01D1
81 #define LENS_YCEN_REG 0x01D2
82 #define LENS_RC_REG 0x01D3
83 #define LENS_GC_REG 0x01D4
84 #define LENS_BC_REG 0x01D5
85 #define L_AGON_REG 0x01D6
86 #define L_AGOFF_REG 0x01D7
87 /* Page 3 - Auto Exposure */
88 #define AE_CTL_REG(n) (0x0310 + (n))
89 #define AE_CTL9_REG 0x032C
90 #define AE_CTL10_REG 0x032D
91 #define AE_YLVL_REG 0x031C
92 #define AE_YTH_REG(n) (0x031D + (n))
93 #define AE_WGT_REG 0x0326
94 #define EXP_TIMEH_REG 0x0333
95 #define EXP_TIMEM_REG 0x0334
96 #define EXP_TIMEL_REG 0x0335
97 #define EXP_MMINH_REG 0x0336
98 #define EXP_MMINL_REG 0x0337
99 #define EXP_MMAXH_REG 0x0338
100 #define EXP_MMAXM_REG 0x0339
101 #define EXP_MMAXL_REG 0x033A
102 /* Page 4 - Auto White Balance */
103 #define AWB_CTL_REG(n) (0x0410 + (n))
104 #define AWB_ENABE 0x80
105 #define AWB_WGHT_REG 0x0419
106 #define BGAIN_PAR_REG(n) (0x044F + (n))
107 /* Manual white balance, when AWB_CTL2[0]=1 */
108 #define MWB_RGAIN_REG 0x0466
109 #define MWB_BGAIN_REG 0x0467
111 /* The token to mark an array end */
112 #define REG_TERM 0xFFFF
114 struct noon010_format {
115 enum v4l2_mbus_pixelcode code;
116 enum v4l2_colorspace colorspace;
120 struct noon010_frmsize {
126 static const char * const noon010_supply_name[] = {
127 "vdd_core", "vddio", "vdda"
130 #define NOON010_NUM_SUPPLIES ARRAY_SIZE(noon010_supply_name)
132 struct noon010_info {
133 struct v4l2_subdev sd;
134 struct media_pad pad;
135 struct v4l2_ctrl_handler hdl;
136 struct regulator_bulk_data supply[NOON010_NUM_SUPPLIES];
140 /* Protects the struct members below */
143 const struct noon010_format *curr_fmt;
144 const struct noon010_frmsize *curr_win;
145 unsigned int apply_new_cfg:1;
146 unsigned int streaming:1;
147 unsigned int hflip:1;
148 unsigned int vflip:1;
149 unsigned int power:1;
158 /* Supported resolutions. */
159 static const struct noon010_frmsize noon010_sizes[] = {
175 /* Supported pixel formats. */
176 static const struct noon010_format noon010_formats[] = {
178 .code = V4L2_MBUS_FMT_YUYV8_2X8,
179 .colorspace = V4L2_COLORSPACE_JPEG,
182 .code = V4L2_MBUS_FMT_YVYU8_2X8,
183 .colorspace = V4L2_COLORSPACE_JPEG,
186 .code = V4L2_MBUS_FMT_VYUY8_2X8,
187 .colorspace = V4L2_COLORSPACE_JPEG,
190 .code = V4L2_MBUS_FMT_UYVY8_2X8,
191 .colorspace = V4L2_COLORSPACE_JPEG,
194 .code = V4L2_MBUS_FMT_RGB565_2X8_BE,
195 .colorspace = V4L2_COLORSPACE_JPEG,
200 static const struct i2c_regval noon010_base_regs[] = {
201 { WIN_COLL_REG, 0x06 }, { HBLANKL_REG, 0x7C },
202 /* Color corection and saturation */
203 { ISP_CTL_REG(0), 0x30 }, { ISP_CTL_REG(2), 0x30 },
204 { YOFS_REG, 0x80 }, { DARK_YOFS_REG, 0x04 },
205 { SAT_CTL_REG, 0x1F }, { BSAT_REG, 0x90 },
206 { CMC_CTL_REG, 0x0F }, { CMC_OFSGH_REG, 0x3C },
207 { CMC_OFSGL_REG, 0x2C }, { CMC_SIGN_REG, 0x3F },
208 { CMC_COEF_REG(0), 0x79 }, { CMC_OFS_REG(0), 0x00 },
209 { CMC_COEF_REG(1), 0x39 }, { CMC_OFS_REG(1), 0x00 },
210 { CMC_COEF_REG(2), 0x00 }, { CMC_OFS_REG(2), 0x00 },
211 { CMC_COEF_REG(3), 0x11 }, { CMC_OFS_REG(3), 0x8B },
212 { CMC_COEF_REG(4), 0x65 }, { CMC_OFS_REG(4), 0x07 },
213 { CMC_COEF_REG(5), 0x14 }, { CMC_OFS_REG(5), 0x04 },
214 { CMC_COEF_REG(6), 0x01 }, { CMC_OFS_REG(6), 0x9C },
215 { CMC_COEF_REG(7), 0x33 }, { CMC_OFS_REG(7), 0x89 },
216 { CMC_COEF_REG(8), 0x74 }, { CMC_OFS_REG(8), 0x25 },
217 /* Automatic white balance */
218 { AWB_CTL_REG(0), 0x78 }, { AWB_CTL_REG(1), 0x2E },
219 { AWB_CTL_REG(2), 0x20 }, { AWB_CTL_REG(3), 0x85 },
221 { AE_CTL_REG(0), 0xDC }, { AE_CTL_REG(1), 0x81 },
222 { AE_CTL_REG(2), 0x30 }, { AE_CTL_REG(3), 0xA5 },
223 { AE_CTL_REG(4), 0x40 }, { AE_CTL_REG(5), 0x51 },
224 { AE_CTL_REG(6), 0x33 }, { AE_CTL_REG(7), 0x7E },
225 { AE_CTL9_REG, 0x00 }, { AE_CTL10_REG, 0x02 },
226 { AE_YLVL_REG, 0x44 }, { AE_YTH_REG(0), 0x34 },
227 { AE_YTH_REG(1), 0x30 }, { AE_WGT_REG, 0xD5 },
228 /* Lens shading compensation */
229 { LENS_CTRL_REG, 0x01 }, { LENS_XCEN_REG, 0x80 },
230 { LENS_YCEN_REG, 0x70 }, { LENS_RC_REG, 0x53 },
231 { LENS_GC_REG, 0x40 }, { LENS_BC_REG, 0x3E },
235 static inline struct noon010_info *to_noon010(struct v4l2_subdev *sd)
237 return container_of(sd, struct noon010_info, sd);
240 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
242 return &container_of(ctrl->handler, struct noon010_info, hdl)->sd;
245 static inline int set_i2c_page(struct noon010_info *info,
246 struct i2c_client *client, unsigned int reg)
248 u32 page = reg >> 8 & 0xFF;
251 if (info->i2c_reg_page != page && (reg & 0xFF) != 0x03) {
252 ret = i2c_smbus_write_byte_data(client, PAGEMODE_REG, page);
254 info->i2c_reg_page = page;
259 static int cam_i2c_read(struct v4l2_subdev *sd, u32 reg_addr)
261 struct i2c_client *client = v4l2_get_subdevdata(sd);
262 struct noon010_info *info = to_noon010(sd);
263 int ret = set_i2c_page(info, client, reg_addr);
267 return i2c_smbus_read_byte_data(client, reg_addr & 0xFF);
270 static int cam_i2c_write(struct v4l2_subdev *sd, u32 reg_addr, u32 val)
272 struct i2c_client *client = v4l2_get_subdevdata(sd);
273 struct noon010_info *info = to_noon010(sd);
274 int ret = set_i2c_page(info, client, reg_addr);
278 return i2c_smbus_write_byte_data(client, reg_addr & 0xFF, val);
281 static inline int noon010_bulk_write_reg(struct v4l2_subdev *sd,
282 const struct i2c_regval *msg)
284 while (msg->addr != REG_TERM) {
285 int ret = cam_i2c_write(sd, msg->addr, msg->val);
294 /* Device reset and sleep mode control */
295 static int noon010_power_ctrl(struct v4l2_subdev *sd, bool reset, bool sleep)
297 struct noon010_info *info = to_noon010(sd);
298 u8 reg = sleep ? 0xF1 : 0xF0;
302 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg | 0x02);
306 ret = cam_i2c_write(sd, POWER_CTRL_REG, reg);
308 info->i2c_reg_page = -1;
313 /* Automatic white balance control */
314 static int noon010_enable_autowhitebalance(struct v4l2_subdev *sd, int on)
318 ret = cam_i2c_write(sd, AWB_CTL_REG(1), on ? 0x2E : 0x2F);
320 ret = cam_i2c_write(sd, AWB_CTL_REG(0), on ? 0xFB : 0x7B);
324 /* Called with struct noon010_info.lock mutex held */
325 static int noon010_set_flip(struct v4l2_subdev *sd, int hflip, int vflip)
327 struct noon010_info *info = to_noon010(sd);
330 reg = cam_i2c_read(sd, VDO_CTL_REG(1));
340 ret = cam_i2c_write(sd, VDO_CTL_REG(1), reg | 0x80);
348 /* Configure resolution and color format */
349 static int noon010_set_params(struct v4l2_subdev *sd)
351 struct noon010_info *info = to_noon010(sd);
353 int ret = cam_i2c_write(sd, VDO_CTL_REG(0),
354 info->curr_win->vid_ctl1);
357 return cam_i2c_write(sd, ISP_CTL_REG(0),
358 info->curr_fmt->ispctl1_reg);
361 /* Find nearest matching image pixel size. */
362 static int noon010_try_frame_size(struct v4l2_mbus_framefmt *mf,
363 const struct noon010_frmsize **size)
365 unsigned int min_err = ~0;
366 int i = ARRAY_SIZE(noon010_sizes);
367 const struct noon010_frmsize *fsize = &noon010_sizes[0],
371 int err = abs(fsize->width - mf->width)
372 + abs(fsize->height - mf->height);
381 mf->width = match->width;
382 mf->height = match->height;
390 /* Called with info.lock mutex held */
391 static int power_enable(struct noon010_info *info)
396 v4l2_info(&info->sd, "%s: sensor is already on\n", __func__);
400 if (gpio_is_valid(info->gpio_nstby))
401 gpio_set_value(info->gpio_nstby, 0);
403 if (gpio_is_valid(info->gpio_nreset))
404 gpio_set_value(info->gpio_nreset, 0);
406 ret = regulator_bulk_enable(NOON010_NUM_SUPPLIES, info->supply);
410 if (gpio_is_valid(info->gpio_nreset)) {
412 gpio_set_value(info->gpio_nreset, 1);
414 if (gpio_is_valid(info->gpio_nstby)) {
416 gpio_set_value(info->gpio_nstby, 1);
418 if (gpio_is_valid(info->gpio_nreset)) {
420 gpio_set_value(info->gpio_nreset, 0);
422 gpio_set_value(info->gpio_nreset, 1);
427 v4l2_dbg(1, debug, &info->sd, "%s: sensor is on\n", __func__);
431 /* Called with info.lock mutex held */
432 static int power_disable(struct noon010_info *info)
437 v4l2_info(&info->sd, "%s: sensor is already off\n", __func__);
441 ret = regulator_bulk_disable(NOON010_NUM_SUPPLIES, info->supply);
445 if (gpio_is_valid(info->gpio_nstby))
446 gpio_set_value(info->gpio_nstby, 0);
448 if (gpio_is_valid(info->gpio_nreset))
449 gpio_set_value(info->gpio_nreset, 0);
453 v4l2_dbg(1, debug, &info->sd, "%s: sensor is off\n", __func__);
458 static int noon010_s_ctrl(struct v4l2_ctrl *ctrl)
460 struct v4l2_subdev *sd = to_sd(ctrl);
461 struct noon010_info *info = to_noon010(sd);
464 v4l2_dbg(1, debug, sd, "%s: ctrl_id: %d, value: %d\n",
465 __func__, ctrl->id, ctrl->val);
467 mutex_lock(&info->lock);
469 * If the device is not powered up by the host driver do
470 * not apply any controls to H/W at this time. Instead
471 * the controls will be restored right after power-up.
477 case V4L2_CID_AUTO_WHITE_BALANCE:
478 ret = noon010_enable_autowhitebalance(sd, ctrl->val);
480 case V4L2_CID_BLUE_BALANCE:
481 ret = cam_i2c_write(sd, MWB_BGAIN_REG, ctrl->val);
483 case V4L2_CID_RED_BALANCE:
484 ret = cam_i2c_write(sd, MWB_RGAIN_REG, ctrl->val);
490 mutex_unlock(&info->lock);
494 static int noon010_enum_mbus_code(struct v4l2_subdev *sd,
495 struct v4l2_subdev_fh *fh,
496 struct v4l2_subdev_mbus_code_enum *code)
498 if (code->index >= ARRAY_SIZE(noon010_formats))
501 code->code = noon010_formats[code->index].code;
505 static int noon010_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
506 struct v4l2_subdev_format *fmt)
508 struct noon010_info *info = to_noon010(sd);
509 struct v4l2_mbus_framefmt *mf;
511 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
513 mf = v4l2_subdev_get_try_format(fh, 0);
520 mutex_lock(&info->lock);
521 mf->width = info->curr_win->width;
522 mf->height = info->curr_win->height;
523 mf->code = info->curr_fmt->code;
524 mf->colorspace = info->curr_fmt->colorspace;
525 mf->field = V4L2_FIELD_NONE;
527 mutex_unlock(&info->lock);
531 /* Return nearest media bus frame format. */
532 static const struct noon010_format *noon010_try_fmt(struct v4l2_subdev *sd,
533 struct v4l2_mbus_framefmt *mf)
535 int i = ARRAY_SIZE(noon010_formats);
538 if (mf->code == noon010_formats[i].code)
540 mf->code = noon010_formats[i].code;
542 return &noon010_formats[i];
545 static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
546 struct v4l2_subdev_format *fmt)
548 struct noon010_info *info = to_noon010(sd);
549 const struct noon010_frmsize *size = NULL;
550 const struct noon010_format *nf;
551 struct v4l2_mbus_framefmt *mf;
554 nf = noon010_try_fmt(sd, &fmt->format);
555 noon010_try_frame_size(&fmt->format, &size);
556 fmt->format.colorspace = V4L2_COLORSPACE_JPEG;
558 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
560 mf = v4l2_subdev_get_try_format(fh, 0);
565 mutex_lock(&info->lock);
566 if (!info->streaming) {
567 info->apply_new_cfg = 1;
569 info->curr_win = size;
573 mutex_unlock(&info->lock);
577 /* Called with struct noon010_info.lock mutex held */
578 static int noon010_base_config(struct v4l2_subdev *sd)
580 int ret = noon010_bulk_write_reg(sd, noon010_base_regs);
582 ret = noon010_set_params(sd);
584 ret = noon010_set_flip(sd, 1, 0);
589 static int noon010_s_power(struct v4l2_subdev *sd, int on)
591 struct noon010_info *info = to_noon010(sd);
594 mutex_lock(&info->lock);
596 ret = power_enable(info);
598 ret = noon010_base_config(sd);
600 noon010_power_ctrl(sd, false, true);
601 ret = power_disable(info);
603 mutex_unlock(&info->lock);
605 /* Restore the controls state */
607 ret = v4l2_ctrl_handler_setup(&info->hdl);
612 static int noon010_s_stream(struct v4l2_subdev *sd, int on)
614 struct noon010_info *info = to_noon010(sd);
617 mutex_lock(&info->lock);
618 if (!info->streaming != !on) {
619 ret = noon010_power_ctrl(sd, false, !on);
621 info->streaming = on;
623 if (!ret && on && info->apply_new_cfg) {
624 ret = noon010_set_params(sd);
626 info->apply_new_cfg = 0;
628 mutex_unlock(&info->lock);
632 static int noon010_log_status(struct v4l2_subdev *sd)
634 struct noon010_info *info = to_noon010(sd);
636 v4l2_ctrl_handler_log_status(&info->hdl, sd->name);
640 static int noon010_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
642 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(fh, 0);
644 mf->width = noon010_sizes[0].width;
645 mf->height = noon010_sizes[0].height;
646 mf->code = noon010_formats[0].code;
647 mf->colorspace = V4L2_COLORSPACE_JPEG;
648 mf->field = V4L2_FIELD_NONE;
652 static const struct v4l2_subdev_internal_ops noon010_subdev_internal_ops = {
653 .open = noon010_open,
656 static const struct v4l2_ctrl_ops noon010_ctrl_ops = {
657 .s_ctrl = noon010_s_ctrl,
660 static const struct v4l2_subdev_core_ops noon010_core_ops = {
661 .s_power = noon010_s_power,
662 .g_ctrl = v4l2_subdev_g_ctrl,
663 .s_ctrl = v4l2_subdev_s_ctrl,
664 .queryctrl = v4l2_subdev_queryctrl,
665 .querymenu = v4l2_subdev_querymenu,
666 .g_ext_ctrls = v4l2_subdev_g_ext_ctrls,
667 .try_ext_ctrls = v4l2_subdev_try_ext_ctrls,
668 .s_ext_ctrls = v4l2_subdev_s_ext_ctrls,
669 .log_status = noon010_log_status,
672 static struct v4l2_subdev_pad_ops noon010_pad_ops = {
673 .enum_mbus_code = noon010_enum_mbus_code,
674 .get_fmt = noon010_get_fmt,
675 .set_fmt = noon010_set_fmt,
678 static struct v4l2_subdev_video_ops noon010_video_ops = {
679 .s_stream = noon010_s_stream,
682 static const struct v4l2_subdev_ops noon010_ops = {
683 .core = &noon010_core_ops,
684 .pad = &noon010_pad_ops,
685 .video = &noon010_video_ops,
688 /* Return 0 if NOON010PC30L sensor type was detected or -ENODEV otherwise. */
689 static int noon010_detect(struct i2c_client *client, struct noon010_info *info)
693 ret = power_enable(info);
697 ret = i2c_smbus_read_byte_data(client, DEVICE_ID_REG);
699 dev_err(&client->dev, "I2C read failed: 0x%X\n", ret);
703 return ret == NOON010PC30_ID ? 0 : -ENODEV;
706 static int noon010_probe(struct i2c_client *client,
707 const struct i2c_device_id *id)
709 struct noon010_info *info;
710 struct v4l2_subdev *sd;
711 const struct noon010pc30_platform_data *pdata
712 = client->dev.platform_data;
717 dev_err(&client->dev, "No platform data!\n");
721 info = kzalloc(sizeof(*info), GFP_KERNEL);
725 mutex_init(&info->lock);
727 strlcpy(sd->name, MODULE_NAME, sizeof(sd->name));
728 v4l2_i2c_subdev_init(sd, client, &noon010_ops);
730 sd->internal_ops = &noon010_subdev_internal_ops;
731 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
733 v4l2_ctrl_handler_init(&info->hdl, 3);
735 v4l2_ctrl_new_std(&info->hdl, &noon010_ctrl_ops,
736 V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1);
737 v4l2_ctrl_new_std(&info->hdl, &noon010_ctrl_ops,
738 V4L2_CID_RED_BALANCE, 0, 127, 1, 64);
739 v4l2_ctrl_new_std(&info->hdl, &noon010_ctrl_ops,
740 V4L2_CID_BLUE_BALANCE, 0, 127, 1, 64);
742 sd->ctrl_handler = &info->hdl;
744 ret = info->hdl.error;
748 info->i2c_reg_page = -1;
749 info->gpio_nreset = -EINVAL;
750 info->gpio_nstby = -EINVAL;
751 info->curr_fmt = &noon010_formats[0];
752 info->curr_win = &noon010_sizes[0];
754 if (gpio_is_valid(pdata->gpio_nreset)) {
755 ret = gpio_request(pdata->gpio_nreset, "NOON010PC30 NRST");
757 dev_err(&client->dev, "GPIO request error: %d\n", ret);
760 info->gpio_nreset = pdata->gpio_nreset;
761 gpio_direction_output(info->gpio_nreset, 0);
762 gpio_export(info->gpio_nreset, 0);
765 if (gpio_is_valid(pdata->gpio_nstby)) {
766 ret = gpio_request(pdata->gpio_nstby, "NOON010PC30 NSTBY");
768 dev_err(&client->dev, "GPIO request error: %d\n", ret);
771 info->gpio_nstby = pdata->gpio_nstby;
772 gpio_direction_output(info->gpio_nstby, 0);
773 gpio_export(info->gpio_nstby, 0);
776 for (i = 0; i < NOON010_NUM_SUPPLIES; i++)
777 info->supply[i].supply = noon010_supply_name[i];
779 ret = regulator_bulk_get(&client->dev, NOON010_NUM_SUPPLIES,
784 info->pad.flags = MEDIA_PAD_FL_SOURCE;
785 sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
786 ret = media_entity_init(&sd->entity, 1, &info->pad, 0);
790 ret = noon010_detect(client, info);
795 regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply);
797 if (gpio_is_valid(info->gpio_nstby))
798 gpio_free(info->gpio_nstby);
800 if (gpio_is_valid(info->gpio_nreset))
801 gpio_free(info->gpio_nreset);
803 v4l2_ctrl_handler_free(&info->hdl);
804 v4l2_device_unregister_subdev(sd);
809 static int noon010_remove(struct i2c_client *client)
811 struct v4l2_subdev *sd = i2c_get_clientdata(client);
812 struct noon010_info *info = to_noon010(sd);
814 v4l2_device_unregister_subdev(sd);
815 v4l2_ctrl_handler_free(&info->hdl);
817 regulator_bulk_free(NOON010_NUM_SUPPLIES, info->supply);
819 if (gpio_is_valid(info->gpio_nreset))
820 gpio_free(info->gpio_nreset);
822 if (gpio_is_valid(info->gpio_nstby))
823 gpio_free(info->gpio_nstby);
825 media_entity_cleanup(&sd->entity);
830 static const struct i2c_device_id noon010_id[] = {
834 MODULE_DEVICE_TABLE(i2c, noon010_id);
837 static struct i2c_driver noon010_i2c_driver = {
841 .probe = noon010_probe,
842 .remove = noon010_remove,
843 .id_table = noon010_id,
846 static int __init noon010_init(void)
848 return i2c_add_driver(&noon010_i2c_driver);
851 static void __exit noon010_exit(void)
853 i2c_del_driver(&noon010_i2c_driver);
856 module_init(noon010_init);
857 module_exit(noon010_exit);
859 MODULE_DESCRIPTION("Siliconfile NOON010PC30 camera driver");
860 MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
861 MODULE_LICENSE("GPL");