[media] s5p-fimc: Remove sensor management code from FIMC capture driver
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Tue, 26 Jul 2011 21:29:50 +0000 (18:29 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 6 Sep 2011 18:21:06 +0000 (15:21 -0300)
The sensor subdevs need to be shared between all available FIMC instances.
Remove their registration from FIMC capture driver so they can then be
registered to the media device driver.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/s5p-fimc/fimc-capture.c
drivers/media/video/s5p-fimc/fimc-core.h

index b786c2c5fe2a86f909bb272f8d92b317b824a372..40f3330869d43ae63acb1a9ac92b46f022a2ed78 100644 (file)
 #include <linux/bug.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
-#include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/list.h>
 #include <linux/slab.h>
-#include <linux/clk.h>
-#include <linux/i2c.h>
 
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
 
 #include "fimc-core.h"
 
-static struct v4l2_subdev *fimc_subdev_register(struct fimc_dev *fimc,
-                                           struct s5p_fimc_isp_info *isp_info)
-{
-       struct i2c_adapter *i2c_adap;
-       struct fimc_vid_cap *vid_cap = &fimc->vid_cap;
-       struct v4l2_subdev *sd = NULL;
-
-       i2c_adap = i2c_get_adapter(isp_info->i2c_bus_num);
-       if (!i2c_adap)
-               return ERR_PTR(-ENOMEM);
-
-       sd = v4l2_i2c_new_subdev_board(&vid_cap->v4l2_dev, i2c_adap,
-                                      isp_info->board_info, NULL);
-       if (!sd) {
-               v4l2_err(&vid_cap->v4l2_dev, "failed to acquire subdev\n");
-               return NULL;
-       }
-
-       v4l2_info(&vid_cap->v4l2_dev, "subdevice %s registered successfuly\n",
-               isp_info->board_info->type);
-
-       return sd;
-}
-
-static void fimc_subdev_unregister(struct fimc_dev *fimc)
-{
-       struct fimc_vid_cap *vid_cap = &fimc->vid_cap;
-       struct i2c_client *client;
-
-       if (vid_cap->input_index < 0)
-               return; /* Subdevice already released or not registered. */
-
-       if (vid_cap->sd) {
-               v4l2_device_unregister_subdev(vid_cap->sd);
-               client = v4l2_get_subdevdata(vid_cap->sd);
-               i2c_unregister_device(client);
-               i2c_put_adapter(client->adapter);
-               vid_cap->sd = NULL;
-       }
-
-       vid_cap->input_index = -1;
-}
-
-/**
- * fimc_subdev_attach - attach v4l2_subdev to camera host interface
- *
- * @fimc: FIMC device information
- * @index: index to the array of available subdevices,
- *        -1 for full array search or non negative value
- *        to select specific subdevice
- */
-static int fimc_subdev_attach(struct fimc_dev *fimc, int index)
-{
-       struct fimc_vid_cap *vid_cap = &fimc->vid_cap;
-       struct s5p_platform_fimc *pdata = fimc->pdata;
-       struct s5p_fimc_isp_info *isp_info;
-       struct v4l2_subdev *sd;
-       int i;
-
-       for (i = 0; i < pdata->num_clients; ++i) {
-               isp_info = &pdata->isp_info[i];
-
-               if (index >= 0 && i != index)
-                       continue;
-
-               sd = fimc_subdev_register(fimc, isp_info);
-               if (!IS_ERR_OR_NULL(sd)) {
-                       vid_cap->sd = sd;
-                       vid_cap->input_index = i;
-
-                       return 0;
-               }
-       }
-
-       vid_cap->input_index = -1;
-       vid_cap->sd = NULL;
-       v4l2_err(&vid_cap->v4l2_dev, "fimc%d: sensor attach failed\n",
-                fimc->id);
-       return -ENODEV;
-}
-
-static int fimc_isp_subdev_init(struct fimc_dev *fimc, unsigned int index)
-{
-       struct s5p_fimc_isp_info *isp_info;
-       struct s5p_platform_fimc *pdata = fimc->pdata;
-       int ret;
-
-       if (index >= pdata->num_clients)
-               return -EINVAL;
-
-       isp_info = &pdata->isp_info[index];
-
-       if (isp_info->clk_frequency)
-               clk_set_rate(fimc->clock[CLK_CAM], isp_info->clk_frequency);
-
-       ret = clk_enable(fimc->clock[CLK_CAM]);
-       if (ret)
-               return ret;
-
-       ret = fimc_subdev_attach(fimc, index);
-       if (ret)
-               return ret;
-
-       ret = fimc_hw_set_camera_polarity(fimc, isp_info);
-       if (ret)
-               return ret;
-
-       ret = v4l2_subdev_call(fimc->vid_cap.sd, core, s_power, 1);
-       if (!ret)
-               return ret;
-
-       /* enabling power failed so unregister subdev */
-       fimc_subdev_unregister(fimc);
-
-       v4l2_err(&fimc->vid_cap.v4l2_dev, "ISP initialization failed: %d\n",
-                ret);
-
-       return ret;
-}
-
 static void fimc_capture_state_cleanup(struct fimc_dev *fimc)
 {
        struct fimc_vid_cap *cap = &fimc->vid_cap;
@@ -411,15 +288,7 @@ static int fimc_capture_open(struct file *file)
        if (ret)
                return ret;
 
-       if (++fimc->vid_cap.refcnt == 1) {
-               ret = fimc_isp_subdev_init(fimc, 0);
-               if (ret) {
-                       pm_runtime_put_sync(&fimc->pdev->dev);
-                       fimc->vid_cap.refcnt--;
-                       return -EIO;
-               }
-       }
-
+       ++fimc->vid_cap.refcnt;
        file->private_data = fimc->vid_cap.ctx;
 
        return 0;
@@ -434,12 +303,6 @@ static int fimc_capture_close(struct file *file)
        if (--fimc->vid_cap.refcnt == 0) {
                fimc_stop_capture(fimc);
                vb2_queue_release(&fimc->vid_cap.vbq);
-
-               v4l2_err(&fimc->vid_cap.v4l2_dev, "releasing ISP\n");
-
-               v4l2_subdev_call(fimc->vid_cap.sd, core, s_power, 0);
-               clk_disable(fimc->clock[CLK_CAM]);
-               fimc_subdev_unregister(fimc);
        }
 
        pm_runtime_put(&fimc->pdev->dev);
index d82bff8c4d1636220e879593ac34a6c99c96b038..a0d6f81272d93929ddad9fe8b8a16fd8405aa579 100644 (file)
@@ -11,6 +11,7 @@
 
 /*#define DEBUG*/
 
+#include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
@@ -649,7 +650,6 @@ int fimc_register_m2m_device(struct fimc_dev *fimc);
 /* fimc-capture.c                                      */
 int fimc_register_capture_device(struct fimc_dev *fimc);
 void fimc_unregister_capture_device(struct fimc_dev *fimc);
-int fimc_sensor_sd_init(struct fimc_dev *fimc, int index);
 int fimc_vid_cap_buf_queue(struct fimc_dev *fimc,
                             struct fimc_vid_buffer *fimc_vb);
 int fimc_capture_suspend(struct fimc_dev *fimc);