From: Liu Ying Date: Tue, 5 Mar 2013 06:54:51 +0000 (+0800) Subject: ENGR00252782 mxc v4l2 capture:Support csi number attribution X-Git-Tag: v3.0.35-fsl~83 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ec1c478eba83abb802cc4592111fd4f528627fbb;p=karo-tx-linux.git ENGR00252782 mxc v4l2 capture:Support csi number attribution 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 --- diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c index 3e9346d356cd..59ba208632e9 100644 --- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c +++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c @@ -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); diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.h b/drivers/media/video/mxc/capture/mxc_v4l2_capture.h index 1431ef919a1c..7edb8d6bd1d3 100644 --- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.h +++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.h @@ -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 */