media_device_for_each_entity(entity, mdev) { switch (entity->function) { case MEDIA_ENT_F_IF_VID_DECODER:
if_vid = entity; break; case MEDIA_ENT_F_IF_AUD_DECODER:
if_aud = entity; break; case MEDIA_ENT_F_TUNER:
tuner = entity; break; case MEDIA_ENT_F_ATV_DECODER:
decoder = entity; break; case MEDIA_ENT_F_IO_V4L:
io_v4l = entity; break; case MEDIA_ENT_F_IO_VBI:
io_vbi = entity; break; case MEDIA_ENT_F_IO_SWRADIO:
io_swradio = entity; break; case MEDIA_ENT_F_CAM_SENSOR:
is_webcam = true; break;
}
}
/* It should have at least one I/O entity */ if (!io_v4l && !io_vbi && !io_swradio) {
dev_warn(mdev->dev, "Didn't find any I/O entity\n"); return -EINVAL;
}
/* *Here,webcamsaremodelledonaverysimpleway:thesensoris *connecteddirectlytotheI/Oentity.Alldirtydetails,like *scalerandcropHWarehidden.Whilesuchmappingisnotenough *formc-centrichardware,itisenoughforv4l2interfacecentric *PC-consumer'shardware.
*/ if (is_webcam) { if (!io_v4l) {
dev_warn(mdev->dev, "Didn't find a MEDIA_ENT_F_IO_V4L\n"); return -EINVAL;
}
media_device_for_each_entity(entity, mdev) { if (entity->function != MEDIA_ENT_F_CAM_SENSOR) continue;
ret = media_create_pad_link(entity, 0,
io_v4l, 0,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "Failed to create a sensor link\n"); return ret;
}
} if (!decoder) return0;
}
/* The device isn't a webcam. So, it should have a decoder */ if (!decoder) {
dev_warn(mdev->dev, "Decoder not found\n"); return -EINVAL;
}
/* Link the tuner and IF video output pads */ if (tuner) { if (if_vid) {
pad_source = media_get_pad_index(tuner,
MEDIA_PAD_FL_SOURCE,
PAD_SIGNAL_ANALOG);
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",
pad_source, pad_sink); return -EINVAL;
}
ret = media_create_pad_link(tuner, pad_source,
if_vid, pad_sink,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "Couldn't create tuner->PLL link)\n"); return ret;
}
if (if_aud) {
pad_source = media_get_pad_index(tuner,
MEDIA_PAD_FL_SOURCE,
PAD_SIGNAL_AUDIO);
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",
pad_source, pad_sink); return -EINVAL;
}
ret = media_create_pad_link(tuner, pad_source,
if_aud, pad_sink,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "couldn't link tuner->audio PLL\n"); return ret;
}
} else {
if_aud = tuner;
}
}
/* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) {
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;
}
ret = media_create_pad_link(decoder, pad_source,
io_v4l, 0,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to V4L I/O\n"); return ret;
}
}
if (io_swradio) {
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;
}
ret = media_create_pad_link(decoder, pad_source,
io_swradio, 0,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to SDR\n"); return ret;
}
}
if (io_vbi) {
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;
}
ret = media_create_pad_link(decoder, pad_source,
io_vbi, 0,
MEDIA_LNK_FL_ENABLED); if (ret) {
dev_warn(mdev->dev, "couldn't link decoder output to VBI\n"); return ret;
}
}
/* Create links for the media connectors */
flags = MEDIA_LNK_FL_ENABLED;
media_device_for_each_entity(entity, mdev) { switch (entity->function) { case MEDIA_ENT_F_CONN_RF: if (!tuner) continue;
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"); return -EINVAL;
}
ret = media_create_pad_link(entity, 0, tuner,
pad_sink,
flags); break; case MEDIA_ENT_F_CONN_SVIDEO: case MEDIA_ENT_F_CONN_COMPOSITE:
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"); return -EINVAL;
}
ret = media_create_pad_link(entity, 0, decoder,
pad_sink,
flags); break; default: continue;
} if (ret) return ret;
src_idx = media_entity_get_fwnode_pad(&src_sd->entity,
endpoint,
MEDIA_PAD_FL_SOURCE); if (src_idx < 0) {
dev_dbg(src_sd->dev, "no source pad found for %pfw\n",
endpoint); continue;
}
remote_ep = fwnode_graph_get_remote_endpoint(endpoint); if (!remote_ep) {
dev_dbg(src_sd->dev, "no remote ep found for %pfw\n",
endpoint); continue;
}
/* *pipeline_pm_power-Applypowerchangetoallentitiesinapipeline *@entity:Theentity *@change:Usecountchange * *Walkthepipelinetoupdatetheusecountandthepowerstateofallnon-node *entities. * *Return0onsuccessoranegativeerrorcodeonfailure.
*/ staticint pipeline_pm_power(struct media_entity *entity, int change, struct media_graph *graph)
{ struct media_entity *first = entity; int ret = 0;
if (!change) return0;
media_graph_walk_start(graph, entity);
while (!ret && (entity = media_graph_walk_next(graph))) if (is_media_entity_v4l2_subdev(entity))
ret = pipeline_pm_power_one(entity, change);
if (!ret) return ret;
media_graph_walk_start(graph, first);
while ((first = media_graph_walk_next(graph))
&& first != entity) if (is_media_entity_v4l2_subdev(first))
pipeline_pm_power_one(first, -change);
return ret;
}
staticint v4l2_pipeline_pm_use(struct media_entity *entity, unsignedint use)
{ struct media_device *mdev = entity->graph_obj.mdev; int change = use ? 1 : -1; int ret;
mutex_lock(&mdev->graph_mutex);
/* Apply use count to node. */
entity->use_count += change;
WARN_ON(entity->use_count < 0);
/* Apply power change to connected non-nodes. */
ret = pipeline_pm_power(entity, change, &mdev->pm_count_walk); if (ret < 0)
entity->use_count -= change;
mutex_unlock(&mdev->graph_mutex);
return ret;
}
int v4l2_pipeline_pm_get(struct media_entity *entity)
{ return v4l2_pipeline_pm_use(entity, 1);
}
EXPORT_SYMBOL_GPL(v4l2_pipeline_pm_get);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.