From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, tomi.valkeinen@ideasonboard.com,
bingbu.cao@intel.com
Subject: Re: [PATCH 1/3] media: mc: Make media_get_pad_index() use pad type flag
Date: Sat, 6 May 2023 14:25:21 +0300 [thread overview]
Message-ID: <20230506112521.GA17474@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230505205101.54569-2-sakari.ailus@linux.intel.com>
Hi Sakari,
Thank you for the patch.
On Fri, May 05, 2023 at 11:50:59PM +0300, Sakari Ailus wrote:
> Use the pad flag specifying the pad type instead of a boolean in
> preparation for internal source pads.
>
> Also make the loop variable unsigned.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/dvb-core/dvbdev.c | 4 +--
> drivers/media/mc/mc-entity.c | 16 ++++-------
> drivers/media/usb/au0828/au0828-core.c | 2 +-
> drivers/media/v4l2-core/v4l2-mc.c | 38 +++++++++++++++++---------
> include/media/media-entity.h | 4 +--
> 5 files changed, 35 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 0ed087caf7f3..0091b5375e45 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -707,7 +707,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
> MEDIA_LNK_FL_ENABLED,
> false);
> } else {
> - pad_sink = media_get_pad_index(tuner, true,
> + pad_sink = media_get_pad_index(tuner, MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_sink < 0)
> return -EINVAL;
> @@ -725,7 +725,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
>
> if (ntuner && ndemod) {
> /* NOTE: first found tuner source pad presumed correct */
> - pad_source = media_get_pad_index(tuner, false,
> + pad_source = media_get_pad_index(tuner, MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_ANALOG);
> if (pad_source < 0)
> return -EINVAL;
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index e7216a985ba6..ef34ddd715c9 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -1052,25 +1052,19 @@ static void __media_entity_remove_link(struct media_entity *entity,
> kfree(link);
> }
>
> -int media_get_pad_index(struct media_entity *entity, bool is_sink,
> +int media_get_pad_index(struct media_entity *entity, u32 pad_type,
> enum media_pad_signal_type sig_type)
> {
> - int i;
> - bool pad_is_sink;
> + unsigned int i;
>
> if (!entity)
> return -EINVAL;
>
> for (i = 0; i < entity->num_pads; i++) {
> - if (entity->pads[i].flags & MEDIA_PAD_FL_SINK)
> - pad_is_sink = true;
> - else if (entity->pads[i].flags & MEDIA_PAD_FL_SOURCE)
> - pad_is_sink = false;
> - else
> - continue; /* This is an error! */
> -
> - if (pad_is_sink != is_sink)
> + if ((entity->pads[i].flags &
> + (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE)) != pad_type)
> continue;
> +
> if (entity->pads[i].sig_type == sig_type)
> return i;
> }
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index b3a09d3ac7d2..1e246b47766d 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -250,7 +250,7 @@ static void au0828_media_graph_notify(struct media_entity *new,
>
> create_link:
> if (decoder && mixer) {
> - ret = media_get_pad_index(decoder, false,
> + ret = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_AUDIO);
> if (ret >= 0)
> ret = media_create_pad_link(decoder, ret,
> diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
> index bf0c18100664..209a7efd08fe 100644
> --- a/drivers/media/v4l2-core/v4l2-mc.c
> +++ b/drivers/media/v4l2-core/v4l2-mc.c
> @@ -105,9 +105,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> /* Link the tuner and IF video output pads */
> if (tuner) {
> if (if_vid) {
> - pad_source = media_get_pad_index(tuner, false,
> + pad_source = media_get_pad_index(tuner,
> + MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_ANALOG);
> - pad_sink = media_get_pad_index(if_vid, true,
> + pad_sink = media_get_pad_index(if_vid,
> + MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_source < 0 || pad_sink < 0) {
> dev_warn(mdev->dev, "Couldn't get tuner and/or PLL pad(s): (%d, %d)\n",
> @@ -122,9 +124,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> return ret;
> }
>
> - pad_source = media_get_pad_index(if_vid, false,
> + pad_source = media_get_pad_index(if_vid,
> + MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_ANALOG);
> - pad_sink = media_get_pad_index(decoder, true,
> + pad_sink = media_get_pad_index(decoder,
> + MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_source < 0 || pad_sink < 0) {
> dev_warn(mdev->dev, "get decoder and/or PLL pad(s): (%d, %d)\n",
> @@ -139,9 +143,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> return ret;
> }
> } else {
> - pad_source = media_get_pad_index(tuner, false,
> + pad_source = media_get_pad_index(tuner,
> + MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_ANALOG);
> - pad_sink = media_get_pad_index(decoder, true,
> + pad_sink = media_get_pad_index(decoder,
> + MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_source < 0 || pad_sink < 0) {
> dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s): (%d, %d)\n",
> @@ -156,9 +162,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> }
>
> if (if_aud) {
> - pad_source = media_get_pad_index(tuner, false,
> + pad_source = media_get_pad_index(tuner,
> + MEDIA_PAD_FL_SOURCE,
> PAD_SIGNAL_AUDIO);
> - pad_sink = media_get_pad_index(if_aud, true,
> + pad_sink = media_get_pad_index(if_aud,
> + MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_AUDIO);
> if (pad_source < 0 || pad_sink < 0) {
> dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s) for audio: (%d, %d)\n",
> @@ -180,7 +188,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
>
> /* Create demod to V4L, VBI and SDR radio links */
> if (io_v4l) {
> - pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV);
> + pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE,
> + PAD_SIGNAL_DV);
> if (pad_source < 0) {
> dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n");
> return -EINVAL;
> @@ -195,7 +204,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> }
>
> if (io_swradio) {
> - pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV);
> + pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE,
> + PAD_SIGNAL_DV);
> if (pad_source < 0) {
> dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n");
> return -EINVAL;
> @@ -210,7 +220,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> }
>
> if (io_vbi) {
> - pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV);
> + pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE,
> + PAD_SIGNAL_DV);
> if (pad_source < 0) {
> dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n");
> return -EINVAL;
> @@ -231,7 +242,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> case MEDIA_ENT_F_CONN_RF:
> if (!tuner)
> continue;
> - pad_sink = media_get_pad_index(tuner, true,
> + pad_sink = media_get_pad_index(tuner, MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_sink < 0) {
> dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n");
> @@ -243,7 +254,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
> break;
> case MEDIA_ENT_F_CONN_SVIDEO:
> case MEDIA_ENT_F_CONN_COMPOSITE:
> - pad_sink = media_get_pad_index(decoder, true,
> + pad_sink = media_get_pad_index(decoder,
> + MEDIA_PAD_FL_SINK,
> PAD_SIGNAL_ANALOG);
> if (pad_sink < 0) {
> dev_warn(mdev->dev, "couldn't get decoder analog pad sink\n");
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 741f9c629c6f..e4f556911c3f 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -741,7 +741,7 @@ static inline void media_entity_cleanup(struct media_entity *entity) {}
> * media_get_pad_index() - retrieves a pad index from an entity
> *
> * @entity: entity where the pads belong
> - * @is_sink: true if the pad is a sink, false if it is a source
> + * @pad_type: the type of the pad, one of MEDIA_PAD_FL_* pad types
> * @sig_type: type of signal of the pad to be search
> *
> * This helper function finds the first pad index inside an entity that
> @@ -752,7 +752,7 @@ static inline void media_entity_cleanup(struct media_entity *entity) {}
> * On success, return the pad number. If the pad was not found or the media
> * entity is a NULL pointer, return -EINVAL.
> */
> -int media_get_pad_index(struct media_entity *entity, bool is_sink,
> +int media_get_pad_index(struct media_entity *entity, u32 pad_type,
> enum media_pad_signal_type sig_type);
>
> /**
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-05-06 11:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 20:50 [PATCH 0/3] Random cleanups Sakari Ailus
2023-05-05 20:50 ` [PATCH 1/3] media: mc: Make media_get_pad_index() use pad type flag Sakari Ailus
2023-05-06 11:25 ` Laurent Pinchart [this message]
2023-05-05 20:51 ` [PATCH 2/3] media: Documentation: Rename meta format files Sakari Ailus
2023-05-06 11:25 ` Laurent Pinchart
2023-05-05 20:51 ` [PATCH 3/3] media: uapi: Use unsigned int values for assigning bits in u32 fields Sakari Ailus
2023-05-06 11:32 ` Laurent Pinchart
2023-05-08 6:19 ` Sakari Ailus
2023-05-08 6:30 ` Laurent Pinchart
2023-05-08 6:58 ` Sakari Ailus
2023-05-08 7:52 ` Laurent Pinchart
2023-05-08 8:34 ` Sakari Ailus
-- strict thread matches above, loose matches on Subject: below --
2023-05-08 9:17 [PATCH v2 0/3] Random cleanups Sakari Ailus
2023-05-08 9:17 ` [PATCH 1/3] media: mc: Make media_get_pad_index() use pad type flag Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230506112521.GA17474@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=bingbu.cao@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox