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()
113 dev_warn(mdev->dev, "Couldn't get tuner and/or PLL pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
115 return -EINVAL; in v4l2_mc_create_media_graph()
121 dev_warn(mdev->dev, "Couldn't create tuner->PLL link)\n"); in v4l2_mc_create_media_graph()
127 pad_sink = media_get_pad_index(decoder, true, in v4l2_mc_create_media_graph()
130 dev_warn(mdev->dev, "get decoder and/or PLL pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
132 return -EINVAL; in v4l2_mc_create_media_graph()
135 decoder, pad_sink, in v4l2_mc_create_media_graph()
138 dev_warn(mdev->dev, "couldn't link PLL to decoder\n"); in v4l2_mc_create_media_graph()
144 pad_sink = media_get_pad_index(decoder, true, in v4l2_mc_create_media_graph()
147 dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s): (%d, %d)\n", in v4l2_mc_create_media_graph()
149 return -EINVAL; in v4l2_mc_create_media_graph()
152 decoder, pad_sink, in v4l2_mc_create_media_graph()
164 dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s) for audio: (%d, %d)\n", in v4l2_mc_create_media_graph()
166 return -EINVAL; in v4l2_mc_create_media_graph()
172 dev_warn(mdev->dev, "couldn't link tuner->audio PLL\n"); in v4l2_mc_create_media_graph()
183 pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); in v4l2_mc_create_media_graph()
185 dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n"); in v4l2_mc_create_media_graph()
186 return -EINVAL; in v4l2_mc_create_media_graph()
188 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
192 dev_warn(mdev->dev, "couldn't link decoder output to V4L I/O\n"); in v4l2_mc_create_media_graph()
198 pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); in v4l2_mc_create_media_graph()
200 dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n"); in v4l2_mc_create_media_graph()
201 return -EINVAL; in v4l2_mc_create_media_graph()
203 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
207 dev_warn(mdev->dev, "couldn't link decoder output to SDR\n"); in v4l2_mc_create_media_graph()
213 pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); in v4l2_mc_create_media_graph()
215 dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n"); in v4l2_mc_create_media_graph()
216 return -EINVAL; in v4l2_mc_create_media_graph()
218 ret = media_create_pad_link(decoder, pad_source, in v4l2_mc_create_media_graph()
222 dev_warn(mdev->dev, "couldn't link decoder output to VBI\n"); in v4l2_mc_create_media_graph()
230 switch (entity->function) { in v4l2_mc_create_media_graph()
237 dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); in v4l2_mc_create_media_graph()
238 return -EINVAL; in v4l2_mc_create_media_graph()
246 pad_sink = media_get_pad_index(decoder, true, in v4l2_mc_create_media_graph()
249 dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); in v4l2_mc_create_media_graph()
250 return -EINVAL; in v4l2_mc_create_media_graph()
252 ret = media_create_pad_link(entity, 0, decoder, in v4l2_mc_create_media_graph()
271 struct media_device *mdev = vdev->entity.graph_obj.mdev; in v4l_enable_media_source()
277 mutex_lock(&mdev->graph_mutex); in v4l_enable_media_source()
278 if (!mdev->enable_source) in v4l_enable_media_source()
280 err = mdev->enable_source(&vdev->entity, &vdev->pipe); in v4l_enable_media_source()
282 ret = -EBUSY; in v4l_enable_media_source()
284 mutex_unlock(&mdev->graph_mutex); in v4l_enable_media_source()
291 struct media_device *mdev = vdev->entity.graph_obj.mdev; in v4l_disable_media_source()
294 mutex_lock(&mdev->graph_mutex); in v4l_disable_media_source()
295 if (mdev->disable_source) in v4l_disable_media_source()
296 mdev->disable_source(&vdev->entity); in v4l_disable_media_source()
297 mutex_unlock(&mdev->graph_mutex); in v4l_disable_media_source()
304 struct v4l2_fh *fh = q->owner; in v4l_vb2q_enable_media_source()
306 if (fh && fh->vdev) in v4l_vb2q_enable_media_source()
307 return v4l_enable_media_source(fh->vdev); in v4l_vb2q_enable_media_source()
318 if (!(sink->flags & MEDIA_PAD_FL_SINK) || in v4l2_create_fwnode_links_to_pad()
319 !is_media_entity_v4l2_subdev(sink->entity)) in v4l2_create_fwnode_links_to_pad()
320 return -EINVAL; in v4l2_create_fwnode_links_to_pad()
322 sink_sd = media_entity_to_v4l2_subdev(sink->entity); in v4l2_create_fwnode_links_to_pad()
324 fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) { in v4l2_create_fwnode_links_to_pad()
329 src_idx = media_entity_get_fwnode_pad(&src_sd->entity, in v4l2_create_fwnode_links_to_pad()
343 sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity, in v4l2_create_fwnode_links_to_pad()
348 if (sink_idx < 0 || sink_idx != sink->index) in v4l2_create_fwnode_links_to_pad()
359 src = &src_sd->entity.pads[src_idx]; in v4l2_create_fwnode_links_to_pad()
365 dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n", in v4l2_create_fwnode_links_to_pad()
366 src_sd->entity.name, src_idx, in v4l2_create_fwnode_links_to_pad()
367 sink_sd->entity.name, sink_idx); in v4l2_create_fwnode_links_to_pad()
369 ret = media_create_pad_link(&src_sd->entity, src_idx, in v4l2_create_fwnode_links_to_pad()
370 &sink_sd->entity, sink_idx, 0); in v4l2_create_fwnode_links_to_pad()
372 dev_err(sink_sd->dev, in v4l2_create_fwnode_links_to_pad()
373 "link %s:%d -> %s:%d failed with %d\n", in v4l2_create_fwnode_links_to_pad()
374 src_sd->entity.name, src_idx, in v4l2_create_fwnode_links_to_pad()
375 sink_sd->entity.name, sink_idx, ret); in v4l2_create_fwnode_links_to_pad()
391 for (i = 0; i < sink_sd->entity.num_pads; i++) { in v4l2_create_fwnode_links()
392 struct media_pad *pad = &sink_sd->entity.pads[i]; in v4l2_create_fwnode_links()
395 if (!(pad->flags & MEDIA_PAD_FL_SINK)) in v4l2_create_fwnode_links()
407 /* -----------------------------------------------------------------------------
411 * one open video device node.
414 * For entities corresponding to video device nodes the use_count field stores
416 * use_count field stores the total number of users of all video device nodes
420 * close() handlers of video device nodes. It increments or decrements the use
429 * pipeline_pm_use_count - Count the number of users of a pipeline
432 * Return the total number of users of all video device nodes in the pipeline.
443 use += entity->use_count; in pipeline_pm_use_count()
450 * pipeline_pm_power_one - Apply power change to an entity
468 if (entity->use_count == 0 && change > 0 && subdev != NULL) { in pipeline_pm_power_one()
470 if (ret < 0 && ret != -ENOIOCTLCMD) in pipeline_pm_power_one()
474 entity->use_count += change; in pipeline_pm_power_one()
475 WARN_ON(entity->use_count < 0); in pipeline_pm_power_one()
477 if (entity->use_count == 0 && change < 0 && subdev != NULL) in pipeline_pm_power_one()
484 * pipeline_pm_power - Apply power change to all entities in a pipeline
488 * Walk the pipeline to update the use count and the power state of all non-node
516 pipeline_pm_power_one(first, -change); in pipeline_pm_power()
523 struct media_device *mdev = entity->graph_obj.mdev; in v4l2_pipeline_pm_use()
524 int change = use ? 1 : -1; in v4l2_pipeline_pm_use()
527 mutex_lock(&mdev->graph_mutex); in v4l2_pipeline_pm_use()
530 entity->use_count += change; in v4l2_pipeline_pm_use()
531 WARN_ON(entity->use_count < 0); in v4l2_pipeline_pm_use()
533 /* Apply power change to connected non-nodes. */ in v4l2_pipeline_pm_use()
534 ret = pipeline_pm_power(entity, change, &mdev->pm_count_walk); in v4l2_pipeline_pm_use()
536 entity->use_count -= change; in v4l2_pipeline_pm_use()
538 mutex_unlock(&mdev->graph_mutex); in v4l2_pipeline_pm_use()
559 struct media_graph *graph = &link->graph_obj.mdev->pm_count_walk; in v4l2_pipeline_link_notify()
560 struct media_entity *source = link->source->entity; in v4l2_pipeline_link_notify()
561 struct media_entity *sink = link->sink->entity; in v4l2_pipeline_link_notify()
572 pipeline_pm_power(source, -sink_use, graph); in v4l2_pipeline_link_notify()
573 pipeline_pm_power(sink, -source_use, graph); in v4l2_pipeline_link_notify()
586 pipeline_pm_power(source, -sink_use, graph); in v4l2_pipeline_link_notify()