Skip to content
  1. Aug 10, 2023
  2. Jul 28, 2023
    • Sakari Ailus's avatar
      media: v4l: async: Support fwnode endpoint list matching for subdevs · e74f7a96
      Sakari Ailus authored
      
      
      Support matching V4L2 async sub-devices based on particular fwnode
      endpoint. This makes it possible to instantiate multiple V4L2 sub-devices
      based on given fwnode endpoints from a single device, based on driver
      needs.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      e74f7a96
    • Sakari Ailus's avatar
      media: v4l: async: Try more connections · 765f6056
      Sakari Ailus authored
      
      
      When an async sub-device is registered, it used to be that the first one
      of its connections were matched when found. Continue looking for matches
      until a notifier no longer has any.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      765f6056
    • Sakari Ailus's avatar
      media: v4l: async: Drop unneeded list entry initialisation · cb8c9f31
      Sakari Ailus authored
      
      
      The list entry is initialised as a head in v4l2_async_register_subdev()
      just before being added to the list. This isn't needed, drop the
      initialisation.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      cb8c9f31
    • Sakari Ailus's avatar
      media: v4l: async: Allow multiple connections between entities · 28a12957
      Sakari Ailus authored
      
      
      When the v4l2-async framework was introduced, the use case for it was to
      connect a camera sensor with a parallel receiver. Both tended to be rather
      simple devices with a single connection between them.
      
      The framework has been since improved in multiple ways but there are
      limitations that have remained, for instance the assumption an async
      sub-device is connected towards a single notifier and via a single link
      only.
      
      This patch enables connecting a sub-device to one or more notifiers
      simultaneously, with one or more connections per notifier. The notifier
      information is moved from the sub-device to the connection and the
      connections in sub-device are no longer a pointer but a linked list.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      28a12957
    • Sakari Ailus's avatar
      media: v4l: async: Obtain async connection based on sub-device · c91fd7b7
      Sakari Ailus authored
      
      
      Add v4l2_async_connection_unique() function for obtaining a struct
      v4l2_async_connection, typically allocated by drivers together with their
      own information on an external sub-device.
      
      The relation between connections and sub-devices still remains 1:1 but
      this code becomes more complex when the relation soon changes.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      c91fd7b7
    • Sakari Ailus's avatar
      media: v4l: async: Rework internal lists · 9bf19fbf
      Sakari Ailus authored
      
      
      This patch re-arranges internal V4L2 async lists for preparation of
      supporting multiple connections per sub-device as well as cleaning up used
      lists.
      
      The list of unbound V4L2 sub-devices shall be maintained for the purpose of
      listing those sub-devices only, not for their bindin status. Also, the V4L2
      async connections now have, instead of two list entries, a single list
      entry in the notifier's list, be that either waiting or done lists, while
      the notifier's asc_list is removed.
      
      The one-to-one relation between a sub-device and a connection is still
      maintained in this patch.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      9bf19fbf
    • Sakari Ailus's avatar
      media: v4l: async: Drop duplicate handling when adding connections · 393cfcc0
      Sakari Ailus authored
      
      
      The connections are checked for duplicates already when the notifier is
      registered. This is effectively a sanity check for driver (and possibly
      obscure firmware) bugs. Don't do this when adding the connection.
      
      Retain the int return type for now. It'll be needed very soon again.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      393cfcc0
    • Sakari Ailus's avatar
      media: v4l: async: Clean up error handling in v4l2_async_match_notify · ed59bbe1
      Sakari Ailus authored
      
      
      Add labels for error handling instead of doing it all in individual cases.
      Prepare for more functionality in this function.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      ed59bbe1
    • Sakari Ailus's avatar
      media: v4l: async: Rename v4l2_async_subdev as v4l2_async_connection · adb2dcd5
      Sakari Ailus authored
      
      
      Rename v4l2_async_subdev as v4l2_async_connection, in order to
      differentiate between the sub-devices and their connections: one
      sub-device can have many connections but the V4L2 async framework has so
      far allowed just a single one. Connections in this context will later
      translate into either MC ancillary or data links.
      
      This patch prepares changing that relation by changing existing users of
      v4l2_async_subdev to switch to v4l2_async_connection. Async sub-devices
      themselves will not be needed anymore
      
      Additionally, __v4l2_async_nf_add_subdev() has been renamed
      __v4l2_async_nf_add_connection().
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      adb2dcd5
    • Sakari Ailus's avatar
      media: v4l: async: Simplify async sub-device fwnode matching · 1029939b
      Sakari Ailus authored
      
      
      V4L2 async sub-device matching originally used the device nodes only.
      Endpoint nodes were taken into use instead as using the device nodes was
      problematic for it was in some cases ambiguous which link might have been
      in question.
      
      There is however no need to use endpoint nodes on both sides, as the async
      sub-device's fwnode can always be trivially obtained using
      fwnode_graph_get_remote_endpoint() when needed while what counts is
      whether or not the link is between two device nodes, i.e. the device nodes
      match.
      
      This will briefly break the adv748x driver but it will be fixed later in
      the set, by patch "media: adv748x: Return to endpoint matching".
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      1029939b
    • Sakari Ailus's avatar
      media: v4l: async: Clean up list heads and entries · b6d42c35
      Sakari Ailus authored
      
      
      The naming of list heads and list entries is confusing as they're named
      similarly. Use _list for list head and _entry for list entries.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      b6d42c35
    • Sakari Ailus's avatar
      media: v4l: async: Only pass match information for async subdev validation · 9b4d2f37
      Sakari Ailus authored
      
      
      Pass only information required for sub-device matching to functions
      checking whether the async sub-device already exists. Do the same for
      debug message printing. This makes further changes to other aspects of
      async sub-devices easier.
      
      Accordingly, also perform further renames:
      
      	asd_equal as v4l2_async_match_equal,
      	v4l2_async_nf_has_async_subdev as v4l2_async_nf_has_async_match,
      	__v4l2_async_nf_has_async_subdev as
      		v4l2_async_nf_has_async_subdev_entry and
      	v4l2_async_nf_asd_valid as v4l2_async_nf_match_valid.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      9b4d2f37
    • Sakari Ailus's avatar
      media: v4l: async: Rename V4L2_ASYNC_MATCH_ macros, add TYPE_ · 7a2259fc
      Sakari Ailus authored
      
      
      The async match type is a struct field now, rename V4L2_ASYNC_MATCH_*
      macros as V4L2_ASYNC_MATCH_TYPE_* instead.
      
      This patch has been produced by:
      
      git grep -l V4L2_ASYNC_MATCH_ -- drivers/media/ drivers/staging/media/ \
      	include/ Documentation/|xargs perl -i -pe \
      	's/V4L2_ASYNC_MATCH_\K/TYPE_/g'
      
      so it must be correct.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      7a2259fc
    • Sakari Ailus's avatar
      media: v4l: async: Make V4L2 async match information a struct · f0e10d0a
      Sakari Ailus authored
      
      
      Make V4L2 async match information a struct, making it easier to use it
      elsewhere outside the scope of struct v4l2_async_subdev.
      
      Also remove an obsolete comment --- none of these fields are supposed to
      be touched by drivers.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      f0e10d0a
    • Sakari Ailus's avatar
      media: v4l: async: Don't check whether asd is NULL in validity check · 1c5cd3ef
      Sakari Ailus authored
      
      
      The callers do pass a non-NULL asd to v4l2_async_nf_asd_valid() already.
      There's no need for the NULL check here.
      
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
      Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
      Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      1c5cd3ef