Lines Matching +full:video +full:- +full:decoder

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Copyright (C) 2006-2010 Nokia Corporation
15 #include <media/media-device.h>
16 #include <media/media-entity.h>
17 #include <media/v4l2-fh.h>
18 #include <media/v4l2-mc.h>
19 #include <media/v4l2-subdev.h>
20 #include <media/videobuf2-core.h>
27 struct media_entity *tuner = NULL, *decoder = NULL; in v4l2_mc_create_media_graph() local
37 switch (entity->function) { in v4l2_mc_create_media_graph()
48 decoder = entity; in v4l2_mc_create_media_graph()
67 dev_warn(mdev->dev, "Didn't find any I/O entity\n"); in v4l2_mc_create_media_graph()
68 return -EINVAL; in v4l2_mc_create_media_graph()
75 * for mc-centric hardware, it is enough for v4l2 interface centric in v4l2_mc_create_media_graph()
76 * PC-consumer's hardware. in v4l2_mc_create_media_graph()
80 dev_warn(mdev->dev, "Didn't find a MEDIA_ENT_F_IO_V4L\n"); in v4l2_mc_create_media_graph()
81 return -EINVAL; in v4l2_mc_create_media_graph()
85 if (entity->function != MEDIA_ENT_F_CAM_SENSOR) in v4l2_mc_create_media_graph()
91 dev_warn(mdev->dev, "Failed to create a sensor link\n"); in v4l2_mc_create_media_graph()
95 if (!decoder) in v4l2_mc_create_media_graph()
99 /* The device isn't a webcam. So, it should have a decoder */ in v4l2_mc_create_media_graph()
100 if (!decoder) { in v4l2_mc_create_media_graph()
101 dev_warn(mdev->dev, "Decoder not found\n"); in v4l2_mc_create_media_graph()
102 return -EINVAL; in v4l2_mc_create_media_graph()
105 /* Link the tuner and IF video output pads */ in v4l2_mc_create_media_graph()
115 dev_warn(mdev->dev, "Couldn't get tuner and/or PLL pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
117 return -EINVAL; in v4l2_mc_create_media_graph()
123 dev_warn(mdev->dev, "Couldn't create tuner->PLL link)\n"); in v4l2_mc_create_media_graph()
130 pad_sink = media_get_pad_index(decoder, in v4l2_mc_create_media_graph()
134 dev_warn(mdev->dev, "get decoder and/or PLL pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
136 return -EINVAL; in v4l2_mc_create_media_graph()
139 decoder, pad_sink, in v4l2_mc_create_media_graph()
142 dev_warn(mdev->dev, "couldn't link PLL to decoder\n"); in v4l2_mc_create_media_graph()
149 pad_sink = media_get_pad_index(decoder, in v4l2_mc_create_media_graph()
153 dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
155 return -EINVAL; in v4l2_mc_create_media_graph()
158 decoder, pad_sink, in v4l2_mc_create_media_graph()
172 dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s) for audio: (%d, %d)\n", in v4l2_mc_create_media_graph()
174 return -EINVAL; in v4l2_mc_create_media_graph()
180 dev_warn(mdev->dev, "couldn't link tuner->audio PLL\n"); in v4l2_mc_create_media_graph()
191 pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE, in v4l2_mc_create_media_graph()
194 dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n"); in v4l2_mc_create_media_graph()
195 return -EINVAL; in v4l2_mc_create_media_graph()
197 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
201 dev_warn(mdev->dev, "couldn't link decoder output to V4L I/O\n"); in v4l2_mc_create_media_graph()
207 pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE, in v4l2_mc_create_media_graph()
210 dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n"); in v4l2_mc_create_media_graph()
211 return -EINVAL; in v4l2_mc_create_media_graph()
213 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
217 dev_warn(mdev->dev, "couldn't link decoder output to SDR\n"); in v4l2_mc_create_media_graph()
223 pad_source = media_get_pad_index(decoder, MEDIA_PAD_FL_SOURCE, in v4l2_mc_create_media_graph()
226 dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n"); in v4l2_mc_create_media_graph()
227 return -EINVAL; in v4l2_mc_create_media_graph()
229 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
233 dev_warn(mdev->dev, "couldn't link decoder output to VBI\n"); in v4l2_mc_create_media_graph()
241 switch (entity->function) { in v4l2_mc_create_media_graph()
248 dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); in v4l2_mc_create_media_graph()
249 return -EINVAL; in v4l2_mc_create_media_graph()
257 pad_sink = media_get_pad_index(decoder, in v4l2_mc_create_media_graph()
261 dev_warn(mdev->dev, "couldn't get decoder analog pad sink\n"); in v4l2_mc_create_media_graph()
262 return -EINVAL; in v4l2_mc_create_media_graph()
264 ret = media_create_pad_link(entity, 0, decoder, in v4l2_mc_create_media_graph()
283 struct media_device *mdev = vdev->entity.graph_obj.mdev; in v4l_enable_media_source()
289 mutex_lock(&mdev->graph_mutex); in v4l_enable_media_source()
290 if (!mdev->enable_source) in v4l_enable_media_source()
292 err = mdev->enable_source(&vdev->entity, &vdev->pipe); in v4l_enable_media_source()
294 ret = -EBUSY; in v4l_enable_media_source()
296 mutex_unlock(&mdev->graph_mutex); in v4l_enable_media_source()
303 struct media_device *mdev = vdev->entity.graph_obj.mdev; in v4l_disable_media_source()
306 mutex_lock(&mdev->graph_mutex); in v4l_disable_media_source()
307 if (mdev->disable_source) in v4l_disable_media_source()
308 mdev->disable_source(&vdev->entity); in v4l_disable_media_source()
309 mutex_unlock(&mdev->graph_mutex); in v4l_disable_media_source()
316 struct v4l2_fh *fh = q->owner; in v4l_vb2q_enable_media_source()
318 if (fh && fh->vdev) in v4l_vb2q_enable_media_source()
319 return v4l_enable_media_source(fh->vdev); in v4l_vb2q_enable_media_source()
329 if (!(sink->flags & MEDIA_PAD_FL_SINK)) in v4l2_create_fwnode_links_to_pad()
330 return -EINVAL; in v4l2_create_fwnode_links_to_pad()
332 fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) { in v4l2_create_fwnode_links_to_pad()
337 src_idx = media_entity_get_fwnode_pad(&src_sd->entity, in v4l2_create_fwnode_links_to_pad()
341 dev_dbg(src_sd->dev, "no source pad found for %pfw\n", in v4l2_create_fwnode_links_to_pad()
348 dev_dbg(src_sd->dev, "no remote ep found for %pfw\n", in v4l2_create_fwnode_links_to_pad()
357 sink_idx = media_entity_get_fwnode_pad(sink->entity, in v4l2_create_fwnode_links_to_pad()
362 if (sink_idx < 0 || sink_idx != sink->index) { in v4l2_create_fwnode_links_to_pad()
363 dev_dbg(src_sd->dev, in v4l2_create_fwnode_links_to_pad()
365 sink_idx, sink->index); in v4l2_create_fwnode_links_to_pad()
377 src = &src_sd->entity.pads[src_idx]; in v4l2_create_fwnode_links_to_pad()
381 dev_dbg(src_sd->dev, in v4l2_create_fwnode_links_to_pad()
382 "link %s:%d -> %s:%d already exists\n", in v4l2_create_fwnode_links_to_pad()
383 src_sd->entity.name, src_idx, in v4l2_create_fwnode_links_to_pad()
384 sink->entity->name, sink_idx); in v4l2_create_fwnode_links_to_pad()
388 dev_dbg(src_sd->dev, "creating link %s:%d -> %s:%d\n", in v4l2_create_fwnode_links_to_pad()
389 src_sd->entity.name, src_idx, in v4l2_create_fwnode_links_to_pad()
390 sink->entity->name, sink_idx); in v4l2_create_fwnode_links_to_pad()
392 ret = media_create_pad_link(&src_sd->entity, src_idx, in v4l2_create_fwnode_links_to_pad()
393 sink->entity, sink_idx, flags); in v4l2_create_fwnode_links_to_pad()
395 dev_err(src_sd->dev, in v4l2_create_fwnode_links_to_pad()
396 "link %s:%d -> %s:%d failed with %d\n", in v4l2_create_fwnode_links_to_pad()
397 src_sd->entity.name, src_idx, in v4l2_create_fwnode_links_to_pad()
398 sink->entity->name, sink_idx, ret); in v4l2_create_fwnode_links_to_pad()
414 for (i = 0; i < sink_sd->entity.num_pads; i++) { in v4l2_create_fwnode_links()
415 struct media_pad *pad = &sink_sd->entity.pads[i]; in v4l2_create_fwnode_links()
418 if (!(pad->flags & MEDIA_PAD_FL_SINK)) in v4l2_create_fwnode_links()
430 /* -----------------------------------------------------------------------------
434 * one open video device node.
437 * For entities corresponding to video device nodes the use_count field stores
439 * use_count field stores the total number of users of all video device nodes
443 * close() handlers of video device nodes. It increments or decrements the use
452 * pipeline_pm_use_count - Count the number of users of a pipeline
455 * Return the total number of users of all video device nodes in the pipeline.
466 use += entity->use_count; in pipeline_pm_use_count()
473 * pipeline_pm_power_one - Apply power change to an entity
491 if (entity->use_count == 0 && change > 0 && subdev != NULL) { in pipeline_pm_power_one()
493 if (ret < 0 && ret != -ENOIOCTLCMD) in pipeline_pm_power_one()
497 entity->use_count += change; in pipeline_pm_power_one()
498 WARN_ON(entity->use_count < 0); in pipeline_pm_power_one()
500 if (entity->use_count == 0 && change < 0 && subdev != NULL) in pipeline_pm_power_one()
507 * pipeline_pm_power - Apply power change to all entities in a pipeline
511 * Walk the pipeline to update the use count and the power state of all non-node
539 pipeline_pm_power_one(first, -change); in pipeline_pm_power()
546 struct media_device *mdev = entity->graph_obj.mdev; in v4l2_pipeline_pm_use()
547 int change = use ? 1 : -1; in v4l2_pipeline_pm_use()
550 mutex_lock(&mdev->graph_mutex); in v4l2_pipeline_pm_use()
553 entity->use_count += change; in v4l2_pipeline_pm_use()
554 WARN_ON(entity->use_count < 0); in v4l2_pipeline_pm_use()
556 /* Apply power change to connected non-nodes. */ in v4l2_pipeline_pm_use()
557 ret = pipeline_pm_power(entity, change, &mdev->pm_count_walk); in v4l2_pipeline_pm_use()
559 entity->use_count -= change; in v4l2_pipeline_pm_use()
561 mutex_unlock(&mdev->graph_mutex); in v4l2_pipeline_pm_use()
582 struct media_graph *graph = &link->graph_obj.mdev->pm_count_walk; in v4l2_pipeline_link_notify()
583 struct media_entity *source = link->source->entity; in v4l2_pipeline_link_notify()
584 struct media_entity *sink = link->sink->entity; in v4l2_pipeline_link_notify()
595 pipeline_pm_power(source, -sink_use, graph); in v4l2_pipeline_link_notify()
596 pipeline_pm_power(sink, -source_use, graph); in v4l2_pipeline_link_notify()
609 pipeline_pm_power(source, -sink_use, graph); in v4l2_pipeline_link_notify()