Commit caf276be authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: v4l2-mc: add print messages when media graph fails

It is not trivial to debug troubles at media graph build.
So, add print messages to help debug what's happening,
in the case of an error occurs.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 9d6d20e6
...@@ -63,8 +63,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -63,8 +63,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
} }
/* It should have at least one I/O entity */ /* It should have at least one I/O entity */
if (!io_v4l && !io_vbi && !io_swradio) if (!io_v4l && !io_vbi && !io_swradio) {
dev_warn(mdev->dev, "Didn't find any I/O entity\n");
return -EINVAL; return -EINVAL;
}
/* /*
* Here, webcams are modelled on a very simple way: the sensor is * Here, webcams are modelled on a very simple way: the sensor is
...@@ -74,8 +76,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -74,8 +76,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
* PC-consumer's hardware. * PC-consumer's hardware.
*/ */
if (is_webcam) { if (is_webcam) {
if (!io_v4l) if (!io_v4l) {
dev_warn(mdev->dev, "Didn't find a MEDIA_ENT_F_IO_V4L\n");
return -EINVAL; return -EINVAL;
}
media_device_for_each_entity(entity, mdev) { media_device_for_each_entity(entity, mdev) {
if (entity->function != MEDIA_ENT_F_CAM_SENSOR) if (entity->function != MEDIA_ENT_F_CAM_SENSOR)
...@@ -83,16 +87,20 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -83,16 +87,20 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
ret = media_create_pad_link(entity, 0, ret = media_create_pad_link(entity, 0,
io_v4l, 0, io_v4l, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "Failed to create a sensor link\n");
return ret; return ret;
} }
}
if (!decoder) if (!decoder)
return 0; return 0;
} }
/* The device isn't a webcam. So, it should have a decoder */ /* The device isn't a webcam. So, it should have a decoder */
if (!decoder) if (!decoder) {
dev_warn(mdev->dev, "Decoder not found\n");
return -EINVAL; return -EINVAL;
}
/* Link the tuner and IF video output pads */ /* Link the tuner and IF video output pads */
if (tuner) { if (tuner) {
...@@ -101,32 +109,45 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -101,32 +109,45 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
pad_sink = media_get_pad_index(if_vid, true, pad_sink = media_get_pad_index(if_vid, true,
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",
pad_source, pad_sink);
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(tuner, pad_source, ret = media_create_pad_link(tuner, pad_source,
if_vid, pad_sink, if_vid, pad_sink,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "Couldn't create tuner->PLL link)\n");
return ret; return ret;
}
pad_source = media_get_pad_index(if_vid, false, pad_source = media_get_pad_index(if_vid, false,
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
pad_sink = media_get_pad_index(decoder, true, pad_sink = media_get_pad_index(decoder, true,
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",
pad_source, pad_sink);
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(if_vid, pad_source, ret = media_create_pad_link(if_vid, pad_source,
decoder, pad_sink, decoder, pad_sink,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "couldn't link PLL to decoder\n");
return ret; return ret;
}
} else { } else {
pad_source = media_get_pad_index(tuner, false, pad_source = media_get_pad_index(tuner, false,
PAD_SIGNAL_ANALOG); PAD_SIGNAL_ANALOG);
pad_sink = media_get_pad_index(decoder, true, pad_sink = media_get_pad_index(decoder, true,
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",
pad_source, pad_sink);
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(tuner, pad_source, ret = media_create_pad_link(tuner, pad_source,
decoder, pad_sink, decoder, pad_sink,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
...@@ -139,13 +160,18 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -139,13 +160,18 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
PAD_SIGNAL_AUDIO); PAD_SIGNAL_AUDIO);
pad_sink = media_get_pad_index(if_aud, true, pad_sink = media_get_pad_index(if_aud, true,
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",
pad_source, pad_sink);
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(tuner, pad_source, ret = media_create_pad_link(tuner, pad_source,
if_aud, pad_sink, if_aud, pad_sink,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "couldn't link tuner->audio PLL\n");
return ret; return ret;
}
} else { } else {
if_aud = tuner; if_aud = tuner;
} }
...@@ -155,36 +181,48 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -155,36 +181,48 @@ 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, false, 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");
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(decoder, pad_source, ret = media_create_pad_link(decoder, pad_source,
io_v4l, 0, io_v4l, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to V4L I/O\n");
return ret; return ret;
} }
}
if (io_swradio) { if (io_swradio) {
pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV);
if (pad_source < 0) if (pad_source < 0) {
dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n");
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(decoder, pad_source, ret = media_create_pad_link(decoder, pad_source,
io_swradio, 0, io_swradio, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to SDR\n");
return ret; return ret;
} }
}
if (io_vbi) { if (io_vbi) {
pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV);
if (pad_source < 0) if (pad_source < 0) {
dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n");
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(decoder, pad_source, ret = media_create_pad_link(decoder, pad_source,
io_vbi, 0, io_vbi, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret) if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to VBI\n");
return ret; return ret;
} }
}
/* Create links for the media connectors */ /* Create links for the media connectors */
flags = MEDIA_LNK_FL_ENABLED; flags = MEDIA_LNK_FL_ENABLED;
...@@ -195,8 +233,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -195,8 +233,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
continue; continue;
pad_sink = media_get_pad_index(tuner, true, pad_sink = media_get_pad_index(tuner, true,
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");
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(entity, 0, tuner, ret = media_create_pad_link(entity, 0, tuner,
pad_sink, pad_sink,
flags); flags);
...@@ -205,8 +245,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ...@@ -205,8 +245,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev)
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, true,
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");
return -EINVAL; return -EINVAL;
}
ret = media_create_pad_link(entity, 0, decoder, ret = media_create_pad_link(entity, 0, decoder,
pad_sink, pad_sink,
flags); flags);
......
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