Lines Matching +full:video +full:- +full:related
1 // SPDX-License-Identifier: GPL-2.0-or-later
14 #include <media/v4l2-common.h>
23 * 4 = I2C related
24 * 8 = Bridge related
25 * 16 = IR related
68 int status = -ENODEV; in send_control_msg()
70 if (dev->usbdev) { in send_control_msg()
73 status = usb_control_msg(dev->usbdev, in send_control_msg()
74 usb_sndctrlpipe(dev->usbdev, 0), in send_control_msg()
95 int status = -ENODEV; in recv_control_msg()
96 mutex_lock(&dev->mutex); in recv_control_msg()
97 if (dev->usbdev) { in recv_control_msg()
98 status = usb_control_msg(dev->usbdev, in recv_control_msg()
99 usb_rcvctrlpipe(dev->usbdev, 0), in recv_control_msg()
103 dev->ctrlmsg, size, 1000); in recv_control_msg()
114 memcpy(cp, dev->ctrlmsg, size); in recv_control_msg()
116 mutex_unlock(&dev->mutex); in recv_control_msg()
128 struct media_device *mdev = dev->media_dev; in au0828_unregister_media_device()
131 if (!mdev || !media_devnode_is_registered(mdev->devnode)) in au0828_unregister_media_device()
135 list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) { in au0828_unregister_media_device()
136 if (notify->notify != au0828_media_graph_notify) in au0828_unregister_media_device()
142 mutex_lock(&mdev->graph_mutex); in au0828_unregister_media_device()
143 dev->media_dev->source_priv = NULL; in au0828_unregister_media_device()
144 dev->media_dev->enable_source = NULL; in au0828_unregister_media_device()
145 dev->media_dev->disable_source = NULL; in au0828_unregister_media_device()
146 mutex_unlock(&mdev->graph_mutex); in au0828_unregister_media_device()
148 media_device_delete(dev->media_dev, KBUILD_MODNAME, THIS_MODULE); in au0828_unregister_media_device()
149 dev->media_dev = NULL; in au0828_unregister_media_device()
170 dev->usbdev is NULL, for poll (e.g: IR) try to access in au0828_usb_disconnect()
175 set_bit(DEV_DISCONNECTED, &dev->dev_state); in au0828_usb_disconnect()
182 mutex_lock(&dev->mutex); in au0828_usb_disconnect()
183 dev->usbdev = NULL; in au0828_usb_disconnect()
184 mutex_unlock(&dev->mutex); in au0828_usb_disconnect()
205 dev->media_dev = mdev; in au0828_media_device_init()
224 media_device_for_each_entity(entity, dev->media_dev) { in au0828_media_graph_notify()
225 if (entity->function == MEDIA_ENT_F_AUDIO_MIXER) in au0828_media_graph_notify()
227 else if (entity->function == MEDIA_ENT_F_ATV_DECODER) in au0828_media_graph_notify()
233 switch (new->function) { in au0828_media_graph_notify()
236 if (dev->decoder) in au0828_media_graph_notify()
237 decoder = dev->decoder; in au0828_media_graph_notify()
241 media_device_for_each_entity(entity, dev->media_dev) { in au0828_media_graph_notify()
242 if (entity->function == MEDIA_ENT_F_AUDIO_MIXER) in au0828_media_graph_notify()
260 dev_err(&dev->usbdev->dev, in au0828_media_graph_notify()
270 /* Tuner link can be shared by audio, video, and VBI */ in au0828_is_link_shareable()
271 switch (owner->function) { in au0828_is_link_shareable()
275 if (entity->function == MEDIA_ENT_F_IO_V4L || in au0828_is_link_shareable()
276 entity->function == MEDIA_ENT_F_AUDIO_CAPTURE || in au0828_is_link_shareable()
277 entity->function == MEDIA_ENT_F_IO_VBI) in au0828_is_link_shareable()
295 struct media_device *mdev = entity->graph_obj.mdev; in au0828_enable_source()
299 return -ENODEV; in au0828_enable_source()
301 dev = mdev->source_priv; in au0828_enable_source()
306 * source (tuner/s-video/Composite), if one exists, nothing in au0828_enable_source()
314 if (entity->function == MEDIA_ENT_F_DTV_DEMOD) { in au0828_enable_source()
316 find_source = dev->tuner; in au0828_enable_source()
319 if (!dev->decoder) { in au0828_enable_source()
320 ret = -ENODEV; in au0828_enable_source()
324 sink = dev->decoder; in au0828_enable_source()
343 if (dev->input_type == AU0828_VMUX_TELEVISION) in au0828_enable_source()
344 find_source = dev->tuner; in au0828_enable_source()
345 else if (dev->input_type == AU0828_VMUX_SVIDEO || in au0828_enable_source()
346 dev->input_type == AU0828_VMUX_COMPOSITE) in au0828_enable_source()
347 find_source = &dev->input_ent[dev->input_type]; in au0828_enable_source()
349 /* unknown input - let user select input */ in au0828_enable_source()
356 if (dev->active_link) { in au0828_enable_source()
357 if (dev->active_link_owner == entity) { in au0828_enable_source()
360 * the course of video/vbi application run-time. in au0828_enable_source()
362 pr_debug("%s already owns the tuner\n", entity->name); in au0828_enable_source()
365 } else if (au0828_is_link_shareable(dev->active_link_owner, in au0828_enable_source()
367 /* Either ALSA or Video own tuner. Sink is the same in au0828_enable_source()
375 dev->active_link_shared = true; in au0828_enable_source()
377 dev->active_link_user = entity; in au0828_enable_source()
378 dev->active_link_user_pipe = pipe; in au0828_enable_source()
380 dev->active_link_owner->name, in au0828_enable_source()
381 entity->name); in au0828_enable_source()
385 ret = -EBUSY; in au0828_enable_source()
390 list_for_each_entry(link, &sink->links, list) { in au0828_enable_source()
392 if (link->sink->entity == sink && in au0828_enable_source()
393 link->source->entity == find_source) { in au0828_enable_source()
400 ret = -ENODEV; in au0828_enable_source()
405 source = found_link->source->entity; in au0828_enable_source()
408 pr_err("Activate link from %s->%s. Error %d\n", in au0828_enable_source()
409 source->name, sink->name, ret); in au0828_enable_source()
413 ret = __media_pipeline_start(entity->pads, pipe); in au0828_enable_source()
415 pr_err("Start Pipeline: %s->%s Error %d\n", in au0828_enable_source()
416 source->name, entity->name, ret); in au0828_enable_source()
423 /* save link state to allow audio and video share the link in au0828_enable_source()
427 dev->active_link = found_link; in au0828_enable_source()
428 dev->active_link_owner = entity; in au0828_enable_source()
429 dev->active_source = source; in au0828_enable_source()
430 dev->active_sink = sink; in au0828_enable_source()
432 pr_info("Enabled Source: %s->%s->%s Ret %d\n", in au0828_enable_source()
433 dev->active_source->name, dev->active_sink->name, in au0828_enable_source()
434 dev->active_link_owner->name, ret); in au0828_enable_source()
437 __func__, entity->name, entity->function, ret); in au0828_enable_source()
445 struct media_device *mdev = entity->graph_obj.mdev; in au0828_disable_source()
451 dev = mdev->source_priv; in au0828_disable_source()
453 if (!dev->active_link) in au0828_disable_source()
456 /* link is active - stop pipeline from source in au0828_disable_source()
457 * (tuner/s-video/Composite) to the entity in au0828_disable_source()
458 * When DVB/s-video/Composite owns tuner, it won't be in in au0828_disable_source()
461 if (dev->active_link->sink->entity == dev->active_sink && in au0828_disable_source()
462 dev->active_link->source->entity == dev->active_source) { in au0828_disable_source()
464 * Prevent video from deactivating link when audio in au0828_disable_source()
466 * handle the case when more than one video/vbi in au0828_disable_source()
471 if (dev->active_link_owner->function == in au0828_disable_source()
475 if (dev->active_link_shared) { in au0828_disable_source()
477 dev->active_link_owner->name, in au0828_disable_source()
478 entity->name, dev->users); in au0828_disable_source()
480 /* Handle video device users > 1 in au0828_disable_source()
482 * more than one video users, avoid in au0828_disable_source()
485 * call from video _close(). Use dev->users to in au0828_disable_source()
488 if (dev->active_link_owner != entity) { in au0828_disable_source()
489 /* video device has users > 1 */ in au0828_disable_source()
490 if (owner_is_audio && dev->users > 1) in au0828_disable_source()
493 dev->active_link_user = NULL; in au0828_disable_source()
494 dev->active_link_user_pipe = NULL; in au0828_disable_source()
495 dev->active_link_shared = false; in au0828_disable_source()
499 /* video owns the link and has users > 1 */ in au0828_disable_source()
500 if (!owner_is_audio && dev->users > 1) in au0828_disable_source()
504 __media_pipeline_stop(dev->active_link_owner->pads); in au0828_disable_source()
506 dev->active_link_owner->name); in au0828_disable_source()
509 dev->active_link_user->pads, in au0828_disable_source()
510 dev->active_link_user_pipe); in au0828_disable_source()
512 pr_err("Start Pipeline: %s->%s %d\n", in au0828_disable_source()
513 dev->active_source->name, in au0828_disable_source()
514 dev->active_link_user->name, in au0828_disable_source()
519 dev->active_link_owner = dev->active_link_user; in au0828_disable_source()
520 dev->active_link_user = NULL; in au0828_disable_source()
521 dev->active_link_user_pipe = NULL; in au0828_disable_source()
522 dev->active_link_shared = false; in au0828_disable_source()
525 dev->active_link_owner->name); in au0828_disable_source()
527 } else if (!owner_is_audio && dev->users > 1) in au0828_disable_source()
528 /* video/vbi owns the link and has users > 1 */ in au0828_disable_source()
531 if (dev->active_link_owner != entity) in au0828_disable_source()
535 __media_pipeline_stop(dev->active_link_owner->pads); in au0828_disable_source()
537 dev->active_link_owner->name); in au0828_disable_source()
540 ret = __media_entity_setup_link(dev->active_link, 0); in au0828_disable_source()
544 pr_info("Disabled Source: %s->%s->%s Ret %d\n", in au0828_disable_source()
545 dev->active_source->name, dev->active_sink->name, in au0828_disable_source()
546 dev->active_link_owner->name, ret); in au0828_disable_source()
548 dev->active_link = NULL; in au0828_disable_source()
549 dev->active_link_owner = NULL; in au0828_disable_source()
550 dev->active_source = NULL; in au0828_disable_source()
551 dev->active_sink = NULL; in au0828_disable_source()
552 dev->active_link_shared = false; in au0828_disable_source()
553 dev->active_link_user = NULL; in au0828_disable_source()
566 if (!dev->media_dev) in au0828_media_device_register()
569 if (!media_devnode_is_registered(dev->media_dev->devnode)) { in au0828_media_device_register()
572 ret = media_device_register(dev->media_dev); in au0828_media_device_register()
574 media_device_delete(dev->media_dev, KBUILD_MODNAME, in au0828_media_device_register()
576 dev->media_dev = NULL; in au0828_media_device_register()
577 dev_err(&udev->dev, in au0828_media_device_register()
600 * by video or audio. Note that this step can't be done until dvb in au0828_media_device_register()
603 media_device_for_each_entity(entity, dev->media_dev) { in au0828_media_device_register()
604 switch (entity->function) { in au0828_media_device_register()
606 dev->tuner = entity; in au0828_media_device_register()
609 dev->decoder = entity; in au0828_media_device_register()
617 /* Disable link between tuner->demod and/or tuner->decoder */ in au0828_media_device_register()
618 if (dev->tuner) { in au0828_media_device_register()
619 list_for_each_entry(link, &dev->tuner->links, list) { in au0828_media_device_register()
620 if (demod && link->sink->entity == demod) in au0828_media_device_register()
622 if (dev->decoder && link->sink->entity == dev->decoder) in au0828_media_device_register()
628 dev->entity_notify.notify_data = (void *) dev; in au0828_media_device_register()
629 dev->entity_notify.notify = (void *) au0828_media_graph_notify; in au0828_media_device_register()
630 media_device_register_entity_notify(dev->media_dev, in au0828_media_device_register()
631 &dev->entity_notify); in au0828_media_device_register()
634 mutex_lock(&dev->media_dev->graph_mutex); in au0828_media_device_register()
635 dev->media_dev->source_priv = (void *) dev; in au0828_media_device_register()
636 dev->media_dev->enable_source = au0828_enable_source; in au0828_media_device_register()
637 dev->media_dev->disable_source = au0828_disable_source; in au0828_media_device_register()
638 mutex_unlock(&dev->media_dev->graph_mutex); in au0828_media_device_register()
652 ifnum = interface->altsetting->desc.bInterfaceNumber; in au0828_usb_probe()
655 return -ENODEV; in au0828_usb_probe()
658 le16_to_cpu(usbdev->descriptor.idVendor), in au0828_usb_probe()
659 le16_to_cpu(usbdev->descriptor.idProduct), in au0828_usb_probe()
664 * video stream wouldn't likely work, since 12 Mbps is generally in au0828_usb_probe()
667 if (usbdev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) { in au0828_usb_probe()
669 pr_err("au0828: Device must be connected to a high-speed USB 2.0 port.\n"); in au0828_usb_probe()
670 return -ENODEV; in au0828_usb_probe()
676 return -ENOMEM; in au0828_usb_probe()
679 mutex_init(&dev->lock); in au0828_usb_probe()
680 mutex_lock(&dev->lock); in au0828_usb_probe()
681 mutex_init(&dev->mutex); in au0828_usb_probe()
682 mutex_init(&dev->dvb.lock); in au0828_usb_probe()
683 dev->usbdev = usbdev; in au0828_usb_probe()
684 dev->boardnr = id->driver_info; in au0828_usb_probe()
685 dev->board = au0828_boards[dev->boardnr]; in au0828_usb_probe()
692 mutex_unlock(&dev->lock); in au0828_usb_probe()
700 mutex_unlock(&dev->lock); in au0828_usb_probe()
728 mutex_unlock(&dev->lock); in au0828_usb_probe()
742 dev->board.name == NULL ? "Unset" : dev->board.name); in au0828_usb_probe()
744 mutex_unlock(&dev->lock); in au0828_usb_probe()