From f54fb924a93b2e74acc0b7033a4b89d2d7886eb3 Mon Sep 17 00:00:00 2001 From: Srishti Sharma Date: Fri, 8 Sep 2017 11:11:09 -0400 Subject: media: Staging: media: imx: Prefer using BIT macro Use BIT(x) instead of (1< Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index d409170632bd..e5b8d2953be5 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -310,16 +310,16 @@ void imx_media_capture_device_set_format(struct imx_media_video_dev *vdev, void imx_media_capture_device_error(struct imx_media_video_dev *vdev); /* subdev group ids */ -#define IMX_MEDIA_GRP_ID_SENSOR (1 << 8) -#define IMX_MEDIA_GRP_ID_VIDMUX (1 << 9) -#define IMX_MEDIA_GRP_ID_CSI2 (1 << 10) +#define IMX_MEDIA_GRP_ID_SENSOR BIT(8) +#define IMX_MEDIA_GRP_ID_VIDMUX BIT(9) +#define IMX_MEDIA_GRP_ID_CSI2 BIT(10) #define IMX_MEDIA_GRP_ID_CSI_BIT 11 #define IMX_MEDIA_GRP_ID_CSI (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_CSI0 (1 << IMX_MEDIA_GRP_ID_CSI_BIT) +#define IMX_MEDIA_GRP_ID_CSI0 BIT(IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI1 (2 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_VDIC (1 << 13) -#define IMX_MEDIA_GRP_ID_IC_PRP (1 << 14) -#define IMX_MEDIA_GRP_ID_IC_PRPENC (1 << 15) -#define IMX_MEDIA_GRP_ID_IC_PRPVF (1 << 16) +#define IMX_MEDIA_GRP_ID_VDIC BIT(13) +#define IMX_MEDIA_GRP_ID_IC_PRP BIT(14) +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15) +#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(16) #endif -- cgit From 1d88f4bccfd87b6359f11032f2018893d531d18d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 27 Nov 2017 08:20:00 -0500 Subject: media: staging: imx: use ktime_t for timestamps The imx media driver passes around monotonic timestamps in the deprecated 'timespec' format. This is not a problem for the driver, as they won't overflow, but moving to either timespec64 or ktime_t is preferred. I'm picking ktime_t for simplicity here. frame_interval_monitor() is the main function that changes, as it tries to compare a time interval in microseconds. The algorithm slightly changes here, to avoid 64-bit division. The code previously assumed that the error was at most 32-bit worth of microseconds here, so I'm making the same assumption but add an explicit test for it. Signed-off-by: Arnd Bergmann Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index e5b8d2953be5..a5ae0baa5e19 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -280,7 +280,7 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd, /* imx-media-fim.c */ struct imx_media_fim; -void imx_media_fim_eof_monitor(struct imx_media_fim *fim, struct timespec *ts); +void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp); int imx_media_fim_set_stream(struct imx_media_fim *fim, const struct v4l2_fract *frame_interval, bool on); -- cgit From bf3cfaa712e5c396f5fe3b2b2a2ca5dd901de23d Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:39 -0500 Subject: media: staging/imx: get CSI bus type from nearest upstream entity The imx-media driver currently supports a device tree graph of limited complexity. This patch is a first step in allowing imx-media to work with more general OF graphs. The CSI subdevice assumes the originating upstream subdevice (the "sensor") is connected directly to either the CSI mux or the MIPI CSI-2 receiver. But for more complex graphs, the sensor can be distant, with possible bridge entities in between. Thus the sensor's bus type could be quite different from what is entering the CSI. For example a distant sensor could have a parallel interface, but the stream entering the i.MX is MIPI CSI-2. To remove this assumption, get the entering bus config from the entity that is directly upstream from either the CSI mux, or the CSI-2 receiver. If the CSI-2 receiver is not in the enabled pipeline, the bus type to the CSI is parallel, otherwise the CSI is receiving MIPI CSI-2. Note that we can't use the direct upstream source connected to CSI (which is either the CSI mux or the CSI-2 receiver) to determine bus type. The bus entering the CSI from the CSI-2 receiver is a 32-bit parallel bus containing the demultiplexed MIPI CSI-2 virtual channels. But the CSI and its IDMAC channels must be configured based on whether it is receiving data from the CSI-2 receiver or from the CSI mux's parallel interface pins. The function csi_get_upstream_endpoint() is used to find this endpoint. It makes use of a new utility function imx_media_find_upstream_pad(), that if given a grp_id of 0, will return the closest upstream pad from start_entity. With these changes, imx_media_find_sensor() is no longer used and is removed. As a result there is also no longer a need to identify any sensor or set the sensor subdev's group id as a method to search for it. So IMX_MEDIA_GRP_ID_SENSOR is removed. Also the video-mux group id IMX_MEDIA_GRP_ID_VIDMUX was never used so that is removed as well. The remaining IMX_MEDIA_GRP_ID_* definitions are entities internal to the i.MX. Another use of imx_media_find_sensor() in the CSI was to call the sensor's g_skip_frames op to determine if a delay was needed before enabling the CSI at stream on. If necessary this will have to be re-addressed at a later time. Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index a5ae0baa5e19..2cc19da2f1e1 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -158,9 +158,6 @@ struct imx_media_subdev { struct platform_device *pdev; /* the devname is needed for async devname match */ char devname[32]; - - /* if this is a sensor */ - struct v4l2_fwnode_endpoint sensor_ep; }; struct imx_media_dev { @@ -251,16 +248,14 @@ int imx_media_add_video_device(struct imx_media_dev *imxmd, struct imx_media_video_dev *vdev); int imx_media_find_mipi_csi2_channel(struct imx_media_dev *imxmd, struct media_entity *start_entity); +struct media_pad * +imx_media_find_upstream_pad(struct imx_media_dev *imxmd, + struct media_entity *start_entity, + u32 grp_id); struct imx_media_subdev * imx_media_find_upstream_subdev(struct imx_media_dev *imxmd, struct media_entity *start_entity, u32 grp_id); -struct imx_media_subdev * -__imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity); -struct imx_media_subdev * -imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity); struct imx_media_dma_buf { void *virt; @@ -310,16 +305,14 @@ void imx_media_capture_device_set_format(struct imx_media_video_dev *vdev, void imx_media_capture_device_error(struct imx_media_video_dev *vdev); /* subdev group ids */ -#define IMX_MEDIA_GRP_ID_SENSOR BIT(8) -#define IMX_MEDIA_GRP_ID_VIDMUX BIT(9) -#define IMX_MEDIA_GRP_ID_CSI2 BIT(10) -#define IMX_MEDIA_GRP_ID_CSI_BIT 11 +#define IMX_MEDIA_GRP_ID_CSI2 BIT(8) +#define IMX_MEDIA_GRP_ID_CSI_BIT 9 #define IMX_MEDIA_GRP_ID_CSI (0x3 << IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI0 BIT(IMX_MEDIA_GRP_ID_CSI_BIT) #define IMX_MEDIA_GRP_ID_CSI1 (2 << IMX_MEDIA_GRP_ID_CSI_BIT) -#define IMX_MEDIA_GRP_ID_VDIC BIT(13) -#define IMX_MEDIA_GRP_ID_IC_PRP BIT(14) -#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(15) -#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(16) +#define IMX_MEDIA_GRP_ID_VDIC BIT(11) +#define IMX_MEDIA_GRP_ID_IC_PRP BIT(12) +#define IMX_MEDIA_GRP_ID_IC_PRPENC BIT(13) +#define IMX_MEDIA_GRP_ID_IC_PRPVF BIT(14) #endif -- cgit From 621b08eabcddb7a4ed6076dc91324c607be7e6b4 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:40 -0500 Subject: media: staging/imx: remove static media link arrays Remove the static list of media links that were formed at probe time. These links can instead be created after all registered async subdevices have been bound in imx_media_probe_complete(). The media links between subdevices that exist in the device tree, can be created post-async completion by using v4l2_fwnode_parse_link() for each endpoint node of that subdevice. Note this approach assumes device-tree ports are equivalent to media pads (pad index equals port id), and that device-tree endpoints are equivalent to media links between pads. Because links are no longer parsed by imx_media_of_parse(), its sole function is now only to add subdevices that it encounters by walking the OF graph to the async list, so the function has been renamed imx_media_add_of_subdevs(). Similarly, the media links between the IPU-internal subdevice pads (the CSI source pads, and all pads between the vdic, ic-prp, ic-prpenc, and ic-prpvf subdevices), can be created post-async completion by looping through the subdevice's media pads and using the const internal_subdev table. Because links are no longer parsed by imx_media_add_internal_subdevs(), this function no longer needs an array of CSI subdevs to form links from. In summary, the following functions, which were used to form a list of media links at probe time, are removed: imx_media_add_pad_link() add_internal_links() of_add_pad_link() replaced by these functions, called at probe time, which only populate the async subdev list: imx_media_add_of_subdevs() imx_media_add_internal_subdevs() and these functions, called at async completion, which create the media links: imx_media_create_of_links() imx_media_create_csi_of_links() imx_media_create_internal_links() Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 39 +++++++++-------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 2cc19da2f1e1..c05deb42231a 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -35,8 +35,6 @@ #define IMX_MEDIA_MAX_SUBDEVS 32 /* max pads per subdev */ #define IMX_MEDIA_MAX_PADS 16 -/* max links per pad */ -#define IMX_MEDIA_MAX_LINKS 8 /* * Pad definitions for the subdevs with multiple source or @@ -119,19 +117,7 @@ static inline struct imx_media_buffer *to_imx_media_vb(struct vb2_buffer *vb) return container_of(vbuf, struct imx_media_buffer, vbuf); } -struct imx_media_link { - struct device_node *remote_sd_node; - char remote_devname[32]; - int local_pad; - int remote_pad; -}; - struct imx_media_pad { - struct media_pad pad; - struct imx_media_link link[IMX_MEDIA_MAX_LINKS]; - bool devnode; /* does this pad link to a device node */ - int num_links; - /* * list of video devices that can be reached from this pad, * list is only valid for source pads. @@ -154,7 +140,7 @@ struct imx_media_subdev { int num_sink_pads; int num_src_pads; - /* the platform device if this is an internal subdev */ + /* the platform device if this is an IPU-internal subdev */ struct platform_device *pdev; /* the devname is needed for async devname match */ char devname[32]; @@ -225,17 +211,13 @@ struct imx_media_subdev * imx_media_add_async_subdev(struct imx_media_dev *imxmd, struct device_node *np, struct platform_device *pdev); -int imx_media_add_pad_link(struct imx_media_dev *imxmd, - struct imx_media_pad *pad, - struct device_node *remote_node, - const char *remote_devname, - int local_pad, int remote_pad); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id); -int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd, - struct imx_media_subdev *csi[4]); +int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd); +int imx_media_create_internal_links(struct imx_media_dev *imxmd, + struct imx_media_subdev *imxsd); void imx_media_remove_internal_subdevs(struct imx_media_dev *imxmd); struct imx_media_subdev * @@ -284,13 +266,12 @@ struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd); void imx_media_fim_free(struct imx_media_fim *fim); /* imx-media-of.c */ -struct imx_media_subdev * -imx_media_of_find_subdev(struct imx_media_dev *imxmd, - struct device_node *np, - const char *name); -int imx_media_of_parse(struct imx_media_dev *dev, - struct imx_media_subdev *(*csi)[4], - struct device_node *np); +int imx_media_add_of_subdevs(struct imx_media_dev *dev, + struct device_node *np); +int imx_media_create_of_links(struct imx_media_dev *imxmd, + struct imx_media_subdev *imxsd); +int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, + struct imx_media_subdev *csi); /* imx-media-capture.c */ struct imx_media_video_dev * -- cgit From f5abe1c5f9bd3e5a4dad5079f6cd51641f2bf2a3 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:41 -0500 Subject: media: staging/imx: of: allow for recursing downstream Calling of_parse_subdev() recursively to a downstream path that has already been followed is ok, it just means that call will return immediately since the subdevice was already added to the async list. With that there is no need to determine whether a subdevice's port is a sink or source, so 'num_{sink|src}_pads' is no longer used and is removed. Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index c05deb42231a..08e34f9e2f67 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -49,9 +49,6 @@ enum { CSI_NUM_PADS, }; -#define CSI_NUM_SINK_PADS 1 -#define CSI_NUM_SRC_PADS 2 - /* ipu_vdic */ enum { VDIC_SINK_PAD_DIRECT = 0, @@ -60,9 +57,6 @@ enum { VDIC_NUM_PADS, }; -#define VDIC_NUM_SINK_PADS 2 -#define VDIC_NUM_SRC_PADS 1 - /* ipu_ic_prp */ enum { PRP_SINK_PAD = 0, @@ -71,9 +65,6 @@ enum { PRP_NUM_PADS, }; -#define PRP_NUM_SINK_PADS 1 -#define PRP_NUM_SRC_PADS 2 - /* ipu_ic_prpencvf */ enum { PRPENCVF_SINK_PAD = 0, @@ -81,9 +72,6 @@ enum { PRPENCVF_NUM_PADS, }; -#define PRPENCVF_NUM_SINK_PADS 1 -#define PRPENCVF_NUM_SRC_PADS 1 - /* How long to wait for EOF interrupts in the buffer-capture subdevs */ #define IMX_MEDIA_EOF_TIMEOUT 1000 @@ -137,8 +125,6 @@ struct imx_media_subdev { struct v4l2_subdev *sd; /* set when bound */ struct imx_media_pad pad[IMX_MEDIA_MAX_PADS]; - int num_sink_pads; - int num_src_pads; /* the platform device if this is an IPU-internal subdev */ struct platform_device *pdev; -- cgit From 4dadf0562bccfa244511d4e5211c8b81e9934712 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:42 -0500 Subject: media: staging/imx: remove devname string from imx_media_subdev A separate string for the device name, for DEVNAME async match, was never needed. Just assign the asd device name to the passed platform device name pointer in imx_media_add_async_subdev(). Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 08e34f9e2f67..c6cea2746424 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -128,8 +128,6 @@ struct imx_media_subdev { /* the platform device if this is an IPU-internal subdev */ struct platform_device *pdev; - /* the devname is needed for async devname match */ - char devname[32]; }; struct imx_media_dev { -- cgit From 4eef678d32d3d2f5c7e9d6c58f4d78e275638b4f Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:43 -0500 Subject: media: staging/imx: pass fwnode handle to find/add async subdev Pass the subdev's fwnode_handle to imx_media_find_async_subdev() and imx_media_add_async_subdev(), instead of a device_node. Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index c6cea2746424..32ec8d23571d 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -189,11 +189,11 @@ int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, struct imx_media_subdev * imx_media_find_async_subdev(struct imx_media_dev *imxmd, - struct device_node *np, + struct fwnode_handle *fwnode, const char *devname); struct imx_media_subdev * imx_media_add_async_subdev(struct imx_media_dev *imxmd, - struct device_node *np, + struct fwnode_handle *fwnode, struct platform_device *pdev); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, -- cgit From 9f6a0c59eba91c116f6cd7a487f4929faa07a7f8 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Thu, 14 Dec 2017 20:04:44 -0500 Subject: media: staging/imx: remove static subdev arrays For more complex OF graphs, there will be more async subdevices registered. Remove the static subdev[IMX_MEDIA_MAX_SUBDEVS] array, so that imx-media places no limits on the number of async subdevs that can be added and registered. There were two uses for 'struct imx_media_subdev'. First was to act as the async subdev list to be passed to v4l2_async_notifier_register(). Second was to aid in inheriting subdev controls to the capture devices, and this is done by creating a list of capture devices that can be reached from a subdev's source pad. So 'struct imx_media_subdev' also contained a static array of 'struct imx_media_pad' for placing the capture device lists at each pad. 'struct imx_media_subdev' has been completely removed. Instead, at async completion, allocate an array of 'struct imx_media_pad' and attach it to the subdev's host_priv pointer, in order to support subdev controls inheritance. Likewise, remove static async_ptrs[IMX_MEDIA_MAX_SUBDEVS] array. Instead, allocate a 'struct imx_media_async_subdev' when forming the async list, and add it to an asd_list list_head in imx_media_add_async_subdev(). At async completion, allocate the asd pointer list and pull the asd's off asd_list for v4l2_async_notifier_register(). Signed-off-by: Steve Longerbeam Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx-media.h | 81 +++++++++++++++-------------------- 1 file changed, 34 insertions(+), 47 deletions(-) (limited to 'drivers/staging/media/imx/imx-media.h') diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 32ec8d23571d..5089a0d88114 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -11,6 +11,7 @@ #ifndef _IMX_MEDIA_H #define _IMX_MEDIA_H +#include #include #include #include @@ -18,23 +19,8 @@ #include #include