Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / drivers / media / video / soc_camera.c
blob5bdfe7e16bc13e26c3bced5a7289d2ad50819f4d
1 /*
2 * camera image capture (abstract) bus driver
4 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
6 * This driver provides an interface between platform-specific camera
7 * busses and camera devices. It should be used if the camera is
8 * connected not over a "proper" bus like PCI or USB, but over a
9 * special bus, like, for example, the Quick Capture interface on PXA270
10 * SoCs. Later it should also be used for i.MX31 SoCs from Freescale.
11 * It can handle multiple cameras and / or multiple busses, which can
12 * be used, e.g., in stereo-vision applications.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
19 #include <linux/device.h>
20 #include <linux/err.h>
21 #include <linux/i2c.h>
22 #include <linux/init.h>
23 #include <linux/list.h>
24 #include <linux/mutex.h>
25 #include <linux/module.h>
26 #include <linux/platform_device.h>
27 #include <linux/regulator/consumer.h>
28 #include <linux/slab.h>
29 #include <linux/pm_runtime.h>
30 #include <linux/vmalloc.h>
32 #include <media/soc_camera.h>
33 #include <media/v4l2-common.h>
34 #include <media/v4l2-ioctl.h>
35 #include <media/v4l2-dev.h>
36 #include <media/videobuf-core.h>
37 #include <media/videobuf2-core.h>
38 #include <media/soc_mediabus.h>
40 /* Default to VGA resolution */
41 #define DEFAULT_WIDTH 640
42 #define DEFAULT_HEIGHT 480
44 #define is_streaming(ici, icd) \
45 (((ici)->ops->init_videobuf) ? \
46 (icd)->vb_vidq.streaming : \
47 vb2_is_streaming(&(icd)->vb2_vidq))
49 static LIST_HEAD(hosts);
50 static LIST_HEAD(devices);
51 static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */
53 static int soc_camera_power_set(struct soc_camera_device *icd,
54 struct soc_camera_link *icl,
55 int power_on)
57 int ret;
59 if (power_on) {
60 ret = regulator_bulk_enable(icl->num_regulators,
61 icl->regulators);
62 if (ret < 0) {
63 dev_err(icd->pdev, "Cannot enable regulators\n");
64 return ret;
67 if (icl->power)
68 ret = icl->power(icd->pdev, power_on);
69 if (ret < 0) {
70 dev_err(icd->pdev,
71 "Platform failed to power-on the camera.\n");
73 regulator_bulk_disable(icl->num_regulators,
74 icl->regulators);
75 return ret;
77 } else {
78 ret = 0;
79 if (icl->power)
80 ret = icl->power(icd->pdev, 0);
81 if (ret < 0) {
82 dev_err(icd->pdev,
83 "Platform failed to power-off the camera.\n");
84 return ret;
87 ret = regulator_bulk_disable(icl->num_regulators,
88 icl->regulators);
89 if (ret < 0) {
90 dev_err(icd->pdev, "Cannot disable regulators\n");
91 return ret;
95 return 0;
98 const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
99 struct soc_camera_device *icd, unsigned int fourcc)
101 unsigned int i;
103 for (i = 0; i < icd->num_user_formats; i++)
104 if (icd->user_formats[i].host_fmt->fourcc == fourcc)
105 return icd->user_formats + i;
106 return NULL;
108 EXPORT_SYMBOL(soc_camera_xlate_by_fourcc);
111 * soc_camera_apply_sensor_flags() - apply platform SOCAM_SENSOR_INVERT_* flags
112 * @icl: camera platform parameters
113 * @flags: flags to be inverted according to platform configuration
114 * @return: resulting flags
116 unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
117 unsigned long flags)
119 unsigned long f;
121 /* If only one of the two polarities is supported, switch to the opposite */
122 if (icl->flags & SOCAM_SENSOR_INVERT_HSYNC) {
123 f = flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW);
124 if (f == SOCAM_HSYNC_ACTIVE_HIGH || f == SOCAM_HSYNC_ACTIVE_LOW)
125 flags ^= SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW;
128 if (icl->flags & SOCAM_SENSOR_INVERT_VSYNC) {
129 f = flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW);
130 if (f == SOCAM_VSYNC_ACTIVE_HIGH || f == SOCAM_VSYNC_ACTIVE_LOW)
131 flags ^= SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW;
134 if (icl->flags & SOCAM_SENSOR_INVERT_PCLK) {
135 f = flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING);
136 if (f == SOCAM_PCLK_SAMPLE_RISING || f == SOCAM_PCLK_SAMPLE_FALLING)
137 flags ^= SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING;
140 return flags;
142 EXPORT_SYMBOL(soc_camera_apply_sensor_flags);
144 #define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
145 ((x) >> 24) & 0xff
147 static int soc_camera_try_fmt(struct soc_camera_device *icd,
148 struct v4l2_format *f)
150 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
151 struct v4l2_pix_format *pix = &f->fmt.pix;
152 int ret;
154 dev_dbg(icd->pdev, "TRY_FMT(%c%c%c%c, %ux%u)\n",
155 pixfmtstr(pix->pixelformat), pix->width, pix->height);
157 pix->bytesperline = 0;
158 pix->sizeimage = 0;
160 ret = ici->ops->try_fmt(icd, f);
161 if (ret < 0)
162 return ret;
164 if (!pix->sizeimage) {
165 if (!pix->bytesperline) {
166 const struct soc_camera_format_xlate *xlate;
168 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
169 if (!xlate)
170 return -EINVAL;
172 ret = soc_mbus_bytes_per_line(pix->width,
173 xlate->host_fmt);
174 if (ret > 0)
175 pix->bytesperline = ret;
177 if (pix->bytesperline)
178 pix->sizeimage = pix->bytesperline * pix->height;
181 return 0;
184 static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
185 struct v4l2_format *f)
187 struct soc_camera_device *icd = file->private_data;
189 WARN_ON(priv != file->private_data);
191 /* Only single-plane capture is supported so far */
192 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
193 return -EINVAL;
195 /* limit format to hardware capabilities */
196 return soc_camera_try_fmt(icd, f);
199 static int soc_camera_enum_input(struct file *file, void *priv,
200 struct v4l2_input *inp)
202 if (inp->index != 0)
203 return -EINVAL;
205 /* default is camera */
206 inp->type = V4L2_INPUT_TYPE_CAMERA;
207 inp->std = V4L2_STD_UNKNOWN;
208 strcpy(inp->name, "Camera");
210 return 0;
213 static int soc_camera_g_input(struct file *file, void *priv, unsigned int *i)
215 *i = 0;
217 return 0;
220 static int soc_camera_s_input(struct file *file, void *priv, unsigned int i)
222 if (i > 0)
223 return -EINVAL;
225 return 0;
228 static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a)
230 struct soc_camera_device *icd = file->private_data;
231 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
233 return v4l2_subdev_call(sd, core, s_std, *a);
236 static int soc_camera_enum_fsizes(struct file *file, void *fh,
237 struct v4l2_frmsizeenum *fsize)
239 struct soc_camera_device *icd = file->private_data;
240 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
242 return ici->ops->enum_fsizes(icd, fsize);
245 static int soc_camera_reqbufs(struct file *file, void *priv,
246 struct v4l2_requestbuffers *p)
248 int ret;
249 struct soc_camera_device *icd = file->private_data;
250 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
252 WARN_ON(priv != file->private_data);
254 if (icd->streamer && icd->streamer != file)
255 return -EBUSY;
257 if (ici->ops->init_videobuf) {
258 ret = videobuf_reqbufs(&icd->vb_vidq, p);
259 if (ret < 0)
260 return ret;
262 ret = ici->ops->reqbufs(icd, p);
263 } else {
264 ret = vb2_reqbufs(&icd->vb2_vidq, p);
267 if (!ret && !icd->streamer)
268 icd->streamer = file;
270 return ret;
273 static int soc_camera_querybuf(struct file *file, void *priv,
274 struct v4l2_buffer *p)
276 struct soc_camera_device *icd = file->private_data;
277 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
279 WARN_ON(priv != file->private_data);
281 if (ici->ops->init_videobuf)
282 return videobuf_querybuf(&icd->vb_vidq, p);
283 else
284 return vb2_querybuf(&icd->vb2_vidq, p);
287 static int soc_camera_qbuf(struct file *file, void *priv,
288 struct v4l2_buffer *p)
290 struct soc_camera_device *icd = file->private_data;
291 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
293 WARN_ON(priv != file->private_data);
295 if (icd->streamer != file)
296 return -EBUSY;
298 if (ici->ops->init_videobuf)
299 return videobuf_qbuf(&icd->vb_vidq, p);
300 else
301 return vb2_qbuf(&icd->vb2_vidq, p);
304 static int soc_camera_dqbuf(struct file *file, void *priv,
305 struct v4l2_buffer *p)
307 struct soc_camera_device *icd = file->private_data;
308 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
310 WARN_ON(priv != file->private_data);
312 if (icd->streamer != file)
313 return -EBUSY;
315 if (ici->ops->init_videobuf)
316 return videobuf_dqbuf(&icd->vb_vidq, p, file->f_flags & O_NONBLOCK);
317 else
318 return vb2_dqbuf(&icd->vb2_vidq, p, file->f_flags & O_NONBLOCK);
321 /* Always entered with .video_lock held */
322 static int soc_camera_init_user_formats(struct soc_camera_device *icd)
324 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
325 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
326 unsigned int i, fmts = 0, raw_fmts = 0;
327 int ret;
328 enum v4l2_mbus_pixelcode code;
330 while (!v4l2_subdev_call(sd, video, enum_mbus_fmt, raw_fmts, &code))
331 raw_fmts++;
333 if (!ici->ops->get_formats)
335 * Fallback mode - the host will have to serve all
336 * sensor-provided formats one-to-one to the user
338 fmts = raw_fmts;
339 else
341 * First pass - only count formats this host-sensor
342 * configuration can provide
344 for (i = 0; i < raw_fmts; i++) {
345 ret = ici->ops->get_formats(icd, i, NULL);
346 if (ret < 0)
347 return ret;
348 fmts += ret;
351 if (!fmts)
352 return -ENXIO;
354 icd->user_formats =
355 vmalloc(fmts * sizeof(struct soc_camera_format_xlate));
356 if (!icd->user_formats)
357 return -ENOMEM;
359 dev_dbg(icd->pdev, "Found %d supported formats.\n", fmts);
361 /* Second pass - actually fill data formats */
362 fmts = 0;
363 for (i = 0; i < raw_fmts; i++)
364 if (!ici->ops->get_formats) {
365 v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code);
366 icd->user_formats[fmts].host_fmt =
367 soc_mbus_get_fmtdesc(code);
368 if (icd->user_formats[fmts].host_fmt)
369 icd->user_formats[fmts++].code = code;
370 } else {
371 ret = ici->ops->get_formats(icd, i,
372 &icd->user_formats[fmts]);
373 if (ret < 0)
374 goto egfmt;
375 fmts += ret;
378 icd->num_user_formats = fmts;
379 icd->current_fmt = &icd->user_formats[0];
381 return 0;
383 egfmt:
384 vfree(icd->user_formats);
385 return ret;
388 /* Always entered with .video_lock held */
389 static void soc_camera_free_user_formats(struct soc_camera_device *icd)
391 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
393 if (ici->ops->put_formats)
394 ici->ops->put_formats(icd);
395 icd->current_fmt = NULL;
396 icd->num_user_formats = 0;
397 vfree(icd->user_formats);
398 icd->user_formats = NULL;
401 /* Called with .vb_lock held, or from the first open(2), see comment there */
402 static int soc_camera_set_fmt(struct soc_camera_device *icd,
403 struct v4l2_format *f)
405 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
406 struct v4l2_pix_format *pix = &f->fmt.pix;
407 int ret;
409 dev_dbg(icd->pdev, "S_FMT(%c%c%c%c, %ux%u)\n",
410 pixfmtstr(pix->pixelformat), pix->width, pix->height);
412 /* We always call try_fmt() before set_fmt() or set_crop() */
413 ret = soc_camera_try_fmt(icd, f);
414 if (ret < 0)
415 return ret;
417 ret = ici->ops->set_fmt(icd, f);
418 if (ret < 0) {
419 return ret;
420 } else if (!icd->current_fmt ||
421 icd->current_fmt->host_fmt->fourcc != pix->pixelformat) {
422 dev_err(icd->pdev,
423 "Host driver hasn't set up current format correctly!\n");
424 return -EINVAL;
427 icd->user_width = pix->width;
428 icd->user_height = pix->height;
429 icd->bytesperline = pix->bytesperline;
430 icd->sizeimage = pix->sizeimage;
431 icd->colorspace = pix->colorspace;
432 icd->field = pix->field;
433 if (ici->ops->init_videobuf)
434 icd->vb_vidq.field = pix->field;
436 dev_dbg(icd->pdev, "set width: %d height: %d\n",
437 icd->user_width, icd->user_height);
439 /* set physical bus parameters */
440 return ici->ops->set_bus_param(icd, pix->pixelformat);
443 static int soc_camera_open(struct file *file)
445 struct video_device *vdev = video_devdata(file);
446 struct soc_camera_device *icd = dev_get_drvdata(vdev->parent);
447 struct soc_camera_link *icl = to_soc_camera_link(icd);
448 struct soc_camera_host *ici;
449 int ret;
451 if (!icd->ops)
452 /* No device driver attached */
453 return -ENODEV;
455 ici = to_soc_camera_host(icd->parent);
457 if (!try_module_get(ici->ops->owner)) {
458 dev_err(icd->pdev, "Couldn't lock capture bus driver.\n");
459 return -EINVAL;
462 icd->use_count++;
464 /* Now we really have to activate the camera */
465 if (icd->use_count == 1) {
466 /* Restore parameters before the last close() per V4L2 API */
467 struct v4l2_format f = {
468 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
469 .fmt.pix = {
470 .width = icd->user_width,
471 .height = icd->user_height,
472 .field = icd->field,
473 .colorspace = icd->colorspace,
474 .pixelformat =
475 icd->current_fmt->host_fmt->fourcc,
479 ret = soc_camera_power_set(icd, icl, 1);
480 if (ret < 0)
481 goto epower;
483 /* The camera could have been already on, try to reset */
484 if (icl->reset)
485 icl->reset(icd->pdev);
487 ret = ici->ops->add(icd);
488 if (ret < 0) {
489 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret);
490 goto eiciadd;
493 pm_runtime_enable(&icd->vdev->dev);
494 ret = pm_runtime_resume(&icd->vdev->dev);
495 if (ret < 0 && ret != -ENOSYS)
496 goto eresume;
499 * Try to configure with default parameters. Notice: this is the
500 * very first open, so, we cannot race against other calls,
501 * apart from someone else calling open() simultaneously, but
502 * .video_lock is protecting us against it.
504 ret = soc_camera_set_fmt(icd, &f);
505 if (ret < 0)
506 goto esfmt;
508 if (ici->ops->init_videobuf) {
509 ici->ops->init_videobuf(&icd->vb_vidq, icd);
510 } else {
511 ret = ici->ops->init_videobuf2(&icd->vb2_vidq, icd);
512 if (ret < 0)
513 goto einitvb;
517 file->private_data = icd;
518 dev_dbg(icd->pdev, "camera device open\n");
520 return 0;
523 * First four errors are entered with the .video_lock held
524 * and use_count == 1
526 einitvb:
527 esfmt:
528 pm_runtime_disable(&icd->vdev->dev);
529 eresume:
530 ici->ops->remove(icd);
531 eiciadd:
532 soc_camera_power_set(icd, icl, 0);
533 epower:
534 icd->use_count--;
535 module_put(ici->ops->owner);
537 return ret;
540 static int soc_camera_close(struct file *file)
542 struct soc_camera_device *icd = file->private_data;
543 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
545 icd->use_count--;
546 if (!icd->use_count) {
547 struct soc_camera_link *icl = to_soc_camera_link(icd);
549 pm_runtime_suspend(&icd->vdev->dev);
550 pm_runtime_disable(&icd->vdev->dev);
552 ici->ops->remove(icd);
553 if (ici->ops->init_videobuf2)
554 vb2_queue_release(&icd->vb2_vidq);
556 soc_camera_power_set(icd, icl, 0);
559 if (icd->streamer == file)
560 icd->streamer = NULL;
562 module_put(ici->ops->owner);
564 dev_dbg(icd->pdev, "camera device close\n");
566 return 0;
569 static ssize_t soc_camera_read(struct file *file, char __user *buf,
570 size_t count, loff_t *ppos)
572 struct soc_camera_device *icd = file->private_data;
573 int err = -EINVAL;
575 dev_err(icd->pdev, "camera device read not implemented\n");
577 return err;
580 static int soc_camera_mmap(struct file *file, struct vm_area_struct *vma)
582 struct soc_camera_device *icd = file->private_data;
583 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
584 int err;
586 dev_dbg(icd->pdev, "mmap called, vma=0x%08lx\n", (unsigned long)vma);
588 if (icd->streamer != file)
589 return -EBUSY;
591 if (ici->ops->init_videobuf)
592 err = videobuf_mmap_mapper(&icd->vb_vidq, vma);
593 else
594 err = vb2_mmap(&icd->vb2_vidq, vma);
596 dev_dbg(icd->pdev, "vma start=0x%08lx, size=%ld, ret=%d\n",
597 (unsigned long)vma->vm_start,
598 (unsigned long)vma->vm_end - (unsigned long)vma->vm_start,
599 err);
601 return err;
604 static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
606 struct soc_camera_device *icd = file->private_data;
607 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
609 if (icd->streamer != file)
610 return -EBUSY;
612 if (ici->ops->init_videobuf && list_empty(&icd->vb_vidq.stream)) {
613 dev_err(icd->pdev, "Trying to poll with no queued buffers!\n");
614 return POLLERR;
617 return ici->ops->poll(file, pt);
620 void soc_camera_lock(struct vb2_queue *vq)
622 struct soc_camera_device *icd = vb2_get_drv_priv(vq);
623 mutex_lock(&icd->video_lock);
625 EXPORT_SYMBOL(soc_camera_lock);
627 void soc_camera_unlock(struct vb2_queue *vq)
629 struct soc_camera_device *icd = vb2_get_drv_priv(vq);
630 mutex_unlock(&icd->video_lock);
632 EXPORT_SYMBOL(soc_camera_unlock);
634 static struct v4l2_file_operations soc_camera_fops = {
635 .owner = THIS_MODULE,
636 .open = soc_camera_open,
637 .release = soc_camera_close,
638 .unlocked_ioctl = video_ioctl2,
639 .read = soc_camera_read,
640 .mmap = soc_camera_mmap,
641 .poll = soc_camera_poll,
644 static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv,
645 struct v4l2_format *f)
647 struct soc_camera_device *icd = file->private_data;
648 int ret;
650 WARN_ON(priv != file->private_data);
652 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
653 dev_warn(icd->pdev, "Wrong buf-type %d\n", f->type);
654 return -EINVAL;
657 if (icd->streamer && icd->streamer != file)
658 return -EBUSY;
660 if (is_streaming(to_soc_camera_host(icd->parent), icd)) {
661 dev_err(icd->pdev, "S_FMT denied: queue initialised\n");
662 return -EBUSY;
665 ret = soc_camera_set_fmt(icd, f);
667 if (!ret && !icd->streamer)
668 icd->streamer = file;
670 return ret;
673 static int soc_camera_enum_fmt_vid_cap(struct file *file, void *priv,
674 struct v4l2_fmtdesc *f)
676 struct soc_camera_device *icd = file->private_data;
677 const struct soc_mbus_pixelfmt *format;
679 WARN_ON(priv != file->private_data);
681 if (f->index >= icd->num_user_formats)
682 return -EINVAL;
684 format = icd->user_formats[f->index].host_fmt;
686 if (format->name)
687 strlcpy(f->description, format->name, sizeof(f->description));
688 f->pixelformat = format->fourcc;
689 return 0;
692 static int soc_camera_g_fmt_vid_cap(struct file *file, void *priv,
693 struct v4l2_format *f)
695 struct soc_camera_device *icd = file->private_data;
696 struct v4l2_pix_format *pix = &f->fmt.pix;
698 WARN_ON(priv != file->private_data);
700 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
701 return -EINVAL;
703 pix->width = icd->user_width;
704 pix->height = icd->user_height;
705 pix->bytesperline = icd->bytesperline;
706 pix->sizeimage = icd->sizeimage;
707 pix->field = icd->field;
708 pix->pixelformat = icd->current_fmt->host_fmt->fourcc;
709 pix->colorspace = icd->colorspace;
710 dev_dbg(icd->pdev, "current_fmt->fourcc: 0x%08x\n",
711 icd->current_fmt->host_fmt->fourcc);
712 return 0;
715 static int soc_camera_querycap(struct file *file, void *priv,
716 struct v4l2_capability *cap)
718 struct soc_camera_device *icd = file->private_data;
719 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
721 WARN_ON(priv != file->private_data);
723 strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver));
724 return ici->ops->querycap(ici, cap);
727 static int soc_camera_streamon(struct file *file, void *priv,
728 enum v4l2_buf_type i)
730 struct soc_camera_device *icd = file->private_data;
731 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
732 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
733 int ret;
735 WARN_ON(priv != file->private_data);
737 if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
738 return -EINVAL;
740 if (icd->streamer != file)
741 return -EBUSY;
743 /* This calls buf_queue from host driver's videobuf_queue_ops */
744 if (ici->ops->init_videobuf)
745 ret = videobuf_streamon(&icd->vb_vidq);
746 else
747 ret = vb2_streamon(&icd->vb2_vidq, i);
749 if (!ret)
750 v4l2_subdev_call(sd, video, s_stream, 1);
752 return ret;
755 static int soc_camera_streamoff(struct file *file, void *priv,
756 enum v4l2_buf_type i)
758 struct soc_camera_device *icd = file->private_data;
759 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
760 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
762 WARN_ON(priv != file->private_data);
764 if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
765 return -EINVAL;
767 if (icd->streamer != file)
768 return -EBUSY;
771 * This calls buf_release from host driver's videobuf_queue_ops for all
772 * remaining buffers. When the last buffer is freed, stop capture
774 if (ici->ops->init_videobuf)
775 videobuf_streamoff(&icd->vb_vidq);
776 else
777 vb2_streamoff(&icd->vb2_vidq, i);
779 v4l2_subdev_call(sd, video, s_stream, 0);
781 return 0;
784 static int soc_camera_queryctrl(struct file *file, void *priv,
785 struct v4l2_queryctrl *qc)
787 struct soc_camera_device *icd = file->private_data;
788 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
789 int i;
791 WARN_ON(priv != file->private_data);
793 if (!qc->id)
794 return -EINVAL;
796 /* First check host controls */
797 for (i = 0; i < ici->ops->num_controls; i++)
798 if (qc->id == ici->ops->controls[i].id) {
799 memcpy(qc, &(ici->ops->controls[i]),
800 sizeof(*qc));
801 return 0;
804 /* Then device controls */
805 for (i = 0; i < icd->ops->num_controls; i++)
806 if (qc->id == icd->ops->controls[i].id) {
807 memcpy(qc, &(icd->ops->controls[i]),
808 sizeof(*qc));
809 return 0;
812 return -EINVAL;
815 static int soc_camera_g_ctrl(struct file *file, void *priv,
816 struct v4l2_control *ctrl)
818 struct soc_camera_device *icd = file->private_data;
819 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
820 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
821 int ret;
823 WARN_ON(priv != file->private_data);
825 if (ici->ops->get_ctrl) {
826 ret = ici->ops->get_ctrl(icd, ctrl);
827 if (ret != -ENOIOCTLCMD)
828 return ret;
831 return v4l2_subdev_call(sd, core, g_ctrl, ctrl);
834 static int soc_camera_s_ctrl(struct file *file, void *priv,
835 struct v4l2_control *ctrl)
837 struct soc_camera_device *icd = file->private_data;
838 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
839 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
840 int ret;
842 WARN_ON(priv != file->private_data);
844 if (ici->ops->set_ctrl) {
845 ret = ici->ops->set_ctrl(icd, ctrl);
846 if (ret != -ENOIOCTLCMD)
847 return ret;
850 return v4l2_subdev_call(sd, core, s_ctrl, ctrl);
853 static int soc_camera_cropcap(struct file *file, void *fh,
854 struct v4l2_cropcap *a)
856 struct soc_camera_device *icd = file->private_data;
857 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
859 return ici->ops->cropcap(icd, a);
862 static int soc_camera_g_crop(struct file *file, void *fh,
863 struct v4l2_crop *a)
865 struct soc_camera_device *icd = file->private_data;
866 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
867 int ret;
869 ret = ici->ops->get_crop(icd, a);
871 return ret;
875 * According to the V4L2 API, drivers shall not update the struct v4l2_crop
876 * argument with the actual geometry, instead, the user shall use G_CROP to
877 * retrieve it.
879 static int soc_camera_s_crop(struct file *file, void *fh,
880 struct v4l2_crop *a)
882 struct soc_camera_device *icd = file->private_data;
883 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
884 struct v4l2_rect *rect = &a->c;
885 struct v4l2_crop current_crop;
886 int ret;
888 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
889 return -EINVAL;
891 dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n",
892 rect->width, rect->height, rect->left, rect->top);
894 /* If get_crop fails, we'll let host and / or client drivers decide */
895 ret = ici->ops->get_crop(icd, &current_crop);
897 /* Prohibit window size change with initialised buffers */
898 if (ret < 0) {
899 dev_err(icd->pdev,
900 "S_CROP denied: getting current crop failed\n");
901 } else if ((a->c.width == current_crop.c.width &&
902 a->c.height == current_crop.c.height) ||
903 !is_streaming(ici, icd)) {
904 /* same size or not streaming - use .set_crop() */
905 ret = ici->ops->set_crop(icd, a);
906 } else if (ici->ops->set_livecrop) {
907 ret = ici->ops->set_livecrop(icd, a);
908 } else {
909 dev_err(icd->pdev,
910 "S_CROP denied: queue initialised and sizes differ\n");
911 ret = -EBUSY;
914 return ret;
917 static int soc_camera_g_parm(struct file *file, void *fh,
918 struct v4l2_streamparm *a)
920 struct soc_camera_device *icd = file->private_data;
921 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
923 if (ici->ops->get_parm)
924 return ici->ops->get_parm(icd, a);
926 return -ENOIOCTLCMD;
929 static int soc_camera_s_parm(struct file *file, void *fh,
930 struct v4l2_streamparm *a)
932 struct soc_camera_device *icd = file->private_data;
933 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
935 if (ici->ops->set_parm)
936 return ici->ops->set_parm(icd, a);
938 return -ENOIOCTLCMD;
941 static int soc_camera_g_chip_ident(struct file *file, void *fh,
942 struct v4l2_dbg_chip_ident *id)
944 struct soc_camera_device *icd = file->private_data;
945 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
947 return v4l2_subdev_call(sd, core, g_chip_ident, id);
950 #ifdef CONFIG_VIDEO_ADV_DEBUG
951 static int soc_camera_g_register(struct file *file, void *fh,
952 struct v4l2_dbg_register *reg)
954 struct soc_camera_device *icd = file->private_data;
955 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
957 return v4l2_subdev_call(sd, core, g_register, reg);
960 static int soc_camera_s_register(struct file *file, void *fh,
961 struct v4l2_dbg_register *reg)
963 struct soc_camera_device *icd = file->private_data;
964 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
966 return v4l2_subdev_call(sd, core, s_register, reg);
968 #endif
970 static int soc_camera_probe(struct soc_camera_device *icd);
972 /* So far this function cannot fail */
973 static void scan_add_host(struct soc_camera_host *ici)
975 struct soc_camera_device *icd;
977 mutex_lock(&list_lock);
979 list_for_each_entry(icd, &devices, list) {
980 if (icd->iface == ici->nr) {
981 int ret;
983 icd->parent = ici->v4l2_dev.dev;
984 ret = soc_camera_probe(icd);
988 mutex_unlock(&list_lock);
991 #ifdef CONFIG_I2C_BOARDINFO
992 static int soc_camera_init_i2c(struct soc_camera_device *icd,
993 struct soc_camera_link *icl)
995 struct i2c_client *client;
996 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
997 struct i2c_adapter *adap = i2c_get_adapter(icl->i2c_adapter_id);
998 struct v4l2_subdev *subdev;
1000 if (!adap) {
1001 dev_err(icd->pdev, "Cannot get I2C adapter #%d. No driver?\n",
1002 icl->i2c_adapter_id);
1003 goto ei2cga;
1006 icl->board_info->platform_data = icd;
1008 subdev = v4l2_i2c_new_subdev_board(&ici->v4l2_dev, adap,
1009 icl->board_info, NULL);
1010 if (!subdev)
1011 goto ei2cnd;
1013 client = v4l2_get_subdevdata(subdev);
1015 /* Use to_i2c_client(dev) to recover the i2c client */
1016 icd->control = &client->dev;
1018 return 0;
1019 ei2cnd:
1020 i2c_put_adapter(adap);
1021 ei2cga:
1022 return -ENODEV;
1025 static void soc_camera_free_i2c(struct soc_camera_device *icd)
1027 struct i2c_client *client =
1028 to_i2c_client(to_soc_camera_control(icd));
1029 struct i2c_adapter *adap = client->adapter;
1031 icd->control = NULL;
1032 v4l2_device_unregister_subdev(i2c_get_clientdata(client));
1033 i2c_unregister_device(client);
1034 i2c_put_adapter(adap);
1036 #else
1037 #define soc_camera_init_i2c(icd, icl) (-ENODEV)
1038 #define soc_camera_free_i2c(icd) do {} while (0)
1039 #endif
1041 static int soc_camera_video_start(struct soc_camera_device *icd);
1042 static int video_dev_create(struct soc_camera_device *icd);
1043 /* Called during host-driver probe */
1044 static int soc_camera_probe(struct soc_camera_device *icd)
1046 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
1047 struct soc_camera_link *icl = to_soc_camera_link(icd);
1048 struct device *control = NULL;
1049 struct v4l2_subdev *sd;
1050 struct v4l2_mbus_framefmt mf;
1051 int ret;
1053 dev_info(icd->pdev, "Probing %s\n", dev_name(icd->pdev));
1055 ret = regulator_bulk_get(icd->pdev, icl->num_regulators,
1056 icl->regulators);
1057 if (ret < 0)
1058 goto ereg;
1060 ret = soc_camera_power_set(icd, icl, 1);
1061 if (ret < 0)
1062 goto epower;
1064 /* The camera could have been already on, try to reset */
1065 if (icl->reset)
1066 icl->reset(icd->pdev);
1068 ret = ici->ops->add(icd);
1069 if (ret < 0)
1070 goto eadd;
1072 /* Must have icd->vdev before registering the device */
1073 ret = video_dev_create(icd);
1074 if (ret < 0)
1075 goto evdc;
1077 /* Non-i2c cameras, e.g., soc_camera_platform, have no board_info */
1078 if (icl->board_info) {
1079 ret = soc_camera_init_i2c(icd, icl);
1080 if (ret < 0)
1081 goto eadddev;
1082 } else if (!icl->add_device || !icl->del_device) {
1083 ret = -EINVAL;
1084 goto eadddev;
1085 } else {
1086 if (icl->module_name)
1087 ret = request_module(icl->module_name);
1089 ret = icl->add_device(icd);
1090 if (ret < 0)
1091 goto eadddev;
1094 * FIXME: this is racy, have to use driver-binding notification,
1095 * when it is available
1097 control = to_soc_camera_control(icd);
1098 if (!control || !control->driver || !dev_get_drvdata(control) ||
1099 !try_module_get(control->driver->owner)) {
1100 icl->del_device(icd);
1101 goto enodrv;
1105 sd = soc_camera_to_subdev(icd);
1106 sd->grp_id = (long)icd;
1108 /* At this point client .probe() should have run already */
1109 ret = soc_camera_init_user_formats(icd);
1110 if (ret < 0)
1111 goto eiufmt;
1113 icd->field = V4L2_FIELD_ANY;
1116 * ..._video_start() will create a device node, video_register_device()
1117 * itself is protected against concurrent open() calls, but we also have
1118 * to protect our data.
1120 mutex_lock(&icd->video_lock);
1122 ret = soc_camera_video_start(icd);
1123 if (ret < 0)
1124 goto evidstart;
1126 /* Try to improve our guess of a reasonable window format */
1127 if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) {
1128 icd->user_width = mf.width;
1129 icd->user_height = mf.height;
1130 icd->colorspace = mf.colorspace;
1131 icd->field = mf.field;
1134 ici->ops->remove(icd);
1136 soc_camera_power_set(icd, icl, 0);
1138 mutex_unlock(&icd->video_lock);
1140 return 0;
1142 evidstart:
1143 mutex_unlock(&icd->video_lock);
1144 soc_camera_free_user_formats(icd);
1145 eiufmt:
1146 if (icl->board_info) {
1147 soc_camera_free_i2c(icd);
1148 } else {
1149 icl->del_device(icd);
1150 module_put(control->driver->owner);
1152 enodrv:
1153 eadddev:
1154 video_device_release(icd->vdev);
1155 evdc:
1156 ici->ops->remove(icd);
1157 eadd:
1158 soc_camera_power_set(icd, icl, 0);
1159 epower:
1160 regulator_bulk_free(icl->num_regulators, icl->regulators);
1161 ereg:
1162 return ret;
1166 * This is called on device_unregister, which only means we have to disconnect
1167 * from the host, but not remove ourselves from the device list
1169 static int soc_camera_remove(struct soc_camera_device *icd)
1171 struct soc_camera_link *icl = to_soc_camera_link(icd);
1172 struct video_device *vdev = icd->vdev;
1174 BUG_ON(!icd->parent);
1176 if (vdev) {
1177 video_unregister_device(vdev);
1178 icd->vdev = NULL;
1181 if (icl->board_info) {
1182 soc_camera_free_i2c(icd);
1183 } else {
1184 struct device_driver *drv = to_soc_camera_control(icd)->driver;
1185 if (drv) {
1186 icl->del_device(icd);
1187 module_put(drv->owner);
1190 soc_camera_free_user_formats(icd);
1192 regulator_bulk_free(icl->num_regulators, icl->regulators);
1194 return 0;
1197 static int default_cropcap(struct soc_camera_device *icd,
1198 struct v4l2_cropcap *a)
1200 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1201 return v4l2_subdev_call(sd, video, cropcap, a);
1204 static int default_g_crop(struct soc_camera_device *icd, struct v4l2_crop *a)
1206 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1207 return v4l2_subdev_call(sd, video, g_crop, a);
1210 static int default_s_crop(struct soc_camera_device *icd, struct v4l2_crop *a)
1212 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1213 return v4l2_subdev_call(sd, video, s_crop, a);
1216 static int default_g_parm(struct soc_camera_device *icd,
1217 struct v4l2_streamparm *parm)
1219 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1220 return v4l2_subdev_call(sd, video, g_parm, parm);
1223 static int default_s_parm(struct soc_camera_device *icd,
1224 struct v4l2_streamparm *parm)
1226 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1227 return v4l2_subdev_call(sd, video, s_parm, parm);
1230 static int default_enum_fsizes(struct soc_camera_device *icd,
1231 struct v4l2_frmsizeenum *fsize)
1233 int ret;
1234 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1235 const struct soc_camera_format_xlate *xlate;
1236 __u32 pixfmt = fsize->pixel_format;
1237 struct v4l2_frmsizeenum fsize_mbus = *fsize;
1239 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
1240 if (!xlate)
1241 return -EINVAL;
1242 /* map xlate-code to pixel_format, sensor only handle xlate-code*/
1243 fsize_mbus.pixel_format = xlate->code;
1245 ret = v4l2_subdev_call(sd, video, enum_mbus_fsizes, &fsize_mbus);
1246 if (ret < 0)
1247 return ret;
1249 *fsize = fsize_mbus;
1250 fsize->pixel_format = pixfmt;
1252 return 0;
1255 int soc_camera_host_register(struct soc_camera_host *ici)
1257 struct soc_camera_host *ix;
1258 int ret;
1260 if (!ici || !ici->ops ||
1261 !ici->ops->try_fmt ||
1262 !ici->ops->set_fmt ||
1263 !ici->ops->set_bus_param ||
1264 !ici->ops->querycap ||
1265 ((!ici->ops->init_videobuf ||
1266 !ici->ops->reqbufs) &&
1267 !ici->ops->init_videobuf2) ||
1268 !ici->ops->add ||
1269 !ici->ops->remove ||
1270 !ici->ops->poll ||
1271 !ici->v4l2_dev.dev)
1272 return -EINVAL;
1274 if (!ici->ops->set_crop)
1275 ici->ops->set_crop = default_s_crop;
1276 if (!ici->ops->get_crop)
1277 ici->ops->get_crop = default_g_crop;
1278 if (!ici->ops->cropcap)
1279 ici->ops->cropcap = default_cropcap;
1280 if (!ici->ops->set_parm)
1281 ici->ops->set_parm = default_s_parm;
1282 if (!ici->ops->get_parm)
1283 ici->ops->get_parm = default_g_parm;
1284 if (!ici->ops->enum_fsizes)
1285 ici->ops->enum_fsizes = default_enum_fsizes;
1287 mutex_lock(&list_lock);
1288 list_for_each_entry(ix, &hosts, list) {
1289 if (ix->nr == ici->nr) {
1290 ret = -EBUSY;
1291 goto edevreg;
1295 ret = v4l2_device_register(ici->v4l2_dev.dev, &ici->v4l2_dev);
1296 if (ret < 0)
1297 goto edevreg;
1299 list_add_tail(&ici->list, &hosts);
1300 mutex_unlock(&list_lock);
1302 scan_add_host(ici);
1304 return 0;
1306 edevreg:
1307 mutex_unlock(&list_lock);
1308 return ret;
1310 EXPORT_SYMBOL(soc_camera_host_register);
1312 /* Unregister all clients! */
1313 void soc_camera_host_unregister(struct soc_camera_host *ici)
1315 struct soc_camera_device *icd;
1317 mutex_lock(&list_lock);
1319 list_del(&ici->list);
1320 list_for_each_entry(icd, &devices, list)
1321 if (icd->iface == ici->nr && to_soc_camera_control(icd))
1322 soc_camera_remove(icd);
1324 mutex_unlock(&list_lock);
1326 v4l2_device_unregister(&ici->v4l2_dev);
1328 EXPORT_SYMBOL(soc_camera_host_unregister);
1330 /* Image capture device */
1331 static int soc_camera_device_register(struct soc_camera_device *icd)
1333 struct soc_camera_device *ix;
1334 int num = -1, i;
1336 for (i = 0; i < 256 && num < 0; i++) {
1337 num = i;
1338 /* Check if this index is available on this interface */
1339 list_for_each_entry(ix, &devices, list) {
1340 if (ix->iface == icd->iface && ix->devnum == i) {
1341 num = -1;
1342 break;
1347 if (num < 0)
1349 * ok, we have 256 cameras on this host...
1350 * man, stay reasonable...
1352 return -ENOMEM;
1354 icd->devnum = num;
1355 icd->use_count = 0;
1356 icd->host_priv = NULL;
1357 mutex_init(&icd->video_lock);
1359 list_add_tail(&icd->list, &devices);
1361 return 0;
1364 static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = {
1365 .vidioc_querycap = soc_camera_querycap,
1366 .vidioc_g_fmt_vid_cap = soc_camera_g_fmt_vid_cap,
1367 .vidioc_enum_fmt_vid_cap = soc_camera_enum_fmt_vid_cap,
1368 .vidioc_s_fmt_vid_cap = soc_camera_s_fmt_vid_cap,
1369 .vidioc_enum_input = soc_camera_enum_input,
1370 .vidioc_g_input = soc_camera_g_input,
1371 .vidioc_s_input = soc_camera_s_input,
1372 .vidioc_s_std = soc_camera_s_std,
1373 .vidioc_enum_framesizes = soc_camera_enum_fsizes,
1374 .vidioc_reqbufs = soc_camera_reqbufs,
1375 .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap,
1376 .vidioc_querybuf = soc_camera_querybuf,
1377 .vidioc_qbuf = soc_camera_qbuf,
1378 .vidioc_dqbuf = soc_camera_dqbuf,
1379 .vidioc_streamon = soc_camera_streamon,
1380 .vidioc_streamoff = soc_camera_streamoff,
1381 .vidioc_queryctrl = soc_camera_queryctrl,
1382 .vidioc_g_ctrl = soc_camera_g_ctrl,
1383 .vidioc_s_ctrl = soc_camera_s_ctrl,
1384 .vidioc_cropcap = soc_camera_cropcap,
1385 .vidioc_g_crop = soc_camera_g_crop,
1386 .vidioc_s_crop = soc_camera_s_crop,
1387 .vidioc_g_parm = soc_camera_g_parm,
1388 .vidioc_s_parm = soc_camera_s_parm,
1389 .vidioc_g_chip_ident = soc_camera_g_chip_ident,
1390 #ifdef CONFIG_VIDEO_ADV_DEBUG
1391 .vidioc_g_register = soc_camera_g_register,
1392 .vidioc_s_register = soc_camera_s_register,
1393 #endif
1396 static int video_dev_create(struct soc_camera_device *icd)
1398 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
1399 struct video_device *vdev = video_device_alloc();
1401 if (!vdev)
1402 return -ENOMEM;
1404 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
1406 vdev->parent = icd->pdev;
1407 vdev->current_norm = V4L2_STD_UNKNOWN;
1408 vdev->fops = &soc_camera_fops;
1409 vdev->ioctl_ops = &soc_camera_ioctl_ops;
1410 vdev->release = video_device_release;
1411 vdev->tvnorms = V4L2_STD_UNKNOWN;
1412 vdev->lock = &icd->video_lock;
1414 icd->vdev = vdev;
1416 return 0;
1420 * Called from soc_camera_probe() above (with .video_lock held???)
1422 static int soc_camera_video_start(struct soc_camera_device *icd)
1424 const struct device_type *type = icd->vdev->dev.type;
1425 int ret;
1427 if (!icd->parent)
1428 return -ENODEV;
1430 if (!icd->ops ||
1431 !icd->ops->query_bus_param ||
1432 !icd->ops->set_bus_param)
1433 return -EINVAL;
1435 ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER, -1);
1436 if (ret < 0) {
1437 dev_err(icd->pdev, "video_register_device failed: %d\n", ret);
1438 return ret;
1441 /* Restore device type, possibly set by the subdevice driver */
1442 icd->vdev->dev.type = type;
1444 return 0;
1447 static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
1449 struct soc_camera_link *icl = pdev->dev.platform_data;
1450 struct soc_camera_device *icd;
1451 int ret;
1453 if (!icl)
1454 return -EINVAL;
1456 icd = kzalloc(sizeof(*icd), GFP_KERNEL);
1457 if (!icd)
1458 return -ENOMEM;
1460 icd->iface = icl->bus_id;
1461 icd->link = icl;
1462 icd->pdev = &pdev->dev;
1463 platform_set_drvdata(pdev, icd);
1465 ret = soc_camera_device_register(icd);
1466 if (ret < 0)
1467 goto escdevreg;
1469 icd->user_width = DEFAULT_WIDTH;
1470 icd->user_height = DEFAULT_HEIGHT;
1472 return 0;
1474 escdevreg:
1475 kfree(icd);
1477 return ret;
1481 * Only called on rmmod for each platform device, since they are not
1482 * hot-pluggable. Now we know, that all our users - hosts and devices have
1483 * been unloaded already
1485 static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
1487 struct soc_camera_device *icd = platform_get_drvdata(pdev);
1489 if (!icd)
1490 return -EINVAL;
1492 list_del(&icd->list);
1494 kfree(icd);
1496 return 0;
1499 static struct platform_driver __refdata soc_camera_pdrv = {
1500 .remove = __devexit_p(soc_camera_pdrv_remove),
1501 .driver = {
1502 .name = "soc-camera-pdrv",
1503 .owner = THIS_MODULE,
1507 static int __init soc_camera_init(void)
1509 return platform_driver_probe(&soc_camera_pdrv, soc_camera_pdrv_probe);
1512 static void __exit soc_camera_exit(void)
1514 platform_driver_unregister(&soc_camera_pdrv);
1517 module_init(soc_camera_init);
1518 module_exit(soc_camera_exit);
1520 MODULE_DESCRIPTION("Image capture bus driver");
1521 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
1522 MODULE_LICENSE("GPL");
1523 MODULE_ALIAS("platform:soc-camera-pdrv");