diff options
author | Guoniu.Zhou <guoniu.zhou@nxp.com> | 2018-04-17 14:48:13 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 640e9431f455fc4c94090b6fd7105cce0e9a05f6 (patch) | |
tree | 05751c72cf1c402339e139d22d5bc1b9f032cbfe /drivers/media/platform | |
parent | 521eb44ea5a5b3ad928fffe7765d389c134d445f (diff) |
MLK-18053: camera: Refine VIDIOC_DBG_G_CHIP_IDENT ioctl
Driver only return camera name for max9286 before, but
the driver is now supporting ov5640. So refine this ioctl
implement and remove max9286 camera driver private data
Reviewed-by: Sandor.yu <sandor.yu@nxp.com>
Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r-- | drivers/media/platform/imx8/max9286.c | 79 | ||||
-rw-r--r-- | drivers/media/platform/imx8/max9286.h | 89 | ||||
-rw-r--r-- | drivers/media/platform/imx8/mxc-isi-cap.c | 57 | ||||
-rw-r--r-- | drivers/media/platform/imx8/mxc-mipi-csi2.c | 2 | ||||
-rw-r--r-- | drivers/media/platform/imx8/mxc-parallel-csi.c | 2 |
5 files changed, 114 insertions, 115 deletions
diff --git a/drivers/media/platform/imx8/max9286.c b/drivers/media/platform/imx8/max9286.c index 4c929cd6f6f2..3f9baa4d7483 100644 --- a/drivers/media/platform/imx8/max9286.c +++ b/drivers/media/platform/imx8/max9286.c @@ -24,7 +24,6 @@ #include <linux/regulator/consumer.h> #include <media/v4l2-subdev.h> -#include "max9286.h" #define MAX9271_MAX_SENSOR_NUM 4 #define CAMERA_USES_15HZ @@ -32,9 +31,87 @@ #define ADDR_MAX9286 0x6A #define ADDR_MAX9271 0x40 #define ADDR_MAX9271_ALL (ADDR_MAX9271 + 5) /* Broadcast address */ + +#define MIPI_CSI2_SENS_VC0_PAD_SOURCE 0 +#define MIPI_CSI2_SENS_VC1_PAD_SOURCE 1 +#define MIPI_CSI2_SENS_VC2_PAD_SOURCE 2 +#define MIPI_CSI2_SENS_VC3_PAD_SOURCE 3 +#define MIPI_CSI2_SENS_VCX_PADS_NUM 4 + +#define MAX_FPS 30 +#define MIN_FPS 30 +#define DEFAULT_FPS 30 + #define ADDR_OV_SENSOR 0x30 #define ADDR_AP_SENSOR 0x5D +/*! + * Maintains the information on the current state of the sesor. + */ +struct imxdpu_videomode { + char name[64]; /* may not be needed */ + + uint32_t pixelclock; /* Hz */ + + /* htotal (pixels) = hlen + hfp + hsync + hbp */ + uint32_t hlen; + uint32_t hfp; + uint32_t hbp; + uint32_t hsync; + + /* field0 - vtotal (lines) = vlen + vfp + vsync + vbp */ + uint32_t vlen; + uint32_t vfp; + uint32_t vbp; + uint32_t vsync; + + /* field1 */ + uint32_t vlen1; + uint32_t vfp1; + uint32_t vbp1; + uint32_t vsync1; + + uint32_t flags; + + uint32_t format; + uint32_t dest_format; /*buffer format for capture*/ + + int16_t clip_top; + int16_t clip_left; + uint16_t clip_width; + uint16_t clip_height; +}; + +struct sensor_data { + struct v4l2_subdev subdev; + struct media_pad pads[MIPI_CSI2_SENS_VCX_PADS_NUM]; + struct i2c_client *i2c_client; + struct v4l2_mbus_framefmt format; + struct v4l2_captureparm streamcap; + char running; + + /* control settings */ + int brightness; + int hue; + int contrast; + int saturation; + int red; + int green; + int blue; + int ae_mode; + + u32 mclk; + u8 mclk_source; + struct clk *sensor_clk; + int v_channel; + bool is_mipi; + struct imxdpu_videomode cap_mode; + + unsigned int sensor_num; /* sensor num connect max9271 */ + unsigned char sensor_is_there; /* Bit 0~3 for 4 cameras, 0b1= is there; 0b0 = is not there */ + int pwn_gpio; +}; + static unsigned int g_max9286_width = 1280; static unsigned int g_max9286_height = 800; diff --git a/drivers/media/platform/imx8/max9286.h b/drivers/media/platform/imx8/max9286.h deleted file mode 100644 index 6acfee73ce41..000000000000 --- a/drivers/media/platform/imx8/max9286.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2017 NXP - */ -/* - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later. - */ - -#ifndef __MAX9286_H__ -#define __MAX9286_H__ - -#define MIPI_CSI2_SENS_VC0_PAD_SOURCE 0 -#define MIPI_CSI2_SENS_VC1_PAD_SOURCE 1 -#define MIPI_CSI2_SENS_VC2_PAD_SOURCE 2 -#define MIPI_CSI2_SENS_VC3_PAD_SOURCE 3 -#define MIPI_CSI2_SENS_VCX_PADS_NUM 4 - -#define MAX_FPS 30 -#define MIN_FPS 30 -#define DEFAULT_FPS 30 - -/*! - * Maintains the information on the current state of the sesor. - */ -struct imxdpu_videomode { - char name[64]; /* may not be needed */ - - uint32_t pixelclock; /* Hz */ - - /* htotal (pixels) = hlen + hfp + hsync + hbp */ - uint32_t hlen; - uint32_t hfp; - uint32_t hbp; - uint32_t hsync; - - /* field0 - vtotal (lines) = vlen + vfp + vsync + vbp */ - uint32_t vlen; - uint32_t vfp; - uint32_t vbp; - uint32_t vsync; - - /* field1 */ - uint32_t vlen1; - uint32_t vfp1; - uint32_t vbp1; - uint32_t vsync1; - - uint32_t flags; - - uint32_t format; - uint32_t dest_format; /*buffer format for capture*/ - - int16_t clip_top; - int16_t clip_left; - uint16_t clip_width; - uint16_t clip_height; - -}; -struct sensor_data { - struct v4l2_subdev subdev; - struct media_pad pads[MIPI_CSI2_SENS_VCX_PADS_NUM]; - struct i2c_client *i2c_client; - struct v4l2_mbus_framefmt format; - struct v4l2_captureparm streamcap; - char running; - - /* control settings */ - int brightness; - int hue; - int contrast; - int saturation; - int red; - int green; - int blue; - int ae_mode; - - u32 mclk; - u8 mclk_source; - struct clk *sensor_clk; - int v_channel; - bool is_mipi; - struct imxdpu_videomode cap_mode; - - unsigned int sensor_num; /* sensor num connect max9271 */ - unsigned char sensor_is_there; /* Bit 0~3 for 4 cameras, 0b1= is there; 0b0 = is not there */ - int pwn_gpio; -}; -#endif diff --git a/drivers/media/platform/imx8/mxc-isi-cap.c b/drivers/media/platform/imx8/mxc-isi-cap.c index c2419c11a16d..c92c1128c915 100644 --- a/drivers/media/platform/imx8/mxc-isi-cap.c +++ b/drivers/media/platform/imx8/mxc-isi-cap.c @@ -19,6 +19,7 @@ #include <linux/pm_runtime.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/of_graph.h> #include <linux/videodev2.h> #include <media/v4l2-device.h> @@ -31,7 +32,6 @@ #include "mxc-isi-core.h" #include "mxc-isi-hw.h" #include "mxc-media-dev.h" -#include "max9286.h" struct mxc_isi_fmt mxc_isi_out_formats[] = { { @@ -968,42 +968,49 @@ static int mxc_isi_cap_s_selection(struct file *file, void *fh, return 0; } -static struct v4l2_subdev *mxc_isi_get_subdev_by_name(struct v4l2_device *v4l2, - const char *name) -{ - struct v4l2_subdev *sd; - bool found = false; - - list_for_each_entry(sd, &v4l2->subdevs, list) { - if (strstr(sd->name, name) != NULL) { - found = true; - break; - } - } - - return (found) ? sd : NULL; -} - static int mxc_isi_cap_g_chip_ident(struct file *file, void *fb, struct v4l2_dbg_chip_ident *chip) { + struct device_node *local, *remote, *endpoint; struct mxc_isi_dev *mxc_isi = video_drvdata(file); - struct v4l2_device *v4l2_dev = mxc_isi->isi_cap.sd.v4l2_dev; struct video_device *vdev = video_devdata(file); - struct sensor_data *max9286; struct v4l2_subdev *sd; + struct media_pad *source_pad; + + source_pad = mxc_isi_get_remote_source_pad(mxc_isi); + if (source_pad == NULL) { + v4l2_err(mxc_isi->v4l2_dev, "%s, No remote pad found!\n", __func__); + return -EINVAL; + } - sd = mxc_isi_get_subdev_by_name(v4l2_dev, "max9286_mipi"); + /* Get remote source pad subdev */ + sd = media_entity_to_v4l2_subdev(source_pad->entity); if (sd == NULL) { - v4l2_err(&mxc_isi->isi_cap.sd, "Can't find sub device\n"); + v4l2_err(mxc_isi->v4l2_dev, "%s, No remote subdev found!\n", __func__); + return -EINVAL; + } + + local = dev_of_node(sd->dev); + if (!local) { + v4l2_err(mxc_isi->v4l2_dev, "%s, Get device node fail\n", __func__); return -ENODEV; } - max9286 = container_of(sd, struct sensor_data, subdev); - if (max9286->sensor_is_there & (0x1 << vdev->num)) - sprintf(chip->match.name, "max9286_mipi%d\n", vdev->num); - else + endpoint = of_graph_get_endpoint_by_regs(local, -1, -1); + if (!endpoint) { + v4l2_err(mxc_isi->v4l2_dev, "%s, No %s endpoint\n", + __func__, local->name); return -ENODEV; + } + + remote = of_graph_get_remote_port_parent(endpoint); + if (!remote) { + v4l2_err(mxc_isi->v4l2_dev, "%s No remote port for %s\n", + __func__, endpoint->name); + return -ENODEV; + } + + sprintf(chip->match.name, "imx8_%s_%d", remote->name, vdev->num); return 0; } diff --git a/drivers/media/platform/imx8/mxc-mipi-csi2.c b/drivers/media/platform/imx8/mxc-mipi-csi2.c index 7972b06c27b4..a236bbbe541e 100644 --- a/drivers/media/platform/imx8/mxc-mipi-csi2.c +++ b/drivers/media/platform/imx8/mxc-mipi-csi2.c @@ -706,6 +706,8 @@ static int mipi_csi2_probe(struct platform_device *pdev) csi2dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; csi2dev->sd.entity.function = MEDIA_ENT_F_IO_V4L; + csi2dev->sd.dev = dev; + csi2dev->pads[MXC_MIPI_CSI2_VC0_PAD_SINK].flags = MEDIA_PAD_FL_SINK; csi2dev->pads[MXC_MIPI_CSI2_VC1_PAD_SINK].flags = MEDIA_PAD_FL_SINK; csi2dev->pads[MXC_MIPI_CSI2_VC2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; diff --git a/drivers/media/platform/imx8/mxc-parallel-csi.c b/drivers/media/platform/imx8/mxc-parallel-csi.c index fcd59f140253..3fde853832bf 100644 --- a/drivers/media/platform/imx8/mxc-parallel-csi.c +++ b/drivers/media/platform/imx8/mxc-parallel-csi.c @@ -548,6 +548,8 @@ static int mxc_parallel_csi_probe(struct platform_device *pdev) pcsidev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pcsidev->sd.entity.function = MEDIA_ENT_F_IO_V4L; + pcsidev->sd.dev = dev; + pcsidev->pads[MXC_PARALLEL_CSI_PAD_SINK].flags = MEDIA_PAD_FL_SINK; pcsidev->pads[MXC_PARALLEL_CSI_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; |