2 * S5P/EXYNOS4 SoC series camera host interface media device driver
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Contact: Sylwester Nawrocki, <s.nawrocki@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 2 of the License,
10 * or (at your option) any later version.
13 #include <linux/bug.h>
14 #include <linux/device.h>
15 #include <linux/errno.h>
16 #include <linux/i2c.h>
17 #include <linux/kernel.h>
18 #include <linux/list.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/pm_runtime.h>
22 #include <linux/types.h>
23 #include <linux/slab.h>
24 #include <linux/version.h>
25 #include <media/v4l2-ctrls.h>
26 #include <media/media-device.h>
28 #include "fimc-core.h"
29 #include "fimc-mdevice.h"
30 #include "mipi-csis.h"
32 static int __fimc_md_set_camclk(struct fimc_md
*fmd
,
33 struct fimc_sensor_info
*s_info
,
36 * fimc_pipeline_prepare - update pipeline information with subdevice pointers
37 * @fimc: fimc device terminating the pipeline
39 * Caller holds the graph mutex.
41 void fimc_pipeline_prepare(struct fimc_dev
*fimc
, struct media_entity
*me
)
43 struct media_entity_graph graph
;
44 struct v4l2_subdev
*sd
;
46 media_entity_graph_walk_start(&graph
, me
);
48 while ((me
= media_entity_graph_walk_next(&graph
))) {
49 if (media_entity_type(me
) != MEDIA_ENT_T_V4L2_SUBDEV
)
51 sd
= media_entity_to_v4l2_subdev(me
);
53 if (sd
->grp_id
== SENSOR_GROUP_ID
)
54 fimc
->pipeline
.sensor
= sd
;
55 else if (sd
->grp_id
== CSIS_GROUP_ID
)
56 fimc
->pipeline
.csis
= sd
;
61 * __subdev_set_power - change power state of a single subdev
62 * @sd: subdevice to change power state for
63 * @on: 1 to enable power or 0 to disable
65 * Return result of s_power subdev operation or -ENXIO if sd argument
66 * is NULL. Return 0 if the subdevice does not implement s_power.
68 static int __subdev_set_power(struct v4l2_subdev
*sd
, int on
)
76 use_count
= &sd
->entity
.use_count
;
77 if (on
&& (*use_count
)++ > 0)
79 else if (!on
&& (*use_count
== 0 || --(*use_count
) > 0))
81 ret
= v4l2_subdev_call(sd
, core
, s_power
, on
);
83 return ret
!= -ENOIOCTLCMD
? ret
: 0;
87 * fimc_pipeline_s_power - change power state of all pipeline subdevs
88 * @fimc: fimc device terminating the pipeline
89 * @state: 1 to enable power or 0 for power down
91 * Need to be called with the graph mutex held.
93 int fimc_pipeline_s_power(struct fimc_dev
*fimc
, int state
)
97 if (fimc
->pipeline
.sensor
== NULL
)
101 ret
= __subdev_set_power(fimc
->pipeline
.csis
, 1);
102 if (ret
&& ret
!= -ENXIO
)
104 return __subdev_set_power(fimc
->pipeline
.sensor
, 1);
107 ret
= __subdev_set_power(fimc
->pipeline
.sensor
, 0);
110 ret
= __subdev_set_power(fimc
->pipeline
.csis
, 0);
112 return ret
== -ENXIO
? 0 : ret
;
116 * __fimc_pipeline_initialize - update the pipeline information, enable power
117 * of all pipeline subdevs and the sensor clock
118 * @me: media entity to start graph walk with
119 * @prep: true to acquire sensor (and csis) subdevs
121 * This function must be called with the graph mutex held.
123 static int __fimc_pipeline_initialize(struct fimc_dev
*fimc
,
124 struct media_entity
*me
, bool prep
)
129 fimc_pipeline_prepare(fimc
, me
);
130 if (fimc
->pipeline
.sensor
== NULL
)
132 ret
= fimc_md_set_camclk(fimc
->pipeline
.sensor
, true);
135 return fimc_pipeline_s_power(fimc
, 1);
138 int fimc_pipeline_initialize(struct fimc_dev
*fimc
, struct media_entity
*me
,
143 mutex_lock(&me
->parent
->graph_mutex
);
144 ret
= __fimc_pipeline_initialize(fimc
, me
, prep
);
145 mutex_unlock(&me
->parent
->graph_mutex
);
151 * __fimc_pipeline_shutdown - disable the sensor clock and pipeline power
152 * @fimc: fimc device terminating the pipeline
154 * Disable power of all subdevs in the pipeline and turn off the external
156 * Called with the graph mutex held.
158 int __fimc_pipeline_shutdown(struct fimc_dev
*fimc
)
162 if (fimc
->pipeline
.sensor
) {
163 ret
= fimc_pipeline_s_power(fimc
, 0);
164 fimc_md_set_camclk(fimc
->pipeline
.sensor
, false);
166 return ret
== -ENXIO
? 0 : ret
;
169 int fimc_pipeline_shutdown(struct fimc_dev
*fimc
)
171 struct media_entity
*me
= &fimc
->vid_cap
.vfd
->entity
;
174 mutex_lock(&me
->parent
->graph_mutex
);
175 ret
= __fimc_pipeline_shutdown(fimc
);
176 mutex_unlock(&me
->parent
->graph_mutex
);
182 * fimc_pipeline_s_stream - invoke s_stream on pipeline subdevs
183 * @fimc: fimc device terminating the pipeline
184 * @on: passed as the s_stream call argument
186 int fimc_pipeline_s_stream(struct fimc_dev
*fimc
, int on
)
188 struct fimc_pipeline
*p
= &fimc
->pipeline
;
191 if (p
->sensor
== NULL
)
194 if ((on
&& p
->csis
) || !on
)
195 ret
= v4l2_subdev_call(on
? p
->csis
: p
->sensor
,
196 video
, s_stream
, on
);
197 if (ret
< 0 && ret
!= -ENOIOCTLCMD
)
199 if ((!on
&& p
->csis
) || on
)
200 ret
= v4l2_subdev_call(on
? p
->sensor
: p
->csis
,
201 video
, s_stream
, on
);
202 return ret
== -ENOIOCTLCMD
? 0 : ret
;
206 * Sensor subdevice helper functions
208 static struct v4l2_subdev
*fimc_md_register_sensor(struct fimc_md
*fmd
,
209 struct fimc_sensor_info
*s_info
)
211 struct i2c_adapter
*adapter
;
212 struct v4l2_subdev
*sd
= NULL
;
217 adapter
= i2c_get_adapter(s_info
->pdata
->i2c_bus_num
);
220 sd
= v4l2_i2c_new_subdev_board(&fmd
->v4l2_dev
, adapter
,
221 s_info
->pdata
->board_info
, NULL
);
222 if (IS_ERR_OR_NULL(sd
)) {
223 v4l2_err(&fmd
->v4l2_dev
, "Failed to acquire subdev\n");
226 v4l2_set_subdev_hostdata(sd
, s_info
);
227 sd
->grp_id
= SENSOR_GROUP_ID
;
229 v4l2_info(&fmd
->v4l2_dev
, "Registered sensor subdevice %s\n",
230 s_info
->pdata
->board_info
->type
);
234 static void fimc_md_unregister_sensor(struct v4l2_subdev
*sd
)
236 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
240 v4l2_device_unregister_subdev(sd
);
241 i2c_unregister_device(client
);
242 i2c_put_adapter(client
->adapter
);
245 static int fimc_md_register_sensor_entities(struct fimc_md
*fmd
)
247 struct s5p_platform_fimc
*pdata
= fmd
->pdev
->dev
.platform_data
;
248 struct fimc_dev
*fd
= NULL
;
249 int num_clients
, ret
, i
;
252 * Runtime resume one of the FIMC entities to make sure
253 * the sclk_cam clocks are not globally disabled.
255 for (i
= 0; !fd
&& i
< ARRAY_SIZE(fmd
->fimc
); i
++)
260 ret
= pm_runtime_get_sync(&fd
->pdev
->dev
);
264 WARN_ON(pdata
->num_clients
> ARRAY_SIZE(fmd
->sensor
));
265 num_clients
= min_t(u32
, pdata
->num_clients
, ARRAY_SIZE(fmd
->sensor
));
267 fmd
->num_sensors
= num_clients
;
268 for (i
= 0; i
< num_clients
; i
++) {
269 fmd
->sensor
[i
].pdata
= &pdata
->isp_info
[i
];
270 ret
= __fimc_md_set_camclk(fmd
, &fmd
->sensor
[i
], true);
273 fmd
->sensor
[i
].subdev
=
274 fimc_md_register_sensor(fmd
, &fmd
->sensor
[i
]);
275 ret
= __fimc_md_set_camclk(fmd
, &fmd
->sensor
[i
], false);
279 pm_runtime_put(&fd
->pdev
->dev
);
284 * MIPI CSIS and FIMC platform devices registration.
286 static int fimc_register_callback(struct device
*dev
, void *p
)
288 struct fimc_dev
*fimc
= dev_get_drvdata(dev
);
289 struct fimc_md
*fmd
= p
;
292 if (!fimc
|| !fimc
->pdev
)
294 if (fimc
->pdev
->id
< 0 || fimc
->pdev
->id
>= FIMC_MAX_DEVS
)
297 fmd
->fimc
[fimc
->pdev
->id
] = fimc
;
298 ret
= fimc_register_m2m_device(fimc
, &fmd
->v4l2_dev
);
301 ret
= fimc_register_capture_device(fimc
, &fmd
->v4l2_dev
);
303 fimc
->vid_cap
.user_subdev_api
= fmd
->user_subdev_api
;
307 static int csis_register_callback(struct device
*dev
, void *p
)
309 struct v4l2_subdev
*sd
= dev_get_drvdata(dev
);
310 struct platform_device
*pdev
;
311 struct fimc_md
*fmd
= p
;
316 pdev
= v4l2_get_subdevdata(sd
);
317 if (!pdev
|| pdev
->id
< 0 || pdev
->id
>= CSIS_MAX_ENTITIES
)
319 v4l2_info(sd
, "csis%d sd: %s\n", pdev
->id
, sd
->name
);
321 id
= pdev
->id
< 0 ? 0 : pdev
->id
;
322 fmd
->csis
[id
].sd
= sd
;
323 sd
->grp_id
= CSIS_GROUP_ID
;
324 ret
= v4l2_device_register_subdev(&fmd
->v4l2_dev
, sd
);
326 v4l2_err(&fmd
->v4l2_dev
,
327 "Failed to register CSIS subdevice: %d\n", ret
);
332 * fimc_md_register_platform_entities - register FIMC and CSIS media entities
334 static int fimc_md_register_platform_entities(struct fimc_md
*fmd
)
336 struct device_driver
*driver
;
339 driver
= driver_find(FIMC_MODULE_NAME
, &platform_bus_type
);
342 ret
= driver_for_each_device(driver
, NULL
, fmd
,
343 fimc_register_callback
);
348 driver
= driver_find(CSIS_DRIVER_NAME
, &platform_bus_type
);
350 ret
= driver_for_each_device(driver
, NULL
, fmd
,
351 csis_register_callback
);
357 static void fimc_md_unregister_entities(struct fimc_md
*fmd
)
361 for (i
= 0; i
< FIMC_MAX_DEVS
; i
++) {
362 if (fmd
->fimc
[i
] == NULL
)
364 fimc_unregister_m2m_device(fmd
->fimc
[i
]);
365 fimc_unregister_capture_device(fmd
->fimc
[i
]);
368 for (i
= 0; i
< CSIS_MAX_ENTITIES
; i
++) {
369 if (fmd
->csis
[i
].sd
== NULL
)
371 v4l2_device_unregister_subdev(fmd
->csis
[i
].sd
);
372 fmd
->csis
[i
].sd
= NULL
;
374 for (i
= 0; i
< fmd
->num_sensors
; i
++) {
375 if (fmd
->sensor
[i
].subdev
== NULL
)
377 fimc_md_unregister_sensor(fmd
->sensor
[i
].subdev
);
378 fmd
->sensor
[i
].subdev
= NULL
;
382 static int fimc_md_register_video_nodes(struct fimc_md
*fmd
)
386 for (i
= 0; i
< FIMC_MAX_DEVS
&& !ret
; i
++) {
390 if (fmd
->fimc
[i
]->m2m
.vfd
)
391 ret
= video_register_device(fmd
->fimc
[i
]->m2m
.vfd
,
392 VFL_TYPE_GRABBER
, -1);
395 if (fmd
->fimc
[i
]->vid_cap
.vfd
)
396 ret
= video_register_device(fmd
->fimc
[i
]->vid_cap
.vfd
,
397 VFL_TYPE_GRABBER
, -1);
404 * __fimc_md_create_fimc_links - create links to all FIMC entities
405 * @fmd: fimc media device
406 * @source: the source entity to create links to all fimc entities from
407 * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null
408 * @pad: the source entity pad index
409 * @fimc_id: index of the fimc device for which link should be enabled
411 static int __fimc_md_create_fimc_links(struct fimc_md
*fmd
,
412 struct media_entity
*source
,
413 struct v4l2_subdev
*sensor
,
414 int pad
, int fimc_id
)
416 struct fimc_sensor_info
*s_info
;
417 struct media_entity
*sink
;
421 for (i
= 0; i
< FIMC_MAX_DEVS
; i
++) {
425 * Some FIMC variants are not fitted with camera capture
426 * interface. Skip creating a link from sensor for those.
428 if (sensor
->grp_id
== SENSOR_GROUP_ID
&&
429 !fmd
->fimc
[i
]->variant
->has_cam_if
)
432 flags
= (i
== fimc_id
) ? MEDIA_LNK_FL_ENABLED
: 0;
433 sink
= &fmd
->fimc
[i
]->vid_cap
.subdev
->entity
;
434 ret
= media_entity_create_link(source
, pad
, sink
,
435 FIMC_SD_PAD_SINK
, flags
);
439 /* Notify FIMC capture subdev entity */
440 ret
= media_entity_call(sink
, link_setup
, &sink
->pads
[0],
441 &source
->pads
[pad
], flags
);
445 v4l2_info(&fmd
->v4l2_dev
, "created link [%s] %c> [%s]",
446 source
->name
, flags
? '=' : '-', sink
->name
);
450 s_info
= v4l2_get_subdev_hostdata(sensor
);
451 if (!WARN_ON(s_info
== NULL
)) {
452 unsigned long irq_flags
;
453 spin_lock_irqsave(&fmd
->slock
, irq_flags
);
454 s_info
->host
= fmd
->fimc
[i
];
455 spin_unlock_irqrestore(&fmd
->slock
, irq_flags
);
462 * fimc_md_create_links - create default links between registered entities
464 * Parallel interface sensor entities are connected directly to FIMC capture
465 * entities. The sensors using MIPI CSIS bus are connected through immutable
466 * link with CSI receiver entity specified by mux_id. Any registered CSIS
467 * entity has a link to each registered FIMC capture entity. Enabled links
468 * are created by default between each subsequent registered sensor and
469 * subsequent FIMC capture entity. The number of default active links is
470 * determined by the number of available sensors or FIMC entities,
473 static int fimc_md_create_links(struct fimc_md
*fmd
)
475 struct v4l2_subdev
*sensor
, *csis
;
476 struct s5p_fimc_isp_info
*pdata
;
477 struct fimc_sensor_info
*s_info
;
478 struct media_entity
*source
, *sink
;
479 int i
, pad
, fimc_id
= 0;
483 for (i
= 0; i
< fmd
->num_sensors
; i
++) {
484 if (fmd
->sensor
[i
].subdev
== NULL
)
487 sensor
= fmd
->sensor
[i
].subdev
;
488 s_info
= v4l2_get_subdev_hostdata(sensor
);
489 if (!s_info
|| !s_info
->pdata
)
493 pdata
= s_info
->pdata
;
495 switch (pdata
->bus_type
) {
497 if (WARN(pdata
->mux_id
>= CSIS_MAX_ENTITIES
,
498 "Wrong CSI channel id: %d\n", pdata
->mux_id
))
501 csis
= fmd
->csis
[pdata
->mux_id
].sd
;
502 if (WARN(csis
== NULL
,
503 "MIPI-CSI interface specified "
504 "but s5p-csis module is not loaded!\n"))
507 ret
= media_entity_create_link(&sensor
->entity
, 0,
508 &csis
->entity
, CSIS_PAD_SINK
,
509 MEDIA_LNK_FL_IMMUTABLE
|
510 MEDIA_LNK_FL_ENABLED
);
514 v4l2_info(&fmd
->v4l2_dev
, "created link [%s] => [%s]",
515 sensor
->entity
.name
, csis
->entity
.name
);
517 source
= &csis
->entity
;
518 pad
= CSIS_PAD_SOURCE
;
521 case FIMC_ITU_601
...FIMC_ITU_656
:
522 source
= &sensor
->entity
;
527 v4l2_err(&fmd
->v4l2_dev
, "Wrong bus_type: %x\n",
534 ret
= __fimc_md_create_fimc_links(fmd
, source
, sensor
, pad
,
537 /* Create immutable links between each FIMC's subdev and video node */
538 flags
= MEDIA_LNK_FL_IMMUTABLE
| MEDIA_LNK_FL_ENABLED
;
539 for (i
= 0; i
< FIMC_MAX_DEVS
; i
++) {
542 source
= &fmd
->fimc
[i
]->vid_cap
.subdev
->entity
;
543 sink
= &fmd
->fimc
[i
]->vid_cap
.vfd
->entity
;
544 ret
= media_entity_create_link(source
, FIMC_SD_PAD_SOURCE
,
554 * The peripheral sensor clock management.
556 static int fimc_md_get_clocks(struct fimc_md
*fmd
)
562 for (i
= 0; i
< FIMC_MAX_CAMCLKS
; i
++) {
563 snprintf(clk_name
, sizeof(clk_name
), "sclk_cam%u", i
);
564 clock
= clk_get(NULL
, clk_name
);
565 if (IS_ERR_OR_NULL(clock
)) {
566 v4l2_err(&fmd
->v4l2_dev
, "Failed to get clock: %s",
570 fmd
->camclk
[i
].clock
= clock
;
575 static void fimc_md_put_clocks(struct fimc_md
*fmd
)
577 int i
= FIMC_MAX_CAMCLKS
;
580 if (IS_ERR_OR_NULL(fmd
->camclk
[i
].clock
))
582 clk_put(fmd
->camclk
[i
].clock
);
583 fmd
->camclk
[i
].clock
= NULL
;
587 static int __fimc_md_set_camclk(struct fimc_md
*fmd
,
588 struct fimc_sensor_info
*s_info
,
591 struct s5p_fimc_isp_info
*pdata
= s_info
->pdata
;
592 struct fimc_camclk_info
*camclk
;
595 if (WARN_ON(pdata
->clk_id
>= FIMC_MAX_CAMCLKS
) || fmd
== NULL
)
598 if (s_info
->clk_on
== on
)
600 camclk
= &fmd
->camclk
[pdata
->clk_id
];
602 dbg("camclk %d, f: %lu, clk: %p, on: %d",
603 pdata
->clk_id
, pdata
->clk_frequency
, camclk
, on
);
606 if (camclk
->use_count
> 0 &&
607 camclk
->frequency
!= pdata
->clk_frequency
)
610 if (camclk
->use_count
++ == 0) {
611 clk_set_rate(camclk
->clock
, pdata
->clk_frequency
);
612 camclk
->frequency
= pdata
->clk_frequency
;
613 ret
= clk_enable(camclk
->clock
);
616 dbg("Enabled camclk %d: f: %lu", pdata
->clk_id
,
617 clk_get_rate(camclk
->clock
));
622 if (WARN_ON(camclk
->use_count
== 0))
625 if (--camclk
->use_count
== 0) {
626 clk_disable(camclk
->clock
);
628 dbg("Disabled camclk %d", pdata
->clk_id
);
634 * fimc_md_set_camclk - peripheral sensor clock setup
635 * @sd: sensor subdev to configure sclk_cam clock for
636 * @on: 1 to enable or 0 to disable the clock
638 * There are 2 separate clock outputs available in the SoC for external
639 * image processors. These clocks are shared between all registered FIMC
640 * devices to which sensors can be attached, either directly or through
641 * the MIPI CSI receiver. The clock is allowed here to be used by
642 * multiple sensors concurrently if they use same frequency.
643 * The per sensor subdev clk_on attribute helps to synchronize accesses
644 * to the sclk_cam clocks from the video and media device nodes.
645 * This function should only be called when the graph mutex is held.
647 int fimc_md_set_camclk(struct v4l2_subdev
*sd
, bool on
)
649 struct fimc_sensor_info
*s_info
= v4l2_get_subdev_hostdata(sd
);
650 struct fimc_md
*fmd
= entity_to_fimc_mdev(&sd
->entity
);
652 return __fimc_md_set_camclk(fmd
, s_info
, on
);
655 static int fimc_md_link_notify(struct media_pad
*source
,
656 struct media_pad
*sink
, u32 flags
)
658 struct v4l2_subdev
*sd
;
659 struct fimc_dev
*fimc
;
662 if (media_entity_type(sink
->entity
) != MEDIA_ENT_T_V4L2_SUBDEV
)
665 sd
= media_entity_to_v4l2_subdev(sink
->entity
);
666 fimc
= v4l2_get_subdevdata(sd
);
668 if (!(flags
& MEDIA_LNK_FL_ENABLED
)) {
669 ret
= __fimc_pipeline_shutdown(fimc
);
670 fimc
->pipeline
.sensor
= NULL
;
671 fimc
->pipeline
.csis
= NULL
;
673 mutex_lock(&fimc
->lock
);
674 fimc_ctrls_delete(fimc
->vid_cap
.ctx
);
675 mutex_unlock(&fimc
->lock
);
679 * Link activation. Enable power of pipeline elements only if the
680 * pipeline is already in use, i.e. its video node is opened.
681 * Recreate the controls destroyed during the link deactivation.
683 mutex_lock(&fimc
->lock
);
684 if (fimc
->vid_cap
.refcnt
> 0) {
685 ret
= __fimc_pipeline_initialize(fimc
, source
->entity
, true);
687 ret
= fimc_capture_ctrls_create(fimc
);
689 mutex_unlock(&fimc
->lock
);
691 return ret
? -EPIPE
: ret
;
694 static ssize_t
fimc_md_sysfs_show(struct device
*dev
,
695 struct device_attribute
*attr
, char *buf
)
697 struct platform_device
*pdev
= to_platform_device(dev
);
698 struct fimc_md
*fmd
= platform_get_drvdata(pdev
);
700 if (fmd
->user_subdev_api
)
701 return strlcpy(buf
, "Sub-device API (sub-dev)\n", PAGE_SIZE
);
703 return strlcpy(buf
, "V4L2 video node only API (vid-dev)\n", PAGE_SIZE
);
706 static ssize_t
fimc_md_sysfs_store(struct device
*dev
,
707 struct device_attribute
*attr
,
708 const char *buf
, size_t count
)
710 struct platform_device
*pdev
= to_platform_device(dev
);
711 struct fimc_md
*fmd
= platform_get_drvdata(pdev
);
715 if (!strcmp(buf
, "vid-dev\n"))
717 else if (!strcmp(buf
, "sub-dev\n"))
722 fmd
->user_subdev_api
= subdev_api
;
723 for (i
= 0; i
< FIMC_MAX_DEVS
; i
++)
725 fmd
->fimc
[i
]->vid_cap
.user_subdev_api
= subdev_api
;
729 * This device attribute is to select video pipeline configuration method.
730 * There are following valid values:
731 * vid-dev - for V4L2 video node API only, subdevice will be configured
732 * by the host driver.
733 * sub-dev - for media controller API, subdevs must be configured in user
734 * space before starting streaming.
736 static DEVICE_ATTR(subdev_conf_mode
, S_IWUSR
| S_IRUGO
,
737 fimc_md_sysfs_show
, fimc_md_sysfs_store
);
739 static int __devinit
fimc_md_probe(struct platform_device
*pdev
)
741 struct v4l2_device
*v4l2_dev
;
745 if (WARN(!pdev
->dev
.platform_data
, "Platform data not specified!\n"))
748 fmd
= kzalloc(sizeof(struct fimc_md
), GFP_KERNEL
);
752 spin_lock_init(&fmd
->slock
);
755 strlcpy(fmd
->media_dev
.model
, "SAMSUNG S5P FIMC",
756 sizeof(fmd
->media_dev
.model
));
757 fmd
->media_dev
.link_notify
= fimc_md_link_notify
;
758 fmd
->media_dev
.dev
= &pdev
->dev
;
760 v4l2_dev
= &fmd
->v4l2_dev
;
761 v4l2_dev
->mdev
= &fmd
->media_dev
;
762 v4l2_dev
->notify
= fimc_sensor_notify
;
763 snprintf(v4l2_dev
->name
, sizeof(v4l2_dev
->name
), "%s",
764 dev_name(&pdev
->dev
));
766 ret
= v4l2_device_register(&pdev
->dev
, &fmd
->v4l2_dev
);
768 v4l2_err(v4l2_dev
, "Failed to register v4l2_device: %d\n", ret
);
771 ret
= media_device_register(&fmd
->media_dev
);
773 v4l2_err(v4l2_dev
, "Failed to register media device: %d\n", ret
);
776 ret
= fimc_md_get_clocks(fmd
);
780 fmd
->user_subdev_api
= false;
781 ret
= fimc_md_register_platform_entities(fmd
);
785 ret
= fimc_md_register_sensor_entities(fmd
);
788 ret
= fimc_md_create_links(fmd
);
791 ret
= v4l2_device_register_subdev_nodes(&fmd
->v4l2_dev
);
794 ret
= fimc_md_register_video_nodes(fmd
);
798 ret
= device_create_file(&pdev
->dev
, &dev_attr_subdev_conf_mode
);
800 platform_set_drvdata(pdev
, fmd
);
804 media_device_unregister(&fmd
->media_dev
);
805 fimc_md_put_clocks(fmd
);
806 fimc_md_unregister_entities(fmd
);
808 v4l2_device_unregister(&fmd
->v4l2_dev
);
814 static int __devexit
fimc_md_remove(struct platform_device
*pdev
)
816 struct fimc_md
*fmd
= platform_get_drvdata(pdev
);
820 device_remove_file(&pdev
->dev
, &dev_attr_subdev_conf_mode
);
821 fimc_md_unregister_entities(fmd
);
822 media_device_unregister(&fmd
->media_dev
);
823 fimc_md_put_clocks(fmd
);
828 static struct platform_driver fimc_md_driver
= {
829 .probe
= fimc_md_probe
,
830 .remove
= __devexit_p(fimc_md_remove
),
832 .name
= "s5p-fimc-md",
833 .owner
= THIS_MODULE
,
837 int __init
fimc_md_init(void)
840 request_module("s5p-csis");
841 ret
= fimc_register_driver();
844 return platform_driver_register(&fimc_md_driver
);
846 void __exit
fimc_md_exit(void)
848 platform_driver_unregister(&fimc_md_driver
);
849 fimc_unregister_driver();
852 module_init(fimc_md_init
);
853 module_exit(fimc_md_exit
);
855 MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
856 MODULE_DESCRIPTION("S5P FIMC camera host interface/video postprocessor driver");
857 MODULE_LICENSE("GPL");
858 MODULE_VERSION("2.0.1");