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 static LIST_HEAD(hosts
);
45 static LIST_HEAD(devices
);
46 static DEFINE_MUTEX(list_lock
); /* Protects the list of hosts */
48 static int soc_camera_power_set(struct soc_camera_device
*icd
,
49 struct soc_camera_link
*icl
,
55 ret
= regulator_bulk_enable(icl
->num_regulators
,
58 dev_err(&icd
->dev
, "Cannot enable regulators\n");
63 ret
= icl
->power(icd
->pdev
, power_on
);
66 "Platform failed to power-on the camera.\n");
68 regulator_bulk_disable(icl
->num_regulators
,
75 ret
= icl
->power(icd
->pdev
, 0);
78 "Platform failed to power-off the camera.\n");
82 ret
= regulator_bulk_disable(icl
->num_regulators
,
85 dev_err(&icd
->dev
, "Cannot disable regulators\n");
93 const struct soc_camera_format_xlate
*soc_camera_xlate_by_fourcc(
94 struct soc_camera_device
*icd
, unsigned int fourcc
)
98 for (i
= 0; i
< icd
->num_user_formats
; i
++)
99 if (icd
->user_formats
[i
].host_fmt
->fourcc
== fourcc
)
100 return icd
->user_formats
+ i
;
103 EXPORT_SYMBOL(soc_camera_xlate_by_fourcc
);
106 * soc_camera_apply_sensor_flags() - apply platform SOCAM_SENSOR_INVERT_* flags
107 * @icl: camera platform parameters
108 * @flags: flags to be inverted according to platform configuration
109 * @return: resulting flags
111 unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link
*icl
,
116 /* If only one of the two polarities is supported, switch to the opposite */
117 if (icl
->flags
& SOCAM_SENSOR_INVERT_HSYNC
) {
118 f
= flags
& (SOCAM_HSYNC_ACTIVE_HIGH
| SOCAM_HSYNC_ACTIVE_LOW
);
119 if (f
== SOCAM_HSYNC_ACTIVE_HIGH
|| f
== SOCAM_HSYNC_ACTIVE_LOW
)
120 flags
^= SOCAM_HSYNC_ACTIVE_HIGH
| SOCAM_HSYNC_ACTIVE_LOW
;
123 if (icl
->flags
& SOCAM_SENSOR_INVERT_VSYNC
) {
124 f
= flags
& (SOCAM_VSYNC_ACTIVE_HIGH
| SOCAM_VSYNC_ACTIVE_LOW
);
125 if (f
== SOCAM_VSYNC_ACTIVE_HIGH
|| f
== SOCAM_VSYNC_ACTIVE_LOW
)
126 flags
^= SOCAM_VSYNC_ACTIVE_HIGH
| SOCAM_VSYNC_ACTIVE_LOW
;
129 if (icl
->flags
& SOCAM_SENSOR_INVERT_PCLK
) {
130 f
= flags
& (SOCAM_PCLK_SAMPLE_RISING
| SOCAM_PCLK_SAMPLE_FALLING
);
131 if (f
== SOCAM_PCLK_SAMPLE_RISING
|| f
== SOCAM_PCLK_SAMPLE_FALLING
)
132 flags
^= SOCAM_PCLK_SAMPLE_RISING
| SOCAM_PCLK_SAMPLE_FALLING
;
137 EXPORT_SYMBOL(soc_camera_apply_sensor_flags
);
139 static int soc_camera_try_fmt_vid_cap(struct file
*file
, void *priv
,
140 struct v4l2_format
*f
)
142 struct soc_camera_device
*icd
= file
->private_data
;
143 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
145 WARN_ON(priv
!= file
->private_data
);
147 /* Only single-plane capture is supported so far */
148 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
151 /* limit format to hardware capabilities */
152 return ici
->ops
->try_fmt(icd
, f
);
155 static int soc_camera_enum_input(struct file
*file
, void *priv
,
156 struct v4l2_input
*inp
)
158 struct soc_camera_device
*icd
= file
->private_data
;
164 if (icd
->ops
->enum_input
)
165 ret
= icd
->ops
->enum_input(icd
, inp
);
167 /* default is camera */
168 inp
->type
= V4L2_INPUT_TYPE_CAMERA
;
169 inp
->std
= V4L2_STD_UNKNOWN
;
170 strcpy(inp
->name
, "Camera");
176 static int soc_camera_g_input(struct file
*file
, void *priv
, unsigned int *i
)
183 static int soc_camera_s_input(struct file
*file
, void *priv
, unsigned int i
)
191 static int soc_camera_s_std(struct file
*file
, void *priv
, v4l2_std_id
*a
)
193 struct soc_camera_device
*icd
= file
->private_data
;
194 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
196 return v4l2_subdev_call(sd
, core
, s_std
, *a
);
199 static int soc_camera_enum_fsizes(struct file
*file
, void *fh
,
200 struct v4l2_frmsizeenum
*fsize
)
202 struct soc_camera_device
*icd
= file
->private_data
;
203 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
205 return ici
->ops
->enum_fsizes(icd
, fsize
);
208 static int soc_camera_reqbufs(struct file
*file
, void *priv
,
209 struct v4l2_requestbuffers
*p
)
212 struct soc_camera_device
*icd
= file
->private_data
;
213 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
215 WARN_ON(priv
!= file
->private_data
);
217 if (icd
->streamer
&& icd
->streamer
!= file
)
220 if (ici
->ops
->init_videobuf
) {
221 ret
= videobuf_reqbufs(&icd
->vb_vidq
, p
);
225 ret
= ici
->ops
->reqbufs(icd
, p
);
227 ret
= vb2_reqbufs(&icd
->vb2_vidq
, p
);
230 if (!ret
&& !icd
->streamer
)
231 icd
->streamer
= file
;
236 static int soc_camera_querybuf(struct file
*file
, void *priv
,
237 struct v4l2_buffer
*p
)
239 struct soc_camera_device
*icd
= file
->private_data
;
240 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
242 WARN_ON(priv
!= file
->private_data
);
244 if (ici
->ops
->init_videobuf
)
245 return videobuf_querybuf(&icd
->vb_vidq
, p
);
247 return vb2_querybuf(&icd
->vb2_vidq
, p
);
250 static int soc_camera_qbuf(struct file
*file
, void *priv
,
251 struct v4l2_buffer
*p
)
253 struct soc_camera_device
*icd
= file
->private_data
;
254 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
256 WARN_ON(priv
!= file
->private_data
);
258 if (icd
->streamer
!= file
)
261 if (ici
->ops
->init_videobuf
)
262 return videobuf_qbuf(&icd
->vb_vidq
, p
);
264 return vb2_qbuf(&icd
->vb2_vidq
, p
);
267 static int soc_camera_dqbuf(struct file
*file
, void *priv
,
268 struct v4l2_buffer
*p
)
270 struct soc_camera_device
*icd
= file
->private_data
;
271 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
273 WARN_ON(priv
!= file
->private_data
);
275 if (icd
->streamer
!= file
)
278 if (ici
->ops
->init_videobuf
)
279 return videobuf_dqbuf(&icd
->vb_vidq
, p
, file
->f_flags
& O_NONBLOCK
);
281 return vb2_dqbuf(&icd
->vb2_vidq
, p
, file
->f_flags
& O_NONBLOCK
);
284 /* Always entered with .video_lock held */
285 static int soc_camera_init_user_formats(struct soc_camera_device
*icd
)
287 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
288 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
289 unsigned int i
, fmts
= 0, raw_fmts
= 0;
291 enum v4l2_mbus_pixelcode code
;
293 while (!v4l2_subdev_call(sd
, video
, enum_mbus_fmt
, raw_fmts
, &code
))
296 if (!ici
->ops
->get_formats
)
298 * Fallback mode - the host will have to serve all
299 * sensor-provided formats one-to-one to the user
304 * First pass - only count formats this host-sensor
305 * configuration can provide
307 for (i
= 0; i
< raw_fmts
; i
++) {
308 ret
= ici
->ops
->get_formats(icd
, i
, NULL
);
318 vmalloc(fmts
* sizeof(struct soc_camera_format_xlate
));
319 if (!icd
->user_formats
)
322 icd
->num_user_formats
= fmts
;
324 dev_dbg(&icd
->dev
, "Found %d supported formats.\n", fmts
);
326 /* Second pass - actually fill data formats */
328 for (i
= 0; i
< raw_fmts
; i
++)
329 if (!ici
->ops
->get_formats
) {
330 v4l2_subdev_call(sd
, video
, enum_mbus_fmt
, i
, &code
);
331 icd
->user_formats
[i
].host_fmt
=
332 soc_mbus_get_fmtdesc(code
);
333 icd
->user_formats
[i
].code
= code
;
335 ret
= ici
->ops
->get_formats(icd
, i
,
336 &icd
->user_formats
[fmts
]);
342 icd
->current_fmt
= &icd
->user_formats
[0];
347 icd
->num_user_formats
= 0;
348 vfree(icd
->user_formats
);
352 /* Always entered with .video_lock held */
353 static void soc_camera_free_user_formats(struct soc_camera_device
*icd
)
355 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
357 if (ici
->ops
->put_formats
)
358 ici
->ops
->put_formats(icd
);
359 icd
->current_fmt
= NULL
;
360 icd
->num_user_formats
= 0;
361 vfree(icd
->user_formats
);
362 icd
->user_formats
= NULL
;
365 #define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
368 /* Called with .vb_lock held, or from the first open(2), see comment there */
369 static int soc_camera_set_fmt(struct soc_camera_device
*icd
,
370 struct v4l2_format
*f
)
372 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
373 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
376 dev_dbg(&icd
->dev
, "S_FMT(%c%c%c%c, %ux%u)\n",
377 pixfmtstr(pix
->pixelformat
), pix
->width
, pix
->height
);
379 /* We always call try_fmt() before set_fmt() or set_crop() */
380 ret
= ici
->ops
->try_fmt(icd
, f
);
384 ret
= ici
->ops
->set_fmt(icd
, f
);
387 } else if (!icd
->current_fmt
||
388 icd
->current_fmt
->host_fmt
->fourcc
!= pix
->pixelformat
) {
390 "Host driver hasn't set up current format correctly!\n");
394 icd
->user_width
= pix
->width
;
395 icd
->user_height
= pix
->height
;
396 icd
->bytesperline
= pix
->bytesperline
;
397 icd
->sizeimage
= pix
->sizeimage
;
398 icd
->colorspace
= pix
->colorspace
;
399 icd
->field
= pix
->field
;
400 if (ici
->ops
->init_videobuf
)
401 icd
->vb_vidq
.field
= pix
->field
;
403 dev_dbg(&icd
->dev
, "set width: %d height: %d\n",
404 icd
->user_width
, icd
->user_height
);
406 /* set physical bus parameters */
407 return ici
->ops
->set_bus_param(icd
, pix
->pixelformat
);
410 static int soc_camera_open(struct file
*file
)
412 struct video_device
*vdev
= video_devdata(file
);
413 struct soc_camera_device
*icd
= container_of(vdev
->parent
,
414 struct soc_camera_device
,
416 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
417 struct soc_camera_host
*ici
;
421 /* No device driver attached */
424 ici
= to_soc_camera_host(icd
->dev
.parent
);
426 if (!try_module_get(ici
->ops
->owner
)) {
427 dev_err(&icd
->dev
, "Couldn't lock capture bus driver.\n");
433 /* Now we really have to activate the camera */
434 if (icd
->use_count
== 1) {
435 /* Restore parameters before the last close() per V4L2 API */
436 struct v4l2_format f
= {
437 .type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
,
439 .width
= icd
->user_width
,
440 .height
= icd
->user_height
,
442 .colorspace
= icd
->colorspace
,
444 icd
->current_fmt
->host_fmt
->fourcc
,
448 ret
= soc_camera_power_set(icd
, icl
, 1);
452 /* The camera could have been already on, try to reset */
454 icl
->reset(icd
->pdev
);
456 ret
= ici
->ops
->add(icd
);
458 dev_err(&icd
->dev
, "Couldn't activate the camera: %d\n", ret
);
462 pm_runtime_enable(&icd
->vdev
->dev
);
463 ret
= pm_runtime_resume(&icd
->vdev
->dev
);
464 if (ret
< 0 && ret
!= -ENOSYS
)
468 * Try to configure with default parameters. Notice: this is the
469 * very first open, so, we cannot race against other calls,
470 * apart from someone else calling open() simultaneously, but
471 * .video_lock is protecting us against it.
473 ret
= soc_camera_set_fmt(icd
, &f
);
477 if (ici
->ops
->init_videobuf
) {
478 ici
->ops
->init_videobuf(&icd
->vb_vidq
, icd
);
480 ret
= ici
->ops
->init_videobuf2(&icd
->vb2_vidq
, icd
);
486 file
->private_data
= icd
;
487 dev_dbg(&icd
->dev
, "camera device open\n");
492 * First four errors are entered with the .video_lock held
497 pm_runtime_disable(&icd
->vdev
->dev
);
499 ici
->ops
->remove(icd
);
501 soc_camera_power_set(icd
, icl
, 0);
504 module_put(ici
->ops
->owner
);
509 static int soc_camera_close(struct file
*file
)
511 struct soc_camera_device
*icd
= file
->private_data
;
512 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
515 if (!icd
->use_count
) {
516 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
518 pm_runtime_suspend(&icd
->vdev
->dev
);
519 pm_runtime_disable(&icd
->vdev
->dev
);
521 ici
->ops
->remove(icd
);
522 if (ici
->ops
->init_videobuf2
)
523 vb2_queue_release(&icd
->vb2_vidq
);
525 soc_camera_power_set(icd
, icl
, 0);
528 if (icd
->streamer
== file
)
529 icd
->streamer
= NULL
;
531 module_put(ici
->ops
->owner
);
533 dev_dbg(&icd
->dev
, "camera device close\n");
538 static ssize_t
soc_camera_read(struct file
*file
, char __user
*buf
,
539 size_t count
, loff_t
*ppos
)
541 struct soc_camera_device
*icd
= file
->private_data
;
544 dev_err(&icd
->dev
, "camera device read not implemented\n");
549 static int soc_camera_mmap(struct file
*file
, struct vm_area_struct
*vma
)
551 struct soc_camera_device
*icd
= file
->private_data
;
552 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
555 dev_dbg(&icd
->dev
, "mmap called, vma=0x%08lx\n", (unsigned long)vma
);
557 if (icd
->streamer
!= file
)
560 if (ici
->ops
->init_videobuf
)
561 err
= videobuf_mmap_mapper(&icd
->vb_vidq
, vma
);
563 err
= vb2_mmap(&icd
->vb2_vidq
, vma
);
565 dev_dbg(&icd
->dev
, "vma start=0x%08lx, size=%ld, ret=%d\n",
566 (unsigned long)vma
->vm_start
,
567 (unsigned long)vma
->vm_end
- (unsigned long)vma
->vm_start
,
573 static unsigned int soc_camera_poll(struct file
*file
, poll_table
*pt
)
575 struct soc_camera_device
*icd
= file
->private_data
;
576 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
578 if (icd
->streamer
!= file
)
581 if (ici
->ops
->init_videobuf
&& list_empty(&icd
->vb_vidq
.stream
)) {
582 dev_err(&icd
->dev
, "Trying to poll with no queued buffers!\n");
586 return ici
->ops
->poll(file
, pt
);
589 void soc_camera_lock(struct vb2_queue
*vq
)
591 struct soc_camera_device
*icd
= vb2_get_drv_priv(vq
);
592 mutex_lock(&icd
->video_lock
);
594 EXPORT_SYMBOL(soc_camera_lock
);
596 void soc_camera_unlock(struct vb2_queue
*vq
)
598 struct soc_camera_device
*icd
= vb2_get_drv_priv(vq
);
599 mutex_unlock(&icd
->video_lock
);
601 EXPORT_SYMBOL(soc_camera_unlock
);
603 static struct v4l2_file_operations soc_camera_fops
= {
604 .owner
= THIS_MODULE
,
605 .open
= soc_camera_open
,
606 .release
= soc_camera_close
,
607 .unlocked_ioctl
= video_ioctl2
,
608 .read
= soc_camera_read
,
609 .mmap
= soc_camera_mmap
,
610 .poll
= soc_camera_poll
,
613 static int soc_camera_s_fmt_vid_cap(struct file
*file
, void *priv
,
614 struct v4l2_format
*f
)
616 struct soc_camera_device
*icd
= file
->private_data
;
619 WARN_ON(priv
!= file
->private_data
);
621 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) {
622 dev_warn(&icd
->dev
, "Wrong buf-type %d\n", f
->type
);
626 if (icd
->streamer
&& icd
->streamer
!= file
)
629 if (icd
->vb_vidq
.bufs
[0]) {
630 dev_err(&icd
->dev
, "S_FMT denied: queue initialised\n");
634 ret
= soc_camera_set_fmt(icd
, f
);
636 if (!ret
&& !icd
->streamer
)
637 icd
->streamer
= file
;
642 static int soc_camera_enum_fmt_vid_cap(struct file
*file
, void *priv
,
643 struct v4l2_fmtdesc
*f
)
645 struct soc_camera_device
*icd
= file
->private_data
;
646 const struct soc_mbus_pixelfmt
*format
;
648 WARN_ON(priv
!= file
->private_data
);
650 if (f
->index
>= icd
->num_user_formats
)
653 format
= icd
->user_formats
[f
->index
].host_fmt
;
656 strlcpy(f
->description
, format
->name
, sizeof(f
->description
));
657 f
->pixelformat
= format
->fourcc
;
661 static int soc_camera_g_fmt_vid_cap(struct file
*file
, void *priv
,
662 struct v4l2_format
*f
)
664 struct soc_camera_device
*icd
= file
->private_data
;
665 struct v4l2_pix_format
*pix
= &f
->fmt
.pix
;
667 WARN_ON(priv
!= file
->private_data
);
669 if (f
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
672 pix
->width
= icd
->user_width
;
673 pix
->height
= icd
->user_height
;
674 pix
->bytesperline
= icd
->bytesperline
;
675 pix
->sizeimage
= icd
->sizeimage
;
676 pix
->field
= icd
->field
;
677 pix
->pixelformat
= icd
->current_fmt
->host_fmt
->fourcc
;
678 pix
->colorspace
= icd
->colorspace
;
679 dev_dbg(&icd
->dev
, "current_fmt->fourcc: 0x%08x\n",
680 icd
->current_fmt
->host_fmt
->fourcc
);
684 static int soc_camera_querycap(struct file
*file
, void *priv
,
685 struct v4l2_capability
*cap
)
687 struct soc_camera_device
*icd
= file
->private_data
;
688 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
690 WARN_ON(priv
!= file
->private_data
);
692 strlcpy(cap
->driver
, ici
->drv_name
, sizeof(cap
->driver
));
693 return ici
->ops
->querycap(ici
, cap
);
696 static int soc_camera_streamon(struct file
*file
, void *priv
,
697 enum v4l2_buf_type i
)
699 struct soc_camera_device
*icd
= file
->private_data
;
700 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
701 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
704 WARN_ON(priv
!= file
->private_data
);
706 if (i
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
709 if (icd
->streamer
!= file
)
712 /* This calls buf_queue from host driver's videobuf_queue_ops */
713 if (ici
->ops
->init_videobuf
)
714 ret
= videobuf_streamon(&icd
->vb_vidq
);
716 ret
= vb2_streamon(&icd
->vb2_vidq
, i
);
719 v4l2_subdev_call(sd
, video
, s_stream
, 1);
724 static int soc_camera_streamoff(struct file
*file
, void *priv
,
725 enum v4l2_buf_type i
)
727 struct soc_camera_device
*icd
= file
->private_data
;
728 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
729 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
731 WARN_ON(priv
!= file
->private_data
);
733 if (i
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
736 if (icd
->streamer
!= file
)
740 * This calls buf_release from host driver's videobuf_queue_ops for all
741 * remaining buffers. When the last buffer is freed, stop capture
743 if (ici
->ops
->init_videobuf
)
744 videobuf_streamoff(&icd
->vb_vidq
);
746 vb2_streamoff(&icd
->vb2_vidq
, i
);
748 v4l2_subdev_call(sd
, video
, s_stream
, 0);
753 static int soc_camera_queryctrl(struct file
*file
, void *priv
,
754 struct v4l2_queryctrl
*qc
)
756 struct soc_camera_device
*icd
= file
->private_data
;
757 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
760 WARN_ON(priv
!= file
->private_data
);
765 /* First check host controls */
766 for (i
= 0; i
< ici
->ops
->num_controls
; i
++)
767 if (qc
->id
== ici
->ops
->controls
[i
].id
) {
768 memcpy(qc
, &(ici
->ops
->controls
[i
]),
773 /* Then device controls */
774 for (i
= 0; i
< icd
->ops
->num_controls
; i
++)
775 if (qc
->id
== icd
->ops
->controls
[i
].id
) {
776 memcpy(qc
, &(icd
->ops
->controls
[i
]),
784 static int soc_camera_g_ctrl(struct file
*file
, void *priv
,
785 struct v4l2_control
*ctrl
)
787 struct soc_camera_device
*icd
= file
->private_data
;
788 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
789 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
792 WARN_ON(priv
!= file
->private_data
);
794 if (ici
->ops
->get_ctrl
) {
795 ret
= ici
->ops
->get_ctrl(icd
, ctrl
);
796 if (ret
!= -ENOIOCTLCMD
)
800 return v4l2_subdev_call(sd
, core
, g_ctrl
, ctrl
);
803 static int soc_camera_s_ctrl(struct file
*file
, void *priv
,
804 struct v4l2_control
*ctrl
)
806 struct soc_camera_device
*icd
= file
->private_data
;
807 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
808 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
811 WARN_ON(priv
!= file
->private_data
);
813 if (ici
->ops
->set_ctrl
) {
814 ret
= ici
->ops
->set_ctrl(icd
, ctrl
);
815 if (ret
!= -ENOIOCTLCMD
)
819 return v4l2_subdev_call(sd
, core
, s_ctrl
, ctrl
);
822 static int soc_camera_cropcap(struct file
*file
, void *fh
,
823 struct v4l2_cropcap
*a
)
825 struct soc_camera_device
*icd
= file
->private_data
;
826 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
828 return ici
->ops
->cropcap(icd
, a
);
831 static int soc_camera_g_crop(struct file
*file
, void *fh
,
834 struct soc_camera_device
*icd
= file
->private_data
;
835 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
838 ret
= ici
->ops
->get_crop(icd
, a
);
844 * According to the V4L2 API, drivers shall not update the struct v4l2_crop
845 * argument with the actual geometry, instead, the user shall use G_CROP to
848 static int soc_camera_s_crop(struct file
*file
, void *fh
,
851 struct soc_camera_device
*icd
= file
->private_data
;
852 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
853 struct v4l2_rect
*rect
= &a
->c
;
854 struct v4l2_crop current_crop
;
857 if (a
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
)
860 dev_dbg(&icd
->dev
, "S_CROP(%ux%u@%u:%u)\n",
861 rect
->width
, rect
->height
, rect
->left
, rect
->top
);
863 /* If get_crop fails, we'll let host and / or client drivers decide */
864 ret
= ici
->ops
->get_crop(icd
, ¤t_crop
);
866 /* Prohibit window size change with initialised buffers */
869 "S_CROP denied: getting current crop failed\n");
870 } else if (icd
->vb_vidq
.bufs
[0] &&
871 (a
->c
.width
!= current_crop
.c
.width
||
872 a
->c
.height
!= current_crop
.c
.height
)) {
874 "S_CROP denied: queue initialised and sizes differ\n");
877 ret
= ici
->ops
->set_crop(icd
, a
);
883 static int soc_camera_g_parm(struct file
*file
, void *fh
,
884 struct v4l2_streamparm
*a
)
886 struct soc_camera_device
*icd
= file
->private_data
;
887 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
889 if (ici
->ops
->get_parm
)
890 return ici
->ops
->get_parm(icd
, a
);
895 static int soc_camera_s_parm(struct file
*file
, void *fh
,
896 struct v4l2_streamparm
*a
)
898 struct soc_camera_device
*icd
= file
->private_data
;
899 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
901 if (ici
->ops
->set_parm
)
902 return ici
->ops
->set_parm(icd
, a
);
907 static int soc_camera_g_chip_ident(struct file
*file
, void *fh
,
908 struct v4l2_dbg_chip_ident
*id
)
910 struct soc_camera_device
*icd
= file
->private_data
;
911 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
913 return v4l2_subdev_call(sd
, core
, g_chip_ident
, id
);
916 #ifdef CONFIG_VIDEO_ADV_DEBUG
917 static int soc_camera_g_register(struct file
*file
, void *fh
,
918 struct v4l2_dbg_register
*reg
)
920 struct soc_camera_device
*icd
= file
->private_data
;
921 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
923 return v4l2_subdev_call(sd
, core
, g_register
, reg
);
926 static int soc_camera_s_register(struct file
*file
, void *fh
,
927 struct v4l2_dbg_register
*reg
)
929 struct soc_camera_device
*icd
= file
->private_data
;
930 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
932 return v4l2_subdev_call(sd
, core
, s_register
, reg
);
936 /* So far this function cannot fail */
937 static void scan_add_host(struct soc_camera_host
*ici
)
939 struct soc_camera_device
*icd
;
941 mutex_lock(&list_lock
);
943 list_for_each_entry(icd
, &devices
, list
) {
944 if (icd
->iface
== ici
->nr
) {
946 icd
->dev
.parent
= ici
->v4l2_dev
.dev
;
947 dev_set_name(&icd
->dev
, "%u-%u", icd
->iface
,
949 ret
= device_register(&icd
->dev
);
951 icd
->dev
.parent
= NULL
;
953 "Cannot register device: %d\n", ret
);
958 mutex_unlock(&list_lock
);
961 #ifdef CONFIG_I2C_BOARDINFO
962 static int soc_camera_init_i2c(struct soc_camera_device
*icd
,
963 struct soc_camera_link
*icl
)
965 struct i2c_client
*client
;
966 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
967 struct i2c_adapter
*adap
= i2c_get_adapter(icl
->i2c_adapter_id
);
968 struct v4l2_subdev
*subdev
;
971 dev_err(&icd
->dev
, "Cannot get I2C adapter #%d. No driver?\n",
972 icl
->i2c_adapter_id
);
976 icl
->board_info
->platform_data
= icd
;
978 subdev
= v4l2_i2c_new_subdev_board(&ici
->v4l2_dev
, adap
,
979 icl
->board_info
, NULL
);
983 client
= v4l2_get_subdevdata(subdev
);
985 /* Use to_i2c_client(dev) to recover the i2c client */
986 dev_set_drvdata(&icd
->dev
, &client
->dev
);
990 i2c_put_adapter(adap
);
995 static void soc_camera_free_i2c(struct soc_camera_device
*icd
)
997 struct i2c_client
*client
=
998 to_i2c_client(to_soc_camera_control(icd
));
999 dev_set_drvdata(&icd
->dev
, NULL
);
1000 v4l2_device_unregister_subdev(i2c_get_clientdata(client
));
1001 i2c_unregister_device(client
);
1002 i2c_put_adapter(client
->adapter
);
1005 #define soc_camera_init_i2c(icd, icl) (-ENODEV)
1006 #define soc_camera_free_i2c(icd) do {} while (0)
1009 static int soc_camera_video_start(struct soc_camera_device
*icd
);
1010 static int video_dev_create(struct soc_camera_device
*icd
);
1011 /* Called during host-driver probe */
1012 static int soc_camera_probe(struct device
*dev
)
1014 struct soc_camera_device
*icd
= to_soc_camera_dev(dev
);
1015 struct soc_camera_host
*ici
= to_soc_camera_host(dev
->parent
);
1016 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
1017 struct device
*control
= NULL
;
1018 struct v4l2_subdev
*sd
;
1019 struct v4l2_mbus_framefmt mf
;
1022 dev_info(dev
, "Probing %s\n", dev_name(dev
));
1024 ret
= regulator_bulk_get(icd
->pdev
, icl
->num_regulators
,
1029 ret
= soc_camera_power_set(icd
, icl
, 1);
1033 /* The camera could have been already on, try to reset */
1035 icl
->reset(icd
->pdev
);
1037 ret
= ici
->ops
->add(icd
);
1041 /* Must have icd->vdev before registering the device */
1042 ret
= video_dev_create(icd
);
1046 /* Non-i2c cameras, e.g., soc_camera_platform, have no board_info */
1047 if (icl
->board_info
) {
1048 ret
= soc_camera_init_i2c(icd
, icl
);
1051 } else if (!icl
->add_device
|| !icl
->del_device
) {
1055 if (icl
->module_name
)
1056 ret
= request_module(icl
->module_name
);
1058 ret
= icl
->add_device(icl
, &icd
->dev
);
1063 * FIXME: this is racy, have to use driver-binding notification,
1064 * when it is available
1066 control
= to_soc_camera_control(icd
);
1067 if (!control
|| !control
->driver
|| !dev_get_drvdata(control
) ||
1068 !try_module_get(control
->driver
->owner
)) {
1069 icl
->del_device(icl
);
1074 /* At this point client .probe() should have run already */
1075 ret
= soc_camera_init_user_formats(icd
);
1079 icd
->field
= V4L2_FIELD_ANY
;
1081 icd
->vdev
->lock
= &icd
->video_lock
;
1084 * ..._video_start() will create a device node, video_register_device()
1085 * itself is protected against concurrent open() calls, but we also have
1086 * to protect our data.
1088 mutex_lock(&icd
->video_lock
);
1090 ret
= soc_camera_video_start(icd
);
1094 /* Try to improve our guess of a reasonable window format */
1095 sd
= soc_camera_to_subdev(icd
);
1096 if (!v4l2_subdev_call(sd
, video
, g_mbus_fmt
, &mf
)) {
1097 icd
->user_width
= mf
.width
;
1098 icd
->user_height
= mf
.height
;
1099 icd
->colorspace
= mf
.colorspace
;
1100 icd
->field
= mf
.field
;
1103 /* Do we have to sysfs_remove_link() before device_unregister()? */
1104 if (sysfs_create_link(&icd
->dev
.kobj
, &to_soc_camera_control(icd
)->kobj
,
1106 dev_warn(&icd
->dev
, "Failed creating the control symlink\n");
1108 ici
->ops
->remove(icd
);
1110 soc_camera_power_set(icd
, icl
, 0);
1112 mutex_unlock(&icd
->video_lock
);
1117 mutex_unlock(&icd
->video_lock
);
1118 soc_camera_free_user_formats(icd
);
1120 if (icl
->board_info
) {
1121 soc_camera_free_i2c(icd
);
1123 icl
->del_device(icl
);
1124 module_put(control
->driver
->owner
);
1128 video_device_release(icd
->vdev
);
1130 ici
->ops
->remove(icd
);
1132 soc_camera_power_set(icd
, icl
, 0);
1134 regulator_bulk_free(icl
->num_regulators
, icl
->regulators
);
1140 * This is called on device_unregister, which only means we have to disconnect
1141 * from the host, but not remove ourselves from the device list
1143 static int soc_camera_remove(struct device
*dev
)
1145 struct soc_camera_device
*icd
= to_soc_camera_dev(dev
);
1146 struct soc_camera_link
*icl
= to_soc_camera_link(icd
);
1147 struct video_device
*vdev
= icd
->vdev
;
1149 BUG_ON(!dev
->parent
);
1152 video_unregister_device(vdev
);
1156 if (icl
->board_info
) {
1157 soc_camera_free_i2c(icd
);
1159 struct device_driver
*drv
= to_soc_camera_control(icd
) ?
1160 to_soc_camera_control(icd
)->driver
: NULL
;
1162 icl
->del_device(icl
);
1163 module_put(drv
->owner
);
1166 soc_camera_free_user_formats(icd
);
1168 regulator_bulk_free(icl
->num_regulators
, icl
->regulators
);
1173 static int soc_camera_suspend(struct device
*dev
, pm_message_t state
)
1175 struct soc_camera_device
*icd
= to_soc_camera_dev(dev
);
1176 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
1179 if (ici
->ops
->suspend
)
1180 ret
= ici
->ops
->suspend(icd
, state
);
1185 static int soc_camera_resume(struct device
*dev
)
1187 struct soc_camera_device
*icd
= to_soc_camera_dev(dev
);
1188 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
1191 if (ici
->ops
->resume
)
1192 ret
= ici
->ops
->resume(icd
);
1197 struct bus_type soc_camera_bus_type
= {
1198 .name
= "soc-camera",
1199 .probe
= soc_camera_probe
,
1200 .remove
= soc_camera_remove
,
1201 .suspend
= soc_camera_suspend
,
1202 .resume
= soc_camera_resume
,
1204 EXPORT_SYMBOL_GPL(soc_camera_bus_type
);
1206 static struct device_driver ic_drv
= {
1208 .bus
= &soc_camera_bus_type
,
1209 .owner
= THIS_MODULE
,
1212 static void dummy_release(struct device
*dev
)
1216 static int default_cropcap(struct soc_camera_device
*icd
,
1217 struct v4l2_cropcap
*a
)
1219 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1220 return v4l2_subdev_call(sd
, video
, cropcap
, a
);
1223 static int default_g_crop(struct soc_camera_device
*icd
, struct v4l2_crop
*a
)
1225 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1226 return v4l2_subdev_call(sd
, video
, g_crop
, a
);
1229 static int default_s_crop(struct soc_camera_device
*icd
, struct v4l2_crop
*a
)
1231 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1232 return v4l2_subdev_call(sd
, video
, s_crop
, a
);
1235 static int default_g_parm(struct soc_camera_device
*icd
,
1236 struct v4l2_streamparm
*parm
)
1238 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1239 return v4l2_subdev_call(sd
, video
, g_parm
, parm
);
1242 static int default_s_parm(struct soc_camera_device
*icd
,
1243 struct v4l2_streamparm
*parm
)
1245 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1246 return v4l2_subdev_call(sd
, video
, s_parm
, parm
);
1249 static int default_enum_fsizes(struct soc_camera_device
*icd
,
1250 struct v4l2_frmsizeenum
*fsize
)
1253 struct v4l2_subdev
*sd
= soc_camera_to_subdev(icd
);
1254 const struct soc_camera_format_xlate
*xlate
;
1255 __u32 pixfmt
= fsize
->pixel_format
;
1256 struct v4l2_frmsizeenum fsize_mbus
= *fsize
;
1258 xlate
= soc_camera_xlate_by_fourcc(icd
, pixfmt
);
1261 /* map xlate-code to pixel_format, sensor only handle xlate-code*/
1262 fsize_mbus
.pixel_format
= xlate
->code
;
1264 ret
= v4l2_subdev_call(sd
, video
, enum_mbus_fsizes
, &fsize_mbus
);
1268 *fsize
= fsize_mbus
;
1269 fsize
->pixel_format
= pixfmt
;
1274 static void soc_camera_device_init(struct device
*dev
, void *pdata
)
1276 dev
->platform_data
= pdata
;
1277 dev
->bus
= &soc_camera_bus_type
;
1278 dev
->release
= dummy_release
;
1281 int soc_camera_host_register(struct soc_camera_host
*ici
)
1283 struct soc_camera_host
*ix
;
1286 if (!ici
|| !ici
->ops
||
1287 !ici
->ops
->try_fmt
||
1288 !ici
->ops
->set_fmt
||
1289 !ici
->ops
->set_bus_param
||
1290 !ici
->ops
->querycap
||
1291 ((!ici
->ops
->init_videobuf
||
1292 !ici
->ops
->reqbufs
) &&
1293 !ici
->ops
->init_videobuf2
) ||
1295 !ici
->ops
->remove
||
1300 if (!ici
->ops
->set_crop
)
1301 ici
->ops
->set_crop
= default_s_crop
;
1302 if (!ici
->ops
->get_crop
)
1303 ici
->ops
->get_crop
= default_g_crop
;
1304 if (!ici
->ops
->cropcap
)
1305 ici
->ops
->cropcap
= default_cropcap
;
1306 if (!ici
->ops
->set_parm
)
1307 ici
->ops
->set_parm
= default_s_parm
;
1308 if (!ici
->ops
->get_parm
)
1309 ici
->ops
->get_parm
= default_g_parm
;
1310 if (!ici
->ops
->enum_fsizes
)
1311 ici
->ops
->enum_fsizes
= default_enum_fsizes
;
1313 mutex_lock(&list_lock
);
1314 list_for_each_entry(ix
, &hosts
, list
) {
1315 if (ix
->nr
== ici
->nr
) {
1321 ret
= v4l2_device_register(ici
->v4l2_dev
.dev
, &ici
->v4l2_dev
);
1325 list_add_tail(&ici
->list
, &hosts
);
1326 mutex_unlock(&list_lock
);
1333 mutex_unlock(&list_lock
);
1336 EXPORT_SYMBOL(soc_camera_host_register
);
1338 /* Unregister all clients! */
1339 void soc_camera_host_unregister(struct soc_camera_host
*ici
)
1341 struct soc_camera_device
*icd
;
1343 mutex_lock(&list_lock
);
1345 list_del(&ici
->list
);
1347 list_for_each_entry(icd
, &devices
, list
) {
1348 if (icd
->iface
== ici
->nr
) {
1349 void *pdata
= icd
->dev
.platform_data
;
1350 /* The bus->remove will be called */
1351 device_unregister(&icd
->dev
);
1353 * Not before device_unregister(), .remove
1354 * needs parent to call ici->ops->remove().
1355 * If the host module is loaded again, device_register()
1356 * would complain "already initialised," since 2.6.32
1357 * this is also needed to prevent use-after-free of the
1358 * device private data.
1360 memset(&icd
->dev
, 0, sizeof(icd
->dev
));
1361 soc_camera_device_init(&icd
->dev
, pdata
);
1365 mutex_unlock(&list_lock
);
1367 v4l2_device_unregister(&ici
->v4l2_dev
);
1369 EXPORT_SYMBOL(soc_camera_host_unregister
);
1371 /* Image capture device */
1372 static int soc_camera_device_register(struct soc_camera_device
*icd
)
1374 struct soc_camera_device
*ix
;
1377 for (i
= 0; i
< 256 && num
< 0; i
++) {
1379 /* Check if this index is available on this interface */
1380 list_for_each_entry(ix
, &devices
, list
) {
1381 if (ix
->iface
== icd
->iface
&& ix
->devnum
== i
) {
1390 * ok, we have 256 cameras on this host...
1391 * man, stay reasonable...
1397 icd
->host_priv
= NULL
;
1398 mutex_init(&icd
->video_lock
);
1400 list_add_tail(&icd
->list
, &devices
);
1405 static void soc_camera_device_unregister(struct soc_camera_device
*icd
)
1407 list_del(&icd
->list
);
1410 static const struct v4l2_ioctl_ops soc_camera_ioctl_ops
= {
1411 .vidioc_querycap
= soc_camera_querycap
,
1412 .vidioc_g_fmt_vid_cap
= soc_camera_g_fmt_vid_cap
,
1413 .vidioc_enum_fmt_vid_cap
= soc_camera_enum_fmt_vid_cap
,
1414 .vidioc_s_fmt_vid_cap
= soc_camera_s_fmt_vid_cap
,
1415 .vidioc_enum_input
= soc_camera_enum_input
,
1416 .vidioc_g_input
= soc_camera_g_input
,
1417 .vidioc_s_input
= soc_camera_s_input
,
1418 .vidioc_s_std
= soc_camera_s_std
,
1419 .vidioc_enum_framesizes
= soc_camera_enum_fsizes
,
1420 .vidioc_reqbufs
= soc_camera_reqbufs
,
1421 .vidioc_try_fmt_vid_cap
= soc_camera_try_fmt_vid_cap
,
1422 .vidioc_querybuf
= soc_camera_querybuf
,
1423 .vidioc_qbuf
= soc_camera_qbuf
,
1424 .vidioc_dqbuf
= soc_camera_dqbuf
,
1425 .vidioc_streamon
= soc_camera_streamon
,
1426 .vidioc_streamoff
= soc_camera_streamoff
,
1427 .vidioc_queryctrl
= soc_camera_queryctrl
,
1428 .vidioc_g_ctrl
= soc_camera_g_ctrl
,
1429 .vidioc_s_ctrl
= soc_camera_s_ctrl
,
1430 .vidioc_cropcap
= soc_camera_cropcap
,
1431 .vidioc_g_crop
= soc_camera_g_crop
,
1432 .vidioc_s_crop
= soc_camera_s_crop
,
1433 .vidioc_g_parm
= soc_camera_g_parm
,
1434 .vidioc_s_parm
= soc_camera_s_parm
,
1435 .vidioc_g_chip_ident
= soc_camera_g_chip_ident
,
1436 #ifdef CONFIG_VIDEO_ADV_DEBUG
1437 .vidioc_g_register
= soc_camera_g_register
,
1438 .vidioc_s_register
= soc_camera_s_register
,
1442 static int video_dev_create(struct soc_camera_device
*icd
)
1444 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
1445 struct video_device
*vdev
= video_device_alloc();
1450 strlcpy(vdev
->name
, ici
->drv_name
, sizeof(vdev
->name
));
1452 vdev
->parent
= &icd
->dev
;
1453 vdev
->current_norm
= V4L2_STD_UNKNOWN
;
1454 vdev
->fops
= &soc_camera_fops
;
1455 vdev
->ioctl_ops
= &soc_camera_ioctl_ops
;
1456 vdev
->release
= video_device_release
;
1457 vdev
->tvnorms
= V4L2_STD_UNKNOWN
;
1465 * Called from soc_camera_probe() above (with .video_lock held???)
1467 static int soc_camera_video_start(struct soc_camera_device
*icd
)
1469 struct device_type
*type
= icd
->vdev
->dev
.type
;
1472 if (!icd
->dev
.parent
)
1476 !icd
->ops
->query_bus_param
||
1477 !icd
->ops
->set_bus_param
)
1480 ret
= video_register_device(icd
->vdev
, VFL_TYPE_GRABBER
, -1);
1482 dev_err(&icd
->dev
, "video_register_device failed: %d\n", ret
);
1486 /* Restore device type, possibly set by the subdevice driver */
1487 icd
->vdev
->dev
.type
= type
;
1492 static int __devinit
soc_camera_pdrv_probe(struct platform_device
*pdev
)
1494 struct soc_camera_link
*icl
= pdev
->dev
.platform_data
;
1495 struct soc_camera_device
*icd
;
1501 icd
= kzalloc(sizeof(*icd
), GFP_KERNEL
);
1505 icd
->iface
= icl
->bus_id
;
1506 icd
->pdev
= &pdev
->dev
;
1507 platform_set_drvdata(pdev
, icd
);
1509 ret
= soc_camera_device_register(icd
);
1513 soc_camera_device_init(&icd
->dev
, icl
);
1515 icd
->user_width
= DEFAULT_WIDTH
;
1516 icd
->user_height
= DEFAULT_HEIGHT
;
1527 * Only called on rmmod for each platform device, since they are not
1528 * hot-pluggable. Now we know, that all our users - hosts and devices have
1529 * been unloaded already
1531 static int __devexit
soc_camera_pdrv_remove(struct platform_device
*pdev
)
1533 struct soc_camera_device
*icd
= platform_get_drvdata(pdev
);
1538 soc_camera_device_unregister(icd
);
1545 static struct platform_driver __refdata soc_camera_pdrv
= {
1546 .remove
= __devexit_p(soc_camera_pdrv_remove
),
1548 .name
= "soc-camera-pdrv",
1549 .owner
= THIS_MODULE
,
1553 static int __init
soc_camera_init(void)
1555 int ret
= bus_register(&soc_camera_bus_type
);
1558 ret
= driver_register(&ic_drv
);
1562 ret
= platform_driver_probe(&soc_camera_pdrv
, soc_camera_pdrv_probe
);
1569 driver_unregister(&ic_drv
);
1571 bus_unregister(&soc_camera_bus_type
);
1575 static void __exit
soc_camera_exit(void)
1577 platform_driver_unregister(&soc_camera_pdrv
);
1578 driver_unregister(&ic_drv
);
1579 bus_unregister(&soc_camera_bus_type
);
1582 module_init(soc_camera_init
);
1583 module_exit(soc_camera_exit
);
1585 MODULE_DESCRIPTION("Image capture bus driver");
1586 MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
1587 MODULE_LICENSE("GPL");
1588 MODULE_ALIAS("platform:soc-camera-pdrv");