| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * S5P/EXYNOS4 SoC series camera host interface media device driver | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  |  * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. | 
					
						
							|  |  |  |  * Author: Sylwester Nawrocki <s.nawrocki@samsung.com> | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published | 
					
						
							|  |  |  |  * by the Free Software Foundation, either version 2 of the License, | 
					
						
							|  |  |  |  * or (at your option) any later version. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/bug.h>
 | 
					
						
							|  |  |  | #include <linux/device.h>
 | 
					
						
							|  |  |  | #include <linux/errno.h>
 | 
					
						
							|  |  |  | #include <linux/i2c.h>
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/list.h>
 | 
					
						
							|  |  |  | #include <linux/module.h>
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | #include <linux/of.h>
 | 
					
						
							|  |  |  | #include <linux/of_platform.h>
 | 
					
						
							|  |  |  | #include <linux/of_device.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/pm_runtime.h>
 | 
					
						
							|  |  |  | #include <linux/types.h>
 | 
					
						
							|  |  |  | #include <linux/slab.h>
 | 
					
						
							| 
									
										
										
										
											2011-08-24 19:25:10 -03:00
										 |  |  | #include <media/v4l2-ctrls.h>
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | #include <media/v4l2-of.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | #include <media/media-device.h>
 | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  | #include <media/s5p_fimc.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-24 16:54:25 +01:00
										 |  |  | #include "media-dev.h"
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | #include "fimc-core.h"
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | #include "fimc-is.h"
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | #include "fimc-lite.h"
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | #include "mipi-csis.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int __fimc_md_set_camclk(struct fimc_md *fmd, | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 				struct fimc_source_info *si, | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 				bool on); | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Set up image sensor subdev -> FIMC capture node notifications. */ | 
					
						
							|  |  |  | static void __setup_sensor_notification(struct fimc_md *fmd, | 
					
						
							|  |  |  | 					struct v4l2_subdev *sensor, | 
					
						
							|  |  |  | 					struct v4l2_subdev *fimc_sd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct fimc_source_info *src_inf; | 
					
						
							|  |  |  | 	struct fimc_sensor_info *md_si; | 
					
						
							|  |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	src_inf = v4l2_get_subdev_hostdata(sensor); | 
					
						
							|  |  |  | 	if (!src_inf || WARN_ON(fmd == NULL)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	md_si = source_to_sensor_info(src_inf); | 
					
						
							|  |  |  | 	spin_lock_irqsave(&fmd->slock, flags); | 
					
						
							|  |  |  | 	md_si->host = v4l2_get_subdevdata(fimc_sd); | 
					
						
							|  |  |  | 	spin_unlock_irqrestore(&fmd->slock, flags); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * fimc_pipeline_prepare - update pipeline information with subdevice pointers | 
					
						
							| 
									
										
										
										
											2013-03-08 08:58:34 -03:00
										 |  |  |  * @me: media entity terminating the pipeline | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Caller holds the graph mutex. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  | static void fimc_pipeline_prepare(struct fimc_pipeline *p, | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 					struct media_entity *me) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 	struct fimc_md *fmd = entity_to_fimc_mdev(me); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	struct v4l2_subdev *sd; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 	struct v4l2_subdev *sensor = NULL; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	for (i = 0; i < IDX_MAX; i++) | 
					
						
							|  |  |  | 		p->subdevs[i] = NULL; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	while (1) { | 
					
						
							| 
									
										
										
										
											2013-03-08 08:58:34 -03:00
										 |  |  | 		struct media_pad *pad = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Find remote source pad */ | 
					
						
							|  |  |  | 		for (i = 0; i < me->num_pads; i++) { | 
					
						
							|  |  |  | 			struct media_pad *spad = &me->pads[i]; | 
					
						
							|  |  |  | 			if (!(spad->flags & MEDIA_PAD_FL_SINK)) | 
					
						
							|  |  |  | 				continue; | 
					
						
							| 
									
										
										
										
											2013-06-03 05:16:13 -03:00
										 |  |  | 			pad = media_entity_remote_pad(spad); | 
					
						
							| 
									
										
										
										
											2013-03-08 08:58:34 -03:00
										 |  |  | 			if (pad) | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (pad == NULL || | 
					
						
							|  |  |  | 		    media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		sd = media_entity_to_v4l2_subdev(pad->entity); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		switch (sd->grp_id) { | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 		case GRP_ID_SENSOR: | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 			sensor = sd; | 
					
						
							|  |  |  | 			/* fall through */ | 
					
						
							|  |  |  | 		case GRP_ID_FIMC_IS_SENSOR: | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 			p->subdevs[IDX_SENSOR] = sd; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 		case GRP_ID_CSIS: | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 			p->subdevs[IDX_CSIS] = sd; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 		case GRP_ID_FLITE: | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 			p->subdevs[IDX_FLITE] = sd; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 		case GRP_ID_FIMC: | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 			p->subdevs[IDX_FIMC] = sd; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 		case GRP_ID_FIMC_IS: | 
					
						
							|  |  |  | 			p->subdevs[IDX_IS_ISP] = sd; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-03-08 08:58:34 -03:00
										 |  |  | 		me = &sd->entity; | 
					
						
							|  |  |  | 		if (me->num_pads == 1) | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:24 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (sensor && p->subdevs[IDX_FIMC]) | 
					
						
							|  |  |  | 		__setup_sensor_notification(fmd, sensor, p->subdevs[IDX_FIMC]); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * __subdev_set_power - change power state of a single subdev | 
					
						
							|  |  |  |  * @sd: subdevice to change power state for | 
					
						
							|  |  |  |  * @on: 1 to enable power or 0 to disable | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Return result of s_power subdev operation or -ENXIO if sd argument | 
					
						
							|  |  |  |  * is NULL. Return 0 if the subdevice does not implement s_power. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static int __subdev_set_power(struct v4l2_subdev *sd, int on) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int *use_count; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (sd == NULL) | 
					
						
							|  |  |  | 		return -ENXIO; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	use_count = &sd->entity.use_count; | 
					
						
							|  |  |  | 	if (on && (*use_count)++ > 0) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	else if (!on && (*use_count == 0 || --(*use_count) > 0)) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	ret = v4l2_subdev_call(sd, core, s_power, on); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret != -ENOIOCTLCMD ? ret : 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * fimc_pipeline_s_power - change power state of all pipeline subdevs | 
					
						
							|  |  |  |  * @fimc: fimc device terminating the pipeline | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  |  * @state: true to power on, false to power off | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  |  * Needs to be called with the graph mutex held. | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-11-20 08:54:22 -03:00
										 |  |  | static int fimc_pipeline_s_power(struct fimc_pipeline *p, bool on) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-20 08:54:22 -03:00
										 |  |  | 	static const u8 seq[2][IDX_MAX - 1] = { | 
					
						
							|  |  |  | 		{ IDX_IS_ISP, IDX_SENSOR, IDX_CSIS, IDX_FLITE }, | 
					
						
							|  |  |  | 		{ IDX_CSIS, IDX_FLITE, IDX_SENSOR, IDX_IS_ISP }, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	int i, ret = 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	if (p->subdevs[IDX_SENSOR] == NULL) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return -ENXIO; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-20 08:54:22 -03:00
										 |  |  | 	for (i = 0; i < IDX_MAX - 1; i++) { | 
					
						
							|  |  |  | 		unsigned int idx = seq[on][i]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ret = __subdev_set_power(p->subdevs[idx], on); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (ret < 0 && ret != -ENXIO) | 
					
						
							| 
									
										
										
										
											2012-11-20 08:54:22 -03:00
										 |  |  | 			goto error; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2012-11-20 08:54:22 -03:00
										 |  |  | error: | 
					
						
							|  |  |  | 	for (; i >= 0; i--) { | 
					
						
							|  |  |  | 		unsigned int idx = seq[on][i]; | 
					
						
							|  |  |  | 		__subdev_set_power(p->subdevs[idx], !on); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  |  * __fimc_pipeline_open - update the pipeline information, enable power | 
					
						
							|  |  |  |  *                        of all pipeline subdevs and the sensor clock | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * @me: media entity to start graph walk with | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  |  * @prepare: true to walk the current pipeline and acquire all subdevs | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-12-06 10:26:19 -03:00
										 |  |  |  * Called with the graph mutex held. | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | static int __fimc_pipeline_open(struct exynos_media_pipeline *ep, | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 				struct media_entity *me, bool prepare) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	struct fimc_md *fmd = entity_to_fimc_mdev(me); | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct fimc_pipeline *p = to_fimc_pipeline(ep); | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	struct v4l2_subdev *sd; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	if (WARN_ON(p == NULL || me == NULL)) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (prepare) | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 		fimc_pipeline_prepare(p, me); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	sd = p->subdevs[IDX_SENSOR]; | 
					
						
							|  |  |  | 	if (sd == NULL) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return -EINVAL; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	/* Disable PXLASYNC clock if this pipeline includes FIMC-IS */ | 
					
						
							|  |  |  | 	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) { | 
					
						
							|  |  |  | 		ret = clk_prepare_enable(fmd->wbclk[CLK_IDX_WB_B]); | 
					
						
							|  |  |  | 		if (ret < 0) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ret = fimc_md_set_camclk(sd, true); | 
					
						
							|  |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		goto err_wbclk; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = fimc_pipeline_s_power(p, 1); | 
					
						
							|  |  |  | 	if (!ret) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	fimc_md_set_camclk(sd, false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | err_wbclk: | 
					
						
							|  |  |  | 	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) | 
					
						
							|  |  |  | 		clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  |  * __fimc_pipeline_close - disable the sensor clock and pipeline power | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  * @fimc: fimc device terminating the pipeline | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2012-12-06 10:26:19 -03:00
										 |  |  |  * Disable power of all subdevs and turn the external sensor clock off. | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | static int __fimc_pipeline_close(struct exynos_media_pipeline *ep) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct fimc_pipeline *p = to_fimc_pipeline(ep); | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	struct v4l2_subdev *sd = p ? p->subdevs[IDX_SENSOR] : NULL; | 
					
						
							|  |  |  | 	struct fimc_md *fmd; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:23 -03:00
										 |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2012-12-06 10:26:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:23 -03:00
										 |  |  | 	if (sd == NULL) { | 
					
						
							|  |  |  | 		pr_warn("%s(): No sensor subdev\n", __func__); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:23 -03:00
										 |  |  | 	ret = fimc_pipeline_s_power(p, 0); | 
					
						
							|  |  |  | 	fimc_md_set_camclk(sd, false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	fmd = entity_to_fimc_mdev(&sd->entity); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Disable PXLASYNC clock if this pipeline includes FIMC-IS */ | 
					
						
							|  |  |  | 	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) | 
					
						
							|  |  |  | 		clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return ret == -ENXIO ? 0 : ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  |  * __fimc_pipeline_s_stream - call s_stream() on pipeline subdevs | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  |  * @pipeline: video pipeline structure | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  |  * @on: passed as the s_stream() callback argument | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  | 	static const u8 seq[2][IDX_MAX] = { | 
					
						
							|  |  |  | 		{ IDX_FIMC, IDX_SENSOR, IDX_IS_ISP, IDX_CSIS, IDX_FLITE }, | 
					
						
							|  |  |  | 		{ IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP }, | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct fimc_pipeline *p = to_fimc_pipeline(ep); | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  | 	int i, ret = 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	if (p->subdevs[IDX_SENSOR] == NULL) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return -ENODEV; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	for (i = 0; i < IDX_MAX; i++) { | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  | 		unsigned int idx = seq[on][i]; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		ret = v4l2_subdev_call(p->subdevs[idx], video, s_stream, on); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  | 			goto error; | 
					
						
							| 
									
										
										
										
											2012-04-27 09:33:10 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2012-11-13 14:35:22 -03:00
										 |  |  | error: | 
					
						
							|  |  |  | 	for (; i >= 0; i--) { | 
					
						
							|  |  |  | 		unsigned int idx = seq[on][i]; | 
					
						
							|  |  |  | 		v4l2_subdev_call(p->subdevs[idx], video, s_stream, !on); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Media pipeline operations for the FIMC/FIMC-LITE video device driver */ | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | static const struct exynos_media_pipeline_ops fimc_pipeline_ops = { | 
					
						
							| 
									
										
										
										
											2012-12-06 10:26:19 -03:00
										 |  |  | 	.open		= __fimc_pipeline_open, | 
					
						
							|  |  |  | 	.close		= __fimc_pipeline_close, | 
					
						
							|  |  |  | 	.set_stream	= __fimc_pipeline_s_stream, | 
					
						
							| 
									
										
										
										
											2012-08-14 10:46:58 -03:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | static struct exynos_media_pipeline *fimc_md_pipeline_create( | 
					
						
							|  |  |  | 						struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct fimc_pipeline *p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	p = kzalloc(sizeof(*p), GFP_KERNEL); | 
					
						
							|  |  |  | 	if (!p) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	list_add_tail(&p->list, &fmd->pipelines); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	p->ep.ops = &fimc_pipeline_ops; | 
					
						
							|  |  |  | 	return &p->ep; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void fimc_md_pipelines_free(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	while (!list_empty(&fmd->pipelines)) { | 
					
						
							|  |  |  | 		struct fimc_pipeline *p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		p = list_entry(fmd->pipelines.next, typeof(*p), list); | 
					
						
							|  |  |  | 		list_del(&p->list); | 
					
						
							|  |  |  | 		kfree(p); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Sensor subdevice helper functions | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct v4l2_subdev *fimc_md_register_sensor(struct fimc_md *fmd, | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 						struct fimc_source_info *si) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct i2c_adapter *adapter; | 
					
						
							|  |  |  | 	struct v4l2_subdev *sd = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	if (!si || !fmd) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											2013-03-20 10:44:39 -03:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * If FIMC bus type is not Writeback FIFO assume it is same | 
					
						
							|  |  |  | 	 * as sensor_bus_type. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	si->fimc_bus_type = si->sensor_bus_type; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	adapter = i2c_get_adapter(si->i2c_bus_num); | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 	if (!adapter) { | 
					
						
							|  |  |  | 		v4l2_warn(&fmd->v4l2_dev, | 
					
						
							|  |  |  | 			  "Failed to get I2C adapter %d, deferring probe\n", | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			  si->i2c_bus_num); | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 		return ERR_PTR(-EPROBE_DEFER); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	sd = v4l2_i2c_new_subdev_board(&fmd->v4l2_dev, adapter, | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 						si->board_info, NULL); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	if (IS_ERR_OR_NULL(sd)) { | 
					
						
							| 
									
										
										
										
											2011-09-13 14:07:09 -03:00
										 |  |  | 		i2c_put_adapter(adapter); | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 		v4l2_warn(&fmd->v4l2_dev, | 
					
						
							|  |  |  | 			  "Failed to acquire subdev %s, deferring probe\n", | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			  si->board_info->type); | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 		return ERR_PTR(-EPROBE_DEFER); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	v4l2_set_subdev_hostdata(sd, si); | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 	sd->grp_id = GRP_ID_SENSOR; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice %s\n", | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 		  sd->name); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return sd; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void fimc_md_unregister_sensor(struct v4l2_subdev *sd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct i2c_client *client = v4l2_get_subdevdata(sd); | 
					
						
							| 
									
										
										
										
											2011-09-13 14:07:09 -03:00
										 |  |  | 	struct i2c_adapter *adapter; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!client) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	v4l2_device_unregister_subdev(sd); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!client->dev.of_node) { | 
					
						
							|  |  |  | 		adapter = client->adapter; | 
					
						
							|  |  |  | 		i2c_unregister_device(client); | 
					
						
							|  |  |  | 		if (adapter) | 
					
						
							|  |  |  | 			i2c_put_adapter(adapter); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | #ifdef CONFIG_OF
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | /* Register I2C client subdev associated with @node. */ | 
					
						
							|  |  |  | static int fimc_md_of_add_sensor(struct fimc_md *fmd, | 
					
						
							|  |  |  | 				 struct device_node *node, int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct fimc_sensor_info *si; | 
					
						
							|  |  |  | 	struct i2c_client *client; | 
					
						
							|  |  |  | 	struct v4l2_subdev *sd; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 	si = &fmd->sensor[index]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	client = of_find_i2c_device_by_node(node); | 
					
						
							|  |  |  | 	if (!client) | 
					
						
							|  |  |  | 		return -EPROBE_DEFER; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	device_lock(&client->dev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-29 10:51:00 +02:00
										 |  |  | 	if (!client->dev.driver || | 
					
						
							|  |  |  | 	    !try_module_get(client->dev.driver->owner)) { | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 		ret = -EPROBE_DEFER; | 
					
						
							|  |  |  | 		v4l2_info(&fmd->v4l2_dev, "No driver found for %s\n", | 
					
						
							|  |  |  | 						node->full_name); | 
					
						
							|  |  |  | 		goto dev_put; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Enable sensor's master clock */ | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	ret = __fimc_md_set_camclk(fmd, &si->pdata, true); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		goto mod_put; | 
					
						
							|  |  |  | 	sd = i2c_get_clientdata(client); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	__fimc_md_set_camclk(fmd, &si->pdata, false); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		goto mod_put; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	v4l2_set_subdev_hostdata(sd, &si->pdata); | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 	if (si->pdata.fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK) | 
					
						
							|  |  |  | 		sd->grp_id = GRP_ID_FIMC_IS_SENSOR; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		sd->grp_id = GRP_ID_SENSOR; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	si->subdev = sd; | 
					
						
							|  |  |  | 	v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice: %s (%d)\n", | 
					
						
							|  |  |  | 		  sd->name, fmd->num_sensors); | 
					
						
							|  |  |  | 	fmd->num_sensors++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | mod_put: | 
					
						
							| 
									
										
										
										
											2013-09-29 10:51:00 +02:00
										 |  |  | 	module_put(client->dev.driver->owner); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | dev_put: | 
					
						
							|  |  |  | 	device_unlock(&client->dev); | 
					
						
							|  |  |  | 	put_device(&client->dev); | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Parse port node and register as a sub-device any sensor specified there. */ | 
					
						
							|  |  |  | static int fimc_md_parse_port_node(struct fimc_md *fmd, | 
					
						
							|  |  |  | 				   struct device_node *port, | 
					
						
							|  |  |  | 				   unsigned int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct device_node *rem, *ep, *np; | 
					
						
							|  |  |  | 	struct fimc_source_info *pd; | 
					
						
							|  |  |  | 	struct v4l2_of_endpoint endpoint; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 	u32 val; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pd = &fmd->sensor[index].pdata; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Assume here a port node can have only one endpoint node. */ | 
					
						
							|  |  |  | 	ep = of_get_next_child(port, NULL); | 
					
						
							|  |  |  | 	if (!ep) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_of_parse_endpoint(ep, &endpoint); | 
					
						
							|  |  |  | 	if (WARN_ON(endpoint.port == 0) || index >= FIMC_MAX_SENSORS) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pd->mux_id = (endpoint.port - 1) & 0x1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	rem = v4l2_of_get_remote_port_parent(ep); | 
					
						
							|  |  |  | 	of_node_put(ep); | 
					
						
							|  |  |  | 	if (rem == NULL) { | 
					
						
							|  |  |  | 		v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n", | 
					
						
							|  |  |  | 							ep->full_name); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!of_property_read_u32(rem, "samsung,camclk-out", &val)) | 
					
						
							|  |  |  | 		pd->clk_id = val; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!of_property_read_u32(rem, "clock-frequency", &val)) | 
					
						
							|  |  |  | 		pd->clk_frequency = val; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (pd->clk_frequency == 0) { | 
					
						
							|  |  |  | 		v4l2_err(&fmd->v4l2_dev, "Wrong clock frequency at node %s\n", | 
					
						
							|  |  |  | 			 rem->full_name); | 
					
						
							|  |  |  | 		of_node_put(rem); | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (fimc_input_is_parallel(endpoint.port)) { | 
					
						
							|  |  |  | 		if (endpoint.bus_type == V4L2_MBUS_PARALLEL) | 
					
						
							|  |  |  | 			pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656; | 
					
						
							|  |  |  | 		pd->flags = endpoint.bus.parallel.flags; | 
					
						
							|  |  |  | 	} else if (fimc_input_is_mipi_csi(endpoint.port)) { | 
					
						
							|  |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * MIPI CSI-2: only input mux selection and | 
					
						
							|  |  |  | 		 * the sensor's clock frequency is needed. | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n", | 
					
						
							|  |  |  | 			 endpoint.port, rem->full_name); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * For FIMC-IS handled sensors, that are placed under i2c-isp device | 
					
						
							|  |  |  | 	 * node, FIMC is connected to the FIMC-IS through its ISP Writeback | 
					
						
							|  |  |  | 	 * input. Sensors are attached to the FIMC-LITE hostdata interface | 
					
						
							|  |  |  | 	 * directly or through MIPI-CSIS, depending on the external media bus | 
					
						
							|  |  |  | 	 * used. This needs to be handled in a more reliable way, not by just | 
					
						
							|  |  |  | 	 * checking parent's node name. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	np = of_get_parent(rem); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (np && !of_node_cmp(np->name, "i2c-isp")) | 
					
						
							|  |  |  | 		pd->fimc_bus_type = FIMC_BUS_TYPE_ISP_WRITEBACK; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		pd->fimc_bus_type = pd->sensor_bus_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = fimc_md_of_add_sensor(fmd, rem, index); | 
					
						
							|  |  |  | 	of_node_put(rem); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Register all SoC external sub-devices */ | 
					
						
							|  |  |  | static int fimc_md_of_sensors_register(struct fimc_md *fmd, | 
					
						
							|  |  |  | 				       struct device_node *np) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct device_node *parent = fmd->pdev->dev.of_node; | 
					
						
							|  |  |  | 	struct device_node *node, *ports; | 
					
						
							|  |  |  | 	int index = 0; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Attach sensors linked to MIPI CSI-2 receivers */ | 
					
						
							|  |  |  | 	for_each_available_child_of_node(parent, node) { | 
					
						
							|  |  |  | 		struct device_node *port; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (of_node_cmp(node->name, "csis")) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		/* The csis node can have only port subnode. */ | 
					
						
							|  |  |  | 		port = of_get_next_child(node, NULL); | 
					
						
							|  |  |  | 		if (!port) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ret = fimc_md_parse_port_node(fmd, port, index); | 
					
						
							|  |  |  | 		if (ret < 0) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							|  |  |  | 		index++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Attach sensors listed in the parallel-ports node */ | 
					
						
							|  |  |  | 	ports = of_get_child_by_name(parent, "parallel-ports"); | 
					
						
							|  |  |  | 	if (!ports) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for_each_child_of_node(ports, node) { | 
					
						
							|  |  |  | 		ret = fimc_md_parse_port_node(fmd, node, index); | 
					
						
							|  |  |  | 		if (ret < 0) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		index++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | static int __of_get_csis_id(struct device_node *np) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 reg = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	np = of_get_child_by_name(np, "port"); | 
					
						
							|  |  |  | 	if (!np) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 	of_property_read_u32(np, "reg", ®); | 
					
						
							|  |  |  | 	return reg - FIMC_INPUT_MIPI_CSI2_0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | #define fimc_md_of_sensors_register(fmd, np) (-ENOSYS)
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | #define __of_get_csis_id(np) (-ENOSYS)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | static int fimc_md_register_sensor_entities(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct s5p_platform_fimc *pdata = fmd->pdev->dev.platform_data; | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	struct device_node *of_node = fmd->pdev->dev.of_node; | 
					
						
							|  |  |  | 	int num_clients = 0; | 
					
						
							|  |  |  | 	int ret, i; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Runtime resume one of the FIMC entities to make sure | 
					
						
							|  |  |  | 	 * the sclk_cam clocks are not globally disabled. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 	if (!fmd->pmf) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return -ENXIO; | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 	ret = pm_runtime_get_sync(fmd->pmf); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	if (of_node) { | 
					
						
							|  |  |  | 		fmd->num_sensors = 0; | 
					
						
							|  |  |  | 		ret = fimc_md_of_sensors_register(fmd, of_node); | 
					
						
							|  |  |  | 	} else if (pdata) { | 
					
						
							|  |  |  | 		WARN_ON(pdata->num_clients > ARRAY_SIZE(fmd->sensor)); | 
					
						
							|  |  |  | 		num_clients = min_t(u32, pdata->num_clients, | 
					
						
							|  |  |  | 				    ARRAY_SIZE(fmd->sensor)); | 
					
						
							|  |  |  | 		fmd->num_sensors = num_clients; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 		for (i = 0; i < num_clients; i++) { | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			struct fimc_sensor_info *si = &fmd->sensor[i]; | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 			struct v4l2_subdev *sd; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			si->pdata = pdata->source_info[i]; | 
					
						
							|  |  |  | 			ret = __fimc_md_set_camclk(fmd, &si->pdata, true); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 			if (ret) | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			sd = fimc_md_register_sensor(fmd, &si->pdata); | 
					
						
							|  |  |  | 			ret = __fimc_md_set_camclk(fmd, &si->pdata, false); | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			if (IS_ERR(sd)) { | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 				si->subdev = NULL; | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 				ret = PTR_ERR(sd); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			si->subdev = sd; | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 			if (ret) | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 	pm_runtime_put(fmd->pmf); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  |  * MIPI-CSIS, FIMC and FIMC-LITE platform devices registration. | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int register_fimc_lite_entity(struct fimc_md *fmd, | 
					
						
							|  |  |  | 				     struct fimc_lite *fimc_lite) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-25 10:56:00 -03:00
										 |  |  | 	struct v4l2_subdev *sd; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct exynos_media_pipeline *ep; | 
					
						
							| 
									
										
										
										
											2012-10-25 10:48:44 -03:00
										 |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	if (WARN_ON(fimc_lite->index >= FIMC_LITE_MAX_DEVS || | 
					
						
							|  |  |  | 		    fmd->fimc_lite[fimc_lite->index])) | 
					
						
							|  |  |  | 		return -EBUSY; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	sd = &fimc_lite->subdev; | 
					
						
							|  |  |  | 	sd->grp_id = GRP_ID_FLITE; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ep = fimc_md_pipeline_create(fmd); | 
					
						
							|  |  |  | 	if (!ep) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_set_subdev_hostdata(sd, ep); | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	if (!ret) | 
					
						
							|  |  |  | 		fmd->fimc_lite[fimc_lite->index] = fimc_lite; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.LITE%d\n", | 
					
						
							|  |  |  | 			 fimc_lite->index); | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	struct v4l2_subdev *sd; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct exynos_media_pipeline *ep; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	if (WARN_ON(fimc->id >= FIMC_MAX_DEVS || fmd->fimc[fimc->id])) | 
					
						
							|  |  |  | 		return -EBUSY; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	sd = &fimc->vid_cap.subdev; | 
					
						
							|  |  |  | 	sd->grp_id = GRP_ID_FIMC; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ep = fimc_md_pipeline_create(fmd); | 
					
						
							|  |  |  | 	if (!ep) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_set_subdev_hostdata(sd, ep); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 
					
						
							|  |  |  | 	if (!ret) { | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 		if (!fmd->pmf && fimc->pdev) | 
					
						
							|  |  |  | 			fmd->pmf = &fimc->pdev->dev; | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 		fmd->fimc[fimc->id] = fimc; | 
					
						
							|  |  |  | 		fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", | 
					
						
							|  |  |  | 			 fimc->id, ret); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | static int register_csis_entity(struct fimc_md *fmd, | 
					
						
							|  |  |  | 				struct platform_device *pdev, | 
					
						
							|  |  |  | 				struct v4l2_subdev *sd) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	struct device_node *node = pdev->dev.of_node; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	int id, ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	id = node ? __of_get_csis_id(node) : max(0, pdev->id); | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	if (WARN_ON(id < 0 || id >= CSIS_MAX_ENTITIES)) | 
					
						
							|  |  |  | 		return -ENOENT; | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	if (WARN_ON(fmd->csis[id].sd)) | 
					
						
							|  |  |  | 		return -EBUSY; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-27 11:57:42 -03:00
										 |  |  | 	sd->grp_id = GRP_ID_CSIS; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 
					
						
							| 
									
										
										
										
											2012-10-25 10:48:44 -03:00
										 |  |  | 	if (!ret) | 
					
						
							|  |  |  | 		fmd->csis[id].sd = sd; | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		v4l2_err(&fmd->v4l2_dev, | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 			 "Failed to register MIPI-CSIS.%d (%d)\n", id, ret); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct v4l2_subdev *sd = &is->isp.subdev; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); | 
					
						
							|  |  |  | 	if (ret) { | 
					
						
							|  |  |  | 		v4l2_err(&fmd->v4l2_dev, | 
					
						
							|  |  |  | 			 "Failed to register FIMC-ISP (%d)\n", ret); | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fmd->fimc_is = is; | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | static int fimc_md_register_platform_entity(struct fimc_md *fmd, | 
					
						
							|  |  |  | 					    struct platform_device *pdev, | 
					
						
							|  |  |  | 					    int plat_entity) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	struct device *dev = &pdev->dev; | 
					
						
							|  |  |  | 	int ret = -EPROBE_DEFER; | 
					
						
							|  |  |  | 	void *drvdata; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Lock to ensure dev->driver won't change. */ | 
					
						
							|  |  |  | 	device_lock(dev); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!dev->driver || !try_module_get(dev->driver->owner)) | 
					
						
							|  |  |  | 		goto dev_unlock; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	drvdata = dev_get_drvdata(dev); | 
					
						
							|  |  |  | 	/* Some subdev didn't probe succesfully id drvdata is NULL */ | 
					
						
							|  |  |  | 	if (drvdata) { | 
					
						
							|  |  |  | 		switch (plat_entity) { | 
					
						
							|  |  |  | 		case IDX_FIMC: | 
					
						
							|  |  |  | 			ret = register_fimc_entity(fmd, drvdata); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case IDX_FLITE: | 
					
						
							|  |  |  | 			ret = register_fimc_lite_entity(fmd, drvdata); | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 		case IDX_CSIS: | 
					
						
							|  |  |  | 			ret = register_csis_entity(fmd, pdev, drvdata); | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 		case IDX_IS_ISP: | 
					
						
							|  |  |  | 			ret = register_fimc_is_entity(fmd, drvdata); | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			ret = -ENODEV; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	module_put(dev->driver->owner); | 
					
						
							|  |  |  | dev_unlock: | 
					
						
							|  |  |  | 	device_unlock(dev); | 
					
						
							|  |  |  | 	if (ret == -EPROBE_DEFER) | 
					
						
							|  |  |  | 		dev_info(&fmd->pdev->dev, "deferring %s device registration\n", | 
					
						
							|  |  |  | 			dev_name(dev)); | 
					
						
							|  |  |  | 	else if (ret < 0) | 
					
						
							|  |  |  | 		dev_err(&fmd->pdev->dev, "%s device registration failed (%d)\n", | 
					
						
							|  |  |  | 			dev_name(dev), ret); | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int fimc_md_pdev_match(struct device *dev, void *data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct platform_device *pdev = to_platform_device(dev); | 
					
						
							|  |  |  | 	int plat_entity = -1; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 	char *p; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!get_device(dev)) | 
					
						
							|  |  |  | 		return -ENODEV; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!strcmp(pdev->name, CSIS_DRIVER_NAME)) { | 
					
						
							|  |  |  | 		plat_entity = IDX_CSIS; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		p = strstr(pdev->name, "fimc"); | 
					
						
							|  |  |  | 		if (p && *(p + 4) == 0) | 
					
						
							|  |  |  | 			plat_entity = IDX_FIMC; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	if (plat_entity >= 0) | 
					
						
							|  |  |  | 		ret = fimc_md_register_platform_entity(data, pdev, | 
					
						
							|  |  |  | 						       plat_entity); | 
					
						
							|  |  |  | 	put_device(dev); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | /* Register FIMC, FIMC-LITE and CSIS media entities */ | 
					
						
							|  |  |  | #ifdef CONFIG_OF
 | 
					
						
							|  |  |  | static int fimc_md_register_of_platform_entities(struct fimc_md *fmd, | 
					
						
							|  |  |  | 						 struct device_node *parent) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct device_node *node; | 
					
						
							|  |  |  | 	int ret = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for_each_available_child_of_node(parent, node) { | 
					
						
							|  |  |  | 		struct platform_device *pdev; | 
					
						
							|  |  |  | 		int plat_entity = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		pdev = of_find_device_by_node(node); | 
					
						
							|  |  |  | 		if (!pdev) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* If driver of any entity isn't ready try all again later. */ | 
					
						
							|  |  |  | 		if (!strcmp(node->name, CSIS_OF_NODE_NAME)) | 
					
						
							|  |  |  | 			plat_entity = IDX_CSIS; | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 		else if	(!strcmp(node->name, FIMC_IS_OF_NODE_NAME)) | 
					
						
							|  |  |  | 			plat_entity = IDX_IS_ISP; | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 		else if (!strcmp(node->name, FIMC_LITE_OF_NODE_NAME)) | 
					
						
							|  |  |  | 			plat_entity = IDX_FLITE; | 
					
						
							|  |  |  | 		else if	(!strcmp(node->name, FIMC_OF_NODE_NAME) && | 
					
						
							|  |  |  | 			 !of_property_read_bool(node, "samsung,lcd-wb")) | 
					
						
							|  |  |  | 			plat_entity = IDX_FIMC; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (plat_entity >= 0) | 
					
						
							|  |  |  | 			ret = fimc_md_register_platform_entity(fmd, pdev, | 
					
						
							|  |  |  | 							plat_entity); | 
					
						
							|  |  |  | 		put_device(&pdev->dev); | 
					
						
							|  |  |  | 		if (ret < 0) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define fimc_md_register_of_platform_entities(fmd, node) (-ENOSYS)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | static void fimc_md_unregister_entities(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_DEVS; i++) { | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 		struct fimc_dev *dev = fmd->fimc[i]; | 
					
						
							|  |  |  | 		if (dev == NULL) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 		v4l2_device_unregister_subdev(&dev->vid_cap.subdev); | 
					
						
							|  |  |  | 		dev->vid_cap.ve.pipe = NULL; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		fmd->fimc[i] = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) { | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 		struct fimc_lite *dev = fmd->fimc_lite[i]; | 
					
						
							|  |  |  | 		if (dev == NULL) | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 		v4l2_device_unregister_subdev(&dev->subdev); | 
					
						
							|  |  |  | 		dev->ve.pipe = NULL; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		fmd->fimc_lite[i] = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	for (i = 0; i < CSIS_MAX_ENTITIES; i++) { | 
					
						
							|  |  |  | 		if (fmd->csis[i].sd == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		v4l2_device_unregister_subdev(fmd->csis[i].sd); | 
					
						
							|  |  |  | 		fmd->csis[i].sd = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	for (i = 0; i < fmd->num_sensors; i++) { | 
					
						
							|  |  |  | 		if (fmd->sensor[i].subdev == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		fimc_md_unregister_sensor(fmd->sensor[i].subdev); | 
					
						
							|  |  |  | 		fmd->sensor[i].subdev = NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-04-18 09:05:54 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (fmd->fimc_is) | 
					
						
							|  |  |  | 		v4l2_device_unregister_subdev(&fmd->fimc_is->isp.subdev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 08:16:05 -03:00
										 |  |  | 	v4l2_info(&fmd->v4l2_dev, "Unregistered all entities\n"); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * __fimc_md_create_fimc_links - create links to all FIMC entities | 
					
						
							|  |  |  |  * @fmd: fimc media device | 
					
						
							|  |  |  |  * @source: the source entity to create links to all fimc entities from | 
					
						
							|  |  |  |  * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null | 
					
						
							|  |  |  |  * @pad: the source entity pad index | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  |  * @link_mask: bitmask of the fimc devices for which link should be enabled | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, | 
					
						
							|  |  |  | 					    struct media_entity *source, | 
					
						
							|  |  |  | 					    struct v4l2_subdev *sensor, | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 					    int pad, int link_mask) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	struct fimc_source_info *si = NULL; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	struct media_entity *sink; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	unsigned int flags = 0; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 	int i, ret = 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 	if (sensor) { | 
					
						
							|  |  |  | 		si = v4l2_get_subdev_hostdata(sensor); | 
					
						
							|  |  |  | 		/* Skip direct FIMC links in the logical FIMC-IS sensor path */ | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 		if (si && si->fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK) | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 			ret = 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; !ret && i < FIMC_MAX_DEVS; i++) { | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		if (!fmd->fimc[i]) | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * Some FIMC variants are not fitted with camera capture | 
					
						
							|  |  |  | 		 * interface. Skip creating a link from sensor for those. | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (!fmd->fimc[i]->variant->has_cam_if) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 		flags = ((1 << i) & link_mask) ? MEDIA_LNK_FL_ENABLED : 0; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		sink = &fmd->fimc[i]->vid_cap.subdev.entity; | 
					
						
							| 
									
										
										
										
											2011-08-24 20:35:30 -03:00
										 |  |  | 		ret = media_entity_create_link(source, pad, sink, | 
					
						
							| 
									
										
										
										
											2013-03-20 10:44:39 -03:00
										 |  |  | 					      FIMC_SD_PAD_SINK_CAM, flags); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		if (ret) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-24 20:35:30 -03:00
										 |  |  | 		/* Notify FIMC capture subdev entity */ | 
					
						
							|  |  |  | 		ret = media_entity_call(sink, link_setup, &sink->pads[0], | 
					
						
							|  |  |  | 					&source->pads[pad], flags); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-25 05:48:19 -03:00
										 |  |  | 		v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n", | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			  source->name, flags ? '=' : '-', sink->name); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) { | 
					
						
							|  |  |  | 		if (!fmd->fimc_lite[i]) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sink = &fmd->fimc_lite[i]->subdev.entity; | 
					
						
							|  |  |  | 		ret = media_entity_create_link(source, pad, sink, | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 					       FLITE_SD_PAD_SINK, 0); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (ret) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Notify FIMC-LITE subdev entity */ | 
					
						
							|  |  |  | 		ret = media_entity_call(sink, link_setup, &sink->pads[0], | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 					&source->pads[pad], 0); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 		v4l2_info(&fmd->v4l2_dev, "created link [%s] -> [%s]\n", | 
					
						
							|  |  |  | 			  source->name, sink->name); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | /* Create links from FIMC-LITE source pads to other entities */ | 
					
						
							|  |  |  | static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct media_entity *source, *sink; | 
					
						
							| 
									
										
										
										
											2012-12-05 13:43:05 -03:00
										 |  |  | 	int i, ret = 0; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) { | 
					
						
							|  |  |  | 		struct fimc_lite *fimc = fmd->fimc_lite[i]; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (fimc == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		source = &fimc->subdev.entity; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:18 -03:00
										 |  |  | 		sink = &fimc->ve.vdev.entity; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		/* FIMC-LITE's subdev and video node */ | 
					
						
							| 
									
										
										
										
											2012-11-28 15:41:01 -03:00
										 |  |  | 		ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA, | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 					       sink, 0, 0); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		/* Link from FIMC-LITE to IS-ISP subdev */ | 
					
						
							|  |  |  | 		sink = &fmd->fimc_is->isp.subdev.entity; | 
					
						
							|  |  |  | 		ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP, | 
					
						
							|  |  |  | 					       sink, 0, 0); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Create FIMC-IS links */ | 
					
						
							|  |  |  | static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct media_entity *source, *sink; | 
					
						
							|  |  |  | 	int i, ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	source = &fmd->fimc_is->isp.subdev.entity; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_DEVS; i++) { | 
					
						
							|  |  |  | 		if (fmd->fimc[i] == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Link from IS-ISP subdev to FIMC */ | 
					
						
							|  |  |  | 		sink = &fmd->fimc[i]->vid_cap.subdev.entity; | 
					
						
							|  |  |  | 		ret = media_entity_create_link(source, FIMC_ISP_SD_PAD_SRC_FIFO, | 
					
						
							|  |  |  | 					       sink, FIMC_SD_PAD_SINK_FIFO, 0); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * fimc_md_create_links - create default links between registered entities | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Parallel interface sensor entities are connected directly to FIMC capture | 
					
						
							|  |  |  |  * entities. The sensors using MIPI CSIS bus are connected through immutable | 
					
						
							|  |  |  |  * link with CSI receiver entity specified by mux_id. Any registered CSIS | 
					
						
							|  |  |  |  * entity has a link to each registered FIMC capture entity. Enabled links | 
					
						
							|  |  |  |  * are created by default between each subsequent registered sensor and | 
					
						
							|  |  |  |  * subsequent FIMC capture entity. The number of default active links is | 
					
						
							|  |  |  |  * determined by the number of available sensors or FIMC entities, | 
					
						
							|  |  |  |  * whichever is less. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static int fimc_md_create_links(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-05 13:40:04 -03:00
										 |  |  | 	struct v4l2_subdev *csi_sensors[CSIS_MAX_ENTITIES] = { NULL }; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	struct v4l2_subdev *sensor, *csis; | 
					
						
							| 
									
										
										
										
											2013-02-01 15:00:40 -03:00
										 |  |  | 	struct fimc_source_info *pdata; | 
					
						
							| 
									
										
										
										
											2011-08-24 20:35:30 -03:00
										 |  |  | 	struct media_entity *source, *sink; | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 	int i, pad, fimc_id = 0, ret = 0; | 
					
						
							|  |  |  | 	u32 flags, link_mask = 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < fmd->num_sensors; i++) { | 
					
						
							|  |  |  | 		if (fmd->sensor[i].subdev == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sensor = fmd->sensor[i].subdev; | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 		pdata = v4l2_get_subdev_hostdata(sensor); | 
					
						
							|  |  |  | 		if (!pdata) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		source = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-01 15:00:40 -03:00
										 |  |  | 		switch (pdata->sensor_bus_type) { | 
					
						
							|  |  |  | 		case FIMC_BUS_TYPE_MIPI_CSI2: | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			if (WARN(pdata->mux_id >= CSIS_MAX_ENTITIES, | 
					
						
							|  |  |  | 				"Wrong CSI channel id: %d\n", pdata->mux_id)) | 
					
						
							|  |  |  | 				return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			csis = fmd->csis[pdata->mux_id].sd; | 
					
						
							|  |  |  | 			if (WARN(csis == NULL, | 
					
						
							|  |  |  | 				 "MIPI-CSI interface specified " | 
					
						
							|  |  |  | 				 "but s5p-csis module is not loaded!\n")) | 
					
						
							| 
									
										
										
										
											2011-10-20 05:15:59 -03:00
										 |  |  | 				return -EINVAL; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-22 12:13:27 -03:00
										 |  |  | 			pad = sensor->entity.num_pads - 1; | 
					
						
							|  |  |  | 			ret = media_entity_create_link(&sensor->entity, pad, | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 					      &csis->entity, CSIS_PAD_SINK, | 
					
						
							|  |  |  | 					      MEDIA_LNK_FL_IMMUTABLE | | 
					
						
							|  |  |  | 					      MEDIA_LNK_FL_ENABLED); | 
					
						
							|  |  |  | 			if (ret) | 
					
						
							|  |  |  | 				return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-07 16:40:08 -03:00
										 |  |  | 			v4l2_info(&fmd->v4l2_dev, "created link [%s] => [%s]\n", | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 				  sensor->entity.name, csis->entity.name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 			source = NULL; | 
					
						
							| 
									
										
										
										
											2012-08-16 14:06:41 -03:00
										 |  |  | 			csi_sensors[pdata->mux_id] = sensor; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-01 15:00:40 -03:00
										 |  |  | 		case FIMC_BUS_TYPE_ITU_601...FIMC_BUS_TYPE_ITU_656: | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			source = &sensor->entity; | 
					
						
							|  |  |  | 			pad = 0; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			v4l2_err(&fmd->v4l2_dev, "Wrong bus_type: %x\n", | 
					
						
							| 
									
										
										
										
											2013-02-01 15:00:40 -03:00
										 |  |  | 				 pdata->sensor_bus_type); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			return -EINVAL; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (source == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 		link_mask = 1 << fimc_id++; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 						       pad, link_mask); | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-05 13:40:04 -03:00
										 |  |  | 	for (i = 0; i < CSIS_MAX_ENTITIES; i++) { | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		if (fmd->csis[i].sd == NULL) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 		source = &fmd->csis[i].sd->entity; | 
					
						
							|  |  |  | 		pad = CSIS_PAD_SOURCE; | 
					
						
							| 
									
										
										
										
											2012-08-16 14:06:41 -03:00
										 |  |  | 		sensor = csi_sensors[i]; | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 		link_mask = 1 << fimc_id++; | 
					
						
							| 
									
										
										
										
											2012-08-16 14:06:41 -03:00
										 |  |  | 		ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, | 
					
						
							| 
									
										
										
										
											2012-05-16 13:08:30 -03:00
										 |  |  | 						       pad, link_mask); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-27 05:29:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-24 20:35:30 -03:00
										 |  |  | 	/* Create immutable links between each FIMC's subdev and video node */ | 
					
						
							|  |  |  | 	flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED; | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_DEVS; i++) { | 
					
						
							|  |  |  | 		if (!fmd->fimc[i]) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		source = &fmd->fimc[i]->vid_cap.subdev.entity; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:18 -03:00
										 |  |  | 		sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-24 20:35:30 -03:00
										 |  |  | 		ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE, | 
					
						
							|  |  |  | 					      sink, 0, flags); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-27 13:29:48 -03:00
										 |  |  | 	ret = __fimc_md_create_flite_source_links(fmd); | 
					
						
							|  |  |  | 	if (ret < 0) | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (fmd->use_isp) | 
					
						
							|  |  |  | 		ret = __fimc_md_create_fimc_is_links(fmd); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  |  * The peripheral sensor and CAM_BLK (PIXELASYNCMx) clocks management. | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | static void fimc_md_put_clocks(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i = FIMC_MAX_CAMCLKS; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (--i >= 0) { | 
					
						
							|  |  |  | 		if (IS_ERR(fmd->camclk[i].clock)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		clk_put(fmd->camclk[i].clock); | 
					
						
							|  |  |  | 		fmd->camclk[i].clock = ERR_PTR(-EINVAL); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Writeback (PIXELASYNCMx) clocks */ | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_WBCLKS; i++) { | 
					
						
							|  |  |  | 		if (IS_ERR(fmd->wbclk[i])) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		clk_put(fmd->wbclk[i]); | 
					
						
							|  |  |  | 		fmd->wbclk[i] = ERR_PTR(-EINVAL); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | static int fimc_md_get_clocks(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 	struct device *dev = NULL; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	char clk_name[32]; | 
					
						
							|  |  |  | 	struct clk *clock; | 
					
						
							| 
									
										
										
										
											2013-07-19 10:05:17 -03:00
										 |  |  | 	int i, ret = 0; | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_CAMCLKS; i++) | 
					
						
							|  |  |  | 		fmd->camclk[i].clock = ERR_PTR(-EINVAL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (fmd->pdev->dev.of_node) | 
					
						
							|  |  |  | 		dev = &fmd->pdev->dev; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_CAMCLKS; i++) { | 
					
						
							|  |  |  | 		snprintf(clk_name, sizeof(clk_name), "sclk_cam%u", i); | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 		clock = clk_get(dev, clk_name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-18 05:28:40 -03:00
										 |  |  | 		if (IS_ERR(clock)) { | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 			dev_err(&fmd->pdev->dev, "Failed to get clock: %s\n", | 
					
						
							|  |  |  | 								clk_name); | 
					
						
							|  |  |  | 			ret = PTR_ERR(clock); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		fmd->camclk[i].clock = clock; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		fimc_md_put_clocks(fmd); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:43:17 -03:00
										 |  |  | 	if (!fmd->use_isp) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * For now get only PIXELASYNCM1 clock (Writeback B/ISP), | 
					
						
							|  |  |  | 	 * leave PIXELASYNCM0 out for the LCD Writeback driver. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	fmd->wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = CLK_IDX_WB_B; i < FIMC_MAX_WBCLKS; i++) { | 
					
						
							|  |  |  | 		snprintf(clk_name, sizeof(clk_name), "pxl_async%u", i); | 
					
						
							|  |  |  | 		clock = clk_get(dev, clk_name); | 
					
						
							|  |  |  | 		if (IS_ERR(clock)) { | 
					
						
							|  |  |  | 			v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s\n", | 
					
						
							|  |  |  | 				  clk_name); | 
					
						
							|  |  |  | 			ret = PTR_ERR(clock); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		fmd->wbclk[i] = clock; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							|  |  |  | 		fimc_md_put_clocks(fmd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 15:34:37 -03:00
										 |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int __fimc_md_set_camclk(struct fimc_md *fmd, | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 				struct fimc_source_info *si, | 
					
						
							| 
									
										
										
										
											2012-05-17 14:22:10 -03:00
										 |  |  | 				bool on) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct fimc_camclk_info *camclk; | 
					
						
							|  |  |  | 	int ret = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	if (WARN_ON(si->clk_id >= FIMC_MAX_CAMCLKS) || !fmd || !fmd->pmf) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	camclk = &fmd->camclk[si->clk_id]; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-17 14:22:10 -03:00
										 |  |  | 	dbg("camclk %d, f: %lu, use_count: %d, on: %d", | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	    si->clk_id, si->clk_frequency, camclk->use_count, on); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (on) { | 
					
						
							|  |  |  | 		if (camclk->use_count > 0 && | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 		    camclk->frequency != si->clk_frequency) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 			return -EINVAL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (camclk->use_count++ == 0) { | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			clk_set_rate(camclk->clock, si->clk_frequency); | 
					
						
							|  |  |  | 			camclk->frequency = si->clk_frequency; | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 			ret = pm_runtime_get_sync(fmd->pmf); | 
					
						
							|  |  |  | 			if (ret < 0) | 
					
						
							|  |  |  | 				return ret; | 
					
						
							| 
									
										
										
										
											2013-07-19 10:05:17 -03:00
										 |  |  | 			ret = clk_prepare_enable(camclk->clock); | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 			dbg("Enabled camclk %d: f: %lu", si->clk_id, | 
					
						
							| 
									
										
										
										
											2012-05-17 14:22:10 -03:00
										 |  |  | 			    clk_get_rate(camclk->clock)); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (WARN_ON(camclk->use_count == 0)) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (--camclk->use_count == 0) { | 
					
						
							| 
									
										
										
										
											2013-07-19 10:05:17 -03:00
										 |  |  | 		clk_disable_unprepare(camclk->clock); | 
					
						
							| 
									
										
										
										
											2013-03-21 14:47:17 -03:00
										 |  |  | 		pm_runtime_put(fmd->pmf); | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 		dbg("Disabled camclk %d", si->clk_id); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * fimc_md_set_camclk - peripheral sensor clock setup | 
					
						
							|  |  |  |  * @sd: sensor subdev to configure sclk_cam clock for | 
					
						
							|  |  |  |  * @on: 1 to enable or 0 to disable the clock | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * There are 2 separate clock outputs available in the SoC for external | 
					
						
							|  |  |  |  * image processors. These clocks are shared between all registered FIMC | 
					
						
							|  |  |  |  * devices to which sensors can be attached, either directly or through | 
					
						
							|  |  |  |  * the MIPI CSI receiver. The clock is allowed here to be used by | 
					
						
							|  |  |  |  * multiple sensors concurrently if they use same frequency. | 
					
						
							|  |  |  |  * This function should only be called when the graph mutex is held. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	struct fimc_source_info *si = v4l2_get_subdev_hostdata(sd); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	struct fimc_md *fmd = entity_to_fimc_mdev(&sd->entity); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 11:11:58 -03:00
										 |  |  | 	return __fimc_md_set_camclk(fmd, si, on); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct exynos_video_entity *ve; | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	struct fimc_pipeline *p; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	struct video_device *vdev; | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	vdev = media_entity_to_video_device(entity); | 
					
						
							|  |  |  | 	if (vdev->entity.use_count == 0) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	ve = vdev_to_exynos_video_entity(vdev); | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	p = to_fimc_pipeline(ve->pipe); | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Nothing to do if we are disabling the pipeline, some link | 
					
						
							|  |  |  | 	 * has been disconnected and p->subdevs array is cleared now. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	if (!enable && p->subdevs[IDX_SENSOR] == NULL) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	if (enable) | 
					
						
							|  |  |  | 		ret = __fimc_pipeline_open(ve->pipe, entity, true); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		ret = __fimc_pipeline_close(ve->pipe); | 
					
						
							| 
									
										
										
										
											2011-08-24 19:25:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	if (ret == 0 && !enable) | 
					
						
							|  |  |  | 		memset(p->subdevs, 0, sizeof(p->subdevs)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Locking: called with entity->parent->graph_mutex mutex held. */ | 
					
						
							|  |  |  | static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct media_entity *entity_err = entity; | 
					
						
							|  |  |  | 	struct media_entity_graph graph; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Walk current graph and call the pipeline open/close routine for each | 
					
						
							|  |  |  | 	 * opened video node that belongs to the graph of entities connected | 
					
						
							|  |  |  | 	 * through active links. This is needed as we cannot power on/off the | 
					
						
							|  |  |  | 	 * subdevs in random order. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	media_entity_graph_walk_start(&graph, entity); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ((entity = media_entity_graph_walk_next(&graph))) { | 
					
						
							|  |  |  | 		if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ret  = __fimc_md_modify_pipeline(entity, enable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (ret < 0) | 
					
						
							|  |  |  | 			goto err; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  |  err: | 
					
						
							|  |  |  | 	media_entity_graph_walk_start(&graph, entity_err); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ((entity_err = media_entity_graph_walk_next(&graph))) { | 
					
						
							|  |  |  | 		if (media_entity_type(entity_err) != MEDIA_ENT_T_DEVNODE) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		__fimc_md_modify_pipeline(entity_err, !enable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (entity_err == entity) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int fimc_md_link_notify(struct media_link *link, unsigned int flags, | 
					
						
							|  |  |  | 				unsigned int notification) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct media_entity *sink = link->sink->entity; | 
					
						
							|  |  |  | 	int ret = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Before link disconnection */ | 
					
						
							|  |  |  | 	if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { | 
					
						
							|  |  |  | 		if (!(flags & MEDIA_LNK_FL_ENABLED)) | 
					
						
							|  |  |  | 			ret = __fimc_md_modify_pipelines(sink, false); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			; /* TODO: Link state change validation */ | 
					
						
							|  |  |  | 	/* After link activation */ | 
					
						
							|  |  |  | 	} else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && | 
					
						
							|  |  |  | 		   (link->flags & MEDIA_LNK_FL_ENABLED)) { | 
					
						
							|  |  |  | 		ret = __fimc_md_modify_pipelines(sink, true); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-12-06 10:26:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 10:37:27 -03:00
										 |  |  | 	return ret ? -EPIPE : 0; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static ssize_t fimc_md_sysfs_show(struct device *dev, | 
					
						
							|  |  |  | 				  struct device_attribute *attr, char *buf) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct platform_device *pdev = to_platform_device(dev); | 
					
						
							|  |  |  | 	struct fimc_md *fmd = platform_get_drvdata(pdev); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (fmd->user_subdev_api) | 
					
						
							|  |  |  | 		return strlcpy(buf, "Sub-device API (sub-dev)\n", PAGE_SIZE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return strlcpy(buf, "V4L2 video node only API (vid-dev)\n", PAGE_SIZE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static ssize_t fimc_md_sysfs_store(struct device *dev, | 
					
						
							|  |  |  | 				   struct device_attribute *attr, | 
					
						
							|  |  |  | 				   const char *buf, size_t count) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct platform_device *pdev = to_platform_device(dev); | 
					
						
							|  |  |  | 	struct fimc_md *fmd = platform_get_drvdata(pdev); | 
					
						
							|  |  |  | 	bool subdev_api; | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!strcmp(buf, "vid-dev\n")) | 
					
						
							|  |  |  | 		subdev_api = false; | 
					
						
							|  |  |  | 	else if (!strcmp(buf, "sub-dev\n")) | 
					
						
							|  |  |  | 		subdev_api = true; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return count; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fmd->user_subdev_api = subdev_api; | 
					
						
							|  |  |  | 	for (i = 0; i < FIMC_MAX_DEVS; i++) | 
					
						
							|  |  |  | 		if (fmd->fimc[i]) | 
					
						
							|  |  |  | 			fmd->fimc[i]->vid_cap.user_subdev_api = subdev_api; | 
					
						
							|  |  |  | 	return count; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * This device attribute is to select video pipeline configuration method. | 
					
						
							|  |  |  |  * There are following valid values: | 
					
						
							|  |  |  |  *  vid-dev - for V4L2 video node API only, subdevice will be configured | 
					
						
							|  |  |  |  *  by the host driver. | 
					
						
							|  |  |  |  *  sub-dev - for media controller API, subdevs must be configured in user | 
					
						
							|  |  |  |  *  space before starting streaming. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static DEVICE_ATTR(subdev_conf_mode, S_IWUSR | S_IRUGO, | 
					
						
							|  |  |  | 		   fimc_md_sysfs_show, fimc_md_sysfs_store); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 10:41:47 -03:00
										 |  |  | static int fimc_md_get_pinctrl(struct fimc_md *fmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct device *dev = &fmd->pdev->dev; | 
					
						
							|  |  |  | 	struct fimc_pinctrl *pctl = &fmd->pinctl; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pctl->pinctrl = devm_pinctrl_get(dev); | 
					
						
							|  |  |  | 	if (IS_ERR(pctl->pinctrl)) | 
					
						
							|  |  |  | 		return PTR_ERR(pctl->pinctrl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pctl->state_default = pinctrl_lookup_state(pctl->pinctrl, | 
					
						
							|  |  |  | 					PINCTRL_STATE_DEFAULT); | 
					
						
							|  |  |  | 	if (IS_ERR(pctl->state_default)) | 
					
						
							|  |  |  | 		return PTR_ERR(pctl->state_default); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pctl->state_idle = pinctrl_lookup_state(pctl->pinctrl, | 
					
						
							|  |  |  | 					PINCTRL_STATE_IDLE); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | static int fimc_md_probe(struct platform_device *pdev) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	struct device *dev = &pdev->dev; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	struct v4l2_device *v4l2_dev; | 
					
						
							|  |  |  | 	struct fimc_md *fmd; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	fmd = devm_kzalloc(dev, sizeof(*fmd), GFP_KERNEL); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	if (!fmd) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	spin_lock_init(&fmd->slock); | 
					
						
							|  |  |  | 	fmd->pdev = pdev; | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	INIT_LIST_HEAD(&fmd->pipelines); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	strlcpy(fmd->media_dev.model, "SAMSUNG S5P FIMC", | 
					
						
							|  |  |  | 		sizeof(fmd->media_dev.model)); | 
					
						
							|  |  |  | 	fmd->media_dev.link_notify = fimc_md_link_notify; | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	fmd->media_dev.dev = dev; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_dev = &fmd->v4l2_dev; | 
					
						
							|  |  |  | 	v4l2_dev->mdev = &fmd->media_dev; | 
					
						
							| 
									
										
										
										
											2011-06-10 15:36:58 -03:00
										 |  |  | 	v4l2_dev->notify = fimc_sensor_notify; | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	strlcpy(v4l2_dev->name, "s5p-fimc-md", sizeof(v4l2_dev->name)); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-21 14:49:16 -03:00
										 |  |  | 	fmd->use_isp = fimc_md_is_isp_available(dev->of_node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	ret = v4l2_device_register(dev, &fmd->v4l2_dev); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	if (ret < 0) { | 
					
						
							|  |  |  | 		v4l2_err(v4l2_dev, "Failed to register v4l2_device: %d\n", ret); | 
					
						
							| 
									
										
										
										
											2012-01-30 11:37:59 -03:00
										 |  |  | 		return ret; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	ret = media_device_register(&fmd->media_dev); | 
					
						
							|  |  |  | 	if (ret < 0) { | 
					
						
							|  |  |  | 		v4l2_err(v4l2_dev, "Failed to register media device: %d\n", ret); | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		goto err_md; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	ret = fimc_md_get_clocks(fmd); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		goto err_clk; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	fmd->user_subdev_api = (dev->of_node != NULL); | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Protect the media graph while we're registering entities */ | 
					
						
							|  |  |  | 	mutex_lock(&fmd->media_dev.graph_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 10:41:47 -03:00
										 |  |  | 	ret = fimc_md_get_pinctrl(fmd); | 
					
						
							|  |  |  | 	if (ret < 0) { | 
					
						
							|  |  |  | 		if (ret != EPROBE_DEFER) | 
					
						
							|  |  |  | 			dev_err(dev, "Failed to get pinctrl: %d\n", ret); | 
					
						
							|  |  |  | 		goto err_unlock; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 	if (dev->of_node) | 
					
						
							|  |  |  | 		ret = fimc_md_register_of_platform_entities(fmd, dev->of_node); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		ret = bus_for_each_dev(&platform_bus_type, NULL, fmd, | 
					
						
							|  |  |  | 						fimc_md_pdev_match); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		goto err_unlock; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-29 14:12:39 -03:00
										 |  |  | 	if (dev->platform_data || dev->of_node) { | 
					
						
							| 
									
										
										
										
											2011-10-07 07:40:00 -03:00
										 |  |  | 		ret = fimc_md_register_sensor_entities(fmd); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 			goto err_unlock; | 
					
						
							| 
									
										
										
										
											2011-10-07 07:40:00 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	ret = fimc_md_create_links(fmd); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		goto err_unlock; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 		goto err_unlock; | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ret = device_create_file(&pdev->dev, &dev_attr_subdev_conf_mode); | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto err_unlock; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	platform_set_drvdata(pdev, fmd); | 
					
						
							|  |  |  | 	mutex_unlock(&fmd->media_dev.graph_mutex); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | err_unlock: | 
					
						
							|  |  |  | 	mutex_unlock(&fmd->media_dev.graph_mutex); | 
					
						
							|  |  |  | err_clk: | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	fimc_md_put_clocks(fmd); | 
					
						
							|  |  |  | 	fimc_md_unregister_entities(fmd); | 
					
						
							| 
									
										
										
										
											2013-07-29 06:53:59 -03:00
										 |  |  | 	media_device_unregister(&fmd->media_dev); | 
					
						
							| 
									
										
										
										
											2012-04-20 18:57:25 -03:00
										 |  |  | err_md: | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	v4l2_device_unregister(&fmd->v4l2_dev); | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-21 13:17:53 -08:00
										 |  |  | static int fimc_md_remove(struct platform_device *pdev) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct fimc_md *fmd = platform_get_drvdata(pdev); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!fmd) | 
					
						
							|  |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2013-08-09 14:23:53 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	v4l2_device_unregister(&fmd->v4l2_dev); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	device_remove_file(&pdev->dev, &dev_attr_subdev_conf_mode); | 
					
						
							|  |  |  | 	fimc_md_unregister_entities(fmd); | 
					
						
							| 
									
										
										
										
											2013-05-31 11:37:22 -03:00
										 |  |  | 	fimc_md_pipelines_free(fmd); | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	media_device_unregister(&fmd->media_dev); | 
					
						
							|  |  |  | 	fimc_md_put_clocks(fmd); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | static struct platform_device_id fimc_driver_ids[] __always_unused = { | 
					
						
							|  |  |  | 	{ .name = "s5p-fimc-md" }, | 
					
						
							|  |  |  | 	{ }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | MODULE_DEVICE_TABLE(platform, fimc_driver_ids); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const struct of_device_id fimc_md_of_match[] = { | 
					
						
							|  |  |  | 	{ .compatible = "samsung,fimc" }, | 
					
						
							|  |  |  | 	{ }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | MODULE_DEVICE_TABLE(of, fimc_md_of_match); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | static struct platform_driver fimc_md_driver = { | 
					
						
							|  |  |  | 	.probe		= fimc_md_probe, | 
					
						
							| 
									
										
										
										
											2012-12-21 13:17:53 -08:00
										 |  |  | 	.remove		= fimc_md_remove, | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	.driver = { | 
					
						
							| 
									
										
										
										
											2013-03-08 12:59:33 -03:00
										 |  |  | 		.of_match_table = of_match_ptr(fimc_md_of_match), | 
					
						
							|  |  |  | 		.name		= "s5p-fimc-md", | 
					
						
							|  |  |  | 		.owner		= THIS_MODULE, | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-26 11:11:54 -03:00
										 |  |  | static int __init fimc_md_init(void) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	request_module("s5p-csis"); | 
					
						
							|  |  |  | 	ret = fimc_register_driver(); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							|  |  |  | 		return ret; | 
					
						
							| 
									
										
										
										
											2012-03-21 09:58:09 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | 	return platform_driver_register(&fimc_md_driver); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2012-05-26 11:11:54 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void __exit fimc_md_exit(void) | 
					
						
							| 
									
										
										
										
											2011-09-01 06:01:08 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	platform_driver_unregister(&fimc_md_driver); | 
					
						
							|  |  |  | 	fimc_unregister_driver(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module_init(fimc_md_init); | 
					
						
							|  |  |  | module_exit(fimc_md_exit); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>"); | 
					
						
							|  |  |  | MODULE_DESCRIPTION("S5P FIMC camera host interface/video postprocessor driver"); | 
					
						
							|  |  |  | MODULE_LICENSE("GPL"); | 
					
						
							|  |  |  | MODULE_VERSION("2.0.1"); |