Commit 4fd463e9 authored by Sakari Ailus's avatar Sakari Ailus Committed by Hans Verkuil

media: mc: Make media_get_pad_index() use pad type flag

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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 7ab94843
...@@ -730,7 +730,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, ...@@ -730,7 +730,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
MEDIA_LNK_FL_ENABLED, MEDIA_LNK_FL_ENABLED,
false); false);
} else { } else {
pad_sink = media_get_pad_index(tuner, true, pad_sink = media_get_pad_index(tuner, MEDIA_PAD_FL_SINK,
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
if (pad_sink < 0) if (pad_sink < 0)
return -EINVAL; return -EINVAL;
...@@ -748,7 +748,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, ...@@ -748,7 +748,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
if (ntuner && ndemod) { if (ntuner && ndemod) {
/* NOTE: first found tuner source pad presumed correct */ /* 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); PAD_SIGNAL_ANALOG);
if (pad_source < 0) if (pad_source < 0)
return -EINVAL; return -EINVAL;
......
...@@ -1052,25 +1052,19 @@ static void __media_entity_remove_link(struct media_entity *entity, ...@@ -1052,25 +1052,19 @@ static void __media_entity_remove_link(struct media_entity *entity,
kfree(link); 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) enum media_pad_signal_type sig_type)
{ {
int i; unsigned int i;
bool pad_is_sink;
if (!entity) if (!entity)
return -EINVAL; return -EINVAL;
for (i = 0; i < entity->num_pads; i++) { for (i = 0; i < entity->num_pads; i++) {
if (entity->pads[i].flags & MEDIA_PAD_FL_SINK) if ((entity->pads[i].flags &
pad_is_sink = true; (MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_SOURCE)) != pad_type)
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)
continue; continue;
if (entity->pads[i].sig_type == sig_type) if (entity->pads[i].sig_type == sig_type)
return i; return i;
} }
......
...@@ -250,7 +250,7 @@ static void au0828_media_graph_notify(struct media_entity *new, ...@@ -250,7 +250,7 @@ static void au0828_media_graph_notify(struct media_entity *new,
create_link: create_link:
if (decoder && mixer) { if (decoder && mixer) {
ret = media_get_pad_index(decoder, false, ret = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE,
PAD_SIGNAL_AUDIO); PAD_SIGNAL_AUDIO);
if (ret >= 0) if (ret >= 0)
ret = media_create_pad_link(decoder, ret, ret = media_create_pad_link(decoder, ret,
......
...@@ -105,9 +105,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -105,9 +105,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
/* Link the tuner and IF video output pads */ /* Link the tuner and IF video output pads */
if (tuner) { if (tuner) {
if (if_vid) { 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_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); PAD_SIGNAL_ANALOG);
if (pad_source < 0 || pad_sink < 0) { if (pad_source < 0 || pad_sink < 0) {
dev_warn(mdev->dev, "Couldn't get tuner and/or PLL pad(s): (%d, %d)\n", 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) ...@@ -122,9 +124,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
return ret; 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_SIGNAL_ANALOG);
pad_sink = media_get_pad_index(decoder, true, pad_sink = media_get_pad_index(decoder,
MEDIA_PAD_FL_SINK,
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
if (pad_source < 0 || pad_sink < 0) { if (pad_source < 0 || pad_sink < 0) {
dev_warn(mdev->dev, "get decoder and/or PLL pad(s): (%d, %d)\n", 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) ...@@ -139,9 +143,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
return ret; return ret;
} }
} else { } else {
pad_source = media_get_pad_index(tuner, false, pad_source = media_get_pad_index(tuner,
MEDIA_PAD_FL_SOURCE,
PAD_SIGNAL_ANALOG); 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); PAD_SIGNAL_ANALOG);
if (pad_source < 0 || pad_sink < 0) { if (pad_source < 0 || pad_sink < 0) {
dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s): (%d, %d)\n", 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) ...@@ -156,9 +162,11 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
} }
if (if_aud) { 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_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); PAD_SIGNAL_AUDIO);
if (pad_source < 0 || pad_sink < 0) { 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", 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) ...@@ -180,7 +188,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
/* Create demod to V4L, VBI and SDR radio links */ /* Create demod to V4L, VBI and SDR radio links */
if (io_v4l) { 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) { if (pad_source < 0) {
dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n"); dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n");
return -EINVAL; return -EINVAL;
...@@ -195,7 +204,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -195,7 +204,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
} }
if (io_swradio) { 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) { if (pad_source < 0) {
dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n"); dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n");
return -EINVAL; return -EINVAL;
...@@ -210,7 +220,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -210,7 +220,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
} }
if (io_vbi) { 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) { if (pad_source < 0) {
dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n"); dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n");
return -EINVAL; return -EINVAL;
...@@ -231,7 +242,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -231,7 +242,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
case MEDIA_ENT_F_CONN_RF: case MEDIA_ENT_F_CONN_RF:
if (!tuner) if (!tuner)
continue; continue;
pad_sink = media_get_pad_index(tuner, true, pad_sink = media_get_pad_index(tuner, MEDIA_PAD_FL_SINK,
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
if (pad_sink < 0) { if (pad_sink < 0) {
dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); 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) ...@@ -243,7 +254,8 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
break; break;
case MEDIA_ENT_F_CONN_SVIDEO: case MEDIA_ENT_F_CONN_SVIDEO:
case MEDIA_ENT_F_CONN_COMPOSITE: 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); PAD_SIGNAL_ANALOG);
if (pad_sink < 0) { if (pad_sink < 0) {
dev_warn(mdev->dev, "couldn't get decoder analog pad sink\n"); dev_warn(mdev->dev, "couldn't get decoder analog pad sink\n");
......
...@@ -741,7 +741,7 @@ static inline void media_entity_cleanup(struct media_entity *entity) {} ...@@ -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 * media_get_pad_index() - retrieves a pad index from an entity
* *
* @entity: entity where the pads belong * @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 * @sig_type: type of signal of the pad to be search
* *
* This helper function finds the first pad index inside an entity that * 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) {} ...@@ -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 * On success, return the pad number. If the pad was not found or the media
* entity is a NULL pointer, return -EINVAL. * 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); enum media_pad_signal_type sig_type);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment