]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00252782 mxc v4l2 capture:Support csi number attribution
authorLiu Ying <Ying.Liu@freescale.com>
Tue, 5 Mar 2013 06:54:51 +0000 (14:54 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:57 +0000 (08:35 +0200)
This patch adds device attribution for video device to
show csi number to userspace. The pattern is in "ipux_csix"
fashion, which tells which ipu and csi is relevant to a
specific video device. In this way, userspace may figure
out different cameras even if they have the same type,
especially, android may use this to know back/front
cameras.

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
drivers/media/video/mxc/capture/mxc_v4l2_capture.c
drivers/media/video/mxc/capture/mxc_v4l2_capture.h

index 3e9346d356cdf94de50c72ed9c5a58ecd0b20c6c..59ba208632e9ae2fa370fb11ed995b679233a11e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -2643,6 +2643,7 @@ static void init_camera_struct(cam_data *cam, struct platform_device *pdev)
        cam->win.w.left = 0;
        cam->win.w.top = 0;
 
+       cam->ipu_id = pdata->ipu;
        cam->csi = pdata->csi;
        cam->mclk_source = pdata->mclk_source;
        cam->mclk_on[cam->mclk_source] = false;
@@ -2687,6 +2688,17 @@ static ssize_t show_overlay(struct device *dev,
 }
 static DEVICE_ATTR(fsl_v4l2_overlay_property, S_IRUGO, show_overlay, NULL);
 
+static ssize_t show_csi(struct device *dev,
+                       struct device_attribute *attr, char *buf)
+{
+       struct video_device *video_dev = container_of(dev,
+                                               struct video_device, dev);
+       cam_data *cam = video_get_drvdata(video_dev);
+
+       return sprintf(buf, "ipu%d_csi%d\n", cam->ipu_id, cam->csi);
+}
+static DEVICE_ATTR(fsl_csi_property, S_IRUGO, show_csi, NULL);
+
 /*!
  * This function is called to probe the devices if registered.
  *
@@ -2732,6 +2744,11 @@ static int mxc_v4l2_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "Error on creating sysfs file"
                        " for overlay\n");
 
+       if (device_create_file(&cam->video_dev->dev,
+                       &dev_attr_fsl_csi_property))
+               dev_err(&pdev->dev, "Error on creating sysfs file"
+                       " for csi number\n");
+
        return 0;
 }
 
@@ -2755,6 +2772,8 @@ static int mxc_v4l2_remove(struct platform_device *pdev)
                        &dev_attr_fsl_v4l2_capture_property);
                device_remove_file(&cam->video_dev->dev,
                        &dev_attr_fsl_v4l2_overlay_property);
+               device_remove_file(&cam->video_dev->dev,
+                       &dev_attr_fsl_csi_property);
 
                pr_info("V4L2 freeing image input device\n");
                v4l2_int_device_unregister(cam->self);
index 1431ef919a1c54e42607d16e75865480ae37bf5a..7edb8d6bd1d3dc34150a7586d5b6211a272051a1 100644 (file)
@@ -198,6 +198,7 @@ typedef struct _cam_data {
        int capture_pid;
        bool low_power;
        wait_queue_head_t power_queue;
+       unsigned int ipu_id;
        unsigned int csi;
        u8 mclk_source;
        bool mclk_on[2];        /* two mclk sources at most now */